Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX
cover Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX
This documents the LANDLOCK_ACCESS_FS_RESOLVE_UNIX feature, introduced in the upcoming Linux 7.1 (Landlock ABI v9).
The first patch in this series fixes documentation for pre-existing functionality and can be picked up directly. The second patch should wait until Linux 7.1 is released, but I'd like to send it for review on time.
–Günther
Günther Noack (2):
man/man7/landlock.7: Adapt compatibility in code example to ABI v8 man/man7/landlock.7: Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX (ABI v9)
man/man7/landlock.7 | 53 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 7 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/2 man/man7/landlock.7: Adapt compatibility in code example to ABI v8
* Bring the code example up to speed with Landlock ABI v8
* Use the correct ABI level in the MIN() macro
--- man/man7/landlock.7 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
man/man7/landlock.7 +4 -1
@@ -583,6 +583,9 @@ __u64 landlock_fs_access_rights[] = { (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ }; \& int abi = landlock_create_ruleset(NULL, 0,
@@ -595,7 +598,7 @@ if (abi == \-1) { perror("Unable to use Landlock"); return; /* Graceful fallback: Do nothing. */ } -abi = MIN(abi, 3); +abi = MIN(abi, 8); \& /* Only use the available rights in the ruleset. */ attr.handled_access_fs &= landlock_fs_access_rights[abi \- 1];
Signature · 1 line
2.54.0
Alejandro Colomar
maintainerRe: [PATCH 1/2] man/man7/landlock.7: Adapt compatibility in code example to ABI v8
Hi Günther!
Quoted 4 lines · Günther Noack
* Bring the code example up to speed with Landlock ABI v8
* Use the correct ABI level in theMIN()macroSigned-off-by Günther Noack <[email protected]>
Thanks! I've applied the patch.
Have a lovely day!
Alex
Quoted 30 lines
--- man/man7/landlock.7 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)man/man7/landlock.7 +4
-1@@ -583,6 +583,9 @@ __u64 landlock_fs_access_rights[] = { (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ }; \& int abi = landlock_create_ruleset(NULL, 0,@@ -595,7 +598,7 @@ if (abi == \-1) { perror("Unable to use Landlock"); return; /* Graceful fallback: Do nothing. */ } -abi = MIN(abi, 3); +abi = MIN(abi, 8); \& /* Only use the available rights in the ruleset. */ attr.handled_access_fs &= landlock_fs_access_rights[abi \- 1];Signature · 1 line
2.54.0
Signature · 1 line
<https://www.alejandro-colomar.es>
PATCH 2/2 man/man7/landlock.7: Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX (ABI v9)
In reply to Günther NoackDocument the new LANDLOCK_ACCESS_FS_RESOLVE_UNIX filesystem access right, which controls lookups of pathname UNIX domain sockets. Restricts both connect(2) and sendmsg(2) with an explicit recipient address to UNIX sockets created outside the Landlock domain (same semantics as LANDLOCK_SCOPE_* flags). Denied attempts return EACCES.
Available since Linux 7.1 (Landlock ABI version 9).
--- man/man7/landlock.7 | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)
man/man7/landlock.7 +46 -10
@@ -139,6 +139,38 @@ whose implementations are safe and return the right error codes .RE .IP This access right is available since the fifth version of the Landlock ABI. +.TP +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +Look up pathname UNIX +domain sockets +.RB ( unix (7)). +On UNIX domain sockets, +this restricts both calls to +.BR connect (2) +and +.BR sendmsg (2) +with an explicit recipient address. +.IP +This access right only applies to connections to UNIX server sockets +which were created outside the newly created Landlock domain +(e.g., from within a parent domain or from an unrestricted process). +Newly created UNIX servers +within the same Landlock domain +continue to be accessible. +In this regard, +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +has the same semantics as the +.B LANDLOCK_SCOPE_* +flags. +.IP +If a resolve attempt is denied, +the operation returns an +.B EACCES +error, +in line with other filesystem access rights +(but different to denials for abstract UNIX domain sockets). +.IP +This access right is available since the ninth version of the Landlock ABI. .P Whether an opened file can be truncated with .BR ftruncate (2)
@@ -478,6 +510,8 @@ _ _ _ \^ \^ LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF _ _ _ 8 7.0 LANDLOCK_RESTRICT_SELF_TSYNC +_ _ _ +9 7.1 LANDLOCK_ACCESS_FS_RESOLVE_UNIX .TE .P Users should use the Landlock ABI version rather than the kernel version
@@ -563,7 +597,8 @@ attr.handled_access_fs = LANDLOCK_ACCESS_FS_MAKE_SYM | LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_TRUNCATE | - LANDLOCK_ACCESS_FS_IOCTL_DEV; + LANDLOCK_ACCESS_FS_IOCTL_DEV | + LANDLOCK_ACCESS_FS_RESOLVE_UNIX; .EE .in .P
@@ -578,14 +613,15 @@ and only use the available subset of access rights: * numbers hardcoded to keep the example short. */ __u64 landlock_fs_access_rights[] = { - (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ - (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ + (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_RESOLVE_UNIX << 1) \- 1, /* v9: add "resolve_unix" */ }; \& int abi = landlock_create_ruleset(NULL, 0,
@@ -598,7 +634,7 @@ if (abi == \-1) { perror("Unable to use Landlock"); return; /* Graceful fallback: Do nothing. */ } -abi = MIN(abi, 8); +abi = MIN(abi, 9); \& /* Only use the available rights in the ruleset. */ attr.handled_access_fs &= landlock_fs_access_rights[abi \- 1];
Signature · 1 line
2.54.0
Alejandro Colomar
maintainerRe: [PATCH 2/2] man/man7/landlock.7: Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX (ABI v9)
Hi Günther,
Quoted 24 lines · Günther Noack
Document the new
LANDLOCK_ACCESS_FS_RESOLVE_UNIXfilesystem access right, which controls lookups of pathname UNIX domain sockets. Restricts both connect(2) and sendmsg(2) with an explicit recipient address to UNIX sockets created outside the Landlock domain (same semantics as LANDLOCK_SCOPE_* flags). Denied attempts return EACCES.Available since Linux 7.1 (Landlock ABI version 9).
Signed-off-by Günther Noack <[email protected]>--- man/man7/landlock.7 | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)man/man7/landlock.7 +3
-0@@ -139,6 +139,38 @@ whose implementations are safe and return the right error codes .RE .IP This access right is available since the fifth version of the Landlock ABI. +.TP +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +Look up pathname UNIX
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 154
Quoted 10 lines
man/man7/landlock.7 +10
-0+domain sockets +.RB ( unix (7)). +On UNIX domain sockets, +this restricts both calls to +.BR connect (2) +and +.BR sendmsg (2) +with an explicit recipient address. +.IP +This access right only applies to connections to UNIX server sockets
s/only applies/applies only/
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 163
Quoted 9 lines
man/man7/landlock.7 +9
-0+which were created outside the newly created Landlock domain +(e.g., from within a parent domain or from an unrestricted process). +Newly created UNIX servers +within the same Landlock domain +continue to be accessible. +In this regard, +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +has the same semantics as the +.B LANDLOCK_SCOPE_*
* is variable part, so it should be in italics:
.BI LANDLOCK_SCOPE_ *
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 166
Quoted 3 lines
man/man7/landlock.7 +3
-0+flags. +.IP +If a resolve attempt is denied,
'resolve attempt' seems weird. Should this be 'resolution attempt'?
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 173
Quoted 7 lines
man/man7/landlock.7 +7
-0+the operation returns an +.B EACCES +error, +in line with other filesystem access rights +(but different to denials for abstract UNIX domain sockets). +.IP +This access right is available since the ninth version of the Landlock ABI.
I see this is consistent with the rest of the page, but we should change all of these to use cardinals instead of ordinals (and in digits, not letters).
Quoted 33 lines
man/man7/landlock.7 +4
-8.P Whether an opened file can be truncated with .BR ftruncate (2)@@ -478,6 +510,8 @@ _ _ _ \^ \^ LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF _ _ _ 8 7.0 LANDLOCK_RESTRICT_SELF_TSYNC +_ _ _ +9 7.1 LANDLOCK_ACCESS_FS_RESOLVE_UNIX .TE .P Users should use the Landlock ABI version rather than the kernel version@@ -563,7 +597,8 @@ attr.handled_access_fs = LANDLOCK_ACCESS_FS_MAKE_SYM | LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_TRUNCATE | - LANDLOCK_ACCESS_FS_IOCTL_DEV; + LANDLOCK_ACCESS_FS_IOCTL_DEV | + LANDLOCK_ACCESS_FS_RESOLVE_UNIX; .EE .in .P@@ -578,14 +613,15 @@ and only use the available subset of access rights: * numbers hardcoded to keep the example short. */ __u64 landlock_fs_access_rights[] = { - (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ - (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */
man/man7/landlock.7 and only use the available subset of access rights: · line 624
Quoted 10 lines
man/man7/landlock.7 +9
-1- (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ + (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_RESOLVE_UNIX << 1) \- 1, /* v9: add "resolve_unix" */
We should probably use C99 comments (//), to reduce the width, and alignment issues.
Feel free to send formatting patches for these side issues.
Cheers,
Alex
Quoted 16 lines
man/man7/landlock.7 +1
-1}; \& int abi = landlock_create_ruleset(NULL, 0,@@ -598,7 +634,7 @@ if (abi == \-1) { perror("Unable to use Landlock"); return; /* Graceful fallback: Do nothing. */ } -abi = MIN(abi, 8); +abi = MIN(abi, 9); \& /* Only use the available rights in the ruleset. */ attr.handled_access_fs &= landlock_fs_access_rights[abi \- 1];Signature · 1 line
2.54.0
Signature · 1 line
<https://www.alejandro-colomar.es>
Re: [PATCH 2/2] man/man7/landlock.7: Document LANDLOCK_ACCESS_FS_RESOLVE_UNIX (ABI v9)
Hello Alejandro,
Quoted 29 lines · Alejandro Colomar
Quoted 28 lines · Günther Noack
Document the new
LANDLOCK_ACCESS_FS_RESOLVE_UNIXfilesystem access right, which controls lookups of pathname UNIX domain sockets. Restricts both connect(2) and sendmsg(2) with an explicit recipient address to UNIX sockets created outside the Landlock domain (same semantics as LANDLOCK_SCOPE_* flags). Denied attempts return EACCES.Available since Linux 7.1 (Landlock ABI version 9).
Signed-off-by Günther Noack <[email protected]>--- man/man7/landlock.7 | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-)man/man7/landlock.7 +7
-0@@ -139,6 +139,38 @@ whose implementations are safe and return the right error codes .RE .IP This access right is available since the fifth version of the Landlock ABI. +.TP +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +Look up pathname UNIX +domain sockets +.RB ( unix (7)). +On UNIX domain sockets, +this restricts both calls to
Quoted 8 lines
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 154
Quoted 6 lines
man/man7/landlock.7 +6
-0+.BR connect (2) +and +.BR sendmsg (2) +with an explicit recipient address. +.IP +This access right only applies to connections to UNIX server socketss/only applies/applies only/
Done, thanks!
I should pay more attention to that,
it might be a German-ism to mix that up.
Quoted 12 lines
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 163
Quoted 9 lines
man/man7/landlock.7 +9
-0+which were created outside the newly created Landlock domain +(e.g., from within a parent domain or from an unrestricted process). +Newly created UNIX servers +within the same Landlock domain +continue to be accessible. +In this regard, +.B LANDLOCK_ACCESS_FS_RESOLVE_UNIX +has the same semantics as the +.B LANDLOCK_SCOPE_** is variable part, so it should be in italics:
Quoted 1 line
.BI
LANDLOCK_SCOPE_*
Done.
Quoted 5 lines
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 166
Quoted 3 lines
man/man7/landlock.7 +3
-0+flags. +.IP +If a resolve attempt is denied,'resolve attempt' seems weird. Should this be 'resolution attempt'?
Good point, done.
Quoted 11 lines
man/man7/landlock.7 whose implementations are safe and return the right error codes · line 173
Quoted 7 lines
man/man7/landlock.7 +7
-0+the operation returns an +.B EACCES +error, +in line with other filesystem access rights +(but different to denials for abstract UNIX domain sockets). +.IP +This access right is available since the ninth version of the Landlock ABI.I see this is consistent with the rest of the page, but we should change all of these to use cardinals instead of ordinals (and in digits, not letters).
Done. I made it consistent with the landlock_restrict_self(2) man page as well, where we have put these version indicators as shorter phrases next to the tagged paragraph headlines of the affected flags.
Quoted 38 lines
Quoted 38 lines
man/man7/landlock.7 +8
-9.P Whether an opened file can be truncated with .BR ftruncate (2)@@ -478,6 +510,8 @@ _ _ _ \^ \^ LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF _ _ _ 8 7.0 LANDLOCK_RESTRICT_SELF_TSYNC +_ _ _ +9 7.1 LANDLOCK_ACCESS_FS_RESOLVE_UNIX .TE .P Users should use the Landlock ABI version rather than the kernel version@@ -563,7 +597,8 @@ attr.handled_access_fs = LANDLOCK_ACCESS_FS_MAKE_SYM | LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_TRUNCATE | - LANDLOCK_ACCESS_FS_IOCTL_DEV; + LANDLOCK_ACCESS_FS_IOCTL_DEV | + LANDLOCK_ACCESS_FS_RESOLVE_UNIX; .EE .in .P@@ -578,14 +613,15 @@ and only use the available subset of access rights: * numbers hardcoded to keep the example short. */ __u64 landlock_fs_access_rights[] = { - (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ - (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ - (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ - (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_MAKE_SYM << 1) \- 1, /* v1 */ + (LANDLOCK_ACCESS_FS_REFER << 1) \- 1, /* v2: add "refer" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v3: add "truncate" */ + (LANDLOCK_ACCESS_FS_TRUNCATE << 1) \- 1, /* v4: TCP support */
Quoted 8 lines
man/man7/landlock.7 and only use the available subset of access rights: · line 624
Quoted 5 lines
man/man7/landlock.7 +5
-0+ (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v5: add "ioctl_dev" */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v6: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v7: same */ + (LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) \- 1, /* v8: same */ + (LANDLOCK_ACCESS_FS_RESOLVE_UNIX << 1) \- 1, /* v9: add "resolve_unix" */We should probably use C99 comments (//), to reduce the width, and alignment issues.
Good idea, done.
Quoted 1 line
Feel free to send formatting patches for these side issues.
I split it up a bit, so that the fixes independent of the new feature can go separately; see
https://lore.kernel.org/all/[email protected]/
Thanks for the review!
–Günther