Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240118000540.369070-4-gael.portay@rtone.fr>
Date: Thu, 18 Jan 2024 01:05:40 +0100
From: Gaƫl PORTAY <gael.portay@...ne.fr>
To: musl@...ts.openwall.com
Cc: gael.portay@...ne.fr
Subject: [PATCH 3/3] use new SYS_fchmodat2 syscall to implement fchmodat with flags

commit 0dc4824479e357a3e23a02d35527e23fca920343 worked around for lack
of flags argument in syscall for fchmodat.

linux 6.6 introduced a new syscall, SYS_fchmodat2, fixing this
deficiency. use it if any flags are passed, and fallback to the old
strategy on ENOSYS. continue using the old syscall when there are no
flags. this is the exact same strategy used when SYS_faccessat2 was used
to implement faccessat with flags.
---
 src/stat/fchmodat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
index 41db0c46..a3f407e3 100644
--- a/src/stat/fchmodat.c
+++ b/src/stat/fchmodat.c
@@ -5,6 +5,11 @@
 
 int fchmodat(int fd, const char *path, mode_t mode, int flag)
 {
+	if (flag) {
+		int ret = __syscall(SYS_fchmodat2, fd, path, mode, flag);
+		if (ret != -ENOSYS) return __syscall_ret(ret);
+	}
+
 	if (!flag) return syscall(SYS_fchmodat, fd, path, mode);
 
 	if (flag != AT_SYMLINK_NOFOLLOW)
-- 
2.43.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.