[PATCH 1/2] vfs: support fstatat(..., NULL, AT_EMPTY_PATH | AT_NO_AUTOMOUNT, ...)

From: Xi Ruoyao
Date: Mon Oct 07 2024 - 09:09:03 EST


Since Linux 4.11 AT_NO_AUTOMOUNT is implied for fstatat. So we should
support this like fstatat(..., NULL, AT_EMPTY_PATH, ...) for
consistency. Also note that statx(..., NULL, AT_EMPTY_PATH |
AT_NO_AUTOMOUNT) is already supported.

Fixes: 27a2d0cb2f38 ("stat: use vfs_empty_path() helper")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xi Ruoyao <xry111@xxxxxxxxxxx>
---
fs/stat.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/stat.c b/fs/stat.c
index 41e598376d7e..ed9d4fd8ba2c 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -334,6 +334,7 @@ int vfs_fstatat(int dfd, const char __user *filename,
* If AT_EMPTY_PATH is set, we expect the common case to be that
* empty path, and avoid doing all the extra pathname work.
*/
+ flags &= ~AT_NO_AUTOMOUNT;
if (flags == AT_EMPTY_PATH && vfs_empty_path(dfd, filename))
return vfs_fstat(dfd, stat);

--
2.46.2