Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp778554rdb; Sun, 18 Feb 2024 11:13:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoWKiJFayoSPJn3zElGoUloElBWPpnkbBSUcuEAyU8axDkt0d8WB1jEEaaQxIbDi5VuHllN67FKbjoolZJVr62Ca++fIADW8IN2rP0ug== X-Google-Smtp-Source: AGHT+IGm7rDF4peFPlWAg84lKfUgb4LVPR2cErUAR835XORXIlXu7BJJ2KKU7EDXqQrk1oxlOnHZ X-Received: by 2002:a05:6830:1d91:b0:6e4:459e:fdba with SMTP id y17-20020a0568301d9100b006e4459efdbamr4150758oti.26.1708283593672; Sun, 18 Feb 2024 11:13:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708283593; cv=pass; d=google.com; s=arc-20160816; b=rod/RXQj2TTWZ4lWDBoLmqvf78hp3FYocqlPSt4dIEtx3kHJyScxF5sYRiU6W7kqDr LIXrlR5/FPrBAxzgfxstN/aNU+ZGEc4QxZcO8SXopsTLe9AZHS5g8SKk66SGgwsz+b8O DVldtKn6UWCN32OSyjA+tZFMoP7dBCaLh5mnHXgXZGzTwCAhwfEPXvfw+Wq7q3iW8Ylb PKA6mur/rNbwYOrLOoid2BcFR64aczXc231XShlV/H6aQfJBcnpUmGsNRtfd0MCe6HJD gMPmnvsSAoUI1HbjnmkyGqDjy+wNYCQj7hUSXd/W3W+brEKNI9qXwAIsocwLkFtzA/JW +sBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=PyunFDBMyOmK4gJo03GIb1K8Lweafc8sl8jT2+wDt70=; fh=40AXWMA9qJ5WVZtVpYb2Gqy+a5Cgt7GZV3Ef1z0Upa8=; b=tCRMMZQyztLND49rnQwBkWyVevXO1LvCI9yaBsocGCfXzmreW30humZaypoGPMNgBM YrDEWeS0RzrS/uhK21zjnldwUeK9TmuIaE/nL2SzZCZD4bc7hDpUpjPMtdNhpnbkGnYm WbTCt5EAzzA5MvRweC7lJ6Xik0/OjO/EDXybIl5Mh5IpjF+kTFbU1+K0BdPtX4ug/UH2 8OEdnTXBVdNVjHw6VzlBpVKNIzLfrsonrsEBWDAaAZZ0KHHupNoQ995GZIzrpx+xHGnf e2NtCMVLzgofB/pnbeFID691WlMh/fhmc8YazcLNUZw/Q+vESQbXHVQFqfmYWM25iPaT AVWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-70541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k190-20020a6384c7000000b005dcab90d688si3207753pgd.526.2024.02.18.11.13.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:13:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-70541-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 98F83B21247 for ; Sun, 18 Feb 2024 19:13:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7346571B2B; Sun, 18 Feb 2024 19:13:01 +0000 (UTC) Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) (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 1BD091D696; Sun, 18 Feb 2024 19:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.255.230.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708283581; cv=none; b=gsiv0VJAG4RCsysNDJFVqXx5ffkInEi7JYXaZrGWOq3VXNmDdroURF9D5q6LR4pHZlwbjaIw1Aq/CUeeBcddNGcGkVOis6keE+ZmLzius+mCT6fpuH3ylO67amektZwh/3QJPP2GHvuJH3c7iqqEMivQBAPr0CtU24Obgt7SusM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708283581; c=relaxed/simple; bh=zO/LuEh8ruW5c8elMQENCvHE5l8w1EYu5MI98z83Z88=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IchtMZp5E/kqOvmknycNQKCmkPraO/B0gMFAxrYecqOYbZ0jGdpAqSP1P6qZdcIJy646A+M3if4TyFdtb36sa/B4TycPc5y1IrQIlilMcRUjB37UsZb5SpnwzrLtnVGCUCnyGD2L2w56BRsXjv/RvYy3S/rDdlr98krSUX4WLZ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=denx.de; spf=fail smtp.mailfrom=denx.de; arc=none smtp.client-ip=46.255.230.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=denx.de Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id DA44B1C006B; Sun, 18 Feb 2024 20:12:56 +0100 (CET) Date: Sun, 18 Feb 2024 20:12:56 +0100 From: Pavel Machek To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Kees Cook , Kentaro Takeda , Tetsuo Handa , Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Andrew Morton , Sebastian Andrzej Siewior , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, surenb@google.com, michael.christie@oracle.com, mst@redhat.com, mjguzik@gmail.com, npiggin@gmail.com, zhangpeng.00@bytedance.com, hca@linux.ibm.com Subject: Re: [PATCH AUTOSEL 5.10 7/8] exec: Distinguish in_execve from in_exec Message-ID: References: <20240202184156.541981-1-sashal@kernel.org> <20240202184156.541981-7-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RWb6j82WY1Y0XPxm" Content-Disposition: inline In-Reply-To: <20240202184156.541981-7-sashal@kernel.org> --RWb6j82WY1Y0XPxm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Kees Cook >=20 > [ Upstream commit 90383cc07895183c75a0db2460301c2ffd912359 ] >=20 > Just to help distinguish the fs->in_exec flag from the current->in_execve > flag, add comments in check_unsafe_exec() and copy_fs() for more > context. Also note that in_execve is only used by TOMOYO now. These are just a whitespace changes, we should not need them. Best regards, Pavel > +++ b/fs/exec.c > @@ -1565,6 +1565,7 @@ static void check_unsafe_exec(struct linux_binprm *= bprm) > } > rcu_read_unlock(); > =20 > + /* "users" and "in_exec" locked for copy_fs() */ > if (p->fs->users > n_fs) > bprm->unsafe |=3D LSM_UNSAFE_SHARE; > else > diff --git a/include/linux/sched.h b/include/linux/sched.h > index aa015416c569..65cfe85de8d5 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -806,7 +806,7 @@ struct task_struct { > */ > unsigned sched_remote_wakeup:1; > =20 > - /* Bit to tell LSMs we're in execve(): */ > + /* Bit to tell TOMOYO we're in execve(): */ > unsigned in_execve:1; > unsigned in_iowait:1; > #ifndef TIF_RESTORE_SIGMASK > diff --git a/kernel/fork.c b/kernel/fork.c > index 633b0af1d1a7..906dbaf25058 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1452,6 +1452,7 @@ static int copy_fs(unsigned long clone_flags, struc= t task_struct *tsk) > if (clone_flags & CLONE_FS) { > /* tsk->fs is already what we want */ > spin_lock(&fs->lock); > + /* "users" and "in_exec" locked for check_unsafe_exec() */ > if (fs->in_exec) { > spin_unlock(&fs->lock); > return -EAGAIN; --=20 DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --RWb6j82WY1Y0XPxm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCZdJWuAAKCRAw5/Bqldv6 8vEZAKCsYpt/9YYcVItFN4Cb+Qx3eGNUzACePikZNygBi7iNKiPV0JHUidFNPlk= =Wlsl -----END PGP SIGNATURE----- --RWb6j82WY1Y0XPxm--