RE: [PATCH] thermal: sysfs: Fall back to vmalloc() for cooling device's statistics

2020-08-21 Thread David Laight
From: Yue Hu > Sent: 21 August 2020 03:44 > > From: Yue Hu > > We observed warning about kzalloc() when register thermal cooling device > in backlight_device_register(). backlight display can be a cooling device > since reducing screen brightness will can help reduce temperature. > > However,

RE: [RFC PATCH 1/5] printk: implement pr_cont_t

2020-08-20 Thread David Laight
From: Petr Mladek > Sent: 20 August 2020 11:16 ... > Now that I think about it. This is the biggest problem with any temporary > buffer > for pr_cont() lines. I am more and more convinced that we should just > _keep the current behavior_. It is not ideal. But sometimes mixed > messages are always

RE: [RFC PATCH 1/5] printk: implement pr_cont_t

2020-08-20 Thread David Laight
From: Joe Perches > Sent: 20 August 2020 09:00 > > On Thu, 2020-08-20 at 07:44 +0000, David Laight wrote: > > I've no idea how you'd 'size' the number of buffers. > > I believe they are static and assume no more than 10 > simultaneous uses of printk_begin What I mean

RE: [RFC PATCH 1/5] printk: implement pr_cont_t

2020-08-20 Thread David Laight
From: Joe Perches > Sent: 20 August 2020 01:34 > > On Thu, 2020-08-20 at 01:32 +0206, John Ogness wrote: > > Implement a new buffering mechanism for pr_cont messages. > > > > Old mechanism syntax: > > > > printk(KERN_INFO "text"); > > printk(KERN_CONT " continued"); > >

RE: [PATCH] x86/uaccess: Use pointer masking to limit uaccess speculation

