From: Palmer Dabbelt <palmer@sifive.com>
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
rth@twiddle.net, ink@jurassic.park.msu.ru, mattst88@gmail.com,
linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org,
tony.luck@intel.com, fenghua.yu@intel.com, geert@linux-m68k.org,
monstr@monstr.eu, ralf@linux-mips.org, paul.burton@mips.com,
jhogan@kernel.org, James.Bottomley@hansenpartnership.com,
deller@gmx.de, benh@kernel.crashing.org, paulus@samba.org,
mpe@ellerman.id.au, heiko.carstens@de.ibm.com, gor@linux.ibm.com,
borntraeger@de.ibm.com, ysato@users.sourceforge.jp,
dalias@libc.org, davem@davemloft.net, luto@kernel.org,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
hpa@zytor.com, x86@kernel.org, peterz@infradead.org,
acme@kernel.org, alexander.shishkin@linux.intel.com,
jolsa@redhat.com, namhyung@kernel.org, dhowells@redhat.com,
firoz.khan@linaro.org, stefan@agner.ch, schwidefsky@de.ibm.com,
axboe@kernel.dk, christian@brauner.io, hare@suse.com,
deepa.kernel@gmail.com, tycho@tycho.ws, kim.phillips@arm.com,
linux-alpha@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-s390@vger.kernel.org, linux-sh@vger.kernel.org,
sparclinux@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH v2 2/4] Add fchmodat4(), a new syscall
Date: Tue, 16 Jul 2019 19:12:31 -0700 (PDT) [thread overview]
Message-ID: <mhng-07134298-232b-4472-ac6f-cf33862883c5@palmer-si-x1e> (raw)
In-Reply-To: <20190717014802.GS17978@ZenIV.linux.org.uk>
On Tue, 16 Jul 2019 18:48:02 PDT (-0700), viro@zeniv.linux.org.uk wrote:
> On Tue, Jul 16, 2019 at 06:27:17PM -0700, Palmer Dabbelt wrote:
>
>> -int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
>> +int do_fchmodat4(int dfd, const char __user *filename, umode_t mode, int flags)
>> {
>> struct path path;
>> int error;
>> - unsigned int lookup_flags = LOOKUP_FOLLOW;
>> + unsigned int lookup_flags;
>> +
>> + if (unlikely(flags & ~AT_SYMLINK_NOFOLLOW))
>> + return -EINVAL;
>> +
>> + lookup_flags = flags & AT_SYMLINK_NOFOLLOW ? 0 : LOOKUP_FOLLOW;
>> +
>
> Why not do that in sys_fchmodat4() itself, passing lookup_flags to
> do_fchmodat() and updating old callers to pass it 0 as extra argument?
Ya, that seems better -- passing LOOKUP_FOLLOW instead of 0, to keep the
behavior the same. That way I could avoid the overhead of these checks for the
old syscalls, as we know they're not necessary.
I'll replace this patch with the following for a v3
diff --git a/fs/open.c b/fs/open.c
index b5b80469b93d..a5f99408af11 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -569,11 +569,12 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
return ksys_fchmod(fd, mode);
}
-int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
+int do_fchmodat4(int dfd, const char __user *filename, umode_t mode,
+ int lookup_flags)
{
struct path path;
int error;
- unsigned int lookup_flags = LOOKUP_FOLLOW;
+
retry:
error = user_path_at(dfd, filename, lookup_flags, &path);
if (!error) {
@@ -587,15 +588,28 @@ int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
return error;
}
+SYSCALL_DEFINE4(fchmodat4, int, dfd, const char __user *, filename,
+ umode_t, mode, int, flags)
+{
+ unsigned int lookup_flags;
+
+ if (unlikely(flags & ~AT_SYMLINK_NOFOLLOW))
+ return -EINVAL;
+
+ lookup_flags = flags & AT_SYMLINK_NOFOLLOW ? 0 : LOOKUP_FOLLOW;
+
+ return do_fchmodat4(dfd, filename, mode, lookup_flags);
+}
+
SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename,
umode_t, mode)
{
- return do_fchmodat(dfd, filename, mode);
+ return do_fchmodat4(dfd, filename, mode, LOOKUP_FOLLOW);
}
SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
{
- return do_fchmodat(AT_FDCWD, filename, mode);
+ return do_fchmodat4(AT_FDCWD, filename, mode, LOOKUP_FOLLOW);
}
static int chown_common(const struct path *path, uid_t user, gid_t group)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e1c20f1d0525..6676b1cc5485 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -81,6 +81,7 @@ struct io_uring_params;
#include <linux/quota.h>
#include <linux/key.h>
#include <linux/personality.h>
+#include <linux/namei.h>
#include <trace/syscall.h>
#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
@@ -433,6 +434,8 @@ asmlinkage long sys_chroot(const char __user *filename);
asmlinkage long sys_fchmod(unsigned int fd, umode_t mode);
asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
umode_t mode);
+asmlinkage long sys_fchmodat4(int dfd, const char __user *filename,
+ umode_t mode, int flags);
asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
gid_t group, int flag);
asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group);
@@ -1320,11 +1323,12 @@ static inline long ksys_link(const char __user *oldname,
return do_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
}
-extern int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
+extern int do_fchmodat4(int dfd, const char __user *filename, umode_t mode,
+ int flags);
static inline int ksys_chmod(const char __user *filename, umode_t mode)
{
- return do_fchmodat(AT_FDCWD, filename, mode);
+ return do_fchmodat4(AT_FDCWD, filename, mode, LOOKUP_FOLLOW);
}
extern long do_faccessat(int dfd, const char __user *filename, int mode);
next prev parent reply other threads:[~2019-07-17 2:12 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 1:27 Add a new fchmodat4() syscall, v2 Palmer Dabbelt
2019-07-17 1:27 ` [PATCH v2 1/4] Non-functional cleanup of a "__user * filename" Palmer Dabbelt
2019-07-17 1:27 ` [PATCH v2 2/4] Add fchmodat4(), a new syscall Palmer Dabbelt
2019-07-17 1:48 ` Al Viro
2019-07-17 2:12 ` Palmer Dabbelt [this message]
2019-07-17 2:40 ` Rich Felker
2019-07-17 3:02 ` Al Viro
2019-07-17 1:27 ` [PATCH v2 3/4] arch: Register fchmodat4, usually as syscall 434 Palmer Dabbelt
2019-07-17 1:27 ` [PATCH v2 4/4] tools: Add fchmodat4 Palmer Dabbelt
2019-07-17 12:39 ` Arnaldo Carvalho de Melo
2020-06-09 13:52 ` Add a new fchmodat4() syscall, v2 Florian Weimer
2023-07-11 11:25 ` [PATCH v3 0/5] Add a new fchmodat4() syscall Alexey Gladkov
2023-07-11 11:25 ` [PATCH v3 1/5] Non-functional cleanup of a "__user * filename" Alexey Gladkov
2023-07-11 11:32 ` Arnd Bergmann
2023-07-11 11:25 ` [PATCH v3 2/5] fs: Add fchmodat4() Alexey Gladkov
2023-07-11 11:42 ` Arnd Bergmann
2023-07-11 11:52 ` Christian Brauner
2023-07-11 12:51 ` Alexey Gladkov
2023-07-11 14:01 ` Christian Brauner
2023-07-11 15:23 ` Alexey Gladkov
2023-07-11 12:28 ` Matthew Wilcox
2023-07-11 12:49 ` Alexey Gladkov
2023-07-11 11:25 ` [PATCH v3 3/5] arch: Register fchmodat4, usually as syscall 451 Alexey Gladkov
2023-07-11 11:31 ` Arnd Bergmann
2023-07-11 11:25 ` [PATCH v3 4/5] tools headers UAPI: Sync files changed by new fchmodat4 syscall Alexey Gladkov
2023-07-11 11:25 ` [PATCH v3 5/5] selftests: add fchmodat4(2) selftest Alexey Gladkov
2023-07-11 12:10 ` Florian Weimer
2023-07-11 13:38 ` Alexey Gladkov
2023-07-11 12:24 ` [PATCH v3 0/5] Add a new fchmodat4() syscall Florian Weimer
2023-07-11 15:14 ` Christian Brauner
2023-07-25 11:05 ` Alexey Gladkov
2023-07-25 12:05 ` Christian Brauner
2023-07-11 16:16 ` [PATCH v4 0/5] Add a new fchmodat2() syscall Alexey Gladkov
2023-07-11 16:16 ` [PATCH v4 1/5] Non-functional cleanup of a "__user * filename" Alexey Gladkov
2023-07-11 16:16 ` [PATCH v4 2/5] fs: Add fchmodat2() Alexey Gladkov
2023-07-11 17:05 ` Christian Brauner
2023-07-25 16:36 ` Aleksa Sarai
2023-07-26 13:45 ` Alexey Gladkov
2023-07-27 10:26 ` Christian Brauner
2023-07-27 17:12 ` Aleksa Sarai
2023-07-27 17:39 ` Aleksa Sarai
2023-07-28 8:43 ` David Laight
2023-07-28 18:42 ` dalias
2023-07-27 9:01 ` David Laight
2023-07-27 16:28 ` Andreas Schwab
2023-07-27 17:02 ` Christian Brauner
2023-07-27 17:13 ` dalias
2023-07-27 17:36 ` Christian Brauner
2023-07-27 16:31 ` dalias
2023-07-11 16:16 ` [PATCH v4 3/5] arch: Register fchmodat2, usually as syscall 452 Alexey Gladkov
2023-07-11 16:26 ` Arnd Bergmann
2023-07-25 7:16 ` Geert Uytterhoeven
2023-07-25 16:43 ` Aleksa Sarai
2023-07-27 10:37 ` Christian Brauner
2023-07-27 17:42 ` Aleksa Sarai
2023-07-11 16:16 ` [PATCH v4 4/5] tools headers UAPI: Sync files changed by new fchmodat2 syscall Alexey Gladkov
2023-07-11 17:19 ` Namhyung Kim
2023-07-11 17:23 ` Alexey Gladkov
2023-07-11 16:16 ` [PATCH v4 5/5] selftests: Add fchmodat2 selftest Alexey Gladkov
2023-07-11 17:36 ` (subset) [PATCH v4 0/5] Add a new fchmodat2() syscall Christian Brauner
2023-07-12 2:42 ` Rich Felker
2023-07-25 15:58 ` Add fchmodat2() - or add a more general syscall? David Howells
2023-07-25 16:10 ` Florian Weimer
2023-07-25 16:50 ` Aleksa Sarai
2023-07-25 18:39 ` David Howells
2023-07-25 18:44 ` Rich Felker
2023-07-26 13:30 ` Christian Brauner
2023-07-27 3:57 ` Eric Biggers
2023-07-27 10:27 ` Christian Brauner
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=mhng-07134298-232b-4472-ac6f-cf33862883c5@palmer-si-x1e \
--to=palmer@sifive.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=benh@kernel.crashing.org \
--cc=borntraeger@de.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=christian@brauner.io \
--cc=dalias@libc.org \
--cc=davem@davemloft.net \
--cc=deepa.kernel@gmail.com \
--cc=deller@gmx.de \
--cc=dhowells@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=firoz.khan@linaro.org \
--cc=geert@linux-m68k.org \
--cc=gor@linux.ibm.com \
--cc=hare@suse.com \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=ink@jurassic.park.msu.ru \
--cc=jhogan@kernel.org \
--cc=jolsa@redhat.com \
--cc=kim.phillips@arm.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mattst88@gmail.com \
--cc=mingo@redhat.com \
--cc=monstr@monstr.eu \
--cc=mpe@ellerman.id.au \
--cc=namhyung@kernel.org \
--cc=paul.burton@mips.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
--cc=rth@twiddle.net \
--cc=schwidefsky@de.ibm.com \
--cc=sparclinux@vger.kernel.org \
--cc=stefan@agner.ch \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=tycho@tycho.ws \
--cc=viro@zeniv.linux.org.uk \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=ysato@users.sourceforge.jp \
/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.
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).