From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Brauner Subject: Re: [PATCH 3/4] signal: support pidctl() with pidfd_send_signal() Date: Mon, 25 Mar 2019 20:41:59 +0100 Message-ID: <20190325194158.rapwoa3oeqluwcfn@brauner.io> References: <20190325162052.28987-1-christian@brauner.io> <20190325162052.28987-4-christian@brauner.io> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Jann Horn Cc: Konstantin Khlebnikov , Andy Lutomirski , David Howells , "Serge E. Hallyn" , "Eric W. Biederman" , Linux API , kernel list , Arnd Bergmann , Kees Cook , Alexey Dobriyan , Thomas Gleixner , Michael Kerrisk-manpages , bl0pbl33p@gmail.com, "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy , cyphar@cyphar.com, Al Viro , "Joel Fernandes (Google)" List-Id: linux-api@vger.kernel.org On Mon, Mar 25, 2019 at 07:39:25PM +0100, Jann Horn wrote: > On Mon, Mar 25, 2019 at 5:21 PM Christian Brauner 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.