Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp724154lqp; Wed, 22 May 2024 19:25:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXryCYwuePguJXrqAR3Yt/8yjwQe/Pv5Kwjs+QZjrPqiFQIE39zlVxq4oQ1BNnZmLhhrWZpmPdrmVn4OEqiKFoKTAIqg54YWxFiBhfK6Q== X-Google-Smtp-Source: AGHT+IGRNUyyy3Yuxi77xXN1KRIST9ctEEdgpFXCAdFyOWcSbJ3Vo1oxMYNJ79RuLP56EmGZunYz X-Received: by 2002:a17:906:1992:b0:a5a:8b8c:6203 with SMTP id a640c23a62f3a-a62280d68famr206782366b.45.1716431125946; Wed, 22 May 2024 19:25:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716431125; cv=pass; d=google.com; s=arc-20160816; b=HFvrCD9zI90b0t5jnNPH+7PZDojAbRcru0jkRHj012mzPVeEwypETGOno8Fkf49nJ8 x2YCJOQ/kGwvl3Z0EeWTF7b4FMY1YSUKiXID588d0uZkmIEbn2EYvGsCD2RPwyBkhZdL HKSEXqnj+qtPkBlC+ryJcStq1DnHTt97IhxmM8OI5EuiEaUpO8mrwJRODepyZJnOjkNf mWqBySVx6yWRta1fCG/NSAbeoxurMJXQE8gf3pQPY/IKdR8c3ssncJURLgVsgaT8316U KqmZP8furwJGdO90xKwaP0bNbbEy0Z1K2oV+KnqrgD4vFS2CroefUGOFtEtAWW5O6rl4 1xKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=a8pilQrg+0LcR8JZ6a5Lw64IT07R5JeNXi2Sc07VtB4=; fh=D3eTSgq0OtjXNl/wczSvE94hXTlanOmyvanGEeUurgk=; b=uNj7IdAk5BgpoxBxGVJ9L2dOOWQbnCn/K3Zzek99vu6ExS2oPNf/cLXHdQh0/pdfnn PF+Kw/vJ35aVza1wfOSgsYTPe8P3rKP8kiCl4KhaKjRl7n7464Flq1B2gf4lV0mGFsLv LYEolT5RjV27JJgpzqV1bynWHke8aDL0Dbfn9PmyFHqagM/ia3SdC4CFRBLI+IL0EPpJ L1btKV1y1XOp6c5viTfZR7oc7IoG1gzpyT6ayEeAbR0foU6CTzLgA6uyqp41LwcS/OG8 lDu/Bm4dNmdOGBo/eG8cVjD6EatCn5je0j/dMlDLjVALhTAgFjmFKrUr1bazAG/scZzg Np4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=qr2XdU4C; arc=pass (i=1 spf=pass spfdomain=protonmail.com dkim=pass dkdomain=protonmail.com dmarc=pass fromdomain=protonmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5cdc24ae2bsi830439066b.286.2024.05.22.19.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 19:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186911-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=@protonmail.com header.s=protonmail3 header.b=qr2XdU4C; arc=pass (i=1 spf=pass spfdomain=protonmail.com dkim=pass dkdomain=protonmail.com dmarc=pass fromdomain=protonmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.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 A1DC61F2200B for ; Thu, 23 May 2024 02:25:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82CCB5680; Thu, 23 May 2024 02:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="qr2XdU4C" Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (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 787A14690; Thu, 23 May 2024 02:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716431117; cv=none; b=uN1y0uCX/aFkpMzTFER7C/lkrYsTl2X5NwHGpGEhNzTUkgzOj2aKvzF3zs1Nrzo6DVa5LsFYr2YQbvPsUoVderc3Ts2ZQd1SVNA4Pl74O/AOPCH/S7Ww5Sq1zyg383IgG8Q1zdpc0qgDf45fRY0JRVxSjiV2Qp1ZGczkl+pvWm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716431117; c=relaxed/simple; bh=O1CV/B9LphTJrxPOucqjkcv56j8RNm7CStUV/UI6DbA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lUe5W7V+77ARU3XMC9ulU8ukl6zOsYHFIzGbYkqnwcYl5MhSrFgZV4Kqu6MqcVMNv9P4T86S20HuoJh+oDoGbXURoxsK/qGOEhrqY8NWFOnUdvsn7eZ454Q5ePruPD71WfBb0fUnhlLNx4kXlerlmgTkZ0idS097yEMQCVrS+i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=qr2XdU4C; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1716431108; x=1716690308; bh=a8pilQrg+0LcR8JZ6a5Lw64IT07R5JeNXi2Sc07VtB4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=qr2XdU4CmvcjXQ/Ji5hOJs60iVCpZlR9xiT9We0JAy9Yjj+ax6UIfDjmc5aqdhr64 GcXV8qVxcDNxWVu7WdGC3PYOscTDob5nKQz96ufHTs5TEjs+lWwLnbqm7C09QxOgJT 3qaeiW+IYKWObwAMfHomBt7CzbgN0gkztzQrn2sXK9Osb6sSUA4VPAOjkHo9IYy50n Zz7i0J7hJ8IpzBtkR8E31TpIPqCxfXcDGKvjdv2lYmyMeBLsWc9zErIga3dB3jvyhE XSRL17heXB/dRmFMqsgsK+HoawKRRi27a7b/YT5qvOuOcXPHbXojWMQIFRxV1DXhkZ v18zdL41AXivA== Date: Thu, 23 May 2024 02:25:04 +0000 To: Andrew Morton From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: Jeff Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jorgelo@chromium.org, skhan@linuxfoundation.org, keescook@chromium.org Subject: Re: [PATCH v1] memfd: `MFD_NOEXEC_SEAL` should not imply `MFD_ALLOW_SEALING` Message-ID: <1KDsEBw8g7ymBVpGJZp9NRH1HmCBsQ_jjQ_jKOg90gLUFhW5W6lcG-bI4-5OPkrD24RiG7G83VoZL4SXPQjfldsNFDg7bFnFFgrVZWwSWXQ=@protonmail.com> In-Reply-To: <20240522162324.0aeba086228eddd8aff4f628@linux-foundation.org> References: <20240513191544.94754-1-pobrn@protonmail.com> <20240522162324.0aeba086228eddd8aff4f628@linux-foundation.org> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 5f6b9c478d44802fc89ce6227ae33d51f6a60db9 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-Transfer-Encoding: quoted-printable Hi 2024. m=C3=A1jus 23., cs=C3=BCt=C3=B6rt=C3=B6k 1:23 keltez=C3=A9ssel, Andre= w Morton =C3=ADrta: > On Wed, 15 May 2024 23:11:12 -0700 Jeff Xu wrote: >=20 > > On Mon, May 13, 2024 at 12:15=E2=80=AFPM Barnab=C3=A1s P=C5=91cze wrote: > > > > > > `MFD_NOEXEC_SEAL` should remove the executable bits and set > > > `F_SEAL_EXEC` to prevent further modifications to the executable > > > bits as per the comment in the uapi header file: > > > > > > not executable and sealed to prevent changing to executable > > > > > > However, currently, it also unsets `F_SEAL_SEAL`, essentially > > > acting as a superset of `MFD_ALLOW_SEALING`. Nothing implies > > > that it should be so, and indeed up until the second version > > > of the of the patchset[0] that introduced `MFD_EXEC` and > > > `MFD_NOEXEC_SEAL`, `F_SEAL_SEAL` was not removed, however it > > > was changed in the third revision of the patchset[1] without > > > a clear explanation. > > > > > > This behaviour is suprising for application developers, > > > there is no documentation that would reveal that `MFD_NOEXEC_SEAL` > > > has the additional effect of `MFD_ALLOW_SEALING`. > > > > > Ya, I agree that there should be documentation, such as a man page. I w= ill > > work on that. > > > > > So do not remove `F_SEAL_SEAL` when `MFD_NOEXEC_SEAL` is requested. > > > This is technically an ABI break, but it seems very unlikely that an > > > application would depend on this behaviour (unless by accident). > > > > > > [0]: https://lore.kernel.org/lkml/20220805222126.142525-3-jeffxu@goog= le.com/ > > > [1]: https://lore.kernel.org/lkml/20221202013404.163143-3-jeffxu@goog= le.com/ > > > > ... > > > > Reviewed-by: Jeff Xu >=20 > It's a change to a userspace API, yes? Please let's have a detailed > description of why this is OK. Why it won't affect any existing users. Yes, it is a uAPI change. To trigger user visible change, a program has to - create a memfd - with MFD_NOEXEC_SEAL, - without MFD_ALLOW_SEALING; - try to add seals / check the seals. This change in essence reverts the kernel's behaviour to that of Linux <6.3= , where only `MFD_ALLOW_SEALING` enabled sealing. If a program works correctly on t= hose kernels, it will likely work correctly after this change. I have looked through Debian Code Search and GitHub, searching for `MFD_NOE= XEC_SEAL`. And I could find only a single breakage that this change would case: dbus-b= roker has its own memfd_create() wrapper that is aware of this implicit `MFD_ALLO= W_SEALING` behaviour[0], and tries to work around it. This workaround will break. Luck= ily, however, as far as I could tell this only affects the test suite of dbus-br= oker, not its normal operations, so I believe it should be fine. I have prepared = a PR with a fix[1]. >=20 > Also, please let's give consideration to a -stable backport so that all > kernel versions will eventually behave in the same manner. >=20 >=20 I think that is a good idea, should I resend this with the `Cc: stable@...`= tag or what should I do? Regards, Barnab=C3=A1s P=C5=91cze [0]: https://github.com/bus1/dbus-broker/blob/9eb0b7e5826fc76cad7b025bc46f2= 67d4a8784cb/src/util/misc.c#L114 [1]: https://github.com/bus1/dbus-broker/pull/366