lkml.org 
[lkml]   [2019]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/4] signal: support pidctl() with pidfd_send_signal()
On Mon, Mar 25, 2019 at 5:21 PM Christian Brauner <christian@brauner.io> wrote:
> Let pidfd_send_signal() use pidfds retrieved via pidctl(). With this patch
> pidfd_send_signal() becomes independent of procfs. This fullfils the
> request made when we merged the pidfd_send_signal() patchset. The
> pidfd_send_signal() syscall is now always available allowing for it to be
> used by users without procfs mounted or even users without procfs support
> compiled into the kernel.
[...]
> static bool access_pidfd_pidns(struct pid *pid)
> {
> + int ret;
> struct pid_namespace *active = task_active_pid_ns(current);
> struct pid_namespace *p = ns_of_pid(pid);
>
> - for (;;) {
> - if (!p)
> - return false;
> - if (p == active)
> - break;
> - p = p->parent;
> - }
> + ret = pidnscmp(active, p);
> + if (ret < 0)
> + return false;
>
> return true;
> }

Nit, if we keep this function: "if (...) return false; return true;"
seems like an antipattern to me. How about "return ret >= 0", or even
"return pidnscmp(active, p) >= 0"?

\
 
 \ /
  Last update: 2019-03-25 19:40    [W:1.714 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site