Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1364809rdb; Wed, 24 Jan 2024 12:52:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IH588YeZvOQEJCbVT+3/dYfyE/6SsYMM74yvL2GniQEW0TUR6iIbDv7wjiBFMEI9rjPt2zp X-Received: by 2002:a17:906:2545:b0:a31:4c93:93b1 with SMTP id j5-20020a170906254500b00a314c9393b1mr238705ejb.15.1706129531380; Wed, 24 Jan 2024 12:52:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706129531; cv=pass; d=google.com; s=arc-20160816; b=jO1nOZk5A9bQu0UI54fFwlzSJb8PPSB1rdjBvXAdtfPwisDW+9TlTh+C/sAEztXBUH Ao/CFE3kVsbBhoiZyRsv+Etc3kW+XHup5yTU7ukHOJEdeZB6+8Sh8zMjILu6n7ty/buF PwymvYhg9Fg53nz7dcWZaBUZ9BBovATJsBFFFeFV1bGf/MOLxNhAZQUm6UTXF08eEXaA ajYeYf0HpcjHdjIg/PeBJVap3U0NuIXIVM9wGCSwnRtNiaw+f0F1aj0QqUpG06VpRHV0 SwtoXete6cwGvF1jFSzkxJHnvbFJrSoOZr1ieb+CWK+xlWWizRI5KwNc4/Rzb+vnJhnQ U6cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=8AHF91uvt8/XRr8nVpdx7OTkc9kUJK+Zdwkb7E1C+tM=; fh=TEvev6l0xtdsdWPyGS7kdN2ZQCZthwjzXddwXuLbFEI=; b=kBj0hLXscvdhmEVSc0GPFwNnYZuR+2qUqCXvvwkky0Vuq6QNxgrnMINFLNc0ODw4TT tDhX9xiln767eKv7+jFbzseRt7nScRzlK1/FaEWUtx7twDg5gRDdFYCtukKHITGe0rY3 tf3BQseseP4MFdm+XrWsndjG1T2BQo3H0LFqrWZuXIIDX+KAkj2DLzEQgwSvgXcSIzm4 kGkcTNMJH81veZpWa7fa8yik5YxiE9nUGBe1EI2DhU8m751+NA3uGhbLRwwTwuGIukK4 bI16QYpK60s+TErur/YiOI5u/bgnohE8Ks362NejfbcZcBwT2pYvxWcq7p/yZ47WDoZp I1vQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QQSaSBKc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-37664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g26-20020a170906349a00b00a30d37c79c7si234123ejb.773.2024.01.24.12.52.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:52:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QQSaSBKc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-37664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 27A151F23610 for ; Wed, 24 Jan 2024 20:52:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25B641350FB; Wed, 24 Jan 2024 20:51:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QQSaSBKc" Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 BAF7C1350C5 for ; Wed, 24 Jan 2024 20:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706129514; cv=none; b=B4ieIwW91ayoHCt5XSoYQP9OJ7op1cA+HzbFb9sa6AxuxbaGJft6q+0vXmXxFP+OC+OufIdA0IB9iKPyXyLlJg1hGrIsv+uhkx/q99tj3cq0EF44Vkf8VgbpHDDKUbIpg6u1QKjF+ElTpltswqjxKdDu/yjGf5Xz1i0VML/lCho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706129514; c=relaxed/simple; bh=8AHF91uvt8/XRr8nVpdx7OTkc9kUJK+Zdwkb7E1C+tM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=H9IpMe3s2kl0uj09gl+MWxBzO1uD6/XCs+HQYbjSFvYTZu4Q8qwQJBX5BdP55tSi+VhuBf9VrDvjvcexGujqB2+KLtaBFaUEGFuUGou8hyyxR+9u8YjSJwJNeGaXxnvrnWDyDfjRB5FHFVC5NtaSx3LXvYV1mZqcfN3sr8H74Xk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QQSaSBKc; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-55818b7053eso4399a12.0 for ; Wed, 24 Jan 2024 12:51:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706129511; x=1706734311; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8AHF91uvt8/XRr8nVpdx7OTkc9kUJK+Zdwkb7E1C+tM=; b=QQSaSBKc5YXRrwseT28VLCXtVbUV7E9Jtd5kb0ypblZapUB9tDqWdtW/mMUMI/O2Ti KfZs9FX4LFcnev1OX1te+yEtwvtIZttYte6zHJGP2FXcLJLiEyNiqY825ehFNXC/k+EC /hackWXgSmqIVPqjIMqXfvuZ8n4R6zJDGptfgjjnCj0qUgEpETladENJuZqUMhLQsIMK NMHCKThaIMl5Cm7T3cwHqPfUL7LjR2Wnhe9jEiZ5qDX9Q5jB6YksnZAkwzAFcjcz6YeK XFNvQrPkMckc5mxcR57G7tAcrdehDi+1YysgeQ4jlw7tl9pegfzFgy8/g64iSMF40EN7 Utrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706129511; x=1706734311; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8AHF91uvt8/XRr8nVpdx7OTkc9kUJK+Zdwkb7E1C+tM=; b=vn3CP4XpNPxB50flJkDiMI8ZzxDjP83GACk7tz4hwsik0jpdYpWNyBTpsBh/sgWfYw 2vW950WLxf7ScfXImGpDoEIqrvoDj7NyK4PFtmvdrqDB8fXdo1mZdeBE3dJs1c8/l+6Z bfrnRd3cseE45DNQ8Q+hFP+dkwcxPMeJZxqeCtYaigbSYlFy2R5X1YFtfkWSvFAfFiZ8 m7a9I2iuFgxpi3Fmi4jNbtOo4yx/J+WvJ3Roc028J77Yhno/nN2b+uG4ZiB9yPmp4J+z eR8PVzM0O1gArL5vERVT2dzCCWSxk637TcLQ9v0Ixp6p5xgDQ3mmeEXNlUZal+8Rowmx hezw== X-Gm-Message-State: AOJu0YxKzx0Lqx01yqMcmDsWpus0SZJ8Q4fuOnggkGuTyoOYDl6SGJRJ N2TwfhXTuP9NZIO8ql58SFpzKkqE5CVOXwDdOlFBQ+sqwDMKimVh1MkbnY/9RyS+gCj88JOmW/0 LDPBW0XTQqzUsU3m8g1f3J3EJvxpx9NpGQUKc X-Received: by 2002:a05:6402:b77:b0:55a:7f4e:1d62 with SMTP id cb23-20020a0564020b7700b0055a7f4e1d62mr47583edb.4.1706129510820; Wed, 24 Jan 2024 12:51:50 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240124192228.work.788-kees@kernel.org> <202401241206.031E2C75B@keescook> In-Reply-To: From: Jann Horn Date: Wed, 24 Jan 2024 21:51:13 +0100 Message-ID: Subject: Re: [PATCH] exec: Check __FMODE_EXEC instead of in_execve for LSMs To: Linus Torvalds Cc: Kees Cook , Josh Triplett , Kevin Locke , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 24, 2024 at 9:47=E2=80=AFPM Linus Torvalds wrote: > > On Wed, 24 Jan 2024 at 12:15, Kees Cook wrote: > > > > Hmpf, and frustratingly Ubuntu (and Debian) still builds with > > CONFIG_USELIB, even though it was reported[2] to them almost 4 years ag= o. > > Well, we could just remove the __FMODE_EXEC from uselib. > > It's kind of wrong anyway. > > Unlike a real execve(), where the target executable actually takes > control and you can't actually control it (except with ptrace, of > course), 'uselib()' really is just a wrapper around a special mmap. > > And you can see it in the "acc_mode" flags: uselib already requires > MAY_READ for that reason. So you cannot uselib() a non-readable file, > unlike execve(). > > So I think just removing __FMODE_EXEC would just do the > RightThing(tm), and changes nothing for any sane situation. Sounds like a good idea. That makes this codepath behave more as if userspace had done the same steps manually...