Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1350108rdb; Wed, 24 Jan 2024 12:15:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+E6OkjmmJzJlS9YrlmLC2uzCH13jkTt4TywGCuYhb4C/11qyGwNOwkYAZv8Fu3p3GzMKZ X-Received: by 2002:ae9:f70a:0:b0:783:56dc:6df1 with SMTP id s10-20020ae9f70a000000b0078356dc6df1mr319649qkg.51.1706127327063; Wed, 24 Jan 2024 12:15:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706127327; cv=pass; d=google.com; s=arc-20160816; b=D8m9Vef5avGPUsocbC/F2BYBsGlR/7/ULU7dD6MU6bIdE7FPPrEXgTIszp+j78h0jz tfL7mKEMr+lAUNfBH6IGnRtJ1akg2b4NuWBg6GQq23/TBxzMBtxoZ0BwqgLBrEzAn1/J za/xc2fI8Su/0vLJ+gcUjxnuMlaI249XG4sUSKZhcnwNRYCQd3VGgYJez0z65naKsS8u pTWLYcwOCrVMf2/Bdpl+iIYtRz/KA/XlKaRmBFzr5jjTQsfCjKZHgeSV8U7DHEJVUxZt 5HzEy80QiZoFcchuWg4Ev1NBO1ee+d4IU0/v+UMBbgc23LmwtT1zbovt7abdn9Nel1ng XBkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Id1qRAoiWWWvqW/dbMxgihjX2oP7pYm4HN95FDf9D2k=; fh=r7r7N4y+kB/v6x/6gFhK+TDxcj+vwZCjAqiv+LWBb18=; b=fhoUKqWThMRcY+SC7VggaIIWo89k9gDZKfu3eXmjD5d1xSWryBngFo+audJnPig5wZ R2iQASl0NSh+nwDpUS9SyvQZimkLRNyxQkinWIWuFLH8jCbVHsdHtyLvqdaeULZcCDrq 4v8IHLAXCT3TD/5R3sRhGOYqCXAk4Rq9063/e80x9yr0P4ijj7trACaQfHzvQkYa+f5/ 3WIEd4YUbN/JD4brQJJsjuEb4dQMecm854/P1E2VJeZiwRuc6rllEckNwghFiQLHHadk 0vk8hPg7yDK5gjpWWsCrPCAXcqLHSQpE6t5xu1oPiQsy9RSX9jf1zftoBmOBOUjT2fYb zB5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FjdZxPgE; 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-37637-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37637-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v22-20020a05620a091600b00783745cb706si10580325qkv.433.2024.01.24.12.15.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:15:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37637-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FjdZxPgE; 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-37637-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37637-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 633331C23796 for ; Wed, 24 Jan 2024 20:15:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9F53133983; Wed, 24 Jan 2024 20:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FjdZxPgE" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 71741133423 for ; Wed, 24 Jan 2024 20:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706127308; cv=none; b=c9dSUGzjn1kMxqzDlexUbHp7TLf3oQsXUhDVdstbv3kdBAY+vglqH4Co9wQZnZ1EdqmysO1sxmQQLX+FUAA3eHR6kVnVh++PfCNc0yUTaa61gwHT6d1VayTg1NBjL7CIH+RcvLhdll0PW5TBBjDbYD6HS9229iZBwMMtnFvWFhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706127308; c=relaxed/simple; bh=qgrbcEGeImcGchUMQ4e+5muNpBrHulW7Z5vgrHJx0zg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FB1ykevGlMyuo/yoEkbCTHGyf3p1KKLxFf5tzr+Spp6mSQsPKw3lGHsFprHYabYXsf54qQe3H0zRsTGx9dBVj2uR+GlPweXhog5igN7Lgq4v9UPyXAhVLW8YK8VtYqpPLIZBbU7gFMDsmc3ncTr1ylYRgYlAcxxi6e0GcacNRD8= 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=FjdZxPgE; arc=none smtp.client-ip=209.85.210.174 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-pf1-f174.google.com with SMTP id d2e1a72fcca58-6dbb003be79so40081b3a.0 for ; Wed, 24 Jan 2024 12:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706127307; x=1706732107; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Id1qRAoiWWWvqW/dbMxgihjX2oP7pYm4HN95FDf9D2k=; b=FjdZxPgEPFJ7RZPevFfZMqlA39csXfimhSPZQ4YAeqPrvpm2BqaZwenAm9q2f4mUdg npyuAQXuqOVIG7NcZsvhQiNKew4Es2e5VY/PLFmf0upAjXxp3tZ0XSnDfjSjitmiv8YY duHl/LQqbBkKZWaSpBI+f5TEG86YrB7hPmwRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706127307; x=1706732107; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Id1qRAoiWWWvqW/dbMxgihjX2oP7pYm4HN95FDf9D2k=; b=qx9TjwpGu2hJGwamQyb5TDI+uH/aknVliITuFbDCrA8VBu1R/aYqyqLetlzCW/w9Lm lLZDWCe5OkGgg3A+c7UFYygsUGgV32FY3R6y81s1g1Vddy5z27pOXXhaaZGojpBMoeW7 EU9KpHAYDaPIvDRObT6Upy6gKpueLe4FTpBIfw9hDN9Yos3EK9vFfQibgfjh2mk0DOT/ ykyOWVgRm7sB4ObmGHZkVLrdpaUfEY+562e5v7P4w3ttYrCQyIBItK2Qw3ME4Hi9mTip BPff4CISJnpawUQZ7r2T4nBYuoMIsCoWDGpMJtPq6TyLy3IKHRBG63Ehf1fpCFv5hV7n U5+w== X-Gm-Message-State: AOJu0Yzlman1LxWQSdRu4m2m06Kr5WzhqgSot85jtLNqjYXfVUyOpZX1 sOidcOKsft27yLCgcRoVGiVZ4yY84gkjRJjnay/UF0uNKc1jBpmRM0pcE45uew== X-Received: by 2002:a05:6a00:9297:b0:6db:9c1:7164 with SMTP id jw23-20020a056a00929700b006db09c17164mr66699pfb.15.1706127306883; Wed, 24 Jan 2024 12:15:06 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id fb18-20020a056a002d9200b006ddc2ac59cesm546649pfb.12.2024.01.24.12.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:15:06 -0800 (PST) Date: Wed, 24 Jan 2024 12:15:05 -0800 From: Kees Cook To: Jann Horn Cc: Josh Triplett , Kevin Locke , 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: <202401241206.031E2C75B@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Jan 24, 2024 at 08:58:55PM +0100, Jann Horn wrote: > On Wed, Jan 24, 2024 at 8:22 PM 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. > > I think this is wrong. When CONFIG_USELIB is enabled, the uselib() > syscall will open a file with __FMODE_EXEC but without going through > execve(). From what I can tell, there are no bprm hooks on this path. Hrm, that's true. We've been trying to remove uselib for at least 10 years[1]. :( > I don't know if it _matters_ much, given that it'll only let you > read/execute stuff from files with valid ELF headers, but still. Hmpf, and frustratingly Ubuntu (and Debian) still builds with CONFIG_USELIB, even though it was reported[2] to them almost 4 years ago. -Kees [1] https://lore.kernel.org/lkml/20140221181103.GA5773@jtriplet-mobl1/ [2] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1879454 -- Kees Cook