landlock: Remove warning in collect_domain_accesses()
Subsystems (2)
Mickaël Salaün
maintainerPATCH 1/1 landlock: Remove warning in collect_domain_accesses()
As in is_access_to_paths_allowed(), it is also possible to reach disconnected root directories in collect_domain_accesses().
Remove a wrong WARN_ON_ONCE() canary in collect_domain_accesses() and fix comment. Using an unlikely() annotation doesn't seem appropriate here. A following patch from Tingmao tests this case [1].
--- security/landlock/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/landlock/fs.c +2 -2
@@ -1061,8 +1061,8 @@ static bool collect_domain_accesses(break ; } -/* We should not reach a root other than @mnt_root. */ -if (dir == mnt_root ||WARN_ON_ONCE (IS_ROOT (dir))) +/* Stops at the mount point or disconnected root directories. */ +if (dir == mnt_root ||IS_ROOT (dir))break ; parent_dentry =dget_parent (dir);
Signature · 1 line
2.49.0
Quoted 34 lines · Mickaël Salaün
As in
is_access_to_paths_allowed(), it is also possible to reach disconnected root directories incollect_domain_accesses().Remove a wrong
WARN_ON_ONCE()canary incollect_domain_accesses()and fix comment. Using anunlikely()annotation doesn't seem appropriate here. A following patch from Tingmao tests this case [1].Cc Günther Noack <[email protected]>Reported-by Tingmao Wang <[email protected]>Link https://lore.kernel.org/r/09b24128f86973a6022e6aa8338945fcfb9a33e4.1749925391.git.m@maowtm.org [1] open hereFixes b91c3e4ea756 ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")Signed-off-by Mickaël Salaün <[email protected]>--- security/landlock/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)security/landlock/fs.c +2
-2@@ -1061,8 +1061,8 @@ static bool collect_domain_accesses(break ; } -/* We should not reach a root other than @mnt_root. */ -if (dir == mnt_root ||WARN_ON_ONCE (IS_ROOT (dir))) +/* Stops at the mount point or disconnected root directories. */ +if (dir == mnt_root ||IS_ROOT (dir))break ; parent_dentry =dget_parent (dir);Signature · 1 line
2.49.0
Mickaël Salaün
maintainerQuoted 7 lines · Mickaël Salaün
As in
is_access_to_paths_allowed(), it is also possible to reach disconnected root directories incollect_domain_accesses().Remove a wrong
WARN_ON_ONCE()canary incollect_domain_accesses()and fix comment. Using anunlikely()annotation doesn't seem appropriate here. A following patch from Tingmao tests this case [1].
Quoted 5 lines
Cc Günther Noack <[email protected]>Reported-by Tingmao Wang <[email protected]>Link https://lore.kernel.org/r/09b24128f86973a6022e6aa8338945fcfb9a33e4.1749925391.git.m@maowtm.org [1] open hereFixes b91c3e4ea756 ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")Signed-off-by Mickaël Salaün <[email protected]>
This patch hides an edge cases that I though wasn't supposed to happen. I'll drop it in favor of this other patch which fixes the underlying issue:
https://lore.kernel.org/all/[email protected]/
Quoted 23 lines
--- security/landlock/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)security/landlock/fs.c +2
-2@@ -1061,8 +1061,8 @@ static bool collect_domain_accesses(break ; } -/* We should not reach a root other than @mnt_root. */ -if (dir == mnt_root ||WARN_ON_ONCE (IS_ROOT (dir))) +/* Stops at the mount point or disconnected root directories. */ +if (dir == mnt_root ||IS_ROOT (dir))break ; parent_dentry =dget_parent (dir);Signature · 1 line
2.49.0