2020-08-19 Thread David Laight
From: Josh Poimboeuf > Sent: 19 August 2020 18:02 > > On Wed, Aug 19, 2020 at 09:39:10AM -0700, Andy Lutomirski wrote: > > On Wed, Aug 19, 2020 at 7:50 AM Josh Poimboeuf wrote: > > > +/* > > > + * Sanitize a uaccess pointer such that it becomes NULL if it's not a > > > valid > > > + * user

RE: [PATCH 00/11] Introduce kernel_clone(), kill _do_fork()

2020-08-19 Thread David Laight
From: Matthew Wilcox > Sent: 19 August 2020 16:45 > > On Wed, Aug 19, 2020 at 03:41:48PM +0000, David Laight wrote: > > Does linux have an O(1) (or do I mean o(1)) pid allocator? > > Or does it have to do a linear scan to find a gap?? > > O(log(n)). It us

RE: [PATCH 00/11] Introduce kernel_clone(), kill _do_fork()

2020-08-19 Thread David Laight
From: Eric W. Biederman > Sent: 19 August 2020 16:01 ... > >> Further the design decisions of pids keeps us densly using pids. So I > >> expect it will be a while before we even come close to using 30 bits of > >> pid space. > > > > Also because it's simply annoying to have to type really large

RE: Scheduler benchmarks

2020-08-19 Thread David Laight
From: Bernd Petrovitsch > Sent: 19 August 2020 11:22 > > On 19/08/2020 10:16, Muni Sekhar wrote: > > On Tue, Aug 18, 2020 at 11:45 PM peter enderborg > > wrote: > [...] > >> On the 4.4 kernel you dont have > >> > >> +CONFIG_RETPOLINE=y > >> +CONFIG_INTEL_RDT=y > > Thanks! That is helpful. Yes, I

RE: [PATCH] mtd: spi-nor: intel-spi: Do not try to make the SPI flash chip writable

2020-08-19 Thread David Laight
From: Arnd Bergmann > Sent: 19 August 2020 09:38 ... > If you are really worried about the write protection being bypassed by > a different driver or code injection, the best way would seem to be to > only enable writing in the mtd write callback and disable it immediately > after the write is

RE: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches

2020-08-19 Thread David Laight
From: Arvind Sankar > Sent: 18 August 2020 23:26 ... > gcc-10 optimizes the generic memset implementation in there into a call > to memset. Now that's on x86 which doesn't use the generic > implementation, but this is just waiting to bite us. > > https://godbolt.org/z/6EhG15 Gah, if I want a

RE: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches

2020-08-18 Thread David Laight
From: Nick Desaulniers > Sent: 18 August 2020 21:59 > > On Tue, Aug 18, 2020 at 1:27 PM Nick Desaulniers > wrote: ... > > > -ffreestanding as it stands today does have __builtin_memcpy and > > > friends. But you need to then use #define memcpy __builtin_memcpy etc, > > > which is messy and also

RE: [PATCH 4.19 051/168] dyndbg: fix a BUG_ON in ddebug_describe_flags

2020-08-18 Thread David Laight
From: Pavel Machek > Sent: 18 August 2020 10:51 > > On Mon 2020-08-17 17:16:22, Greg Kroah-Hartman wrote: > > From: Jim Cromie > > > > [ Upstream commit f678ce8cc3cb2ad29df75d8824c74f36398ba871 ] > > > > ddebug_describe_flags() currently fills a caller provided string buffer, > > after testing

RE: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement'

2020-08-18 Thread David Laight
> I'm a big fan of -Wdeclaration-after-statement and I think C++ style > mixed variables/statements code has several disadvantages: Agreed. Personally I think declarations should either be either right at the top of a function or in a very small code block. Otherwise they are annoying to find.

RE: [PATCH 09/11] x86: remove address space overrides using set_fs()

2020-08-17 Thread David Laight
From: Christoph Hellwig > Sent: 17 August 2020 08:32 > > Stop providing the possibility to override the address space using > set_fs() now that there is no need for that any more. To properly > handle the TASK_SIZE_MAX checking for 4 vs 5-level page tables on > x86 a new alternative is

RE: POC: Alternative solution: Re: [PATCH 0/4] printk: reimplement LOG_CONT handling

2020-08-15 Thread David Laight
From: Joe Perches > Sent: 15 August 2020 00:52 ... > > This is why I think any discussion that says "people should buffer > > their lines themselves and we should get rid if pr_cont()" is > > fundamentally broken. > > > > Don't go down that hole. I won't take it. It's wrong. > > I don't think

RE: [PATCH] lib/string.c: implement stpcpy

2020-08-15 Thread David Laight
From: Nick Desaulniers > Sent: 15 August 2020 01:24 > > LLVM implemented a recent "libcall optimization" that lowers calls to > `sprintf(dest, "%s", str)` where the return value is used to > `stpcpy(dest, str) - dest`. This generally avoids the machinery involved > in parsing format strings. > >

RE: [PATCH] ceph: remove unnecessary return in switch statement

2020-08-14 Thread David Laight
From: Luis Henriques > Sent: 14 August 2020 10:38 > > Since there's a return immediately after the 'break', there's no need for > this extra 'return' in the S_IFDIR case. > > Signed-off-by: Luis Henriques > --- > fs/ceph/file.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git

RE: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread David Laight
From: Josef Bacik > Sent: 13 August 2020 18:19 ... > We wouldn't even need the extra +1 part, since we're only copying in how much > the user wants anyway, we could just go ahead and convert this to > > left -= snprintf(buffer, left, "0x%04x\n", *(unsigned int *) table->data); > > and be fine,

RE: [PATCH] proc: use vmalloc for our kernel buffer

2020-08-13 Thread David Laight
From: Josef Bacik > Sent: 13 August 2020 15:53 > > sysctl: pass kernel pointers to ->proc_handler > > we have been pre-allocating a buffer to copy the data from the proc > handlers into, and then copying that to userspace. The problem is this > just blind kmalloc()'s the buffer size passed in

RE: [PATCH] fs/select.c: batch user writes in do_sys_poll

2020-08-13 Thread David Laight
From: Daniel Axtens > Sent: 13 August 2020 12:37 > > >> Seem like this could simply use a copy_to_user to further simplify > >> things? > > > > I'll benchmark it and find out. > > I tried this: > > for (walk = head; walk; walk = walk->next) { > - struct pollfd *fds =

RE: [PATCH v4 1/4] fpga: dfl: change data type of feature id to u16

2020-08-13 Thread David Laight
From: Xu Yilun > Sent: 13 August 2020 10:04 > > On Thu, Aug 13, 2020 at 08:28:05AM +0000, David Laight wrote: > > From: Xu Yilun > > > Sent: 13 August 2020 08:59 > > > On Wed, Aug 12, 2020 at 08:52:39AM +, David Laight wrote: > > > > From: Moritz

RE: [PATCH] fs/select.c: batch user writes in do_sys_poll

2020-08-13 Thread David Laight
From: Christoph Hellwig > Sent: 13 August 2020 08:32 > > On Thu, Aug 13, 2020 at 05:11:20PM +1000, Daniel Axtens wrote: > > When returning results to userspace, do_sys_poll repeatedly calls > > put_user() - once per fd that it's watching. > > > > This means that on architectures that support some

RE: [PATCH] x86: work around clang IAS bug referencing __force_order

2020-08-13 Thread David Laight
From: Nick Desaulniers > Sent: 13 August 2020 01:13 > > On Thu, Aug 6, 2020 at 3:11 PM Thomas Gleixner wrote: > > > > Arnd Bergmann writes: > > > When using the clang integrated assembler, we get a reference > > > to __force_order that should normally get ignored in a few > > > rare cases: > >

RE: [PATCH v4 1/4] fpga: dfl: change data type of feature id to u16

2020-08-13 Thread David Laight
From: Xu Yilun > Sent: 13 August 2020 08:59 > On Wed, Aug 12, 2020 at 08:52:39AM +, David Laight wrote: > > From: Moritz Fischer > > > Sent: 12 August 2020 04:56 > > > > > > On Mon, Aug 10, 2020 at 10:41:10AM +0800, Xu Yilun wrote: > > > > Th

RE: [PATCH] net: untag pointer in sockptr_is_kernel

2020-08-12 Thread David Laight
From: Miles Chen > Sent: 12 August 2020 10:16 > > On Tue, 2020-08-11 at 11:44 +0000, David Laight wrote: > > > On Tue, Aug 11, 2020 at 06:27:04PM +0800, Miles Chen wrote: > > > > From: Miles Chen > > > > > > > > sockptr_

RE: [PATCH v4 1/4] fpga: dfl: change data type of feature id to u16

2020-08-12 Thread David Laight
From: Moritz Fischer > Sent: 12 August 2020 04:56 > > On Mon, Aug 10, 2020 at 10:41:10AM +0800, Xu Yilun wrote: > > The feature id is stored in a 12 bit field in DFH. So a u16 variable is > > enough for feature id. > > > > This patch changes all feature id related places to fit u16. How much

RE: [PATCH 1/2] perf: Add closing sibling events' file descriptors

2020-08-11 Thread David Laight
> On Tue, Aug 11, 2020 at 02:47:03PM +0000, David Laight wrote: > > From: Andi Kleen > > > On Mon, Aug 10, 2020 at 10:36:32PM +0200, Peter Zijlstra wrote: > > > > On Mon, Aug 10, 2020 at 07:45:18AM -0700, Andi Kleen wrote: > > > > > > > > >

RE: [PATCH 1/2] perf: Add closing sibling events' file descriptors

2020-08-11 Thread David Laight
From: Andi Kleen > On Mon, Aug 10, 2020 at 10:36:32PM +0200, Peter Zijlstra wrote: > > On Mon, Aug 10, 2020 at 07:45:18AM -0700, Andi Kleen wrote: > > > > > Unfortunately we're kind of stuck with the old NFILE=1024 default > > > even though it makes little sense on modern servers. > > > > Why

RE: [PATCH] net: untag pointer in sockptr_is_kernel

2020-08-11 Thread David Laight
> On Tue, Aug 11, 2020 at 06:27:04PM +0800, Miles Chen wrote: > > From: Miles Chen > > > > sockptr_is_kernel() uses (sockptr.kernel >= TASK_SIZE) to tell > > if the pointer is kernel space or user space. When user space uses > > the "top byte ignored" feature such as HWAsan, we must untag > > the

RE: [PATCH v7 0/7] Add support for O_MAYEXEC

2020-08-11 Thread David Laight
> On 11/08/2020 00:28, Al Viro wrote: > > On Mon, Aug 10, 2020 at 10:09:09PM +0000, David Laight wrote: > >>> On Mon, Aug 10, 2020 at 10:11:53PM +0200, Mickaël Salaün wrote: > >>>> It seems that there is no more complains nor questions. Do you want me > >&

RE: [PATCH v7 0/7] Add support for O_MAYEXEC

2020-08-10 Thread David Laight
> On Mon, Aug 10, 2020 at 10:11:53PM +0200, Mickaël Salaün wrote: > > It seems that there is no more complains nor questions. Do you want me > > to send another series to fix the order of the S-o-b in patch 7? > > There is a major question regarding the API design and the choice of > hooking that

RE: [RFC][PATCH 2/3] locking,entry: #PF vs TRACE_IRQFLAGS

2020-08-10 Thread David Laight
From: pet...@infradead.org > Sent: 10 August 2020 12:58 > ... > > > --- a/include/linux/entry-common.h > > > +++ b/include/linux/entry-common.h > > > @@ -310,6 +310,7 @@ void irqentry_exit_to_user_mode(struct p > > > #ifndef irqentry_state > > > typedef struct irqentry_state { > > > bool

RE: [PATCH net-next v1] hinic: fix strncpy output truncated compile warnings

2020-08-10 Thread David Laight
> Thanks for your explanation and review. I haven't realized using strncpy() on > NUL-terminated strings > is deprecated > and just trying to avoid the compile warnings. The website you provide helps > me a lot. Thank you very > much! Never try to remove compile-time warnings without

RE: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt

2020-08-08 Thread David Laight
From: Eric Dumazet > Sent: 07 August 2020 19:29 > > On 8/7/20 2:18 AM, David Laight wrote: > > From: Eric Dumazet > >> Sent: 06 August 2020 23:21 > >> > >> On 7/22/20 11:09 PM, Christoph Hellwig wrote: > >>> Rework the remaining setsockopt

RE: [PATCH net-next v1] hinic: fix strncpy output truncated compile warnings

2020-08-08 Thread David Laight
From: luobin (L) > Sent: 08 August 2020 04:37 > > On 2020/8/7 17:32, David Laight wrote: > > From: Luo bin > >> Sent: 07 August 2020 03:09 > >> > >> fix the compile warnings of 'strncpy' output truncated before > >> terminating nul copying N byte

RE: [PATCH 3/3] quota: simplify the quotactl compat handling

2020-08-07 Thread David Laight
From: Christoph Hellwig > Sent: 31 July 2020 13:22 > > Fold the misaligned u64 workarounds into the main quotactl flow instead > of implementing a separate compat syscall handler. > ... > +static int compat_copy_fs_quota_stat(struct compat_fs_quota_stat __user *to, > + struct

RE: [PATCH net-next v1] hinic: fix strncpy output truncated compile warnings

2020-08-07 Thread David Laight
From: Luo bin > Sent: 07 August 2020 03:09 > > fix the compile warnings of 'strncpy' output truncated before > terminating nul copying N bytes from a string of the same length > > Signed-off-by: Luo bin > Reported-by: kernel test robot > --- > V0~V1: > - use the strlen()+1 pattern consistently

RE: [PATCH 25/26] net: pass a sockptr_t into ->setsockopt

2020-08-07 Thread David Laight
From: Eric Dumazet > Sent: 06 August 2020 23:21 > > On 7/22/20 11:09 PM, Christoph Hellwig wrote: > > Rework the remaining setsockopt code to pass a sockptr_t instead of a > > plain user pointer. This removes the last remaining set_fs(KERNEL_DS) > > outside of architecture specific code. > > > >

RE: [PATCH 3/3] quota: simplify the quotactl compat handling

2020-08-07 Thread David Laight
From: Christoph Hellwig > Sent: 31 July 2020 13:22 > > Fold the misaligned u64 workarounds into the main quotactl flow instead > of implementing a separate compat syscall handler. > ... > diff --git a/fs/quota/compat.h b/fs/quota/compat.h > new file mode 100644 > index

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-04 Thread David Laight
> > > If you look at the libffi reference patch I have included, the > > > architecture > > > specific changes to use trampfd just involve a single C function call to > > > a common code function. > > No idea what libffi is, but it must surely be simpler to > rewrite it to avoid nested function

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-04 Thread David Laight
> > If you look at the libffi reference patch I have included, the architecture > > specific changes to use trampfd just involve a single C function call to > > a common code function. No idea what libffi is, but it must surely be simpler to rewrite it to avoid nested function definitions. Or

RE: [RFC PATCH 0/5] madvise MADV_DOEXEC

2020-08-04 Thread David Laight
From: James Bottomley > Sent: 03 August 2020 16:43 > > On Mon, 2020-08-03 at 10:28 -0500, Eric W. Biederman wrote: > [...] > > What is wrong with live migration between one qemu process and > > another qemu process on the same machine not work for this use case? > > > > Just reusing live

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-03 Thread David Laight
From: Madhavan T. Venkataraman > Sent: 03 August 2020 17:03 > > On 8/3/20 3:27 AM, David Laight wrote: > > From: Mark Rutland > >> Sent: 31 July 2020 19:32 > > ... > >>> It requires PC-relative data references. I have not worked on all > >>>

RE: [RFC PATCH 0/5] madvise MADV_DOEXEC

2020-08-03 Thread David Laight
> Maybe. We still need to preserve an anonymous segment, though. MADV_DOEXEC, > or mshare, > or something else. And I think the ability to preserve memory containing > pointers to itself > is an interesting use case, though not ours. Why does all this remind me of the old sendmail code.

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-03 Thread David Laight
From: Mark Rutland > Sent: 31 July 2020 19:32 ... > > It requires PC-relative data references. I have not worked on all > > architectures. > > So, I need to study this. But do all ISAs support PC-relative data > > references? > > Not all do, but pretty much any recent ISA will as it's a

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-03 Thread David Laight
From: Madhavan T. Venkataraman > Sent: 02 August 2020 19:55 > To: Andy Lutomirski > Cc: Kernel Hardening ; Linux API > ; > linux-arm-kernel ; Linux FS Devel > fsde...@vger.kernel.org>; linux-integrity ; > LKML ker...@vger.kernel.org>; LSM List ; > Oleg Nesterov > ; X86 ML > Subject: Re:

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-08-03 Thread David Laight
From: Pavel Machek > Sent: 02 August 2020 12:56 > Hi! > > > > This is quite clever, but now I???m wondering just how much kernel help > > > is really needed. In your series, the trampoline is an non-executable > > > page. I can think of at least two alternative approaches, and I'd > > > like to

RE: [PATCH v2 4/4] KVM: SVM: Use __packed shorthand

2020-07-30 Thread David Laight
From: Joerg Roedel > Sent: 30 July 2020 16:44 > > From: Borislav Petkov > > Use the shorthand to make it more readable. ... > diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h > index 8744817358bf..6b4b43f68f4b 100644 > --- a/arch/x86/include/asm/svm.h > +++

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-07-30 Thread David Laight
> This is quite clever, but now I’m wondering just how much kernel help > is really needed. In your series, the trampoline is an non-executable > page. I can think of at least two alternative approaches, and I'd > like to know the pros and cons. > > 1. Entirely userspace: a return trampoline

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-07-29 Thread David Laight
From: Madhavan T. Venkataraman > Sent: 28 July 2020 19:52 ... > trampfd faults are instruction faults that go through a different code path > than > the one that calls handle_mm_fault(). Perhaps, it is the handle_mm_fault() > that > is time consuming. Could you clarify? Given that the

RE: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor

2020-07-28 Thread David Laight
From: madve...@linux.microsoft.com > Sent: 28 July 2020 14:11 ... > The kernel creates the trampoline mapping without any permissions. When > the trampoline is executed by user code, a page fault happens and the > kernel gets control. The kernel recognizes that this is a trampoline > invocation.

RE: [Linux-kernel-mentees] [PATCH v2] drm/bufs: Prevent kernel-infoleak in copy_one_buf()

2020-07-28 Thread David Laight
From: Peilin Ye > Sent: 28 July 2020 12:52 > Currently `struct drm_buf_desc` is defined as follows: > > struct drm_buf_desc { > int count; > int size; > int low_mark; > int high_mark; > enum { > _DRM_PAGE_ALIGN = 0x01, > _DRM_AGP_BUFFER =

RE: [PATCH] eeprom: at25: set minimum read/write access stride to 1

2020-07-28 Thread David Laight
From: Christian Eggers > Sent: 28 July 2020 11:30 > > On Tuesday, 28 July 2020, 11:52:05 CEST, David Laight wrote: > > From: Christian Eggers > > > > > Sent: 28 July 2020 10:30 > > > > > > SPI eeproms are addressed by byte. > > > > T

RE: [PATCH] eeprom: at25: set minimum read/write access stride to 1

2020-07-28 Thread David Laight
From: Christian Eggers > Sent: 28 July 2020 10:30 > > SPI eeproms are addressed by byte. They also support multi-byte writes - possibly with alignment restrictions. So forcing 4-byte writes (at aligned addresses) would typically speed up writes by a factor of 4 over byte writes. So does this

RE: [PATCH 12/26] netfilter: switch nf_setsockopt to sockptr_t

2020-07-28 Thread David Laight
From: Christoph Hellwig > Sent: 27 July 2020 17:24 > > On Mon, Jul 27, 2020 at 06:16:32PM +0200, Jason A. Donenfeld wrote: > > Maybe sockptr_advance should have some safety checks and sometimes > > return -EFAULT? Or you should always use the implementation where > > being a kernel address is an

RE: get rid of the address_space override in setsockopt v2

2020-07-27 Thread David Laight
From: Al Viro > Sent: 27 July 2020 14:48 > > On Mon, Jul 27, 2020 at 09:51:45AM +0000, David Laight wrote: > > > I'm sure there is code that processes options in chunks. > > This probably means it is possible to put a chunk boundary > > at the end of userspace an

RE: [PATCH 19/26] net/ipv6: switch ipv6_flowlabel_opt to sockptr_t

2020-07-27 Thread David Laight
From: Ido Schimmel > Sent: 27 July 2020 13:15 > On Thu, Jul 23, 2020 at 08:09:01AM +0200, Christoph Hellwig wrote: > > Pass a sockptr_t to prepare for set_fs-less handling of the kernel > > pointer from bpf-cgroup. > > > > Note that the get case is pretty weird in that it actually copies data > >

RE: get rid of the address_space override in setsockopt v2

2020-07-27 Thread David Laight
From: David Miller > Sent: 24 July 2020 23:44 > > From: Christoph Hellwig > Date: Thu, 23 Jul 2020 08:08:42 +0200 > > > setsockopt is the last place in architecture-independ code that still > > uses set_fs to force the uaccess routines to operate on kernel pointers. > > > > This series adds a

RE: [RFC 0/7] Add support to process rx packets in thread

2020-07-26 Thread David Laight
From: Sebastian Gottschall > Sent: 25 July 2020 16:42 > >> i agree. i just can say that i tested this patch recently due this > >> discussion here. and it can be changed by sysfs. but it doesnt work for > >> wifi drivers which are mainly using dummy netdev devices. for this i > >> made a small

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-23 Thread David Laight
From: Al Viro > Sent: 23 July 2020 16:21 ... > The point is, your "~4.5 cycles per vector" is pretty much noise and the > difference between the 3-argument and 4-argument variants could easily be > in the same range. It might be a valid microoptimization, it might be not. > 3-argument variant is

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-23 Thread David Laight
From: Al Viro > Sent: 23 July 2020 15:54 > On Thu, Jul 23, 2020 at 01:54:47PM +, David Laight wrote: > > From: Al Viro > > > Sent: 22 July 2020 18:39 > > > I would love to see your patch, anyway, along with the testcases and > > > performance > &g

RE: [PATCH 03/26] bpfilter: reject kernel addresses

2020-07-23 Thread David Laight
From: 'Christoph Hellwig' > Sent: 23 July 2020 15:45 > > On Thu, Jul 23, 2020 at 02:42:11PM +0000, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 23 July 2020 07:09 > > > > > > The bpfilter user mode helper processes the optval address

RE: [PATCH 03/26] bpfilter: reject kernel addresses

2020-07-23 Thread David Laight
From: Christoph Hellwig > Sent: 23 July 2020 07:09 > > The bpfilter user mode helper processes the optval address using > process_vm_readv. Don't send it kernel addresses fed under > set_fs(KERNEL_DS) as that won't work. What sort of operations is the bpf filter doing on the sockopt buffers?

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-23 Thread David Laight
> I had to replace the ror32() with __builtin_bswap32(). > The kernel object do contain the 'ror' instruction - even though I > didn't find the asm for it. Looking at some instruction timings ror32() and bswap32() seem to need one of the same execution ports. However on Intel cpus bswap64() takes

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-23 Thread David Laight
From: Al Viro > Sent: 22 July 2020 18:39 > I would love to see your patch, anyway, along with the testcases and > performance > comparison. See attached program. Compile and run (as root): csum_iov 1 Unpatched (as shipped) 16 vectors of 1 byte take ~430 clocks on my haswell cpu. With dsl_patch

RE: [PATCH 13/26] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t

2020-07-23 Thread David Laight
From: Christoph Hellwig > Sent: 23 July 2020 07:09 > > This is mostly to prepare for cleaning up the callers, as bpfilter by > design can't handle kernel pointers. You've failed to fix the sense of the above... David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton

RE: [RFC] raw_copy_from_user() semantics

2020-07-23 Thread David Laight
From: Catalin Marinas > Sent: 23 July 2020 11:19 > On Thu, Jul 23, 2020 at 08:37:27AM +, David Laight wrote: > > From: Catalin Marinas > > > Sent: 22 July 2020 17:54 > > > On Wed, Jul 22, 2020 at 01:14:21PM +, David Laight wrote: > > > > From: Ca

RE: [RFC] raw_copy_from_user() semantics

2020-07-23 Thread David Laight
From: Catalin Marinas > Sent: 22 July 2020 17:54 > > On Wed, Jul 22, 2020 at 01:14:21PM +0000, David Laight wrote: > > From: Catalin Marinas > > > Sent: 22 July 2020 12:37 > > > On Sun, Jul 19, 2020 at 12:34:11PM -0700, Linus Torvalds wrote: > > > > On

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-23 Thread David Laight
From: Al Viro > Sent: 22 July 2020 18:39 > On Wed, Jul 22, 2020 at 04:17:02PM +, David Laight wrote: > > > David, do you *ever* bother to RTFS? I mean, competent supercilious twits > > > are annoying, but at least with those you can generally assume that what &g

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-22 Thread David Laight
From: Al Viro > Sent: 22 July 2020 16:55 > To: David Laight > Cc: Linus Torvalds ; > linux-kernel@vger.kernel.org; linux- > a...@vger.kernel.org > Subject: Re: [PATCH 04/18] csum_and_copy_..._user(): pass 0x instead > of 0 as initial sum > > On Wed, Jul 2

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-22 Thread David Laight
From: Al Viro > Sent: 22 July 2020 15:42 > > On Wed, Jul 22, 2020 at 09:27:32AM +0000, David Laight wrote: > > From: Al Viro > > > Sent: 21 July 2020 21:26 > > > Preparation for the change of calling conventions; right now all > > > callers pass 0 a

RE: [RFC] raw_copy_from_user() semantics

2020-07-22 Thread David Laight
From: Catalin Marinas > Sent: 22 July 2020 12:37 > > On Sun, Jul 19, 2020 at 12:34:11PM -0700, Linus Torvalds wrote: > > On Sun, Jul 19, 2020 at 12:28 PM Linus Torvalds > > wrote: > > > I think we should try to get rid of the exact semantics. > > > > Side note: I think one of the historical

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-22 Thread David Laight
From: Linus Torvalds > Sent: 21 July 2020 21:55 > On Tue, Jul 21, 2020 at 1:25 PM Al Viro wrote: > > > > Preparation for the change of calling conventions; right now all > > callers pass 0 as initial sum. Passing 0x instead yields > > the values comparable mod 0x and guarantees that

RE: [PATCH 04/18] csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum

2020-07-22 Thread David Laight
From: Al Viro > Sent: 21 July 2020 21:26 > Preparation for the change of calling conventions; right now all > callers pass 0 as initial sum. Passing 0x instead yields > the values comparable mod 0x and guarantees that 0 will not > be returned on success. > > Signed-off-by: Al Viro >

RE: [RFC 0/7] Add support to process rx packets in thread

2020-07-22 Thread David Laight
From: Andrew Lunn > Sent: 21 July 2020 18:25 > > On Tue, Jul 21, 2020 at 10:44:19PM +0530, Rakesh Pillai wrote: > > NAPI gets scheduled on the CPU core which got the > > interrupt. The linux scheduler cannot move it to a > > different core, even if the CPU on which NAPI is running > > is heavily

RE: io_uring vs in_compat_syscall()

2020-07-22 Thread David Laight
From: Christoph Hellwig > Sent: 22 July 2020 07:31 ... > > I agree that MSG_CMSG_COMPAT is nasty, but I think the concept is > > sound -- rather than tracking whether we're compat by using a > > different function or a per-thread variable, actually explicitly > > tracking the mode seems sensible.

RE: get rid of the address_space override in setsockopt

2020-07-22 Thread David Laight
From: 'Christoph Hellwig' > Sent: 22 July 2020 09:07 > On Tue, Jul 21, 2020 at 09:38:23AM +, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 20 July 2020 13:47 > > > > > > setsockopt is the last place in architecture-independ code that still

RE: [patch V2 2/5] posix-cpu-timers: Convert the flags to a bitmap

2020-07-21 Thread David Laight
From: Thomas Gleixner > Sent: 21 July 2020 17:11 > > Frederic Weisbecker writes: > > On Thu, Jul 16, 2020 at 10:19:25PM +0200, Thomas Gleixner wrote: > >> --- a/kernel/time/posix-cpu-timers.c > >> +++ b/kernel/time/posix-cpu-timers.c > >> @@ -25,7 +25,7 @@ void posix_cputimers_group_init(struct

RE: get rid of the address_space override in setsockopt

2020-07-21 Thread David Laight
From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer,

RE: [PATCH 03/24] net: add a new sockptr_t type

2020-07-21 Thread David Laight
From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > Add a uptr_t type that can hold a pointer to either a user or kernel > memory region, and simply helpers to copy to and from it. For > architectures like x86 that have non-overlapping user and kernel > address space it just is a union and

RE: [PATCH 03/24] net: add a new sockptr_t type

2020-07-21 Thread David Laight
From: Eric Biggers > Sent: 20 July 2020 17:38 ... > How does this not introduce a massive security hole when > CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE? > > AFAICS, userspace can pass in a pointer >= TASK_SIZE, > and this code makes it be treated as a kernel pointer. One thought I've had is

RE: get rid of the address_space override in setsockopt

2020-07-21 Thread David Laight
From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > setsockopt is the last place in architecture-independ code that still > uses set_fs to force the uaccess routines to operate on kernel pointers. > > This series adds a new sockptr_t type that can contained either a kernel > or user pointer,

RE: [PATCH 12/24] bpfilter: switch bpfilter_ip_set_sockopt to sockptr_t

2020-07-21 Thread David Laight
From: Christoph Hellwig > Sent: 20 July 2020 13:47 > > This is mostly to prepare for cleaning up the callers, as bpfilter by > design can't handle kernel pointers. ^^^ user ?? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT,

RE: [PATCH] Fix memory overwriting issue when copy an address to user space

2020-07-20 Thread David Laight
From: lebon zhou > Sent: 20 July 2020 05:35 > To: da...@davemloft.net; k...@kernel.org > Cc: linux-kernel@vger.kernel.org; net...@vger.kernel.org > Subject: [PATCH] Fix memory overwriting issue when copy an address to user > space > > When application provided buffer size less than

RE: Linux kernel in-tree Rust support

2020-07-20 Thread David Laight
From: Adrian Bunk > Sent: 19 July 2020 19:19 ... > The correct range for a mandatory tool are the 6 to 12 years for gcc. > > Debian stable and Ubuntu LTS are providing (different) mechanisms > for installing the kernel from the next stable/LTS release 2 years > later[1] for supporting new

RE: [PATCH 07/13] fs/kernel_read_file: Switch buffer size arg to size_t

2020-07-20 Thread David Laight
From: Kees Cook > Sent: 17 July 2020 18:43 > In preparation for further refactoring of kernel_read_file*(), rename > the "max_size" argument to the more accurate "buf_size", and correct > its type to size_t. Add kerndoc to explain the specifics of how the > arguments will be used. Note that with

RE: [PATCH 1/4] mm/page_alloc: fix non cma alloc context

2020-07-17 Thread David Laight
From: js1...@gmail.com > Sent: 15 July 2020 06:05 > From: Joonsoo Kim > > Currently, preventing cma area in page allocation is implemented by using > current_gfp_context(). However, there are two problems of this > implementation. ... > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-16 Thread David Laight
From: Benjamin Herrenschmidt > Sent: 15 July 2020 23:49 > On Wed, 2020-07-15 at 17:12 -0500, Bjorn Helgaas wrote: > > > I've 'played' with PCIe error handling - without much success. > > > What might be useful is for a driver that has just read ~0u to > > > be able to ask 'has there been an error

RE: [PATCH 7/7] exec: Implement kernel_execve

2020-07-15 Thread David Laight
From: Kees Cook > Sent: 15 July 2020 16:09 > > On Wed, Jul 15, 2020 at 02:55:50PM +0000, David Laight wrote: > > From: Christoph Hellwig > > > Sent: 15 July 2020 07:43 > > > Subject: Re: [PATCH 7/7] exec: Implement kernel_execve > > > > > >

RE: [PATCH 7/7] exec: Implement kernel_execve

2020-07-15 Thread David Laight
From: Christoph Hellwig > Sent: 15 July 2020 07:43 > Subject: Re: [PATCH 7/7] exec: Implement kernel_execve > > On Tue, Jul 14, 2020 at 02:49:23PM -0700, Kees Cook wrote: > > On Tue, Jul 14, 2020 at 08:31:40AM -0500, Eric W. Biederman wrote: > > > +static int count_strings_kernel(const char

RE: [RFC PATCH 00/35] Move all PCIBIOS* definitions into arch/x86

2020-07-15 Thread David Laight
From: Oliver O'Halloran > Sent: 15 July 2020 05:19 > > On Wed, Jul 15, 2020 at 8:03 AM Arnd Bergmann wrote: ... > > - config space accesses are very rare compared to memory > > space access and on the hardware side the error handling > > would be similar, but readl/writel don't return

RE: Linux kernel in-tree Rust support

2020-07-14 Thread David Laight
From: Adrian Bunk > Sent: 12 July 2020 21:45 > Rust gets updated frequently. > Sometimes this also changes the LLVM version used by Rust. > Debian stable supports targets like ARMv5 and 32bit MIPS. > Distribution kernel updates are often automatically installed > on user hardware. This

RE: [PATCH 11/14 v3] PCI/PM: Check return value of pcie_capability_read_*()

2020-07-14 Thread David Laight
> From: Saheed Olayemi Bolarinwa > Sent: 10 July 2020 22:20 > To: helg...@kernel.org > From: Bolarinwa Olayemi Saheed > > On failure pcie_capability_read_dword() sets it's last parameter, > val to 0. > However, with Patch 14/14, it is possible that val is set to ~0 on > failure. This would

RE: objtool clac/stac handling change..

2020-07-13 Thread David Laight
From: Linus Torvalds > Sent: 10 July 2020 23:37 > On Tue, Jul 7, 2020 at 5:35 AM David Laight wrote: > > > > > > So separate copy and checksum passes should easily exceed 4 bytes/clock, > > but I suspect that doing them together never does. > > (Unless th

RE: objtool clac/stac handling change..

2020-07-07 Thread David Laight
From: Al Viro > Sent: 04 July 2020 03:12 ... > BTW, looking at csum_and_copy_{to,from}_user() callers (all 3 of them, > all in lib/iov_iter.c) we have this: > 1) len is never 0 > 2) sum (initial value of csum) is always 0 > 3) failure (reported via *err_ptr) is always treateds as

RE: [PATCH] scsi: sd: stop SSD (non-rotational) disks before reboot

2020-07-03 Thread David Laight
From: Pavel Machek > Sent: 02 July 2020 22:17 > > > during a FLASH write or erase can cause from weakened cells, to much > > > larger damage. It is possible to harden the chip or the design against > > > this, but it is *expensive*. And even if warded off by hardening and no > > > FLASH damage

RE: Writing to a const pointer: is this supposed to happen?

2020-07-03 Thread David Laight
From: Kars Mulder > Sent: 02 July 2020 22:48 > > On Thursday, July 02, 2020 09:55 CEST, David Laight wrote: > > Hmm... sscanf() is also horrid. > > Surprisingly difficult to use correctly. > > > > It is usually best to use strchr() (and maybe str[c]scn()) > >

RE: [PATCH 00/22] add support for Clang LTO

2020-07-02 Thread David Laight
From: Paul E. McKenney > Sent: 01 July 2020 17:06 ... > > Would an asm statement that uses the same 'register' for input and > > output but doesn't actually do anything help? > > It won't generate any code, but the compiler ought to assume that > > it might change the value - so can't do

RE: Writing to a const pointer: is this supposed to happen?

2020-07-02 Thread David Laight
From: Kars Mulder > Sent: 02 July 2020 00:03 > On Saturday, June 27, 2020 12:24 CEST, David Laight wrote: > > The code quoted (using strset()) is almost certainly wrong. > > The caller is unlikely to expect the input be modified. > > Since it doesn't fault the string must

RE: [PATCH 00/22] add support for Clang LTO

2020-07-01 Thread David Laight
From: Peter Zijlstra > Sent: 01 July 2020 10:11 > On Tue, Jun 30, 2020 at 01:30:16PM -0700, Paul E. McKenney wrote: > > On Tue, Jun 30, 2020 at 10:12:43PM +0200, Peter Zijlstra wrote: > > > > I'm not convinced C11 memory_order_consume would actually work for us, > > > even if it would work. That

<    2   3   4   5   6   7   8   9   10   11   >