[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190325194158.rapwoa3oeqluwcfn@brauner.io>
Date: Mon, 25 Mar 2019 20:41:59 +0100
From: Christian Brauner <christian@...uner.io>
To: Jann Horn <jannh@...gle.com>
Cc: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
Andy Lutomirski <luto@...nel.org>,
David Howells <dhowells@...hat.com>,
"Serge E. Hallyn" <serge@...lyn.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Linux API <linux-api@...r.kernel.org>,
kernel list <linux-kernel@...r.kernel.org>,
Arnd Bergmann <arnd@...db.de>,
Kees Cook <keescook@...omium.org>,
Alexey Dobriyan <adobriyan@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Michael Kerrisk-manpages <mtk.manpages@...il.com>,
bl0pbl33p@...il.com, "Dmitry V. Levin" <ldv@...linux.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Nagarathnam Muthusamy <nagarathnam.muthusamy@...cle.com>,
cyphar@...har.com, Al Viro <viro@...iv.linux.org.uk>,
"Joel Fernandes (Google)" <joel@...lfernandes.org>,
Daniel Colascione <dancol@...gle.com>
Subject: Re: [PATCH 3/4] signal: support pidctl() with pidfd_send_signal()
On Mon, Mar 25, 2019 at 07:39:25PM +0100, Jann Horn wrote:
> On Mon, Mar 25, 2019 at 5:21 PM Christian Brauner <christian@...uner.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"?
Yip, sounds good.
Powered by blists - more mailing lists