Message ID | 20240124192336.work.346-kees@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF422C46CD2 for <linux-mm@archiver.kernel.org>; Wed, 24 Jan 2024 19:23:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52CA48D0007; Wed, 24 Jan 2024 14:23:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DD3B8D0001; Wed, 24 Jan 2024 14:23:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37D418D0007; Wed, 24 Jan 2024 14:23:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 26F208D0001 for <linux-mm@kvack.org>; Wed, 24 Jan 2024 14:23:42 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E0CBD80108 for <linux-mm@kvack.org>; Wed, 24 Jan 2024 19:23:41 +0000 (UTC) X-FDA: 81715179042.06.EB08A76 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf29.hostedemail.com (Postfix) with ESMTP id 19607120018 for <linux-mm@kvack.org>; Wed, 24 Jan 2024 19:23:39 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=YGPk79HG; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.176 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706124220; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=4OCyr5pSg26Go2Q3o/nYX227mKURIEY3hyUdQOlpImo=; b=N4p2YznoNojl289f9ikFHYutn+pCTOXU8UoTuaD8nAGGy0aiEwyaMm7w5u3YTkD0msG7DD PeXZIp8FYPrvpPcMImuFrIMUmQM9mRP1hnMKqewagBS9WiVLizvS7bTcXCMmcqvYxNdL21 3mFuIYhTcSA77QCH/4G2WFx0eDK0MVY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706124220; a=rsa-sha256; cv=none; b=H5csoWZ113TE/RnC1/eNVys6hrPsf4JhTQlfN4MjEX8VBszwT60gtfgk4/Yj5oL6nRarMR SpNNT2CpgOUEAOIWPLt6iiLe0Jqwzpls+QcNC7XOvxqt+LQxDTmK/qvVa4WykNpJX6rFJZ 3AhxCNWwySYTuubCHZjxzJ02sUurEv8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=YGPk79HG; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.176 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-5d5ce6a0e5fso368578a12.2 for <linux-mm@kvack.org>; Wed, 24 Jan 2024 11:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706124219; x=1706729019; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4OCyr5pSg26Go2Q3o/nYX227mKURIEY3hyUdQOlpImo=; b=YGPk79HGN6NrvAnunCerllbq2yS4ytTZkPvFZtPGqKS8jMH5ovWHrpzSTF6A51hsmm z8auQsWBWLL6NjgByCphgmhhJH/zXyUz8j7O6eKDRayU0Ae1sekztv1Npt4XAzODZkl9 XoO5xZ/31etXJvPQ8Pk8UOW7JPiDvuF2i2/Hs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706124219; x=1706729019; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4OCyr5pSg26Go2Q3o/nYX227mKURIEY3hyUdQOlpImo=; b=FIP4yS8dymFgHFgh/FWg8lVQC8hgraGNemuQTkmOMtk0oCMOQrbifH6F0a1pNXWADN BtiJqeZPDiVBAFoeusSY+Q1hxb9oj7kqABU+31k0QQhi/ELmQAFxXh9672/6/DUXrFc1 C8M1fNr6NGK9PBvntTweTwlTzIBtcxD6E02VK2ITdGv+xF6cAx1GZvM+JJW3cYW5gw58 VADANInv3101yWFEFcTCRvbJPcwgG/gbGSSqzeD3LC+z4shvVQ7pVKOz2aY7Afc7LHVb V/bmzKHH7wYgdWtbwA2y8NpdrOoIYItDSByXBhZp6BHSDvXgLfYoomVRXOrFWIrzBK2Q 7FTQ== X-Gm-Message-State: AOJu0YzHGCCyYC5M8PvoRmjZJ/Su3xOLYcWXZsoAcj2+VC+/dbf7eMOY lyEPziryxzNdKUZRNzL2LlVQmcEBLmCEfxWdE4u8h7PA92EtxM57Z4TE6C/vNw== X-Google-Smtp-Source: AGHT+IHJyVGEDKONb5N+QJmOiSDJSmei1sELC71O2denBprxp6vv4OD8lz0PhgNPTwOyl9RHYLBoYg== X-Received: by 2002:a05:6a20:c907:b0:199:e6d0:646f with SMTP id gx7-20020a056a20c90700b00199e6d0646fmr1372021pzb.62.1706124218867; Wed, 24 Jan 2024 11:23:38 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id i18-20020aa79092000000b006d9a7a48bbesm14077211pfa.116.2024.01.24.11.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 11:23:38 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Kentaro Takeda <takedakn@nttdata.co.jp> Cc: Kees Cook <keescook@chromium.org>, Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>, Eric Biederman <ebiederm@xmission.com>, Andrew Morton <akpm@linux-foundation.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Juri Lelli <juri.lelli@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Steven Rostedt <rostedt@goodmis.org>, Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>, Daniel Bristot de Oliveira <bristot@redhat.com>, Valentin Schneider <vschneid@redhat.com>, Suren Baghdasaryan <surenb@google.com>, Mike Christie <michael.christie@oracle.com>, "Michael S. Tsirkin" <mst@redhat.com>, Mateusz Guzik <mjguzik@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Peng Zhang <zhangpeng.00@bytedance.com>, Heiko Carstens <hca@linux.ibm.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] exec: Distinguish in_execve from in_exec Date: Wed, 24 Jan 2024 11:23:36 -0800 Message-Id: <20240124192336.work.346-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2067; i=keescook@chromium.org; h=from:subject:message-id; bh=VR9kpbQ0DKQJADcCvje12k4QMRw3v2j7EWNUrR5Qufc=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlsWO4+WfxI39wun33oA9LOez8cVdNcQbQe0jig /3TTk5FmSuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZbFjuAAKCRCJcvTf3G3A JgR4EACebytLFIu8RYZJITvGsNEcqZqvOSILHoYE48QXsSIUs9g9QRKFIkJ5vh/QPgwtsmhGiIJ JnV/zDBcSQkSPdc7dZ+v+imUpKhe0fPzsBQdcUaP8UGjlJCBlA6DMd+YAeXkZF3+WG3CkKBzPMP QJhvssc4dQ4XW5o0KGGNetMWLG/mJhLpka5HJ8pZkAAcSycsLT1wJFXYgWy51n/TMAwdOfHVMiK Ivzzjiz0hWK81C8SqqaGbFhGU7+2KnIg7Zfs5bUbe/8zIjXkOQiO+VfjxLGyB9daFfbNrtXNPGK okEYC4+omNvm5517jvtuSE5N6dvcOhtF34mgDV9UBdZnc6NFYWDuDUBNv89HWXAKpHkGIChV8jB 28gO71T0qDIno9Bz00/utOA/8B84rw5srxL5+ABi/HjCxAxYIqisZym150VKYGSV5ro68qp5nLM 28X4+mbOdOHyybgFGME8CPBGkYqAVP3t28aS94mz29mU0bAIBHlErmfjKnPc7qNvEzpazZA1Jt+ B/B80aaP+TPl7Z+Rpud+gXpkVQ17jFmTjyD04rF1xIOHm941DQJ+hzZRf9F8fQWDOhafdSkSm9p xh3y/wcuEkSaGIh1mk6sYDNzpb7lnAXGJc2VDc2kPKUsrCwf5T6x+eEP/e6aHudoJHP7GNVAFCJ b1tnmrQ J0V5evIQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Stat-Signature: pr5cyjfwz63moihx7jgzgcmut96zhfzz X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 19607120018 X-Rspam-User: X-HE-Tag: 1706124219-453261 X-HE-Meta: U2FsdGVkX18SvzAdwCgG/Q2OEoyTPmZV2ffMWEYK9Eto2KKSXxdAHge3ATiLT9dulBY/Fdc++nHMfYCmY2TtlV/M23X4jVtgpZ41czO5A5ECrGsMrilOzGsEEv5TEl8x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74q4ui5DfiDu6GS7/XCL1soDKtBRDc9kj291Q+PRF6ebqwM09TyPiqnqmfRZ4g3gsXlAR3Ag7Ovs+W8TmZTR+jZzdwPu7I3/5A+P39qk8744MgciyKD3FocNjtPiWeYWUeSZ0o+jnSWB3mp3uPk3mi/QOsPo097RstspKFGNAZwQSGhaZF5LaGbLYNOC3WgsylAY55wQk8TBICclRhDz/r8Tnw2S7Kbgcf1vUuy/JczqBbHxnyinHVrnBtDcJVg26aRnlGmWiH2iylnCMlf74O2cR/D9vrRzKeKIycXVYJ7x703ut0mZPO+bzsnU4SHG+X4QsHXesXSNXLwI10LARy9seaqAQ/tF+VW2mkB9/49nD20uS7jHHZqYn63AA8/poOnQKtGWfDKvXzxUUxHR+ShTpb2sz8GanEff7sVKKw1nLd0cSz6Ww2vbPeDhNL94a5ZnuEk5zXIDL7w9HejbnDfq6rEfIGGOELijw9eP1W6+CY7To3e0WaU6U8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
exec: Distinguish in_execve from in_exec
|
expand
|
diff --git a/fs/exec.c b/fs/exec.c index 39d773021fff..d179abb78a1c 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1633,6 +1633,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm) } rcu_read_unlock(); + /* "users" and "in_exec" locked for copy_fs() */ if (p->fs->users > n_fs) bprm->unsafe |= LSM_UNSAFE_SHARE; else diff --git a/include/linux/sched.h b/include/linux/sched.h index cdb8ea53c365..ffe8f618ab86 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -920,7 +920,7 @@ struct task_struct { unsigned sched_rt_mutex:1; #endif - /* 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 47ff3b35352e..0d944e92a43f 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1748,6 +1748,7 @@ static int copy_fs(unsigned long clone_flags, struct 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;
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. Cc: Kentaro Takeda <takedakn@nttdata.co.jp> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: Jan Kara <jack@suse.cz> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Kees Cook <keescook@chromium.org> --- fs/exec.c | 1 + include/linux/sched.h | 2 +- kernel/fork.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)