Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1225198

Re: [PATCH RFC] pidns: introduce syscall getvpid

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC] pidns: introduce syscall getvpid
Date 2015-09-15 16:30 +0200
Message-ID <q8Zpb-7qt-79@gated-at.bofh.it> (permalink)
References <q8XdE-4lR-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 09/15, Konstantin Khlebnikov wrote:
>
> +SYSCALL_DEFINE3(getvpid, pid_t, pid, pid_t, source, pid_t, target)
> +{
> +#ifdef CONFIG_PID_NS
> +	struct pid_namespace *current_ns = task_active_pid_ns(current);
> +	struct pid_namespace *source_ns = current_ns, *target_ns = current_ns;
> +	struct pid *task_pid;
> +	pid_t result = -ESRCH;
> +
> +	rcu_read_lock();
> +	if (source)
> +		source_ns = ns_of_pid(find_pid_ns(source, current_ns));
> +	if (target)
> +		target_ns = ns_of_pid(find_pid_ns(target, current_ns));
> +	if (source_ns && target_ns) {
> +		task_pid = find_pid_ns(pid, source_ns);
> +		if (task_pid)
> +			result = pid_nr_ns(task_pid, target_ns);
> +	}
> +	rcu_read_unlock();
> +
> +	return result;
> +#else
> +	return pid;
> +#endif /* CONFIG_PID_NS */
> +}

Not sure we actually want ifdef(CONFIG_PID_NS). If this is just optimization
I'd suggest to simply add

	if (!IS_ENABLED(CONFIG_PID_NS))
		return pid;

at the start.

But. Either way this unconditional "return pid" doesn't look right imho.
I think we should return -ESRCH if this pid number is not valid to ensure
we have the same semantics with-or-without CONFIG_PID_NS. So it seems that
you should remove this ifdef, this will also ensure that we return -ESRCH
if (say) source != 0 and find_pid_ns(source) fails.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-15 14:10 +0200
  Re: [PATCH RFC] pidns: introduce syscall getvpid Oleg Nesterov <oleg@redhat.com> - 2015-09-15 16:30 +0200
  Re: [PATCH RFC] pidns: introduce syscall getvpid ebiederm@xmission.com (Eric W. Biederman) - 2015-09-15 16:40 +0200
    Re: [PATCH RFC] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-15 17:10 +0200
      Re: [PATCH RFC] pidns: introduce syscall getvpid Stéphane Graber <stgraber@ubuntu.com> - 2015-09-15 17:30 +0200
        Re: [PATCH RFC] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-15 18:10 +0200
        Re: [PATCH RFC] pidns: introduce syscall getvpid Serge Hallyn <serge.hallyn@ubuntu.com> - 2015-09-15 19:50 +0200
          Re: [PATCH RFC] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-16 09:40 +0200
            Re: [PATCH RFC] pidns: introduce syscall getvpid "Serge E. Hallyn" <serge@hallyn.com> - 2015-09-16 16:40 +0200
              Re: [PATCH RFC] pidns: introduce syscall getvpid ebiederm@xmission.com (Eric W. Biederman) - 2015-09-16 17:00 +0200
                Re: [PATCH RFC] pidns: introduce syscall getvpid "Serge E. Hallyn" <serge@hallyn.com> - 2015-09-16 18:40 +0200
                Re: Re: [PATCH RFC] pidns: introduce syscall getvpid Chen Fan <chen.fan.fnst@cn.fujitsu.com> - 2015-09-21 05:00 +0200
                Re: Re: [PATCH RFC] pidns: introduce syscall getvpid "Serge E. Hallyn" <serge@hallyn.com> - 2015-09-21 16:30 +0200
                Re: [PATCH RFC] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-22 09:50 +0200

csiph-web