Re: [PATCH v12 01/12] lib: introduce copy_struct_{to,from}_user helpers

2019-09-05 Thread Al Viro
On Fri, Sep 06, 2019 at 12:49:44AM +0100, Al Viro wrote: > On Fri, Sep 06, 2019 at 09:00:03AM +1000, Aleksa Sarai wrote: > > > > + return -EFAULT; > > > > + } > > > > + /* Copy the interoperable parts of the struct. */ >

Re: [PATCH v12 01/12] lib: introduce copy_struct_{to,from}_user helpers

2019-09-05 Thread Al Viro
On Fri, Sep 06, 2019 at 09:00:03AM +1000, Aleksa Sarai wrote: > > > + return -EFAULT; > > > + } > > > + /* Copy the interoperable parts of the struct. */ > > > + if (__copy_to_user(dst, src, size)) > > > + return -EFAULT; > > > > Why not simply clear_user() and

Re: [PATCH v12 01/12] lib: introduce copy_struct_{to,from}_user helpers

2019-09-05 Thread Al Viro
On Fri, Sep 06, 2019 at 05:56:18AM +1000, Aleksa Sarai wrote: > On 2019-09-05, Al Viro wrote: > > On Thu, Sep 05, 2019 at 08:23:03PM +0200, Christian Brauner wrote: > > > > > Because every caller of that function right now has that limit set > > > anyway iirc

Re: [PATCH v12 01/12] lib: introduce copy_struct_{to,from}_user helpers

2019-09-05 Thread Al Viro
On Thu, Sep 05, 2019 at 08:23:03PM +0200, Christian Brauner wrote: > Because every caller of that function right now has that limit set > anyway iirc. So we can either remove it from here and place it back for > the individual callers or leave it in the helper. > Also, I'm really asking, why not?

Re: [PATCH v12 01/12] lib: introduce copy_struct_{to,from}_user helpers

