mm/memfd: add documentation for MFD_NOEXEC_SEAL
Subsystems (4)
cover mm/memfd: add documentation for MFD_NOEXEC_SEAL
From: Jeff Xu <[email protected]>
When MFD_NOEXEC_SEAL was introduced, there was one big mistake: it didn't have proper documentation. This led to a lot of confusion, especially about whether or not memfd created with the MFD_NOEXEC_SEAL flag is sealable. Before MFD_NOEXEC_SEAL, memfd had to explicitly set MFD_ALLOW_SEALING to be sealable, so it's a fair question.
As one might have noticed, unlike other flags in memfd_create, MFD_NOEXEC_SEAL is actually a combination of multiple flags. The idea is to make it easier to use memfd in the most common way, which is NOEXEC + F_SEAL_EXEC + MFD_ALLOW_SEALING. This works with sysctl vm.noexec to help existing applications move to a more secure way of using memfd.
Proposals have been made to put MFD_NOEXEC_SEAL non-sealable, unless MFD_ALLOW_SEALING is set, to be consistent with other flags [1] [2], Those are based on the viewpoint that each flag is an atomic unit, which is a reasonable assumption. However, MFD_NOEXEC_SEAL was designed with the intent of promoting the most secure method of using memfd, therefore a combination of multiple functionalities into one bit.
Furthermore, the MFD_NOEXEC_SEAL has been added for more than one year, and multiple applications and distributions have backported and utilized it. Altering ABI now presents a degree of risk and may lead to disruption.
MFD_NOEXEC_SEAL is a new flag, and applications must change their code to use it. There is no backward compatibility problem.
When sysctl vm.noexec == 1 or 2, applications that don't set MFD_NOEXEC_SEAL or MFD_EXEC will get MFD_NOEXEC_SEAL memfd. And old-application might break, that is by-design, in such a system vm.noexec = 0 shall be used. Also no backward compatibility problem.
I propose to include this documentation patch to assist in clarifying the semantics of MFD_NOEXEC_SEAL, thereby preventing any potential future confusion.
This patch supersede previous patch which is trying different direction [3], and please remove [2] from mm-unstable branch when applying this patch.
Finally, I would like to express my gratitude to David Rheinsberg and Barnabás Pőcze for initiating the discussion on the topic of sealability.
[1]
https://lore.kernel.org/lkml/[email protected]/
[2]
https://lore.kernel.org/lkml/[email protected]/
[3]
https://lore.kernel.org/lkml/[email protected]/
Jeff Xu (1):
mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rst
Signature · 1 line
2.45.2.505.gda0bf45e8d-goog
PATCH 1/1 mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
From: Jeff Xu <[email protected]>
Add documentation for memfd_create flags: FMD_NOEXEC_SEAL and MFD_EXEC
--- Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rst
Documentation/userspace-api/index.rst +1 -0
@@ -32,6 +32,7 @@ Security-related interfaces seccomp_filter landlock lsm + mfd_noexec spec_ctrl tee
Documentation/userspace-api/mfd_noexec.rst new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.45.2.505.gda0bf45e8d-goog
kernel test robot
build botRe: [PATCH v1 1/1] mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
FYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH v1 1/1] mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Randy Dunlap
reviewerRe: [PATCH v1 1/1] mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
In reply to [email protected]Hi--
Quoted 3 lines · On 6/7/24 1:35 PM, [email protected] wrote:
From: Jeff Xu <[email protected]>
Add documentation for
memfd_createflags:FMD_NOEXEC_SEAL
s/FMD/MFD/
Quoted 27 lines
and
MFD_EXECSigned-off-by Jeff Xu <[email protected]>--- Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rstDocumentation/userspace-api/index.rst +1
-0@@ -32,6 +32,7 @@ Security-related interfaces seccomp_filter landlock lsm + mfd_noexec spec_ctrl teeDocumentation/userspace-api/mfd_noexec.rst new file +0
-0
Documentation/userspace-api/mfd_noexec.rst line 4
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0@@ -0,0 +1,86 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================== +Introduction of non executable mfd
non-executable mfd
Documentation/userspace-api/mfd_noexec.rst line 13
Quoted 9 lines
Documentation/userspace-api/mfd_noexec.rst new file +9
-0+================================== +:Author: + Daniel Verkamp <[email protected]> + Jeff Xu <[email protected]> + +:Contributor: + Aleksa Sarai <[email protected]> + +Since Linux introduced the memfd feature, memfd have always had their
memfds
i.e., plural
Documentation/userspace-api/mfd_noexec.rst line 17
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0+execute bit set, and the memfd_create() syscall doesn't allow setting +it differently. + +However, in a secure by default system, such as ChromeOS, (where all
secure-by-default
Documentation/userspace-api/mfd_noexec.rst line 23
Quoted 6 lines
Documentation/userspace-api/mfd_noexec.rst new file +6
-0+executables should come from the rootfs, which is protected by Verified +boot), this executable nature of memfd opens a door for NoExec bypass +and enables “confused deputy attack”. E.g, in VRP bug [1]: cros_vm +process created a memfd to share the content with an external process, +however the memfd is overwritten and used for executing arbitrary code +and root escalation. [2] lists more VRP in this kind.
of this kind.
Documentation/userspace-api/mfd_noexec.rst line 25
Quoted 2 lines
Documentation/userspace-api/mfd_noexec.rst new file +2
-0+ +On the other hand, executable memfd has its legit use, runc uses memfd’s
use:
Documentation/userspace-api/mfd_noexec.rst line 27
Quoted 2 lines
Documentation/userspace-api/mfd_noexec.rst new file +2
-0+seal and executable feature to copy the contents of the binary then +execute them, for such system, we need a solution to differentiate runc's
them. For such a system,
Documentation/userspace-api/mfd_noexec.rst line 30
Quoted 3 lines
Documentation/userspace-api/mfd_noexec.rst new file +3
-0+use of executable memfds and an attacker's [3]. + +To address those above.
above:
Documentation/userspace-api/mfd_noexec.rst line 33
Quoted 3 lines
Documentation/userspace-api/mfd_noexec.rst new file +3
-0+ - Let memfd_create() set X bit at creation time. + - Let memfd be sealed for modifying X bit when NX is set. + - A new pid namespace sysctl: vm.memfd_noexec to help applications to
- Add a new applications in
Quoted 8 lines
Documentation/userspace-api/mfd_noexec.rst new file +8
-0+ migrating and enforcing non-executable MFD. + +User API +======== +``int memfd_create(const char *name, unsigned int flags)`` + +``MFD_NOEXEC_SEAL`` + When MFD_NOEXEC_SEAL bit is set in the ``flags``, memfd is created
Documentation/userspace-api/mfd_noexec.rst line 51
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ with NX. F_SEAL_EXEC is set and the memfd can't be modified to + add X later. MFD_ALLOW_SEALING is also implied. + This is the most common case for the application to use memfd. + +``MFD_EXEC`` + When MFD_EXEC bit is set in the ``flags``, memfd is created with X. + +Note: + ``MFD_NOEXEC_SEAL`` implies ``MFD_ALLOW_SEALING``. In case that + app doesn't want sealing, it can add F_SEAL_SEAL after creation.
an app
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ + +Sysctl: +======== +``pid namespaced sysctl vm.memfd_noexec`` + +The new pid namespaced sysctl vm.memfd_noexec has 3 values: + + - 0: MEMFD_NOEXEC_SCOPE_EXEC + memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts like
Documentation/userspace-api/mfd_noexec.rst line 71
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ MFD_EXEC was set. + + - 1: MEMFD_NOEXEC_SCOPE_NOEXEC_SEAL + memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts like + MFD_NOEXEC_SEAL was set. + + - 2: MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED + memfd_create() without MFD_NOEXEC_SEAL will be rejected. + +The sysctl allows finer control of memfd_create for old-software that
old software
Documentation/userspace-api/mfd_noexec.rst line 72
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+doesn't set the executable bit, for example, a container with
bit;
Documentation/userspace-api/mfd_noexec.rst line 73
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+vm.memfd_noexec=1 means the old-software will create non-executable memfd
old software
Documentation/userspace-api/mfd_noexec.rst line 74
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+by default while new-software can create executable memfd by setting
new software
Documentation/userspace-api/mfd_noexec.rst line 78
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0+MFD_EXEC. + +The value of vm.memfd_noexec is passed to child namespace at creation +time, in addition, the setting is hierarchical, i.e. during memfd_create,
time. In addition,
Quoted 8 lines
Documentation/userspace-api/mfd_noexec.rst new file +8
-0+we will search from current ns to root ns and use the most restrictive +setting. + +[1] https://crbug.com/1305267 + +[2] https://bugs.chromium.org/p/chromium/issues/list?q=type%3Dbug-security%20memfd%20escalation&can=1 + +[3] https://lwn.net/Articles/781013/
Signature · 1 line
~Randy
Re: [PATCH v1 1/1] mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
Hi
Quoted 149 lines · Randy Dunlap
Hi--
Quoted 3 lines · On 6/7/24 1:35 PM, [email protected] wrote:
From: Jeff Xu <[email protected]>
Add documentation for
memfd_createflags:FMD_NOEXEC_SEALs/FMD/MFD/
Quoted 27 lines
and
MFD_EXECSigned-off-by Jeff Xu <[email protected]>--- Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rstDocumentation/userspace-api/index.rst +1
-0@@ -32,6 +32,7 @@ Security-related interfaces seccomp_filter landlock lsm + mfd_noexec spec_ctrl teeDocumentation/userspace-api/mfd_noexec.rst new file +0
-0Documentation/userspace-api/mfd_noexec.rst line 4
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0@@ -0,0 +1,86 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================== +Introduction of non executable mfdnon-executable mfd
Documentation/userspace-api/mfd_noexec.rst line 13
Quoted 9 lines
Documentation/userspace-api/mfd_noexec.rst new file +9
-0+================================== +:Author: + Daniel Verkamp <[email protected]> + Jeff Xu <[email protected]> + +:Contributor: + Aleksa Sarai <[email protected]> + +Since Linux introduced the memfd feature, memfd have always had theirmemfds
i.e., pluralDocumentation/userspace-api/mfd_noexec.rst line 17
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0+execute bit set, and the memfd_create() syscall doesn't allow setting +it differently. + +However, in a secure by default system, such as ChromeOS, (where allsecure-by-default
Documentation/userspace-api/mfd_noexec.rst line 23
Quoted 6 lines
Documentation/userspace-api/mfd_noexec.rst new file +6
-0+executables should come from the rootfs, which is protected by Verified +boot), this executable nature of memfd opens a door for NoExec bypass +and enables “confused deputy attack”. E.g, in VRP bug [1]: cros_vm +process created a memfd to share the content with an external process, +however the memfd is overwritten and used for executing arbitrary code +and root escalation. [2] lists more VRP in this kind.of this kind.
Documentation/userspace-api/mfd_noexec.rst line 25
Quoted 2 lines
Documentation/userspace-api/mfd_noexec.rst new file +2
-0+ +On the other hand, executable memfd has its legit use, runc uses memfd’suse:
Documentation/userspace-api/mfd_noexec.rst line 27
Quoted 2 lines
Documentation/userspace-api/mfd_noexec.rst new file +2
-0+seal and executable feature to copy the contents of the binary then +execute them, for such system, we need a solution to differentiate runc'sthem. For such a system,
Documentation/userspace-api/mfd_noexec.rst line 30
Quoted 3 lines
Documentation/userspace-api/mfd_noexec.rst new file +3
-0+use of executable memfds and an attacker's [3]. + +To address those above.above:
Documentation/userspace-api/mfd_noexec.rst line 33
Quoted 3 lines
Documentation/userspace-api/mfd_noexec.rst new file +3
-0+ - Let memfd_create() set X bit at creation time. + - Let memfd be sealed for modifying X bit when NX is set. + - A new pid namespace sysctl: vm.memfd_noexec to help applications to- Add a new applications in
Quoted 8 lines
Documentation/userspace-api/mfd_noexec.rst new file +8
-0+ migrating and enforcing non-executable MFD. + +User API +======== +``int memfd_create(const char *name, unsigned int flags)`` + +``MFD_NOEXEC_SEAL`` + When MFD_NOEXEC_SEAL bit is set in the ``flags``, memfd is createdDocumentation/userspace-api/mfd_noexec.rst line 51
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ with NX. F_SEAL_EXEC is set and the memfd can't be modified to + add X later. MFD_ALLOW_SEALING is also implied. + This is the most common case for the application to use memfd. + +``MFD_EXEC`` + When MFD_EXEC bit is set in the ``flags``, memfd is created with X. + +Note: + ``MFD_NOEXEC_SEAL`` implies ``MFD_ALLOW_SEALING``. In case that + app doesn't want sealing, it can add F_SEAL_SEAL after creation.an app
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ + +Sysctl: +======== +``pid namespaced sysctl vm.memfd_noexec`` + +The new pid namespaced sysctl vm.memfd_noexec has 3 values: + + - 0: MEMFD_NOEXEC_SCOPE_EXEC + memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts likeDocumentation/userspace-api/mfd_noexec.rst line 71
Quoted 10 lines
Documentation/userspace-api/mfd_noexec.rst new file +10
-0+ MFD_EXEC was set. + + - 1: MEMFD_NOEXEC_SCOPE_NOEXEC_SEAL + memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts like + MFD_NOEXEC_SEAL was set. + + - 2: MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED + memfd_create() without MFD_NOEXEC_SEAL will be rejected. + +The sysctl allows finer control of memfd_create for old-software thatold software
Documentation/userspace-api/mfd_noexec.rst line 72
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+doesn't set the executable bit, for example, a container withbit;Documentation/userspace-api/mfd_noexec.rst line 73
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+vm.memfd_noexec=1 means the old-software will create non-executable memfdold software
Documentation/userspace-api/mfd_noexec.rst line 74
Quoted 1 line
Documentation/userspace-api/mfd_noexec.rst new file +1
-0+by default while new-software can create executable memfd by setting
Quoted 9 lines
new software
Documentation/userspace-api/mfd_noexec.rst line 78
Quoted 4 lines
Documentation/userspace-api/mfd_noexec.rst new file +4
-0+MFD_EXEC. + +The value of vm.memfd_noexec is passed to child namespace at creation +time, in addition, the setting is hierarchical, i.e. during memfd_create,time. In addition,
Updated in V2.
Thanks!
-Jeff
Quoted 11 lines
Documentation/userspace-api/mfd_noexec.rst line 86
Quoted 8 lines
Documentation/userspace-api/mfd_noexec.rst new file +8
-0+we will search from current ns to root ns and use the most restrictive +setting. + +[1] https://crbug.com/1305267 + +[2] https://bugs.chromium.org/p/chromium/issues/list?q=type%3Dbug-security%20memfd%20escalation&can=1 + +[3] https://lwn.net/Articles/781013/--
~Randy
Hi
2024. június 7., péntek 22:35 keltezéssel, [email protected] <[email protected]> írta:
Quoted 23 lines
From: Jeff Xu <[email protected]>
When
MFD_NOEXEC_SEALwas introduced, there was one big mistake: it didn't have proper documentation. This led to a lot of confusion, especially about whether or not memfd created with theMFD_NOEXEC_SEALflag is sealable. BeforeMFD_NOEXEC_SEAL, memfd had to explicitly setMFD_ALLOW_SEALINGto be sealable, so it's a fair question.As one might have noticed, unlike other flags in
memfd_create,MFD_NOEXEC_SEALis actually a combination of multiple flags. The idea is to make it easier to use memfd in the most common way, which is NOEXEC +F_SEAL_EXEC+MFD_ALLOW_SEALING. This works with sysctl vm.noexec to help existing applications move to a more secure way of using memfd.Proposals have been made to put
MFD_NOEXEC_SEALnon-sealable, unlessMFD_ALLOW_SEALINGis set, to be consistent with other flags [1] [2], Those are based on the viewpoint that each flag is an atomic unit, which is a reasonable assumption. However,MFD_NOEXEC_SEALwas designed with the intent of promoting the most secure method of using memfd, therefore a combination of multiple functionalities into one bit.
Quoted 4 lines
Furthermore, the
MFD_NOEXEC_SEALhas been added for more than one year, and multiple applications and distributions have backported and utilized it. Altering ABI now presents a degree of risk and may lead to disruption.
I feel compelled to mention again that based on my investigation the risk is minimal. Not to mention that it can easily be reverted if need be.
In my view, it is better to fix the inconsistency than to document it. I would argue that "MFD_ALLOW_SEALING is needed to enable sealing except that XYZ" is unintuitive and confusing for a non-significant amount of people.
In conclusion, I think it would be unfortunate if the inconsistency was not fixed and the problem was considered "solved" by a passing mention in the documentation.
Regards,
Barnabás Pőcze
Quoted 41 lines
MFD_NOEXEC_SEALis a new flag, and applications must change their code to use it. There is no backward compatibility problem.When sysctl vm.noexec == 1 or 2, applications that don't set
MFD_NOEXEC_SEALorMFD_EXECwill getMFD_NOEXEC_SEALmemfd. And old-application might break, that is by-design, in such a system vm.noexec = 0 shall be used. Also no backward compatibility problem.I propose to include this documentation patch to assist in clarifying the semantics of
MFD_NOEXEC_SEAL, thereby preventing any potential future confusion.This patch supersede previous patch which is trying different direction [3], and please remove [2] from mm-unstable branch when applying this patch.
Finally, I would like to express my gratitude to David Rheinsberg and Barnabás Pőcze for initiating the discussion on the topic of sealability.
[1]
https://lore.kernel.org/lkml/[email protected]/[2]
https://lore.kernel.org/lkml/[email protected]/[3]
https://lore.kernel.org/lkml/[email protected]/Jeff Xu (1):
mm/memfd: add documentation forMFD_NOEXEC_SEALMFD_EXECDocumentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rst--
2.45.2.505.gda0bf45e8d-goog
Hi
Quoted 29 lines · Barnabás Pőcze
Hi
2024. június 7., péntek 22:35 keltezéssel, [email protected] < [email protected]> írta:
Quoted 23 lines
From: Jeff Xu <[email protected]>
When
MFD_NOEXEC_SEALwas introduced, there was one big mistake: it didn't have proper documentation. This led to a lot of confusion, especially about whether or not memfd created with theMFD_NOEXEC_SEALflag is sealable. BeforeMFD_NOEXEC_SEAL, memfd had to explicitly setMFD_ALLOW_SEALINGto be sealable, so it's a fair question.As one might have noticed, unlike other flags in
memfd_create,MFD_NOEXEC_SEALis actually a combination of multiple flags. The idea is to make it easier to use memfd in the most common way, which is NOEXEC +F_SEAL_EXEC+MFD_ALLOW_SEALING. This works with sysctl vm.noexec to help existing applications move to a more secure way of using memfd.Proposals have been made to put
MFD_NOEXEC_SEALnon-sealable, unlessMFD_ALLOW_SEALINGis set, to be consistent with other flags [1] [2], Those are based on the viewpoint that each flag is an atomic unit, which is a reasonable assumption. However,MFD_NOEXEC_SEALwas designed with the intent of promoting the most secure method of using memfd, therefore a combination of multiple functionalities into one bit.
Quoted 9 lines
Quoted 4 lines
Furthermore, the
MFD_NOEXEC_SEALhas been added for more than one year, and multiple applications and distributions have backported and utilized it. Altering ABI now presents a degree of risk and may lead to disruption.I feel compelled to mention again that based on my investigation the risk is
minimal. Not to mention that it can easily be reverted if need be.
The risk is not zero. If we changed the ABI it would be propagated to early kernel stable versions. Various Linux distributions also backported the patch to earlier kernels such as 5.4. If it needs a revert, then everyone has to do it again.
Quoted 6 lines
In my view, it is better to fix the inconsistency than to document it. I would
argue that "MFD_ALLOW_SEALINGis needed to enable sealing except that XYZ"
is unintuitive and confusing for a non-significant amount of people.
I understand, documentation help resolve the confusion, the next step i will updated man page for memfd.
Thanks
-Jeff
Resent, (previous email is not plain text)
Hi
Quoted 29 lines · Barnabás Pőcze
Hi
2024. június 7., péntek 22:35 keltezéssel, [email protected] <[email protected]> írta:
Quoted 23 lines
From: Jeff Xu <[email protected]>
When
MFD_NOEXEC_SEALwas introduced, there was one big mistake: it didn't have proper documentation. This led to a lot of confusion, especially about whether or not memfd created with theMFD_NOEXEC_SEALflag is sealable. BeforeMFD_NOEXEC_SEAL, memfd had to explicitly setMFD_ALLOW_SEALINGto be sealable, so it's a fair question.As one might have noticed, unlike other flags in
memfd_create,MFD_NOEXEC_SEALis actually a combination of multiple flags. The idea is to make it easier to use memfd in the most common way, which is NOEXEC +F_SEAL_EXEC+MFD_ALLOW_SEALING. This works with sysctl vm.noexec to help existing applications move to a more secure way of using memfd.Proposals have been made to put
MFD_NOEXEC_SEALnon-sealable, unlessMFD_ALLOW_SEALINGis set, to be consistent with other flags [1] [2], Those are based on the viewpoint that each flag is an atomic unit, which is a reasonable assumption. However,MFD_NOEXEC_SEALwas designed with the intent of promoting the most secure method of using memfd, therefore a combination of multiple functionalities into one bit.
Quoted 8 lines
Quoted 4 lines
Furthermore, the
MFD_NOEXEC_SEALhas been added for more than one year, and multiple applications and distributions have backported and utilized it. Altering ABI now presents a degree of risk and may lead to disruption.I feel compelled to mention again that based on my investigation the risk is minimal. Not to mention that it can easily be reverted if need be.
The risk is not zero. If we changed the ABI it would be propagated to early kernel stable versions. Various Linux distributions also backported the patch to earlier kernels such as 5.4. If it needs a revert, then everyone has to do it again.
Quoted 4 lines
In my view, it is better to fix the inconsistency than to document it. I would argue that "
MFD_ALLOW_SEALINGis needed to enable sealing except that XYZ" is unintuitive and confusing for a non-significant amount of people.
I understand, documentation helps resolve the confusion, the next step is to update the man page for memfd.
Thanks
-Jeff