From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by smtp.lore.kernel.org (Postfix) with SMTP id 9CE53D75E5A for ; Fri, 22 Nov 2024 14:51:15 +0000 (UTC) Received: (qmail 15683 invoked by uid 550); 22 Nov 2024 14:51:05 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 15657 invoked from network); 22 Nov 2024 14:51:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1732287056; bh=Dw83SL5Y8yup9QeWhRY3Xv+H570yVpAemu+fQwUxJwQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZxPR1yB/99EMPpelBHdCWInnXjSxUxn8CxobKR87WOV/XW8j4P2i/WrLRNt3tk3Pm PwdepQSQuLCaAzIfcdHDKM5tasTYMdPYLpz5ZRscRNi4N8kGaH50/8TPen3EyKDgJ6 Cu2uU2k/vW0zhArwJAuMwtubKMwDV38J+e5CnuqY= Date: Fri, 22 Nov 2024 15:50:56 +0100 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: Mimi Zohar Cc: Al Viro , Christian Brauner , Kees Cook , Paul Moore , Serge Hallyn , Adhemerval Zanella Netto , Alejandro Colomar , Aleksa Sarai , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Casey Schaufler , Christian Heimes , Dmitry Vyukov , Elliott Hughes , Eric Biggers , Eric Chiang , Fan Wu , Florian Weimer , Geert Uytterhoeven , James Morris , Jan Kara , Jann Horn , Jeff Xu , Jonathan Corbet , Jordan R Abrahams , Lakshmi Ramasubramanian , Linus Torvalds , Luca Boccassi , Luis Chamberlain , "Madhavan T . Venkataraman" , Matt Bobrowski , Matthew Garrett , Matthew Wilcox , Miklos Szeredi , Nicolas Bouchinet , Scott Shell , Shuah Khan , Stephen Rothwell , Steve Dower , Steve Grubb , Theodore Ts'o , Thibaut Sautereau , Vincent Strubel , Xiaoming Ni , Yin Fengwei , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v21 6/6] samples/check-exec: Add an enlighten "inc" interpreter and 28 tests Message-ID: <20241122.ahY1pooz1ing@digikod.net> References: <20241112191858.162021-1-mic@digikod.net> <20241112191858.162021-7-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Infomaniak-Routing: alpha On Thu, Nov 21, 2024 at 03:34:47PM -0500, Mimi Zohar wrote: > Hi Mickaël, > > On Tue, 2024-11-12 at 20:18 +0100, Mickaël Salaün wrote: > > > > + > > +/* Returns 1 on error, 0 otherwise. */ > > +static int interpret_stream(FILE *script, char *const script_name, > > + char *const *const envp, const bool restrict_stream) > > +{ > > + int err; > > + char *const script_argv[] = { script_name, NULL }; > > + char buf[128] = {}; > > + size_t buf_size = sizeof(buf); > > + > > + /* > > + * We pass a valid argv and envp to the kernel to emulate a native > > + * script execution. We must use the script file descriptor instead of > > + * the script path name to avoid race conditions. > > + */ > > + err = execveat(fileno(script), "", script_argv, envp, > > + AT_EMPTY_PATH | AT_EXECVE_CHECK); > > At least with v20, the AT_CHECK always was being set, independent of whether > set-exec.c set it. I'll re-test with v21. AT_EXECVE_CEHCK should always be set, only the interpretation of the result should be relative to securebits. This is highlighted in the documentation. > > thanks, > > Mimi > > > + if (err && restrict_stream) { > > + perror("ERROR: Script execution check"); > > + return 1; > > + } > > + > > + /* Reads script. */ > > + buf_size = fread(buf, 1, buf_size - 1, script); > > + return interpret_buffer(buf, buf_size); > > +} > > + > >