Re: [PATCH v3 1/4] seccomp: add a return code to trap to userspace
A few other piddly suggestions. On Thu, May 31, 2018 at 08:49:46AM -0600, Tycho Andersen wrote: > This patch introduces a means for syscalls matched in seccomp to notify > some other task that a particular filter has been triggered. > > The motivation for this is primarily for use with containers. For example, > if a container does an init_module(), we obviously don't want to load this > untrusted code, which may be compiled for the wrong version of the kernel > anyway. Instead, we could parse the module image, figure out which module > the container is trying to load and load it on the host. > > As another example, containers cannot mknod(), since this checks > capable(CAP_SYS_ADMIN). However, harmless devices like /dev/null or > /dev/zero should be ok for containers to mknod, but we'd like to avoid hard > coding some whitelist in the kernel. Another example is mount(), which has > many security restrictions for good reason, but configuration or runtime > knowledge could potentially be used to relax these restrictions. > > This patch adds functionality that is already possible via at least two > other means that I know about, both of which involve ptrace(): first, one > could ptrace attach, and then iterate through syscalls via PTRACE_SYSCALL. > Unfortunately this is slow, so a faster version would be to install a > filter that does SECCOMP_RET_TRACE, which triggers a PTRACE_EVENT_SECCOMP. > Since ptrace allows only one tracer, if the container runtime is that > tracer, users inside the container (or outside) trying to debug it will not > be able to use ptrace, which is annoying. It also means that older > distributions based on Upstart cannot boot inside containers using ptrace, > since upstart itself uses ptrace to start services. > > The actual implementation of this is fairly small, although getting the > synchronization right was/is slightly complex. > > Finally, it's worth noting that the classic seccomp TOCTOU of reading > memory data from the task still applies here, but can be avoided with > careful design of the userspace handler: if the userspace handler reads all > of the task memory that is necessary before applying its security policy, > the tracee's subsequent memory edits will not be read by the tracer. > > v2: * make id a u64; the idea here being that it will never overflow, > because 64 is huge (one syscall every nanosecond => wrap every 584 > years) (Andy) > * prevent nesting of user notifications: if someone is already attached > the tree in one place, nobody else can attach to the tree (Andy) > * notify the listener of signals the tracee receives as well (Andy) > * implement poll > v3: * lockdep fix (Oleg) > * drop unnecessary WARN()s (Christian) > * rearrange error returns to be more rpetty (Christian) > * fix build in !CONFIG_SECCOMP_USER_NOTIFICATION case > > Signed-off-by: Tycho Andersen > CC: Kees Cook > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Eric W. Biederman > CC: "Serge E. Hallyn" > CC: Christian Brauner > CC: Tyler Hicks > CC: Akihiro Suda > --- > arch/Kconfig | 7 + > include/linux/seccomp.h | 3 +- > include/uapi/linux/seccomp.h | 18 +- > kernel/seccomp.c | 398 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 195 - > 5 files changed, 615 insertions(+), 6 deletions(-) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 75dd23acf133..1c1ae8d8c8b9 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -401,6 +401,13 @@ config SECCOMP_FILTER > > See Documentation/prctl/seccomp_filter.txt for details. > > +config SECCOMP_USER_NOTIFICATION > + bool "Enable the SECCOMP_RET_USER_NOTIF seccomp action" > + depends on SECCOMP_FILTER > + help > + Enable SECCOMP_RET_USER_NOTIF, a return code which can be used by > seccomp > + programs to notify a userspace listener that a particular event > happened. > + > config HAVE_GCC_PLUGINS > bool > help > diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h > index c723a5c4e3ff..0fd3e0676a1c 100644 > --- a/include/linux/seccomp.h > +++ b/include/linux/seccomp.h > @@ -5,7 +5,8 @@ > #include > > #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ > - SECCOMP_FILTER_FLAG_LOG) > + SECCOMP_FILTER_FLAG_LOG | \ > + SECCOMP_FILTER_FLAG_GET_LISTENER) > > #ifdef CONFIG_SECCOMP > > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h > index 2a0bd9dd104d..8160e6cad528 100644 > --- a/include/uapi/linux/seccomp.h > +++ b/include/uapi/linux/seccomp.h > @@ -17,8 +17,9 @@ > #define SECCOMP_GET_ACTION_AVAIL 2 > > /* Valid flags for SECCOMP_SET_MODE_FILTER */ > -#define SECCOMP_FILTER_FLAG_TSYNC1 > -#define SECCOMP_FILTER_FLAG_LOG
Re: [PATCH 2/3] pinctrl: msm: Mux out gpio function with gpio_request()
Quoting Doug Anderson (2018-06-19 14:38:57) > On Tue, Jun 19, 2018 at 2:18 PM, Stephen Boyd wrote: > > Quoting Doug Anderson (2018-06-18 16:54:49) > >> > >> Is there a reason why you'd want to return 0 instead of some sort of > >> error code? Wouldn't you want to know that this pin can't be a GPIO? > > > > On ACPI there aren't any functions and thus all pins are GPIO mode and > > only GPIO mode if they're used as GPIOs. At least that's my > > understanding of how the ACPI version of this driver works. > > OK. I have no understanding of how the ACPI version of this driver > works, so your understanding is much more likely to be right than > mine. I guess this is just "pinctrl-qdf2xxx.c"? > Yes that's the single ACPI driver. > > >> Another non-ACPI example is sdc2 on sdm845 and it seems like you'd > >> want to know if someone tried to set one of those as a GPIO. > >> > >> ...oh, but I guess ufs_reset also has no funcs but it still probably > >> wants to use the GPIO framework to write something. Hrmmm... Maybe > >> check if either in_bit or out_bit is not -1? > > > > ufs_reset and sdc2 aren't in the GPIO chip's numberspace so I don't > > think we need to care? At least I can't convince myself that those pins > > would eventually call into the this function. We could check if offset > > is greater than ngpios for the chip but that seems useless if higher > > layers are handling this already. > > Ah, I see what you mean. These pins do have numbers in the code: > > PINCTRL_PIN(150, "SDC2_CLK"), > PINCTRL_PIN(151, "SDC2_CMD"), > PINCTRL_PIN(152, "SDC2_DATA"), > PINCTRL_PIN(153, "UFS_RESET"), > > ...but those are effectively made up numbers and they are all past the > "ngpios" (150). ...and the higher level code seems to be already > checking that. Right. Hopefully that saves us from this trouble. > > > OK, thought I've already proven my cluelessness about this driver, > FWIW this patch makes sense to me now so FWIW: > > Reviewed-by: Douglas Anderson > Thanks!
Re: [PATCH v3 1/4] seccomp: add a return code to trap to userspace
A few other piddly suggestions. On Thu, May 31, 2018 at 08:49:46AM -0600, Tycho Andersen wrote: > This patch introduces a means for syscalls matched in seccomp to notify > some other task that a particular filter has been triggered. > > The motivation for this is primarily for use with containers. For example, > if a container does an init_module(), we obviously don't want to load this > untrusted code, which may be compiled for the wrong version of the kernel > anyway. Instead, we could parse the module image, figure out which module > the container is trying to load and load it on the host. > > As another example, containers cannot mknod(), since this checks > capable(CAP_SYS_ADMIN). However, harmless devices like /dev/null or > /dev/zero should be ok for containers to mknod, but we'd like to avoid hard > coding some whitelist in the kernel. Another example is mount(), which has > many security restrictions for good reason, but configuration or runtime > knowledge could potentially be used to relax these restrictions. > > This patch adds functionality that is already possible via at least two > other means that I know about, both of which involve ptrace(): first, one > could ptrace attach, and then iterate through syscalls via PTRACE_SYSCALL. > Unfortunately this is slow, so a faster version would be to install a > filter that does SECCOMP_RET_TRACE, which triggers a PTRACE_EVENT_SECCOMP. > Since ptrace allows only one tracer, if the container runtime is that > tracer, users inside the container (or outside) trying to debug it will not > be able to use ptrace, which is annoying. It also means that older > distributions based on Upstart cannot boot inside containers using ptrace, > since upstart itself uses ptrace to start services. > > The actual implementation of this is fairly small, although getting the > synchronization right was/is slightly complex. > > Finally, it's worth noting that the classic seccomp TOCTOU of reading > memory data from the task still applies here, but can be avoided with > careful design of the userspace handler: if the userspace handler reads all > of the task memory that is necessary before applying its security policy, > the tracee's subsequent memory edits will not be read by the tracer. > > v2: * make id a u64; the idea here being that it will never overflow, > because 64 is huge (one syscall every nanosecond => wrap every 584 > years) (Andy) > * prevent nesting of user notifications: if someone is already attached > the tree in one place, nobody else can attach to the tree (Andy) > * notify the listener of signals the tracee receives as well (Andy) > * implement poll > v3: * lockdep fix (Oleg) > * drop unnecessary WARN()s (Christian) > * rearrange error returns to be more rpetty (Christian) > * fix build in !CONFIG_SECCOMP_USER_NOTIFICATION case > > Signed-off-by: Tycho Andersen > CC: Kees Cook > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Eric W. Biederman > CC: "Serge E. Hallyn" > CC: Christian Brauner > CC: Tyler Hicks > CC: Akihiro Suda > --- > arch/Kconfig | 7 + > include/linux/seccomp.h | 3 +- > include/uapi/linux/seccomp.h | 18 +- > kernel/seccomp.c | 398 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 195 - > 5 files changed, 615 insertions(+), 6 deletions(-) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 75dd23acf133..1c1ae8d8c8b9 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -401,6 +401,13 @@ config SECCOMP_FILTER > > See Documentation/prctl/seccomp_filter.txt for details. > > +config SECCOMP_USER_NOTIFICATION > + bool "Enable the SECCOMP_RET_USER_NOTIF seccomp action" > + depends on SECCOMP_FILTER > + help > + Enable SECCOMP_RET_USER_NOTIF, a return code which can be used by > seccomp > + programs to notify a userspace listener that a particular event > happened. > + > config HAVE_GCC_PLUGINS > bool > help > diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h > index c723a5c4e3ff..0fd3e0676a1c 100644 > --- a/include/linux/seccomp.h > +++ b/include/linux/seccomp.h > @@ -5,7 +5,8 @@ > #include > > #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ > - SECCOMP_FILTER_FLAG_LOG) > + SECCOMP_FILTER_FLAG_LOG | \ > + SECCOMP_FILTER_FLAG_GET_LISTENER) > > #ifdef CONFIG_SECCOMP > > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h > index 2a0bd9dd104d..8160e6cad528 100644 > --- a/include/uapi/linux/seccomp.h > +++ b/include/uapi/linux/seccomp.h > @@ -17,8 +17,9 @@ > #define SECCOMP_GET_ACTION_AVAIL 2 > > /* Valid flags for SECCOMP_SET_MODE_FILTER */ > -#define SECCOMP_FILTER_FLAG_TSYNC1 > -#define SECCOMP_FILTER_FLAG_LOG
Re: [PATCH 2/3] pinctrl: msm: Mux out gpio function with gpio_request()
Quoting Doug Anderson (2018-06-19 14:38:57) > On Tue, Jun 19, 2018 at 2:18 PM, Stephen Boyd wrote: > > Quoting Doug Anderson (2018-06-18 16:54:49) > >> > >> Is there a reason why you'd want to return 0 instead of some sort of > >> error code? Wouldn't you want to know that this pin can't be a GPIO? > > > > On ACPI there aren't any functions and thus all pins are GPIO mode and > > only GPIO mode if they're used as GPIOs. At least that's my > > understanding of how the ACPI version of this driver works. > > OK. I have no understanding of how the ACPI version of this driver > works, so your understanding is much more likely to be right than > mine. I guess this is just "pinctrl-qdf2xxx.c"? > Yes that's the single ACPI driver. > > >> Another non-ACPI example is sdc2 on sdm845 and it seems like you'd > >> want to know if someone tried to set one of those as a GPIO. > >> > >> ...oh, but I guess ufs_reset also has no funcs but it still probably > >> wants to use the GPIO framework to write something. Hrmmm... Maybe > >> check if either in_bit or out_bit is not -1? > > > > ufs_reset and sdc2 aren't in the GPIO chip's numberspace so I don't > > think we need to care? At least I can't convince myself that those pins > > would eventually call into the this function. We could check if offset > > is greater than ngpios for the chip but that seems useless if higher > > layers are handling this already. > > Ah, I see what you mean. These pins do have numbers in the code: > > PINCTRL_PIN(150, "SDC2_CLK"), > PINCTRL_PIN(151, "SDC2_CMD"), > PINCTRL_PIN(152, "SDC2_DATA"), > PINCTRL_PIN(153, "UFS_RESET"), > > ...but those are effectively made up numbers and they are all past the > "ngpios" (150). ...and the higher level code seems to be already > checking that. Right. Hopefully that saves us from this trouble. > > > OK, thought I've already proven my cluelessness about this driver, > FWIW this patch makes sense to me now so FWIW: > > Reviewed-by: Douglas Anderson > Thanks!
4.18.0-rc1-next-20180619 boot failed on beagle board x15
Linux next (4.18.0-rc1-next-20180619) boot failed on beagle board x15. Full log of trace please refer this link, https://lkft.validation.linaro.org/scheduler/job/291535#L946 Here is back trace, [3.561640] omap_rng 4809.rng: Random Number Generator ver. 20 [3.611949] brd: module loaded [3.641298] loop: module loaded [3.646435] at24 0-0050: 4096 byte 24c32 EEPROM, writable, 1 bytes/write [3.658481] [ cut here ] [3.663196] WARNING: CPU: 0 PID: 1 at /srv/oe/build/tmp-rpb-glibc/work-shared/am57xx-evm/kernel-source/drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x27c/0x39c [3.678052] 4400.ocp:L3 Custom Error: MASTER MPU TARGET L4_CFG (Read): Data Access in User mode during Functional access [3.689330] Modules linked in: [3.692426] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc1-next-20180619 #1 [3.699952] Hardware name: Generic DRA74X (Flattened Device Tree) [3.706099] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [3.713897] [] (show_stack) from [] (dump_stack+0xb0/0xdc) [3.721171] [] (dump_stack) from [] (__warn+0x118/0x130) [3.728270] [] (__warn) from [] (warn_slowpath_fmt+0x58/0x74) [3.735808] [] (warn_slowpath_fmt) from [] (l3_interrupt_handler+0x27c/0x39c) [3.744742] [] (l3_interrupt_handler) from [] (__handle_irq_event_percpu+0x90/0x45c) [3.754286] [] (__handle_irq_event_percpu) from [] (handle_irq_event_percpu+0x3c/0x8c) [3.764001] [] (handle_irq_event_percpu) from [] (handle_irq_event+0x48/0x6c) [3.772933] [] (handle_irq_event) from [] (handle_fasteoi_irq+0xb0/0x164) [3.781513] [] (handle_fasteoi_irq) from [] (generic_handle_irq+0x34/0x44) [3.790183] [] (generic_handle_irq) from [] (__handle_domain_irq+0x6c/0xc4) [3.798941] [] (__handle_domain_irq) from [] (gic_handle_irq+0x68/0xac) [3.807347] [] (gic_handle_irq) from [] (__irq_svc+0x5c/0x7c) [3.814874] Exception stack(0xee179c70 to 0xee179cb8) [3.819963] 9c60: fc14 ee3e2f10 ee3a9810 [3.828189] 9c80: ee3e2f10 fc140004 fc14 ee3a9800 ee3a9810 ee179cdc [3.836414] 9ca0: ee179ce0 ee179cc0 c0c3b364 c0c3b2ec 6013 [3.843079] [] (__irq_svc) from [] (ahci_enable_ahci+0x24/0x70) [3.850789] [] (ahci_enable_ahci) from [] (ahci_save_initial_config+0x2c/0x388) [3.859894] [] (ahci_save_initial_config) from [] (ahci_platform_init_host+0x9c/0x4f4) [3.869609] [] (ahci_platform_init_host) from [] (ahci_probe+0xa0/0xc0) [3.878018] [] (ahci_probe) from [] (platform_drv_probe+0x58/0xac) [3.885989] [] (platform_drv_probe) from [] (driver_probe_device+0x25c/0x338) [3.894915] [] (driver_probe_device) from [] (__driver_attach+0xf4/0xf8) [3.903411] [] (__driver_attach) from [] (bus_for_each_dev+0x78/0xc4) [3.911643] [] (bus_for_each_dev) from [] (driver_attach+0x2c/0x30) [3.919696] [] (driver_attach) from [] (bus_add_driver+0x114/0x220) [3.927752] [] (bus_add_driver) from [] (driver_register+0x88/0x11c) [3.935896] [] (driver_register) from [] (__platform_driver_register+0x50/0x58) [3.945003] [] (__platform_driver_register) from [] (ahci_driver_init+0x24/0x28) [3.954195] [] (ahci_driver_init) from [] (do_one_initcall+0x9c/0x434) [3.962517] [] (do_one_initcall) from [] (kernel_init_freeable+0x3b8/0x53c) [3.971276] [] (kernel_init_freeable) from [] (kernel_init+0x18/0x128) [3.979597] [] (kernel_init) from [] (ret_from_fork+0x14/0x28) [3.987210] Exception stack(0xee179fb0 to 0xee179ff8) [3.992298] 9fa0: [4.000524] 9fc0: [4.008750] 9fe0: 0013 [4.015405] irq event stamp: 663130 [4.018926] hardirqs last enabled at (663129): [] _raw_spin_unlock_irqrestore+0x40/0x6c [4.027939] hardirqs last disabled at (663130): [] __irq_svc+0x4c/0x7c [4.035384] softirqs last enabled at (661486): [] __do_softirq+0x2a8/0x5e8 [4.043262] softirqs last disabled at (661449): [] irq_exit+0x178/0x1a4 [4.050826] ---[ end trace 095abac70926448f ]--- Best regards Naresh Kamboju
4.18.0-rc1-next-20180619 boot failed on beagle board x15
Linux next (4.18.0-rc1-next-20180619) boot failed on beagle board x15. Full log of trace please refer this link, https://lkft.validation.linaro.org/scheduler/job/291535#L946 Here is back trace, [3.561640] omap_rng 4809.rng: Random Number Generator ver. 20 [3.611949] brd: module loaded [3.641298] loop: module loaded [3.646435] at24 0-0050: 4096 byte 24c32 EEPROM, writable, 1 bytes/write [3.658481] [ cut here ] [3.663196] WARNING: CPU: 0 PID: 1 at /srv/oe/build/tmp-rpb-glibc/work-shared/am57xx-evm/kernel-source/drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x27c/0x39c [3.678052] 4400.ocp:L3 Custom Error: MASTER MPU TARGET L4_CFG (Read): Data Access in User mode during Functional access [3.689330] Modules linked in: [3.692426] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc1-next-20180619 #1 [3.699952] Hardware name: Generic DRA74X (Flattened Device Tree) [3.706099] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [3.713897] [] (show_stack) from [] (dump_stack+0xb0/0xdc) [3.721171] [] (dump_stack) from [] (__warn+0x118/0x130) [3.728270] [] (__warn) from [] (warn_slowpath_fmt+0x58/0x74) [3.735808] [] (warn_slowpath_fmt) from [] (l3_interrupt_handler+0x27c/0x39c) [3.744742] [] (l3_interrupt_handler) from [] (__handle_irq_event_percpu+0x90/0x45c) [3.754286] [] (__handle_irq_event_percpu) from [] (handle_irq_event_percpu+0x3c/0x8c) [3.764001] [] (handle_irq_event_percpu) from [] (handle_irq_event+0x48/0x6c) [3.772933] [] (handle_irq_event) from [] (handle_fasteoi_irq+0xb0/0x164) [3.781513] [] (handle_fasteoi_irq) from [] (generic_handle_irq+0x34/0x44) [3.790183] [] (generic_handle_irq) from [] (__handle_domain_irq+0x6c/0xc4) [3.798941] [] (__handle_domain_irq) from [] (gic_handle_irq+0x68/0xac) [3.807347] [] (gic_handle_irq) from [] (__irq_svc+0x5c/0x7c) [3.814874] Exception stack(0xee179c70 to 0xee179cb8) [3.819963] 9c60: fc14 ee3e2f10 ee3a9810 [3.828189] 9c80: ee3e2f10 fc140004 fc14 ee3a9800 ee3a9810 ee179cdc [3.836414] 9ca0: ee179ce0 ee179cc0 c0c3b364 c0c3b2ec 6013 [3.843079] [] (__irq_svc) from [] (ahci_enable_ahci+0x24/0x70) [3.850789] [] (ahci_enable_ahci) from [] (ahci_save_initial_config+0x2c/0x388) [3.859894] [] (ahci_save_initial_config) from [] (ahci_platform_init_host+0x9c/0x4f4) [3.869609] [] (ahci_platform_init_host) from [] (ahci_probe+0xa0/0xc0) [3.878018] [] (ahci_probe) from [] (platform_drv_probe+0x58/0xac) [3.885989] [] (platform_drv_probe) from [] (driver_probe_device+0x25c/0x338) [3.894915] [] (driver_probe_device) from [] (__driver_attach+0xf4/0xf8) [3.903411] [] (__driver_attach) from [] (bus_for_each_dev+0x78/0xc4) [3.911643] [] (bus_for_each_dev) from [] (driver_attach+0x2c/0x30) [3.919696] [] (driver_attach) from [] (bus_add_driver+0x114/0x220) [3.927752] [] (bus_add_driver) from [] (driver_register+0x88/0x11c) [3.935896] [] (driver_register) from [] (__platform_driver_register+0x50/0x58) [3.945003] [] (__platform_driver_register) from [] (ahci_driver_init+0x24/0x28) [3.954195] [] (ahci_driver_init) from [] (do_one_initcall+0x9c/0x434) [3.962517] [] (do_one_initcall) from [] (kernel_init_freeable+0x3b8/0x53c) [3.971276] [] (kernel_init_freeable) from [] (kernel_init+0x18/0x128) [3.979597] [] (kernel_init) from [] (ret_from_fork+0x14/0x28) [3.987210] Exception stack(0xee179fb0 to 0xee179ff8) [3.992298] 9fa0: [4.000524] 9fc0: [4.008750] 9fe0: 0013 [4.015405] irq event stamp: 663130 [4.018926] hardirqs last enabled at (663129): [] _raw_spin_unlock_irqrestore+0x40/0x6c [4.027939] hardirqs last disabled at (663130): [] __irq_svc+0x4c/0x7c [4.035384] softirqs last enabled at (661486): [] __do_softirq+0x2a8/0x5e8 [4.043262] softirqs last disabled at (661449): [] irq_exit+0x178/0x1a4 [4.050826] ---[ end trace 095abac70926448f ]--- Best regards Naresh Kamboju
Re: [PATCH] proc: add missing '\0' back to /proc/$pid/cmdline
On Wed, Jun 20, 2018 at 2:08 PM Michal Kubecek wrote: > > > > @@ -254,10 +258,19 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, > > char __user *buf, > > while (count) { > > int got; > > size_t size = min_t(size_t, PAGE_SIZE, count); > > We limit size to be at most PAGE_SIZE here. > > > + long offset; > > > > - got = access_remote_vm(mm, pos, page, size, FOLL_ANON); > > - if (got <= 0) > > + /* > > + * Are we already starting past the official end? > > + * We always include the last byte that is *supposed* > > + * to be NUL > > + */ > > + offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; > > + > > + got = access_remote_vm(mm, pos - offset, page, size + offset, > > FOLL_ANON); > > But here we read (size + offset) bytes which may be more than PAGE_SIZE. Actually, no. We limit size not just to PAGE_SIZE, but to count as well. And there's *another* limit on 'count' that you missed, namely this part: /* .. and limit it to a maximum of one page of slop */ if (env_end >= arg_end + PAGE_SIZE) env_end = arg_end + PAGE_SIZE - 1; coupled with /* .. and we never go past env_end */ if (env_end - pos < count) count = env_end - pos; so we know that "pos + size" can never be larger than "arg_end + PAGE_SIZE - 1" And then: offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; means that "offset" will be bigger than zero only if "pos > arg_end-1". So let's ignore all other cases, and just say that we care about that case where 'offset' can be non-zero. So we have offset = pos - arg_end +1 (from the above initialization of offset), but we also know that pos + count <= end_end and since we've limited end_end to "arg_end + PAGE_SIZE -1" we have pos + count <= arg_end + PAGE_SIZE -1 agreed? Now, we can do some math on the above. Re-write that "offset = .." equation as pos = arg_end + offset - 1 And the same time we can take that "pos + count" inequality, and replacing "pos", we get arg_end + offset - 1 + count <= arg_end + PAGE_SIZE -1 and then we can remove "arg_end - 1" from both sides, and get offset+count <= PAGE_SIZE agreed? Linus
Re: [PATCH] proc: add missing '\0' back to /proc/$pid/cmdline
On Wed, Jun 20, 2018 at 2:08 PM Michal Kubecek wrote: > > > > @@ -254,10 +258,19 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, > > char __user *buf, > > while (count) { > > int got; > > size_t size = min_t(size_t, PAGE_SIZE, count); > > We limit size to be at most PAGE_SIZE here. > > > + long offset; > > > > - got = access_remote_vm(mm, pos, page, size, FOLL_ANON); > > - if (got <= 0) > > + /* > > + * Are we already starting past the official end? > > + * We always include the last byte that is *supposed* > > + * to be NUL > > + */ > > + offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; > > + > > + got = access_remote_vm(mm, pos - offset, page, size + offset, > > FOLL_ANON); > > But here we read (size + offset) bytes which may be more than PAGE_SIZE. Actually, no. We limit size not just to PAGE_SIZE, but to count as well. And there's *another* limit on 'count' that you missed, namely this part: /* .. and limit it to a maximum of one page of slop */ if (env_end >= arg_end + PAGE_SIZE) env_end = arg_end + PAGE_SIZE - 1; coupled with /* .. and we never go past env_end */ if (env_end - pos < count) count = env_end - pos; so we know that "pos + size" can never be larger than "arg_end + PAGE_SIZE - 1" And then: offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; means that "offset" will be bigger than zero only if "pos > arg_end-1". So let's ignore all other cases, and just say that we care about that case where 'offset' can be non-zero. So we have offset = pos - arg_end +1 (from the above initialization of offset), but we also know that pos + count <= end_end and since we've limited end_end to "arg_end + PAGE_SIZE -1" we have pos + count <= arg_end + PAGE_SIZE -1 agreed? Now, we can do some math on the above. Re-write that "offset = .." equation as pos = arg_end + offset - 1 And the same time we can take that "pos + count" inequality, and replacing "pos", we get arg_end + offset - 1 + count <= arg_end + PAGE_SIZE -1 and then we can remove "arg_end - 1" from both sides, and get offset+count <= PAGE_SIZE agreed? Linus
[PATCH] proc: use ktime_get_coarse_boottime64
get_monotonic_boottime() has been deprecated and might not be safe to call in every context. Change to use ktime_get_coarse_boottime_ts64. Signed-off-by: Allen Pais --- fs/proc/uptime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c index 3f723cb..17c6fff 100644 --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c @@ -9,7 +9,7 @@ static int uptime_proc_show(struct seq_file *m, void *v) { - struct timespec uptime; + struct timespec64 uptime; struct timespec64 idle; u64 nsec; u32 rem; @@ -19,7 +19,7 @@ static int uptime_proc_show(struct seq_file *m, void *v) for_each_possible_cpu(i) nsec += (__force u64) kcpustat_cpu(i).cpustat[CPUTIME_IDLE]; - get_monotonic_boottime(); + ktime_get_coarse_boottime_ts64(); idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, ); idle.tv_nsec = rem; seq_printf(m, "%lu.%02lu %lu.%02lu\n", -- 2.7.4
[PATCH] proc: use ktime_get_coarse_boottime64
get_monotonic_boottime() has been deprecated and might not be safe to call in every context. Change to use ktime_get_coarse_boottime_ts64. Signed-off-by: Allen Pais --- fs/proc/uptime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c index 3f723cb..17c6fff 100644 --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c @@ -9,7 +9,7 @@ static int uptime_proc_show(struct seq_file *m, void *v) { - struct timespec uptime; + struct timespec64 uptime; struct timespec64 idle; u64 nsec; u32 rem; @@ -19,7 +19,7 @@ static int uptime_proc_show(struct seq_file *m, void *v) for_each_possible_cpu(i) nsec += (__force u64) kcpustat_cpu(i).cpustat[CPUTIME_IDLE]; - get_monotonic_boottime(); + ktime_get_coarse_boottime_ts64(); idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, ); idle.tv_nsec = rem; seq_printf(m, "%lu.%02lu %lu.%02lu\n", -- 2.7.4
Re: [Customers.Eckelmann] [PATCH] locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS
Hi, On Wed, 2018-06-20 at 07:09 +0800, Waiman Long wrote: > On 05/24/2018 09:26 PM, Waiman Long wrote: > > It was found that the use of up_read_non_owner() in NFS was causing > > the following warning when DEBUG_RWSEMS was configured. > > > > DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0))) > > > > Looking into the rwsem.c file, it was discovered that the corresponding > > down_read_non_owner() function was not setting the owner field properly. > > This is fixed now, and the warning should be gone. > > > > Signed-off-by: Waiman Long Tested-by: Gavin Schenk This fixes my reproducible locking splat when booting with nfsroot and changing password. Thank you! Regards Gavin Schenk
Re: [Customers.Eckelmann] [PATCH] locking/rwsem: Fix up_read_non_owner() warning with DEBUG_RWSEMS
Hi, On Wed, 2018-06-20 at 07:09 +0800, Waiman Long wrote: > On 05/24/2018 09:26 PM, Waiman Long wrote: > > It was found that the use of up_read_non_owner() in NFS was causing > > the following warning when DEBUG_RWSEMS was configured. > > > > DEBUG_LOCKS_WARN_ON(sem->owner != ((struct task_struct *)(1UL << 0))) > > > > Looking into the rwsem.c file, it was discovered that the corresponding > > down_read_non_owner() function was not setting the owner field properly. > > This is fixed now, and the warning should be gone. > > > > Signed-off-by: Waiman Long Tested-by: Gavin Schenk This fixes my reproducible locking splat when booting with nfsroot and changing password. Thank you! Regards Gavin Schenk
[PATCH v3 treewide] headers: separate linux/mod_devicetable.h from linux/platform_device.h
From: Randy Dunlap At over 4000 #includes, is the 9th most #included header file in the Linux kernel. It does not need , so drop that header and explicitly add to source files that need it. 4146 #include After this patch, there are 225 files that use , for a reduction of around 3900 times that does not have to be read & parsed. 225 #include This patch was build-tested on 20 different arch-es. It also makes these drivers SubmitChecklist#1 compliant. Signed-off-by: Randy Dunlap Reported-by: kbuild test robot # drivers/media/platform/vimc/ Reported-by: kbuild test robot # drivers/pinctrl/pinctrl-u300.c --- v3: add fix for drivers/pinctrl/pinctrl-u300.c v2: add fixes for drivers/media/platform/vimc/ arch/arm/mach-mmp/sram.c |1 + drivers/ata/pata_imx.c|1 + drivers/ata/pata_samsung_cf.c |1 + drivers/auxdisplay/hd44780.c |1 + drivers/char/hw_random/atmel-rng.c|1 + drivers/char/hw_random/exynos-trng.c |1 + drivers/char/hw_random/imx-rngc.c |1 + drivers/char/hw_random/powernv-rng.c |1 + drivers/crypto/mediatek/mtk-platform.c|1 + drivers/crypto/qce/core.c |1 + drivers/crypto/stm32/stm32_crc32.c|1 + drivers/crypto/ux500/cryp/cryp_core.c |1 + drivers/crypto/ux500/hash/hash_core.c |1 + drivers/devfreq/tegra-devfreq.c |1 + drivers/dma/ep93xx_dma.c |1 + drivers/dma/s3c24xx-dma.c |1 + drivers/extcon/extcon-intel-cht-wc.c |1 + drivers/extcon/extcon-qcom-spmi-misc.c|1 + drivers/gpu/drm/mediatek/mtk_cec.c|1 + drivers/gpu/drm/sun4i/sun6i_drc.c |1 + drivers/hsi/controllers/omap_ssi_port.c |1 + drivers/hwmon/max197.c|1 + drivers/hwmon/mc13783-adc.c |1 + drivers/media/platform/coda/imx-vdoa.c|1 + drivers/media/platform/rcar-fcp.c |1 + drivers/media/platform/vimc/vimc-capture.c|1 + drivers/media/platform/vimc/vimc-debayer.c|1 + drivers/media/platform/vimc/vimc-scaler.c |1 + drivers/media/platform/vimc/vimc-sensor.c |1 + drivers/memory/tegra/tegra186.c |1 + drivers/mfd/atmel-hlcdc.c |1 + drivers/mfd/cros_ec_dev.c |1 + drivers/mtd/nand/raw/brcmnand/brcmstb_nand.c |1 + drivers/net/ethernet/calxeda/xgmac.c |1 + drivers/net/ethernet/faraday/ftmac100.c |1 + drivers/net/wireless/ath/ath9k/ahb.c |1 + drivers/net/wireless/ti/wl12xx/main.c |1 + drivers/net/wireless/ti/wl18xx/main.c |1 + drivers/nvmem/lpc18xx_eeprom.c|1 + drivers/nvmem/mtk-efuse.c |1 + drivers/nvmem/qfprom.c|1 + drivers/nvmem/uniphier-efuse.c|1 + drivers/perf/arm-ccn.c|1 + drivers/pinctrl/intel/pinctrl-merrifield.c|1 + drivers/pinctrl/pinctrl-u300.c|1 + drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c|1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c |1 + drivers/platform/goldfish/goldfish_pipe.c |1 + drivers/platform/x86/intel_bxtwc_tmu.c|1 + drivers/power/avs/smartreflex.c |1 + drivers/power/reset/ltc2952-poweroff.c|1 +
[PATCH v3 treewide] headers: separate linux/mod_devicetable.h from linux/platform_device.h
From: Randy Dunlap At over 4000 #includes, is the 9th most #included header file in the Linux kernel. It does not need , so drop that header and explicitly add to source files that need it. 4146 #include After this patch, there are 225 files that use , for a reduction of around 3900 times that does not have to be read & parsed. 225 #include This patch was build-tested on 20 different arch-es. It also makes these drivers SubmitChecklist#1 compliant. Signed-off-by: Randy Dunlap Reported-by: kbuild test robot # drivers/media/platform/vimc/ Reported-by: kbuild test robot # drivers/pinctrl/pinctrl-u300.c --- v3: add fix for drivers/pinctrl/pinctrl-u300.c v2: add fixes for drivers/media/platform/vimc/ arch/arm/mach-mmp/sram.c |1 + drivers/ata/pata_imx.c|1 + drivers/ata/pata_samsung_cf.c |1 + drivers/auxdisplay/hd44780.c |1 + drivers/char/hw_random/atmel-rng.c|1 + drivers/char/hw_random/exynos-trng.c |1 + drivers/char/hw_random/imx-rngc.c |1 + drivers/char/hw_random/powernv-rng.c |1 + drivers/crypto/mediatek/mtk-platform.c|1 + drivers/crypto/qce/core.c |1 + drivers/crypto/stm32/stm32_crc32.c|1 + drivers/crypto/ux500/cryp/cryp_core.c |1 + drivers/crypto/ux500/hash/hash_core.c |1 + drivers/devfreq/tegra-devfreq.c |1 + drivers/dma/ep93xx_dma.c |1 + drivers/dma/s3c24xx-dma.c |1 + drivers/extcon/extcon-intel-cht-wc.c |1 + drivers/extcon/extcon-qcom-spmi-misc.c|1 + drivers/gpu/drm/mediatek/mtk_cec.c|1 + drivers/gpu/drm/sun4i/sun6i_drc.c |1 + drivers/hsi/controllers/omap_ssi_port.c |1 + drivers/hwmon/max197.c|1 + drivers/hwmon/mc13783-adc.c |1 + drivers/media/platform/coda/imx-vdoa.c|1 + drivers/media/platform/rcar-fcp.c |1 + drivers/media/platform/vimc/vimc-capture.c|1 + drivers/media/platform/vimc/vimc-debayer.c|1 + drivers/media/platform/vimc/vimc-scaler.c |1 + drivers/media/platform/vimc/vimc-sensor.c |1 + drivers/memory/tegra/tegra186.c |1 + drivers/mfd/atmel-hlcdc.c |1 + drivers/mfd/cros_ec_dev.c |1 + drivers/mtd/nand/raw/brcmnand/brcmstb_nand.c |1 + drivers/net/ethernet/calxeda/xgmac.c |1 + drivers/net/ethernet/faraday/ftmac100.c |1 + drivers/net/wireless/ath/ath9k/ahb.c |1 + drivers/net/wireless/ti/wl12xx/main.c |1 + drivers/net/wireless/ti/wl18xx/main.c |1 + drivers/nvmem/lpc18xx_eeprom.c|1 + drivers/nvmem/mtk-efuse.c |1 + drivers/nvmem/qfprom.c|1 + drivers/nvmem/uniphier-efuse.c|1 + drivers/perf/arm-ccn.c|1 + drivers/pinctrl/intel/pinctrl-merrifield.c|1 + drivers/pinctrl/pinctrl-u300.c|1 + drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c|1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c |1 + drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c |1 + drivers/platform/goldfish/goldfish_pipe.c |1 + drivers/platform/x86/intel_bxtwc_tmu.c|1 + drivers/power/avs/smartreflex.c |1 + drivers/power/reset/ltc2952-poweroff.c|1 +
Re: [PATCH] printk: inject caller information into the body of message
On Sat, May 26, 2018 at 8:36 AM, Dmitry Vyukov wrote: > On Thu, May 24, 2018 at 4:14 AM, Sergey Senozhatsky > wrote: >>> First, we should ask what we expect from this feature. >> >> Yeah. Can't really comment on this, it's up to Tetsuo and Dmitry to >> decide. So far I've seen slightly different requirements/expectations. > > The root problem is that it's not possible to make sense out of kernel > output if message takes more than 1 line (or output non-atomically > with several printk's) because of intermixed output from several > tasks/interrupts/etc. For example, it's not generally possible to > recover crash stack trace, because one gets random mix of frames. > Humans usually, but not always, can restore most of the sense. So the > goal is to make this ought-to-be-simple task actually simple and not > requiring human intelligence and time each time. > > Prefixing each line with task/cpu/interrupt context should do the > trick as it will be possible to split kernel output into multiple > independent streams and analyze them independently. > > In our context (syzbot testing) we can enable an additional config, > and adopt parser to understand additional line prefix. But I don't > know how prefixing lines fits into a larger picture. Does it make > sense to thought out a potential extension story for this format? E.g. > user specifies set of extension records that are dumped before each > line, and then can unambiguously parse them? I guess some > consoles/interfaces will never be extended to provide access to the > extension records, so it can make sense to make them accessible in > text format too (optionally). up We continue to get mess like this, each instance of which needs to be checked by human. BUG: unable to handle kernel NULL pointer dereference at sysfs: cannot create duplicate filename '/class/ieee80211/!' PGD 1cae7e067 P4D 1cae7e067 PUD 1b4da6067 PMD 0 Oops: 0010 [#1] SMP KASAN CPU: 1 PID: 1728 Comm: syz-executor4 Not tainted 4.17.0+ #84 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 CPU: 0 PID: 1738 Comm: syz-executor7 Not tainted 4.17.0+ #84 RIP: 0010: (null) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Code: Call Trace: Bad RIP value. __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1b9/0x294 lib/dump_stack.c:113 RSP: 0018:88018cd3f590 EFLAGS: 00010246 RAX: RBX: 880192f05800 RCX: 110eeea9 sysfs_warn_dup.cold.3+0x1c/0x2b fs/sysfs/dir.c:30 RDX: 88018cd3fab0 RSI: 8801c927a480 RDI: 88018c77c040 sysfs_do_create_link_sd.isra.2+0x116/0x130 fs/sysfs/symlink.c:50 RBP: 88018cd3f700 R08: 0001 R09: sysfs_do_create_link fs/sysfs/symlink.c:79 [inline] sysfs_create_link+0x65/0xc0 fs/sysfs/symlink.c:91 R10: R11: R12: 1100319a7eb7 R13: 88018cd3fab0 R14: 880192f05812 R15: 880192f05c58 device_add_class_symlinks drivers/base/core.c:1632 [inline] device_add+0x5c9/0x16f0 drivers/base/core.c:1834 FS: 7f4a8e71f700() GS:8801daf0() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: ffd6 CR3: 000191e1b000 CR4: 001406e0 DR0: DR1: DR2: wiphy_register+0x182e/0x24e0 net/wireless/core.c:813 DR3: DR6: fffe0ff0 DR7: 0400 Call Trace: ieee80211_register_hw+0x13cd/0x35d0 net/mac80211/main.c:1050 sock_poll+0x1d1/0x710 net/socket.c:1168 mac80211_hwsim_new_radio+0x1da2/0x33b0 drivers/net/wireless/mac80211_hwsim.c:2772 vfs_poll+0x77/0x2a0 fs/select.c:40 do_pollfd fs/select.c:848 [inline] do_poll fs/select.c:896 [inline] do_sys_poll+0x6fd/0x1100 fs/select.c:990 hwsim_new_radio_nl+0x7b8/0xa60 drivers/net/wireless/mac80211_hwsim.c:3247 genl_family_rcv_msg+0x889/0x1120 net/netlink/genetlink.c:599 genl_rcv_msg+0xc6/0x170 net/netlink/genetlink.c:624 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2448 __do_sys_poll fs/select.c:1048 [inline] __se_sys_poll fs/select.c:1036 [inline] __x64_sys_poll+0x189/0x510 fs/select.c:1036 genl_rcv+0x28/0x40 net/netlink/genetlink.c:635 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] netlink_unicast+0x58b/0x740 net/netlink/af_netlink.c:1336 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:290 netlink_sendmsg+0x9f0/0xfa0 net/netlink/af_netlink.c:1901 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x455b29 sock_sendmsg_nosec net/socket.c:645 [inline] sock_sendmsg+0xd5/0x120 net/socket.c:655 Code: ___sys_sendmsg+0x805/0x940 net/socket.c:2161 1d ba fb ff c3 66 2e 0f 1f __sys_sendmsg+0x115/0x270 net/socket.c:2199 84 00 00 00 __do_sys_sendmsg net/socket.c:2208 [inline] __se_sys_sendmsg net/socket.c:2206 [inline] __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2206 00 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:290 00 66 90 48 89 f8 48 89
Re: [PATCH] net: nixge: Add __packed attribute to DMA descriptor struct
From: Moritz Fischer Date: Tue, 19 Jun 2018 09:54:53 -0700 > @@ -122,7 +122,7 @@ struct nixge_hw_dma_bd { > u32 sw_id_offset; > u32 reserved5; > u32 reserved6; > -}; > +} __packed; As I understand it, based upon your replies to Florian, this bug doesn't even show up with the current code. The problem only happens with some 64-bit changes you are working on. So, the change is not valid right now. And for the 64-bit changes, I agree with Florian that you should adjust your implementation so that this __packed dance isn't necessary and that you can avoid some MMIOs as well. Thanks.
Re: [PATCH] printk: inject caller information into the body of message
On Sat, May 26, 2018 at 8:36 AM, Dmitry Vyukov wrote: > On Thu, May 24, 2018 at 4:14 AM, Sergey Senozhatsky > wrote: >>> First, we should ask what we expect from this feature. >> >> Yeah. Can't really comment on this, it's up to Tetsuo and Dmitry to >> decide. So far I've seen slightly different requirements/expectations. > > The root problem is that it's not possible to make sense out of kernel > output if message takes more than 1 line (or output non-atomically > with several printk's) because of intermixed output from several > tasks/interrupts/etc. For example, it's not generally possible to > recover crash stack trace, because one gets random mix of frames. > Humans usually, but not always, can restore most of the sense. So the > goal is to make this ought-to-be-simple task actually simple and not > requiring human intelligence and time each time. > > Prefixing each line with task/cpu/interrupt context should do the > trick as it will be possible to split kernel output into multiple > independent streams and analyze them independently. > > In our context (syzbot testing) we can enable an additional config, > and adopt parser to understand additional line prefix. But I don't > know how prefixing lines fits into a larger picture. Does it make > sense to thought out a potential extension story for this format? E.g. > user specifies set of extension records that are dumped before each > line, and then can unambiguously parse them? I guess some > consoles/interfaces will never be extended to provide access to the > extension records, so it can make sense to make them accessible in > text format too (optionally). up We continue to get mess like this, each instance of which needs to be checked by human. BUG: unable to handle kernel NULL pointer dereference at sysfs: cannot create duplicate filename '/class/ieee80211/!' PGD 1cae7e067 P4D 1cae7e067 PUD 1b4da6067 PMD 0 Oops: 0010 [#1] SMP KASAN CPU: 1 PID: 1728 Comm: syz-executor4 Not tainted 4.17.0+ #84 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 CPU: 0 PID: 1738 Comm: syz-executor7 Not tainted 4.17.0+ #84 RIP: 0010: (null) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Code: Call Trace: Bad RIP value. __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1b9/0x294 lib/dump_stack.c:113 RSP: 0018:88018cd3f590 EFLAGS: 00010246 RAX: RBX: 880192f05800 RCX: 110eeea9 sysfs_warn_dup.cold.3+0x1c/0x2b fs/sysfs/dir.c:30 RDX: 88018cd3fab0 RSI: 8801c927a480 RDI: 88018c77c040 sysfs_do_create_link_sd.isra.2+0x116/0x130 fs/sysfs/symlink.c:50 RBP: 88018cd3f700 R08: 0001 R09: sysfs_do_create_link fs/sysfs/symlink.c:79 [inline] sysfs_create_link+0x65/0xc0 fs/sysfs/symlink.c:91 R10: R11: R12: 1100319a7eb7 R13: 88018cd3fab0 R14: 880192f05812 R15: 880192f05c58 device_add_class_symlinks drivers/base/core.c:1632 [inline] device_add+0x5c9/0x16f0 drivers/base/core.c:1834 FS: 7f4a8e71f700() GS:8801daf0() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: ffd6 CR3: 000191e1b000 CR4: 001406e0 DR0: DR1: DR2: wiphy_register+0x182e/0x24e0 net/wireless/core.c:813 DR3: DR6: fffe0ff0 DR7: 0400 Call Trace: ieee80211_register_hw+0x13cd/0x35d0 net/mac80211/main.c:1050 sock_poll+0x1d1/0x710 net/socket.c:1168 mac80211_hwsim_new_radio+0x1da2/0x33b0 drivers/net/wireless/mac80211_hwsim.c:2772 vfs_poll+0x77/0x2a0 fs/select.c:40 do_pollfd fs/select.c:848 [inline] do_poll fs/select.c:896 [inline] do_sys_poll+0x6fd/0x1100 fs/select.c:990 hwsim_new_radio_nl+0x7b8/0xa60 drivers/net/wireless/mac80211_hwsim.c:3247 genl_family_rcv_msg+0x889/0x1120 net/netlink/genetlink.c:599 genl_rcv_msg+0xc6/0x170 net/netlink/genetlink.c:624 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2448 __do_sys_poll fs/select.c:1048 [inline] __se_sys_poll fs/select.c:1036 [inline] __x64_sys_poll+0x189/0x510 fs/select.c:1036 genl_rcv+0x28/0x40 net/netlink/genetlink.c:635 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] netlink_unicast+0x58b/0x740 net/netlink/af_netlink.c:1336 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:290 netlink_sendmsg+0x9f0/0xfa0 net/netlink/af_netlink.c:1901 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x455b29 sock_sendmsg_nosec net/socket.c:645 [inline] sock_sendmsg+0xd5/0x120 net/socket.c:655 Code: ___sys_sendmsg+0x805/0x940 net/socket.c:2161 1d ba fb ff c3 66 2e 0f 1f __sys_sendmsg+0x115/0x270 net/socket.c:2199 84 00 00 00 __do_sys_sendmsg net/socket.c:2208 [inline] __se_sys_sendmsg net/socket.c:2206 [inline] __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2206 00 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:290 00 66 90 48 89 f8 48 89
Re: [PATCH] net: nixge: Add __packed attribute to DMA descriptor struct
From: Moritz Fischer Date: Tue, 19 Jun 2018 09:54:53 -0700 > @@ -122,7 +122,7 @@ struct nixge_hw_dma_bd { > u32 sw_id_offset; > u32 reserved5; > u32 reserved6; > -}; > +} __packed; As I understand it, based upon your replies to Florian, this bug doesn't even show up with the current code. The problem only happens with some 64-bit changes you are working on. So, the change is not valid right now. And for the 64-bit changes, I agree with Florian that you should adjust your implementation so that this __packed dance isn't necessary and that you can avoid some MMIOs as well. Thanks.
[PATCH V2] nvme-pci: move nvme_kill_queues to nvme_remove_dead_ctrl
There is race between nvme_remove and nvme_reset_work that can lead to io hang. nvme_removenvme_reset_work -> nvme_remove_dead_ctrl -> nvme_dev_disable -> quiesce request_queue -> queue remove_work -> cancel_work_sync reset_work -> nvme_remove_namespaces -> splice ctrl->namespaces nvme_remove_dead_ctrl_work -> nvme_kill_queues -> nvme_ns_remove do nothing -> blk_cleanup_queue -> blk_freeze_queue Finally, the request_queue is quiesced state when wait freeze, we will get io hang here. To fix it, move the nvme_kill_queues from nvme_remove_dead_ctrl_work to nvme_remove_dead_ctrl. Suggested-by: Keith Busch Signed-off-by: Jianchao Wang --- V2: - Just not invoke nvme_remove_dead_ctrl cannot fix the hole completely. Move the nvme_kill_queues to nvme_remove_dead_ctrl based on Keith's suggestion - Patch comment changes drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index fc33804..73a97fc 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2289,6 +2289,7 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status) nvme_get_ctrl(>ctrl); nvme_dev_disable(dev, false); + nvme_kill_queues(>ctrl); if (!queue_work(nvme_wq, >remove_work)) nvme_put_ctrl(>ctrl); } @@ -2405,7 +2406,6 @@ static void nvme_remove_dead_ctrl_work(struct work_struct *work) struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work); struct pci_dev *pdev = to_pci_dev(dev->dev); - nvme_kill_queues(>ctrl); if (pci_get_drvdata(pdev)) device_release_driver(>dev); nvme_put_ctrl(>ctrl); -- 2.7.4
[PATCH V2] nvme-pci: move nvme_kill_queues to nvme_remove_dead_ctrl
There is race between nvme_remove and nvme_reset_work that can lead to io hang. nvme_removenvme_reset_work -> nvme_remove_dead_ctrl -> nvme_dev_disable -> quiesce request_queue -> queue remove_work -> cancel_work_sync reset_work -> nvme_remove_namespaces -> splice ctrl->namespaces nvme_remove_dead_ctrl_work -> nvme_kill_queues -> nvme_ns_remove do nothing -> blk_cleanup_queue -> blk_freeze_queue Finally, the request_queue is quiesced state when wait freeze, we will get io hang here. To fix it, move the nvme_kill_queues from nvme_remove_dead_ctrl_work to nvme_remove_dead_ctrl. Suggested-by: Keith Busch Signed-off-by: Jianchao Wang --- V2: - Just not invoke nvme_remove_dead_ctrl cannot fix the hole completely. Move the nvme_kill_queues to nvme_remove_dead_ctrl based on Keith's suggestion - Patch comment changes drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index fc33804..73a97fc 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2289,6 +2289,7 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status) nvme_get_ctrl(>ctrl); nvme_dev_disable(dev, false); + nvme_kill_queues(>ctrl); if (!queue_work(nvme_wq, >remove_work)) nvme_put_ctrl(>ctrl); } @@ -2405,7 +2406,6 @@ static void nvme_remove_dead_ctrl_work(struct work_struct *work) struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work); struct pci_dev *pdev = to_pci_dev(dev->dev); - nvme_kill_queues(>ctrl); if (pci_get_drvdata(pdev)) device_release_driver(>dev); nvme_put_ctrl(>ctrl); -- 2.7.4
Re: [PATCH] Add quick erase format option
On Mon, Aug 9, 2010 at 10:52 AM, Stefani Seibold wrote: > Am Montag, den 09.08.2010, 09:37 +0100 schrieb David Woodhouse: >> On Mon, 2010-08-09 at 09:25 +0100, stef...@seibold.net wrote: >> > From: Stefani Seibold >> > >> > This patch add a quick format option which skips erasing of already erased >> > flash blocks. This is useful for first time production environments where >> > the flash arrived erased. >> > >> > Signed-off-by: Stefani Seibold >> >> This scares me, given the lengths we had to go to in JFFS2 to cope with >> blocks which *look* like they're erased, but which actually start losing >> data as soon as you start writing to them because the erase didn't >> complete. >> > > I know the drawback. This is why it is only an option which must be > enabled. And in most use cases there is a subsequent ubimkvol, which > will fail if the flash is not correct initialized. > > Flash are normally delivered erased. So this save in our production > environment (Nokia Siemens Networks) about 5 minutes per device (256 MB > NOR CFI Flash). > > The old JFFS2 was very fast to install the first time on a flash, it was > only a simple mount of the MTD partition. > > Which the quick format option i have now only a slightly first time > installation overhead compared to JFFS2. Without this option the > overhead is more than 5 minutes. This mail arrived now?! David, was it delayed by mailman for 8 years? -- Thanks, //richard
Re: [PATCH] Add quick erase format option
On Mon, Aug 9, 2010 at 10:52 AM, Stefani Seibold wrote: > Am Montag, den 09.08.2010, 09:37 +0100 schrieb David Woodhouse: >> On Mon, 2010-08-09 at 09:25 +0100, stef...@seibold.net wrote: >> > From: Stefani Seibold >> > >> > This patch add a quick format option which skips erasing of already erased >> > flash blocks. This is useful for first time production environments where >> > the flash arrived erased. >> > >> > Signed-off-by: Stefani Seibold >> >> This scares me, given the lengths we had to go to in JFFS2 to cope with >> blocks which *look* like they're erased, but which actually start losing >> data as soon as you start writing to them because the erase didn't >> complete. >> > > I know the drawback. This is why it is only an option which must be > enabled. And in most use cases there is a subsequent ubimkvol, which > will fail if the flash is not correct initialized. > > Flash are normally delivered erased. So this save in our production > environment (Nokia Siemens Networks) about 5 minutes per device (256 MB > NOR CFI Flash). > > The old JFFS2 was very fast to install the first time on a flash, it was > only a simple mount of the MTD partition. > > Which the quick format option i have now only a slightly first time > installation overhead compared to JFFS2. Without this option the > overhead is more than 5 minutes. This mail arrived now?! David, was it delayed by mailman for 8 years? -- Thanks, //richard
Re: [PATCH] arm: dts: socfpga: denali needs nand_x_clk too
Marek, Am Mittwoch, 20. Juni 2018, 06:52:09 CEST schrieb Marek Vasut: > On 06/19/2018 02:07 PM, Richard Weinberger wrote: > > The denali NAND flash controller needs at least two clocks to operate, > > nand_clk and nand_x_clk. > > Since 1bb88666775e ("mtd: nand: denali: handle timing parameters by > > setup_data_interface()") nand_x_clk is used to derive timing settings. > > > > Signed-off-by: Richard Weinberger > > --- > > Strictly speaking denali needs a ecc_clk too, but AFAIK such a clock > > is not present on this SoC. > > But my SoCFPGA knowledge is very limited. > > > > Thanks, > > //richard > > It looks sane, but I cannot test it right now, since I'm on vacation. > I hope Dinh/Chin can jump in. The patch was tested by me. So, at least it is not completely untested. BTW: I forgot to mention that it depends on Masahiro's Denali fixes. Thanks, //richard
Re: [PATCH] nvme-pci: not invoke nvme_remove_dead_ctrl when change state fails
Hi Keith On 06/20/2018 12:39 AM, Keith Busch wrote: > On Tue, Jun 19, 2018 at 04:30:50PM +0800, Jianchao Wang wrote: >> There is race between nvme_remove and nvme_reset_work that can >> lead to io hang. >> >> nvme_removenvme_reset_work >> -> change state to DELETING >>-> fail to change state to LIVE >>-> nvme_remove_dead_ctrl >> -> nvme_dev_disable >>-> quiesce request_queue >> -> queue remove_work >> -> cancel_work_sync reset_work >> -> nvme_remove_namespaces >> -> splice ctrl->namespaces >>nvme_remove_dead_ctrl_work >>-> nvme_kill_queues >> -> nvme_ns_remove do nothing >> -> blk_cleanup_queue >> -> blk_freeze_queue >> Finally, the request_queue is quiesced state when wait freeze, >> we will get io hang here. >> >> In fact, when fails to change state in nvme_reset_work, the only >> reason is someone has changed state to DELETING. So it is not >> necessary to invoke nvme_remove_dead_ctrl in that case. >> >> Signed-off-by: Jianchao Wang > > Good catch. I think the fix should either have the nvme_dev_disable set > shutdown to true to indicate the controller isn't coming back online, or > move the nvme_kill_queues inside nvme_remove_dead_ctrl. Yes,just not invoking nvme_remove_dead_ctrl when change state fails couldn't fix the hole completely. I prefer to move nvme_kill_queues from nvme_remove_dead_ctrl_work to nvme_remove_dead_ctrl. Will post the V2 version based on this. Thanks Jianchao
Re: [PATCH] arm: dts: socfpga: denali needs nand_x_clk too
Marek, Am Mittwoch, 20. Juni 2018, 06:52:09 CEST schrieb Marek Vasut: > On 06/19/2018 02:07 PM, Richard Weinberger wrote: > > The denali NAND flash controller needs at least two clocks to operate, > > nand_clk and nand_x_clk. > > Since 1bb88666775e ("mtd: nand: denali: handle timing parameters by > > setup_data_interface()") nand_x_clk is used to derive timing settings. > > > > Signed-off-by: Richard Weinberger > > --- > > Strictly speaking denali needs a ecc_clk too, but AFAIK such a clock > > is not present on this SoC. > > But my SoCFPGA knowledge is very limited. > > > > Thanks, > > //richard > > It looks sane, but I cannot test it right now, since I'm on vacation. > I hope Dinh/Chin can jump in. The patch was tested by me. So, at least it is not completely untested. BTW: I forgot to mention that it depends on Masahiro's Denali fixes. Thanks, //richard
Re: [PATCH] nvme-pci: not invoke nvme_remove_dead_ctrl when change state fails
Hi Keith On 06/20/2018 12:39 AM, Keith Busch wrote: > On Tue, Jun 19, 2018 at 04:30:50PM +0800, Jianchao Wang wrote: >> There is race between nvme_remove and nvme_reset_work that can >> lead to io hang. >> >> nvme_removenvme_reset_work >> -> change state to DELETING >>-> fail to change state to LIVE >>-> nvme_remove_dead_ctrl >> -> nvme_dev_disable >>-> quiesce request_queue >> -> queue remove_work >> -> cancel_work_sync reset_work >> -> nvme_remove_namespaces >> -> splice ctrl->namespaces >>nvme_remove_dead_ctrl_work >>-> nvme_kill_queues >> -> nvme_ns_remove do nothing >> -> blk_cleanup_queue >> -> blk_freeze_queue >> Finally, the request_queue is quiesced state when wait freeze, >> we will get io hang here. >> >> In fact, when fails to change state in nvme_reset_work, the only >> reason is someone has changed state to DELETING. So it is not >> necessary to invoke nvme_remove_dead_ctrl in that case. >> >> Signed-off-by: Jianchao Wang > > Good catch. I think the fix should either have the nvme_dev_disable set > shutdown to true to indicate the controller isn't coming back online, or > move the nvme_kill_queues inside nvme_remove_dead_ctrl. Yes,just not invoking nvme_remove_dead_ctrl when change state fails couldn't fix the hole completely. I prefer to move nvme_kill_queues from nvme_remove_dead_ctrl_work to nvme_remove_dead_ctrl. Will post the V2 version based on this. Thanks Jianchao
Re: [PATCH v2] kernel/hung_task.c: allow to set checking interval separately from timeout
On Wed, Jun 20, 2018 at 1:03 AM, Andrew Morton wrote: > On Mon, 11 Jun 2018 13:10:04 +0200 Dmitry Vyukov wrote: > >> Currently task hung checking interval is equal to timeout, >> as the result hung is detected anywhere between timeout and 2*timeout. >> This is fine for most interactive environments, but this hurts automated >> testing setups (syzbot). In an automated setup we need to strictly order >> CPU lockup < RCU stall < workqueue lockup < task hung < silent loss, >> so that RCU stall is not detected as task hung and task hung is not >> detected as silent machine loss. The large variance in task hung >> detection timeout requires setting silent machine loss timeout to >> a very large value (e.g. if task hung is 3 mins, then silent loss >> need to be set to ~7 mins). The additional 3 minutes significantly >> reduce testing efficiency because usually we crash kernel within >> a minute, and this can add hours to bug localization process as it >> needs to do dozens of tests. >> >> Allow setting checking interval separately from timeout. >> This allows to set timeout to, say, 3 minutes, >> but checking interval to 10 secs. >> >> The interval is controlled via a new hung_task_check_interval_secs >> sysctl, similar to the existing hung_task_timeout_secs sysctl. >> The default value of 0 results in the current behavior: >> checking interval is equal to timeout. > > I suppose we shoold do this: Hi Andrew, I see you added the patch and fixup to mm tree. Do you want me to resend v3 with the fixup included, or how does this work? Thanks > --- > a/kernel/sysctl.c~kernel-hung_taskc-allow-to-set-checking-interval-separately-from-timeout-fix > +++ a/kernel/sysctl.c > @@ -145,7 +145,10 @@ static int minolduid; > static int ngroups_max = NGROUPS_MAX; > static const int cap_last_cap = CAP_LAST_CAP; > > -/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs > */ > +/* > + * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs > + * and hung_task_check_interval_secs > + */ > #ifdef CONFIG_DETECT_HUNG_TASK > static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); > #endif
Re: [PATCH v2] kernel/hung_task.c: allow to set checking interval separately from timeout
On Wed, Jun 20, 2018 at 1:03 AM, Andrew Morton wrote: > On Mon, 11 Jun 2018 13:10:04 +0200 Dmitry Vyukov wrote: > >> Currently task hung checking interval is equal to timeout, >> as the result hung is detected anywhere between timeout and 2*timeout. >> This is fine for most interactive environments, but this hurts automated >> testing setups (syzbot). In an automated setup we need to strictly order >> CPU lockup < RCU stall < workqueue lockup < task hung < silent loss, >> so that RCU stall is not detected as task hung and task hung is not >> detected as silent machine loss. The large variance in task hung >> detection timeout requires setting silent machine loss timeout to >> a very large value (e.g. if task hung is 3 mins, then silent loss >> need to be set to ~7 mins). The additional 3 minutes significantly >> reduce testing efficiency because usually we crash kernel within >> a minute, and this can add hours to bug localization process as it >> needs to do dozens of tests. >> >> Allow setting checking interval separately from timeout. >> This allows to set timeout to, say, 3 minutes, >> but checking interval to 10 secs. >> >> The interval is controlled via a new hung_task_check_interval_secs >> sysctl, similar to the existing hung_task_timeout_secs sysctl. >> The default value of 0 results in the current behavior: >> checking interval is equal to timeout. > > I suppose we shoold do this: Hi Andrew, I see you added the patch and fixup to mm tree. Do you want me to resend v3 with the fixup included, or how does this work? Thanks > --- > a/kernel/sysctl.c~kernel-hung_taskc-allow-to-set-checking-interval-separately-from-timeout-fix > +++ a/kernel/sysctl.c > @@ -145,7 +145,10 @@ static int minolduid; > static int ngroups_max = NGROUPS_MAX; > static const int cap_last_cap = CAP_LAST_CAP; > > -/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs > */ > +/* > + * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs > + * and hung_task_check_interval_secs > + */ > #ifdef CONFIG_DETECT_HUNG_TASK > static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); > #endif
Re: [PATCH V2 5/5] PCI: Unify slot and bus reset API
Hi Sinan, I love your patch! Yet something to improve: [auto build test ERROR on pci/next] [also build test ERROR on v4.18-rc1 next-20180619] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/PCI-handle-error-return-from-pci_reset_bridge_secondary_bus/20180620-121648 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: x86_64-allyesconfig (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/infiniband//hw/hfi1/pcie.c: In function 'trigger_sbr': >> drivers/infiniband//hw/hfi1/pcie.c:908:23: error: passing argument 1 of >> 'pci_reset_bus' from incompatible pointer type >> [-Werror=incompatible-pointer-types] return pci_reset_bus(dev->bus); ^~~ In file included from drivers/infiniband//hw/hfi1/pcie.c:48:0: include/linux/pci.h:1099:5: note: expected 'struct pci_dev *' but argument is of type 'struct pci_bus *' int pci_reset_bus(struct pci_dev *dev); ^ cc1: some warnings being treated as errors vim +/pci_reset_bus +908 drivers/infiniband//hw/hfi1/pcie.c 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 873 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 874 /* 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 875 * Trigger a secondary bus reset (SBR) on ourselves using our parent. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 876 * 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 877 * Based on pci_parent_bus_reset() which is not exported by the 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 878 * kernel core. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 879 */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 880 static int trigger_sbr(struct hfi1_devdata *dd) 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 881 { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 882 struct pci_dev *dev = dd->pcidev; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 883 struct pci_dev *pdev; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 884 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 885 /* need a parent */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 886 if (!dev->bus->self) { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 887 dd_dev_err(dd, "%s: no parent device\n", __func__); 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 888 return -ENOTTY; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 889 } 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 890 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 891 /* should not be anyone else on the bus */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 892 list_for_each_entry(pdev, >bus->devices, bus_list) 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 893 if (pdev != dev) { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 894 dd_dev_err(dd, 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 895 "%s: another device is on the same bus\n", 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 896 __func__); 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 897 return -ENOTTY; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 898 } 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 899 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 900 /* 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 901 * A secondary bus reset (SBR) issues a hot reset to our device. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 902 * The following routine does a 1s wait after the reset is dropped 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 903 * per PCI Trhfa (recovery time). PCIe 3.0 section 6.6.1 - 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 904 * Conventional Reset, paragraph 3, line 35 also says that a 1s 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 905 * delay after
[PATCH v2 00/10] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
Hi! With the introduction of mux-locked I2C muxes, the concept of locking only a segment of the I2C adapter tree was added. At the time, I did not want to cause a lot of extra churn, so left most users of i2c_lock_adapter alone and apparently didn't think enough about it; they simply continued to lock the whole adapter tree. However, i2c_lock_adapter is in fact wrong for almost every caller (there is naturally an exception) that is itself not a driver for a root adapter. What normal drivers generally want is to only lock the segment of the adapter tree that their device sits on. In fact, if a device sits behind a mux-locked I2C mux, and its driver calls i2c_lock_adapter followed by an unlocked I2C transfer, things will deadlock (since even a mux-locked I2C adapter will lock its parent at some point). If the device is not sitting behind a mux-locked I2C mux (i.e. either directly on the root adapter or behind a (chain of) parent-locked I2C muxes) the root/segment distinction is of no consequence; the root adapter is locked either way. Mux-locked I2C muxes are probably not that common, and putting any of the affected devices behind one is probably even rarer, which is why we have not seen any deadlocks. At least not that I know of... Since silently changing the semantics of i2c_lock_adapter might be quite a surprise, especially for out-of-tree users, this series instead removes the function and forces all users to explicitly name I2C_LOCK_SEGMENT or I2C_LOCK_ROOT_ADAPTER in a call to i2c_lock_bus, as suggested by Wolfram. Yes, users will be a teensy bit more wordy, but open-coding I2C locking from random drivers should be avoided, so it's perhaps a good thing if it doesn't look too neat? I suggest that Wolfram takes this series through the I2C tree and creates an immutable branch for the other subsystems. The series is based on v4.18-r1. I do not have *any* of the affected devices, and have thus only done build tests. Cheers, Peter PS. for more background on mux-locked vs. parent-locked etc, see Documentation/i2c/i2c-topology Changes since v1: - rebased to v4.18-rc1, thus removing the i2c-tegra hunk from the last patch - Not adding i2c_lock_segment (et al) and remove i2c_lock_adapter instead of renaming it to i2c_lock_root, since having 8 closely related inline locking functions in include/linux/i2c.h was a few too many. I.e., instead going from 5 to 8, we are now going from 5 to 3. Peter Rosin (10): tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) i2c: mux: pca9541: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) input: rohm_bu21023: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: af9013: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: drxk_hard: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: rtl2830: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: tda1004x: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: tda18271: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) mfd: 88pm860x-i2c: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) i2c: remove i2c_lock_adapter and use i2c_lock_bus directly drivers/char/tpm/tpm_i2c_infineon.c | 8 +++ drivers/i2c/busses/i2c-brcmstb.c | 8 +++ drivers/i2c/busses/i2c-davinci.c | 4 ++-- drivers/i2c/busses/i2c-gpio.c| 40 drivers/i2c/busses/i2c-s3c2410.c | 4 ++-- drivers/i2c/busses/i2c-sprd.c| 8 +++ drivers/i2c/i2c-core-slave.c | 8 +++ drivers/i2c/muxes/i2c-mux-pca9541.c | 6 ++--- drivers/iio/temperature/mlx90614.c | 4 ++-- drivers/input/touchscreen/rohm_bu21023.c | 4 ++-- drivers/media/dvb-frontends/af9013.c | 8 +++ drivers/media/dvb-frontends/drxk_hard.c | 4 ++-- drivers/media/dvb-frontends/rtl2830.c| 12 +- drivers/media/dvb-frontends/tda1004x.c | 6 ++--- drivers/media/tuners/tda18271-common.c | 8 +++ drivers/mfd/88pm860x-i2c.c | 8 +++ include/linux/i2c.h | 12 -- 17 files changed, 70 insertions(+), 82 deletions(-) -- 2.11.0
Re: [PATCH v4 0/4] locking,drm: Fix ww mutex naming / algorithm inconsistency
On 06/19/2018 11:45 AM, Peter Zijlstra wrote: I suspect you want this through the DRM tree? Ingo are you OK with that? Yes, I can ask Dave to pull this. Ingo? Thanks, Thomas
Re: [PATCH V2 5/5] PCI: Unify slot and bus reset API
Hi Sinan, I love your patch! Yet something to improve: [auto build test ERROR on pci/next] [also build test ERROR on v4.18-rc1 next-20180619] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/PCI-handle-error-return-from-pci_reset_bridge_secondary_bus/20180620-121648 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: x86_64-allyesconfig (attached as .config) compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/infiniband//hw/hfi1/pcie.c: In function 'trigger_sbr': >> drivers/infiniband//hw/hfi1/pcie.c:908:23: error: passing argument 1 of >> 'pci_reset_bus' from incompatible pointer type >> [-Werror=incompatible-pointer-types] return pci_reset_bus(dev->bus); ^~~ In file included from drivers/infiniband//hw/hfi1/pcie.c:48:0: include/linux/pci.h:1099:5: note: expected 'struct pci_dev *' but argument is of type 'struct pci_bus *' int pci_reset_bus(struct pci_dev *dev); ^ cc1: some warnings being treated as errors vim +/pci_reset_bus +908 drivers/infiniband//hw/hfi1/pcie.c 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 873 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 874 /* 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 875 * Trigger a secondary bus reset (SBR) on ourselves using our parent. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 876 * 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 877 * Based on pci_parent_bus_reset() which is not exported by the 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 878 * kernel core. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 879 */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 880 static int trigger_sbr(struct hfi1_devdata *dd) 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 881 { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 882 struct pci_dev *dev = dd->pcidev; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 883 struct pci_dev *pdev; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 884 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 885 /* need a parent */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 886 if (!dev->bus->self) { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 887 dd_dev_err(dd, "%s: no parent device\n", __func__); 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 888 return -ENOTTY; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 889 } 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 890 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 891 /* should not be anyone else on the bus */ 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 892 list_for_each_entry(pdev, >bus->devices, bus_list) 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 893 if (pdev != dev) { 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 894 dd_dev_err(dd, 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 895 "%s: another device is on the same bus\n", 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 896 __func__); 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 897 return -ENOTTY; 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 898 } 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 899 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 900 /* 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 901 * A secondary bus reset (SBR) issues a hot reset to our device. 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 902 * The following routine does a 1s wait after the reset is dropped 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 903 * per PCI Trhfa (recovery time). PCIe 3.0 section 6.6.1 - 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 904 * Conventional Reset, paragraph 3, line 35 also says that a 1s 77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 905 * delay after
[PATCH v2 00/10] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
Hi! With the introduction of mux-locked I2C muxes, the concept of locking only a segment of the I2C adapter tree was added. At the time, I did not want to cause a lot of extra churn, so left most users of i2c_lock_adapter alone and apparently didn't think enough about it; they simply continued to lock the whole adapter tree. However, i2c_lock_adapter is in fact wrong for almost every caller (there is naturally an exception) that is itself not a driver for a root adapter. What normal drivers generally want is to only lock the segment of the adapter tree that their device sits on. In fact, if a device sits behind a mux-locked I2C mux, and its driver calls i2c_lock_adapter followed by an unlocked I2C transfer, things will deadlock (since even a mux-locked I2C adapter will lock its parent at some point). If the device is not sitting behind a mux-locked I2C mux (i.e. either directly on the root adapter or behind a (chain of) parent-locked I2C muxes) the root/segment distinction is of no consequence; the root adapter is locked either way. Mux-locked I2C muxes are probably not that common, and putting any of the affected devices behind one is probably even rarer, which is why we have not seen any deadlocks. At least not that I know of... Since silently changing the semantics of i2c_lock_adapter might be quite a surprise, especially for out-of-tree users, this series instead removes the function and forces all users to explicitly name I2C_LOCK_SEGMENT or I2C_LOCK_ROOT_ADAPTER in a call to i2c_lock_bus, as suggested by Wolfram. Yes, users will be a teensy bit more wordy, but open-coding I2C locking from random drivers should be avoided, so it's perhaps a good thing if it doesn't look too neat? I suggest that Wolfram takes this series through the I2C tree and creates an immutable branch for the other subsystems. The series is based on v4.18-r1. I do not have *any* of the affected devices, and have thus only done build tests. Cheers, Peter PS. for more background on mux-locked vs. parent-locked etc, see Documentation/i2c/i2c-topology Changes since v1: - rebased to v4.18-rc1, thus removing the i2c-tegra hunk from the last patch - Not adding i2c_lock_segment (et al) and remove i2c_lock_adapter instead of renaming it to i2c_lock_root, since having 8 closely related inline locking functions in include/linux/i2c.h was a few too many. I.e., instead going from 5 to 8, we are now going from 5 to 3. Peter Rosin (10): tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) i2c: mux: pca9541: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) input: rohm_bu21023: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: af9013: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: drxk_hard: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: rtl2830: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: tda1004x: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) media: tda18271: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) mfd: 88pm860x-i2c: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) i2c: remove i2c_lock_adapter and use i2c_lock_bus directly drivers/char/tpm/tpm_i2c_infineon.c | 8 +++ drivers/i2c/busses/i2c-brcmstb.c | 8 +++ drivers/i2c/busses/i2c-davinci.c | 4 ++-- drivers/i2c/busses/i2c-gpio.c| 40 drivers/i2c/busses/i2c-s3c2410.c | 4 ++-- drivers/i2c/busses/i2c-sprd.c| 8 +++ drivers/i2c/i2c-core-slave.c | 8 +++ drivers/i2c/muxes/i2c-mux-pca9541.c | 6 ++--- drivers/iio/temperature/mlx90614.c | 4 ++-- drivers/input/touchscreen/rohm_bu21023.c | 4 ++-- drivers/media/dvb-frontends/af9013.c | 8 +++ drivers/media/dvb-frontends/drxk_hard.c | 4 ++-- drivers/media/dvb-frontends/rtl2830.c| 12 +- drivers/media/dvb-frontends/tda1004x.c | 6 ++--- drivers/media/tuners/tda18271-common.c | 8 +++ drivers/mfd/88pm860x-i2c.c | 8 +++ include/linux/i2c.h | 12 -- 17 files changed, 70 insertions(+), 82 deletions(-) -- 2.11.0
Re: [PATCH v4 0/4] locking,drm: Fix ww mutex naming / algorithm inconsistency
On 06/19/2018 11:45 AM, Peter Zijlstra wrote: I suspect you want this through the DRM tree? Ingo are you OK with that? Yes, I can ask Dave to pull this. Ingo? Thanks, Thomas
Re: [PATCH] proc: add missing '\0' back to /proc/$pid/cmdline
On Wed, Jun 20, 2018 at 06:56:04AM +0900, Linus Torvalds wrote: > On Wed, Jun 20, 2018 at 1:24 AM Michal Kubecek wrote: > > > > Recent rewrite introduced a regression, /proc/$pid/cmdline is missing the > > trailing null character: > > > > mike@lion:/tmp> cat /proc/self/cmdline | od -t c > > 000 c a t \0 / p r o c / s e l f / c > > 020 m d l i n e > > 026 > > Thanks, and obviously right you are. > > That said, I'm not a fan of your patch. I'd much rather just tweak the > "strnlen()" logic a bit instead, and make the rule be that when we go > into the "slop" area, we always include the last byte of the "real" > argv area. > > That limits the slop to a page (well, one byte less, since we want the > one byte of non-slop), but honestly, a page for *everything* was what > we used to do originally, so.. Yes, that should be enough for real life applications. > How does the attached patch work for you? I haven't tested it yet but it looks good except this: > @@ -254,10 +258,19 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, > char __user *buf, > while (count) { > int got; > size_t size = min_t(size_t, PAGE_SIZE, count); We limit size to be at most PAGE_SIZE here. > + long offset; > > - got = access_remote_vm(mm, pos, page, size, FOLL_ANON); > - if (got <= 0) > + /* > + * Are we already starting past the official end? > + * We always include the last byte that is *supposed* > + * to be NUL > + */ > + offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; > + > + got = access_remote_vm(mm, pos - offset, page, size + offset, > FOLL_ANON); But here we read (size + offset) bytes which may be more than PAGE_SIZE. I guess it should rather be size_t size; ... offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; size = min_t(size_t, PAGE_SIZE - offset, count); We already made sure that offset < PAGE_SIZE so that size will be at least 1. Michal Kubecek
Re: [PATCH] proc: add missing '\0' back to /proc/$pid/cmdline
On Wed, Jun 20, 2018 at 06:56:04AM +0900, Linus Torvalds wrote: > On Wed, Jun 20, 2018 at 1:24 AM Michal Kubecek wrote: > > > > Recent rewrite introduced a regression, /proc/$pid/cmdline is missing the > > trailing null character: > > > > mike@lion:/tmp> cat /proc/self/cmdline | od -t c > > 000 c a t \0 / p r o c / s e l f / c > > 020 m d l i n e > > 026 > > Thanks, and obviously right you are. > > That said, I'm not a fan of your patch. I'd much rather just tweak the > "strnlen()" logic a bit instead, and make the rule be that when we go > into the "slop" area, we always include the last byte of the "real" > argv area. > > That limits the slop to a page (well, one byte less, since we want the > one byte of non-slop), but honestly, a page for *everything* was what > we used to do originally, so.. Yes, that should be enough for real life applications. > How does the attached patch work for you? I haven't tested it yet but it looks good except this: > @@ -254,10 +258,19 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, > char __user *buf, > while (count) { > int got; > size_t size = min_t(size_t, PAGE_SIZE, count); We limit size to be at most PAGE_SIZE here. > + long offset; > > - got = access_remote_vm(mm, pos, page, size, FOLL_ANON); > - if (got <= 0) > + /* > + * Are we already starting past the official end? > + * We always include the last byte that is *supposed* > + * to be NUL > + */ > + offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; > + > + got = access_remote_vm(mm, pos - offset, page, size + offset, > FOLL_ANON); But here we read (size + offset) bytes which may be more than PAGE_SIZE. I guess it should rather be size_t size; ... offset = (pos >= arg_end) ? pos - arg_end + 1 : 0; size = min_t(size_t, PAGE_SIZE - offset, count); We already made sure that offset < PAGE_SIZE so that size will be at least 1. Michal Kubecek
[PATCH v3 0/4] mtd: rawnand: support MT29F1G08ABAFAWP-ITE:F
Hi, I'm looking at adding support for the Micron MT29F1G08ABAFAWP-ITE:F chip to one of our boards which uses the Marvell NFCv2 controller. This particular chip is a bit odd in that the datasheet states support for ONFI 1.0 but the revision number field is 00 00. It also is marked ABAFA but reports internally as ABAGA. Finally it has internal 8-bit ECC which cannot be disabled. The existing test in micron_supports_on_die_ecc() determines that on-die ECC is supported but not mandatory but I know for this chip it is mandatory despite what set_features returns. In order for this to work I need to set nand-ecc-mode = "on-die" in my dts. Ideally I'd like it to be automatic based on what the hardware can support but that may be asking too much at the moment. Here's a dump of the parameter page from the chip I have : 4f 4e 46 49 00 00 18 00 3f 00 00 00 00 00 00 00 ONFI?... 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0020: 4d 49 43 52 4f 4e 20 20 20 20 20 20 4d 54 32 39 MICRON MT29 0030: 46 31 47 30 38 41 42 41 47 41 57 50 20 20 20 20 F1G08ABAGAWP 0040: 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ,... 0050: 00 08 00 00 80 00 00 02 00 00 20 00 40 00 00 00 .. .@... 0060: 00 04 00 00 01 22 01 14 00 01 05 08 00 00 04 00 .".. 0070: 08 01 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 0080: 08 3f 00 3f 00 58 02 10 27 46 00 64 00 00 00 00 .?.?.X..'F.d 0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00a0: 00 00 00 00 01 00 00 00 00 02 04 80 01 81 04 03 00b0: 02 01 1e 90 00 00 00 00 00 00 00 00 00 00 00 00 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 a6 Series changes in v3: - No longer RFC - dropped "mtd: rawnand: micron: add ONFI_FEATURE_ON_DIE_ECC to supported features" which Boris has already picked up - dropped "mtd: rawnand: marvell: Support page size of 2048 with 8-bit ECC" since I can't test it. Chris Packham (4): mtd: rawnand: marvell: Handle on-die ECC mtd: rawnand: add manufacturer fixup for ONFI parameter page mtd: rawnand: micron: add fixup for ONFI revision mtd: rawnand: micron: support 8/512 on-die ECC drivers/mtd/nand/raw/marvell_nand.c | 1 + drivers/mtd/nand/raw/nand_base.c| 4 +++ drivers/mtd/nand/raw/nand_micron.c | 47 - include/linux/mtd/rawnand.h | 3 ++ 4 files changed, 48 insertions(+), 7 deletions(-) -- 2.17.1
[PATCH v3 0/4] mtd: rawnand: support MT29F1G08ABAFAWP-ITE:F
Hi, I'm looking at adding support for the Micron MT29F1G08ABAFAWP-ITE:F chip to one of our boards which uses the Marvell NFCv2 controller. This particular chip is a bit odd in that the datasheet states support for ONFI 1.0 but the revision number field is 00 00. It also is marked ABAFA but reports internally as ABAGA. Finally it has internal 8-bit ECC which cannot be disabled. The existing test in micron_supports_on_die_ecc() determines that on-die ECC is supported but not mandatory but I know for this chip it is mandatory despite what set_features returns. In order for this to work I need to set nand-ecc-mode = "on-die" in my dts. Ideally I'd like it to be automatic based on what the hardware can support but that may be asking too much at the moment. Here's a dump of the parameter page from the chip I have : 4f 4e 46 49 00 00 18 00 3f 00 00 00 00 00 00 00 ONFI?... 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0020: 4d 49 43 52 4f 4e 20 20 20 20 20 20 4d 54 32 39 MICRON MT29 0030: 46 31 47 30 38 41 42 41 47 41 57 50 20 20 20 20 F1G08ABAGAWP 0040: 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ,... 0050: 00 08 00 00 80 00 00 02 00 00 20 00 40 00 00 00 .. .@... 0060: 00 04 00 00 01 22 01 14 00 01 05 08 00 00 04 00 .".. 0070: 08 01 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 0080: 08 3f 00 3f 00 58 02 10 27 46 00 64 00 00 00 00 .?.?.X..'F.d 0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00a0: 00 00 00 00 01 00 00 00 00 02 04 80 01 81 04 03 00b0: 02 01 1e 90 00 00 00 00 00 00 00 00 00 00 00 00 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 a6 Series changes in v3: - No longer RFC - dropped "mtd: rawnand: micron: add ONFI_FEATURE_ON_DIE_ECC to supported features" which Boris has already picked up - dropped "mtd: rawnand: marvell: Support page size of 2048 with 8-bit ECC" since I can't test it. Chris Packham (4): mtd: rawnand: marvell: Handle on-die ECC mtd: rawnand: add manufacturer fixup for ONFI parameter page mtd: rawnand: micron: add fixup for ONFI revision mtd: rawnand: micron: support 8/512 on-die ECC drivers/mtd/nand/raw/marvell_nand.c | 1 + drivers/mtd/nand/raw/nand_base.c| 4 +++ drivers/mtd/nand/raw/nand_micron.c | 47 - include/linux/mtd/rawnand.h | 3 ++ 4 files changed, 48 insertions(+), 7 deletions(-) -- 2.17.1
[PATCH v3 4/4] mtd: rawnand: micron: support 8/512 on-die ECC
Micron MT29F1G08ABAFAWP-ITE:F supports an on-die ECC with 8 bits per 512 bytes. Add support for this combination. Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Handle reporting of corrected errors that don't require a rewrite, expand comment for the ECC status bits. drivers/mtd/nand/raw/nand_micron.c | 34 -- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 5cec79372181..0c2bde4411d7 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -18,10 +18,24 @@ #include /* - * Special Micron status bit that indicates when the block has been - * corrected by on-die ECC and should be rewritten + * Special Micron status bit 3 indicates that the block has been + * corrected by on-die ECC and should be rewritten. + * + * On chips with 8-bit ECC and additional bit can be used to distinguish + * cases where a errors were corrected without needing a rewrite + * + * Bit 4 Bit 3 Bit 0 Description + * - - - --- + * 0 0 0 No Errors + * 0 0 1 Multiple uncorrected errors + * 0 1 0 4 - 6 errors corrected, recommend rewrite + * 0 0 1 Reserved + * 1 0 0 1 - 3 errors corrected + * 1 0 1 Reserved + * 1 1 0 7 - 8 errors corrected, recommend rewrite */ #define NAND_STATUS_WRITE_RECOMMENDED BIT(3) +#define NAND_STATUS_ERRORS_CORRECTED BIT(4) struct nand_onfi_vendor_micron { u8 two_plane_read; @@ -141,7 +155,7 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip, mtd->ecc_stats.failed++; /* -* The internal ECC doesn't tell us the number of bitflips +* The internal 4-bit ECC doesn't tell us the number of bitflips * that have been corrected, but tells us if it recommends to * rewrite the block. If it's the case, then we pretend we had * a number of bitflips equal to the ECC strength, which will @@ -149,6 +163,12 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip, */ else if (status & NAND_STATUS_WRITE_RECOMMENDED) max_bitflips = chip->ecc.strength; + /* +* Chips with 8-bit internal ECC do tell us if errors 1 to 3 bit +* errors have been corrected without recommending a rewrite. +*/ + else if (status & NAND_STATUS_ERRORS_CORRECTED) + max_bitflips = 3; ret = nand_read_data_op(chip, buf, mtd->writesize, false); if (!ret && oob_required) @@ -240,9 +260,9 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip) /* * Some Micron NANDs have an on-die ECC of 4/512, some other -* 8/512. We only support the former. +* 8/512. */ - if (chip->ecc_strength_ds != 4) + if (chip->ecc_strength_ds != 4 && chip->ecc_strength_ds != 8) return MICRON_ON_DIE_UNSUPPORTED; return MICRON_ON_DIE_SUPPORTED; @@ -274,9 +294,9 @@ static int micron_nand_init(struct nand_chip *chip) return -EINVAL; } - chip->ecc.bytes = 8; + chip->ecc.bytes = chip->ecc_strength_ds * 2; chip->ecc.size = 512; - chip->ecc.strength = 4; + chip->ecc.strength = chip->ecc_strength_ds; chip->ecc.algo = NAND_ECC_BCH; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc; -- 2.17.1
[PATCH v3 4/4] mtd: rawnand: micron: support 8/512 on-die ECC
Micron MT29F1G08ABAFAWP-ITE:F supports an on-die ECC with 8 bits per 512 bytes. Add support for this combination. Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Handle reporting of corrected errors that don't require a rewrite, expand comment for the ECC status bits. drivers/mtd/nand/raw/nand_micron.c | 34 -- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 5cec79372181..0c2bde4411d7 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -18,10 +18,24 @@ #include /* - * Special Micron status bit that indicates when the block has been - * corrected by on-die ECC and should be rewritten + * Special Micron status bit 3 indicates that the block has been + * corrected by on-die ECC and should be rewritten. + * + * On chips with 8-bit ECC and additional bit can be used to distinguish + * cases where a errors were corrected without needing a rewrite + * + * Bit 4 Bit 3 Bit 0 Description + * - - - --- + * 0 0 0 No Errors + * 0 0 1 Multiple uncorrected errors + * 0 1 0 4 - 6 errors corrected, recommend rewrite + * 0 0 1 Reserved + * 1 0 0 1 - 3 errors corrected + * 1 0 1 Reserved + * 1 1 0 7 - 8 errors corrected, recommend rewrite */ #define NAND_STATUS_WRITE_RECOMMENDED BIT(3) +#define NAND_STATUS_ERRORS_CORRECTED BIT(4) struct nand_onfi_vendor_micron { u8 two_plane_read; @@ -141,7 +155,7 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip, mtd->ecc_stats.failed++; /* -* The internal ECC doesn't tell us the number of bitflips +* The internal 4-bit ECC doesn't tell us the number of bitflips * that have been corrected, but tells us if it recommends to * rewrite the block. If it's the case, then we pretend we had * a number of bitflips equal to the ECC strength, which will @@ -149,6 +163,12 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip, */ else if (status & NAND_STATUS_WRITE_RECOMMENDED) max_bitflips = chip->ecc.strength; + /* +* Chips with 8-bit internal ECC do tell us if errors 1 to 3 bit +* errors have been corrected without recommending a rewrite. +*/ + else if (status & NAND_STATUS_ERRORS_CORRECTED) + max_bitflips = 3; ret = nand_read_data_op(chip, buf, mtd->writesize, false); if (!ret && oob_required) @@ -240,9 +260,9 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip) /* * Some Micron NANDs have an on-die ECC of 4/512, some other -* 8/512. We only support the former. +* 8/512. */ - if (chip->ecc_strength_ds != 4) + if (chip->ecc_strength_ds != 4 && chip->ecc_strength_ds != 8) return MICRON_ON_DIE_UNSUPPORTED; return MICRON_ON_DIE_SUPPORTED; @@ -274,9 +294,9 @@ static int micron_nand_init(struct nand_chip *chip) return -EINVAL; } - chip->ecc.bytes = 8; + chip->ecc.bytes = chip->ecc_strength_ds * 2; chip->ecc.size = 512; - chip->ecc.strength = 4; + chip->ecc.strength = chip->ecc_strength_ds; chip->ecc.algo = NAND_ECC_BCH; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc; -- 2.17.1
[PATCH v3 3/4] mtd: rawnand: micron: add fixup for ONFI revision
Some Micron NAND chips (MT29F1G08ABAFAWP-ITE:F) report 00 00 for the revision number field of the ONFI parameter page. Rather than rejecting these outright assume ONFI version 1.0 if the revision number is 00 00. Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- This is now qualified on vendor == MICRON. I haven't qualified this based on specific chips the ABAFA (id=d1) and ABBFA (id=a1) variants are documented to have this behaviour. Changes in v2: - use fixup_onfi_param_page Changes in v3: - add code comment next to workaround drivers/mtd/nand/raw/nand_micron.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 5ec4c90a637d..5cec79372181 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -289,6 +289,19 @@ static int micron_nand_init(struct nand_chip *chip) return 0; } +static void micron_fixup_onfi_param_page(struct nand_chip *chip, +struct nand_onfi_params *p) +{ + /* +* MT29F1G08ABAFAWP-ITE:F and possibly others report 00 00 for the +* revision number field of the ONFI parameter page. Assume ONFI +* version 1.0 if the revision number is 00 00. +*/ + if (le16_to_cpu(p->revision) == 0) + p->revision = cpu_to_le16(1 << 1); +} + const struct nand_manufacturer_ops micron_nand_manuf_ops = { .init = micron_nand_init, + .fixup_onfi_param_page = micron_fixup_onfi_param_page, }; -- 2.17.1
[PATCH v3 3/4] mtd: rawnand: micron: add fixup for ONFI revision
Some Micron NAND chips (MT29F1G08ABAFAWP-ITE:F) report 00 00 for the revision number field of the ONFI parameter page. Rather than rejecting these outright assume ONFI version 1.0 if the revision number is 00 00. Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- This is now qualified on vendor == MICRON. I haven't qualified this based on specific chips the ABAFA (id=d1) and ABBFA (id=a1) variants are documented to have this behaviour. Changes in v2: - use fixup_onfi_param_page Changes in v3: - add code comment next to workaround drivers/mtd/nand/raw/nand_micron.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 5ec4c90a637d..5cec79372181 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -289,6 +289,19 @@ static int micron_nand_init(struct nand_chip *chip) return 0; } +static void micron_fixup_onfi_param_page(struct nand_chip *chip, +struct nand_onfi_params *p) +{ + /* +* MT29F1G08ABAFAWP-ITE:F and possibly others report 00 00 for the +* revision number field of the ONFI parameter page. Assume ONFI +* version 1.0 if the revision number is 00 00. +*/ + if (le16_to_cpu(p->revision) == 0) + p->revision = cpu_to_le16(1 << 1); +} + const struct nand_manufacturer_ops micron_nand_manuf_ops = { .init = micron_nand_init, + .fixup_onfi_param_page = micron_fixup_onfi_param_page, }; -- 2.17.1
[PATCH v3 2/4] mtd: rawnand: add manufacturer fixup for ONFI parameter page
This is called after the ONFI parameter page checksum is verified and allows us to override the contents of the parameter page. Suggested-by: Boris Brezillon Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Add doc comment and review from Boris drivers/mtd/nand/raw/nand_base.c | 4 include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0cd3e216b95c..65250308c82d 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5172,6 +5172,10 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) } } + if (chip->manufacturer.desc && chip->manufacturer.desc->ops && + chip->manufacturer.desc->ops->fixup_onfi_param_page) + chip->manufacturer.desc->ops->fixup_onfi_param_page(chip, p); + /* Check version */ val = le16_to_cpu(p->revision); if (val & (1 << 5)) diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 3e8ec3b8a39c..ef7e3b4e91ea 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -778,11 +778,14 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) * implementation) if any. * @cleanup: the ->init() function may have allocated resources, ->cleanup() * is here to let vendor specific code release those resources. + * @fixup_onfi_param_page: apply vendor specific fixups to the ONFI + * parameter page. This is called after the checksum is verified. */ struct nand_manufacturer_ops { void (*detect)(struct nand_chip *chip); int (*init)(struct nand_chip *chip); void (*cleanup)(struct nand_chip *chip); + void (*fixup_onfi_param_page)(struct nand_chip *chip, struct nand_onfi_params *p); }; /** -- 2.17.1
[PATCH v3 2/4] mtd: rawnand: add manufacturer fixup for ONFI parameter page
This is called after the ONFI parameter page checksum is verified and allows us to override the contents of the parameter page. Suggested-by: Boris Brezillon Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Add doc comment and review from Boris drivers/mtd/nand/raw/nand_base.c | 4 include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0cd3e216b95c..65250308c82d 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5172,6 +5172,10 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) } } + if (chip->manufacturer.desc && chip->manufacturer.desc->ops && + chip->manufacturer.desc->ops->fixup_onfi_param_page) + chip->manufacturer.desc->ops->fixup_onfi_param_page(chip, p); + /* Check version */ val = le16_to_cpu(p->revision); if (val & (1 << 5)) diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 3e8ec3b8a39c..ef7e3b4e91ea 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -778,11 +778,14 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) * implementation) if any. * @cleanup: the ->init() function may have allocated resources, ->cleanup() * is here to let vendor specific code release those resources. + * @fixup_onfi_param_page: apply vendor specific fixups to the ONFI + * parameter page. This is called after the checksum is verified. */ struct nand_manufacturer_ops { void (*detect)(struct nand_chip *chip); int (*init)(struct nand_chip *chip); void (*cleanup)(struct nand_chip *chip); + void (*fixup_onfi_param_page)(struct nand_chip *chip, struct nand_onfi_params *p); }; /** -- 2.17.1
[PATCH v3 1/4] mtd: rawnand: marvell: Handle on-die ECC
>From the controllers point of view this is the same as no or software only ECC. Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Add review from Boris drivers/mtd/nand/raw/marvell_nand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index ebb1d141b900..ba6889bbe802 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -2157,6 +2157,7 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, break; case NAND_ECC_NONE: case NAND_ECC_SOFT: + case NAND_ECC_ON_DIE: if (!nfc->caps->is_nfcv2 && mtd->writesize != SZ_512 && mtd->writesize != SZ_2K) { dev_err(nfc->dev, "NFCv1 cannot write %d bytes pages\n", -- 2.17.1
[PATCH v3 1/4] mtd: rawnand: marvell: Handle on-die ECC
>From the controllers point of view this is the same as no or software only ECC. Reviewed-by: Boris Brezillon Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Add review from Boris drivers/mtd/nand/raw/marvell_nand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index ebb1d141b900..ba6889bbe802 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -2157,6 +2157,7 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, break; case NAND_ECC_NONE: case NAND_ECC_SOFT: + case NAND_ECC_ON_DIE: if (!nfc->caps->is_nfcv2 && mtd->writesize != SZ_512 && mtd->writesize != SZ_2K) { dev_err(nfc->dev, "NFCv1 cannot write %d bytes pages\n", -- 2.17.1
Re: [PATCH v3 1/4] seccomp: add a return code to trap to userspace
On Thu, May 31, 2018 at 08:49:46AM -0600, Tycho Andersen wrote: > This patch introduces a means for syscalls matched in seccomp to notify > some other task that a particular filter has been triggered. > > The motivation for this is primarily for use with containers. For example, > if a container does an init_module(), we obviously don't want to load this > untrusted code, which may be compiled for the wrong version of the kernel > anyway. Instead, we could parse the module image, figure out which module > the container is trying to load and load it on the host. > > As another example, containers cannot mknod(), since this checks > capable(CAP_SYS_ADMIN). However, harmless devices like /dev/null or > /dev/zero should be ok for containers to mknod, but we'd like to avoid hard > coding some whitelist in the kernel. Another example is mount(), which has > many security restrictions for good reason, but configuration or runtime > knowledge could potentially be used to relax these restrictions. > > This patch adds functionality that is already possible via at least two > other means that I know about, both of which involve ptrace(): first, one > could ptrace attach, and then iterate through syscalls via PTRACE_SYSCALL. > Unfortunately this is slow, so a faster version would be to install a > filter that does SECCOMP_RET_TRACE, which triggers a PTRACE_EVENT_SECCOMP. > Since ptrace allows only one tracer, if the container runtime is that > tracer, users inside the container (or outside) trying to debug it will not > be able to use ptrace, which is annoying. It also means that older > distributions based on Upstart cannot boot inside containers using ptrace, > since upstart itself uses ptrace to start services. > > The actual implementation of this is fairly small, although getting the > synchronization right was/is slightly complex. > > Finally, it's worth noting that the classic seccomp TOCTOU of reading > memory data from the task still applies here, but can be avoided with > careful design of the userspace handler: if the userspace handler reads all > of the task memory that is necessary before applying its security policy, > the tracee's subsequent memory edits will not be read by the tracer. > > v2: * make id a u64; the idea here being that it will never overflow, > because 64 is huge (one syscall every nanosecond => wrap every 584 > years) (Andy) > * prevent nesting of user notifications: if someone is already attached > the tree in one place, nobody else can attach to the tree (Andy) > * notify the listener of signals the tracee receives as well (Andy) > * implement poll > v3: * lockdep fix (Oleg) > * drop unnecessary WARN()s (Christian) > * rearrange error returns to be more rpetty (Christian) > * fix build in !CONFIG_SECCOMP_USER_NOTIFICATION case > > Signed-off-by: Tycho Andersen > CC: Kees Cook > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Eric W. Biederman > CC: "Serge E. Hallyn" > CC: Christian Brauner > CC: Tyler Hicks > CC: Akihiro Suda > --- > arch/Kconfig | 7 + > include/linux/seccomp.h | 3 +- > include/uapi/linux/seccomp.h | 18 +- > kernel/seccomp.c | 398 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 195 - > 5 files changed, 615 insertions(+), 6 deletions(-) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 75dd23acf133..1c1ae8d8c8b9 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -401,6 +401,13 @@ config SECCOMP_FILTER > > See Documentation/prctl/seccomp_filter.txt for details. > > +config SECCOMP_USER_NOTIFICATION > + bool "Enable the SECCOMP_RET_USER_NOTIF seccomp action" > + depends on SECCOMP_FILTER > + help > + Enable SECCOMP_RET_USER_NOTIF, a return code which can be used by > seccomp > + programs to notify a userspace listener that a particular event > happened. > + > config HAVE_GCC_PLUGINS > bool > help > diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h > index c723a5c4e3ff..0fd3e0676a1c 100644 > --- a/include/linux/seccomp.h > +++ b/include/linux/seccomp.h > @@ -5,7 +5,8 @@ > #include > > #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ > - SECCOMP_FILTER_FLAG_LOG) > + SECCOMP_FILTER_FLAG_LOG | \ > + SECCOMP_FILTER_FLAG_GET_LISTENER) > > #ifdef CONFIG_SECCOMP > > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h > index 2a0bd9dd104d..8160e6cad528 100644 > --- a/include/uapi/linux/seccomp.h > +++ b/include/uapi/linux/seccomp.h > @@ -17,8 +17,9 @@ > #define SECCOMP_GET_ACTION_AVAIL 2 > > /* Valid flags for SECCOMP_SET_MODE_FILTER */ > -#define SECCOMP_FILTER_FLAG_TSYNC1 > -#define SECCOMP_FILTER_FLAG_LOG 2 > +#define
Re: [PATCH v3 1/4] seccomp: add a return code to trap to userspace
On Thu, May 31, 2018 at 08:49:46AM -0600, Tycho Andersen wrote: > This patch introduces a means for syscalls matched in seccomp to notify > some other task that a particular filter has been triggered. > > The motivation for this is primarily for use with containers. For example, > if a container does an init_module(), we obviously don't want to load this > untrusted code, which may be compiled for the wrong version of the kernel > anyway. Instead, we could parse the module image, figure out which module > the container is trying to load and load it on the host. > > As another example, containers cannot mknod(), since this checks > capable(CAP_SYS_ADMIN). However, harmless devices like /dev/null or > /dev/zero should be ok for containers to mknod, but we'd like to avoid hard > coding some whitelist in the kernel. Another example is mount(), which has > many security restrictions for good reason, but configuration or runtime > knowledge could potentially be used to relax these restrictions. > > This patch adds functionality that is already possible via at least two > other means that I know about, both of which involve ptrace(): first, one > could ptrace attach, and then iterate through syscalls via PTRACE_SYSCALL. > Unfortunately this is slow, so a faster version would be to install a > filter that does SECCOMP_RET_TRACE, which triggers a PTRACE_EVENT_SECCOMP. > Since ptrace allows only one tracer, if the container runtime is that > tracer, users inside the container (or outside) trying to debug it will not > be able to use ptrace, which is annoying. It also means that older > distributions based on Upstart cannot boot inside containers using ptrace, > since upstart itself uses ptrace to start services. > > The actual implementation of this is fairly small, although getting the > synchronization right was/is slightly complex. > > Finally, it's worth noting that the classic seccomp TOCTOU of reading > memory data from the task still applies here, but can be avoided with > careful design of the userspace handler: if the userspace handler reads all > of the task memory that is necessary before applying its security policy, > the tracee's subsequent memory edits will not be read by the tracer. > > v2: * make id a u64; the idea here being that it will never overflow, > because 64 is huge (one syscall every nanosecond => wrap every 584 > years) (Andy) > * prevent nesting of user notifications: if someone is already attached > the tree in one place, nobody else can attach to the tree (Andy) > * notify the listener of signals the tracee receives as well (Andy) > * implement poll > v3: * lockdep fix (Oleg) > * drop unnecessary WARN()s (Christian) > * rearrange error returns to be more rpetty (Christian) > * fix build in !CONFIG_SECCOMP_USER_NOTIFICATION case > > Signed-off-by: Tycho Andersen > CC: Kees Cook > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Eric W. Biederman > CC: "Serge E. Hallyn" > CC: Christian Brauner > CC: Tyler Hicks > CC: Akihiro Suda > --- > arch/Kconfig | 7 + > include/linux/seccomp.h | 3 +- > include/uapi/linux/seccomp.h | 18 +- > kernel/seccomp.c | 398 +- > tools/testing/selftests/seccomp/seccomp_bpf.c | 195 - > 5 files changed, 615 insertions(+), 6 deletions(-) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 75dd23acf133..1c1ae8d8c8b9 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -401,6 +401,13 @@ config SECCOMP_FILTER > > See Documentation/prctl/seccomp_filter.txt for details. > > +config SECCOMP_USER_NOTIFICATION > + bool "Enable the SECCOMP_RET_USER_NOTIF seccomp action" > + depends on SECCOMP_FILTER > + help > + Enable SECCOMP_RET_USER_NOTIF, a return code which can be used by > seccomp > + programs to notify a userspace listener that a particular event > happened. > + > config HAVE_GCC_PLUGINS > bool > help > diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h > index c723a5c4e3ff..0fd3e0676a1c 100644 > --- a/include/linux/seccomp.h > +++ b/include/linux/seccomp.h > @@ -5,7 +5,8 @@ > #include > > #define SECCOMP_FILTER_FLAG_MASK (SECCOMP_FILTER_FLAG_TSYNC | \ > - SECCOMP_FILTER_FLAG_LOG) > + SECCOMP_FILTER_FLAG_LOG | \ > + SECCOMP_FILTER_FLAG_GET_LISTENER) > > #ifdef CONFIG_SECCOMP > > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h > index 2a0bd9dd104d..8160e6cad528 100644 > --- a/include/uapi/linux/seccomp.h > +++ b/include/uapi/linux/seccomp.h > @@ -17,8 +17,9 @@ > #define SECCOMP_GET_ACTION_AVAIL 2 > > /* Valid flags for SECCOMP_SET_MODE_FILTER */ > -#define SECCOMP_FILTER_FLAG_TSYNC1 > -#define SECCOMP_FILTER_FLAG_LOG 2 > +#define
Re: linux-next: Signed-off-by missing for commit in the scsi-mkp tree
Hi Martin, On Tue, 19 Jun 2018 22:03:48 -0400 "Martin K. Petersen" wrote: > > > Commit > > > > 508fbc44bbb7 ("scsi: be2iscsi: Include null char in SET_HOST_DATA") > > > > is missing a Signed-off-by from its author. > > Fixed, thanks! Unfortunately, James had already merged your tree :-( -- Cheers, Stephen Rothwell pgpO9wit21WIL.pgp Description: OpenPGP digital signature
Re: linux-next: Signed-off-by missing for commit in the scsi-mkp tree
Hi Martin, On Tue, 19 Jun 2018 22:03:48 -0400 "Martin K. Petersen" wrote: > > > Commit > > > > 508fbc44bbb7 ("scsi: be2iscsi: Include null char in SET_HOST_DATA") > > > > is missing a Signed-off-by from its author. > > Fixed, thanks! Unfortunately, James had already merged your tree :-( -- Cheers, Stephen Rothwell pgpO9wit21WIL.pgp Description: OpenPGP digital signature
Re: [PATCH] arm: dts: socfpga: denali needs nand_x_clk too
On 06/19/2018 02:07 PM, Richard Weinberger wrote: > The denali NAND flash controller needs at least two clocks to operate, > nand_clk and nand_x_clk. > Since 1bb88666775e ("mtd: nand: denali: handle timing parameters by > setup_data_interface()") nand_x_clk is used to derive timing settings. > > Signed-off-by: Richard Weinberger > --- > Strictly speaking denali needs a ecc_clk too, but AFAIK such a clock > is not present on this SoC. > But my SoCFPGA knowledge is very limited. > > Thanks, > //richard It looks sane, but I cannot test it right now, since I'm on vacation. I hope Dinh/Chin can jump in. > --- > arch/arm/boot/dts/socfpga.dtsi | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi > index 486d4e7433ed..562f7b375bbd 100644 > --- a/arch/arm/boot/dts/socfpga.dtsi > +++ b/arch/arm/boot/dts/socfpga.dtsi > @@ -754,7 +754,8 @@ > reg-names = "nand_data", "denali_reg"; > interrupts = <0x0 0x90 0x4>; > dma-mask = <0x>; > - clocks = <_clk>; > + clocks = <_clk>, <_x_clk>; > + clock-names = "nand", "nand_x"; > status = "disabled"; > }; > > -- Best regards, Marek Vasut
Re: [PATCH] arm: dts: socfpga: denali needs nand_x_clk too
On 06/19/2018 02:07 PM, Richard Weinberger wrote: > The denali NAND flash controller needs at least two clocks to operate, > nand_clk and nand_x_clk. > Since 1bb88666775e ("mtd: nand: denali: handle timing parameters by > setup_data_interface()") nand_x_clk is used to derive timing settings. > > Signed-off-by: Richard Weinberger > --- > Strictly speaking denali needs a ecc_clk too, but AFAIK such a clock > is not present on this SoC. > But my SoCFPGA knowledge is very limited. > > Thanks, > //richard It looks sane, but I cannot test it right now, since I'm on vacation. I hope Dinh/Chin can jump in. > --- > arch/arm/boot/dts/socfpga.dtsi | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi > index 486d4e7433ed..562f7b375bbd 100644 > --- a/arch/arm/boot/dts/socfpga.dtsi > +++ b/arch/arm/boot/dts/socfpga.dtsi > @@ -754,7 +754,8 @@ > reg-names = "nand_data", "denali_reg"; > interrupts = <0x0 0x90 0x4>; > dma-mask = <0x>; > - clocks = <_clk>; > + clocks = <_clk>, <_x_clk>; > + clock-names = "nand", "nand_x"; > status = "disabled"; > }; > > -- Best regards, Marek Vasut
include/linux/syscalls.h:211:18: error: 'sys_mmap2' alias between functions of incompatible types 'long int(long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigne
Hi Al, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: ba4dbdedd3edc2798659bcd8b1a184ea8bdd04dc commit: ee076e81fc14ca79334d02970cea66604f183a14 sparc: trivial conversions to {COMPAT_,}SYSCALL_DEFINE() date: 3 months ago config: sparc-defconfig (attached as .config) compiler: sparc-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout ee076e81fc14ca79334d02970cea66604f183a14 # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=sparc All errors (new ones prefixed by >>): In file included from arch/sparc/kernel/sys_sparc_32.c:21: >> include/linux/syscalls.h:211:18: error: 'sys_mmap2' alias between functions >> of incompatible types 'long int(long unsigned int, long unsigned int, long >> unsigned int, long unsigned int, long unsigned int, long unsigned int)' >> and 'long int(long int, long int, long int, long int, long int, long >> int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:101:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, ^~~ include/linux/syscalls.h:215:18: note: aliased declaration here asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:101:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, ^~~ >> include/linux/syscalls.h:211:18: error: 'sys_getdomainname' alias between >> functions of incompatible types 'long int(char *, int)' and 'long int(long >> int, long int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:205:1: note: in expansion of macro 'SYSCALL_DEFINE2' SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len) ^~~ include/linux/syscalls.h:215:18: note: aliased declaration here asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:205:1: note: in expansion of macro 'SYSCALL_DEFINE2' SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len) ^~~ include/linux/syscalls.h:211:18: error: 'sys_rt_sigaction' alias between functions of incompatible types 'long int(int, const struct sigaction *, struct sigaction *, void *, size_t)' {aka 'long int(int, const struct sigaction *, struct sigaction *, void *, unsigned int)'} and 'long int(long int, long int, long int, long int, long int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:200:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:176:1: note: in expansion of macro 'SYSCALL_DEFINE5'
Re: [PATCH v2] mdio-mux-gpio: Remove VLA usage
On Wed, May 30, 2018 at 1:57 PM, Andrew Lunn wrote: > On Wed, May 30, 2018 at 01:48:30PM -0700, Kees Cook wrote: >> In the quest to remove all stack VLA usage from the kernel[1], this >> moves the allocation into struct mdio_mux_gpio_state during probe. >> >> [1] >> https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com >> >> Signed-off-by: Kees Cook >> --- >> v2: allocate array as part of structure (Andrew Lunn) > > Hi Kees > > This looks much better, thanks. > > Reviewed-by: Andrew Lunn Thanks! Who can take this patch? Linus? -Kees -- Kees Cook Pixel Security
include/linux/syscalls.h:211:18: error: 'sys_mmap2' alias between functions of incompatible types 'long int(long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigne
Hi Al, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: ba4dbdedd3edc2798659bcd8b1a184ea8bdd04dc commit: ee076e81fc14ca79334d02970cea66604f183a14 sparc: trivial conversions to {COMPAT_,}SYSCALL_DEFINE() date: 3 months ago config: sparc-defconfig (attached as .config) compiler: sparc-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout ee076e81fc14ca79334d02970cea66604f183a14 # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=sparc All errors (new ones prefixed by >>): In file included from arch/sparc/kernel/sys_sparc_32.c:21: >> include/linux/syscalls.h:211:18: error: 'sys_mmap2' alias between functions >> of incompatible types 'long int(long unsigned int, long unsigned int, long >> unsigned int, long unsigned int, long unsigned int, long unsigned int)' >> and 'long int(long int, long int, long int, long int, long int, long >> int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:101:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, ^~~ include/linux/syscalls.h:215:18: note: aliased declaration here asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:201:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:101:1: note: in expansion of macro 'SYSCALL_DEFINE6' SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, ^~~ >> include/linux/syscalls.h:211:18: error: 'sys_getdomainname' alias between >> functions of incompatible types 'long int(char *, int)' and 'long int(long >> int, long int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:205:1: note: in expansion of macro 'SYSCALL_DEFINE2' SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len) ^~~ include/linux/syscalls.h:215:18: note: aliased declaration here asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:197:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:205:1: note: in expansion of macro 'SYSCALL_DEFINE2' SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len) ^~~ include/linux/syscalls.h:211:18: error: 'sys_rt_sigaction' alias between functions of incompatible types 'long int(int, const struct sigaction *, struct sigaction *, void *, size_t)' {aka 'long int(int, const struct sigaction *, struct sigaction *, void *, unsigned int)'} and 'long int(long int, long int, long int, long int, long int)' [-Werror=attribute-alias] asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ ^~~ include/linux/syscalls.h:207:2: note: in expansion of macro '__SYSCALL_DEFINEx' __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) ^ include/linux/syscalls.h:200:36: note: in expansion of macro 'SYSCALL_DEFINEx' #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) ^~~ arch/sparc/kernel/sys_sparc_32.c:176:1: note: in expansion of macro 'SYSCALL_DEFINE5'
Re: [PATCH v2] mdio-mux-gpio: Remove VLA usage
On Wed, May 30, 2018 at 1:57 PM, Andrew Lunn wrote: > On Wed, May 30, 2018 at 01:48:30PM -0700, Kees Cook wrote: >> In the quest to remove all stack VLA usage from the kernel[1], this >> moves the allocation into struct mdio_mux_gpio_state during probe. >> >> [1] >> https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com >> >> Signed-off-by: Kees Cook >> --- >> v2: allocate array as part of structure (Andrew Lunn) > > Hi Kees > > This looks much better, thanks. > > Reviewed-by: Andrew Lunn Thanks! Who can take this patch? Linus? -Kees -- Kees Cook Pixel Security
linux-next: Tree for Jun 20
Hi all, Changes since 20180619: Undropped tree: userns The userns tree gained conflicts against the vfs tree. The akpm-current tree gained a conflict against the scsi tree. Non-merge commits (relative to Linus' tree): 1399 1468 files changed, 45747 insertions(+), 23865 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 279 trees (counting Linus' and 64 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (ba4dbdedd3ed Merge tag 'jfs-4.18' of git://github.com/kleikamp/linux-shaggy) Merging fixes/master (147a89bc71e7 Merge tag 'kconfig-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild) Merging kbuild-current/fixes (ce397d215ccd Linux 4.18-rc1) Merging arc-current/for-curr (e6c62399504c ARCv2: support manual regfile save on interrupts) Merging arm-current/fixes (92d44a42af81 ARM: fix kill( ,SIGFPE) breakage) Merging arm64-fixes/for-next/fixes (b154886f7892 arm64: make secondary_start_kernel() notrace) Merging m68k-current/for-linus (b12c8a70643f m68k: Set default dma mask for platform devices) Merging powerpc-fixes/fixes (faf37c44a105 powerpc/64s: Clear PCR on boot) Merging sparc/master (1aaccb5fa0ea Merge tag 'rtc-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (7e85dc8cb35a net_sched: blackhole: tell upper qdisc about dropped packets) Merging bpf/master (7e85dc8cb35a net_sched: blackhole: tell upper qdisc about dropped packets) Merging ipsec/master (45c180bc29ba xfrm_user: prevent leaking 2 bytes of kernel memory) Merging netfilter/master (ad9852af9758 netfilter: nf_ct_helper: Fix possible panic after nf_conntrack_helper_unregister) Merging ipvs/master (312564269535 net: netsec: reduce DMA mask to 40 bits) Merging wireless-drivers/master (755abd247a3d MAINTAINERS: update Xinming's email address) Merging mac80211/master (bf2b61a6838f cfg80211: fix rcu in cfg80211_unregister_wdev) Merging rdma-fixes/for-rc (375dc53d032f IB/rxe: Fix missing completion for mem_reg work requests) Merging sound-current/for-linus (a57a46b93244 ALSA: hda/ca0132: Fix DMic data rate for Alienware M17x R4) Merging sound-asoc-fixes/for-linus (e6eac9600614 Merge branch 'asoc-4.18' into asoc-linus) Merging regmap-fixes/for-linus (ce397d215ccd Linux 4.18-rc1) Merging regulator-fixes/for-linus (4f687fb1244b Merge branch 'regulator-4.18' into regulator-linus) Merging spi-fixes/for-linus (95a7bdea2f84 Merge branch 'spi-4.18' into spi-linus) Merging pci-current/for-linus (ce397d215ccd Linux 4.18-rc1) Merging driver-core.current/driver-core-linus (ce397d215ccd Linux 4.18-rc1) Merging tty.current/tty-linus (ce397d215ccd Linux 4.18-rc1) Merging usb.current/usb-linus (ce397d215ccd Linux 4.18-rc1) Merging usb-gadget-fixes/fixes (1d8e5c002758 dwc2: gadget: Fix ISOC IN DDMA PID bitfield value calculation) Merging usb-serial-fixes/usb-linus (24160628a34a USB: serial: cp210x: add CESINEL device ids) Merging usb-chipidea-fixes/ci-for-usb-stable (964728f9f407 USB: chipidea: msm: fix ulpi-node lookup) Merging phy/fixes (60cc43fc8884 Linux 4.17-rc1) Merging staging.current/staging-linus (ce397d215ccd Linux 4.18-rc1) Merging char-misc.current/char-misc-linus (ce397d215ccd Linux 4.1
linux-next: Tree for Jun 20
Hi all, Changes since 20180619: Undropped tree: userns The userns tree gained conflicts against the vfs tree. The akpm-current tree gained a conflict against the scsi tree. Non-merge commits (relative to Linus' tree): 1399 1468 files changed, 45747 insertions(+), 23865 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 279 trees (counting Linus' and 64 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (ba4dbdedd3ed Merge tag 'jfs-4.18' of git://github.com/kleikamp/linux-shaggy) Merging fixes/master (147a89bc71e7 Merge tag 'kconfig-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild) Merging kbuild-current/fixes (ce397d215ccd Linux 4.18-rc1) Merging arc-current/for-curr (e6c62399504c ARCv2: support manual regfile save on interrupts) Merging arm-current/fixes (92d44a42af81 ARM: fix kill( ,SIGFPE) breakage) Merging arm64-fixes/for-next/fixes (b154886f7892 arm64: make secondary_start_kernel() notrace) Merging m68k-current/for-linus (b12c8a70643f m68k: Set default dma mask for platform devices) Merging powerpc-fixes/fixes (faf37c44a105 powerpc/64s: Clear PCR on boot) Merging sparc/master (1aaccb5fa0ea Merge tag 'rtc-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (7e85dc8cb35a net_sched: blackhole: tell upper qdisc about dropped packets) Merging bpf/master (7e85dc8cb35a net_sched: blackhole: tell upper qdisc about dropped packets) Merging ipsec/master (45c180bc29ba xfrm_user: prevent leaking 2 bytes of kernel memory) Merging netfilter/master (ad9852af9758 netfilter: nf_ct_helper: Fix possible panic after nf_conntrack_helper_unregister) Merging ipvs/master (312564269535 net: netsec: reduce DMA mask to 40 bits) Merging wireless-drivers/master (755abd247a3d MAINTAINERS: update Xinming's email address) Merging mac80211/master (bf2b61a6838f cfg80211: fix rcu in cfg80211_unregister_wdev) Merging rdma-fixes/for-rc (375dc53d032f IB/rxe: Fix missing completion for mem_reg work requests) Merging sound-current/for-linus (a57a46b93244 ALSA: hda/ca0132: Fix DMic data rate for Alienware M17x R4) Merging sound-asoc-fixes/for-linus (e6eac9600614 Merge branch 'asoc-4.18' into asoc-linus) Merging regmap-fixes/for-linus (ce397d215ccd Linux 4.18-rc1) Merging regulator-fixes/for-linus (4f687fb1244b Merge branch 'regulator-4.18' into regulator-linus) Merging spi-fixes/for-linus (95a7bdea2f84 Merge branch 'spi-4.18' into spi-linus) Merging pci-current/for-linus (ce397d215ccd Linux 4.18-rc1) Merging driver-core.current/driver-core-linus (ce397d215ccd Linux 4.18-rc1) Merging tty.current/tty-linus (ce397d215ccd Linux 4.18-rc1) Merging usb.current/usb-linus (ce397d215ccd Linux 4.18-rc1) Merging usb-gadget-fixes/fixes (1d8e5c002758 dwc2: gadget: Fix ISOC IN DDMA PID bitfield value calculation) Merging usb-serial-fixes/usb-linus (24160628a34a USB: serial: cp210x: add CESINEL device ids) Merging usb-chipidea-fixes/ci-for-usb-stable (964728f9f407 USB: chipidea: msm: fix ulpi-node lookup) Merging phy/fixes (60cc43fc8884 Linux 4.17-rc1) Merging staging.current/staging-linus (ce397d215ccd Linux 4.18-rc1) Merging char-misc.current/char-misc-linus (ce397d215ccd Linux 4.1
Re: [PATCH V9] powercap/drivers/idle_injection: Add an idle injection framework
On 19-06-18, 15:23, Daniel Lezcano wrote: > Initially, the cpu_cooling device for ARM was changed by adding a new > policy inserting idle cycles. The intel_powerclamp driver does a > similar action. > > Instead of implementing idle injections privately in the cpu_cooling > device, move the idle injection code in a dedicated framework and give > the opportunity to other frameworks to make use of it. > > The framework relies on the smpboot kthreads which handles via its > main loop the common code for hotplugging and [un]parking. > > This code was previously tested with the cpu cooling device and went > through several iterations. It results now in split code and API > exported in the header file. It was tested with the cpu cooling device > with success. > > Signed-off-by: Daniel Lezcano > Cc: Viresh Kumar > Cc: Eduardo Valentin > Cc: Javi Merino > Cc: Leo Yan > Cc: Kevin Wangtao > Cc: Vincent Guittot > Cc: Rui Zhang > Cc: Daniel Thompson > Cc: Peter Zijlstra > Cc: Andrea Parri > --- > > V9: >- Unconditionnally reset the should_run flag for all kthreads > belonging to the cpumask and remove the park() callback (Viresh Kumar) >- Fix up the typos in the comments (Viresh Kumar) Looks great now. Can't think of any more races :) Reviewed-by: Viresh Kumar -- viresh
Re: [PATCH V9] powercap/drivers/idle_injection: Add an idle injection framework
On 19-06-18, 15:23, Daniel Lezcano wrote: > Initially, the cpu_cooling device for ARM was changed by adding a new > policy inserting idle cycles. The intel_powerclamp driver does a > similar action. > > Instead of implementing idle injections privately in the cpu_cooling > device, move the idle injection code in a dedicated framework and give > the opportunity to other frameworks to make use of it. > > The framework relies on the smpboot kthreads which handles via its > main loop the common code for hotplugging and [un]parking. > > This code was previously tested with the cpu cooling device and went > through several iterations. It results now in split code and API > exported in the header file. It was tested with the cpu cooling device > with success. > > Signed-off-by: Daniel Lezcano > Cc: Viresh Kumar > Cc: Eduardo Valentin > Cc: Javi Merino > Cc: Leo Yan > Cc: Kevin Wangtao > Cc: Vincent Guittot > Cc: Rui Zhang > Cc: Daniel Thompson > Cc: Peter Zijlstra > Cc: Andrea Parri > --- > > V9: >- Unconditionnally reset the should_run flag for all kthreads > belonging to the cpumask and remove the park() callback (Viresh Kumar) >- Fix up the typos in the comments (Viresh Kumar) Looks great now. Can't think of any more races :) Reviewed-by: Viresh Kumar -- viresh
pci: pci_printk use
All the pci_printk uses are at KERN_DEBUG which is always emitted into the kernel logging whenever the console log level is high enough. Are any of these appropriate for conversion to pci_dbg to allow these only to be emitted via dynamic_debug or if necessary via a #define DEBUG during compilation? $ git grep -w -n pci_printk drivers drivers/pci/bus.c:291: pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", drivers/pci/hotplug/shpchp.h:51:pci_printk(KERN_DEBUG, ctrl->pci_dev, \ drivers/pci/pci.c:2484: pci_printk(KERN_DEBUG, dev, "supports%s%s\n", drivers/pci/pci.c:2491: pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", drivers/pci/pci.c:2655: pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2658: pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2661: pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2664: pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:3775: pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", drivers/pci/pcie/aer.c:775: pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", drivers/pci/pcie/aer.c:1317:pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); drivers/pci/pcie/err.c:75: pci_printk(KERN_DEBUG, dev, "device has %s\n", drivers/pci/pcie/err.c:179: pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); drivers/pci/pcie/err.c:205: pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", drivers/pci/pcie/err.c:211: pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", drivers/pci/pcie/err.c:237: pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); drivers/pci/probe.c:321:pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); drivers/pci/probe.c:388:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:410:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:463:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:493:pci_printk(KERN_DEBUG, dev, drivers/pci/probe.c:1598: pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", drivers/pci/setup-bus.c:258:pci_printk(KERN_DEBUG, add_res->dev, drivers/pci/setup-bus.c:954:pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", drivers/pci/setup-bus.c:1101: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", drivers/pci/setup-bus.c:1569: pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n",
pci: pci_printk use
All the pci_printk uses are at KERN_DEBUG which is always emitted into the kernel logging whenever the console log level is high enough. Are any of these appropriate for conversion to pci_dbg to allow these only to be emitted via dynamic_debug or if necessary via a #define DEBUG during compilation? $ git grep -w -n pci_printk drivers drivers/pci/bus.c:291: pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n", drivers/pci/hotplug/shpchp.h:51:pci_printk(KERN_DEBUG, ctrl->pci_dev, \ drivers/pci/pci.c:2484: pci_printk(KERN_DEBUG, dev, "supports%s%s\n", drivers/pci/pci.c:2491: pci_printk(KERN_DEBUG, dev, "PME# supported from%s%s%s%s%s\n", drivers/pci/pci.c:2655: pci_printk(KERN_DEBUG, dev, "BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2658: pci_printk(KERN_DEBUG, dev, "ROM: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2661: pci_printk(KERN_DEBUG, dev, "VF BAR %d: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:2664: pci_printk(KERN_DEBUG, dev, "BEI %d res: %pR (from Enhanced Allocation, properties %#02x)\n", drivers/pci/pci.c:3775: pci_printk(KERN_DEBUG, dev, "cache line size of %d is not supported\n", drivers/pci/pcie/aer.c:775: pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n", drivers/pci/pcie/aer.c:1317:pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); drivers/pci/pcie/err.c:75: pci_printk(KERN_DEBUG, dev, "device has %s\n", drivers/pci/pcie/err.c:179: pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); drivers/pci/pcie/err.c:205: pci_printk(KERN_DEBUG, dev, "no link-reset support at upstream device %s\n", drivers/pci/pcie/err.c:211: pci_printk(KERN_DEBUG, dev, "link reset at upstream device %s failed\n", drivers/pci/pcie/err.c:237: pci_printk(KERN_DEBUG, dev, "broadcast %s message\n", error_mesg); drivers/pci/probe.c:321:pci_printk(KERN_DEBUG, dev, "reg 0x%x: %pR\n", pos, res); drivers/pci/probe.c:388:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:410:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:463:pci_printk(KERN_DEBUG, dev, " bridge window %pR\n", res); drivers/pci/probe.c:493:pci_printk(KERN_DEBUG, dev, drivers/pci/probe.c:1598: pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n", drivers/pci/setup-bus.c:258:pci_printk(KERN_DEBUG, add_res->dev, drivers/pci/setup-bus.c:954:pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx\n", drivers/pci/setup-bus.c:1101: pci_printk(KERN_DEBUG, bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", drivers/pci/setup-bus.c:1569: pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n",
Re: [PATCH 1/2] staging: android: ashmem: Remove use of unlikely()
On Tue, Jun 19, 2018 at 05:57:34PM -0700, Alistair Strachan wrote: > There is no speed difference, and it makes the code harder to read. > > Cc: Greg Kroah-Hartman > Cc: Arve Hjønnevåg > Cc: Todd Kjos > Cc: Martijn Coenen > Cc: de...@driverdev.osuosl.org > Cc: linux-kernel@vger.kernel.org > Cc: kernel-t...@android.com > Cc: Joel Fernandes > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Alistair Strachan Acked-by: Joel Fernandes (Google) thanks, - Joel
Re: [PATCH 1/2] staging: android: ashmem: Remove use of unlikely()
On Tue, Jun 19, 2018 at 05:57:34PM -0700, Alistair Strachan wrote: > There is no speed difference, and it makes the code harder to read. > > Cc: Greg Kroah-Hartman > Cc: Arve Hjønnevåg > Cc: Todd Kjos > Cc: Martijn Coenen > Cc: de...@driverdev.osuosl.org > Cc: linux-kernel@vger.kernel.org > Cc: kernel-t...@android.com > Cc: Joel Fernandes > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Alistair Strachan Acked-by: Joel Fernandes (Google) thanks, - Joel
[PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c
With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to detect buffer overflows. If src or dest is declared as a char, attempts to copy more than byte will result in a fortify_panic(). Address this problem in mvebu_setup_boot_addr_wa() by declaring mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays. Also remove a couple addressof operators to avoid "arithmetic on pointer to an incomplete type" compiler error. See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays, not single characters") for a similar fix. Fixes "detected buffer overflow in memcpy" error during init on some mvebu systems (armada-370-xp, armada-375): (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4) (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204) (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8) (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254) (kernel_init_freeable) from (kernel_init+0x8/0x114) (kernel_init) from (ret_from_fork+0x14/0x2c) Signed-off-by: Ethan Tuttle Tested-by: Ethan Tuttle --- arch/arm/mach-mvebu/pmsu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index 27a78c80e5b1..73d5d72dfc3e 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr) PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu)); } -extern unsigned char mvebu_boot_wa_start; -extern unsigned char mvebu_boot_wa_end; +extern unsigned char mvebu_boot_wa_start[]; +extern unsigned char mvebu_boot_wa_end[]; /* * This function sets up the boot address workaround needed for SMP @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target, phys_addr_t resume_addr_reg) { void __iomem *sram_virt_base; - u32 code_len = _boot_wa_end - _boot_wa_start; + u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start; mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE); mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute, -- 2.17.1
Re: [PATCH 2/2 v2] staging: android: ashmem: Fix mmap size validation
On Tue, Jun 19, 2018 at 05:57:35PM -0700, Alistair Strachan wrote: > The ashmem driver did not check that the size/offset of the vma passed > to its .mmap() function was not larger than the ashmem object being > mapped. This could cause mmap() to succeed, even though accessing parts > of the mapping would later fail with a segmentation fault. > > Ensure an error is returned by the ashmem_mmap() function if the vma > size is larger than the ashmem object size. This enables safer handling > of the problem in userspace. > > Cc: Greg Kroah-Hartman > Cc: Arve Hjønnevåg > Cc: Todd Kjos > Cc: Martijn Coenen > Cc: de...@driverdev.osuosl.org > Cc: linux-kernel@vger.kernel.org > Cc: kernel-t...@android.com > Cc: Joel Fernandes > Signed-off-by: Alistair Strachan > --- > v2: Removed unnecessary use of unlikely() macro > > drivers/staging/android/ashmem.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/staging/android/ashmem.c > b/drivers/staging/android/ashmem.c > index c6386e4f5c9b..e392358ec244 100644 > --- a/drivers/staging/android/ashmem.c > +++ b/drivers/staging/android/ashmem.c > @@ -366,6 +366,12 @@ static int ashmem_mmap(struct file *file, struct > vm_area_struct *vma) > goto out; > } > > + /* requested mapping size larger than object size */ > + if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { > + ret = -EINVAL; > + goto out; > + } > + Acked-by: Joel Fernandes (Google) thanks, - Joel
[PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c
With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to detect buffer overflows. If src or dest is declared as a char, attempts to copy more than byte will result in a fortify_panic(). Address this problem in mvebu_setup_boot_addr_wa() by declaring mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays. Also remove a couple addressof operators to avoid "arithmetic on pointer to an incomplete type" compiler error. See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays, not single characters") for a similar fix. Fixes "detected buffer overflow in memcpy" error during init on some mvebu systems (armada-370-xp, armada-375): (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4) (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204) (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8) (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254) (kernel_init_freeable) from (kernel_init+0x8/0x114) (kernel_init) from (ret_from_fork+0x14/0x2c) Signed-off-by: Ethan Tuttle Tested-by: Ethan Tuttle --- arch/arm/mach-mvebu/pmsu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index 27a78c80e5b1..73d5d72dfc3e 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr) PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu)); } -extern unsigned char mvebu_boot_wa_start; -extern unsigned char mvebu_boot_wa_end; +extern unsigned char mvebu_boot_wa_start[]; +extern unsigned char mvebu_boot_wa_end[]; /* * This function sets up the boot address workaround needed for SMP @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target, phys_addr_t resume_addr_reg) { void __iomem *sram_virt_base; - u32 code_len = _boot_wa_end - _boot_wa_start; + u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start; mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE); mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute, -- 2.17.1
Re: [PATCH 2/2 v2] staging: android: ashmem: Fix mmap size validation
On Tue, Jun 19, 2018 at 05:57:35PM -0700, Alistair Strachan wrote: > The ashmem driver did not check that the size/offset of the vma passed > to its .mmap() function was not larger than the ashmem object being > mapped. This could cause mmap() to succeed, even though accessing parts > of the mapping would later fail with a segmentation fault. > > Ensure an error is returned by the ashmem_mmap() function if the vma > size is larger than the ashmem object size. This enables safer handling > of the problem in userspace. > > Cc: Greg Kroah-Hartman > Cc: Arve Hjønnevåg > Cc: Todd Kjos > Cc: Martijn Coenen > Cc: de...@driverdev.osuosl.org > Cc: linux-kernel@vger.kernel.org > Cc: kernel-t...@android.com > Cc: Joel Fernandes > Signed-off-by: Alistair Strachan > --- > v2: Removed unnecessary use of unlikely() macro > > drivers/staging/android/ashmem.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/staging/android/ashmem.c > b/drivers/staging/android/ashmem.c > index c6386e4f5c9b..e392358ec244 100644 > --- a/drivers/staging/android/ashmem.c > +++ b/drivers/staging/android/ashmem.c > @@ -366,6 +366,12 @@ static int ashmem_mmap(struct file *file, struct > vm_area_struct *vma) > goto out; > } > > + /* requested mapping size larger than object size */ > + if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) { > + ret = -EINVAL; > + goto out; > + } > + Acked-by: Joel Fernandes (Google) thanks, - Joel
RE: [PATCH v6 6/8] platform/mellanox: Introduce support for Mellanox register access driver
> -Original Message- > From: Darren Hart [mailto:dvh...@infradead.org] > Sent: Wednesday, June 20, 2018 3:20 AM > To: Randy Dunlap > Cc: Vadim Pasternak ; andy.shevche...@gmail.com; > gre...@linuxfoundation.org; linux-kernel@vger.kernel.org; platform-driver- > x...@vger.kernel.org; j...@resnulli.us; Michael Shych > ; ivec...@redhat.com > Subject: Re: [PATCH v6 6/8] platform/mellanox: Introduce support for Mellanox > register access driver > > On Sun, Jun 17, 2018 at 09:52:16AM -0700, Randy Dunlap wrote: > > On 06/17/2018 09:56 AM, Vadim Pasternak wrote: > > > diff --git a/drivers/platform/mellanox/Kconfig > > > b/drivers/platform/mellanox/Kconfig > ... > > > + space trough sysfs interface. The sets of registers for sysfs > > > +access > > > > through > > > > > + are defined per system type bases and includes the registers > > > +related > > > > and include the > > > > I've taken care of these, thanks Randy, and applied the series to my testing > queue. Once the builds complete, I'll move these to for-next. > > Vadim, I see you've already updated the kernel version in the sys > documentation > to 4.19, so I won't attempt to push these into the 4.18 RC cycle. > Hi Daren, Thank you very much. Yes, it's good to push into 4.19. Thanks, Vadim. > -- > Darren Hart > VMware Open Source Technology Center
RE: [PATCH v6 6/8] platform/mellanox: Introduce support for Mellanox register access driver
> -Original Message- > From: Darren Hart [mailto:dvh...@infradead.org] > Sent: Wednesday, June 20, 2018 3:20 AM > To: Randy Dunlap > Cc: Vadim Pasternak ; andy.shevche...@gmail.com; > gre...@linuxfoundation.org; linux-kernel@vger.kernel.org; platform-driver- > x...@vger.kernel.org; j...@resnulli.us; Michael Shych > ; ivec...@redhat.com > Subject: Re: [PATCH v6 6/8] platform/mellanox: Introduce support for Mellanox > register access driver > > On Sun, Jun 17, 2018 at 09:52:16AM -0700, Randy Dunlap wrote: > > On 06/17/2018 09:56 AM, Vadim Pasternak wrote: > > > diff --git a/drivers/platform/mellanox/Kconfig > > > b/drivers/platform/mellanox/Kconfig > ... > > > + space trough sysfs interface. The sets of registers for sysfs > > > +access > > > > through > > > > > + are defined per system type bases and includes the registers > > > +related > > > > and include the > > > > I've taken care of these, thanks Randy, and applied the series to my testing > queue. Once the builds complete, I'll move these to for-next. > > Vadim, I see you've already updated the kernel version in the sys > documentation > to 4.19, so I won't attempt to push these into the 4.18 RC cycle. > Hi Daren, Thank you very much. Yes, it's good to push into 4.19. Thanks, Vadim. > -- > Darren Hart > VMware Open Source Technology Center
Re: [RFC][PATCH 0/6] Use printk_safe context for TTY and UART port locks
On (06/20/18 12:38), Linus Torvalds wrote: > On Wed, Jun 20, 2018 at 11:50 AM Sergey Senozhatsky > wrote: > > > > It's not UART on its own that immediately calls into printk(), that would > > be trivial to fix, it's all those subsystems that serial console driver > > can call into. > > We already have the whole PRINTK_SAFE_CONTEXT_MASK model that only > adds it to a secondary buffer if you get recursion. Why isn't that > triggering? That's the whole point of it. This is exactly what I'm doing in my patch set. PRINTK_SAFE_CONTEXT_MASK so far worked *one* way only: when we start from printk.c IOW: printk -> printk_safe_mask -> vsprinf -> printk But we also can have printk-related deadlocks the *other* way around. For instance: uart -> printk -> uart printk_safe_mask is not triggering there because we don't use printk_safe in uart / tty yet. And this is what I do in my patch set - extend printk_safe usage. The patch set does not add any _new_ locks or locking rules. It just replaces the existing spin_lock(a) with prinkt_safe_enter(); spin_lock(a) and spin_unlock(a) with spin_unlock(a) printk_safe_exit(); and that's it. So now we use printk_safe mechanism to avoid another bunch of deadlock scenarious: which don't start from printk, but from parts of the kernel which printk eventually calls. -ss
Re: [RFC][PATCH 0/6] Use printk_safe context for TTY and UART port locks
On (06/20/18 12:38), Linus Torvalds wrote: > On Wed, Jun 20, 2018 at 11:50 AM Sergey Senozhatsky > wrote: > > > > It's not UART on its own that immediately calls into printk(), that would > > be trivial to fix, it's all those subsystems that serial console driver > > can call into. > > We already have the whole PRINTK_SAFE_CONTEXT_MASK model that only > adds it to a secondary buffer if you get recursion. Why isn't that > triggering? That's the whole point of it. This is exactly what I'm doing in my patch set. PRINTK_SAFE_CONTEXT_MASK so far worked *one* way only: when we start from printk.c IOW: printk -> printk_safe_mask -> vsprinf -> printk But we also can have printk-related deadlocks the *other* way around. For instance: uart -> printk -> uart printk_safe_mask is not triggering there because we don't use printk_safe in uart / tty yet. And this is what I do in my patch set - extend printk_safe usage. The patch set does not add any _new_ locks or locking rules. It just replaces the existing spin_lock(a) with prinkt_safe_enter(); spin_lock(a) and spin_unlock(a) with spin_unlock(a) printk_safe_exit(); and that's it. So now we use printk_safe mechanism to avoid another bunch of deadlock scenarious: which don't start from printk, but from parts of the kernel which printk eventually calls. -ss
[PATCH v8 2/4] random: Return nbytes filled from hw RNG
Currently the function get_random_bytes_arch() has return value 'void'. If the hw RNG fails we currently fall back to using get_random_bytes(). This defeats the purpose of requesting random material from the hw RNG in the first place. There are currently no intree users of get_random_bytes_arch(). Only get random bytes from the hw RNG, make function return the number of bytes retrieved from the hw RNG. Acked-by: Theodore Ts'o Reviewed-by: Steven Rostedt (VMware) Signed-off-by: Tobin C. Harding --- drivers/char/random.c | 16 +--- include/linux/random.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index ed679099afba..e98fa03cdb91 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1724,26 +1724,28 @@ EXPORT_SYMBOL(del_random_ready_callback); * key known by the NSA). So it's useful if we need the speed, but * only if we're willing to trust the hardware manufacturer not to * have put in a back door. + * + * Return number of bytes filled in. */ -void get_random_bytes_arch(void *buf, int nbytes) +int __must_check get_random_bytes_arch(void *buf, int nbytes) { + int left = nbytes; char *p = buf; - trace_get_random_bytes_arch(nbytes, _RET_IP_); - while (nbytes) { + trace_get_random_bytes_arch(left, _RET_IP_); + while (left) { unsigned long v; - int chunk = min(nbytes, (int)sizeof(unsigned long)); + int chunk = min_t(int, left, sizeof(unsigned long)); if (!arch_get_random_long()) break; memcpy(p, , chunk); p += chunk; - nbytes -= chunk; + left -= chunk; } - if (nbytes) - get_random_bytes(p, nbytes); + return nbytes - left; } EXPORT_SYMBOL(get_random_bytes_arch); diff --git a/include/linux/random.h b/include/linux/random.h index 2ddf13b4281e..f1c9bc5cd231 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -38,7 +38,7 @@ extern void get_random_bytes(void *buf, int nbytes); extern int wait_for_random_bytes(void); extern int add_random_ready_callback(struct random_ready_callback *rdy); extern void del_random_ready_callback(struct random_ready_callback *rdy); -extern void get_random_bytes_arch(void *buf, int nbytes); +extern int __must_check get_random_bytes_arch(void *buf, int nbytes); #ifndef MODULE extern const struct file_operations random_fops, urandom_fops; -- 2.17.1
[PATCH v8 4/4] vsprintf: Add command line option debug_boot_weak_hash
Currently printing [hashed] pointers requires enough entropy to be available. Early in the boot sequence this may not be the case resulting in a dummy string '(ptrval)' being printed. This makes debugging the early boot sequence difficult. We can relax the requirement to use cryptographically secure hashing during debugging. This enables debugging while keeping development/production kernel behaviour the same. If new command line option debug_boot_weak_hash is enabled use cryptographically insecure hashing and hash pointer value immediately. Signed-off-by: Tobin C. Harding Reviewed-by: Steven Rostedt (VMware) --- Documentation/admin-guide/kernel-parameters.txt | 9 + lib/vsprintf.c | 17 + 2 files changed, 26 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 638342d0a095..a116fc0366b0 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -748,6 +748,15 @@ debug [KNL] Enable kernel debugging (events log level). + debug_boot_weak_hash + [KNL] Enable printing pointers early in the boot + sequence. If enabled, we use a weak hash instead of + siphash to hash pointers. Use this option if you need + to see pointer values during early boot (i.e you are + seeing instances of '(___ptrval___)'). + Cryptographically insecure, please do not use on + production kernels. + debug_locks_verbose= [KNL] verbose self-tests Format=<0|1> diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c445f9f28760..17ebe076ae41 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1651,6 +1651,17 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, return widen_string(buf, buf - buf_start, end, spec); } +/* Make pointers available for printing early in the boot sequence. */ +static int debug_boot_weak_hash __ro_after_init; + +static int __init debug_boot_weak_hash_enable(char *str) +{ + debug_boot_weak_hash = 1; + pr_info("debug_boot_weak_hash enabled\n"); + return 0; +} +early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable); + static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key); static siphash_key_t ptr_key __read_mostly; @@ -1703,6 +1714,12 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) const char *str = sizeof(ptr) == 8 ? "(ptrval)" : "(ptrval)"; unsigned long hashval; + /* When debugging early boot use non-cryptographically secure hash */ + if (unlikely(debug_boot_weak_hash)) { + hashval = hash_long((unsigned long)ptr, 32); + return pointer_string(buf, end, (const void *)hashval, spec); + } + if (static_branch_unlikely(_filled_random_ptr_key)) { spec.field_width = 2 * sizeof(ptr); /* string length must be less than default_width */ -- 2.17.1
[PATCH v8 2/4] random: Return nbytes filled from hw RNG
Currently the function get_random_bytes_arch() has return value 'void'. If the hw RNG fails we currently fall back to using get_random_bytes(). This defeats the purpose of requesting random material from the hw RNG in the first place. There are currently no intree users of get_random_bytes_arch(). Only get random bytes from the hw RNG, make function return the number of bytes retrieved from the hw RNG. Acked-by: Theodore Ts'o Reviewed-by: Steven Rostedt (VMware) Signed-off-by: Tobin C. Harding --- drivers/char/random.c | 16 +--- include/linux/random.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index ed679099afba..e98fa03cdb91 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1724,26 +1724,28 @@ EXPORT_SYMBOL(del_random_ready_callback); * key known by the NSA). So it's useful if we need the speed, but * only if we're willing to trust the hardware manufacturer not to * have put in a back door. + * + * Return number of bytes filled in. */ -void get_random_bytes_arch(void *buf, int nbytes) +int __must_check get_random_bytes_arch(void *buf, int nbytes) { + int left = nbytes; char *p = buf; - trace_get_random_bytes_arch(nbytes, _RET_IP_); - while (nbytes) { + trace_get_random_bytes_arch(left, _RET_IP_); + while (left) { unsigned long v; - int chunk = min(nbytes, (int)sizeof(unsigned long)); + int chunk = min_t(int, left, sizeof(unsigned long)); if (!arch_get_random_long()) break; memcpy(p, , chunk); p += chunk; - nbytes -= chunk; + left -= chunk; } - if (nbytes) - get_random_bytes(p, nbytes); + return nbytes - left; } EXPORT_SYMBOL(get_random_bytes_arch); diff --git a/include/linux/random.h b/include/linux/random.h index 2ddf13b4281e..f1c9bc5cd231 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -38,7 +38,7 @@ extern void get_random_bytes(void *buf, int nbytes); extern int wait_for_random_bytes(void); extern int add_random_ready_callback(struct random_ready_callback *rdy); extern void del_random_ready_callback(struct random_ready_callback *rdy); -extern void get_random_bytes_arch(void *buf, int nbytes); +extern int __must_check get_random_bytes_arch(void *buf, int nbytes); #ifndef MODULE extern const struct file_operations random_fops, urandom_fops; -- 2.17.1
[PATCH v8 4/4] vsprintf: Add command line option debug_boot_weak_hash
Currently printing [hashed] pointers requires enough entropy to be available. Early in the boot sequence this may not be the case resulting in a dummy string '(ptrval)' being printed. This makes debugging the early boot sequence difficult. We can relax the requirement to use cryptographically secure hashing during debugging. This enables debugging while keeping development/production kernel behaviour the same. If new command line option debug_boot_weak_hash is enabled use cryptographically insecure hashing and hash pointer value immediately. Signed-off-by: Tobin C. Harding Reviewed-by: Steven Rostedt (VMware) --- Documentation/admin-guide/kernel-parameters.txt | 9 + lib/vsprintf.c | 17 + 2 files changed, 26 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 638342d0a095..a116fc0366b0 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -748,6 +748,15 @@ debug [KNL] Enable kernel debugging (events log level). + debug_boot_weak_hash + [KNL] Enable printing pointers early in the boot + sequence. If enabled, we use a weak hash instead of + siphash to hash pointers. Use this option if you need + to see pointer values during early boot (i.e you are + seeing instances of '(___ptrval___)'). + Cryptographically insecure, please do not use on + production kernels. + debug_locks_verbose= [KNL] verbose self-tests Format=<0|1> diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c445f9f28760..17ebe076ae41 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1651,6 +1651,17 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, return widen_string(buf, buf - buf_start, end, spec); } +/* Make pointers available for printing early in the boot sequence. */ +static int debug_boot_weak_hash __ro_after_init; + +static int __init debug_boot_weak_hash_enable(char *str) +{ + debug_boot_weak_hash = 1; + pr_info("debug_boot_weak_hash enabled\n"); + return 0; +} +early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable); + static DEFINE_STATIC_KEY_TRUE(not_filled_random_ptr_key); static siphash_key_t ptr_key __read_mostly; @@ -1703,6 +1714,12 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) const char *str = sizeof(ptr) == 8 ? "(ptrval)" : "(ptrval)"; unsigned long hashval; + /* When debugging early boot use non-cryptographically secure hash */ + if (unlikely(debug_boot_weak_hash)) { + hashval = hash_long((unsigned long)ptr, 32); + return pointer_string(buf, end, (const void *)hashval, spec); + } + if (static_branch_unlikely(_filled_random_ptr_key)) { spec.field_width = 2 * sizeof(ptr); /* string length must be less than default_width */ -- 2.17.1
[PATCH v8 0/4] enable early printing of hashed pointers
Ted, Version 8 changes patch 2 which you previously acked. Change is to remove integer cast as suggested on LKML. I've kept the ACK. Changes made to patch with reviewed-by tag from Steve were acknowledged on LKML, I've also kept Steve's tag. Currently printing pointers early in the boot sequence can result in a dummy string '(ptrval)' being printed. While resolving this issue it was noticed that we can use the hw RNG if available for hashing pointers. Patch one and two do the ground work to be able to use hw RNG removing from get_random_bytes_arch() the call to get_random_bytes() and returning the number of bytes of random material successfully returned. Patch three uses the hw RNG to get keying material if it is available. Patch four further assists debugging early in the boot sequence for machines that do not have a hw RNG by adding a command line option 'debug_boot_weak_hash'. If enabled, non-cryptographically secure hashing is used instead of siphash so we can hash at any time. thanks, Tobin. v8 - Remove pointless EXPORT_SYMBOL on static variable (thanks Steve). - Remove unnecessary integer cast from min_t() argument (thanks Andy). v7 - Remove unused variable, clearing compiler warning (found by Stephen Rothwell's linux-next build infrastructure). v6 - Rebase on top of Steve's patch (fixing race condition). Uses static branch instead of memory barrier. v5 - Use 'upside-down-xmas-tree' style to declare local variables (Steve) - Added Reviewed-by tag from Steve (patch 2 and 3). v4 - remove last patch of series (command line option patch) v3 - Add __ro_after_init (suggested by Kees). v2 - Use min_t() instead of min() (thanks checkpatch). - Add __must_check to function declaration (thanks Steve). - Use hw RNG by default if available (as originally suggested by Kees). - Add command line option to use cryptographically insecure hashing. If debug_early_boot is enabled use hash_long() instead of siphash (as requested by Steve, and solves original problem for Anna-Maria). - Added Acked-by tag from Ted (patch 1 and 2) Tobin C. Harding (4): random: Fix whitespace pre random-bytes work random: Return nbytes filled from hw RNG vsprintf: Use hw RNG for ptr_key vsprintf: Add command line option debug_boot_weak_hash .../admin-guide/kernel-parameters.txt | 9 +++ drivers/char/random.c | 19 ++--- include/linux/random.h| 2 +- lib/vsprintf.c| 27 ++- 4 files changed, 46 insertions(+), 11 deletions(-) -- 2.17.1
[PATCH v8 0/4] enable early printing of hashed pointers
Ted, Version 8 changes patch 2 which you previously acked. Change is to remove integer cast as suggested on LKML. I've kept the ACK. Changes made to patch with reviewed-by tag from Steve were acknowledged on LKML, I've also kept Steve's tag. Currently printing pointers early in the boot sequence can result in a dummy string '(ptrval)' being printed. While resolving this issue it was noticed that we can use the hw RNG if available for hashing pointers. Patch one and two do the ground work to be able to use hw RNG removing from get_random_bytes_arch() the call to get_random_bytes() and returning the number of bytes of random material successfully returned. Patch three uses the hw RNG to get keying material if it is available. Patch four further assists debugging early in the boot sequence for machines that do not have a hw RNG by adding a command line option 'debug_boot_weak_hash'. If enabled, non-cryptographically secure hashing is used instead of siphash so we can hash at any time. thanks, Tobin. v8 - Remove pointless EXPORT_SYMBOL on static variable (thanks Steve). - Remove unnecessary integer cast from min_t() argument (thanks Andy). v7 - Remove unused variable, clearing compiler warning (found by Stephen Rothwell's linux-next build infrastructure). v6 - Rebase on top of Steve's patch (fixing race condition). Uses static branch instead of memory barrier. v5 - Use 'upside-down-xmas-tree' style to declare local variables (Steve) - Added Reviewed-by tag from Steve (patch 2 and 3). v4 - remove last patch of series (command line option patch) v3 - Add __ro_after_init (suggested by Kees). v2 - Use min_t() instead of min() (thanks checkpatch). - Add __must_check to function declaration (thanks Steve). - Use hw RNG by default if available (as originally suggested by Kees). - Add command line option to use cryptographically insecure hashing. If debug_early_boot is enabled use hash_long() instead of siphash (as requested by Steve, and solves original problem for Anna-Maria). - Added Acked-by tag from Ted (patch 1 and 2) Tobin C. Harding (4): random: Fix whitespace pre random-bytes work random: Return nbytes filled from hw RNG vsprintf: Use hw RNG for ptr_key vsprintf: Add command line option debug_boot_weak_hash .../admin-guide/kernel-parameters.txt | 9 +++ drivers/char/random.c | 19 ++--- include/linux/random.h| 2 +- lib/vsprintf.c| 27 ++- 4 files changed, 46 insertions(+), 11 deletions(-) -- 2.17.1
[PATCH v8 3/4] vsprintf: Use hw RNG for ptr_key
Currently we must wait for enough entropy to become available before hashed pointers can be printed. We can remove this wait by using the hw RNG if available. Use hw RNG to get keying material. Reviewed-by: Steven Rostedt (VMware) Suggested-by: Kees Cook Signed-off-by: Tobin C. Harding --- lib/vsprintf.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index a48aaa79d352..c445f9f28760 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1675,8 +1675,16 @@ static struct random_ready_callback random_ready = { static int __init initialize_ptr_random(void) { - int ret = add_random_ready_callback(_ready); + int key_size = sizeof(ptr_key); + int ret; + + /* Use hw RNG if available */ + if (get_random_bytes_arch(_key, key_size) == key_size) { + static_branch_disable(_filled_random_ptr_key); + return 0; + } + ret = add_random_ready_callback(_ready); if (!ret) { return 0; } else if (ret == -EALREADY) { -- 2.17.1
[PATCH v8 1/4] random: Fix whitespace pre random-bytes work
There are a couple of whitespace issues around the function get_random_bytes_arch(). In preparation for patching this function let's clean them up. Acked-by: Theodore Ts'o Signed-off-by: Tobin C. Harding --- drivers/char/random.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index a8fb0020ba5c..ed679099afba 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1736,7 +1736,7 @@ void get_random_bytes_arch(void *buf, int nbytes) if (!arch_get_random_long()) break; - + memcpy(p, , chunk); p += chunk; nbytes -= chunk; @@ -1747,7 +1747,6 @@ void get_random_bytes_arch(void *buf, int nbytes) } EXPORT_SYMBOL(get_random_bytes_arch); - /* * init_std_data - initialize pool with system data * -- 2.17.1
[PATCH v8 3/4] vsprintf: Use hw RNG for ptr_key
Currently we must wait for enough entropy to become available before hashed pointers can be printed. We can remove this wait by using the hw RNG if available. Use hw RNG to get keying material. Reviewed-by: Steven Rostedt (VMware) Suggested-by: Kees Cook Signed-off-by: Tobin C. Harding --- lib/vsprintf.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index a48aaa79d352..c445f9f28760 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1675,8 +1675,16 @@ static struct random_ready_callback random_ready = { static int __init initialize_ptr_random(void) { - int ret = add_random_ready_callback(_ready); + int key_size = sizeof(ptr_key); + int ret; + + /* Use hw RNG if available */ + if (get_random_bytes_arch(_key, key_size) == key_size) { + static_branch_disable(_filled_random_ptr_key); + return 0; + } + ret = add_random_ready_callback(_ready); if (!ret) { return 0; } else if (ret == -EALREADY) { -- 2.17.1
[PATCH v8 1/4] random: Fix whitespace pre random-bytes work
There are a couple of whitespace issues around the function get_random_bytes_arch(). In preparation for patching this function let's clean them up. Acked-by: Theodore Ts'o Signed-off-by: Tobin C. Harding --- drivers/char/random.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index a8fb0020ba5c..ed679099afba 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1736,7 +1736,7 @@ void get_random_bytes_arch(void *buf, int nbytes) if (!arch_get_random_long()) break; - + memcpy(p, , chunk); p += chunk; nbytes -= chunk; @@ -1747,7 +1747,6 @@ void get_random_bytes_arch(void *buf, int nbytes) } EXPORT_SYMBOL(get_random_bytes_arch); - /* * init_std_data - initialize pool with system data * -- 2.17.1
Re: [GIT PULL] HID fixes
On Wed, 20 Jun 2018, Linus Torvalds wrote: > What is that odd binary blob i2c_hid_desc_override, and where does the > data come from? Not explained anywhere. Fair enough; it's a pretty standard HID descriptor override, but you're right that we're usually replacing it in a bit more verbose way. Julian, could you please run that descriptor through something like HID descriptor tool, and send me a patch that reformats it? (for the way we usually do this, look for example in hid-sony.c). I'll drop this commit and resend the pull request (as namely the steam fix really should go in). The plan eventually is to offload all this crazy rdesc replacing to userspace, but that is still WIP. Thanks, -- Jiri Kosina SUSE Labs
Re: [GIT PULL] HID fixes
On Wed, 20 Jun 2018, Linus Torvalds wrote: > What is that odd binary blob i2c_hid_desc_override, and where does the > data come from? Not explained anywhere. Fair enough; it's a pretty standard HID descriptor override, but you're right that we're usually replacing it in a bit more verbose way. Julian, could you please run that descriptor through something like HID descriptor tool, and send me a patch that reformats it? (for the way we usually do this, look for example in hid-sony.c). I'll drop this commit and resend the pull request (as namely the steam fix really should go in). The plan eventually is to offload all this crazy rdesc replacing to userspace, but that is still WIP. Thanks, -- Jiri Kosina SUSE Labs
Re: [PATCH 0/2] serial: 8250_omap: Add compatible for AM654 UART
* Nishanth Menon [180619 20:13]: > Hi, > > This series was previously send out as part of a larger AM654 UART > support series, but was determined to create a bit of merge conflicts > due to interdependence. Both patches look good to me: Acked-by: Tony Lindgren
Re: [PATCH 0/2] serial: 8250_omap: Add compatible for AM654 UART
* Nishanth Menon [180619 20:13]: > Hi, > > This series was previously send out as part of a larger AM654 UART > support series, but was determined to create a bit of merge conflicts > due to interdependence. Both patches look good to me: Acked-by: Tony Lindgren
Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces
On (06/19/18 22:32), Steven Rostedt wrote: > On Wed, 20 Jun 2018 10:58:34 +0900 > Sergey Senozhatsky wrote: > > > Which one of these you'd prefer to see in ftrace_dump(): > > > > - printk_nmi_direct_enter() / printk_nmi_direct_exit() > > The above appears to be the most sane. OK. The original name suggested by Petr. -ss
Re: [PATCH] printk/nmi: Prevent deadlock when serializing NMI backtraces
On (06/19/18 22:32), Steven Rostedt wrote: > On Wed, 20 Jun 2018 10:58:34 +0900 > Sergey Senozhatsky wrote: > > > Which one of these you'd prefer to see in ftrace_dump(): > > > > - printk_nmi_direct_enter() / printk_nmi_direct_exit() > > The above appears to be the most sane. OK. The original name suggested by Petr. -ss
[PATCH V2 5/5] PCI: Unify slot and bus reset API
Drivers are expected to call pci_reset_slot() or pci_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_slot_reset() from drivers and embed into pci_bus_reset(). Change pci_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 27 +++ include/linux/pci.h | 3 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 79a1566..a44b948 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4798,7 +4798,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_slot); * * Return 0 on success, non-zero on error. */ -int pci_reset_slot(struct pci_slot *slot) +static int __pci_reset_slot(struct pci_slot *slot) { int rc; @@ -4814,7 +4814,6 @@ int pci_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_reset_slot); /** * __pci_try_reset_slot - Try to reset a PCI slot @@ -4878,7 +4877,7 @@ int pci_probe_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_probe_reset_bus); /** - * pci_reset_bus - reset a PCI bus + * __pci_reset_bus - reset a PCI bus * @bus: top level PCI bus to reset * * Do a bus reset on the given bus and any subordinate buses, saving @@ -4886,7 +4885,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_bus); * * Return 0 on success, non-zero on error. */ -int pci_reset_bus(struct pci_bus *bus) +static int __pci_reset_bus(struct pci_bus *bus) { int rc; @@ -4902,6 +4901,26 @@ int pci_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_reset_bus - reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Do a slot/bus reset on the given bus and any subordinate buses, saving + * and restoring state of all devices. + * + * Return 0 on success, non-zero on error. + */ +int pci_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_reset_slot(pdev->slot) : + __pci_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_reset_bus); /** diff --git a/include/linux/pci.h b/include/linux/pci.h index f5c85b6..e68ca2e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1095,9 +1095,8 @@ int pci_reset_function(struct pci_dev *dev); int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); -int pci_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); -int pci_reset_bus(struct pci_bus *bus); +int pci_reset_bus(struct pci_dev *dev); int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); -- 2.7.4
[PATCH V2 5/5] PCI: Unify slot and bus reset API
Drivers are expected to call pci_reset_slot() or pci_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_slot_reset() from drivers and embed into pci_bus_reset(). Change pci_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 27 +++ include/linux/pci.h | 3 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 79a1566..a44b948 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4798,7 +4798,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_slot); * * Return 0 on success, non-zero on error. */ -int pci_reset_slot(struct pci_slot *slot) +static int __pci_reset_slot(struct pci_slot *slot) { int rc; @@ -4814,7 +4814,6 @@ int pci_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_reset_slot); /** * __pci_try_reset_slot - Try to reset a PCI slot @@ -4878,7 +4877,7 @@ int pci_probe_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_probe_reset_bus); /** - * pci_reset_bus - reset a PCI bus + * __pci_reset_bus - reset a PCI bus * @bus: top level PCI bus to reset * * Do a bus reset on the given bus and any subordinate buses, saving @@ -4886,7 +4885,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_bus); * * Return 0 on success, non-zero on error. */ -int pci_reset_bus(struct pci_bus *bus) +static int __pci_reset_bus(struct pci_bus *bus) { int rc; @@ -4902,6 +4901,26 @@ int pci_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_reset_bus - reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Do a slot/bus reset on the given bus and any subordinate buses, saving + * and restoring state of all devices. + * + * Return 0 on success, non-zero on error. + */ +int pci_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_reset_slot(pdev->slot) : + __pci_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_reset_bus); /** diff --git a/include/linux/pci.h b/include/linux/pci.h index f5c85b6..e68ca2e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1095,9 +1095,8 @@ int pci_reset_function(struct pci_dev *dev); int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); -int pci_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); -int pci_reset_bus(struct pci_bus *bus); +int pci_reset_bus(struct pci_dev *dev); int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); -- 2.7.4
[PATCH V2 3/5] PCI: Hide pci_reset_bridge_secondary_bus() from drivers
Rename pci_reset_bridge_secondary_bus() to pci_bridge_secondary_bus_reset() and move the declartation from linux/pci.h to drivers/pci.h to be used internally in PCI directory only. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp_hpc.c | 2 +- drivers/pci/pci.c| 11 +-- drivers/pci/pci.h| 1 + drivers/pci/pcie/aer.c | 2 +- drivers/pci/pcie/err.c | 2 +- include/linux/pci.h | 1 - 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index bbaa211..8dae232 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -746,7 +746,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) if (pciehp_poll_mode) del_timer_sync(>poll_timer); - rc = pci_reset_bridge_secondary_bus(ctrl->pcie->port); + rc = pci_bridge_secondary_bus_reset(ctrl->pcie->port); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 98d1490..236220c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4224,19 +4224,18 @@ void __weak pcibios_reset_secondary_bus(struct pci_dev *dev) } /** - * pci_reset_bridge_secondary_bus - Reset the secondary bus on a PCI bridge. + * pci_bridge_secondary_bus_reset - Reset the secondary bus on a PCI bridge. * @dev: Bridge device * * Use the bridge control register to assert reset on the secondary bus. * Devices on the secondary bus are left in power-on state. */ -int pci_reset_bridge_secondary_bus(struct pci_dev *dev) +int pci_bridge_secondary_bus_reset(struct pci_dev *dev) { pcibios_reset_secondary_bus(dev); return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS); } -EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus); static int pci_parent_bus_reset(struct pci_dev *dev, int probe) { @@ -4253,7 +4252,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe) if (probe) return 0; - return pci_reset_bridge_secondary_bus(dev->bus->self); + return pci_bridge_secondary_bus_reset(dev->bus->self); } static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe) @@ -4860,7 +4859,7 @@ static int pci_bus_reset(struct pci_bus *bus, int probe) might_sleep(); - ret = pci_reset_bridge_secondary_bus(bus->self); + ret = pci_bridge_secondary_bus_reset(bus->self); pci_bus_unlock(bus); @@ -4924,7 +4923,7 @@ int pci_try_reset_bus(struct pci_bus *bus) if (pci_bus_trylock(bus)) { might_sleep(); - rc = pci_reset_bridge_secondary_bus(bus->self); + rc = pci_bridge_secondary_bus_reset(bus->self); pci_bus_unlock(bus); } else rc = -EAGAIN; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index c358e7a0..f784263 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -33,6 +33,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai, enum pci_mmap_api mmap_api); int pci_probe_reset_function(struct pci_dev *dev); +int pci_bridge_secondary_bus_reset(struct pci_dev *dev); /** * struct pci_platform_pm_ops - Firmware PM callbacks diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index f1d0f3e..74ea6ec 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1314,7 +1314,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - rc = pci_reset_bridge_secondary_bus(dev); + rc = pci_bridge_secondary_bus_reset(dev); pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); /* Clear Root Error Status */ diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 3a62a2e..a3a26f1 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -177,7 +177,7 @@ static pci_ers_result_t default_reset_link(struct pci_dev *dev) { int rc; - rc = pci_reset_bridge_secondary_bus(dev); + rc = pci_bridge_secondary_bus_reset(dev); pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } diff --git a/include/linux/pci.h b/include/linux/pci.h index 340029b..6b12ce2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1102,7 +1102,6 @@ int pci_reset_bus(struct pci_bus *bus); int pci_try_reset_bus(struct pci_bus *bus); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); -int pci_reset_bridge_secondary_bus(struct pci_dev *dev); void pci_update_resource(struct pci_dev *dev, int resno); int __must_check pci_assign_resource(struct
[PATCH V2 4/5] PCI: Unify try slot and bus reset API
Drivers are expected to call pci_try_reset_slot() or pci_try_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_try_slot_reset() from drivers and embed into pci_try_bus_reset(). Change pci_try_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 26 +- drivers/vfio/pci/vfio_pci.c | 6 ++ include/linux/pci.h | 3 +-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 236220c..79a1566 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4817,12 +4817,12 @@ int pci_reset_slot(struct pci_slot *slot) EXPORT_SYMBOL_GPL(pci_reset_slot); /** - * pci_try_reset_slot - Try to reset a PCI slot + * __pci_try_reset_slot - Try to reset a PCI slot * @slot: PCI slot to reset * * Same as above except return -EAGAIN if the slot cannot be locked */ -int pci_try_reset_slot(struct pci_slot *slot) +static int __pci_try_reset_slot(struct pci_slot *slot) { int rc; @@ -4843,7 +4843,6 @@ int pci_try_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_try_reset_slot); static int pci_bus_reset(struct pci_bus *bus, int probe) { @@ -4906,12 +4905,12 @@ int pci_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_reset_bus); /** - * pci_try_reset_bus - Try to reset a PCI bus + * __pci_try_reset_bus - Try to reset a PCI bus * @bus: top level PCI bus to reset * * Same as above except return -EAGAIN if the bus cannot be locked */ -int pci_try_reset_bus(struct pci_bus *bus) +static int __pci_try_reset_bus(struct pci_bus *bus) { int rc; @@ -4932,6 +4931,23 @@ int pci_try_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_try_reset_bus - Try to reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Same as above except return -EAGAIN if the bus cannot be locked + */ +int pci_try_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_try_reset_slot(pdev->slot) : + __pci_try_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_try_reset_bus); /** diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index b423a30..71018ec 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1010,8 +1010,7 @@ static long vfio_pci_ioctl(void *device_data, , slot); if (!ret) /* User has access, do the reset */ - ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : -pci_try_reset_bus(vdev->pdev->bus); + ret = pci_try_reset_bus(vdev->pdev); hot_reset_release: for (i--; i >= 0; i--) @@ -1373,8 +1372,7 @@ static void vfio_pci_try_bus_reset(struct vfio_pci_device *vdev) } if (needs_reset) - ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : -pci_try_reset_bus(vdev->pdev->bus); + ret = pci_try_reset_bus(vdev->pdev); put_devs: for (i = 0; i < devs.cur_index; i++) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 6b12ce2..f5c85b6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1096,10 +1096,9 @@ int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); int pci_reset_slot(struct pci_slot *slot); -int pci_try_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); int pci_reset_bus(struct pci_bus *bus); -int pci_try_reset_bus(struct pci_bus *bus); +int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); void pci_update_resource(struct pci_dev *dev, int resno); -- 2.7.4
[PATCH V2 3/5] PCI: Hide pci_reset_bridge_secondary_bus() from drivers
Rename pci_reset_bridge_secondary_bus() to pci_bridge_secondary_bus_reset() and move the declartation from linux/pci.h to drivers/pci.h to be used internally in PCI directory only. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp_hpc.c | 2 +- drivers/pci/pci.c| 11 +-- drivers/pci/pci.h| 1 + drivers/pci/pcie/aer.c | 2 +- drivers/pci/pcie/err.c | 2 +- include/linux/pci.h | 1 - 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index bbaa211..8dae232 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -746,7 +746,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) if (pciehp_poll_mode) del_timer_sync(>poll_timer); - rc = pci_reset_bridge_secondary_bus(ctrl->pcie->port); + rc = pci_bridge_secondary_bus_reset(ctrl->pcie->port); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 98d1490..236220c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4224,19 +4224,18 @@ void __weak pcibios_reset_secondary_bus(struct pci_dev *dev) } /** - * pci_reset_bridge_secondary_bus - Reset the secondary bus on a PCI bridge. + * pci_bridge_secondary_bus_reset - Reset the secondary bus on a PCI bridge. * @dev: Bridge device * * Use the bridge control register to assert reset on the secondary bus. * Devices on the secondary bus are left in power-on state. */ -int pci_reset_bridge_secondary_bus(struct pci_dev *dev) +int pci_bridge_secondary_bus_reset(struct pci_dev *dev) { pcibios_reset_secondary_bus(dev); return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS); } -EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus); static int pci_parent_bus_reset(struct pci_dev *dev, int probe) { @@ -4253,7 +4252,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe) if (probe) return 0; - return pci_reset_bridge_secondary_bus(dev->bus->self); + return pci_bridge_secondary_bus_reset(dev->bus->self); } static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe) @@ -4860,7 +4859,7 @@ static int pci_bus_reset(struct pci_bus *bus, int probe) might_sleep(); - ret = pci_reset_bridge_secondary_bus(bus->self); + ret = pci_bridge_secondary_bus_reset(bus->self); pci_bus_unlock(bus); @@ -4924,7 +4923,7 @@ int pci_try_reset_bus(struct pci_bus *bus) if (pci_bus_trylock(bus)) { might_sleep(); - rc = pci_reset_bridge_secondary_bus(bus->self); + rc = pci_bridge_secondary_bus_reset(bus->self); pci_bus_unlock(bus); } else rc = -EAGAIN; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index c358e7a0..f784263 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -33,6 +33,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai, enum pci_mmap_api mmap_api); int pci_probe_reset_function(struct pci_dev *dev); +int pci_bridge_secondary_bus_reset(struct pci_dev *dev); /** * struct pci_platform_pm_ops - Firmware PM callbacks diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index f1d0f3e..74ea6ec 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1314,7 +1314,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - rc = pci_reset_bridge_secondary_bus(dev); + rc = pci_bridge_secondary_bus_reset(dev); pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); /* Clear Root Error Status */ diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 3a62a2e..a3a26f1 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -177,7 +177,7 @@ static pci_ers_result_t default_reset_link(struct pci_dev *dev) { int rc; - rc = pci_reset_bridge_secondary_bus(dev); + rc = pci_bridge_secondary_bus_reset(dev); pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } diff --git a/include/linux/pci.h b/include/linux/pci.h index 340029b..6b12ce2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1102,7 +1102,6 @@ int pci_reset_bus(struct pci_bus *bus); int pci_try_reset_bus(struct pci_bus *bus); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); -int pci_reset_bridge_secondary_bus(struct pci_dev *dev); void pci_update_resource(struct pci_dev *dev, int resno); int __must_check pci_assign_resource(struct
[PATCH V2 4/5] PCI: Unify try slot and bus reset API
Drivers are expected to call pci_try_reset_slot() or pci_try_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_try_slot_reset() from drivers and embed into pci_try_bus_reset(). Change pci_try_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 26 +- drivers/vfio/pci/vfio_pci.c | 6 ++ include/linux/pci.h | 3 +-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 236220c..79a1566 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4817,12 +4817,12 @@ int pci_reset_slot(struct pci_slot *slot) EXPORT_SYMBOL_GPL(pci_reset_slot); /** - * pci_try_reset_slot - Try to reset a PCI slot + * __pci_try_reset_slot - Try to reset a PCI slot * @slot: PCI slot to reset * * Same as above except return -EAGAIN if the slot cannot be locked */ -int pci_try_reset_slot(struct pci_slot *slot) +static int __pci_try_reset_slot(struct pci_slot *slot) { int rc; @@ -4843,7 +4843,6 @@ int pci_try_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_try_reset_slot); static int pci_bus_reset(struct pci_bus *bus, int probe) { @@ -4906,12 +4905,12 @@ int pci_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_reset_bus); /** - * pci_try_reset_bus - Try to reset a PCI bus + * __pci_try_reset_bus - Try to reset a PCI bus * @bus: top level PCI bus to reset * * Same as above except return -EAGAIN if the bus cannot be locked */ -int pci_try_reset_bus(struct pci_bus *bus) +static int __pci_try_reset_bus(struct pci_bus *bus) { int rc; @@ -4932,6 +4931,23 @@ int pci_try_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_try_reset_bus - Try to reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Same as above except return -EAGAIN if the bus cannot be locked + */ +int pci_try_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_try_reset_slot(pdev->slot) : + __pci_try_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_try_reset_bus); /** diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index b423a30..71018ec 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1010,8 +1010,7 @@ static long vfio_pci_ioctl(void *device_data, , slot); if (!ret) /* User has access, do the reset */ - ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : -pci_try_reset_bus(vdev->pdev->bus); + ret = pci_try_reset_bus(vdev->pdev); hot_reset_release: for (i--; i >= 0; i--) @@ -1373,8 +1372,7 @@ static void vfio_pci_try_bus_reset(struct vfio_pci_device *vdev) } if (needs_reset) - ret = slot ? pci_try_reset_slot(vdev->pdev->slot) : -pci_try_reset_bus(vdev->pdev->bus); + ret = pci_try_reset_bus(vdev->pdev); put_devs: for (i = 0; i < devs.cur_index; i++) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 6b12ce2..f5c85b6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1096,10 +1096,9 @@ int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); int pci_reset_slot(struct pci_slot *slot); -int pci_try_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); int pci_reset_bus(struct pci_bus *bus); -int pci_try_reset_bus(struct pci_bus *bus); +int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev); void pci_update_resource(struct pci_dev *dev, int resno); -- 2.7.4
[PATCH V2 1/5] PCI: handle error return from pci_reset_bridge_secondary_bus()
commit 01fd61c0b9bd ("PCI: Add a return type for pci_reset_bridge_secondary_bus()") added a return value to the function to return if a device is accessible following a reset. Callers are not checking the value. Pass error code up high in the stack if device is not accessible. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp_hpc.c | 5 +++-- drivers/pci/pci.c| 12 ++-- drivers/pci/pcie/aer.c | 5 +++-- drivers/pci/pcie/err.c | 6 -- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 718b607..bbaa211 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -728,6 +728,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) struct controller *ctrl = slot->ctrl; struct pci_dev *pdev = ctrl_dev(ctrl); u16 stat_mask = 0, ctrl_mask = 0; + int rc; if (probe) return 0; @@ -745,7 +746,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) if (pciehp_poll_mode) del_timer_sync(>poll_timer); - pci_reset_bridge_secondary_bus(ctrl->pcie->port); + rc = pci_reset_bridge_secondary_bus(ctrl->pcie->port); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask); @@ -753,7 +754,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask); if (pciehp_poll_mode) int_poll_timeout(>poll_timer); - return 0; + return rc; } int pcie_init_notification(struct controller *ctrl) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 97acba7..98d1490 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4253,9 +4253,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe) if (probe) return 0; - pci_reset_bridge_secondary_bus(dev->bus->self); - - return 0; + return pci_reset_bridge_secondary_bus(dev->bus->self); } static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe) @@ -4850,6 +4848,8 @@ EXPORT_SYMBOL_GPL(pci_try_reset_slot); static int pci_bus_reset(struct pci_bus *bus, int probe) { + int ret; + if (!bus->self || !pci_bus_resetable(bus)) return -ENOTTY; @@ -4860,11 +4860,11 @@ static int pci_bus_reset(struct pci_bus *bus, int probe) might_sleep(); - pci_reset_bridge_secondary_bus(bus->self); + ret = pci_reset_bridge_secondary_bus(bus->self); pci_bus_unlock(bus); - return 0; + return ret; } /** @@ -4924,7 +4924,7 @@ int pci_try_reset_bus(struct pci_bus *bus) if (pci_bus_trylock(bus)) { might_sleep(); - pci_reset_bridge_secondary_bus(bus->self); + rc = pci_reset_bridge_secondary_bus(bus->self); pci_bus_unlock(bus); } else rc = -EAGAIN; diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index a2e8838..f1d0f3e 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1305,6 +1305,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) { u32 reg32; int pos; + int rc; pos = dev->aer_cap; @@ -1313,7 +1314,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - pci_reset_bridge_secondary_bus(dev); + rc = pci_reset_bridge_secondary_bus(dev); pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); /* Clear Root Error Status */ @@ -1325,7 +1326,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - return PCI_ERS_RESULT_RECOVERED; + return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } /** diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index f7ce0cb..3a62a2e 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -175,9 +175,11 @@ static int report_resume(struct pci_dev *dev, void *data) */ static pci_ers_result_t default_reset_link(struct pci_dev *dev) { - pci_reset_bridge_secondary_bus(dev); + int rc; + + rc = pci_reset_bridge_secondary_bus(dev); pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); - return PCI_ERS_RESULT_RECOVERED; + return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service) -- 2.7.4
[PATCH V2 2/5] IB/hfi1: use pci_reset_bus() for initiating pci secondary bus reset
Getting ready to hide pci_reset_bridge_secondary_bus() from the drivers. pci_reset_bridge_secondary_bus() should only be used internally by the PCI code itself. Other drivers should rely on higher level pci_reset_xxx() API. Signed-off-by: Sinan Kaya --- drivers/infiniband/hw/hfi1/pcie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 4d4371b..a6d695a 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -905,9 +905,7 @@ static int trigger_sbr(struct hfi1_devdata *dd) * delay after a reset is required. Per spec requirements, * the link is either working or not after that point. */ - pci_reset_bridge_secondary_bus(dev->bus->self); - - return 0; + return pci_reset_bus(dev->bus); } /* -- 2.7.4
[PATCH V2 1/5] PCI: handle error return from pci_reset_bridge_secondary_bus()
commit 01fd61c0b9bd ("PCI: Add a return type for pci_reset_bridge_secondary_bus()") added a return value to the function to return if a device is accessible following a reset. Callers are not checking the value. Pass error code up high in the stack if device is not accessible. Signed-off-by: Sinan Kaya --- drivers/pci/hotplug/pciehp_hpc.c | 5 +++-- drivers/pci/pci.c| 12 ++-- drivers/pci/pcie/aer.c | 5 +++-- drivers/pci/pcie/err.c | 6 -- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 718b607..bbaa211 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -728,6 +728,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) struct controller *ctrl = slot->ctrl; struct pci_dev *pdev = ctrl_dev(ctrl); u16 stat_mask = 0, ctrl_mask = 0; + int rc; if (probe) return 0; @@ -745,7 +746,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) if (pciehp_poll_mode) del_timer_sync(>poll_timer); - pci_reset_bridge_secondary_bus(ctrl->pcie->port); + rc = pci_reset_bridge_secondary_bus(ctrl->pcie->port); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); pcie_write_cmd_nowait(ctrl, ctrl_mask, ctrl_mask); @@ -753,7 +754,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask); if (pciehp_poll_mode) int_poll_timeout(>poll_timer); - return 0; + return rc; } int pcie_init_notification(struct controller *ctrl) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 97acba7..98d1490 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4253,9 +4253,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe) if (probe) return 0; - pci_reset_bridge_secondary_bus(dev->bus->self); - - return 0; + return pci_reset_bridge_secondary_bus(dev->bus->self); } static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe) @@ -4850,6 +4848,8 @@ EXPORT_SYMBOL_GPL(pci_try_reset_slot); static int pci_bus_reset(struct pci_bus *bus, int probe) { + int ret; + if (!bus->self || !pci_bus_resetable(bus)) return -ENOTTY; @@ -4860,11 +4860,11 @@ static int pci_bus_reset(struct pci_bus *bus, int probe) might_sleep(); - pci_reset_bridge_secondary_bus(bus->self); + ret = pci_reset_bridge_secondary_bus(bus->self); pci_bus_unlock(bus); - return 0; + return ret; } /** @@ -4924,7 +4924,7 @@ int pci_try_reset_bus(struct pci_bus *bus) if (pci_bus_trylock(bus)) { might_sleep(); - pci_reset_bridge_secondary_bus(bus->self); + rc = pci_reset_bridge_secondary_bus(bus->self); pci_bus_unlock(bus); } else rc = -EAGAIN; diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index a2e8838..f1d0f3e 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1305,6 +1305,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) { u32 reg32; int pos; + int rc; pos = dev->aer_cap; @@ -1313,7 +1314,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - pci_reset_bridge_secondary_bus(dev); + rc = pci_reset_bridge_secondary_bus(dev); pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n"); /* Clear Root Error Status */ @@ -1325,7 +1326,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) reg32 |= ROOT_PORT_INTR_ON_MESG_MASK; pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32); - return PCI_ERS_RESULT_RECOVERED; + return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } /** diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index f7ce0cb..3a62a2e 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -175,9 +175,11 @@ static int report_resume(struct pci_dev *dev, void *data) */ static pci_ers_result_t default_reset_link(struct pci_dev *dev) { - pci_reset_bridge_secondary_bus(dev); + int rc; + + rc = pci_reset_bridge_secondary_bus(dev); pci_printk(KERN_DEBUG, dev, "downstream link has been reset\n"); - return PCI_ERS_RESULT_RECOVERED; + return !rc ? PCI_ERS_RESULT_RECOVERED : PCI_ERS_RESULT_DISCONNECT; } static pci_ers_result_t reset_link(struct pci_dev *dev, u32 service) -- 2.7.4
[PATCH V2 2/5] IB/hfi1: use pci_reset_bus() for initiating pci secondary bus reset
Getting ready to hide pci_reset_bridge_secondary_bus() from the drivers. pci_reset_bridge_secondary_bus() should only be used internally by the PCI code itself. Other drivers should rely on higher level pci_reset_xxx() API. Signed-off-by: Sinan Kaya --- drivers/infiniband/hw/hfi1/pcie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 4d4371b..a6d695a 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -905,9 +905,7 @@ static int trigger_sbr(struct hfi1_devdata *dd) * delay after a reset is required. Per spec requirements, * the link is either working or not after that point. */ - pci_reset_bridge_secondary_bus(dev->bus->self); - - return 0; + return pci_reset_bus(dev->bus); } /* -- 2.7.4
Re: [PATCH v10 3/7] i2c: fsi: Add port structures
On 20 June 2018 at 13:04, Benjamin Herrenschmidt wrote: > On Wed, 2018-06-13 at 14:36 -0500, Eddie James wrote: >> } >> >> +static int fsi_i2c_remove(struct device *dev) >> +{ >> + struct fsi_i2c_master *i2c = dev_get_drvdata(dev); >> + struct fsi_i2c_port *port; >> + >> + list_for_each_entry(port, >ports, list) { >> + i2c_del_adapter(>adapter); >> + kfree(port); >> + } >> + >> + return 0; >> +} >> + > > This is a use-after-free, the list linkage of the freed port is used to > get to the next one. With memory poisoning, kbooom ! > > You can fold that in: > > From f9d9092160897e7308f6990067a03e937339537f Mon Sep 17 00:00:00 2001 > From: Benjamin Herrenschmidt > Date: Wed, 20 Jun 2018 13:27:32 +1000 > Subject: [PATCH] i2c: fsi: Fix use after free This fixes the issue I was seeing. For the series: Tested-by: Joel Stanley Thanks, Joel > > Signed-off-by: Benjamin Herrenschmidt > --- > drivers/i2c/busses/i2c-fsi.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c > index 713959b44403..ff69ab6aa79a 100644 > --- a/drivers/i2c/busses/i2c-fsi.c > +++ b/drivers/i2c/busses/i2c-fsi.c > @@ -696,9 +696,10 @@ static int fsi_i2c_probe(struct device *dev) > static int fsi_i2c_remove(struct device *dev) > { > struct fsi_i2c_master *i2c = dev_get_drvdata(dev); > - struct fsi_i2c_port *port; > + struct fsi_i2c_port *port, *tmp; > > - list_for_each_entry(port, >ports, list) { > + list_for_each_entry_safe(port,tmp, >ports, list) { > + list_del(>list); > i2c_del_adapter(>adapter); > kfree(port); > } >
Re: [PATCH v10 3/7] i2c: fsi: Add port structures
On 20 June 2018 at 13:04, Benjamin Herrenschmidt wrote: > On Wed, 2018-06-13 at 14:36 -0500, Eddie James wrote: >> } >> >> +static int fsi_i2c_remove(struct device *dev) >> +{ >> + struct fsi_i2c_master *i2c = dev_get_drvdata(dev); >> + struct fsi_i2c_port *port; >> + >> + list_for_each_entry(port, >ports, list) { >> + i2c_del_adapter(>adapter); >> + kfree(port); >> + } >> + >> + return 0; >> +} >> + > > This is a use-after-free, the list linkage of the freed port is used to > get to the next one. With memory poisoning, kbooom ! > > You can fold that in: > > From f9d9092160897e7308f6990067a03e937339537f Mon Sep 17 00:00:00 2001 > From: Benjamin Herrenschmidt > Date: Wed, 20 Jun 2018 13:27:32 +1000 > Subject: [PATCH] i2c: fsi: Fix use after free This fixes the issue I was seeing. For the series: Tested-by: Joel Stanley Thanks, Joel > > Signed-off-by: Benjamin Herrenschmidt > --- > drivers/i2c/busses/i2c-fsi.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c > index 713959b44403..ff69ab6aa79a 100644 > --- a/drivers/i2c/busses/i2c-fsi.c > +++ b/drivers/i2c/busses/i2c-fsi.c > @@ -696,9 +696,10 @@ static int fsi_i2c_probe(struct device *dev) > static int fsi_i2c_remove(struct device *dev) > { > struct fsi_i2c_master *i2c = dev_get_drvdata(dev); > - struct fsi_i2c_port *port; > + struct fsi_i2c_port *port, *tmp; > > - list_for_each_entry(port, >ports, list) { > + list_for_each_entry_safe(port,tmp, >ports, list) { > + list_del(>list); > i2c_del_adapter(>adapter); > kfree(port); > } >