Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1338164rdb; Wed, 24 Jan 2024 11:52:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYO8NJDIwsq/pPmr4j8n05+a9D9/6foqhcdRmSXGjlFDpG6FMgEkcKcnb3eddTmcwvNx4Q X-Received: by 2002:a2e:9344:0:b0:2ce:fa00:9b0a with SMTP id m4-20020a2e9344000000b002cefa009b0amr981787ljh.16.1706125924316; Wed, 24 Jan 2024 11:52:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706125924; cv=pass; d=google.com; s=arc-20160816; b=tMAf7uN39e9MAt0o0gZoj30qM0wAl4w/kJjsV9dFMUYoQlZlrIOmcebCoUmqZWEiMz +IVgmivlPfylZaavdDc3qYMcMRLOBV9+kWaUjh/dsm1eZW/W3cbH4yRwG2yH/sxQrxER B5C4Sbo/NXGwQ5k8AyRnAw5/3ZQAyJyUaV5AnctlVGxORKJqwPO/u436C31MTcv1NMMC Bmkcv4TkDYOqYlFiY6l+GUR00+P39tQ6ETAG+/osQrQPlxnO0+1xltIJZccKm+ETN2vu h3hg1GjTodpOkOk2qgNdAOtqlNp/0C+SiSJdJR4p7JShM0Bersbo1KnhcUC3AcAokv3Q NEMQ== 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:to :from:date:dkim-signature; bh=kA0mFxG1k0QSiOKDeUD/WDcdNFn8yF9DrGJFsA48PEc=; fh=DE7IZJck10ltpk92fKaTk5SgOI7P28FiV5uT0qCk9tA=; b=Pwv0SqlTxlYRI9aiGvmKlF3ufed/oy0Z7oxwnDhxhcfJfnrumXW1Cw/K+SgJc39Zqx VTiKXNAFHY3gfpam+WrrJ+4GG6QzEaS1ko07+aYUqEU+Vcl69rrgXYWoep+YbkMlc72R LR0n8dK3zFmiFa5OKGH6s7oEK/JDuM6bXdFdc8Z9gxrqmoTjqJ+FG4qKBc9jAXmc1CM/ 19aSHkMMMFoqwu7MYR3WDzNCod3HR/eZllCARDec9LcotJuH0dPd/rEnJItHBKOwQPXE BadNNJuNu3Jj3afr+nxpbwD7z5U6kFTeekH0U2fpIZouc5CEEu5fcDx3bGIiRmcVRVwN YSuw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J4Diar6n; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-37612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c26-20020a50d65a000000b0055c971d54c9si1630415edj.56.2024.01.24.11.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 11:52:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J4Diar6n; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-37612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E222D1F2581A for ; Wed, 24 Jan 2024 19:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBBC4133435; Wed, 24 Jan 2024 19:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="J4Diar6n" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63EC6133406 for ; Wed, 24 Jan 2024 19:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706125912; cv=none; b=FGiwysUuZTEKdF6XI/xxaujperjZ1E49P5q6qP4POMfO2PgvRnDn1qjRNLHwDV2PEfkiyQ7B3wJuyvHLfncYmL+SmwLHLa2ziRKyt3eeFG/jxCqq3y9XN+g+J5sLMWITwY6KYOwDNlHXeG30qZ4lw/hN2gVpOtYJkhWa+k5wzYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706125912; c=relaxed/simple; bh=+IYqSxEQ9oBa5c9r8B0bfIvQXLqXBMpi4Ryc4G+HXuE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TK1FPxvKu3E8+ZHFOrR5WPQFH2NP7sTB8NJyUs/OMjDYibFgn5l11uLXAWdZXWvnkND3paulq2YFDcxA/wzNLBNrDCHD4LzdPiJjiWulQQDU2kDf7x9Pgnd+le8KWul3X4QRg4wkECvB9LgRgsaQc3kujvjEH7PgSIgJm+MKYz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=J4Diar6n; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d750660a0aso19969845ad.0 for ; Wed, 24 Jan 2024 11:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706125911; x=1706730711; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=kA0mFxG1k0QSiOKDeUD/WDcdNFn8yF9DrGJFsA48PEc=; b=J4Diar6nU/37c0/UwBQQFu7zCFodAGZNbMK8zK5T4ksD60wf29XsDjczDxsZMoOkG8 VWNui00mTtdF2GLDTKMEYsm80XO6z1961TZkKiOaKfAmeJPEEG9nw+44TX83kwwOMNbj w/zguEDg41/bg68FDXI9OEyyVi7Lkay37ry3M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706125911; x=1706730711; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kA0mFxG1k0QSiOKDeUD/WDcdNFn8yF9DrGJFsA48PEc=; b=K9AG6dHsz0eARsgLAfOyybSMYnPlHkzikSAyxUiKsr9yLBzzCXNNLA8EVHzt4PRSbg pfFrS2TjRrYPmiCkbijOxvfDiX21HOffQH6FlKg38CpFNlUDiaBXbPQy/qfSOToAdEhq aYzG30nwtOSLw3J9jaxXORPtKrVHBG1XzQKYYs9cUyCECGfAYRb0b+IdHBQsKfVC/tGS jfSgjXoZ1nSKrW2md807sPOn9rnbA30GXyxtfJSlQSZ514uFNu+uIjFZuinEsqeNokkn nKdZbM1NWbvgbKzqtGI8cmK0FiFgIlrfIoTwiYADnSTFAzA5alj3cxdft/t+3ffLydmE aqDg== X-Gm-Message-State: AOJu0YwLVyk+/jGKigZ5NI3oaAhnC3eCjPA2om1nYWNkoDAIgGaZBg0C wr7T1e/nqBDtS40c1H9QQx+67PKB6UDib57khLpC9ct62t6dgI15vzjRx0B9ng== X-Received: by 2002:a17:902:8685:b0:1d7:70d7:c05a with SMTP id g5-20020a170902868500b001d770d7c05amr1210754plo.98.1706125910737; Wed, 24 Jan 2024 11:51:50 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id d9-20020a170902c18900b001d707163122sm10456896pld.7.2024.01.24.11.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 11:51:50 -0800 (PST) Date: Wed, 24 Jan 2024 11:51:49 -0800 From: Kees Cook To: Kevin Locke , Josh Triplett , Linus Torvalds , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , 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, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] exec: Check __FMODE_EXEC instead of in_execve for LSMs Message-ID: <202401241151.25D468FE@keescook> References: <20240124192228.work.788-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 24, 2024 at 12:39:38PM -0700, Kevin Locke wrote: > On Wed, 2024-01-24 at 11:22 -0800, Kees Cook wrote: > > After commit 978ffcbf00d8 ("execve: open the executable file before > > doing anything else"), current->in_execve was no longer in sync with the > > open(). This broke AppArmor and TOMOYO which depend on this flag to > > distinguish "open" operations from being "exec" operations. > > > > Instead of moving around in_execve, switch to using __FMODE_EXEC, which > > is where the "is this an exec?" intent is stored. Note that TOMOYO still > > uses in_execve around cred handling. > > It solves the AppArmor issue I was experiencing and I don't notice any > other issues. > > Tested-by: Kevin Locke Thanks! Sounds like Linus has taken the patch directly, and I'll send a follow-up PR with other clean-ups. -Kees -- Kees Cook