From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751932AbbCVT20 (ORCPT ); Sun, 22 Mar 2015 15:28:26 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:32770 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751832AbbCVT2Y (ORCPT ); Sun, 22 Mar 2015 15:28:24 -0400 Message-ID: <550F17CE.5080400@gmail.com> Date: Sun, 22 Mar 2015 20:28:14 +0100 From: "Michael Kerrisk (man-pages)" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jann Horn , Mikael Pettersson CC: mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Jeff Dike , Richard Weinberger , Kees Cook , Andy Lutomirski , Will Drewry Subject: Re: [PATCH] seccomp.2: Add note about alarm(2) not being sufficient to limit runtime References: <20150311174204.GA5712@pc.thejh.net> <21760.46870.338764.599348@gargle.gargle.HOWL> <20150312130701.GA11073@pc.thejh.net> In-Reply-To: <20150312130701.GA11073@pc.thejh.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Jann, On 03/12/2015 02:07 PM, Jann Horn wrote: > On Wed, Mar 11, 2015 at 10:43:50PM +0100, Mikael Pettersson wrote: >> Jann Horn writes: >> > Or should I throw this patch away and write a patch >> > for the prctl() manpage instead that documents that >> > being able to call sigreturn() implies being able to >> > effectively call sigprocmask(), at least on some >> > architectures like X86? >> >> Well, that is the semantics of sigreturn(). It is essentially >> setcontext() [which includes the actions of sigprocmask()], but >> with restrictions on parameter placement (at least on x86). >> >> You could introduce some setting to restrict that aspect for >> seccomp processes, but you can't change this for normal processes >> without breaking things. > > Then I think it's probably better and easier to just document the existing > behavior? If a new setting would have to be introduced and developers would > need to be aware of that, it's probably easier to just tell everyone to use > SIGKILL. > > Does this manpage patch look good? Patch applied, with Acks from Andy, Mikael, and Kees (I don't usually get patches whose pedigree is that good. Thanks!) I tweaked a few wordings. You can find the changes in Git [1] Cheers, Michael [1] http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=65be1b46fb88e14f0af494ac6b53a2d6a63bb860 > --- > man2/seccomp.2 | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/man2/seccomp.2 b/man2/seccomp.2 > index 702ceb8..f762d07 100644 > --- a/man2/seccomp.2 > +++ b/man2/seccomp.2 > @@ -64,6 +64,31 @@ Strict secure computing mode is useful for number-crunching > applications that may need to execute untrusted byte code, perhaps > obtained by reading from a pipe or socket. > > +Note that although the calling thread can no longer call > +.BR sigprocmask (2), > +it can use > +.BR sigreturn (2) > +to block all signals apart from > +.BR SIGKILL > +and > +.BR SIGSTOP . > +Therefore, to reliably terminate it, > +.BR SIGKILL > +has to be used, meaning that e.g. > +.BR alarm (2) > +is not sufficient for restricting its runtime. Instead, use > +.BR timer_create (2) > +with > +.BR SIGEV_SIGNAL > +and > +.BR sigev_signo > +set to > +.BR SIGKILL > +or use > +.BR setrlimit (2) > +to set the hard limit for > +.BR RLIMIT_CPU . > + > This operation is available only if the kernel is configured with > .BR CONFIG_SECCOMP > enabled. > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/