From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-42aa.mail.infomaniak.ch (smtp-42aa.mail.infomaniak.ch [84.16.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C101FAC5D for ; Wed, 27 Nov 2024 12:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732709415; cv=none; b=Cmrh3IkTrboFhdtGqYZFgJMvSIq3jTjFe7FwtzNE7QXbETBwqIK4d0o0hDkf204ScmpNy9aAk1VajQ5j4l8Sm0HgYAMgpERiM3FYPxadoLlimRjpyug3ry2LZRT/a6YArSTDHOBcUxpe/UF/vPJm9ADcmBIu4YIrQD4zyAIpedU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732709415; c=relaxed/simple; bh=iL9L2yvqBC7QBxFr60b9hN1d56U3FPt5NB22f54JlZE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TrP2XYegD5nZLER49m4i4f/1wT3XQhfjwoqTkxKQx0pF6WvSRJtyrS+hzTkRYAUqEmylnR+EwMhoKwVSSj3NlCq8lhjnM3tDyuXFaKUseHMi12IAVd7pTLmdgQHaPgNJIfZjciaT+ejubK9lUbPc4Yl8lUjIEKXKhlmAWtoPDOk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=z1nDNSfD; arc=none smtp.client-ip=84.16.66.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="z1nDNSfD" Received: from smtp-3-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:4:17::246c]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Xyyth2djbz6vv; Wed, 27 Nov 2024 13:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1732709404; bh=eaKW65KI9A4QWlkoj9p8ZqojNDFsLmXT/WQoZnFsFi4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=z1nDNSfDg8/hBzUqX3ND2eBcdGPY0I9VFQ7uecWNWsXIjKccfI9h5bzk/YwjONaUY F6ZVNzQLzkfp8vDEcetAyqgAdma7/LWhN950mzLoaG/ViuhXt0nFJUuAuvOCupiWmr 2456DcNFx8quafajuekQEQoGZa5dDLRuchrtSIFk= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Xyytg25xszfTJ; Wed, 27 Nov 2024 13:10:03 +0100 (CET) Date: Wed, 27 Nov 2024 13:10:01 +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: <20241127.Ob8DaeR9xaul@digikod.net> References: <20241112191858.162021-1-mic@digikod.net> <20241112191858.162021-7-mic@digikod.net> <20241122.ahY1pooz1ing@digikod.net> <623f89b4de41ac14e0e48e106b846abc9e9d70cf.camel@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <623f89b4de41ac14e0e48e106b846abc9e9d70cf.camel@linux.ibm.com> X-Infomaniak-Routing: alpha On Tue, Nov 26, 2024 at 12:41:45PM -0500, Mimi Zohar wrote: > On Fri, 2024-11-22 at 15:50 +0100, Mickaël Salaün wrote: > > 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. > > Sure, that sounds correct. With an IMA-appraisal policy, any unsigned script > with the is_check flag set now emits an "cause=IMA-signature-required" audit > message. However since IMA-appraisal isn't enforcing file signatures, this > sounds wrong. > > New audit messages like "IMA-signature-required-by-interpreter" and "IMA- > signature-not-required-by-interpreter" would need to be defined based on the > SECBIT_EXEC_RESTRICT_FILE. It makes sense. Could you please send a patch for these IMA-*-interpreter changes? I'll include it in the next series. > > > > > > > > > + 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); > > > > +} > > > > + > > > > > > > > > >