Re: [RFC][PATCHES] uaccess-related stuff in net/*

2020-05-20 Thread Al Viro
On Mon, May 11, 2020 at 05:02:51PM -0700, David Miller wrote: > From: Al Viro > Date: Mon, 11 May 2020 05:43:28 +0100 > > > Assorted uaccess-related work in net/*. First, there's > > getting rid of compat_alloc_user_space() mess in MCAST_... > > [gs]et

Re: [PATCH 22/24] uaccess: add memzero_user

2020-05-20 Thread Al Viro
On Wed, May 20, 2020 at 11:13:36PM +0200, Paolo Bonzini wrote: > On 20/05/20 22:40, Christoph Hellwig wrote: > > On Wed, May 20, 2020 at 01:21:43PM -0400, Paolo Bonzini wrote: > >> + unsafe_put_user(val, (unsigned long __user *) from, > >> err_fault); > > This adds a way too long

Re: [PATCH 22/24] uaccess: add memzero_user

2020-05-20 Thread Al Viro
On Wed, May 20, 2020 at 01:40:36PM -0700, Christoph Hellwig wrote: > On Wed, May 20, 2020 at 01:21:43PM -0400, Paolo Bonzini wrote: > > + unsafe_put_user(val, (unsigned long __user *) from, > > err_fault); > > This adds a way too long line. In many ways it would be much nicer

Re: [PATCH 3/2] block: remove ioctl_by_bdev

2020-05-19 Thread Al Viro
On Tue, May 19, 2020 at 04:33:21PM +0200, Christoph Hellwig wrote: > No callers left. No callers left after...? IOW, where are the patches? There'd been several patchsets posted, each with more than one revision... I realize that some of that went into -mm, but could you repost the final

Re: [PATCH 0/3] sparc: port to copy_thread_tls() and struct kernel_clone_args

2020-05-18 Thread Al Viro
On Sun, May 17, 2020 at 11:13:47PM +0100, Al Viro wrote: > Is virtio-blk-pci more resilent to lost interrupt bug introduced in > "sun4u: update PCI topology to include simba PCI bridges"? I hadn't tried > it yet (reverted to the last working mainline qemu commit for now

Re: [PATCH 0/3] sparc: port to copy_thread_tls() and struct kernel_clone_args

2020-05-17 Thread Al Viro
On Sun, May 17, 2020 at 05:34:34PM +0100, Mark Cave-Ayland wrote: > FWIW if you're running a more recent version of QEMU (>=3.1) then you can > also boot > from the virtio-blk-pci device directly instead of having to switch back to > the IDE > device after installation as you have done above.

Re: linux-next boot error: general protection fault in tomoyo_get_local_path

2020-05-15 Thread Al Viro
On Fri, May 15, 2020 at 09:13:57PM +0100, Al Viro wrote: > On Sat, May 16, 2020 at 12:36:28AM +0900, Tetsuo Handa wrote: > > On 2020/05/16 0:18, Tetsuo Handa wrote: [snip] > > A similar bug (racing inode destruction with open() on proc filesystem) was > > fixed as > &

Re: linux-next boot error: general protection fault in tomoyo_get_local_path

2020-05-15 Thread Al Viro
On Sat, May 16, 2020 at 12:36:28AM +0900, Tetsuo Handa wrote: > On 2020/05/16 0:18, Tetsuo Handa wrote: > > This is > > > > if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { > > char *ep; > > const pid_t pid = (pid_t) simple_strtoul(pos + 1, , 10); > >

Re: [PATCH v2] Implement close-on-fork

2020-05-15 Thread Al Viro
r LWN article says it _appears_ that"), none of *BSD do it. IMO it's a bad idea. NAKed-by: Al Viro

Re: [PATCH 11/20] amifb: get rid of pointless access_ok() calls

2020-05-14 Thread Al Viro
On Thu, May 14, 2020 at 04:25:35PM +0200, Bartlomiej Zolnierkiewicz wrote: > Thank you for in-detail explanations, for this patch: > > Acked-by: Bartlomiej Zolnierkiewicz > > Could you also please take care of adding missing checks for {get,put}_user() > failures later? Umm... OK; put_user()

Re: [PATCH 11/20] amifb: get rid of pointless access_ok() calls

2020-05-14 Thread Al Viro
On Thu, May 14, 2020 at 03:45:09PM +0200, Bartlomiej Zolnierkiewicz wrote: > > Hi Al, > > On 5/10/20 1:45 AM, Al Viro wrote: > > From: Al Viro > > > > addresses passed only to get_user() and put_user() > > This driver lacks checks for {get,put}_user() ret

Re: [PATCH 11/18] maccess: remove strncpy_from_unsafe

2020-05-13 Thread Al Viro
On Thu, May 14, 2020 at 12:36:28AM +0200, Daniel Borkmann wrote: > > So on say s390 TASK_SIZE_USUALLy is (-PAGE_SIZE), which means we'd alway > > try the user copy first, which seems odd. > > > > I'd really like to here from the bpf folks what the expected use case > > is here, and if the

Re: [PATCH 04/20] FIEMAP: don't bother with access_ok()

2020-05-13 Thread Al Viro
On Sun, May 10, 2020 at 12:02:41AM -0700, Christoph Hellwig wrote: > On Sun, May 10, 2020 at 12:45:41AM +0100, Al Viro wrote: > > From: Al Viro > > > > we use copy_to_user() on that thing anyway (and always had). > > I already have this patch in this series: > &

Re: file system permissions regression affecting root

2020-05-13 Thread Al Viro
On Wed, May 13, 2020 at 08:00:28AM -0700, Patrick Donnelly wrote: > In newer kernels (at least 5.6), it appears root is not able to write > to files owned by other users in a sticky directory: Yes. Controlled by /proc/sys/fs/protected_regular, which systemd crowd has decided to enable in commit

Re: [PATCH v2 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd()

2020-05-12 Thread Al Viro
On Tue, May 12, 2020 at 01:43:05PM -0600, Shuah Khan wrote: > Fix kernel_read_file_from_fd() to avoid fdput() after a failed fdget(). > fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set > in fd.flags. Fix it anyway since failed fdget() doesn't require > a fdput(). > > This was

Re: [PATCH v2 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range()

2020-05-12 Thread Al Viro
On Tue, May 12, 2020 at 01:43:04PM -0600, Shuah Khan wrote: > @@ -364,15 +364,15 @@ int sync_file_range(struct file *file, loff_t offset, > loff_t nbytes, > int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, >unsigned int flags) > { > - int ret; > -

Re: [PATCH] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-05-12 Thread Al Viro
On Tue, May 12, 2020 at 10:20:21AM +0200, Alexander Potapenko wrote: > On Tue, May 12, 2020 at 5:44 AM Al Viro wrote: > > > > On Tue, May 12, 2020 at 02:09:01AM +0100, Al Viro wrote: > > > On Tue, Apr 21, 2020 at 10:14:25AM +0200, Alexander Potapenko wrote: > > >

Re: [PATCH] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-05-11 Thread Al Viro
On Tue, May 12, 2020 at 02:09:01AM +0100, Al Viro wrote: > On Tue, Apr 21, 2020 at 10:14:25AM +0200, Alexander Potapenko wrote: > > > Not lately and I would also like to hear the details; which regset it is? > > > Should be reasonably easy to find - just memset() the damn thin

Re: [PATCH] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-05-11 Thread Al Viro
On Tue, Apr 21, 2020 at 10:14:25AM +0200, Alexander Potapenko wrote: > > Not lately and I would also like to hear the details; which regset it is? > > Should be reasonably easy to find - just memset() the damn thing to > > something > > recognizable, do whatever triggers that KMSAN report and

[PATCH 06/19] ipv4: do compat setsockopt for MCAST_MSFILTER directly

2020-05-10 Thread Al Viro
From: Al Viro Parallel to what the native setsockopt() does, except that unlike the native setsockopt() we do not use memdup_user() - we want the sockaddr_storage fields properly aligned, so we allocate 4 bytes more and copy compat_group_filter at the offset 4, which yields the proper alignments

[PATCH 04/19] get rid of compat_mc_getsockopt()

2020-05-10 Thread Al Viro
From: Al Viro now we can do MCAST_MSFILTER in compat ->getsockopt() without playing silly buggers with copying things back and forth. We can form a native struct group_filter (sans the variable-length tail) on stack, pass that + pointer to the tail of original request to the helper do

[PATCH 03/19] ip*_mc_gsfget(): lift copyout of struct group_filter into callers

2020-05-10 Thread Al Viro
From: Al Viro pass the userland pointer to the array in its tail, so that part gets copied out by our functions; copyout of everything else is done in the callers. Rationale: reuse for compat; the array is the same in native and compat, the layout of parts before it is different for compat

[PATCH 01/19] lift compat definitions of mcast [sg]etsockopt requests into net/compat.h

2020-05-10 Thread Al Viro
From: Al Viro We want to get rid of compat_mc_[sg]etsockopt() and to have that stuff handled without compat_alloc_user_space(), extra copying through userland, etc. To do that we'll need ipv4 and ipv6 instances of ->compat_[sg]etsockopt() to manipulate the 32bit variants of mcast requests,

[PATCH 07/19] ip6_mc_msfilter(): pass the address list separately

2020-05-10 Thread Al Viro
From: Al Viro that way we'll be able to reuse it for compat case Signed-off-by: Al Viro --- include/net/ipv6.h | 3 ++- net/ipv6/ipv6_sockglue.c | 2 +- net/ipv6/mcast.c | 7 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/net/ipv6.h b/include/net

[PATCH 09/19] ipv[46]: do compat setsockopt for MCAST_{JOIN,LEAVE}_GROUP directly

2020-05-10 Thread Al Viro
From: Al Viro direct parallel to the way these two are handled in the native ->setsockopt() instances - the helpers that do the real work are already separated and can be reused as-is in this case. Signed-off-by: Al Viro --- net/ipv4/ip_sockglue.c | 31 +++

[PATCH 11/19] ipv6: take handling of group_source_req options into a helper

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/ipv6/ipv6_sockglue.c | 65 +++- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index b386a2b3668c..fc525ad9ed3c 100644 --- a/net/ipv6

[PATCH 19/19] atm: switch do_atmif_sioc() to direct use of atm_dev_ioctl()

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/atm/ioctl.c | 25 - 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index 52f2c77e656f..838ebf0cabbf 100644 --- a/net/atm/ioctl.c +++ b/net/atm/ioctl.c @@ -286,30 +286,13

[PATCH 10/19] ipv4: take handling of group_source_req options into a helper

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/ipv4/ip_sockglue.c | 83 ++ 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 937f39906419..4f412b0bdda4 100644 --- a/net/ipv4

[PATCH 14/19] batadv_socket_read(): get rid of pointless access_ok()

2020-05-10 Thread Al Viro
From: Al Viro address is passed only to copy_to_user() Signed-off-by: Al Viro --- net/batman-adv/icmp_socket.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index ccb535c77e5d..8bdabc03b0b2 100644 --- a/net/batman-adv

[PATCH 13/19] get rid of compat_mc_setsockopt()

2020-05-10 Thread Al Viro
From: Al Viro not used anymore Signed-off-by: Al Viro --- include/net/compat.h | 4 --- net/compat.c | 90 2 files changed, 94 deletions(-) diff --git a/include/net/compat.h b/include/net/compat.h index b6043e759cde..2de4dfcdc11f

[PATCH 15/19] atm: separate ATM_GETNAMES handling from the rest of atm_dev_ioctl()

2020-05-10 Thread Al Viro
From: Al Viro atm_dev_ioctl() does copyin in two different ways - one for ATM_GETNAMES, another for everything else. Start with separating the former into a new helper (atm_getnames()). The next step will be to lift the copyin into the callers. Signed-off-by: Al Viro --- net/atm/ioctl.c

[PATCH 12/19] handle the group_source_req options directly

2020-05-10 Thread Al Viro
From: Al Viro Native ->setsockopt() handling of these options (MCAST_..._SOURCE_GROUP and MCAST_{,UN}BLOCK_SOURCE) consists of copyin + call of a helper that does the actual work. The only change needed for ->compat_setsockopt() is a slightly different copyin - the helpers can be

[PATCH 18/19] atm: lift copyin from atm_dev_ioctl()

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/atm/ioctl.c | 25 - net/atm/resources.c | 35 +-- net/atm/resources.h | 4 ++-- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index

[PATCH 17/19] atm: switch do_atm_iobuf() to direct use of atm_getnames()

2020-05-10 Thread Al Viro
From: Al Viro ... and sod the compat_alloc_user_space() with its complications Signed-off-by: Al Viro --- net/atm/ioctl.c | 25 +++-- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index e239cebf48da..fdd0e3434523 100644

[PATCH 05/19] set_mcast_msfilter(): take the guts of setsockopt(MCAST_MSFILTER) into a helper

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/ipv4/ip_sockglue.c | 73 +++--- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 6bdaf43236ea..8c14a474870d 100644 --- a/net/ipv4

[PATCH 08/19] ipv6: do compat setsockopt for MCAST_MSFILTER directly

2020-05-10 Thread Al Viro
From: Al Viro similar to the ipv4 counterpart of that patch - the same trick used to align the tail array properly. Signed-off-by: Al Viro --- net/ipv6/ipv6_sockglue.c | 48 +++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/net/ipv6

[PATCH 16/19] atm: move copyin from atm_getnames() into the caller

2020-05-10 Thread Al Viro
From: Al Viro Signed-off-by: Al Viro --- net/atm/ioctl.c | 19 ++- net/atm/resources.c | 19 +-- net/atm/resources.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index 0b4b07740fe4..e239cebf48da

[PATCH 02/19] compat_ip{,v6}_setsockopt(): enumerate MCAST_... options explicitly

2020-05-10 Thread Al Viro
From: Al Viro We want to check if optname is among the MCAST_... ones; do that as an explicit switch. Signed-off-by: Al Viro --- net/ipv4/ip_sockglue.c | 10 +- net/ipv6/ipv6_sockglue.c | 10 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/net/ipv4

[RFC][PATCHES] uaccess-related stuff in net/*

2020-05-10 Thread Al Viro
ent net/master) is in git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git #uaccess.net Shortlog: Al Viro (19): lift compat definitions of mcast [sg]etsockopt requests into net/compat.h compat_ip{,v6}_setsockopt(): enumerate MCAST_... options explicitly ip*_mc_gsfget(): l

Re: [PATCHES] uaccess simple access_ok() removals

2020-05-09 Thread Al Viro
On Sat, May 09, 2020 at 05:34:58PM -0700, Linus Torvalds wrote: > On Sat, May 9, 2020 at 4:41 PM Al Viro wrote: > > > > Individual patches in followups; if nobody screams - into #for-next > > it goes... > > Looks fine to me, although I only read your com

Re: [PATCH 05/20] tomoyo_write_control(): get rid of pointless access_ok()

2020-05-09 Thread Al Viro
On Sat, May 09, 2020 at 05:57:56PM -0700, Linus Torvalds wrote: > On Sat, May 9, 2020 at 5:51 PM Tetsuo Handa > wrote: > > > > I think that this access_ok() check helps reducing partial writes (either > > "whole amount was processed" or "not processed at all" unless -ENOMEM). > > No it doesn't.

[PATCH 07/20] nvram: drop useless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro we are using copy_to_user()/memdup_user() anyway Signed-off-by: Al Viro --- drivers/char/nvram.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 4667844eee69..8206412d25ba 100644 --- a/drivers/char/nvram.c +++ b/drivers

[PATCH 01/20] dlmfs_file_write(): get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro address passed only to copy_from_user() Signed-off-by: Al Viro --- fs/ocfs2/dlmfs/dlmfs.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 1de77f1a600b..a06f19b67d3b 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2

[PATCH 02/20] fat_dir_ioctl(): hadn't needed that access_ok() for more than a decade...

2020-05-09 Thread Al Viro
From: Al Viro address is passed only to put_user() and copy_to_user() Signed-off-by: Al Viro --- fs/fat/dir.c | 4 1 file changed, 4 deletions(-) diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 054acd9fd033..b4ddf48fa444 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -804,8 +804,6

[PATCH 03/20] btrfs_ioctl_send(): don't bother with access_ok()

2020-05-09 Thread Al Viro
From: Al Viro we do copy_from_user() on that range anyway Signed-off-by: Al Viro --- fs/btrfs/send.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index c5f41bd86765..6a92ecf9eaa2 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -7065,13

[PATCH 06/20] n_hdlc_tty_read(): remove pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro only copy_to_user() is done to the address in question Signed-off-by: Al Viro --- drivers/tty/n_hdlc.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c index 991f49ee4026..b09eac4b6d64 100644 --- a/drivers/tty/n_hdlc.c +++ b

[PATCH 18/20] usb: get rid of pointless access_ok() calls

2020-05-09 Thread Al Viro
From: Al Viro in all affected cases addresses are passed only to copy_from()_user or copy_to_user(). Signed-off-by: Al Viro --- drivers/usb/core/devices.c | 2 -- drivers/usb/core/devio.c| 9 - drivers/usb/gadget/function/f_hid.c | 6 -- 3 files changed, 17

[PATCH 13/20] drivers/crypto/ccp/sev-dev.c: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro Contrary to the comments, those do *NOT* verify anything about writability of memory, etc. In all cases addresses are passed only to copy_to_user(). Signed-off-by: Al Viro --- drivers/crypto/ccp/sev-dev.c | 15 +++ 1 file changed, 3 insertions(+), 12 deletions

[PATCH 15/20] drm_read(): get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro address is passed only to copy_to_user() Signed-off-by: Al Viro --- drivers/gpu/drm/drm_file.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index eb009d3ab48f..6a1f6c802415 100644 --- a/drivers/gpu/drm/drm_file.c

[PATCH 16/20] efi_test: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro really, people - get_user(), copy_from_user(), memdup_user(), etc. all fail if access_ok() does. Signed-off-by: Al Viro --- drivers/firmware/efi/test/efi_test.c | 12 1 file changed, 12 deletions(-) diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers

[PATCH 12/20] omapfb: get rid of pointless access_ok() calls

2020-05-09 Thread Al Viro
From: Al Viro address is passed only to copy_to_user() Signed-off-by: Al Viro --- drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c b/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c index

[PATCH 17/20] lpfc_debugfs: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro No, you do NOT need to "protect copy from user" that way. Incidentally, your userland ABI stinks. I understand that you wanted to accept "reset" and "reset\n" as equivalent, but I suspect that accepting "reset this, you !@^!@!" h

[PATCH 08/20] cm4000_cs.c cmm_ioctl(): get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro copy_to_user()/copy_from_user() for everything Signed-off-by: Al Viro --- drivers/char/pcmcia/cm4000_cs.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 4edb4174a1e2..89681f07bc78 100644

[PATCH 11/20] amifb: get rid of pointless access_ok() calls

2020-05-09 Thread Al Viro
From: Al Viro addresses passed only to get_user() and put_user() Signed-off-by: Al Viro --- drivers/video/fbdev/amifb.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index 20e03e00b66d..6062104f3afb 100644 --- a/drivers/video

[PATCH 05/20] tomoyo_write_control(): get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro address is passed only to get_user() Signed-off-by: Al Viro --- security/tomoyo/common.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 1b467381986f..f93f8acd05f7 100644 --- a/security/tomoyo/common.c +++ b/security

[PATCH 09/20] drivers/fpga/dfl-fme-pr.c: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro followed by copy_from_user() Signed-off-by: Al Viro --- drivers/fpga/dfl-fme-pr.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/fpga/dfl-fme-pr.c b/drivers/fpga/dfl-fme-pr.c index a233a53db708..1194c0e850e0 100644 --- a/drivers/fpga/dfl-fme-pr.c +++ b/drivers

[PATCH 04/20] FIEMAP: don't bother with access_ok()

2020-05-09 Thread Al Viro
From: Al Viro we use copy_to_user() on that thing anyway (and always had). Signed-off-by: Al Viro --- fs/ext4/ioctl.c | 5 - fs/ioctl.c | 5 - 2 files changed, 10 deletions(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index bfc1281fc4cb..a0afd0338722 100644 --- a/fs/ext4

[PATCH 14/20] via-pmu: don't bother with access_ok()

2020-05-09 Thread Al Viro
From: Al Viro we are using copy_to_user() for actual copying Signed-off-by: Al Viro --- drivers/macintosh/via-pmu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 83eb05bf85ff..8450d7c008d0 100644 --- a/drivers/macintosh

[PATCH 19/20] hfi1: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro pin_user_pages_fast() doesn't need that from its caller. NB: only reachable from ->ioctl(), and only under USER_DS Signed-off-by: Al Viro --- drivers/infiniband/hw/hfi1/user_exp_rcv.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/drivers/infiniband/hw/h

[PATCH 4/4] vmci_host: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro get_user_pages_fast() doesn't need the caller to check that. NB: reachable only from ioctl(2) and only under USER_DS Signed-off-by: Al Viro --- drivers/misc/vmw_vmci/vmci_host.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers

[PATCH 10/20] drivers/fpga/dfl-afu-dma-region.c: get rid of pointless access_ok()

2020-05-09 Thread Al Viro
From: Al Viro Address is passed to get_user_pages_fast(), which does access_ok(). NB: this is called only from ->ioctl(), and only under USER_DS. Signed-off-by: Al Viro --- drivers/fpga/dfl-afu-dma-region.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/fpga/dfl-afu-

[PATCHES] uaccess simple access_ok() removals

2020-05-09 Thread Al Viro
if this one comes with a buggered Cc - this is the first time I have to deal with a series with Cc lists varying that much; I hope I manage to get git-send-email do the right thing, but... Shortlog: Al Viro (20): dlmfs_file_write(): get rid of pointless access_ok() fat_dir_ioctl(): hadn't

Re: [PATCH 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range()

2020-05-07 Thread Al Viro
On Fri, May 08, 2020 at 01:05:09AM +0100, Al Viro wrote: > On Thu, May 07, 2020 at 05:57:09PM -0600, Shuah Khan wrote: > > Fix ksys_sync_file_range() to avoid fdput() after a failed fdget(). > > fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set > > in fd.flags

Re: [PATCH 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range()

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 05:57:09PM -0600, Shuah Khan wrote: > Fix ksys_sync_file_range() to avoid fdput() after a failed fdget(). > fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set > in fd.flags. Fix it anyway since failed fdget() doesn't require > a fdput(). > > This was

Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 05:03:17PM -0600, Jens Axboe wrote: > On 5/7/20 4:44 PM, Al Viro wrote: > > On Thu, May 07, 2020 at 04:25:24PM -0600, Jens Axboe wrote: > > > >> static int io_close(struct io_kiocb *req, bool force_nonblock) > >> { > >> + s

Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 04:25:24PM -0600, Jens Axboe wrote: > static int io_close(struct io_kiocb *req, bool force_nonblock) > { > + struct files_struct *files = current->files; > int ret; > > req->close.put_file = NULL; > - ret = __close_fd_get_file(req->close.fd,

Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 02:53:30PM -0600, Jens Axboe wrote: > I think the patch is correct as-is, I took a good look at how we're > currently handling it. None of those three ops should fiddle with > the fd at all, and all of them do forbid the use of fixed files (the > descriptor table

Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 01:05:23PM -0600, Jens Axboe wrote: > On 5/7/20 1:01 PM, Al Viro wrote: > > On Thu, May 07, 2020 at 08:57:25PM +0200, Max Kellermann wrote: > >> If an operation's flag `needs_file` is set, the function > >> io_req_set_file() calls io_file_get

Re: [PATCH] fs/io_uring: fix O_PATH fds in openat, openat2, statx

2020-05-07 Thread Al Viro
On Thu, May 07, 2020 at 08:57:25PM +0200, Max Kellermann wrote: > If an operation's flag `needs_file` is set, the function > io_req_set_file() calls io_file_get() to obtain a `struct file*`. > > This fails for `O_PATH` file descriptors, because those have no > `struct file*` O_PATH descriptors

Re: linux-next: build failure after merge of the vfs tree

2020-05-06 Thread Al Viro
On Thu, May 07, 2020 at 10:39:21AM +1000, Stephen Rothwell wrote: > Hi all, > > After merging the vfs tree, today's linux-next build (arm > multi_v7_defconfig) failed like this: > > fs/eventfd.c: In function 'eventfd_read': > fs/eventfd.c:226:6: error: implicit declaration of function

Re: [PATCH] securityfs: Add missing d_delete() call on removal

2020-05-06 Thread Al Viro
On Wed, May 06, 2020 at 08:34:29AM -0700, Kees Cook wrote: > Just posted the whole series: > https://lore.kernel.org/lkml/20200506152114.50375-1-keesc...@chromium.org/ > > But the specific question was driven by this patch: >

Re: [PATCH] securityfs: Add missing d_delete() call on removal

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 08:28:33PM -0700, Kees Cook wrote: > On Wed, May 06, 2020 at 02:14:31AM +0100, Al Viro wrote: > > On Tue, May 05, 2020 at 04:40:35PM -0700, Kees Cook wrote: > > > After using simple_unlink(), a call to d_delete() is needed in addition > > > to

Re: [PATCH] securityfs: Add missing d_delete() call on removal

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 04:40:35PM -0700, Kees Cook wrote: > After using simple_unlink(), a call to d_delete() is needed in addition > to dput(). > > Signed-off-by: Kees Cook > --- > Is this correct? I went looking around and there are a lot of variations > on the simple_unlink() pattern... > >

Re: remove set_fs calls from the coredump code v6

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 10:42:58PM +0200, Christoph Hellwig wrote: > On Tue, May 05, 2020 at 09:34:46PM +0100, Al Viro wrote: > > Looks good. Want me to put it into vfs.git? #work.set_fs-exec, perhaps? > > Sounds good. Applied, pushed and added into #for-next

Re: remove set_fs calls from the coredump code v6

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 12:12:49PM +0200, Christoph Hellwig wrote: > Hi all, > > this series gets rid of playing with the address limit in the exec and > coredump code. Most of this was fairly trivial, the biggest changes are > those to the spufs coredump code. > > Changes since v5: > - fix

Re: Re: [PATCH net v2 0/2] Revert the 'socket_alloc' life cycle change

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 09:00:44AM -0700, Eric Dumazet wrote: > > Not exactly the 10,000,000, as it is only the possible highest number, but I > > was able to observe clear exponential increase of the number of the objects > > using slabtop. Before the start of the problematic workload, the

Re: [PATCH net 0/2] Revert the 'socket_alloc' life cycle change

2020-05-05 Thread Al Viro
On Tue, May 05, 2020 at 09:28:39AM +0200, SeongJae Park wrote: > From: SeongJae Park > > The commit 6d7855c54e1e ("sockfs: switch to ->free_inode()") made the > deallocation of 'socket_alloc' to be done asynchronously using RCU, as > same to 'sock.wq'. And the following commit 333f7909a857

Re: [PATCH V2 00/11] Subject: Remove duplicated kmap code

2020-05-04 Thread Al Viro
On Mon, May 04, 2020 at 01:17:41PM -0700, Ira Weiny wrote: > > || * arm: much, much worse. We have several files that pull > > linux/highmem.h: > > || arch/arm/mm/cache-feroceon-l2.c, arch/arm/mm/cache-xsc3l2.c, > > || arch/arm/mm/copypage-*.c, arch/arm/mm/dma-mapping.c, arch/arm/mm/flush.c, >

Re: [PATCH V2 00/11] Subject: Remove duplicated kmap code

2020-05-03 Thread Al Viro
On Sun, May 03, 2020 at 10:04:47PM -0700, Ira Weiny wrote: > Grepping for 'asm/highmem.h' and investigations don't reveal any issues... > But > you do have me worried. That said 0-day has been crunching on multiple > versions of this series without issues such as this (save the mips issue >

Re: [PATCH V2 00/11] Subject: Remove duplicated kmap code

2020-05-03 Thread Al Viro
On Sun, May 03, 2020 at 06:09:01PM -0700, ira.we...@intel.com wrote: > From: Ira Weiny > > The kmap infrastructure has been copied almost verbatim to every architecture. > This series consolidates obvious duplicated code by defining core functions > which call into the architectures only when

Re: [PATCH v4] eventfd: convert to f_op->read_iter()

2020-05-03 Thread Al Viro
On Fri, May 01, 2020 at 05:54:09PM -0600, Jens Axboe wrote: > On 5/1/20 5:12 PM, Al Viro wrote: > > On Fri, May 01, 2020 at 01:11:09PM -0600, Jens Axboe wrote: > >> + flags &= EFD_SHARED_FCNTL_FLAGS; > >> + flags |= O_RDWR; > >> + fd = get_un

Re: [PATCH v4] eventfd: convert to f_op->read_iter()

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 01:11:09PM -0600, Jens Axboe wrote: > + flags &= EFD_SHARED_FCNTL_FLAGS; > + flags |= O_RDWR; > + fd = get_unused_fd_flags(flags); > if (fd < 0) > - eventfd_free_ctx(ctx); > + goto err; > + > + file =

Re: [PATCH 2/2] exec: open code copy_string_kernel

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 02:40:13PM -0700, Andrew Morton wrote: > On Fri, 1 May 2020 22:30:48 +0100 Al Viro wrote: > > > On Fri, May 01, 2020 at 02:19:03PM -0700, Andrew Morton wrote: > > > On Fri, 1 May 2020 12:41:05 +0200 Christoph Hellwig wrote: > > > > &

Re: [PATCH 2/2] exec: open code copy_string_kernel

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 09:26:39PM +0200, Christoph Hellwig wrote: > On Fri, May 01, 2020 at 01:50:49PM +0100, Al Viro wrote: > > On Fri, May 01, 2020 at 12:41:05PM +0200, Christoph Hellwig wrote: > > > Currently copy_string_kernel is just a wrapper around copy_strings tha

Re: [PATCH 2/2] exec: open code copy_string_kernel

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 02:19:03PM -0700, Andrew Morton wrote: > On Fri, 1 May 2020 12:41:05 +0200 Christoph Hellwig wrote: > > > Currently copy_string_kernel is just a wrapper around copy_strings that > > simplifies the calling conventions and uses set_fs to allow passing a > > kernel pointer.

Re: [PATCH v3b] eventfd: convert to f_op->read_iter()

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 11:54:01AM -0600, Jens Axboe wrote: > @@ -427,8 +424,17 @@ static int do_eventfd(unsigned int count, int flags) > > fd = anon_inode_getfd("[eventfd]", _fops, ctx, > O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); > - if (fd < 0) > +

Re: [PATCH v2] eventfd: convert to f_op->read_iter()

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 11:18:05AM -0600, Jens Axboe wrote: > - if (res > 0 && put_user(ucnt, (__u64 __user *)buf)) > + if (res > 0 && copy_to_iter(, res, iov) < res) *whoa* It is correct, but only because here res > 0 <=> res == 8. And that's not trivial at the first glance. Please,

Re: [PATCH 2/2] exec: open code copy_string_kernel

2020-05-01 Thread Al Viro
On Fri, May 01, 2020 at 12:41:05PM +0200, Christoph Hellwig wrote: > Currently copy_string_kernel is just a wrapper around copy_strings that > simplifies the calling conventions and uses set_fs to allow passing a > kernel pointer. But due to the fact the we only need to handle a single > kernel

Re: linux-next: manual merge of the akpm-current tree with the bpf-next tree

2020-04-30 Thread Al Viro
On Wed, Apr 29, 2020 at 06:24:06PM +1000, Stephen Rothwell wrote: > Hi Christoph, > > On Wed, 29 Apr 2020 08:54:04 +0200 Christoph Hellwig wrote: > > > > On Tue, Apr 28, 2020 at 11:49:34PM -0700, Alexei Starovoitov wrote: > > > On Tue, Apr 28, 2020 at 11:47 PM Christoph Hellwig wrote: > > > >

Re: [PATCH] pipe: read/write_iter() handler should check for IOCB_NOWAIT

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 10:24:46AM -0600, Jens Axboe wrote: > Pipe read/write only checks for the file O_NONBLOCK flag, but we should > also check for IOCB_NOWAIT for whether or not we should handle this read > or write in a non-blocking fashion. If we don't, then we will block on > data or space

Re: [PATCH V1 09/10] arch/kmap: Define kmap_atomic_prot() for all arch's

2020-04-30 Thread Al Viro
On Fri, May 01, 2020 at 03:37:34AM +0100, Al Viro wrote: > On Thu, Apr 30, 2020 at 01:38:44PM -0700, ira.we...@intel.com wrote: > > > -static inline void *kmap_atomic(struct page *page) > > +static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot) > > {

Re: [PATCH V1 09/10] arch/kmap: Define kmap_atomic_prot() for all arch's

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 01:38:44PM -0700, ira.we...@intel.com wrote: > -static inline void *kmap_atomic(struct page *page) > +static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot) > { > preempt_disable(); > pagefault_disable(); > if (!PageHighMem(page)) >

Re: [PATCH V1 08/10] arch/kmap: Don't hard code kmap_prot values

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 01:38:43PM -0700, ira.we...@intel.com wrote: > From: Ira Weiny > > To support kmap_atomic_prot() on all architectures each arch must > support protections passed in to them. > > Change csky, mips, nds32 and xtensa to use their global kmap_prot value > rather than a hard

Re: [PATCH V1 05/10] arch/kmap_atomic: Consolidate duplicate code

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 01:38:40PM -0700, ira.we...@intel.com wrote: > From: Ira Weiny > > Every arch has the same code to ensure atomic operations and a check for > !HIGHMEM page. > > Remove the duplicate code by defining a core kmap_atomic() which only > calls the arch specific

Re: [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Al Viro
On Fri, May 01, 2020 at 02:42:29AM +0100, Al Viro wrote: > On Thu, Apr 30, 2020 at 03:13:38PM -0700, Matthew Wilcox wrote: > > > > +/** > > > + * clear_page_private - clear page's private field and PG_private. > > > + * @page: page to be cleared. > > &

Re: [RFC PATCH V2 1/9] include/linux/pagemap.h: introduce attach/clear_page_private

2020-04-30 Thread Al Viro
On Thu, Apr 30, 2020 at 03:13:38PM -0700, Matthew Wilcox wrote: > > +/** > > + * clear_page_private - clear page's private field and PG_private. > > + * @page: page to be cleared. > > + * > > + * The counterpart function of attach_page_private. > > + * Return: private data of page or NULL if page

Re: [PATCH] epoll: Fix UAF dentry name access in wakeup source setup

2020-04-28 Thread Al Viro
On Wed, Apr 29, 2020 at 04:31:04AM +0200, Jann Horn wrote: > I'm guessing this will go through akpm's tree? > > fs/eventpoll.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/eventpoll.c b/fs/eventpoll.c > index 8c596641a72b0..5052a41670479 100644 > ---

[git pull] vfs.git fixes

2020-04-28 Thread Al Viro
to b0d3869ce9eeacbb1bbd541909beeef4126426d5: propagate_one(): mnt_set_mountpoint() needs mount_lock (2020-04-27 10:37:14 -0400) Al Viro (2): dlmfs_file_write(): fix the bogosity in handling non-zero *ppos propagate_one

Re: [PATCH v6 11/43] compat_ioctl: move drivers to compat_ptr_ioctl

2019-10-22 Thread Al Viro
On Tue, Oct 22, 2019 at 12:26:09PM +0200, Arnd Bergmann wrote: > On Tue, Oct 22, 2019 at 6:34 AM Al Viro wrote: > > > > On Wed, Oct 09, 2019 at 09:10:11PM +0200, Arnd Bergmann wrote: > > > Each of these drivers has a copy of the same trivial helper function to > >

Re: [PATCH RESEND 1/1] vfs: Really check for inode ptr in lookup_fast

2019-10-22 Thread Al Viro
On Tue, Oct 22, 2019 at 03:37:36PM +0100, Al Viro wrote: > On Tue, Oct 22, 2019 at 07:08:54PM +0530, Ritesh Harjani wrote: > > I think we have still not taken this patch. Al? > You've picked the easiest one to hit, but on e.g. KVM setups you can have the > host thread representin

<    5   6   7   8   9   10   11   12   13   14   >