From: Khem Raj <raj.khem@gmail.com>
To: musl@lists.openwall.com
Cc: dalias@libc.org,
Richard Purdie <richard.purdie@linuxfoundation.org>,
Khem Raj <raj.khem@gmail.com>
Subject: [musl] [PATCH] handle AT_SYMLINK_NOFOLLOW
Date: Tue, 16 Feb 2021 09:30:22 -0800 [thread overview]
Message-ID: <20210216173022.759116-1-raj.khem@gmail.com> (raw)
From: Richard Purdie <richard.purdie@linuxfoundation.org>
For faccessat(), AT_SYMLINK_NOFOLLOW is a supported flag by the
Linux kernel and musl should really handle it correctly rather
than return EINVAL. Noticed from code in systemd.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/unistd/faccessat.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/unistd/faccessat.c b/src/unistd/faccessat.c
index 8e8689c1..22c30bc6 100644
--- a/src/unistd/faccessat.c
+++ b/src/unistd/faccessat.c
@@ -9,6 +9,7 @@ struct ctx {
const char *filename;
int amode;
int p;
+ int flag;
};
static int checker(void *p)
@@ -18,7 +19,7 @@ static int checker(void *p)
if (__syscall(SYS_setregid, __syscall(SYS_getegid), -1)
|| __syscall(SYS_setreuid, __syscall(SYS_geteuid), -1))
__syscall(SYS_exit, 1);
- ret = __syscall(SYS_faccessat, c->fd, c->filename, c->amode, 0);
+ ret = __syscall(SYS_faccessat, c->fd, c->filename, c->amode, c->flag & AT_SYMLINK_NOFOLLOW);
__syscall(SYS_write, c->p, &ret, sizeof ret);
return 0;
}
@@ -30,11 +31,11 @@ int faccessat(int fd, const char *filename, int amode, int flag)
if (ret != -ENOSYS) return __syscall_ret(ret);
}
- if (flag & ~AT_EACCESS)
+ if (flag & ~(AT_EACCESS | AT_SYMLINK_NOFOLLOW))
return __syscall_ret(-EINVAL);
- if (!flag || (getuid()==geteuid() && getgid()==getegid()))
- return syscall(SYS_faccessat, fd, filename, amode);
+ if (!(flag & AT_EACCESS) || (getuid()==geteuid() && getgid()==getegid()))
+ return syscall(SYS_faccessat, fd, filename, amode, flag);
char stack[1024];
sigset_t set;
@@ -42,7 +43,7 @@ int faccessat(int fd, const char *filename, int amode, int flag)
int ret, p[2];
if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
- struct ctx c = { .fd = fd, .filename = filename, .amode = amode, .p = p[1] };
+ struct ctx c = { .fd = fd, .filename = filename, .amode = amode, .p = p[1], .flag=flag };
__block_all_sigs(&set);
--
2.30.1
next reply other threads:[~2021-02-16 17:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 17:30 Khem Raj [this message]
2021-02-16 17:53 ` [musl] " Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210216173022.759116-1-raj.khem@gmail.com \
--to=raj.khem@gmail.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).