2019-09-05 Thread Al Viro
On Thu, Sep 05, 2019 at 06:19:22AM +1000, Aleksa Sarai wrote: > +/* > + * "memset(p, 0, size)" but for user space buffers. Caller must have already > + * checked access_ok(p, size). > + */ > +static int __memzero_user(void __user *p, size_t s) > +{ > + const char zeros[BUFFER_SIZE] = {}; > +

Re: [PATCH v12 10/12] namei: aggressively check for nd->root escape on ".." resolution

2019-09-04 Thread Al Viro
On Wed, Sep 04, 2019 at 03:38:20PM -0700, Linus Torvalds wrote: > On Wed, Sep 4, 2019 at 3:31 PM David Howells wrote: > > > > It ought to be reasonably easy to make them per-sb at least, I think. We > > don't allow cross-super rename, right? > > Right now the sequence count handling very much

Re: [PATCH] arch/alpha: Remove dead code

2019-08-03 Thread Al Viro
On Sun, Aug 04, 2019 at 12:47:36AM +0530, Souptick Joarder wrote: > These are dead code since 2.6.11. If there is no plan to use > it further, this can be removed forever. What's the point in removing ifdefed-out debugging printks?

Re: [PATCH v2 2/4] Add fchmodat4(), a new syscall

2019-07-16 Thread Al Viro
On Tue, Jul 16, 2019 at 10:40:46PM -0400, Rich Felker wrote: > On Tue, Jul 16, 2019 at 06:27:17PM -0700, Palmer Dabbelt wrote: > > man 3p says that fchmodat() takes a flags argument, but the Linux > > syscall does not. There doesn't appear to be a good userspace > > workaround for this issue but

Re: [PATCH v2 2/4] Add fchmodat4(), a new syscall

2019-07-16 Thread Al Viro
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

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-14 Thread Al Viro
On Sun, Jul 14, 2019 at 05:00:29PM +1000, Aleksa Sarai wrote: > The basic property being guaranteed by LOOKUP_IN_ROOT is that it will > not result in resolution of a path component which was not inside the > root of the dirfd tree at some point during resolution (and that all > absolute symlink

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-13 Thread Al Viro
On Sat, Jul 13, 2019 at 03:41:53AM +0100, Al Viro wrote: > On Fri, Jul 12, 2019 at 04:00:26PM +0100, Al Viro wrote: > > On Fri, Jul 12, 2019 at 02:25:53PM +0100, Al Viro wrote: > > > > > if (flags & LOOKUP_BENEATH) { > > > nd->root = nd->pat

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 04:00:26PM +0100, Al Viro wrote: > On Fri, Jul 12, 2019 at 02:25:53PM +0100, Al Viro wrote: > > > if (flags & LOOKUP_BENEATH) { > > nd->root = nd->path; > > if (!(flags & LOOKUP_RCU)) > >

Re: [PATCH v9 00/10] namei: openat2(2) path resolution restrictions

2019-07-12 Thread Al Viro
On Sun, Jul 07, 2019 at 12:57:27AM +1000, Aleksa Sarai wrote: > Patch changelog: > v9: > * Replace resolveat(2) with openat2(2). [Linus] > * Output a warning to dmesg if may_open_magiclink() is violated. > * Add an openat2(O_CREAT) testcase. One general note for the future, BTW: for

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 02:25:53PM +0100, Al Viro wrote: > if (flags & LOOKUP_BENEATH) { > nd->root = nd->path; > if (!(flags & LOOKUP_RCU)) > path_get(>root); > else >

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 01:55:52PM +0100, Al Viro wrote: > On Fri, Jul 12, 2019 at 01:39:24PM +0100, Al Viro wrote: > > On Fri, Jul 12, 2019 at 08:57:45PM +1000, Aleksa Sarai wrote: > > > > > > > @@ -2350,9 +2400,11 @@ static const char *path_init(struct nameidata

Re: [PATCH v9 01/10] namei: obey trailing magic-link DAC permissions

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 10:20:17PM +1000, Aleksa Sarai wrote: > On 2019-07-12, Al Viro wrote: > > On Sun, Jul 07, 2019 at 12:57:28AM +1000, Aleksa Sarai wrote: > > > @@ -514,7 +516,14 @@ static void set_nameidata(struct nameidata *p, int > > > dfd, struct filename

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 01:39:24PM +0100, Al Viro wrote: > On Fri, Jul 12, 2019 at 08:57:45PM +1000, Aleksa Sarai wrote: > > > > > @@ -2350,9 +2400,11 @@ static const char *path_init(struct nameidata > > > > *nd, unsigned flags) > > > >

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 08:57:45PM +1000, Aleksa Sarai wrote: > > > @@ -2350,9 +2400,11 @@ static const char *path_init(struct nameidata *nd, > > > unsigned flags) > > > s = ERR_PTR(error); > > > return s; > > > } > > > - error = dirfd_path_init(nd); > > > - if

Re: [PATCH v9 01/10] namei: obey trailing magic-link DAC permissions

2019-07-12 Thread Al Viro
On Fri, Jul 12, 2019 at 05:14:54AM +0100, Al Viro wrote: > That's not quite guaranteed (it is possible to bind a symlink on top > of a regular file, and you will get LOOKUP_JUMPED on the entry into > trailing_symlink() when looking the result up). Moreover, why bother > with LOOKUP

Re: [PATCH v9 05/10] namei: O_BENEATH-style path resolution flags

2019-07-11 Thread Al Viro
On Sun, Jul 07, 2019 at 12:57:32AM +1000, Aleksa Sarai wrote: > @@ -1442,8 +1464,11 @@ static int follow_dotdot_rcu(struct nameidata *nd) > struct inode *inode = nd->inode; > > while (1) { > - if (path_equal(>path, >root)) > + if (path_equal(>path, >root)) {

Re: [PATCH v9 04/10] namei: split out nd->dfd handling to dirfd_path_init

2019-07-11 Thread Al Viro
On Sun, Jul 07, 2019 at 12:57:31AM +1000, Aleksa Sarai wrote: > Previously, path_init's handling of *at(dfd, ...) was only done once, > but with LOOKUP_BENEATH (and LOOKUP_IN_ROOT) we have to parse the > initial nd->path at different times (before or after absolute path > handling) depending on

Re: [PATCH v9 01/10] namei: obey trailing magic-link DAC permissions

2019-07-11 Thread Al Viro
On Sun, Jul 07, 2019 at 12:57:28AM +1000, Aleksa Sarai wrote: > @@ -514,7 +516,14 @@ static void set_nameidata(struct nameidata *p, int dfd, > struct filename *name) > p->stack = p->internal; > p->dfd = dfd; > p->name = name; > - p->total_link_count = old ?

Re: [PATCH 1/2] open: add close_range()

2019-05-21 Thread Al Viro
On Tue, May 21, 2019 at 01:34:47PM +0200, Christian Brauner wrote: > This adds the close_range() syscall. It allows to efficiently close a range > of file descriptors up to all file descriptors of a calling task. > > The syscall came up in a recent discussion around the new mount API and >

Re: [PATCH] x86: Deprecate a.out support

2019-03-10 Thread Al Viro
On Sun, Mar 10, 2019 at 03:40:20PM -0700, Linus Torvalds wrote: > SYSCALL_DEFINE3(osf_readv, unsigned long, fd, > const struct iovec __user *, vector, unsigned long, count) > { > -#ifdef CONFIG_OSF4_COMPAT > - if (unlikely(personality(current->personality) == PER_OSF4)) > -

[git pull] alpha syscall glue stuff

2018-10-24 Thread Al Viro
) Al Viro (2): alpha: use alpha_ni_syscall only for syscall zero alpha: unify the glue for sigreturn-like syscalls arch/alpha/kernel/entry.S | 53 arch/alpha/kernel/systbls.S | 318 ++-- 2 files changed, 183

Re: [PATCH 1/6] alpha: Move __IGNORE* entries to non uapi header

2018-08-11 Thread Al Viro
On Mon, Jul 16, 2018 at 03:53:53PM +0530, Firoz Khan wrote: > It is correct to keep __IGNORE* entry in non uapi header > asm/unistd.h while uapi/asm/unistd.h must hold information > only useful for user space applications. > diff --git a/arch/alpha/include/uapi/asm/unistd.h >

Re: [PATCH 3/6] alpha: Unify the not-implemented system call entry name

2018-08-10 Thread Al Viro
On Fri, Aug 10, 2018 at 07:31:55PM -0700, Richard Henderson wrote: > > +++ b/arch/alpha/kernel/entry.S > > @@ -473,7 +473,7 @@ entSys: > > bne $3, strace > > beq $4, 1f > > ldq $27, 0($5) > > -1: jsr $26, ($27), alpha_ni_syscall > > +1: jsr $26, ($27),

Re: [PATCH 3/6] alpha: Unify the not-implemented system call entry name

2018-08-10 Thread Al Viro
is that extra twist needed in case of syscall #0. Let's keep it only for syscall #0 and replace the rest with sys_ni_syscall. And use sys_ni_syscall for "number out range" in ptraced-call case, as we'd been doing for normal codepath since 2.1.86... Signed-off-by: Al Viro --- d

Re: [PATCH v2] fs: don't let getdents return bogus names

2018-07-31 Thread Al Viro
On Tue, Jul 31, 2018 at 06:10:27PM +0200, Jann Horn wrote: > +/* > + * Most filesystems don't filter out bogus directory entry names, and > userspace > + * can get very confused by such names. Behave as if a low-level IO error had > + * happened while reading directory entries. > + */ > +bool

[PATCH] fix osf_wait4() breakage

2018-07-22 Thread Al Viro
kernel_wait4() expects a userland address for status - it's only rusage that goes as a kernel one (and needs a copyout afterwards) Fixes: "osf_wait4: switch to kernel_wait4()" Cc: sta...@vger.kernel.org # v4.12+ Signed-off-by: Al Viro --- diff --git a/arch/alpha/kernel/osf_sys.c b/

Re: [PATCH] fs: don't let getdents return bogus names

2018-07-16 Thread Al Viro
On Mon, Jul 16, 2018 at 09:48:43PM +0200, Jann Horn wrote: > When you e.g. run `find` on a directory for which getdents returns > "filenames" that contain slashes, `find` passes those "filenames" back to > the kernel, which then interprets them as paths. That could conceivably > cause userspace to

Re: [PATCH] sys: don't hold uts_sem while accessing userspace memory

2018-06-25 Thread Al Viro
On Mon, Jun 25, 2018 at 06:34:10PM +0200, Jann Horn wrote: > + char tmp[32]; > > - if (namelen > 32) > + if (namelen < 0 || namelen > 32) > namelen = 32; > > down_read(_sem); > kname = utsname()->domainname; > len = strnlen(kname, namelen); > -