4.4.180-stable review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 247/266 cpu/speculation: Add mitigations= cmdline option
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit 98af8452945c55652de68536afdde3b520fec429 upstream.
Keeping track of the number of mitigations for all the CPU speculation bugs has become overwhelming for many users. It's getting more and more complicated to decide which mitigations are needed for a given architecture. Complicating matters is the fact that each arch tends to have its own custom way to mitigate the same vulnerability.
Most users fall into a few basic categories:
a) they want all mitigations off;
b) they want all reasonable mitigations on, with SMT enabled even if it's vulnerable; or
c) they want all reasonable mitigations on, with SMT disabled if vulnerable.
Define a set of curated, arch-independent options, each of which is an aggregation of existing options:
- mitigations=off: Disable all mitigations.
- mitigations=auto: [default] Enable all the default mitigations, but leave SMT enabled, even if it's vulnerable.
- mitigations=auto,nosmt: Enable all the default mitigations, disabling SMT if needed by a mitigation.
Currently, these options are placeholders which don't actually do anything. They will be fleshed out in upcoming patches.
[bwh: Backported to 4.4:
- Drop the auto,nosmt option which we can't support
- Adjust filename]
--- Documentation/kernel-parameters.txt | 19 +++++++++++++++++++ include/linux/cpu.h | 17 +++++++++++++++++ kernel/cpu.c | 13 +++++++++++++ 3 files changed, 49 insertions(+)
Documentation/kernel-parameters.txt +19 -0
@@ -2173,6 +2173,25 @@ bytes respectively. Such letter suffixes in the "bleeding edge" mini2440 support kernel at http://repo.or.cz/w/linux-2.6/mini2440.git + mitigations= + Control optional mitigations for CPU vulnerabilities. + This is a set of curated, arch-independent options, each + of which is an aggregation of existing arch-specific + options. + + off + Disable all optional CPU mitigations. This + improves system performance, but it may also + expose users to several CPU vulnerabilities. + + auto (default) + Mitigate all CPU vulnerabilities, but leave SMT + enabled, even if it's vulnerable. This is for + users who don't want to be surprised by SMT + getting disabled across kernel upgrades, or who + have other ways of avoiding SMT-based attacks. + This is the default behavior. + mminit_loglevel= [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this parameter allows control of the logging verbosity for
include/linux/cpu.h +17 -0
@@ -296,4 +296,21 @@ bool cpu_wait_death(unsigned int cpu, inbool cpu_report_death (void );#endif /* #ifdef CONFIG_HOTPLUG_CPU */ +/* +* These are used for a global "mitigations=" cmdline option for toggling +* optional CPU mitigations. +*/ +enum cpu_mitigations { +CPU_MITIGATIONS_OFF , +CPU_MITIGATIONS_AUTO , +}; + +extern enum cpu_mitigations cpu_mitigations; + +/* mitigations=off */ +static inline bool cpu_mitigations_off (void ) +{ +return cpu_mitigations ==CPU_MITIGATIONS_OFF ; +} +#endif /* _LINUX_CPU_H_ */
kernel/cpu.c +13 -0
@@ -842,3 +842,16 @@ void init_cpu_online(const struct cpumas {cpumask_copy (to_cpumask (cpu_online_bits), src); } + +enum cpu_mitigations cpu_mitigations =CPU_MITIGATIONS_AUTO ; + +static int __init mitigations_parse_cmdline (char *arg) +{ +if (!strcmp (arg,"off" )) + cpu_mitigations =CPU_MITIGATIONS_OFF ; +else if (!strcmp (arg,"auto" )) + cpu_mitigations =CPU_MITIGATIONS_AUTO ; + +return 0 ; +} +early_param ("mitigations" , mitigations_parse_cmdline);
Greg Kroah-Hartman
maintainerPATCH 248/266 x86/speculation: Support mitigations= cmdline option
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
commit d68be4c4d31295ff6ae34a8ddfaa4c1a8ff42812 upstream.
Configure x86 runtime CPU speculation bug mitigations in accordance with the 'mitigations=' cmdline option. This affects Meltdown, Spectre v2, Speculative Store Bypass, and L1TF.
The default behavior is unchanged.
[bwh: Backported to 4.4:
- Drop the auto,nosmt option and the l1tf mitigation selection, which we can't support
- Adjust filenames, context]
--- Documentation/kernel-parameters.txt | 14 +++++++++----- arch/x86/kernel/cpu/bugs.c | 6 ++++-- arch/x86/mm/kaiser.c | 4 +++- 3 files changed, 16 insertions(+), 8 deletions(-)
Documentation/kernel-parameters.txt +9 -5
@@ -2174,15 +2174,19 @@ bytes respectively. Such letter suffixes http://repo.or.cz/w/linux-2.6/mini2440.git mitigations= - Control optional mitigations for CPU vulnerabilities. - This is a set of curated, arch-independent options, each - of which is an aggregation of existing arch-specific - options. + [X86] Control optional mitigations for CPU + vulnerabilities. This is a set of curated, + arch-independent options, each of which is an + aggregation of existing arch-specific options. off Disable all optional CPU mitigations. This improves system performance, but it may also expose users to several CPU vulnerabilities. + Equivalent to: nopti [X86] + nospectre_v2 [X86] + spectre_v2_user=off [X86] + spec_store_bypass_disable=off [X86] auto (default) Mitigate all CPU vulnerabilities, but leave SMT
@@ -2190,7 +2194,7 @@ bytes respectively. Such letter suffixes users who don't want to be surprised by SMT getting disabled across kernel upgrades, or who have other ways of avoiding SMT-based attacks. - This is the default behavior. + Equivalent to: (default behavior) mminit_loglevel= [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
arch/x86/kernel/cpu/bugs.c +4 -2
@@ -479,7 +479,8 @@ static enum spectre_v2_mitigation_cmd __char arg[20 ];int ret, i; -if (cmdline_find_option_bool (boot_command_line,"nospectre_v2" )) +if (cmdline_find_option_bool (boot_command_line,"nospectre_v2" ) || +cpu_mitigations_off ())return SPECTRE_V2_CMD_NONE ; ret =cmdline_find_option (boot_command_line,"spectre_v2" , arg,sizeof (arg));
@@ -743,7 +744,8 @@ static enum ssb_mitigation_cmd __init sschar arg[20 ];int ret, i; -if (cmdline_find_option_bool (boot_command_line,"nospec_store_bypass_disable" )) { +if (cmdline_find_option_bool (boot_command_line,"nospec_store_bypass_disable" ) || +cpu_mitigations_off ()) {return SPEC_STORE_BYPASS_CMD_NONE ; }else { ret = cmdline_find_option(boot_command_line, "spec_store_bypass_disable",
arch/x86/mm/kaiser.c +3 -1
@@ -10,6 +10,7 @@#include <linux/mm.h> #include <linux/uaccess.h> #include <linux/ftrace.h> +#include <linux/cpu.h> #undef pr_fmt#define pr_fmt (fmt) "Kernel/User page tables isolation: " fmt
@@ -297,7 +298,8 @@ void __init kaiser_check_boottime_disabl goto skip; } -if (cmdline_find_option_bool (boot_command_line,"nopti" )) +if (cmdline_find_option_bool (boot_command_line,"nopti" ) || +cpu_mitigations_off ()) goto disable; skip:
Greg Kroah-Hartman
maintainerPATCH 1/266 kbuild: simplify ld-option implementation
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 0294e6f4a0006856e1f36b8cd8fa088d9e499e98 upstream.
Currently, linker options are tested by the coordination of $(CC) and $(LD) because $(LD) needs some object to link.
As commit 86a9df597cdd ("kbuild: fix linker feature test macros when cross compiling with Clang") addressed, we need to make sure $(CC) and $(LD) agree the underlying architecture of the passed object.
This could be a bit complex when we combine tools from different groups. For example, we can use clang for $(CC), but we still need to rely on GCC toolchain for $(LD).
So, I was searching for a way of standalone testing of linker options. A trick I found is to use '-v'; this not only prints the version string, but also tests if the given option is recognized.
If a given option is supported,
$ aarch64-linux-gnu-ld -v --fix-cortex-a53-843419 GNU ld (Linaro_Binutils-2017.11) 2.28.2.20170706 $ echo $? 0
If unsupported,
$ aarch64-linux-gnu-ld -v --fix-cortex-a53-843419 GNU ld (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1 aarch64-linux-gnu-ld: unrecognized option '--fix-cortex-a53-843419' aarch64-linux-gnu-ld: use the --help option for usage information $ echo $? 1
Gold works likewise.
$ aarch64-linux-gnu-ld.gold -v --fix-cortex-a53-843419 GNU gold (Linaro_Binutils-2017.11 2.28.2.20170706) 1.14 masahiro@pug:~/ref/linux$ echo $? 0 $ aarch64-linux-gnu-ld.gold -v --fix-cortex-a53-999999 GNU gold (Linaro_Binutils-2017.11 2.28.2.20170706) 1.14 aarch64-linux-gnu-ld.gold: --fix-cortex-a53-999999: unknown option aarch64-linux-gnu-ld.gold: use the --help option for usage information $ echo $? 1
LLD too.
$ ld.lld -v --gc-sections LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 0 $ ld.lld -v --fix-cortex-a53-843419 LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 0 $ ld.lld -v --fix-cortex-a53-999999 ld.lld: error: unknown argument: --fix-cortex-a53-999999 LLD 7.0.0 (http://llvm.org/git/lld.git 4a0e4190e74cea19f8a8dc625ccaebdf8b5d1585) (compatible with GNU linkers) $ echo $? 1
[nc: try-run-cached was added later, just use try-run, which is the
current mainline state]
--- scripts/Kbuild.include | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
scripts/Kbuild.include +1 -3
@@ -156,9 +156,7 @@ cc-ldoption = $(call try-run,\ # ld-option # Usage: LDFLAGS += $(call ld-option, -X) -ld-option = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ - $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) +ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
Greg Kroah-Hartman
maintainerPATCH 10/266 sunrpc: dont mark uninitialised items as VALID.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit d58431eacb226222430940134d97bfd72f292fcd upstream.
A recent commit added a call to cache_fresh_locked() when an expired item was found.
The call sets the CACHE_VALID flag, so it is important that the item actually is valid.
There are two ways it could be valid:
1/ If ->update has been called to fill in relevant content 2/ if CACHE_NEGATIVE is set, to say that content doesn't exist.
An expired item that is waiting for an update will be neither. Setting CACHE_VALID will mean that a subsequent call to cache_put() will be likely to dereference uninitialised pointers.
So we must make sure the item is valid, and we already have code to do that in try_to_negate_entry(). This takes the hash lock and so cannot be used directly, so take out the two lines that we need and use them.
Now cache_fresh_locked() is certain to be called only on a valid item.
--- net/sunrpc/cache.c | 3 +++ 1 file changed, 3 insertions(+)
net/sunrpc/cache.c +3 -0
@@ -54,6 +54,7 @@ static void cache_init(struct cache_head h->last_refresh = now; } +static inline int cache_is_valid (struct cache_head *h);static void cache_fresh_locked (struct cache_head *head,time_t expiry,struct cache_detail *detail); static void cache_fresh_unlocked(struct cache_head *head,
@@ -100,6 +101,8 @@ struct cache_head *sunrpc_cache_lookup(sif (cache_is_expired (detail, tmp)) {hlist_del_init (&tmp->cache_list); detail->entries --; +if (cache_is_valid (tmp) == -EAGAIN ) +set_bit (CACHE_NEGATIVE , &tmp->flags);cache_fresh_locked (tmp,0 , detail); freeme = tmp;break ;
Greg Kroah-Hartman
maintainerPATCH 11/266 USB: Add new USB LPM helpers
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 7529b2574a7aaf902f1f8159fbc2a7caa74be559 upstream.
Use new helpers to make LPM enabling/disabling more clear.
This is a preparation to subsequent patch.
--- drivers/usb/core/driver.c | 12 +++++++++++- drivers/usb/core/hub.c | 12 ++++++------ drivers/usb/core/message.c | 2 +- drivers/usb/core/sysfs.c | 5 ++++- drivers/usb/core/usb.h | 10 ++++++++-- 5 files changed, 30 insertions(+), 11 deletions(-)
drivers/usb/core/driver.c +11 -1
@@ -1888,7 +1888,7 @@ int usb_runtime_idle(struct device *dev)return -EBUSY ; } -int usb_set_usb2_hardware_lpm (struct usb_device *udev,int enable) +static int usb_set_usb2_hardware_lpm (struct usb_device *udev,int enable) {struct usb_hcd *hcd =bus_to_hcd (udev->bus);int ret = -EPERM ;
@@ -1905,6 +1905,16 @@ int usb_set_usb2_hardware_lpm(struct usbreturn ret; } +int usb_enable_usb2_hardware_lpm (struct usb_device *udev) +{ +return usb_set_usb2_hardware_lpm (udev,1 ); +} + +int usb_disable_usb2_hardware_lpm (struct usb_device *udev) +{ +return usb_set_usb2_hardware_lpm (udev,0 ); +} +#endif /* CONFIG_PM */ struct bus_type usb_bus_type = {
drivers/usb/core/hub.c +6 -6
@@ -3117,7 +3117,7 @@ int usb_port_suspend(struct usb_device */* disable USB2 hardware LPM */ if (udev->usb2_hw_lpm_enabled ==1 ) -usb_set_usb2_hardware_lpm (udev,0 ); +usb_disable_usb2_hardware_lpm (udev);if (usb_disable_ltm (udev)) {dev_err (&udev->dev,"Failed to disable LTM before suspend\n." );
@@ -3164,7 +3164,7 @@ int usb_port_suspend(struct usb_device * err_ltm:/* Try to enable USB2 hardware LPM again */ if (udev->usb2_hw_lpm_capable ==1 ) -usb_set_usb2_hardware_lpm (udev,1 ); +usb_enable_usb2_hardware_lpm (udev);if (udev->do_remote_wakeup) (void )usb_disable_remote_wakeup (udev);
@@ -3444,7 +3444,7 @@ int usb_port_resume(struct usb_device *u }else {/* Try to enable USB2 hardware LPM */ if (udev->usb2_hw_lpm_capable ==1 ) -usb_set_usb2_hardware_lpm (udev,1 ); +usb_enable_usb2_hardware_lpm (udev);/* Try to enable USB3 LTM and LPM */ usb_enable_ltm (udev);
@@ -4270,7 +4270,7 @@ static void hub_set_initial_usb2_lpm_polif ((udev->bos->ext_cap->bmAttributes &cpu_to_le32 (USB_BESL_SUPPORT )) || connect_type ==USB_PORT_CONNECT_TYPE_HARD_WIRED ) { udev->usb2_hw_lpm_allowed =1 ; -usb_set_usb2_hardware_lpm (udev,1 ); +usb_enable_usb2_hardware_lpm (udev); } }
@@ -5416,7 +5416,7 @@ static int usb_reset_and_verify_device(s* It will be re-enabled by the enumeration process. */ if (udev->usb2_hw_lpm_enabled ==1 ) -usb_set_usb2_hardware_lpm (udev,0 ); +usb_disable_usb2_hardware_lpm (udev);/* Disable LPM and LTM while we reset the device and reinstall the alt * settings. Device-initiated LPM settings, and system exit latency
@@ -5526,7 +5526,7 @@ static int usb_reset_and_verify_device(s done:/* Now that the alt settings are re-installed, enable LTM and LPM. */ -usb_set_usb2_hardware_lpm (udev,1 ); +usb_enable_usb2_hardware_lpm (udev);usb_unlocked_enable_lpm (udev);usb_enable_ltm (udev);usb_release_bos_descriptor (udev);
drivers/usb/core/message.c +1 -1
@@ -1185,7 +1185,7 @@ void usb_disable_device(struct usb_devic }if (dev->usb2_hw_lpm_enabled ==1 ) -usb_set_usb2_hardware_lpm (dev,0 ); +usb_disable_usb2_hardware_lpm (dev);usb_unlocked_disable_lpm (dev);usb_disable_ltm (dev);
drivers/usb/core/sysfs.c +4 -1
@@ -472,7 +472,10 @@ static ssize_t usb2_hardware_lpm_store(sif (!ret) { udev->usb2_hw_lpm_allowed = value; - ret =usb_set_usb2_hardware_lpm (udev, value); +if (value) + ret =usb_enable_usb2_hardware_lpm (udev); +else + ret =usb_disable_usb2_hardware_lpm (udev); }usb_unlock_device (udev);
drivers/usb/core/usb.h +8 -2
@@ -84,7 +84,8 @@ extern int usb_remote_wakeup(struct usb_extern int usb_runtime_suspend (struct device *dev);extern int usb_runtime_resume (struct device *dev);extern int usb_runtime_idle (struct device *dev); -extern int usb_set_usb2_hardware_lpm (struct usb_device *udev,int enable); +extern int usb_enable_usb2_hardware_lpm (struct usb_device *udev); +extern int usb_disable_usb2_hardware_lpm (struct usb_device *udev);#else
@@ -104,7 +105,12 @@ static inline int usb_autoresume_device(return 0 ; } -static inline int usb_set_usb2_hardware_lpm (struct usb_device *udev,int enable) +static inline int usb_enable_usb2_hardware_lpm (struct usb_device *udev) +{ +return 0 ; +} + +static inline int usb_disable_usb2_hardware_lpm (struct usb_device *udev) {return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 12/266 USB: Consolidate LPM checks to avoid enabling LPM twice
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit d7a6c0ce8d26412903c7981503bad9e1cc7c45d2 upstream.
USB Bluetooth controller QCA ROME (0cf3:e007) sometimes stops working after S3:
[ 165.110742] Bluetooth: hci0: using NVM file: qca/nvm_usb_00000302.bin [ 168.432065] Bluetooth: hci0: Failed to send body at 4 of 1953 (-110)
After some experiments, I found that disabling LPM can workaround the issue.
On some platforms, the USB power is cut during S3, so the driver uses reset-resume to resume the device. During port resume, LPM gets enabled twice, by usb_reset_and_verify_device() and usb_port_resume().
Consolidate all checks into new LPM helpers to make sure LPM only gets enabled once.
--- drivers/usb/core/driver.c | 11 ++++++++--- drivers/usb/core/hub.c | 12 ++++-------- drivers/usb/core/message.c | 3 +-- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/usb/core/driver.c +8 -3
@@ -1893,9 +1893,6 @@ static int usb_set_usb2_hardware_lpm(strstruct usb_hcd *hcd =bus_to_hcd (udev->bus);int ret = -EPERM ; -if (enable && !udev->usb2_hw_lpm_allowed) -return 0 ; -if (hcd->driver->set_usb2_hw_lpm) { ret = hcd->driver->set_usb2_hw_lpm (hcd, udev, enable);if (!ret)
@@ -1907,11 +1904,19 @@ static int usb_set_usb2_hardware_lpm(strint usb_enable_usb2_hardware_lpm (struct usb_device *udev) { +if (!udev->usb2_hw_lpm_capable || + !udev->usb2_hw_lpm_allowed || + udev->usb2_hw_lpm_enabled) +return 0 ; +return usb_set_usb2_hardware_lpm (udev,1 ); }int usb_disable_usb2_hardware_lpm (struct usb_device *udev) { +if (!udev->usb2_hw_lpm_enabled) +return 0 ; +return usb_set_usb2_hardware_lpm (udev,0 ); }
drivers/usb/core/hub.c +4 -8
@@ -3116,8 +3116,7 @@ int usb_port_suspend(struct usb_device * }/* disable USB2 hardware LPM */ -if (udev->usb2_hw_lpm_enabled ==1 ) -usb_disable_usb2_hardware_lpm (udev); +usb_disable_usb2_hardware_lpm (udev);if (usb_disable_ltm (udev)) {dev_err (&udev->dev,"Failed to disable LTM before suspend\n." );
@@ -3163,8 +3162,7 @@ int usb_port_suspend(struct usb_device *usb_enable_ltm (udev); err_ltm:/* Try to enable USB2 hardware LPM again */ -if (udev->usb2_hw_lpm_capable ==1 ) -usb_enable_usb2_hardware_lpm (udev); +usb_enable_usb2_hardware_lpm (udev);if (udev->do_remote_wakeup) (void )usb_disable_remote_wakeup (udev);
@@ -3443,8 +3441,7 @@ int usb_port_resume(struct usb_device *uhub_port_logical_disconnect (hub, port1); }else {/* Try to enable USB2 hardware LPM */ -if (udev->usb2_hw_lpm_capable ==1 ) -usb_enable_usb2_hardware_lpm (udev); +usb_enable_usb2_hardware_lpm (udev);/* Try to enable USB3 LTM and LPM */ usb_enable_ltm (udev);
@@ -5415,8 +5412,7 @@ static int usb_reset_and_verify_device(s/* Disable USB2 hardware LPM. * It will be re-enabled by the enumeration process. */ -if (udev->usb2_hw_lpm_enabled ==1 ) -usb_disable_usb2_hardware_lpm (udev); +usb_disable_usb2_hardware_lpm (udev);/* Disable LPM and LTM while we reset the device and reinstall the alt * settings. Device-initiated LPM settings, and system exit latency
drivers/usb/core/message.c +1 -2
@@ -1184,8 +1184,7 @@ void usb_disable_device(struct usb_devic dev->actconfig->interface[i] =NULL ; } -if (dev->usb2_hw_lpm_enabled ==1 ) -usb_disable_usb2_hardware_lpm (dev); +usb_disable_usb2_hardware_lpm (dev);usb_unlocked_disable_lpm (dev);usb_disable_ltm (dev);
Greg Kroah-Hartman
maintainerPATCH 13/266 powerpc/xmon: Add RFI flush related fields to paca dump
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 274920a3ecd5f43af0cc380bc0a9ee73a52b9f8a upstream.
--- arch/powerpc/xmon/xmon.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/xmon/xmon.c +4 -0
@@ -2144,6 +2144,10 @@ static void dump_one_paca(int cpu)DUMP (p, slb_cache_ptr,"x" );for (i =0 ; i <SLB_CACHE_ENTRIES ; i++)printf (" slb_cache[%d]: = 0x%016lx\n" , i, p->slb_cache[i]); + +DUMP (p, rfi_flush_fallback_area,"px" ); +DUMP (p, l1d_flush_congruence,"llx" ); +DUMP (p, l1d_flush_sets,"llx" );#endif DUMP (p, dscr_default,"llx" );#ifdef CONFIG_PPC_BOOK3E
Greg Kroah-Hartman
maintainerPATCH 15/266 powerpc/pseries: Support firmware disable of RFI flush
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 582605a429e20ae68fd0b041b2e840af296edd08 upstream.
Some versions of firmware will have a setting that can be configured to disable the RFI flush, add support for it.
--- arch/powerpc/platforms/pseries/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/setup.c +2 -1
@@ -522,7 +522,8 @@ static void pseries_setup_rfi_flush(voidif (types ==L1D_FLUSH_NONE ) types =L1D_FLUSH_FALLBACK ; -if (!(result.behaviour &H_CPU_BEHAV_L1D_FLUSH_PR )) +if ((!(result.behaviour &H_CPU_BEHAV_L1D_FLUSH_PR )) || + (!(result.behaviour &H_CPU_BEHAV_FAVOUR_SECURITY ))) enable = false; }else {/* Default to fallback if case hcall is not available */
Greg Kroah-Hartman
maintainerPATCH 16/266 powerpc/powernv: Support firmware disable of RFI flush
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit eb0a2d2620ae431c543963c8c7f08f597366fc60 upstream.
Some versions of firmware will have a setting that can be configured to disable the RFI flush, add support for it.
--- arch/powerpc/platforms/powernv/setup.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/setup.c +4 -0
@@ -79,6 +79,10 @@ static void pnv_setup_rfi_flush(void)if (np &&of_property_read_bool (np,"disabled" )) enable--; + np =of_get_child_by_name (fw_features,"speculation-policy-favor-security" ); +if (np &&of_property_read_bool (np,"disabled" )) + enable =0 ; +of_node_put (np);of_node_put (fw_features); }
Greg Kroah-Hartman
maintainerPATCH 18/266 powerpc/rfi-flush: Make it possible to call setup_rfi_flush() again
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit abf110f3e1cea40f5ea15e85f5d67c39c14568a7 upstream.
For PowerVM migration we want to be able to call setup_rfi_flush() again after we've migrated the partition.
To support that we need to check that we're not trying to allocate the fallback flush area after memblock has gone away (i.e., boot-time only).
--- arch/powerpc/include/asm/setup.h | 2 +- arch/powerpc/kernel/setup_64.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/setup.h +1 -1
@@ -36,7 +36,7 @@ enum l1d_flush_type { L1D_FLUSH_MTTRIG = 0x8, }; -void __init setup_rfi_flush (enum l1d_flush_type ,bool enable); +void setup_rfi_flush (enum l1d_flush_type ,bool enable);void do_rfi_flush_fixups (enum l1d_flush_type types);#endif /* !__ASSEMBLY__ */
arch/powerpc/kernel/setup_64.c +5 -1
@@ -887,6 +887,10 @@ static void init_fallback_flush(void)u64 l1d_size, limit;int cpu; +/* Only allocate the fallback flush area once (at boot time). */ +if (l1d_flush_fallback_area) +return ; + l1d_size = ppc64_caches.dsize; limit =min (safe_stack_limit (), ppc64_rma_size);
@@ -904,7 +908,7 @@ static void init_fallback_flush(void) } } -void __init setup_rfi_flush (enum l1d_flush_type types,bool enable) +void setup_rfi_flush (enum l1d_flush_type types,bool enable) {if (types &L1D_FLUSH_FALLBACK ) {pr_info ("rfi-flush: Using fallback displacement flush\n" );
Greg Kroah-Hartman
maintainerPATCH 19/266 powerpc/rfi-flush: Always enable fallback flush on pseries
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 84749a58b6e382f109abf1e734bc4dd43c2c25bb upstream.
This ensures the fallback flush area is always allocated on pseries, so in case a LPAR is migrated from a patched to an unpatched system, it is possible to enable the fallback flush in the target system.
--- arch/powerpc/platforms/pseries/setup.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
arch/powerpc/platforms/pseries/setup.c +1 -9
@@ -508,26 +508,18 @@ static void pseries_setup_rfi_flush(void/* Enable by default */ enable = true; + types =L1D_FLUSH_FALLBACK ; rc =plpar_get_cpu_characteristics (&result);if (rc ==H_SUCCESS ) { - types =L1D_FLUSH_NONE ; -if (result.character &H_CPU_CHAR_L1D_FLUSH_TRIG2 ) types |=L1D_FLUSH_MTTRIG ;if (result.character &H_CPU_CHAR_L1D_FLUSH_ORI30 ) types |=L1D_FLUSH_ORI ; -/* Use fallback if nothing set in hcall */ -if (types ==L1D_FLUSH_NONE ) - types =L1D_FLUSH_FALLBACK ; -if ((!(result.behaviour &H_CPU_BEHAV_L1D_FLUSH_PR )) || (!(result.behaviour &H_CPU_BEHAV_FAVOUR_SECURITY ))) enable = false; - }else { -/* Default to fallback if case hcall is not available */ - types =L1D_FLUSH_FALLBACK ; }setup_rfi_flush (types, enable);
Greg Kroah-Hartman
maintainerPATCH 20/266 powerpc/rfi-flush: Differentiate enabled and patched flush types
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 0063d61ccfc011f379a31acaeba6de7c926fed2c upstream.
Currently the rfi-flush messages print 'Using <type> flush' for all enabled_flush_types, but that is not necessarily true -- as now the fallback flush is always enabled on pseries, but the fixup function overwrites its nop/branch slot with other flush types, if available.
So, replace the 'Using <type> flush' messages with '<type> flush is available'.
Also, print the patched flush types in the fixup function, so users can know what is (not) being used (e.g., the slower, fallback flush, or no flush type at all if flush is disabled via the debugfs switch).
--- arch/powerpc/kernel/setup_64.c | 6 +++--- arch/powerpc/lib/feature-fixups.c | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-)
arch/powerpc/kernel/setup_64.c +3 -3
@@ -911,15 +911,15 @@ static void init_fallback_flush(void)void setup_rfi_flush (enum l1d_flush_type types,bool enable) {if (types &L1D_FLUSH_FALLBACK ) { -pr_info ("rfi-flush: Using fallback displacement flush\n" ); +pr_info ("rfi-flush: fallback displacement flush available\n" );init_fallback_flush (); }if (types &L1D_FLUSH_ORI ) -pr_info ("rfi-flush: Using ori type flush\n" ); +pr_info ("rfi-flush: ori type flush available\n" );if (types &L1D_FLUSH_MTTRIG ) -pr_info ("rfi-flush: Using mttrig type flush\n" ); +pr_info ("rfi-flush: mttrig type flush available\n" ); enabled_flush_types = types;
arch/powerpc/lib/feature-fixups.c +8 -1
@@ -151,7 +151,14 @@ void do_rfi_flush_fixups(enum l1d_flush_ patch_instruction(dest + 2, instrs[2]); } -printk (KERN_DEBUG "rfi-flush: patched %d locations\n" , i); +printk (KERN_DEBUG "rfi-flush: patched %d locations (%s flush)\n" , i, + (types ==L1D_FLUSH_NONE ) ?"no" : + (types ==L1D_FLUSH_FALLBACK ) ?"fallback displacement" : + (types &L1D_FLUSH_ORI ) ? (types &L1D_FLUSH_MTTRIG ) + ?"ori+mttrig type" + :"ori type" : + (types &L1D_FLUSH_MTTRIG ) ?"mttrig type" + :"unknown" ); }#endif /* CONFIG_PPC_BOOK3S_64 */
Greg Kroah-Hartman
maintainerPATCH 21/266 powerpc/pseries: Add new H_GET_CPU_CHARACTERISTICS flags
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit c4bc36628d7f8b664657d8bd6ad1c44c177880b7 upstream.
Add some additional values which have been defined for the H_GET_CPU_CHARACTERISTICS hypercall.
--- arch/powerpc/include/asm/hvcall.h | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/include/asm/hvcall.h +3 -0
@@ -292,6 +292,9 @@#define H_CPU_CHAR_L1D_FLUSH_ORI30 (1ull << 61) // IBM bit 2#define H_CPU_CHAR_L1D_FLUSH_TRIG2 (1ull << 60) // IBM bit 3#define H_CPU_CHAR_L1D_THREAD_PRIV (1ull << 59) // IBM bit 4 +#define H_CPU_CHAR_BRANCH_HINTS_HONORED (1ull << 58) // IBM bit 5 +#define H_CPU_CHAR_THREAD_RECONFIG_CTRL (1ull << 57) // IBM bit 6 +#define H_CPU_CHAR_COUNT_CACHE_DISABLED (1ull << 56) // IBM bit 7#define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0#define H_CPU_BEHAV_L1D_FLUSH_PR (1ull << 62) // IBM bit 1
Greg Kroah-Hartman
maintainerPATCH 3/266 cifs: do not attempt cifs operation on smb2+ rename error
In reply to Greg Kroah-HartmanFrom: Frank Sorenson <[email protected]>
commit 652727bbe1b17993636346716ae5867627793647 upstream.
A path-based rename returning EBUSY will incorrectly try opening the file with a cifs (NT Create AndX) operation on an smb2+ mount, which causes the server to force a session close.
If the mount is smb2+, skip the fallback.
--- fs/cifs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/cifs/inode.c +4 -0
@@ -1669,6 +1669,10 @@ cifs_do_rename(const unsigned int xid, sif (rc ==0 || rc != -EBUSY ) goto do_rename_exit; +/* Don't fall back to using SMB on SMB 2+ mount */ +if (server->vals->protocol_id !=0 ) + goto do_rename_exit; +/* open-file renames don't work across directories */ if (to_dentry->d_parent != from_dentry->d_parent) goto do_rename_exit;
Greg Kroah-Hartman
maintainerPATCH 4/266 MIPS: scall64-o32: Fix indirect syscall number load
In reply to Greg Kroah-HartmanFrom: Aurelien Jarno <[email protected]>
commit 79b4a9cf0e2ea8203ce777c8d5cfa86c71eae86e upstream.
Commit 4c21b8fd8f14 (MIPS: seccomp: Handle indirect system calls (o32)) added indirect syscall detection for O32 processes running on MIPS64, but it did not work correctly for big endian kernel/processes. The reason is that the syscall number is loaded from ARG1 using the lw instruction while this is a 64-bit value, so zero is loaded instead of the syscall number.
Fix the code by using the ld instruction instead. When running a 32-bit processes on a 64 bit CPU, the values are properly sign-extended, so it ensures the value passed to syscall_trace_enter is correct.
Recent systemd versions with seccomp enabled whitelist the getpid syscall for their internal processes (e.g. systemd-journald), but call it through syscall(SYS_getpid). This fix therefore allows O32 big endian systems with a 64-bit kernel to run recent systemd versions.
--- arch/mips/kernel/scall64-o32.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/scall64-o32.S +1 -1
@@ -126,7 +126,7 @@ trace_a_syscall: subu t1, v0, __NR_O32_Linux move a1, v0 bnez t1, 1f /* __NR_syscall at offset 0 */ - lw a1, PT_R4(sp) /* Arg1 for __NR_syscall case */ + ld a1, PT_R4(sp) /* Arg1 for __NR_syscall case */ .set pop 1: jal syscall_trace_enter
Greg Kroah-Hartman
maintainerPATCH 6/266 sched/numa: Fix a possible divide-by-zero
In reply to Greg Kroah-HartmanFrom: Xie XiuQi <[email protected]>
commit a860fa7b96e1a1c974556327aa1aee852d434c21 upstream.
sched_clock_cpu() may not be consistent between CPUs. If a task migrates to another CPU, then se.exec_start is set to that CPU's rq_clock_task() by update_stats_curr_start(). Specifically, the new value might be before the old value due to clock skew.
So then if in numa_get_avg_runtime() the expression:
'now - p->last_task_numa_placement'
ends up as -1, then the divider '*period + 1' in task_numa_placement() is 0 and things go bang. Similar to update_curr(), check if time goes backwards to avoid this.
[ peterz: Wrote new changelog. ]
[ mingo: Tweaked the code comment. ]
--- kernel/sched/fair.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/sched/fair.c +4 -0
@@ -1722,6 +1722,10 @@ static u64 numa_get_avg_runtime(struct tif (p->last_task_numa_placement) { delta = runtime - p->last_sum_exec_runtime; *period = now - p->last_task_numa_placement; + +/* Avoid time going backwards, prevent potential divide error: */ +if (unlikely ((s64)*period <0 )) + *period =0 ; }else { delta = p->se.avg.load_sum / p->se.load.weight; *period =LOAD_AVG_MAX ;
Greg Kroah-Hartman
maintainerPATCH 7/266 ceph: ensure d_name stability in ceph_dentry_hash()
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream.
Take the d_lock here to ensure that d_name doesn't change.
--- fs/ceph/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/dir.c +5 -1
@@ -1288,6 +1288,7 @@ void ceph_dentry_lru_del(struct dentry *unsigned ceph_dentry_hash (struct inode *dir,struct dentry *dn) {struct ceph_inode_info *dci =ceph_inode (dir); +unsigned hash;switch (dci->i_dir_layout.dl_dir_hash) {case 0 :/* for backward compat */
@@ -1295,8 +1296,11 @@ unsigned ceph_dentry_hash(struct inode *return dn->d_name.hash;default : -return ceph_str_hash (dci->i_dir_layout.dl_dir_hash, +spin_lock (&dn->d_lock); + hash =ceph_str_hash (dci->i_dir_layout.dl_dir_hash, dn->d_name.name, dn->d_name.len); +spin_unlock (&dn->d_lock); +return hash; } }
Greg Kroah-Hartman
maintainerPATCH 8/266 ceph: fix ci->i_head_snapc leak
In reply to Greg Kroah-HartmanFrom: Yan, Zheng <[email protected]>
commit 37659182bff1eeaaeadcfc8f853c6d2b6dbc3f47 upstream.
We missed two places that i_wrbuffer_ref_head, i_wr_ref, i_dirty_caps and i_flushing_caps may change. When they are all zeros, we should free i_head_snapc.
--- fs/ceph/mds_client.c | 9 +++++++++ fs/ceph/snap.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +9 -0
@@ -1198,6 +1198,15 @@ static int remove_session_caps_cb(structlist_add (&ci->i_prealloc_cap_flush->list, &to_remove); ci->i_prealloc_cap_flush =NULL ; } + +if (drop && + ci->i_wrbuffer_ref_head ==0 && + ci->i_wr_ref ==0 && + ci->i_dirty_caps ==0 && + ci->i_flushing_caps ==0 ) { +ceph_put_snap_context (ci->i_head_snapc); + ci->i_head_snapc =NULL ; + } }spin_unlock (&ci->i_ceph_lock);while (!list_empty (&to_remove)) {
fs/ceph/snap.c +6 -1
@@ -567,7 +567,12 @@ void ceph_queue_cap_snap(struct ceph_ino capsnap =NULL ; update_snapc: -if (ci->i_head_snapc) { +if (ci->i_wrbuffer_ref_head ==0 && + ci->i_wr_ref ==0 && + ci->i_dirty_caps ==0 && + ci->i_flushing_caps ==0 ) { + ci->i_head_snapc =NULL ; + }else { ci->i_head_snapc =ceph_get_snap_context (new_snapc);dout (" new snapc is %p\n" , new_snapc); }
Greg Kroah-Hartman
maintainerPATCH 9/266 nfsd: Dont release the callback slot unless it was actually held
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit e6abc8caa6deb14be2a206253f7e1c5e37e9515b upstream.
If there are multiple callbacks queued, waiting for the callback slot when the callback gets shut down, then they all currently end up acting as if they hold the slot, and call nfsd4_cb_sequence_done() resulting in interesting side-effects.
In addition, the 'retry_nowait' path in nfsd4_cb_sequence_done() causes a loop back to nfsd4_cb_prepare() without first freeing the slot, which causes a deadlock when nfsd41_cb_get_slot() gets called a second time.
This patch therefore adds a boolean to track whether or not the callback did pick up the slot, so that it can do the right thing in these 2 cases.
--- fs/nfsd/nfs4callback.c | 8 +++++++- fs/nfsd/state.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
fs/nfsd/nfs4callback.c +7 -1
@@ -874,8 +874,9 @@ static void nfsd4_cb_prepare(struct rpc_ cb->cb_seq_status =1 ; cb->cb_status =0 ;if (minorversion) { -if (!nfsd41_cb_get_slot (clp, task)) +if (!cb->cb_holds_slot && !nfsd41_cb_get_slot (clp, task))return ; + cb->cb_holds_slot = true; }rpc_call_start (task); }
@@ -902,6 +903,9 @@ static bool nfsd4_cb_sequence_done(strucreturn true; } +if (!cb->cb_holds_slot) + goto need_restart; +switch (cb->cb_seq_status) {case 0 :/*
@@ -939,6 +943,7 @@ static bool nfsd4_cb_sequence_done(struc cb->cb_seq_status); } + cb->cb_holds_slot = false;clear_bit (0 , &clp->cl_cb_slot_busy);rpc_wake_up_next (&clp->cl_cb_waitq); dprintk("%s: freed slot, new seqid=%d\n", __func__,
@@ -1146,6 +1151,7 @@ void nfsd4_init_cb(struct nfsd4_callback cb->cb_seq_status =1 ; cb->cb_status =0 ; cb->cb_need_restart = false; + cb->cb_holds_slot = false; }void nfsd4_run_cb (struct nfsd4_callback *cb)
fs/nfsd/state.h +1 -0
@@ -70,6 +70,7 @@ struct nfsd4_callback {int cb_seq_status;int cb_status;bool cb_need_restart; +bool cb_holds_slot; };struct nfsd4_callback_ops {
Greg Kroah-Hartman
maintainercover 4.4.180-stable review
This is the start of the stable review cycle for the 4.4.180 release. There are 266 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 17 May 2019 09:04:49 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.180-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.4.180-rc1
Laurentiu Tudor <[email protected]>
powerpc/booke64: set RI in default MSR
Dan Carpenter <[email protected]>
drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl
Dan Carpenter <[email protected]>
drivers/virt/fsl_hypervisor.c: dereferencing error pointers in ioctl
Jarod Wilson <[email protected]>
bonding: fix arp_validate toggling in active-backup mode
David Ahern <[email protected]>
ipv4: Fix raw socket lookup for local traffic
Stephen Suryaputra <[email protected]>
vrf: sit mtu should not be updated when vrf netdev is the link
Hangbin Liu <[email protected]>
vlan: disable SIOCSHWTSTAMP in container
YueHaibing <[email protected]>
packet: Fix error path in packet_init
Christophe Leroy <[email protected]>
net: ucc_geth - fix Oops when changing number of buffers in the ring
Tobin C. Harding <[email protected]>
bridge: Fix error path for kobject_init_and_add()
Breno Leitao <[email protected]>
powerpc/64s: Include cpu header
Johan Hovold <[email protected]>
USB: serial: fix unthrottle races
Oliver Neukum <[email protected]>
USB: serial: use variable for status
Ben Hutchings <[email protected]>
x86/bugs: Change L1TF mitigation string to match upstream
Josh Poimboeuf <[email protected]>
x86/speculation/mds: Fix documentation typo
Tyler Hicks <[email protected]>
Documentation: Correct the possible MDS sysfs values
speck for Pawan Gupta <[email protected]>
x86/mds: Add MDSUM variant to the MDS documentation
Josh Poimboeuf <[email protected]>
x86/speculation/mds: Add 'mitigations=' support for MDS
Josh Poimboeuf <[email protected]>
x86/speculation: Support 'mitigations=' cmdline option
Josh Poimboeuf <[email protected]>
cpu/speculation: Add 'mitigations=' cmdline option
Konrad Rzeszutek Wilk <[email protected]>
x86/speculation/mds: Print SMT vulnerable on MSBDS with mitigations off
Boris Ostrovsky <[email protected]>
x86/speculation/mds: Fix comment
Josh Poimboeuf <[email protected]>
x86/speculation/mds: Add SMT warning message
Josh Poimboeuf <[email protected]>
x86/speculation: Move arch_smt_update() call to after mitigation decisions
Andi Kleen <[email protected]>
x86/cpu/bugs: Use __initconst for 'const' init data
Thomas Gleixner <[email protected]>
Documentation: Add MDS vulnerability documentation
Thomas Gleixner <[email protected]>
Documentation: Move L1TF to separate directory
Thomas Gleixner <[email protected]>
x86/speculation/mds: Add mitigation mode VMWERV
Thomas Gleixner <[email protected]>
x86/speculation/mds: Add sysfs reporting for MDS
Ben Hutchings <[email protected]>
x86/speculation/l1tf: Document l1tf in sysfs
Thomas Gleixner <[email protected]>
x86/speculation/mds: Add mitigation control for MDS
Thomas Gleixner <[email protected]>
x86/speculation/mds: Conditionally clear CPU buffers on idle entry
Thomas Gleixner <[email protected]>
x86/speculation/mds: Clear CPU buffers on exit to user
Thomas Gleixner <[email protected]>
x86/speculation/mds: Add mds_clear_cpu_buffers()
Andi Kleen <[email protected]>
x86/kvm: Expose X86_FEATURE_MD_CLEAR to guests
Thomas Gleixner <[email protected]>
x86/speculation/mds: Add BUG_MSBDS_ONLY
Andi Kleen <[email protected]>
x86/speculation/mds: Add basic bug infrastructure for MDS
Thomas Gleixner <[email protected]>
x86/speculation: Consolidate CPU whitelists
Thomas Gleixner <[email protected]>
x86/msr-index: Cleanup bit defines
Eduardo Habkost <[email protected]>
kvm: x86: Report STIBP on GET_SUPPORTED_CPUID
Thomas Gleixner <[email protected]>
x86/speculation: Provide IBPB always command line options
Thomas Gleixner <[email protected]>
x86/speculation: Add seccomp Spectre v2 user space protection mode
Thomas Gleixner <[email protected]>
x86/speculation: Enable prctl mode for spectre_v2_user
Thomas Gleixner <[email protected]>
x86/speculation: Add prctl() control for indirect branch speculation
Thomas Gleixner <[email protected]>
x86/speculation: Prevent stale SPEC_CTRL msr content
Thomas Gleixner <[email protected]>
x86/speculation: Prepare arch_smt_update() for PRCTL mode
Thomas Gleixner <[email protected]>
x86/speculation: Split out TIF update
Thomas Gleixner <[email protected]>
x86/speculation: Prepare for conditional IBPB in switch_mm()
Thomas Gleixner <[email protected]>
x86/speculation: Avoid __switch_to_xtra() calls
Thomas Gleixner <[email protected]>
x86/process: Consolidate and simplify switch_to_xtra() code
Tim Chen <[email protected]>
x86/speculation: Prepare for per task indirect branch speculation control
Thomas Gleixner <[email protected]>
x86/speculation: Add command line control for indirect branch speculation
Thomas Gleixner <[email protected]>
x86/speculation: Unify conditional spectre v2 print functions
Thomas Gleixner <[email protected]>
x86/speculataion: Mark command line parser data __initdata
Thomas Gleixner <[email protected]>
x86/speculation: Mark string arrays const correctly
Thomas Gleixner <[email protected]>
x86/speculation: Reorder the spec_v2 code
Thomas Gleixner <[email protected]>
x86/speculation: Rework SMT state change
Ben Hutchings <[email protected]>
sched: Add sched_smt_active()
Thomas Gleixner <[email protected]>
x86/Kconfig: Select SCHED_SMT if SMP enabled
Tim Chen <[email protected]>
x86/speculation: Reorganize speculation control MSRs update
Thomas Gleixner <[email protected]>
x86/speculation: Rename SSBD update functions
Tim Chen <[email protected]>
x86/speculation: Disable STIBP when enhanced IBRS is in use
Tim Chen <[email protected]>
x86/speculation: Move STIPB/IBPB string conditionals out of cpu_show_common()
Tim Chen <[email protected]>
x86/speculation: Remove unnecessary ret variable in cpu_show_common()
Tim Chen <[email protected]>
x86/speculation: Clean up spectre_v2_parse_cmdline()
Tim Chen <[email protected]>
x86/speculation: Update the TIF_SSBD comment
Jiri Kosina <[email protected]>
x86/speculation: Propagate information about RSB filling mitigation to sysfs
Jiri Kosina <[email protected]>
x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation
Jiri Kosina <[email protected]>
x86/speculation: Apply IBPB more strictly to avoid cross-process data leak
Nadav Amit <[email protected]>
x86/mm: Use WRITE_ONCE() when setting PTEs
Thomas Gleixner <tglx@xxxxxxxxxxxxx>
KVM: x86: SVM: Call x86_spec_ctrl_set_guest/host() with interrupts disabled
Peter Zijlstra <[email protected]>
x86/cpu: Sanitize FAM6_ATOM naming
Filippo Sironi <[email protected]>
x86/microcode: Update the new microcode revision unconditionally
Prarit Bhargava <[email protected]>
x86/microcode: Make sure boot_cpu_data.microcode is up-to-date
Jiang Biao <[email protected]>
x86/speculation: Remove SPECTRE_V2_IBRS in enum spectre_v2_mitigation
Tom Lendacky <[email protected]>
x86/bugs: Fix the AMD SSBD usage of the SPEC_CTRL MSR
Will Deacon <[email protected]>
locking/atomics, asm-generic: Move some macros from <linux/bitops.h> to a new <linux/bits.h> file
Konrad Rzeszutek Wilk <[email protected]>
x86/bugs: Switch the selection of mitigation from CPU vendor to CPU features
Konrad Rzeszutek Wilk <[email protected]>
x86/bugs: Add AMD's SPEC_CTRL MSR usage
Konrad Rzeszutek Wilk <[email protected]>
x86/bugs: Add AMD's variant of SSB_NO
Dominik Brodowski <[email protected]>
x86/speculation: Simplify the CPU bug detection logic
Sai Praneeth <[email protected]>
x86/speculation: Support Enhanced IBRS on future CPUs
Ben Hutchings <[email protected]>
x86/cpufeatures: Hide AMD-specific speculation flags
Tony Luck <[email protected]>
x86/MCE: Save microcode revision in machine check records
Ashok Raj <[email protected]>
x86/microcode/intel: Check microcode revision before updating sibling threads
Matthias Kaehlcke <[email protected]>
bitops: avoid integer overflow in GENMASK(_ULL)
Nicolas Dichtel <[email protected]>
x86: stop exporting msr-index.h to userland
Borislav Petkov <[email protected]>
x86/microcode/intel: Add a helper which gives the microcode revision
Tony Luck <[email protected]>
locking/static_keys: Provide DECLARE and well as DEFINE macros
Nigel Croxon <[email protected]>
Don't jump to compute_result state from check_result state
Alistair Strachan <[email protected]>
x86/vdso: Pass --eh-frame-hdr to the linker
Wei Yongjun <[email protected]>
cw1200: fix missing unlock on error in cw1200_hw_scan()
Lucas Stach <[email protected]>
gpu: ipu-v3: dp: fix CSC handling
Po-Hsu Lin <[email protected]>
selftests/net: correct the return value for run_netsocktests
Arnd Bergmann <[email protected]>
s390: ctcm: fix ctcm_new_device error return code
Julian Anastasov <[email protected]>
ipvs: do not schedule icmp errors from tunnels
Dan Williams <[email protected]>
init: initialize jump labels before command line option parsing
Rikard Falkeborn <[email protected]>
tools lib traceevent: Fix missing equality check for strcmp
Vitaly Kuznetsov <[email protected]>
KVM: x86: avoid misreporting level-triggered irqs as edge-triggered in tracing
Martin Schwidefsky <[email protected]>
s390/3270: fix lockdep false positive on view->lock
Peter Oberparleiter <[email protected]>
s390/dasd: Fix capacity calculation for large volumes
Aditya Pakki <[email protected]>
libnvdimm/btt: Fix a kmemdup failure check
Dmitry Torokhov <[email protected]>
HID: input: add mapping for keyboard Brightness Up/Down/Toggle keys
Dmitry Torokhov <[email protected]>
HID: input: add mapping for Expose/Overview key
Sven Van Asbroeck <[email protected]>
iio: adc: xilinx: fix potential use-after-free on remove
Gustavo A. R. Silva <[email protected]>
platform/x86: sony-laptop: Fix unintentional fall-through
Michal Hocko <[email protected]>
mm, vmstat: make quiet_vmstat lighter
Francesco Ruggeri <[email protected]>
netfilter: compat: initialize all fields in xt_init
Ben Hutchings <[email protected]>
timer/debug: Change /proc/timer_stats from 0644 to 0600
Ross Zwisler <[email protected]>
ASoC: Intel: avoid Oops if DMA setup fails
WANG Cong <[email protected]>
ipv6: fix a potential deadlock in do_ipv6_setsockopt()
Oliver Neukum <[email protected]>
UAS: fix alignment of scatter/gather segments
Marcel Holtmann <[email protected]>
Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
Young Xiao <[email protected]>
Bluetooth: hidp: fix buffer overflow
Andrew Vasquez <[email protected]>
scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines
Thinh Nguyen <[email protected]>
usb: dwc3: Fix default lpm_nyet_threshold value
Prasad Sodagudi <[email protected]>
genirq: Prevent use-after-free and work list corruption
Joerg Roedel <[email protected]>
iommu/amd: Set exclusion range correctly
Varun Prakash <[email protected]>
scsi: csiostor: fix missing data copy in csio_scsi_err_handler()
Stephane Eranian <[email protected]>
perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS
Annaliese McDermond <[email protected]>
ASoC: tlv320aic32x4: Fix Common Pins
Daniel Mack <[email protected]>
ASoC: cs4270: Set auto-increment bit for register writes
Rander Wang <[email protected]>
ASoC:soc-pcm:fix a codec fixup issue in TDM case
Jason Yan <[email protected]>
scsi: libsas: fix a race condition when smp task timeout
Jacopo Mondi <[email protected]>
media: v4l2: i2c: ov7670: Fix PLL bypass register values
Tony Luck <[email protected]>
x86/mce: Improve error message when kernel cannot recover, p2
Ondrej Mosnacek <[email protected]>
selinux: never allow relabeling on context mounts
Anson Huang <[email protected]>
Input: snvs_pwrkey - initialize necessary driver data before enabling IRQ
Jeremy Fertic <[email protected]>
staging: iio: adt7316: fix the dac write calculation
Jeremy Fertic <[email protected]>
staging: iio: adt7316: fix the dac read calculation
Jeremy Fertic <[email protected]>
staging: iio: adt7316: allow adt751x to use internal vref for all dacs
Malte Leip <[email protected]>
usb: usbip: fix isoc packet num validation in get_pipe
Arnd Bergmann <[email protected]>
ARM: iop: don't use using 64-bit DMA masks
Arnd Bergmann <[email protected]>
ARM: orion: don't use using 64-bit DMA masks
Guenter Roeck <[email protected]>
xsysace: Fix error handling in ace_setup
Mike Kravetz <[email protected]>
hugetlbfs: fix memory leak for resv_map
Yonglong Liu <[email protected]>
net: hns: Fix WARNING when remove HNS driver with SMMU enabled
Yonglong Liu <[email protected]>
net: hns: Use NAPI_POLL_WEIGHT for hns driver
Michael Kelley <[email protected]>
scsi: storvsc: Fix calculation of sub-channel count
Louis Taylor <[email protected]>
vfio/pci: use correct format characters
Alexandre Belloni <[email protected]>
rtc: da9063: set uie_unsupported when relevant
Al Viro <[email protected]>
debugfs: fix use-after-free on symlink traversal
Al Viro <[email protected]>
jffs2: fix use-after-free on symlink traversal
Konstantin Khorenko <[email protected]>
bonding: show full hw address in sysfs for slave entries
Arvind Sankar <[email protected]>
igb: Fix WARN_ONCE on runtime suspend
Geert Uytterhoeven <[email protected]>
rtc: sh: Fix invalid alarm warning for non-enabled alarm
He, Bo <[email protected]>
HID: debug: fix race condition with between rdesc_show() and device removal
Alan Stern <[email protected]>
USB: core: Fix bug caused by duplicate interface PM usage counter
Alan Stern <[email protected]>
USB: core: Fix unterminated string returned by usb_string()
Alan Stern <[email protected]>
USB: w1 ds2490: Fix bug caused by improper use of altsetting array
Alan Stern <[email protected]>
USB: yurex: Fix protection fault after device removal
Willem de Bruijn <[email protected]>
packet: validate msg_namelen in send directly
Michael Chan <[email protected]>
bnxt_en: Improve multicast address setup logic.
Willem de Bruijn <[email protected]>
ipv6: invert flowlabel sharing check in process and user mode
Eric Dumazet <[email protected]>
ipv6/flowlabel: wait rcu grace period before put_pid()
Shmulik Ladkani <[email protected]>
ipv4: ip_do_fragment: Preserve skb_iif during fragmentation
Greg Kroah-Hartman <[email protected]>
ALSA: line6: use dynamic buffers
Alex Williamson <[email protected]>
vfio/type1: Limit DMA mappings per container
Changbin Du <[email protected]>
kconfig/[mn]conf: handle backspace (^H) key
raymond pang <[email protected]>
libata: fix using DMA buffers on stack
Steffen Maier <[email protected]>
scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN
Al Viro <[email protected]>
ceph: fix use-after-free on symlink traversal
Mukesh Ojha <[email protected]>
usb: u132-hcd: fix resource leak
Kangjie Lu <[email protected]>
scsi: qla4xxx: fix a potential NULL pointer dereference
Wen Yang <[email protected]>
net: ethernet: ti: fix possible object reference leak
Wen Yang <[email protected]>
net: ibm: fix possible object reference leak
Wen Yang <[email protected]>
net: xilinx: fix possible object reference leak
Lukas Wunner <[email protected]>
net: ks8851: Set initial carrier state to down
Lukas Wunner <[email protected]>
net: ks8851: Delay requesting IRQ until opened
Lukas Wunner <[email protected]>
net: ks8851: Reassert reset pin if chip ID check fails
Lukas Wunner <[email protected]>
net: ks8851: Dequeue RX packets explicitly
Marco Felsch <[email protected]>
ARM: dts: pfla02: increase phy reset duration
Guido Kiener <[email protected]>
usb: gadget: net2272: Fix net2272_dequeue()
Guido Kiener <[email protected]>
usb: gadget: net2280: Fix net2280_dequeue()
Guido Kiener <[email protected]>
usb: gadget: net2280: Fix overrun of OUT messages
Mao Wenan <[email protected]>
sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
Xin Long <[email protected]>
netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING
Aditya Pakki <[email protected]>
qlcnic: Avoid potential NULL pointer dereference
Gustavo A. R. Silva <[email protected]>
usbnet: ipheth: fix potential null pointer dereference in ipheth_carrier_set
Alexander Kappner <[email protected]>
usbnet: ipheth: prevent TX queue timeouts when device not ready
Diana Craciun <[email protected]>
Documentation: Add nospectre_v1 parameter
Diana Craciun <[email protected]>
powerpc/fsl: Add FSL_PPC_BOOK3E as supported arch for nospectre_v2 boot arg
Diana Craciun <[email protected]>
powerpc/fsl: Fixed warning: orphan section `__btb_flush_fixup'
Diana Craciun <[email protected]>
powerpc/fsl: Sanitize the syscall table for NXP PowerPC 32 bit platforms
Diana Craciun <[email protected]>
powerpc/fsl: Flush the branch predictor at each kernel entry (32 bit)
Diana Craciun <[email protected]>
powerpc/fsl: Emulate SPRN_BUCSR register
Diana Craciun <[email protected]>
powerpc/fsl: Flush branch predictor when entering KVM
Diana Craciun <[email protected]>
powerpc/fsl: Enable runtime patching if nospectre_v2 boot arg is used
ZhangXiaoxu <[email protected]>
ipv4: set the tcp_min_rtt_wlen range from 0 to one day
Vinod Koul <[email protected]>
net: stmmac: move stmmac_check_ether_addr() to driver probe
Hangbin Liu <[email protected]>
team: fix possible recursive locking when add slaves
Eric Dumazet <[email protected]>
ipv4: add sanity checks in ipv4_link_failure()
Greg Kroah-Hartman <[email protected]>
Revert "block/loop: Use global lock for ioctl() operation."
Daniel Borkmann <[email protected]>
bpf: reject wrong sized filters earlier
Xin Long <[email protected]>
tipc: check link name with right length in tipc_nl_compat_link_set
Xin Long <[email protected]>
tipc: check bearer name with right length in tipc_nl_compat_bearer_enable
Florian Westphal <[email protected]>
netfilter: ebtables: CONFIG_COMPAT: drop a bogus WARN_ON
Tetsuo Handa <[email protected]>
NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family.
YueHaibing <[email protected]>
fs/proc/proc_sysctl.c: Fix a NULL pointer dereference
Alexander Shishkin <[email protected]>
intel_th: gth: Fix an off-by-one in output unassigning
Linus Torvalds <[email protected]>
slip: make slhc_free() silently accept an error pointer
Xin Long <[email protected]>
tipc: handle the err returned from cmd header function
Christophe Leroy <[email protected]>
powerpc/fsl: Fix the flush of branch predictor.
Michael Ellerman <[email protected]>
powerpc/security: Fix spectre_v2 reporting
Diana Craciun <[email protected]>
powerpc/fsl: Update Spectre v2 reporting
Diana Craciun <[email protected]>
powerpc/fsl: Flush the branch predictor at each kernel entry (64bit)
Diana Craciun <[email protected]>
powerpc/fsl: Add nospectre_v2 command line argument
Diana Craciun <[email protected]>
powerpc/fsl: Fix spectre_v2 mitigations reporting
Diana Craciun <[email protected]>
powerpc/fsl: Add macro to flush the branch predictor
Diana Craciun <[email protected]>
powerpc/fsl: Add infrastructure to fixup branch predictor flush
Michael Neuling <[email protected]>
powerpc: Avoid code patching freed init sections
Michael Ellerman <[email protected]>
powerpc/powernv: Query firmware for count cache flush settings
Michael Ellerman <[email protected]>
powerpc/pseries: Query hypervisor for count cache flush settings
Michael Ellerman <[email protected]>
powerpc/64s: Add support for software count cache flush
Michael Ellerman <[email protected]>
powerpc/64s: Add new security feature flags for count cache flush
Michael Ellerman <[email protected]>
powerpc/asm: Add a patch_site macro & helpers for patching instructions
Diana Craciun <[email protected]>
powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book3E
Diana Craciun <[email protected]>
powerpc/64: Make meltdown reporting Book3S 64 specific
Michael Ellerman <[email protected]>
powerpc/64: Call setup_barrier_nospec() from setup_arch()
Michael Ellerman <[email protected]>
powerpc/64: Add CONFIG_PPC_BARRIER_NOSPEC
Diana Craciun <[email protected]>
powerpc/64: Make stf barrier PPC_BOOK3S_64 specific.
Diana Craciun <[email protected]>
powerpc/64: Disable the speculation barrier from the command line
Michael Ellerman <[email protected]>
powerpc64s: Show ori31 availability in spectre_v1 sysfs file not v2
Michal Suchanek <[email protected]>
powerpc/64s: Enhance the information in cpu_show_spectre_v1()
Michael Ellerman <[email protected]>
powerpc: Use barrier_nospec in copy_from_user()
Michael Ellerman <[email protected]>
powerpc/64: Use barrier_nospec in syscall entry
Michal Suchanek <[email protected]>
powerpc/64s: Enable barrier_nospec based on firmware settings
Michal Suchanek <[email protected]>
powerpc/64s: Patch barrier_nospec in modules
Michal Suchanek <[email protected]>
powerpc/64s: Add support for ori barrier_nospec patching
Michal Suchanek <[email protected]>
powerpc/64s: Add barrier_nospec
Nicholas Piggin <[email protected]>
powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit
Michael Ellerman <[email protected]>
powerpc/64s: Fix section mismatch warnings from setup_rfi_flush()
Mauricio Faria de Oliveira <[email protected]>
powerpc/pseries: Restore default security feature flags on setup
Mauricio Faria de Oliveira <[email protected]>
powerpc: Move default security feature flags
Mauricio Faria de Oliveira <[email protected]>
powerpc/pseries: Fix clearing of security feature flags
Michael Ellerman <[email protected]>
powerpc/64s: Wire up cpu_show_spectre_v2()
Michael Ellerman <[email protected]>
powerpc/64s: Wire up cpu_show_spectre_v1()
Michael Ellerman <[email protected]>
powerpc/pseries: Use the security flags in pseries_setup_rfi_flush()
Michael Ellerman <[email protected]>
powerpc/powernv: Use the security flags in pnv_setup_rfi_flush()
Michael Ellerman <[email protected]>
powerpc/64s: Enhance the information in cpu_show_meltdown()
Michael Ellerman <[email protected]>
powerpc/64s: Move cpu_show_meltdown()
Michael Ellerman <[email protected]>
powerpc/powernv: Set or clear security feature flags
Michael Ellerman <[email protected]>
powerpc/pseries: Set or clear security feature flags
Michael Ellerman <[email protected]>
powerpc: Add security feature flags for Spectre/Meltdown
Michael Ellerman <[email protected]>
powerpc/rfi-flush: Call setup_rfi_flush() after LPM migration
Michael Ellerman <[email protected]>
powerpc/pseries: Add new H_GET_CPU_CHARACTERISTICS flags
Mauricio Faria de Oliveira <[email protected]>
powerpc/rfi-flush: Differentiate enabled and patched flush types
Michael Ellerman <[email protected]>
powerpc/rfi-flush: Always enable fallback flush on pseries
Michael Ellerman <[email protected]>
powerpc/rfi-flush: Make it possible to call setup_rfi_flush() again
Michael Ellerman <[email protected]>
powerpc/rfi-flush: Move the logic to avoid a redo into the debugfs code
Michael Ellerman <[email protected]>
powerpc/powernv: Support firmware disable of RFI flush
Michael Ellerman <[email protected]>
powerpc/pseries: Support firmware disable of RFI flush
Nicholas Piggin <[email protected]>
powerpc/64s: Improve RFI L1-D cache flush fallback
Michael Ellerman <[email protected]>
powerpc/xmon: Add RFI flush related fields to paca dump
Kai-Heng Feng <[email protected]>
USB: Consolidate LPM checks to avoid enabling LPM twice
Kai-Heng Feng <[email protected]>
USB: Add new USB LPM helpers
NeilBrown <[email protected]>
sunrpc: don't mark uninitialised items as VALID.
Trond Myklebust <[email protected]>
nfsd: Don't release the callback slot unless it was actually held
Yan, Zheng <[email protected]>
ceph: fix ci->i_head_snapc leak
Jeff Layton <[email protected]>
ceph: ensure d_name stability in ceph_dentry_hash()
Xie XiuQi <[email protected]>
sched/numa: Fix a possible divide-by-zero
Peter Zijlstra <[email protected]>
trace: Fix preempt_enable_no_resched() abuse
Aurelien Jarno <[email protected]>
MIPS: scall64-o32: Fix indirect syscall number load
Frank Sorenson <[email protected]>
cifs: do not attempt cifs operation on smb2+ rename error
Paolo Bonzini <[email protected]>
KVM: fail KVM_SET_VCPU_EVENTS with invalid exception number
Masahiro Yamada <[email protected]>
kbuild: simplify ld-option implementation
-------------
Diffstat:
Documentation/ABI/testing/sysfs-devices-system-cpu | 2 + Documentation/hw-vuln/mds.rst | 305 ++++++++++ Documentation/kernel-parameters.txt | 110 +++- Documentation/networking/ip-sysctl.txt | 1 + Documentation/spec_ctrl.txt | 9 + Documentation/usb/power-management.txt | 14 +- Documentation/x86/mds.rst | 225 +++++++ Makefile | 4 +- arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi | 1 + arch/arm/mach-iop13xx/setup.c | 8 +- arch/arm/mach-iop13xx/tpmi.c | 10 +- arch/arm/plat-iop/adma.c | 6 +- arch/arm/plat-orion/common.c | 4 +- arch/mips/kernel/scall64-o32.S | 2 +- arch/powerpc/Kconfig | 7 +- arch/powerpc/include/asm/asm-prototypes.h | 21 + arch/powerpc/include/asm/barrier.h | 21 + arch/powerpc/include/asm/code-patching-asm.h | 18 + arch/powerpc/include/asm/code-patching.h | 2 + arch/powerpc/include/asm/exception-64s.h | 35 ++ arch/powerpc/include/asm/feature-fixups.h | 40 ++ arch/powerpc/include/asm/hvcall.h | 5 + arch/powerpc/include/asm/paca.h | 3 +- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/include/asm/ppc_asm.h | 11 + arch/powerpc/include/asm/reg_booke.h | 2 +- arch/powerpc/include/asm/security_features.h | 92 +++ arch/powerpc/include/asm/setup.h | 23 +- arch/powerpc/include/asm/uaccess.h | 18 +- arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/asm-offsets.c | 3 +- arch/powerpc/kernel/entry_32.S | 10 + arch/powerpc/kernel/entry_64.S | 69 +++ arch/powerpc/kernel/exceptions-64e.S | 27 +- arch/powerpc/kernel/exceptions-64s.S | 98 ++-- arch/powerpc/kernel/head_booke.h | 12 + arch/powerpc/kernel/head_fsl_booke.S | 15 + arch/powerpc/kernel/module.c | 10 +- arch/powerpc/kernel/security.c | 434 ++++++++++++++ arch/powerpc/kernel/setup_32.c | 3 + arch/powerpc/kernel/setup_64.c | 51 +- arch/powerpc/kernel/vmlinux.lds.S | 33 +- arch/powerpc/kvm/bookehv_interrupts.S | 4 + arch/powerpc/kvm/e500_emulate.c | 7 + arch/powerpc/lib/code-patching.c | 29 + arch/powerpc/lib/feature-fixups.c | 218 ++++++- arch/powerpc/mm/mem.c | 2 + arch/powerpc/mm/tlb_low_64e.S | 7 + arch/powerpc/platforms/powernv/setup.c | 99 +++- arch/powerpc/platforms/pseries/mobility.c | 3 + arch/powerpc/platforms/pseries/pseries.h | 2 + arch/powerpc/platforms/pseries/setup.c | 88 ++- arch/powerpc/xmon/xmon.c | 2 + arch/x86/Kconfig | 8 +- arch/x86/entry/common.c | 3 + arch/x86/entry/vdso/Makefile | 3 +- arch/x86/include/asm/cpufeatures.h | 12 +- arch/x86/include/asm/intel-family.h | 30 +- arch/x86/include/asm/irqflags.h | 5 + arch/x86/include/asm/microcode_intel.h | 15 + arch/x86/include/asm/msr-index.h | 30 +- arch/x86/include/asm/mwait.h | 7 + arch/x86/include/asm/nospec-branch.h | 66 ++- arch/x86/include/asm/pgtable_64.h | 16 +- arch/x86/include/asm/processor.h | 7 + arch/x86/include/asm/spec-ctrl.h | 20 +- arch/x86/include/asm/switch_to.h | 3 - arch/x86/include/asm/thread_info.h | 20 +- arch/x86/include/asm/tlbflush.h | 8 +- arch/x86/include/uapi/asm/Kbuild | 1 - arch/x86/include/uapi/asm/mce.h | 4 + arch/x86/kernel/cpu/bugs.c | 643 +++++++++++++++++---- arch/x86/kernel/cpu/common.c | 140 +++-- arch/x86/kernel/cpu/intel.c | 11 +- arch/x86/kernel/cpu/mcheck/mce-severity.c | 5 + arch/x86/kernel/cpu/mcheck/mce.c | 4 +- arch/x86/kernel/cpu/microcode/amd.c | 22 +- arch/x86/kernel/cpu/microcode/intel.c | 64 +- arch/x86/kernel/cpu/perf_event_intel.c | 2 +- arch/x86/kernel/nmi.c | 4 + arch/x86/kernel/process.c | 101 +++- arch/x86/kernel/process.h | 39 ++ arch/x86/kernel/process_32.c | 9 +- arch/x86/kernel/process_64.c | 9 +- arch/x86/kernel/traps.c | 8 + arch/x86/kvm/cpuid.c | 13 +- arch/x86/kvm/cpuid.h | 2 +- arch/x86/kvm/svm.c | 10 +- arch/x86/kvm/trace.h | 4 +- arch/x86/kvm/x86.c | 4 + arch/x86/mm/kaiser.c | 4 +- arch/x86/mm/pgtable.c | 6 +- arch/x86/mm/tlb.c | 114 +++- drivers/ata/libata-zpodd.c | 34 +- drivers/base/cpu.c | 8 + drivers/block/loop.c | 42 +- drivers/block/loop.h | 1 + drivers/block/xsysace.c | 2 + drivers/gpu/ipu-v3/ipu-dp.c | 12 +- drivers/hid/hid-debug.c | 5 + drivers/hid/hid-input.c | 6 + drivers/hwtracing/intel_th/gth.c | 2 +- drivers/iio/adc/xilinx-xadc-core.c | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 6 +- drivers/iommu/amd_iommu_init.c | 2 +- drivers/md/raid5.c | 19 +- drivers/media/i2c/ov7670.c | 16 +- drivers/net/bonding/bond_options.c | 7 - drivers/net/bonding/bond_sysfs_slave.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +- drivers/net/ethernet/freescale/ucc_geth_ethtool.c | 8 +- drivers/net/ethernet/hisilicon/hns/hnae.c | 4 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 7 +- drivers/net/ethernet/ibm/ehea/ehea_main.c | 1 + drivers/net/ethernet/intel/igb/e1000_defines.h | 2 + drivers/net/ethernet/intel/igb/igb_main.c | 57 +- drivers/net/ethernet/micrel/ks8851.c | 36 +- .../net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +- drivers/net/ethernet/ti/netcp_ethss.c | 8 +- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 + drivers/net/slip/slhc.c | 2 +- drivers/net/team/team.c | 6 + drivers/net/usb/ipheth.c | 33 +- drivers/net/wireless/cw1200/scan.c | 5 +- drivers/nvdimm/btt_devs.c | 18 +- drivers/platform/x86/sony-laptop.c | 8 +- drivers/rtc/rtc-da9063.c | 7 + drivers/rtc/rtc-sh.c | 2 +- drivers/s390/block/dasd_eckd.c | 6 +- drivers/s390/char/con3270.c | 2 +- drivers/s390/char/fs3270.c | 3 +- drivers/s390/char/raw3270.c | 3 +- drivers/s390/char/raw3270.h | 4 +- drivers/s390/char/tty3270.c | 3 +- drivers/s390/net/ctcm_main.c | 1 + drivers/s390/scsi/zfcp_fc.c | 21 +- drivers/scsi/csiostor/csio_scsi.c | 5 +- drivers/scsi/libsas/sas_expander.c | 9 +- drivers/scsi/qla2xxx/qla_attr.c | 4 +- drivers/scsi/qla4xxx/ql4_os.c | 2 + drivers/scsi/storvsc_drv.c | 13 +- drivers/staging/iio/addac/adt7316.c | 22 +- drivers/tty/serial/sc16is7xx.c | 12 +- drivers/usb/core/driver.c | 36 +- drivers/usb/core/hub.c | 16 +- drivers/usb/core/message.c | 7 +- drivers/usb/core/sysfs.c | 5 +- drivers/usb/core/usb.h | 10 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/gadget/udc/net2272.c | 1 + drivers/usb/gadget/udc/net2280.c | 8 +- drivers/usb/host/u132-hcd.c | 3 + drivers/usb/misc/yurex.c | 1 + drivers/usb/serial/generic.c | 57 +- drivers/usb/storage/realtek_cr.c | 13 +- drivers/usb/storage/uas.c | 38 +- drivers/usb/usbip/stub_rx.c | 18 +- drivers/usb/usbip/usbip_common.h | 7 + drivers/vfio/pci/vfio_pci.c | 4 +- drivers/vfio/vfio_iommu_type1.c | 14 + drivers/virt/fsl_hypervisor.c | 29 +- drivers/w1/masters/ds2490.c | 6 +- fs/ceph/dir.c | 6 +- fs/ceph/inode.c | 2 +- fs/ceph/mds_client.c | 9 + fs/ceph/snap.c | 7 +- fs/cifs/inode.c | 4 + fs/debugfs/inode.c | 13 +- fs/hugetlbfs/inode.c | 20 +- fs/jffs2/readinode.c | 5 - fs/jffs2/super.c | 5 +- fs/nfs/super.c | 3 +- fs/nfsd/nfs4callback.c | 8 +- fs/nfsd/state.h | 1 + fs/proc/proc_sysctl.c | 6 +- include/linux/bitops.h | 21 +- include/linux/bits.h | 26 + include/linux/cpu.h | 19 + include/linux/jump_label.h | 6 + include/linux/ptrace.h | 21 +- include/linux/sched.h | 9 + include/linux/sched/smt.h | 20 + include/linux/usb.h | 2 - include/net/addrconf.h | 1 + include/net/bluetooth/hci_core.h | 3 + include/uapi/linux/prctl.h | 1 + init/main.c | 4 +- kernel/cpu.c | 23 +- kernel/irq/manage.c | 4 +- kernel/ptrace.c | 10 + kernel/sched/core.c | 24 + kernel/sched/fair.c | 4 + kernel/sched/sched.h | 1 + kernel/time/timer_stats.c | 2 +- kernel/trace/ring_buffer.c | 2 +- mm/vmstat.c | 68 ++- net/8021q/vlan_dev.c | 4 +- net/bluetooth/hci_conn.c | 8 + net/bluetooth/hidp/sock.c | 1 + net/bridge/br_if.c | 13 +- net/bridge/br_netfilter_hooks.c | 1 + net/bridge/br_netfilter_ipv6.c | 2 + net/bridge/netfilter/ebtables.c | 3 +- net/core/filter.c | 23 +- net/ipv4/ip_output.c | 1 + net/ipv4/raw.c | 4 +- net/ipv4/route.c | 32 +- net/ipv4/sysctl_net_ipv4.c | 5 +- net/ipv6/ip6_flowlabel.c | 22 +- net/ipv6/ipv6_sockglue.c | 3 +- net/ipv6/mcast.c | 17 +- net/ipv6/sit.c | 2 +- net/netfilter/ipvs/ip_vs_core.c | 2 +- net/netfilter/x_tables.c | 2 +- net/packet/af_packet.c | 48 +- net/sunrpc/cache.c | 3 + net/tipc/netlink_compat.c | 24 +- scripts/Kbuild.include | 4 +- scripts/kconfig/lxdialog/inputbox.c | 3 +- scripts/kconfig/nconf.c | 2 +- scripts/kconfig/nconf.gui.c | 3 +- security/selinux/hooks.c | 40 +- sound/soc/codecs/cs4270.c | 1 + sound/soc/codecs/tlv320aic32x4.c | 2 + sound/soc/intel/common/sst-dsp.c | 8 +- sound/soc/soc-pcm.c | 7 +- sound/usb/line6/driver.c | 60 +- sound/usb/line6/toneport.c | 24 +- tools/lib/traceevent/event-parse.c | 2 +- tools/power/x86/turbostat/Makefile | 2 +- tools/testing/selftests/net/run_netsocktests | 2 +- 232 files changed, 4217 insertions(+), 1000 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 33/266 powerpc: Move default security feature flags
From: Mauricio Faria de Oliveira <[email protected]>
commit e7347a86830f38dc3e40c8f7e28c04412b12a2e7 upstream.
This moves the definition of the default security feature flags (i.e., enabled by default) closer to the security feature flags.
This can be used to restore current flags to the default flags.
--- arch/powerpc/include/asm/security_features.h | 8 ++++++++ arch/powerpc/kernel/security.c | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/security_features.h +8 -0
@@ -63,4 +63,12 @@ static inline bool security_ftr_enabled(// Firmware configuration indicates user favours security over performance #define SEC_FTR_FAVOUR_SECURITY 0x0000000000000200ull + +// Features enabled by default +#define SEC_FTR_DEFAULT \ + (SEC_FTR_L1D_FLUSH_HV | \ + SEC_FTR_L1D_FLUSH_PR | \ + SEC_FTR_BNDS_CHK_SPEC_BAR | \ + SEC_FTR_FAVOUR_SECURITY) +#endif /* _ASM_POWERPC_SECURITY_FEATURES_H */
arch/powerpc/kernel/security.c +1 -6
@@ -11,12 +11,7 @@#include <asm/security_features.h> -unsigned long powerpc_security_features __read_mostly = \ -SEC_FTR_L1D_FLUSH_HV | \ -SEC_FTR_L1D_FLUSH_PR | \ -SEC_FTR_BNDS_CHK_SPEC_BAR | \ -SEC_FTR_FAVOUR_SECURITY ; - +unsigned long powerpc_security_features__read_mostly =SEC_FTR_DEFAULT ;ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) {
Greg Kroah-Hartman
maintainerPATCH 24/266 powerpc/pseries: Set or clear security feature flags
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit f636c14790ead6cc22cf62279b1f8d7e11a67116 upstream.
Now that we have feature flags for security related things, set or clear them based on what we receive from the hypercall.
--- arch/powerpc/platforms/pseries/setup.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
arch/powerpc/platforms/pseries/setup.c +43 -0
@@ -67,6 +67,7 @@#include <asm/eeh.h> #include <asm/reg.h> #include <asm/plpar_wrappers.h> +#include <asm/security_features.h> #include "pseries.h"
@@ -499,6 +500,40 @@ static void __init find_and_init_phbs(voof_pci_check_probe_only (); } +static void init_cpu_char_feature_flags (struct h_cpu_char_result *result) +{ +if (result->character &H_CPU_CHAR_SPEC_BAR_ORI31 ) +security_ftr_set (SEC_FTR_SPEC_BAR_ORI31 ); + +if (result->character &H_CPU_CHAR_BCCTRL_SERIALISED ) +security_ftr_set (SEC_FTR_BCCTRL_SERIALISED ); + +if (result->character &H_CPU_CHAR_L1D_FLUSH_ORI30 ) +security_ftr_set (SEC_FTR_L1D_FLUSH_ORI30 ); + +if (result->character &H_CPU_CHAR_L1D_FLUSH_TRIG2 ) +security_ftr_set (SEC_FTR_L1D_FLUSH_TRIG2 ); + +if (result->character &H_CPU_CHAR_L1D_THREAD_PRIV ) +security_ftr_set (SEC_FTR_L1D_THREAD_PRIV ); + +if (result->character &H_CPU_CHAR_COUNT_CACHE_DISABLED ) +security_ftr_set (SEC_FTR_COUNT_CACHE_DISABLED ); + +/* +* The features below are enabled by default, so we instead look to see +* if firmware has *disabled* them, and clear them if so. +*/ +if (!(result->character &H_CPU_BEHAV_FAVOUR_SECURITY )) +security_ftr_clear (SEC_FTR_FAVOUR_SECURITY ); + +if (!(result->character &H_CPU_BEHAV_L1D_FLUSH_PR )) +security_ftr_clear (SEC_FTR_L1D_FLUSH_PR ); + +if (!(result->character &H_CPU_BEHAV_BNDS_CHK_SPEC_BAR )) +security_ftr_clear (SEC_FTR_BNDS_CHK_SPEC_BAR ); +} +void pseries_setup_rfi_flush (void ) {struct h_cpu_char_result result;
@@ -512,6 +547,8 @@ void pseries_setup_rfi_flush(void) rc =plpar_get_cpu_characteristics (&result);if (rc ==H_SUCCESS ) { +init_cpu_char_feature_flags (&result); +if (result.character &H_CPU_CHAR_L1D_FLUSH_TRIG2 ) types |=L1D_FLUSH_MTTRIG ;if (result.character &H_CPU_CHAR_L1D_FLUSH_ORI30 )
@@ -522,6 +559,12 @@ void pseries_setup_rfi_flush(void) enable = false; } +/* +* We're the guest so this doesn't apply to us, clear it to simplify +* handling of it elsewhere. +*/ +security_ftr_clear (SEC_FTR_L1D_FLUSH_HV ); +setup_rfi_flush (types, enable); }
Greg Kroah-Hartman
maintainerPATCH 35/266 powerpc/64s: Fix section mismatch warnings from setup_rfi_flush()
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 501a78cbc17c329fabf8e9750a1e9ab810c88a0e upstream.
The recent LPM changes to setup_rfi_flush() are causing some section mismatch warnings because we removed the __init annotation on setup_rfi_flush():
The function setup_rfi_flush() references
the function __init ppc64_bolted_size().
the function __init memblock_alloc_base().
The references are actually in init_fallback_flush(), but that is inlined into setup_rfi_flush().
These references are safe because:
- only pseries calls setup_rfi_flush() at runtime
- pseries always passes L1D_FLUSH_FALLBACK at boot
- so the fallback flush area will always be allocated
- so the check in init_fallback_flush() will always return early:
/* Only allocate the fallback flush area once (at boot time). */ if (l1d_flush_fallback_area)
return;
- and therefore we won't actually call the freed init routines.
We should rework the code to make it safer by default rather than relying on the above, but for now as a quick-fix just add a __ref annotation to squash the warning.
--- arch/powerpc/kernel/setup_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/setup_64.c +1 -1
@@ -882,7 +882,7 @@ void rfi_flush_enable(bool enable) rfi_flush = enable; } -static void init_fallback_flush (void ) +static void __ref init_fallback_flush (void ) {u64 l1d_size, limit;int cpu;
Greg Kroah-Hartman
maintainerPATCH 36/266 powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
commit a048a07d7f4535baa4cbad6bc024f175317ab938 upstream.
On some CPUs we can prevent a vulnerability related to store-to-load forwarding by preventing store forwarding between privilege domains, by inserting a barrier in kernel entry and exit paths.
This is known to be the case on at least Power7, Power8 and Power9 powerpc CPUs.
Barriers must be inserted generally before the first load after moving to a higher privilege, and after the last store before moving to a lower privilege, HV and PR privilege transitions must be protected.
Barriers are added as patch sections, with all kernel/hypervisor entry points patched, and the exit points to lower privilge levels patched similarly to the RFI flush patching.
Firmware advertisement is not implemented yet, so CPU flush types are hard coded.
Thanks to Michal Suchánek for bug fixes and review.
--- arch/powerpc/include/asm/exception-64s.h | 35 ++++++ arch/powerpc/include/asm/feature-fixups.h | 19 +++ arch/powerpc/include/asm/security_features.h | 11 ++ arch/powerpc/kernel/exceptions-64s.S | 22 +++- arch/powerpc/kernel/security.c | 148 +++++++++++++++++++++++++++ arch/powerpc/kernel/vmlinux.lds.S | 14 ++ arch/powerpc/lib/feature-fixups.c | 116 ++++++++++++++++++++- arch/powerpc/platforms/powernv/setup.c | 1 arch/powerpc/platforms/pseries/setup.c | 1 9 files changed, 365 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/exception-64s.h +35 -0
@@ -50,6 +50,27 @@#define EX_PPR 88/* SMT thread status register (priority) */ #define EX_CTR 96 +#define STF_ENTRY_BARRIER_SLOT \ + STF_ENTRY_BARRIER_FIXUP_SECTION; \ + nop; \ + nop; \ + nop + +#define STF_EXIT_BARRIER_SLOT \ + STF_EXIT_BARRIER_FIXUP_SECTION; \ + nop; \ + nop; \ + nop; \ + nop; \ + nop; \ + nop + +/* +* r10 must be free to use, r13 must be paca +*/ +#define INTERRUPT_TO_KERNEL \ + STF_ENTRY_BARRIER_SLOT +/* * Macros for annotating the expected destination of (h)rfid *
@@ -66,16 +87,19 @@ rfid#define RFI_TO_USER \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ rfid; \ b rfi_flush_fallback#define RFI_TO_USER_OR_KERNEL \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ rfid; \ b rfi_flush_fallback#define RFI_TO_GUEST \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ rfid; \ b rfi_flush_fallback
@@ -84,21 +108,25 @@ hrfid#define HRFI_TO_USER \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ hrfid; \ b hrfi_flush_fallback#define HRFI_TO_USER_OR_KERNEL \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ hrfid; \ b hrfi_flush_fallback#define HRFI_TO_GUEST \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ hrfid; \ b hrfi_flush_fallback#define HRFI_TO_UNKNOWN \ + STF_EXIT_BARRIER_SLOT; \ RFI_FLUSH_SLOT; \ hrfid; \ b hrfi_flush_fallback
@@ -226,6 +254,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)#define __EXCEPTION_PROLOG_1 (area, extra, vec) \ OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \ OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \ + INTERRUPT_TO_KERNEL; \ SAVE_CTR(r10, area); \ mfcr r9; \ extra(vec); \
@@ -512,6 +541,12 @@ label##_relon_hv: \#define _MASKABLE_EXCEPTION_PSERIES (vec, label, h, extra) \ __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) +#define MASKABLE_EXCEPTION_OOL (vec, label) \ + .globl label##_ool; \ +label##_ool: \ + EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ + EXCEPTION_PROLOG_PSERIES_1(label##_common, EXC_STD); +#define MASKABLE_EXCEPTION_PSERIES (loc, vec, label) \ . = loc; \ .globl label##_pSeries; \
arch/powerpc/include/asm/feature-fixups.h +19 -0
@@ -184,6 +184,22 @@ label##3: \ FTR_ENTRY_OFFSET label##1b-label##3b; \ .popsection; +#define STF_ENTRY_BARRIER_FIXUP_SECTION \ +953: \ + .pushsection __stf_entry_barrier_fixup,"a"; \ + .align 2; \ +954: \ + FTR_ENTRY_OFFSET 953b-954b; \ + .popsection; + +#define STF_EXIT_BARRIER_FIXUP_SECTION \ +955: \ + .pushsection __stf_exit_barrier_fixup,"a"; \ + .align 2; \ +956: \ + FTR_ENTRY_OFFSET 955b-956b; \ + .popsection; +#define RFI_FLUSH_FIXUP_SECTION \ 951: \ .pushsection __rfi_flush_fixup,"a"; \
@@ -195,6 +211,9 @@ label##3: \#ifndef __ASSEMBLY__ +extern long stf_barrier_fallback; +extern long __start___stf_entry_barrier_fixup, __stop___stf_entry_barrier_fixup; +extern long __start___stf_exit_barrier_fixup, __stop___stf_exit_barrier_fixup;extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;#endif
arch/powerpc/include/asm/security_features.h +11 -0
@@ -12,6 +12,17 @@extern unsigned long powerpc_security_features;extern bool rfi_flush; +/* These are bit flags */ +enum stf_barrier_type { +STF_BARRIER_NONE =0x1 , +STF_BARRIER_FALLBACK =0x2 , +STF_BARRIER_EIEIO =0x4 , +STF_BARRIER_SYNC_ORI =0x8 , +}; + +void setup_stf_barrier (void ); +void do_stf_barrier_fixups (enum stf_barrier_type types); +static inline void security_ftr_set (unsigned long feature) { powerpc_security_features |= feature;
arch/powerpc/kernel/exceptions-64s.S +21 -1
@@ -36,6 +36,7 @@ BEGIN_FTR_SECTION \ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ mr r9,r13 ; \ GET_PACA(r13) ; \ + INTERRUPT_TO_KERNEL ; \ mfspr r11,SPRN_SRR0 ; \ 0:
@@ -292,7 +293,9 @@ hardware_interrupt_hv: . = 0x900 .globl decrementer_pSeries decrementer_pSeries: - _MASKABLE_EXCEPTION_PSERIES(0x900, decrementer, EXC_STD, SOFTEN_TEST_PR) + SET_SCRATCH0(r13) + EXCEPTION_PROLOG_0(PACA_EXGEN) + b decrementer_ool STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
@@ -319,6 +322,7 @@ system_call_pSeries: OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); HMT_MEDIUM; std r10,PACA_EXGEN+EX_R10(r13) + INTERRUPT_TO_KERNEL OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR); mfcr r9 KVMTEST(0xc00)
@@ -607,6 +611,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) .align 7 /* moved from 0xe00 */ + MASKABLE_EXCEPTION_OOL(0x900, decrementer) STD_EXCEPTION_HV_OOL(0xe02, h_data_storage) KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02) STD_EXCEPTION_HV_OOL(0xe22, h_instr_storage)
@@ -1564,6 +1569,21 @@ power4_fixup_nap: blr #endif + .balign 16 + .globl stf_barrier_fallback +stf_barrier_fallback: + std r9,PACA_EXRFI+EX_R9(r13) + std r10,PACA_EXRFI+EX_R10(r13) + sync + ld r9,PACA_EXRFI+EX_R9(r13) + ld r10,PACA_EXRFI+EX_R10(r13) + ori 31,31,0 + .rept 14 + b 1f +1: + .endr + blr + .globl rfi_flush_fallback rfi_flush_fallback: SET_SCRATCH0(r13);
arch/powerpc/kernel/security.c +148 -0
160 lines not on this page · raw message
arch/powerpc/kernel/vmlinux.lds.S +14 -0
@@ -74,6 +74,20 @@ SECTIONS #ifdef CONFIG_PPC64 . = ALIGN(8); + __stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) { + __start___stf_entry_barrier_fixup = .; + *(__stf_entry_barrier_fixup) + __stop___stf_entry_barrier_fixup = .; + } + + . = ALIGN(8); + __stf_exit_barrier_fixup : AT(ADDR(__stf_exit_barrier_fixup) - LOAD_OFFSET) { + __start___stf_exit_barrier_fixup = .; + *(__stf_exit_barrier_fixup) + __stop___stf_exit_barrier_fixup = .; + } + + . = ALIGN(8); __rfi_flush_fixup : AT(ADDR(__rfi_flush_fixup) - LOAD_OFFSET) { __start___rfi_flush_fixup = .; *(__rfi_flush_fixup)
arch/powerpc/lib/feature-fixups.c +115 -1
128 lines not on this page · raw message
arch/powerpc/platforms/powernv/setup.c +1 -0
@@ -130,6 +130,7 @@ static void __init pnv_setup_arch(void)set_arch_panic_timeout (10 ,ARCH_PANIC_TIMEOUT );pnv_setup_rfi_flush (); +setup_stf_barrier ();/* Initialize SMP */ pnv_smp_init ();
arch/powerpc/platforms/pseries/setup.c +1 -0
@@ -593,6 +593,7 @@ static void __init pSeries_setup_arch(vofwnmi_init ();pseries_setup_rfi_flush (); +setup_stf_barrier ();/* By default, only probe PCI (can be overridden by rtas_pci) */ pci_add_flags (PCI_PROBE_ONLY );
Greg Kroah-Hartman
maintainerPATCH 38/266 powerpc/64s: Add support for ori barrier_nospec patching
In reply to Greg Kroah-HartmanFrom: Michal Suchanek <[email protected]>
commit 2eea7f067f495e33b8b116b35b5988ab2b8aec55 upstream.
Based on the RFI patching. This is required to be able to disable the speculation barrier.
Only one barrier type is supported and it does nothing when the firmware does not enable it. Also re-patching modules is not supported So the only meaningful thing that can be done is patching out the speculation barrier at boot when the user says it is not wanted.
--- arch/powerpc/include/asm/barrier.h | 2 +- arch/powerpc/include/asm/feature-fixups.h | 9 +++++++++ arch/powerpc/include/asm/setup.h | 1 + arch/powerpc/kernel/security.c | 9 +++++++++ arch/powerpc/kernel/vmlinux.lds.S | 7 +++++++ arch/powerpc/lib/feature-fixups.c | 27 +++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/barrier.h +1 -1
@@ -97,7 +97,7 @@ do { \* Prevent execution of subsequent instructions until preceding branches have * been fully resolved and are no longer executing speculatively. */ -#define barrier_nospec_asm ori 31,31,0 +#define barrier_nospec_asm NOSPEC_BARRIER_FIXUP_SECTION; nop// This also acts as a compiler barrier due to the memory clobber. #define barrier_nospec () asm (stringify_in_c(barrier_nospec_asm) ::: "memory")
arch/powerpc/include/asm/feature-fixups.h +9 -0
@@ -208,6 +208,14 @@ label##3: \ FTR_ENTRY_OFFSET 951b-952b; \ .popsection; +#define NOSPEC_BARRIER_FIXUP_SECTION \ +953: \ + .pushsection __barrier_nospec_fixup,"a"; \ + .align 2; \ +954: \ + FTR_ENTRY_OFFSET 953b-954b; \ + .popsection; +#ifndef __ASSEMBLY__
@@ -215,6 +223,7 @@ extern long stf_barrier_fallback;extern long __start___stf_entry_barrier_fixup, __stop___stf_entry_barrier_fixup;extern long __start___stf_exit_barrier_fixup, __stop___stf_exit_barrier_fixup;extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup; +extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup;#endif
arch/powerpc/include/asm/setup.h +1 -0
@@ -38,6 +38,7 @@ enum l1d_flush_type {void setup_rfi_flush (enum l1d_flush_type ,bool enable);void do_rfi_flush_fixups (enum l1d_flush_type types); +void do_barrier_nospec_fixups (bool enable);#endif /* !__ASSEMBLY__ */
arch/powerpc/kernel/security.c +9 -0
@@ -11,10 +11,19 @@#include <asm/debug.h> #include <asm/security_features.h> +#include <asm/setup.h> unsigned long powerpc_security_features__read_mostly =SEC_FTR_DEFAULT ; +static bool barrier_nospec_enabled; + +static void enable_barrier_nospec (bool enable) +{ + barrier_nospec_enabled = enable; +do_barrier_nospec_fixups (enable); +} +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) {bool thread_priv;
arch/powerpc/kernel/vmlinux.lds.S +7 -0
@@ -93,6 +93,13 @@ SECTIONS *(__rfi_flush_fixup) __stop___rfi_flush_fixup = .; } + + . = ALIGN(8); + __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) { + __start___barrier_nospec_fixup = .; + *(__barrier_nospec_fixup) + __stop___barrier_nospec_fixup = .; + } #endif EXCEPTION_TABLE(0)
arch/powerpc/lib/feature-fixups.c +27 -0
@@ -274,6 +274,33 @@ void do_rfi_flush_fixups(enum l1d_flush_ (types &L1D_FLUSH_MTTRIG ) ?"mttrig type" : "unknown"); } + +void do_barrier_nospec_fixups (bool enable) +{ +unsigned int instr, *dest; +long *start, *end; +int i; + + start =PTRRELOC (&__start___barrier_nospec_fixup), + end =PTRRELOC (&__stop___barrier_nospec_fixup); + + instr =0x60000000 ;/* nop */ + +if (enable) { +pr_info ("barrier-nospec: using ORI speculation barrier\n" ); + instr =0x63ff0000 ;/* ori 31,31,0 speculation barrier */ + } + +for (i =0 ; start < end; start++, i++) { + dest = (void *)start + *start; + +pr_devel ("patching dest %lx\n" , (unsigned long )dest); +patch_instruction (dest, instr); + } + +printk (KERN_DEBUG "barrier-nospec: patched %d locations\n" , i); +} +#endif /* CONFIG_PPC_BOOK3S_64 */ void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end)
Greg Kroah-Hartman
maintainerPATCH 39/266 powerpc/64s: Patch barrier_nospec in modules
In reply to Greg Kroah-HartmanFrom: Michal Suchanek <[email protected]>
commit 815069ca57c142eb71d27439bc27f41a433a67b3 upstream.
Note that unlike RFI which is patched only in kernel the nospec state reflects settings at the time the module was loaded.
Iterating all modules and re-patching every time the settings change is not implemented.
Based on lwsync patching.
--- arch/powerpc/include/asm/setup.h | 7 +++++++ arch/powerpc/kernel/module.c | 6 ++++++ arch/powerpc/kernel/security.c | 2 +- arch/powerpc/lib/feature-fixups.c | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/setup.h +7 -0
@@ -39,6 +39,13 @@ enum l1d_flush_type {void setup_rfi_flush (enum l1d_flush_type ,bool enable);void do_rfi_flush_fixups (enum l1d_flush_type types);void do_barrier_nospec_fixups (bool enable); +extern bool barrier_nospec_enabled; + +#ifdef CONFIG_PPC_BOOK3S_64 +void do_barrier_nospec_fixups_range (bool enable,void *start,void *end); +#else +static inline void do_barrier_nospec_fixups_range (bool enable,void *start,void *end) { }; +#endif #endif /* !__ASSEMBLY__ */
arch/powerpc/kernel/module.c +6 -0
@@ -67,6 +67,12 @@ int module_finalize(const Elf_Ehdr *hdr,do_feature_fixups (powerpc_firmware_features, (void *)sect->sh_addr, (void *)sect->sh_addr + sect->sh_size); + + sect =find_section (hdr, sechdrs,"__spec_barrier_fixup" ); +if (sect !=NULL ) +do_barrier_nospec_fixups_range (barrier_nospec_enabled, + (void *)sect->sh_addr, + (void *)sect->sh_addr + sect->sh_size);#endif sect =find_section (hdr, sechdrs,"__lwsync_fixup" );
arch/powerpc/kernel/security.c +1 -1
@@ -16,7 +16,7 @@unsigned long powerpc_security_features__read_mostly =SEC_FTR_DEFAULT ; -static bool barrier_nospec_enabled; +bool barrier_nospec_enabled;static void enable_barrier_nospec (bool enable) {
arch/powerpc/lib/feature-fixups.c +13 -3
@@ -275,14 +275,14 @@ void do_rfi_flush_fixups(enum l1d_flush_ : "unknown"); } -void do_barrier_nospec_fixups (bool enable) +void do_barrier_nospec_fixups_range (bool enable,void *fixup_start,void *fixup_end) {unsigned int instr, *dest;long *start, *end;int i; - start =PTRRELOC (&__start___barrier_nospec_fixup), - end =PTRRELOC (&__stop___barrier_nospec_fixup); + start = fixup_start; + end = fixup_end; instr =0x60000000 ;/* nop */
@@ -301,6 +301,16 @@ void do_barrier_nospec_fixups(bool enabl printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i); } +void do_barrier_nospec_fixups (bool enable) +{ +void *start, *end; + + start =PTRRELOC (&__start___barrier_nospec_fixup), + end =PTRRELOC (&__stop___barrier_nospec_fixup); + +do_barrier_nospec_fixups_range (enable, start, end); +} +#endif /* CONFIG_PPC_BOOK3S_64 */ void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end)
Greg Kroah-Hartman
maintainerPATCH 41/266 powerpc/64: Use barrier_nospec in syscall entry
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 51973a815c6b46d7b23b68d6af371ad1c9d503ca upstream.
Our syscall entry is done in assembly so patch in an explicit barrier_nospec.
Based on a patch by Michal Suchanek.
--- arch/powerpc/kernel/entry_64.S | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/kernel/entry_64.S +10 -0
@@ -36,6 +36,7 @@ #include <asm/hw_irq.h> #include <asm/context_tracking.h> #include <asm/tm.h> +#include <asm/barrier.h> #ifdef CONFIG_PPC_BOOK3S #include <asm/exception-64s.h> #else
@@ -177,6 +178,15 @@ system_call: /* label this so stack tr clrldi r8,r8,32 15: slwi r0,r0,4 + + barrier_nospec_asm + /* + * Prevent the load of the handler below (based on the user-passed + * system call number) being speculatively executed until the test + * against NR_syscalls and branch to .Lsyscall_enosys above has + * committed. + */ + ldx r12,r11,r0 /* Fetch system call handler [ptr] */ mtctr r12 bctrl /* Call handler */
Greg Kroah-Hartman
maintainerPATCH 40/266 powerpc/64s: Enable barrier_nospec based on firmware settings
In reply to Greg Kroah-HartmanFrom: Michal Suchanek <[email protected]>
commit cb3d6759a93c6d0aea1c10deb6d00e111c29c19c upstream.
Check what firmware told us and enable/disable the barrier_nospec as appropriate.
We err on the side of enabling the barrier, as it's no-op on older systems, see the comment for more detail.
--- arch/powerpc/include/asm/setup.h | 1 arch/powerpc/kernel/security.c | 59 +++++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/setup.c | 1 arch/powerpc/platforms/pseries/setup.c | 1 4 files changed, 62 insertions(+)
arch/powerpc/include/asm/setup.h +1 -0
@@ -38,6 +38,7 @@ enum l1d_flush_type {void setup_rfi_flush (enum l1d_flush_type ,bool enable);void do_rfi_flush_fixups (enum l1d_flush_type types); +void setup_barrier_nospec (void );void do_barrier_nospec_fixups (bool enable);extern bool barrier_nospec_enabled;
arch/powerpc/kernel/security.c +59 -0
65 lines not on this page · raw message
arch/powerpc/platforms/powernv/setup.c +1 -0
@@ -123,6 +123,7 @@ static void pnv_setup_rfi_flush(void) security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV));setup_rfi_flush (type, enable); +setup_barrier_nospec (); }static void __init pnv_setup_arch (void )
arch/powerpc/platforms/pseries/setup.c +1 -0
@@ -574,6 +574,7 @@ void pseries_setup_rfi_flush(void)security_ftr_enabled (SEC_FTR_L1D_FLUSH_PR );setup_rfi_flush (types, enable); +setup_barrier_nospec (); }static void __init pSeries_setup_arch (void )
Greg Kroah-Hartman
maintainerPATCH 25/266 powerpc/powernv: Set or clear security feature flags
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 77addf6e95c8689e478d607176b399a6242a777e upstream.
Now that we have feature flags for security related things, set or clear them based on what we see in the device tree provided by firmware.
--- arch/powerpc/platforms/powernv/setup.c | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/powerpc/platforms/powernv/setup.c +56 -0
@@ -37,9 +37,63 @@#include <asm/smp.h> #include <asm/tm.h> #include <asm/setup.h> +#include <asm/security_features.h> #include "powernv.h" + +static bool fw_feature_is (const char *state,const char *name, +struct device_node *fw_features) +{ +struct device_node *np; +bool rc = false; + + np =of_get_child_by_name (fw_features, name); +if (np) { + rc =of_property_read_bool (np, state); +of_node_put (np); + } + +return rc; +} + +static void init_fw_feat_flags (struct device_node *np) +{ +if (fw_feature_is ("enabled" ,"inst-spec-barrier-ori31,31,0" , np)) +security_ftr_set (SEC_FTR_SPEC_BAR_ORI31 ); + +if (fw_feature_is ("enabled" ,"fw-bcctrl-serialized" , np)) +security_ftr_set (SEC_FTR_BCCTRL_SERIALISED ); + +if (fw_feature_is ("enabled" ,"inst-spec-barrier-ori31,31,0" , np)) +security_ftr_set (SEC_FTR_L1D_FLUSH_ORI30 ); + +if (fw_feature_is ("enabled" ,"inst-l1d-flush-trig2" , np)) +security_ftr_set (SEC_FTR_L1D_FLUSH_TRIG2 ); + +if (fw_feature_is ("enabled" ,"fw-l1d-thread-split" , np)) +security_ftr_set (SEC_FTR_L1D_THREAD_PRIV ); + +if (fw_feature_is ("enabled" ,"fw-count-cache-disabled" , np)) +security_ftr_set (SEC_FTR_COUNT_CACHE_DISABLED ); + +/* +* The features below are enabled by default, so we instead look to see +* if firmware has *disabled* them, and clear them if so. +*/ +if (fw_feature_is ("disabled" ,"speculation-policy-favor-security" , np)) +security_ftr_clear (SEC_FTR_FAVOUR_SECURITY ); + +if (fw_feature_is ("disabled" ,"needs-l1d-flush-msr-pr-0-to-1" , np)) +security_ftr_clear (SEC_FTR_L1D_FLUSH_PR ); + +if (fw_feature_is ("disabled" ,"needs-l1d-flush-msr-hv-1-to-0" , np)) +security_ftr_clear (SEC_FTR_L1D_FLUSH_HV ); + +if (fw_feature_is ("disabled" ,"needs-spec-barrier-for-bound-checks" , np)) +security_ftr_clear (SEC_FTR_BNDS_CHK_SPEC_BAR ); +} +static void pnv_setup_rfi_flush (void ) {struct device_node *np, *fw_features;
@@ -55,6 +109,8 @@ static void pnv_setup_rfi_flush(void)of_node_put (np);if (fw_features) { +init_fw_feat_flags (fw_features); + np =of_get_child_by_name (fw_features,"inst-l1d-flush-trig2" );if (np &&of_property_read_bool (np,"enabled" )) type =L1D_FLUSH_MTTRIG ;
Greg Kroah-Hartman
maintainerPATCH 44/266 powerpc64s: Show ori31 availability in spectre_v1 sysfs file not v2
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 6d44acae1937b81cf8115ada8958e04f601f3f2e upstream.
When I added the spectre_v2 information in sysfs, I included the availability of the ori31 speculation barrier.
Although the ori31 barrier can be used to mitigate v2, it's primarily intended as a spectre v1 mitigation. Spectre v2 is mitigated by hardware changes.
So rework the sysfs files to show the ori31 information in the spectre_v1 file, rather than v2.
Currently we display eg:
$ grep . spectre_v* spectre_v1:Mitigation: __user pointer sanitization spectre_v2:Mitigation: Indirect branch cache disabled, ori31 speculation barrier enabled
After:
$ grep . spectre_v* spectre_v1:Mitigation: __user pointer sanitization, ori31 speculation barrier enabled spectre_v2:Mitigation: Indirect branch cache disabled
--- arch/powerpc/kernel/security.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
arch/powerpc/kernel/security.c +17 -10
@@ -118,25 +118,35 @@ ssize_t cpu_show_meltdown(struct devicessize_t cpu_show_spectre_v1 (struct device *dev,struct device_attribute *attr,char *buf) { -if (!security_ftr_enabled (SEC_FTR_BNDS_CHK_SPEC_BAR )) -return sprintf (buf,"Not affected\n" ); +struct seq_buf s; + +seq_buf_init (&s, buf,PAGE_SIZE -1 ); + +if (security_ftr_enabled (SEC_FTR_BNDS_CHK_SPEC_BAR )) { +if (barrier_nospec_enabled) +seq_buf_printf (&s,"Mitigation: __user pointer sanitization" ); +else +seq_buf_printf (&s,"Vulnerable" ); -if (barrier_nospec_enabled) -return sprintf (buf,"Mitigation: __user pointer sanitization\n" ); +if (security_ftr_enabled (SEC_FTR_SPEC_BAR_ORI31 )) +seq_buf_printf (&s,", ori31 speculation barrier enabled" ); -return sprintf (buf,"Vulnerable\n" ); +seq_buf_printf (&s,"\n" ); + }else +seq_buf_printf (&s,"Not affected\n" ); + +return s.len; }ssize_t cpu_show_spectre_v2 (struct device *dev,struct device_attribute *attr,char *buf) { -bool bcs, ccd, ori;struct seq_buf s; +bool bcs, ccd;seq_buf_init (&s, buf,PAGE_SIZE -1 ); bcs =security_ftr_enabled (SEC_FTR_BCCTRL_SERIALISED ); ccd =security_ftr_enabled (SEC_FTR_COUNT_CACHE_DISABLED ); - ori =security_ftr_enabled (SEC_FTR_SPEC_BAR_ORI31 );if (bcs || ccd) {seq_buf_printf (&s,"Mitigation: " );
@@ -152,9 +162,6 @@ ssize_t cpu_show_spectre_v2(struct devic }else seq_buf_printf (&s,"Vulnerable" ); -if (ori) -seq_buf_printf (&s,", ori31 speculation barrier enabled" ); -seq_buf_printf (&s,"\n" );return s.len;
Greg Kroah-Hartman
maintainerPATCH 45/266 powerpc/64: Disable the speculation barrier from the command line
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit cf175dc315f90185128fb061dc05b6fbb211aa2f upstream.
The speculation barrier can be disabled from the command line with the parameter: "nospectre_v1".
--- arch/powerpc/kernel/security.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/kernel/security.c +11 -1
@@ -17,6 +17,7 @@unsigned long powerpc_security_features__read_mostly =SEC_FTR_DEFAULT ;bool barrier_nospec_enabled; +static bool no_nospec;static void enable_barrier_nospec (bool enable) {
@@ -43,9 +44,18 @@ void setup_barrier_nospec(void) enable =security_ftr_enabled (SEC_FTR_FAVOUR_SECURITY ) &&security_ftr_enabled (SEC_FTR_BNDS_CHK_SPEC_BAR ); -enable_barrier_nospec (enable); +if (!no_nospec) +enable_barrier_nospec (enable); } +static int __init handle_nospectre_v1 (char *p) +{ + no_nospec = true; + +return 0 ; +} +early_param ("nospectre_v1" , handle_nospectre_v1); +#ifdef CONFIG_DEBUG_FS static int barrier_nospec_set (void *data,u64 val) {
Greg Kroah-Hartman
maintainerPATCH 47/266 powerpc/64: Add CONFIG_PPC_BARRIER_NOSPEC
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 179ab1cbf883575c3a585bcfc0f2160f1d22a149 upstream.
Add a config symbol to encode which platforms support the barrier_nospec speculation barrier. Currently this is just Book3S 64 but we will add Book3E in a future patch.
--- arch/powerpc/Kconfig | 7 ++++++- arch/powerpc/include/asm/barrier.h | 6 +++--- arch/powerpc/include/asm/setup.h | 2 +- arch/powerpc/kernel/Makefile | 3 ++- arch/powerpc/kernel/module.c | 4 +++- arch/powerpc/kernel/vmlinux.lds.S | 4 +++- arch/powerpc/lib/feature-fixups.c | 6 ++++-- 7 files changed, 22 insertions(+), 10 deletions(-)
arch/powerpc/Kconfig +6 -1
@@ -136,7 +136,7 @@ config PPC select GENERIC_SMP_IDLE_THREAD select GENERIC_CMOS_UPDATE select GENERIC_TIME_VSYSCALL_OLD - select GENERIC_CPU_VULNERABILITIES if PPC_BOOK3S_64 + select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
@@ -162,6 +162,11 @@ config PPC select ARCH_HAS_DMA_SET_COHERENT_MASK select HAVE_ARCH_SECCOMP_FILTER +config PPC_BARRIER_NOSPEC + bool + default y + depends on PPC_BOOK3S_64 + config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN
arch/powerpc/include/asm/barrier.h +3 -3
@@ -92,7 +92,7 @@ do { \#define smp_mb__after_atomic () smp_mb()#define smp_mb__before_spinlock () smp_mb() -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_BARRIER_NOSPEC /* * Prevent execution of subsequent instructions until preceding branches have * been fully resolved and are no longer executing speculatively.
@@ -102,9 +102,9 @@ do { \// This also acts as a compiler barrier due to the memory clobber. #define barrier_nospec () asm (stringify_in_c(barrier_nospec_asm) ::: "memory") -#else /* !CONFIG_PPC_BOOK3S_64 */ +#else /* !CONFIG_PPC_BARRIER_NOSPEC */ #define barrier_nospec_asm#define barrier_nospec () -#endif +#endif /* CONFIG_PPC_BARRIER_NOSPEC */ #endif /* _ASM_POWERPC_BARRIER_H */
arch/powerpc/include/asm/setup.h +1 -1
@@ -42,7 +42,7 @@ void setup_barrier_nospec(void);void do_barrier_nospec_fixups (bool enable);extern bool barrier_nospec_enabled; -#ifdef CONFIG_PPC_BOOK3S_64 +#ifdef CONFIG_PPC_BARRIER_NOSPEC void do_barrier_nospec_fixups_range (bool enable,void *start,void *end);#else static inline void do_barrier_nospec_fixups_range (bool enable,void *start,void *end) { };
arch/powerpc/kernel/Makefile +2 -1
@@ -40,10 +40,11 @@ obj-$(CONFIG_PPC64) += setup_64.o sys_p obj-$(CONFIG_VDSO32) += vdso32/ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o -obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o security.o +obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o obj64-$(CONFIG_RELOCATABLE) += reloc_64.o obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o +obj-$(CONFIG_PPC_BARRIER_NOSPEC) += security.o obj-$(CONFIG_PPC64) += vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
arch/powerpc/kernel/module.c +3 -1
@@ -67,13 +67,15 @@ int module_finalize(const Elf_Ehdr *hdr,do_feature_fixups (powerpc_firmware_features, (void *)sect->sh_addr, (void *)sect->sh_addr + sect->sh_size); +#endif /* CONFIG_PPC64 */ +#ifdef CONFIG_PPC_BARRIER_NOSPEC sect =find_section (hdr, sechdrs,"__spec_barrier_fixup" );if (sect !=NULL )do_barrier_nospec_fixups_range (barrier_nospec_enabled, (void *)sect->sh_addr, (void *)sect->sh_addr + sect->sh_size); -#endif +#endif /* CONFIG_PPC_BARRIER_NOSPEC */ sect =find_section (hdr, sechdrs,"__lwsync_fixup" );if (sect !=NULL )
arch/powerpc/kernel/vmlinux.lds.S +3 -1
@@ -93,14 +93,16 @@ SECTIONS *(__rfi_flush_fixup) __stop___rfi_flush_fixup = .; } +#endif /* CONFIG_PPC64 */ +#ifdef CONFIG_PPC_BARRIER_NOSPEC . = ALIGN(8); __spec_barrier_fixup : AT(ADDR(__spec_barrier_fixup) - LOAD_OFFSET) { __start___barrier_nospec_fixup = .; *(__barrier_nospec_fixup) __stop___barrier_nospec_fixup = .; } -#endif +#endif /* CONFIG_PPC_BARRIER_NOSPEC */ EXCEPTION_TABLE(0)
arch/powerpc/lib/feature-fixups.c +4 -2
@@ -301,6 +301,9 @@ void do_barrier_nospec_fixups_range(boolprintk (KERN_DEBUG "barrier-nospec: patched %d locations\n" , i); } +#endif /* CONFIG_PPC_BOOK3S_64 */ + +#ifdef CONFIG_PPC_BARRIER_NOSPEC void do_barrier_nospec_fixups (bool enable) {void *start, *end;
@@ -310,8 +313,7 @@ void do_barrier_nospec_fixups(bool enabl do_barrier_nospec_fixups_range(enable, start, end); } - -#endif /* CONFIG_PPC_BOOK3S_64 */ +#endif /* CONFIG_PPC_BARRIER_NOSPEC */ void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end) {
Greg Kroah-Hartman
maintainerPATCH 50/266 powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book3E
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit ebcd1bfc33c7a90df941df68a6e5d4018c022fba upstream.
Implement the barrier_nospec as a isync;sync instruction sequence. The implementation uses the infrastructure built for BOOK3S 64.
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/barrier.h | 8 +++++++- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/lib/feature-fixups.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -165,7 +165,7 @@ config PPC config PPC_BARRIER_NOSPEC bool default y - depends on PPC_BOOK3S_64 + depends on PPC_BOOK3S_64 || PPC_FSL_BOOK3E config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN
arch/powerpc/include/asm/barrier.h +7 -1
@@ -92,12 +92,18 @@ do { \#define smp_mb__after_atomic () smp_mb()#define smp_mb__before_spinlock () smp_mb() +#ifdef CONFIG_PPC_BOOK3S_64 +#define NOSPEC_BARRIER_SLOT nop +#elif defined(CONFIG_PPC_FSL_BOOK3E ) +#define NOSPEC_BARRIER_SLOT nop; nop +#endif +#ifdef CONFIG_PPC_BARRIER_NOSPEC /* * Prevent execution of subsequent instructions until preceding branches have * been fully resolved and are no longer executing speculatively. */ -#define barrier_nospec_asm NOSPEC_BARRIER_FIXUP_SECTION; nop +#define barrier_nospec_asm NOSPEC_BARRIER_FIXUP_SECTION; NOSPEC_BARRIER_SLOT// This also acts as a compiler barrier due to the memory clobber. #define barrier_nospec () asm (stringify_in_c(barrier_nospec_asm) ::: "memory")
arch/powerpc/include/asm/ppc-opcode.h +1 -0
@@ -147,6 +147,7 @@#define PPC_INST_LWSYNC 0x7c2004ac#define PPC_INST_SYNC 0x7c0004ac#define PPC_INST_SYNC_MASK 0xfc0007fe +#define PPC_INST_ISYNC 0x4c00012c#define PPC_INST_LXVD2X 0x7c000698#define PPC_INST_MCRXR 0x7c000400#define PPC_INST_MCRXR_MASK 0xfc0007fe
arch/powerpc/lib/feature-fixups.c +31 -0
@@ -315,6 +315,37 @@ void do_barrier_nospec_fixups(bool enabl }#endif /* CONFIG_PPC_BARRIER_NOSPEC */ +#ifdef CONFIG_PPC_FSL_BOOK3E +void do_barrier_nospec_fixups_range (bool enable,void *fixup_start,void *fixup_end) +{ +unsigned int instr[2 ], *dest; +long *start, *end; +int i; + + start = fixup_start; + end = fixup_end; + + instr[0 ] =PPC_INST_NOP ; + instr[1 ] =PPC_INST_NOP ; + +if (enable) { +pr_info ("barrier-nospec: using isync; sync as speculation barrier\n" ); + instr[0 ] =PPC_INST_ISYNC ; + instr[1 ] =PPC_INST_SYNC ; + } + +for (i =0 ; start < end; start++, i++) { + dest = (void *)start + *start; + +pr_devel ("patching dest %lx\n" , (unsigned long )dest); +patch_instruction (dest, instr[0 ]); +patch_instruction (dest +1 , instr[1 ]); + } + +printk (KERN_DEBUG "barrier-nospec: patched %d locations\n" , i); +} +#endif /* CONFIG_PPC_FSL_BOOK3E */ +void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end) {long *start, *end;
Greg Kroah-Hartman
maintainerPATCH 51/266 powerpc/asm: Add a patch_site macro & helpers for patching instructions
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 06d0bbc6d0f56dacac3a79900e9a9a0d5972d818 upstream.
Add a macro and some helper C functions for patching single asm instructions.
The gas macro means we can do something like:
1: nop
patch_site 1b, patch__foo
Which is less visually distracting than defining a GLOBAL symbol at 1, and also doesn't pollute the symbol table which can confuse eg. perf.
These are obviously similar to our existing feature sections, but are not automatically patched based on CPU/MMU features, rather they are designed to be manually patched by C code at some arbitrary point.
--- arch/powerpc/include/asm/code-patching-asm.h | 18 ++++++++++++++++++ arch/powerpc/include/asm/code-patching.h | 2 ++ arch/powerpc/lib/code-patching.c | 16 ++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 arch/powerpc/include/asm/code-patching-asm.h
arch/powerpc/include/asm/code-patching-asm.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2018, Michael Ellerman, IBM Corporation. +*/ +#ifndef _ASM_POWERPC_CODE_PATCHING_ASM_H +#define _ASM_POWERPC_CODE_PATCHING_ASM_H + +/* Define a "site" that can be patched */ +.macro patch_site label name + .pushsection ".rodata" + .balign 4 + .global \name +\name: + .4byte \label - . + .popsection +.endm + +#endif /* _ASM_POWERPC_CODE_PATCHING_ASM_H */
arch/powerpc/include/asm/code-patching.h +2 -0
@@ -28,6 +28,8 @@ unsigned int create_cond_branch(const un unsigned long target, int flags);int patch_branch (unsigned int *addr,unsigned long target,int flags);int patch_instruction (unsigned int *addr,unsigned int instr); +int patch_instruction_site (s32 *addr,unsigned int instr); +int patch_branch_site (s32 *site,unsigned long target,int flags);int instr_is_relative_branch (unsigned int instr);int instr_is_branch_to_addr (const unsigned int *instr,unsigned long addr);
arch/powerpc/lib/code-patching.c +16 -0
@@ -32,6 +32,22 @@ int patch_branch(unsigned int *addr, unsreturn patch_instruction (addr,create_branch (addr, target, flags)); } +int patch_branch_site (s32 *site,unsigned long target,int flags) +{ +unsigned int *addr; + + addr = (unsigned int *)((unsigned long )site + *site); +return patch_instruction (addr,create_branch (addr, target, flags)); +} + +int patch_instruction_site (s32 *site,unsigned int instr) +{ +unsigned int *addr; + + addr = (unsigned int *)((unsigned long )site + *site); +return patch_instruction (addr, instr); +} +unsigned int create_branch (const unsigned int *addr,unsigned long target,int flags) {
Greg Kroah-Hartman
maintainerPATCH 26/266 powerpc/64s: Move cpu_show_meltdown()
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 8ad33041563a10b34988800c682ada14b2612533 upstream.
This landed in setup_64.c for no good reason other than we had nowhere else to put it. Now that we have a security-related file, that is a better place for it so move it.
--- arch/powerpc/kernel/security.c | 11 +++++++++++ arch/powerpc/kernel/setup_64.c | 8 -------- 2 files changed, 11 insertions(+), 8 deletions(-)
arch/powerpc/kernel/security.c +11 -0
@@ -5,6 +5,8 @@// Copyright 2018, Michael Ellerman, IBM Corporation. #include <linux/kernel.h> +#include <linux/device.h> +#include <asm/security_features.h>
@@ -13,3 +15,12 @@ unsigned long powerpc_security_featuresSEC_FTR_L1D_FLUSH_PR | \SEC_FTR_BNDS_CHK_SPEC_BAR | \SEC_FTR_FAVOUR_SECURITY ; + + +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) +{ +if (rfi_flush) +return sprintf (buf,"Mitigation: RFI Flush\n" ); + +return sprintf (buf,"Vulnerable\n" ); +}
arch/powerpc/kernel/setup_64.c +0 -8
@@ -961,12 +961,4 @@ static __init int rfi_flush_debugfs_init }device_initcall (rfi_flush_debugfs_init);#endif - -ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) -{ -if (rfi_flush) -return sprintf (buf,"Mitigation: RFI Flush\n" ); - -return sprintf (buf,"Vulnerable\n" ); -}#endif /* CONFIG_PPC_BOOK3S_64 */
Greg Kroah-Hartman
maintainerPATCH 53/266 powerpc/64s: Add support for software count cache flush
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit ee13cb249fabdff8b90aaff61add347749280087 upstream.
Some CPU revisions support a mode where the count cache needs to be flushed by software on context switch. Additionally some revisions may have a hardware accelerated flush, in which case the software flush sequence can be shortened.
If we detect the appropriate flag from firmware we patch a branch into _switch() which takes us to a count cache flush sequence.
That sequence in turn may be patched to return early if we detect that the CPU supports accelerating the flush sequence in hardware.
Add debugfs support for reporting the state of the flush, as well as runtime disabling it.
And modify the spectre_v2 sysfs file to report the state of the software flush.
--- arch/powerpc/include/asm/asm-prototypes.h | 21 +++++ arch/powerpc/include/asm/security_features.h | 1 arch/powerpc/kernel/entry_64.S | 54 ++++++++++++++ arch/powerpc/kernel/security.c | 98 +++++++++++++++++++++++++-- 4 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 arch/powerpc/include/asm/asm-prototypes.h
arch/powerpc/include/asm/asm-prototypes.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef _ASM_POWERPC_ASM_PROTOTYPES_H +#define _ASM_POWERPC_ASM_PROTOTYPES_H +/* +* This file is for prototypes of C functions that are only called +* from asm, and any associated variables. +* +* Copyright 2016, Daniel Axtens, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +*/ + +/* Patch sites */ +extern s32 patch__call_flush_count_cache; +extern s32 patch__flush_count_cache_return; + +extern long flush_count_cache; + +#endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
arch/powerpc/include/asm/security_features.h +1 -0
@@ -22,6 +22,7 @@ enum stf_barrier_type {void setup_stf_barrier (void );void do_stf_barrier_fixups (enum stf_barrier_type types); +void setup_count_cache_flush (void );static inline void security_ftr_set (unsigned long feature) {
arch/powerpc/kernel/entry_64.S +54 -0
72 lines not on this page · raw message
arch/powerpc/kernel/security.c +93 -5
126 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 55/266 powerpc/powernv: Query firmware for count cache flush settings
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 99d54754d3d5f896a8f616b0b6520662bc99d66b upstream.
Look for fw-features properties to determine the appropriate settings for the count cache flush, and then call the generic powerpc code to set it up based on the security feature flags.
--- arch/powerpc/platforms/powernv/setup.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/platforms/powernv/setup.c +7 -0
@@ -77,6 +77,12 @@ static void init_fw_feat_flags(struct deif (fw_feature_is ("enabled" ,"fw-count-cache-disabled" , np))security_ftr_set (SEC_FTR_COUNT_CACHE_DISABLED ); +if (fw_feature_is ("enabled" ,"fw-count-cache-flush-bcctr2,0,0" , np)) +security_ftr_set (SEC_FTR_BCCTR_FLUSH_ASSIST ); + +if (fw_feature_is ("enabled" ,"needs-count-cache-flush-on-context-switch" , np)) +security_ftr_set (SEC_FTR_FLUSH_COUNT_CACHE ); +/* * The features below are enabled by default, so we instead look to see * if firmware has *disabled* them, and clear them if so.
@@ -123,6 +129,7 @@ static void pnv_setup_rfi_flush(void) security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV));setup_rfi_flush (type, enable); +setup_count_cache_flush (); }static void __init pnv_setup_arch (void )
Greg Kroah-Hartman
maintainerPATCH 56/266 powerpc: Avoid code patching freed init sections
In reply to Greg Kroah-HartmanFrom: Michael Neuling <[email protected]>
commit 51c3c62b58b357e8d35e4cc32f7b4ec907426fe3 upstream.
This stops us from doing code patching in init sections after they've been freed.
In this chain:
kvm_guest_init() ->
kvm_use_magic_page() ->
fault_in_pages_readable() ->
__get_user() ->
__get_user_nocheck() ->
barrier_nospec();We have a code patching location at barrier_nospec() and kvm_guest_init() is an init function. This whole chain gets inlined, so when we free the init section (hence kvm_guest_init()), this code goes away and hence should no longer be patched.
We seen this as userspace memory corruption when using a memory checker while doing partition migration testing on powervm (this starts the code patching post migration via /sys/kernel/mobility/migration). In theory, it could also happen when using /sys/kernel/debug/powerpc/barrier_nospec.
--- arch/powerpc/include/asm/setup.h | 1 + arch/powerpc/lib/code-patching.c | 13 +++++++++++++ arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 16 insertions(+)
arch/powerpc/include/asm/setup.h +1 -0
@@ -8,6 +8,7 @@ extern void ppc_printk_progress(char *s,extern unsigned int rtas_data;extern unsigned long long memory_limit; +extern bool init_mem_is_free;extern unsigned long klimit;extern void *zalloc_maybe_bootmem (size_t size,gfp_t mask);
arch/powerpc/lib/code-patching.c +13 -0
@@ -14,12 +14,25 @@#include <asm/page.h> #include <asm/code-patching.h> #include <asm/uaccess.h> +#include <asm/setup.h> +#include <asm/sections.h> +static inline bool is_init (unsigned int *addr) +{ +return addr >= (unsigned int *)__init_begin && addr < (unsigned int *)__init_end; +} +int patch_instruction (unsigned int *addr,unsigned int instr) {int err; +/* Make sure we aren't patching a freed init section */ +if (init_mem_is_free &&is_init (addr)) { +pr_debug ("Skipping init section patching addr: 0x%px\n" , addr); +return 0 ; + } +__put_user_size (instr, addr,4 , err);if (err)return err;
arch/powerpc/mm/mem.c +2 -0
@@ -62,6 +62,7 @@#endif unsigned long long memory_limit; +bool init_mem_is_free;#ifdef CONFIG_HIGHMEM pte_t *kmap_pte;
@@ -381,6 +382,7 @@ void __init mem_init(void)void free_initmem (void ) { ppc_md.progress = ppc_printk_progress; + init_mem_is_free = true;free_initmem_default (POISON_FREE_INITMEM ); }
Greg Kroah-Hartman
maintainerPATCH 58/266 powerpc/fsl: Add macro to flush the branch predictor
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 1cbf8990d79ff69da8ad09e8a3df014e1494462b upstream.
The BUCSR register can be used to invalidate the entries in the branch prediction mechanisms.
--- arch/powerpc/include/asm/ppc_asm.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/powerpc/include/asm/ppc_asm.h +11 -0
@@ -821,4 +821,15 @@ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,C .long 0x2400004c /* rfid */#endif /* !CONFIG_PPC_BOOK3E */ #endif /* __ASSEMBLY__ */ + +#ifdef CONFIG_PPC_FSL_BOOK3E +#define BTB_FLUSH (reg) \ + lis reg,BUCSR_INIT@h; \ + ori reg,reg,BUCSR_INIT@l; \ + mtspr SPRN_BUCSR,reg; \ + isync; +#else +#define BTB_FLUSH (reg) +#endif /* CONFIG_PPC_FSL_BOOK3E */ +#endif /* _ASM_POWERPC_PPC_ASM_H */
Greg Kroah-Hartman
maintainerPATCH 57/266 powerpc/fsl: Add infrastructure to fixup branch predictor flush
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 76a5eaa38b15dda92cd6964248c39b5a6f3a4e9d upstream.
In order to protect against speculation attacks (Spectre variant 2) on NXP PowerPC platforms, the branch predictor should be flushed when the privillege level is changed. This patch is adding the infrastructure to fixup at runtime the code sections that are performing the branch predictor flush depending on a boot arg parameter which is added later in a separate patch.
--- arch/powerpc/include/asm/feature-fixups.h | 12 ++++++++++++ arch/powerpc/include/asm/setup.h | 2 ++ arch/powerpc/kernel/vmlinux.lds.S | 8 ++++++++ arch/powerpc/lib/feature-fixups.c | 23 +++++++++++++++++++++++ 4 files changed, 45 insertions(+)
arch/powerpc/include/asm/feature-fixups.h +12 -0
@@ -216,6 +216,17 @@ label##3: \ FTR_ENTRY_OFFSET 953b-954b; \ .popsection; +#define START_BTB_FLUSH_SECTION \ +955: \ + +#define END_BTB_FLUSH_SECTION \ +956: \ + .pushsection __btb_flush_fixup,"a"; \ + .align 2; \ +957: \ + FTR_ENTRY_OFFSET 955b-957b; \ + FTR_ENTRY_OFFSET 956b-957b; \ + .popsection;#ifndef __ASSEMBLY__
@@ -224,6 +235,7 @@ extern long __start___stf_entry_barrier_extern long __start___stf_exit_barrier_fixup, __stop___stf_exit_barrier_fixup;extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup; +extern long __start__btb_flush_fixup, __stop__btb_flush_fixup;#endif
arch/powerpc/include/asm/setup.h +2 -0
@@ -53,6 +53,8 @@ void do_barrier_nospec_fixups_range(boolstatic inline void do_barrier_nospec_fixups_range (bool enable,void *start,void *end) { };#endif +void do_btb_flush_fixups (void ); +#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_SETUP_H */
arch/powerpc/kernel/vmlinux.lds.S +8 -0
@@ -104,6 +104,14 @@ SECTIONS } #endif /* CONFIG_PPC_BARRIER_NOSPEC */ +#ifdef CONFIG_PPC_FSL_BOOK3E + . = ALIGN(8); + __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) { + __start__btb_flush_fixup = .; + *(__btb_flush_fixup) + __stop__btb_flush_fixup = .; + } +#endif EXCEPTION_TABLE(0) NOTES :kernel :notes
arch/powerpc/lib/feature-fixups.c +23 -0
@@ -344,6 +344,29 @@ void do_barrier_nospec_fixups_range(boolprintk (KERN_DEBUG "barrier-nospec: patched %d locations\n" , i); } + +static void patch_btb_flush_section (long *curr) +{ +unsigned int *start, *end; + + start = (void *)curr + *curr; + end = (void *)curr + *(curr +1 ); +for (; start < end; start++) { +pr_devel ("patching dest %lx\n" , (unsigned long )start); +patch_instruction (start,PPC_INST_NOP ); + } +} + +void do_btb_flush_fixups (void ) +{ +long *start, *end; + + start =PTRRELOC (&__start__btb_flush_fixup); + end =PTRRELOC (&__stop__btb_flush_fixup); + +for (; start < end; start +=2 ) +patch_btb_flush_section (start); +}#endif /* CONFIG_PPC_FSL_BOOK3E */ void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end)
Greg Kroah-Hartman
maintainerPATCH 59/266 powerpc/fsl: Fix spectre_v2 mitigations reporting
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 7d8bad99ba5a22892f0cad6881289fdc3875a930 upstream.
Currently for CONFIG_PPC_FSL_BOOK3E the spectre_v2 file is incorrect:
$ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 "Mitigation: Software count cache flush"
Which is wrong. Fix it to report vulnerable for now.
--- arch/powerpc/kernel/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/security.c +1 -1
@@ -23,7 +23,7 @@ enum count_cache_flush_type {COUNT_CACHE_FLUSH_SW =0x2 , COUNT_CACHE_FLUSH_HW = 0x4, }; -static enum count_cache_flush_type count_cache_flush_type; +static enum count_cache_flush_type count_cache_flush_type =COUNT_CACHE_FLUSH_NONE ;bool barrier_nospec_enabled;static bool no_nospec;
Greg Kroah-Hartman
maintainerPATCH 60/266 powerpc/fsl: Add nospectre_v2 command line argument
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit f633a8ad636efb5d4bba1a047d4a0f1ef719aa06 upstream.
When the command line argument is present, the Spectre variant 2 mitigations are disabled.
--- arch/powerpc/include/asm/setup.h | 5 +++++ arch/powerpc/kernel/security.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+)
arch/powerpc/include/asm/setup.h +5 -0
@@ -53,6 +53,11 @@ void do_barrier_nospec_fixups_range(boolstatic inline void do_barrier_nospec_fixups_range (bool enable,void *start,void *end) { };#endif +#ifdef CONFIG_PPC_FSL_BOOK3E +void setup_spectre_v2 (void ); +#else +static inline void setup_spectre_v2 (void ) {}; +#endif void do_btb_flush_fixups (void );#endif /* !__ASSEMBLY__ */
arch/powerpc/kernel/security.c +21 -0
@@ -27,6 +27,10 @@ static enum count_cache_flush_type countbool barrier_nospec_enabled;static bool no_nospec; +static bool btb_flush_enabled; +#ifdef CONFIG_PPC_FSL_BOOK3E +static bool no_spectrev2; +#endif static void enable_barrier_nospec (bool enable) {
@@ -102,6 +106,23 @@ static __init int barrier_nospec_debugfsdevice_initcall (barrier_nospec_debugfs_init);#endif /* CONFIG_DEBUG_FS */ +#ifdef CONFIG_PPC_FSL_BOOK3E +static int __init handle_nospectre_v2 (char *p) +{ + no_spectrev2 = true; + +return 0 ; +} +early_param ("nospectre_v2" , handle_nospectre_v2); +void setup_spectre_v2 (void ) +{ +if (no_spectrev2) +do_btb_flush_fixups (); +else + btb_flush_enabled = true; +} +#endif /* CONFIG_PPC_FSL_BOOK3E */ +#ifdef CONFIG_PPC_BOOK3S_64 ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) {
Greg Kroah-Hartman
maintainerPATCH 27/266 powerpc/64s: Enhance the information in cpu_show_meltdown()
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit ff348355e9c72493947be337bb4fae4fc1a41eba upstream.
Now that we have the security feature flags we can make the information displayed in the "meltdown" file more informative.
--- arch/powerpc/include/asm/security_features.h | 1 arch/powerpc/kernel/security.c | 30 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/security_features.h +1 -0
@@ -10,6 +10,7 @@extern unsigned long powerpc_security_features; +extern bool rfi_flush;static inline void security_ftr_set (unsigned long feature) {
arch/powerpc/kernel/security.c +28 -2
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <linux/device.h> +#include <linux/seq_buf.h> #include <asm/security_features.h>
@@ -19,8 +20,33 @@ unsigned long powerpc_security_featuresssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) { -if (rfi_flush) -return sprintf (buf,"Mitigation: RFI Flush\n" ); +bool thread_priv; + + thread_priv =security_ftr_enabled (SEC_FTR_L1D_THREAD_PRIV ); + +if (rfi_flush || thread_priv) { +struct seq_buf s; +seq_buf_init (&s, buf,PAGE_SIZE -1 ); + +seq_buf_printf (&s,"Mitigation: " ); + +if (rfi_flush) +seq_buf_printf (&s,"RFI Flush" ); + +if (rfi_flush && thread_priv) +seq_buf_printf (&s,", " ); + +if (thread_priv) +seq_buf_printf (&s,"L1D private per thread" ); + +seq_buf_printf (&s,"\n" ); + +return s.len; + } + +if (!security_ftr_enabled (SEC_FTR_L1D_FLUSH_HV ) && + !security_ftr_enabled (SEC_FTR_L1D_FLUSH_PR )) +return sprintf (buf,"Not affected\n" );return sprintf (buf,"Vulnerable\n" ); }
Greg Kroah-Hartman
maintainerPATCH 64/266 powerpc/fsl: Fix the flush of branch predictor.
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 27da80719ef132cf8c80eb406d5aeb37dddf78cc upstream.
The commit identified below adds MC_BTB_FLUSH macro only when CONFIG_PPC_FSL_BOOK3E is defined. This results in the following error on some configs (seen several times with kisskb randconfig_defconfig)
arch/powerpc/kernel/exceptions-64e.S:576: Error: Unrecognized opcode: `mc_btb_flush' make[3]: *** [scripts/Makefile.build:367: arch/powerpc/kernel/exceptions-64e.o] Error 1 make[2]: *** [scripts/Makefile.build:492: arch/powerpc/kernel] Error 2 make[1]: *** [Makefile:1043: arch/powerpc] Error 2
make: *** [Makefile:152: sub-make] Error 2
This patch adds a blank definition of MC_BTB_FLUSH for other cases.
--- arch/powerpc/kernel/exceptions-64e.S | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/exceptions-64e.S +1 -0
@@ -348,6 +348,7 @@ ret_from_mc_except: #define GEN_BTB_FLUSH #define CRIT_BTB_FLUSH #define DBG_BTB_FLUSH +#define MC_BTB_FLUSH #define GDBELL_BTB_FLUSH #endif
Greg Kroah-Hartman
maintainerPATCH 65/266 tipc: handle the err returned from cmd header function
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
commit 2ac695d1d602ce00b12170242f58c3d3a8e36d04 upstream.
Syzbot found a crash:
BUG: KMSAN: uninit-value in tipc_nl_compat_name_table_dump+0x54f/0xcd0 net/tipc/netlink_compat.c:872
Call Trace:
tipc_nl_compat_name_table_dump+0x54f/0xcd0 net/tipc/netlink_compat.c:872
__tipc_nl_compat_dumpit+0x59e/0xda0 net/tipc/netlink_compat.c:215
tipc_nl_compat_dumpit+0x63a/0x820 net/tipc/netlink_compat.c:280
tipc_nl_compat_handle net/tipc/netlink_compat.c:1226 [inline]
tipc_nl_compat_recv+0x1b5f/0x2750 net/tipc/netlink_compat.c:1265
genl_family_rcv_msg net/netlink/genetlink.c:601 [inline]
genl_rcv_msg+0x185f/0x1a60 net/netlink/genetlink.c:626
netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2477
genl_rcv+0x63/0x80 net/netlink/genetlink.c:637
netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
netlink_unicast+0xf3e/0x1020 net/netlink/af_netlink.c:1336
netlink_sendmsg+0x127f/0x1300 net/netlink/af_netlink.c:1917
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg net/socket.c:632 [inline]Uninit was created at:
__alloc_skb+0x309/0xa20 net/core/skbuff.c:208
alloc_skb include/linux/skbuff.h:1012 [inline]
netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline]
netlink_sendmsg+0xb82/0x1300 net/netlink/af_netlink.c:1892
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg net/socket.c:632 [inline]It was supposed to be fixed on commit 974cb0e3e7c9 ("tipc: fix uninit-value in tipc_nl_compat_name_table_dump") by checking TLV_GET_DATA_LEN(msg->req) in cmd->header()/tipc_nl_compat_name_table_dump_header(), which is called ahead of tipc_nl_compat_name_table_dump().
However, tipc_nl_compat_dumpit() doesn't handle the error returned from cmd header function. It means even when the check added in that fix fails, it won't stop calling tipc_nl_compat_name_table_dump(), and the issue will be triggered again.
So this patch is to add the process for the err returned from cmd header function in tipc_nl_compat_dumpit().
--- net/tipc/netlink_compat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/tipc/netlink_compat.c +8 -2
@@ -262,8 +262,14 @@ static int tipc_nl_compat_dumpit(structif (msg->rep_type)tipc_tlv_init (msg->rep, msg->rep_type); -if (cmd->header) - (*cmd->header)(msg); +if (cmd->header) { + err = (*cmd->header)(msg); +if (err) { +kfree_skb (msg->rep); + msg->rep =NULL ; +return err; + } + } arg =nlmsg_new (0 ,GFP_KERNEL );if (!arg) {
Greg Kroah-Hartman
maintainerPATCH 66/266 slip: make slhc_free() silently accept an error pointer
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit baf76f0c58aec435a3a864075b8f6d8ee5d1f17e upstream.
This way, slhc_free() accepts what slhc_init() returns, whether that is an error or not.
In particular, the pattern in sl_alloc_bufs() is
slcomp = slhc_init(16, 16);
...
slhc_free(slcomp);for the error handling path, and rather than complicate that code, just make it ok to always free what was returned by the init function.
That's what the code used to do before commit 4ab42d78e37a ("ppp, slip:
Validate VJ compression slot parameters completely") when slhc_init() just returned NULL for the error case, with no actual indication of the details of the error.
--- drivers/net/slip/slhc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/slip/slhc.c +1 -1
@@ -153,7 +153,7 @@ out_fail:void slhc_free (struct slcompress *comp) { -if ( comp ==NULLSLCOMPR ) +if (IS_ERR_OR_NULL (comp) )return ;if ( comp->tstate !=NULLSLSTATE )
Greg Kroah-Hartman
maintainerPATCH 29/266 powerpc/pseries: Use the security flags in pseries_setup_rfi_flush()
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 2e4a16161fcd324b1f9bf6cb6856529f7eaf0689 upstream.
Now that we have the security flags we can simplify the code in pseries_setup_rfi_flush() because the security flags have pessimistic defaults.
--- arch/powerpc/platforms/pseries/setup.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
arch/powerpc/platforms/pseries/setup.c +12 -15
@@ -541,30 +541,27 @@ void pseries_setup_rfi_flush(void)bool enable;long rc; -/* Enable by default */ - enable = true; - types =L1D_FLUSH_FALLBACK ; - rc =plpar_get_cpu_characteristics (&result); -if (rc ==H_SUCCESS ) { +if (rc ==H_SUCCESS )init_cpu_char_feature_flags (&result); -if (result.character &H_CPU_CHAR_L1D_FLUSH_TRIG2 ) - types |=L1D_FLUSH_MTTRIG ; -if (result.character &H_CPU_CHAR_L1D_FLUSH_ORI30 ) - types |=L1D_FLUSH_ORI ; - -if ((!(result.behaviour &H_CPU_BEHAV_L1D_FLUSH_PR )) || - (!(result.behaviour &H_CPU_BEHAV_FAVOUR_SECURITY ))) - enable = false; - } -/* * We're the guest so this doesn't apply to us, clear it to simplify * handling of it elsewhere. */ security_ftr_clear (SEC_FTR_L1D_FLUSH_HV ); + types =L1D_FLUSH_FALLBACK ; + +if (security_ftr_enabled (SEC_FTR_L1D_FLUSH_TRIG2 )) + types |=L1D_FLUSH_MTTRIG ; + +if (security_ftr_enabled (SEC_FTR_L1D_FLUSH_ORI30 )) + types |=L1D_FLUSH_ORI ; + + enable =security_ftr_enabled (SEC_FTR_FAVOUR_SECURITY ) && \ +security_ftr_enabled (SEC_FTR_L1D_FLUSH_PR ); +setup_rfi_flush (types, enable); }
Greg Kroah-Hartman
maintainerPATCH 30/266 powerpc/64s: Wire up cpu_show_spectre_v1()
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 56986016cb8cd9050e601831fe89f332b4e3c46e upstream.
Add a definition for cpu_show_spectre_v1() to override the generic version. Currently this just prints "Not affected" or "Vulnerable" based on the firmware flag.
Although the kernel does have array_index_nospec() in a few places, we haven't yet audited all the powerpc code to see where it's necessary, so for now we don't list that as a mitigation.
--- arch/powerpc/kernel/security.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/kernel/security.c +8 -0
@@ -50,3 +50,11 @@ ssize_t cpu_show_meltdown(struct devicereturn sprintf (buf,"Vulnerable\n" ); } + +ssize_t cpu_show_spectre_v1 (struct device *dev,struct device_attribute *attr,char *buf) +{ +if (!security_ftr_enabled (SEC_FTR_BNDS_CHK_SPEC_BAR )) +return sprintf (buf,"Not affected\n" ); + +return sprintf (buf,"Vulnerable\n" ); +}
Greg Kroah-Hartman
maintainerPATCH 32/266 powerpc/pseries: Fix clearing of security feature flags
In reply to Greg Kroah-HartmanFrom: Mauricio Faria de Oliveira <[email protected]>
commit 0f9bdfe3c77091e8704d2e510eb7c2c2c6cde524 upstream.
The H_CPU_BEHAV_* flags should be checked for in the 'behaviour' field of 'struct h_cpu_char_result' -- 'character' is for H_CPU_CHAR_* flags.
Found by playing around with QEMU's implementation of the hypercall:
H_CPU_CHAR=0xf000000000000000
H_CPU_BEHAV=0x0000000000000000
This clears H_CPU_BEHAV_FAVOUR_SECURITY and H_CPU_BEHAV_L1D_FLUSH_PR so pseries_setup_rfi_flush() disables 'rfi_flush'; and it also clears H_CPU_CHAR_L1D_THREAD_PRIV flag. So there is no RFI flush mitigation at all for cpu_show_meltdown() to report; but currently it does:
Original kernel:
# cat /sys/devices/system/cpu/vulnerabilities/meltdown
Mitigation: RFI FlushPatched kernel:
# cat /sys/devices/system/cpu/vulnerabilities/meltdown
Not affected H_CPU_CHAR=0x0000000000000000
H_CPU_BEHAV=0xf000000000000000
This sets H_CPU_BEHAV_BNDS_CHK_SPEC_BAR so cpu_show_spectre_v1() should report vulnerable; but currently it doesn't:
Original kernel:
# cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
Not affectedPatched kernel:
# cat /sys/devices/system/cpu/vulnerabilities/spectre_v1
Vulnerable--- arch/powerpc/platforms/pseries/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/setup.c +3 -3
@@ -524,13 +524,13 @@ static void init_cpu_char_feature_flags(* The features below are enabled by default, so we instead look to see * if firmware has *disabled* them, and clear them if so. */ -if (!(result->character &H_CPU_BEHAV_FAVOUR_SECURITY )) +if (!(result->behaviour &H_CPU_BEHAV_FAVOUR_SECURITY ))security_ftr_clear (SEC_FTR_FAVOUR_SECURITY ); -if (!(result->character &H_CPU_BEHAV_L1D_FLUSH_PR )) +if (!(result->behaviour &H_CPU_BEHAV_L1D_FLUSH_PR ))security_ftr_clear (SEC_FTR_L1D_FLUSH_PR ); -if (!(result->character &H_CPU_BEHAV_BNDS_CHK_SPEC_BAR )) +if (!(result->behaviour &H_CPU_BEHAV_BNDS_CHK_SPEC_BAR ))security_ftr_clear (SEC_FTR_BNDS_CHK_SPEC_BAR ); }
Greg Kroah-Hartman
maintainerPATCH 23/266 powerpc: Add security feature flags for Spectre/Meltdown
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 9a868f634349e62922c226834aa23e3d1329ae7f upstream.
This commit adds security feature flags to reflect the settings we receive from firmware regarding Spectre/Meltdown mitigations.
The feature names reflect the names we are given by firmware on bare metal machines. See the hostboot source for details.
Arguably these could be firmware features, but that then requires them to be read early in boot so they're available prior to asm feature patching, but we don't actually want to use them for patching. We may also want to dynamically update them in future, which would be incompatible with the way firmware features work (at the moment at least). So for now just make them separate flags.
--- arch/powerpc/include/asm/security_features.h | 65 +++++++++++++++++++++++++++ arch/powerpc/kernel/Makefile | 2 arch/powerpc/kernel/security.c | 15 ++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/security_features.h create mode 100644 arch/powerpc/kernel/security.c
arch/powerpc/include/asm/security_features.h new file +65 -0
@@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Security related feature bit definitions. +* +* Copyright 2018, Michael Ellerman, IBM Corporation. +*/ + +#ifndef _ASM_POWERPC_SECURITY_FEATURES_H +#define _ASM_POWERPC_SECURITY_FEATURES_H + + +extern unsigned long powerpc_security_features; + +static inline void security_ftr_set (unsigned long feature) +{ + powerpc_security_features |= feature; +} + +static inline void security_ftr_clear (unsigned long feature) +{ + powerpc_security_features &= ~feature; +} + +static inline bool security_ftr_enabled (unsigned long feature) +{ +return !!(powerpc_security_features & feature); +} + + +// Features indicating support for Spectre/Meltdown mitigations + +// The L1-D cache can be flushed with ori r30,r30,0 +#define SEC_FTR_L1D_FLUSH_ORI30 0x0000000000000001ull + +// The L1-D cache can be flushed with mtspr 882,r0 (aka SPRN_TRIG2) +#define SEC_FTR_L1D_FLUSH_TRIG2 0x0000000000000002ull + +// ori r31,r31,0 acts as a speculation barrier +#define SEC_FTR_SPEC_BAR_ORI31 0x0000000000000004ull + +// Speculation past bctr is disabled +#define SEC_FTR_BCCTRL_SERIALISED 0x0000000000000008ull + +// Entries in L1-D are private to a SMT thread +#define SEC_FTR_L1D_THREAD_PRIV 0x0000000000000010ull + +// Indirect branch prediction cache disabled +#define SEC_FTR_COUNT_CACHE_DISABLED 0x0000000000000020ull + + +// Features indicating need for Spectre/Meltdown mitigations + +// The L1-D cache should be flushed on MSR[HV] 1->0 transition (hypervisor to guest) +#define SEC_FTR_L1D_FLUSH_HV 0x0000000000000040ull + +// The L1-D cache should be flushed on MSR[PR] 0->1 transition (kernel to userspace) +#define SEC_FTR_L1D_FLUSH_PR 0x0000000000000080ull + +// A speculation barrier should be used for bounds checks (Spectre variant 1) +#define SEC_FTR_BNDS_CHK_SPEC_BAR 0x0000000000000100ull + +// Firmware configuration indicates user favours security over performance +#define SEC_FTR_FAVOUR_SECURITY 0x0000000000000200ull + +#endif /* _ASM_POWERPC_SECURITY_FEATURES_H */
arch/powerpc/kernel/Makefile +1 -1
@@ -40,7 +40,7 @@ obj-$(CONFIG_PPC64) += setup_64.o sys_p obj-$(CONFIG_VDSO32) += vdso32/ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o -obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o +obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o security.o obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o obj64-$(CONFIG_RELOCATABLE) += reloc_64.o obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o
arch/powerpc/kernel/security.c new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Security related flags and so on. +// +// Copyright 2018, Michael Ellerman, IBM Corporation. + +#include <linux/kernel.h> +#include <asm/security_features.h> + + +unsigned long powerpc_security_features __read_mostly = \ +SEC_FTR_L1D_FLUSH_HV | \ +SEC_FTR_L1D_FLUSH_PR | \ +SEC_FTR_BNDS_CHK_SPEC_BAR | \ +SEC_FTR_FAVOUR_SECURITY ;
Greg Kroah-Hartman
maintainerPATCH 77/266 net: stmmac: move stmmac_check_ether_addr() to driver probe
In reply to Greg Kroah-HartmanFrom: Vinod Koul <[email protected]>
[ Upstream commit b561af36b1841088552464cdc3f6371d92f17710 ]
stmmac_check_ether_addr() checks the MAC address and assigns one in driver open(). In many cases when we create slave netdevice, the dev addr is inherited from master but the master dev addr maybe NULL at that time, so move this call to driver probe so that address is always valid.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -1792,8 +1792,6 @@ static int stmmac_open(struct net_devicestruct stmmac_priv *priv =netdev_priv (dev);int ret; -stmmac_check_ether_addr (priv); -if (priv->pcs !=STMMAC_PCS_RGMII && priv->pcs !=STMMAC_PCS_TBI && priv->pcs !=STMMAC_PCS_RTBI ) { ret =stmmac_init_phy (dev);
@@ -2929,6 +2927,8 @@ int stmmac_dvr_probe(struct device *deviif (ret) goto error_hw_init; +stmmac_check_ether_addr (priv); + ndev->netdev_ops = &stmmac_netdev_ops; ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
Greg Kroah-Hartman
maintainerPATCH 78/266 ipv4: set the tcp_min_rtt_wlen range from 0 to one day
In reply to Greg Kroah-HartmanFrom: ZhangXiaoxu <[email protected]>
[ Upstream commit 19fad20d15a6494f47f85d869f00b11343ee5c78 ]
There is a UBSAN report as below:
UBSAN: Undefined behaviour in net/ipv4/tcp_input.c:2877:56 signed integer overflow: 2147483647 * 1000 cannot be represented in type 'int' CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.1.0-rc4-00058-g582549e #1 Call Trace: <IRQ> dump_stack+0x8c/0xba ubsan_epilogue+0x11/0x60 handle_overflow+0x12d/0x170 ? ttwu_do_wakeup+0x21/0x320 __ubsan_handle_mul_overflow+0x12/0x20 tcp_ack_update_rtt+0x76c/0x780 tcp_clean_rtx_queue+0x499/0x14d0 tcp_ack+0x69e/0x1240 ? __wake_up_sync_key+0x2c/0x50 ? update_group_capacity+0x50/0x680 tcp_rcv_established+0x4e2/0xe10 tcp_v4_do_rcv+0x22b/0x420 tcp_v4_rcv+0xfe8/0x1190 ip_protocol_deliver_rcu+0x36/0x180 ip_local_deliver+0x15b/0x1a0 ip_rcv+0xac/0xd0 __netif_receive_skb_one_core+0x7f/0xb0 __netif_receive_skb+0x33/0xc0 netif_receive_skb_internal+0x84/0x1c0 napi_gro_receive+0x2a0/0x300 receive_buf+0x3d4/0x2350 ? detach_buf_split+0x159/0x390 virtnet_poll+0x198/0x840 ? reweight_entity+0x243/0x4b0 net_rx_action+0x25c/0x770 __do_softirq+0x19b/0x66d irq_exit+0x1eb/0x230 do_IRQ+0x7a/0x150 common_interrupt+0xf/0xf </IRQ>
It can be reproduced by:
echo 2147483647 > /proc/sys/net/ipv4/tcp_min_rtt_wlen
--- Documentation/networking/ip-sysctl.txt | 1 + net/ipv4/sysctl_net_ipv4.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.txt +1 -0
@@ -387,6 +387,7 @@ tcp_min_rtt_wlen - INTEGER minimum RTT when it is moved to a longer path (e.g., due to traffic engineering). A longer window makes the filter more resistant to RTT inflations such as transient congestion. The unit is seconds. + Possible values: 0 - 86400 (1 day) Default: 300 tcp_moderate_rcvbuf - BOOLEAN
net/ipv4/sysctl_net_ipv4.c +4 -1
@@ -42,6 +42,7 @@ static int tcp_syn_retries_min = 1;static int tcp_syn_retries_max =MAX_TCP_SYNCNT ;static int ip_ping_group_range_min[] = {0 ,0 };static int ip_ping_group_range_max[] = {GID_T_MAX ,GID_T_MAX }; +static int one_day_secs =24 *3600 ;/* Update system visible IP port range */ static void set_local_port_range (struct net *net,int range[2 ])
@@ -597,7 +598,9 @@ static struct ctl_table ipv4_table[] = { .data = &sysctl_tcp_min_rtt_wlen, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one_day_secs }, { .procname = "tcp_low_latency",
Greg Kroah-Hartman
maintainerPATCH 80/266 powerpc/fsl: Flush branch predictor when entering KVM
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit e7aa61f47b23afbec41031bc47ca8d6cb6516abc upstream.
Switching from the guest to host is another place where the speculative accesses can be exploited. Flush the branch predictor when entering KVM.
--- arch/powerpc/kvm/bookehv_interrupts.S | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kvm/bookehv_interrupts.S +4 -0
@@ -75,6 +75,10 @@ PPC_LL r1, VCPU_HOST_STACK(r4) PPC_LL r2, HOST_R2(r1) +START_BTB_FLUSH_SECTION + BTB_FLUSH(r10) +END_BTB_FLUSH_SECTION + mfspr r10, SPRN_PID lwz r8, VCPU_HOST_PID(r4) PPC_LL r11, VCPU_SHARED(r4)
Greg Kroah-Hartman
maintainerPATCH 81/266 powerpc/fsl: Emulate SPRN_BUCSR register
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 98518c4d8728656db349f875fcbbc7c126d4c973 upstream.
In order to flush the branch predictor the guest kernel performs writes to the BUCSR register which is hypervisor privilleged. However, the branch predictor is flushed at each KVM entry, so the branch predictor has been already flushed, so just return as soon as possible to guest.
--- arch/powerpc/kvm/e500_emulate.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/kvm/e500_emulate.c +7 -0
@@ -277,6 +277,13 @@ int kvmppc_core_emulate_mtspr_e500(struc vcpu->arch.pwrmgtcr0 = spr_val;break ; +case SPRN_BUCSR : +/* +* If we are here, it means that we have already flushed the +* branch predictor, so just return to guest. +*/ +break ; +/* extra exceptions */ #ifdef CONFIG_SPE_POSSIBLE case SPRN_IVOR32 :
Greg Kroah-Hartman
maintainerPATCH 82/266 powerpc/fsl: Flush the branch predictor at each kernel entry (32 bit)
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 7fef436295bf6c05effe682c8797dfcb0deb112a upstream.
In order to protect against speculation attacks on indirect branches, the branch predictor is flushed at kernel entry to protect for the following situations:
- userspace process attacking another userspace process
- userspace process attacking the kernel Basically when the privillege level change (i.e.the kernel is entered), the branch predictor state is flushed.
--- arch/powerpc/kernel/head_booke.h | 6 ++++++ arch/powerpc/kernel/head_fsl_booke.S | 15 +++++++++++++++ 2 files changed, 21 insertions(+)
arch/powerpc/kernel/head_booke.h +6 -0
@@ -42,6 +42,9 @@ andi. r11, r11,MSR_PR ;/* check whether user or kernel */ \mr r11, r1; \ beq 1f; \ +START_BTB_FLUSH_SECTION \ + BTB_FLUSH(r11) \ +END_BTB_FLUSH_SECTION \ /* if from user, start at top of this thread's kernel stack */ \ lwz r11, THREAD_INFO-THREAD(r10); \ALLOC_STACK_FRAME (r11,THREAD_SIZE ); \
@@ -127,6 +130,9 @@stw r9,_CCR (r8 );/* save CR on stack */ \mfspr r11,exc_level_srr1;/* check whether user or kernel */ \ DO_KVM BOOKE_INTERRUPT_##intno exc_level_srr1; \ +START_BTB_FLUSH_SECTION \ + BTB_FLUSH(r10) \ +END_BTB_FLUSH_SECTION \ andi. r11,r11,MSR_PR; \ mfspr r11,SPRN_SPRG_THREAD;/* if from user, start at top of */ \ lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
arch/powerpc/kernel/head_fsl_booke.S +15 -0
@@ -451,6 +451,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) mfcr r13 stw r13, THREAD_NORMSAVE(3)(r10) DO_KVM BOOKE_INTERRUPT_DTLB_MISS SPRN_SRR1 +START_BTB_FLUSH_SECTION + mfspr r11, SPRN_SRR1 + andi. r10,r11,MSR_PR + beq 1f + BTB_FLUSH(r10) +1: +END_BTB_FLUSH_SECTION mfspr r10, SPRN_DEAR /* Get faulting address */ /* If we are faulting a kernel address, we have to use the
@@ -545,6 +552,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) mfcr r13 stw r13, THREAD_NORMSAVE(3)(r10) DO_KVM BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR1 +START_BTB_FLUSH_SECTION + mfspr r11, SPRN_SRR1 + andi. r10,r11,MSR_PR + beq 1f + BTB_FLUSH(r10) +1: +END_BTB_FLUSH_SECTION + mfspr r10, SPRN_SRR0 /* Get faulting address */ /* If we are faulting a kernel address, we have to use the
Greg Kroah-Hartman
maintainerPATCH 84/266 powerpc/fsl: Fixed warning: orphan section `__btb_flush_fixup
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 039daac5526932ec731e4499613018d263af8b3e upstream.
Fixed the following build warning:
powerpc-linux-gnu-ld: warning: orphan section __btb_flush_fixup' from arch/powerpc/kernel/head_44x.o' being placed in section `__btb_flush_fixup'.
--- arch/powerpc/kernel/head_booke.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/powerpc/kernel/head_booke.h +12 -6
@@ -31,6 +31,16 @@*/ #define THREAD_NORMSAVE (offset) (THREAD_NORMSAVES + (offset * 4)) +#ifdef CONFIG_PPC_FSL_BOOK3E +#define BOOKE_CLEAR_BTB (reg) \ +START_BTB_FLUSH_SECTION \ + BTB_FLUSH(reg) \ +END_BTB_FLUSH_SECTION +#else +#define BOOKE_CLEAR_BTB (reg) +#endif + +#define NORMAL_EXCEPTION_PROLOG (intno) \ mtspr SPRN_SPRG_WSCRATCH0, r10;/* save one register */ \mfspr r10,SPRN_SPRG_THREAD ; \
@@ -42,9 +52,7 @@ andi. r11, r11,MSR_PR ;/* check whether user or kernel */ \mr r11, r1; \ beq 1f; \ -START_BTB_FLUSH_SECTION \ - BTB_FLUSH(r11) \ -END_BTB_FLUSH_SECTION \ +BOOKE_CLEAR_BTB (r11) \/* if from user, start at top of this thread's kernel stack */ \ lwz r11, THREAD_INFO-THREAD(r10); \ALLOC_STACK_FRAME (r11,THREAD_SIZE ); \
@@ -130,9 +138,7 @@ END_BTB_FLUSH_SECTION \stw r9,_CCR (r8 );/* save CR on stack */ \mfspr r11,exc_level_srr1;/* check whether user or kernel */ \ DO_KVM BOOKE_INTERRUPT_##intno exc_level_srr1; \ -START_BTB_FLUSH_SECTION \ - BTB_FLUSH(r10) \ -END_BTB_FLUSH_SECTION \ + BOOKE_CLEAR_BTB(r10) \ andi. r11,r11,MSR_PR; \ mfspr r11,SPRN_SPRG_THREAD;/* if from user, start at top of */ \ lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
Greg Kroah-Hartman
maintainerPATCH 85/266 powerpc/fsl: Add FSL_PPC_BOOK3E as supported arch for nospectre_v2 boot arg
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit e59f5bd759b7dee57593c5b6c0441609bda5d530 upstream.
--- Documentation/kernel-parameters.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/kernel-parameters.txt +1 -1
@@ -2450,7 +2450,7 @@ bytes respectively. Such letter suffixes nohugeiomap [KNL,x86] Disable kernel huge I/O mappings. - nospectre_v2 [X86] Disable all mitigations for the Spectre variant 2 + nospectre_v2 [X86,PPC_FSL_BOOK3E] Disable all mitigations for the Spectre variant 2 (indirect branch prediction) vulnerability. System may allow data leaks with this option, which is equivalent to spectre_v2=off.
Greg Kroah-Hartman
maintainerPATCH 86/266 Documentation: Add nospectre_v1 parameter
In reply to Greg Kroah-HartmanFrom: Diana Craciun <[email protected]>
commit 26cb1f36c43ee6e89d2a9f48a5a7500d5248f836 upstream.
Currently only supported on powerpc.
--- Documentation/kernel-parameters.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/kernel-parameters.txt +4 -0
@@ -2450,6 +2450,10 @@ bytes respectively. Such letter suffixes nohugeiomap [KNL,x86] Disable kernel huge I/O mappings. + nospectre_v1 [PPC] Disable mitigations for Spectre Variant 1 (bounds + check bypass). With this option data leaks are possible + in the system. + nospectre_v2 [X86,PPC_FSL_BOOK3E] Disable all mitigations for the Spectre variant 2 (indirect branch prediction) vulnerability. System may allow data leaks with this option, which is equivalent
Greg Kroah-Hartman
maintainerPATCH 69/266 NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family.
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit 7c2bd9a39845bfb6d72ddb55ce737650271f6f96 upstream.
syzbot is reporting uninitialized value at rpc_sockaddr2uaddr() [1]. This is because syzbot is setting AF_INET6 to "struct sockaddr_in"->sin_family (which is embedded into user-visible "struct nfs_mount_data" structure) despite nfs23_validate_mount_data() cannot pass sizeof(struct sockaddr_in6) bytes of AF_INET6 address to rpc_sockaddr2uaddr().
Since "struct nfs_mount_data" structure is user-visible, we can't change "struct nfs_mount_data" to use "struct sockaddr_storage". Therefore, assuming that everybody is using AF_INET family when passing address via "struct nfs_mount_data"->addr, reject if its sin_family is not AF_INET.
[1] https://syzkaller.appspot.com/bug?id=599993614e7cbbf66bc2656a919ab2a95fb5d75c
--- fs/nfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/super.c +2 -1
@@ -2020,7 +2020,8 @@ static int nfs23_validate_mount_data(voimemcpy (sap, &data->addr,sizeof (data->addr)); args->nfs_server.addrlen =sizeof (data->addr); args->nfs_server.port =ntohs (data->addr.sin_port); -if (!nfs_verify_server_address (sap)) +if (sap->sa_family !=AF_INET || + !nfs_verify_server_address (sap)) goto out_no_address;if (!(data->flags &NFS_MOUNT_TCP ))
Greg Kroah-Hartman
maintainerPATCH 88/266 usbnet: ipheth: fix potential null pointer dereference in ipheth_carrier_set
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
commit 61c59355e0154a938b28710dfa6c1d8be2ddcefa upstream.
_dev_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference.
Fix this by moving the pointer dereference after _dev_ has been null checked.
Addresses-Coverity-ID: 1462020
--- drivers/net/usb/ipheth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/ipheth.c +4 -1
@@ -290,12 +290,15 @@ static void ipheth_sndbulk_callback(strustatic int ipheth_carrier_set (struct ipheth_device *dev) { -struct usb_device *udev = dev->udev; +struct usb_device *udev;int retval; +if (!dev)return 0 ;if (!dev->confirmed_pairing)return 0 ; + + udev = dev->udev; retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), IPHETH_CMD_CARRIER_CHECK, /* request */
Greg Kroah-Hartman
maintainerPATCH 87/266 usbnet: ipheth: prevent TX queue timeouts when device not ready
In reply to Greg Kroah-HartmanFrom: Alexander Kappner <[email protected]>
commit bb1b40c7cb863f0800a6410c7dcb86cf3f28d3b1 upstream.
iOS devices require the host to be "trusted" before servicing network packets. Establishing trust requires the user to confirm a dialog on the iOS device.Until trust is established, the iOS device will silently discard network packets from the host. Currently, the ipheth driver does not detect whether an iOS device has established trust with the host, and immediately sets up the transmit queues.
This causes the following problems:
- Kernel taint due to WARN() in netdev watchdog.
- Dmesg spam ("TX timeout").
- Disruption of user space networking activity (dhcpd, etc...) when new interface comes up but cannot be used.
- Unnecessary host and device wakeups and USB traffic
Example dmesg output:
[ 1101.319778] NETDEV WATCHDOG: eth1 (ipheth): transmit queue 0 timed out [ 1101.319817] ------------[ cut here ]------------ [ 1101.319828] WARNING: CPU: 0 PID: 0 at net/sched/sch_generic.c:316 dev_watchdog+0x20f/0x220 [ 1101.319831] Modules linked in: ipheth usbmon nvidia_drm(PO) nvidia_modeset(PO) nvidia(PO) iwlmvm mac80211 iwlwifi btusb btrtl btbcm btintel qmi_wwan bluetooth cfg80211 ecdh_generic thinkpad_acpi rfkill [last unloaded: ipheth] [ 1101.319861] CPU: 0 PID: 0 Comm: swapper/0 Tainted: P O 4.13.12.1 #1 [ 1101.319864] Hardware name: LENOVO 20ENCTO1WW/20ENCTO1WW, BIOS N1EET62W (1.35 ) 11/10/2016 [ 1101.319867] task: ffffffff81e11500 task.stack: ffffffff81e00000 [ 1101.319873] RIP: 0010:dev_watchdog+0x20f/0x220 [ 1101.319876] RSP: 0018:ffff8810a3c03e98 EFLAGS: 00010292 [ 1101.319880] RAX: 000000000000003a RBX: 0000000000000000 RCX: 0000000000000000 [ 1101.319883] RDX: ffff8810a3c15c48 RSI: ffffffff81ccbfc2 RDI: 00000000ffffffff [ 1101.319886] RBP: ffff880c04ebc41c R08: 0000000000000000 R09: 0000000000000379 [ 1101.319889] R10: 00000100696589d0 R11: 0000000000000378 R12: ffff880c04ebc000 [ 1101.319892] R13: 0000000000000000 R14: 0000000000000001 R15: ffff880c2865fc80 [ 1101.319896] FS: 0000000000000000(0000) GS:ffff8810a3c00000(0000) knlGS:0000000000000000 [ 1101.319899] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1101.319902] CR2: 00007f3ff24ac000 CR3: 0000000001e0a000 CR4: 00000000003406f0 [ 1101.319905] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1101.319908] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1101.319910] Call Trace: [ 1101.319914] <IRQ> [ 1101.319921] ? dev_graft_qdisc+0x70/0x70 [ 1101.319928] ? dev_graft_qdisc+0x70/0x70 [ 1101.319934] ? call_timer_fn+0x2e/0x170 [ 1101.319939] ? dev_graft_qdisc+0x70/0x70 [ 1101.319944] ? run_timer_softirq+0x1ea/0x440 [ 1101.319951] ? timerqueue_add+0x54/0x80 [ 1101.319956] ? enqueue_hrtimer+0x38/0xa0 [ 1101.319963] ? __do_softirq+0xed/0x2e7 [ 1101.319970] ? irq_exit+0xb4/0xc0 [ 1101.319976] ? smp_apic_timer_interrupt+0x39/0x50 [ 1101.319981] ? apic_timer_interrupt+0x8c/0xa0 [ 1101.319983] </IRQ> [ 1101.319992] ? cpuidle_enter_state+0xfa/0x2a0 [ 1101.319999] ? do_idle+0x1a3/0x1f0 [ 1101.320004] ? cpu_startup_entry+0x5f/0x70 [ 1101.320011] ? start_kernel+0x444/0x44c [ 1101.320017] ? early_idt_handler_array+0x120/0x120 [ 1101.320023] ? x86_64_start_kernel+0x145/0x154 [ 1101.320028] ? secondary_startup_64+0x9f/0x9f [ 1101.320033] Code: 20 04 00 00 eb 9f 4c 89 e7 c6 05 59 44 71 00 01 e8 a7 df fd ff 89 d9 4c 89 e6 48 c7 c7 70 b7 cd 81 48 89 c2 31 c0 e8 97 64 90 ff <0f> ff eb bf 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 [ 1101.320103] ---[ end trace 0cc4d251e2b57080 ]--- [ 1101.320110] ipheth 1-5:4.2: ipheth_tx_timeout: TX timeout
The last message "TX timeout" is repeated every 5 seconds until trust is established or the device is disconnected, filling up dmesg.
The proposed patch eliminates the problem by, upon connection, keeping the TX queue and carrier disabled until a packet is first received from the iOS device. This is reflected by the confirmed_pairing variable in the device structure. Only after at least one packet has been received from the iOS device, the transmit queue and carrier are brought up during the periodic device poll in ipheth_carrier_set. Because the iOS device will always send a packet immediately upon trust being established, this should not delay the interface becoming useable. To prevent failed UBRs in ipheth_rcvbulk_callback from perpetually re-enabling the queue if it was disabled, a new check is added so only successful transfers re-enable the queue, whereas failed transfers only trigger an immediate poll.
This has the added benefit of removing the periodic control requests to the iOS device until trust has been established and thus should reduce wakeup events on both the host and the iOS device.
--- drivers/net/usb/ipheth.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/net/usb/ipheth.c +21 -9
@@ -148,6 +148,7 @@ struct ipheth_device {u8 bulk_in;u8 bulk_out;struct delayed_work carrier_work; +bool confirmed_pairing; };static int ipheth_rx_submit (struct ipheth_device *dev,gfp_t mem_flags);
@@ -259,7 +260,7 @@ static void ipheth_rcvbulk_callback(stru dev->net->stats.rx_packets++; dev->net->stats.rx_bytes += len; - + dev->confirmed_pairing = true;netif_rx (skb);ipheth_rx_submit (dev,GFP_ATOMIC ); }
@@ -280,14 +281,21 @@ static void ipheth_sndbulk_callback(strudev_err (&dev->intf->dev,"%s: urb status: %d\n" , __func__, status); -netif_wake_queue (dev->net); +if (status ==0 ) +netif_wake_queue (dev->net); +else +// on URB error, trigger immediate poll +schedule_delayed_work (&dev->carrier_work,0 ); }static int ipheth_carrier_set (struct ipheth_device *dev) {struct usb_device *udev = dev->udev;int retval; - +if (!dev) +return 0 ; +if (!dev->confirmed_pairing) +return 0 ; retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), IPHETH_CMD_CARRIER_CHECK, /* request */
@@ -302,11 +310,14 @@ static int ipheth_carrier_set(struct iphreturn retval; } -if (dev->ctrl_buf[0 ] ==IPHETH_CARRIER_ON ) +if (dev->ctrl_buf[0 ] ==IPHETH_CARRIER_ON ) {netif_carrier_on (dev->net); -else +if (dev->tx_urb->status != -EINPROGRESS ) +netif_wake_queue (dev->net); + }else {netif_carrier_off (dev->net); - +netif_stop_queue (dev->net); + }return 0 ; }
@@ -386,7 +397,6 @@ static int ipheth_open(struct net_devicereturn retval;schedule_delayed_work (&dev->carrier_work,IPHETH_CARRIER_CHECK_TIMEOUT ); -netif_start_queue (net);return retval; }
@@ -489,7 +499,7 @@ static int ipheth_probe(struct usb_inter dev->udev = udev; dev->net = netdev; dev->intf = intf; - + dev->confirmed_pairing = false;/* Set up endpoints */ hintf =usb_altnum_to_altsetting (intf,IPHETH_ALT_INTFNUM );if (hintf ==NULL ) {
@@ -540,7 +550,9 @@ static int ipheth_probe(struct usb_inter retval = -EIO ; goto err_register_netdev; } - +// carrier down and transmit queues stopped until packet from device +netif_carrier_off (netdev); +netif_tx_stop_all_queues (netdev);dev_info (&intf->dev,"Apple iPhone USB Ethernet device attached\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 89/266 qlcnic: Avoid potential NULL pointer dereference
In reply to Greg Kroah-Hartman[ Upstream commit 5bf7295fe34a5251b1d241b9736af4697b590670 ]
netdev_alloc_skb can fail and return a NULL pointer which is dereferenced without a check. The patch avoids such a scenario.
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +2 -0
@@ -1038,6 +1038,8 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode)for (i =0 ; i <QLCNIC_NUM_ILB_PKT ; i++) { skb =netdev_alloc_skb (adapter->netdev,QLCNIC_ILB_PKT_SIZE ); +if (!skb) +break ;qlcnic_create_loopback_buff (skb->data, adapter->mac_addr);skb_put (skb,QLCNIC_ILB_PKT_SIZE ); adapter->ahw->diag_cnt =0 ;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 90/266 netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING
In reply to Greg Kroah-Hartman[ Upstream commit e166e4fdaced850bee3d5ee12a5740258fb30587 ]
Since Commit 21d1196a35f5 ("ipv4: set transport header earlier"), skb->transport_header has been always set before entering INET netfilter. This patch is to set skb->transport_header for bridge before entering INET netfilter by bridge-nf-call-iptables.
It also fixes an issue that sctp_error() couldn't compute a right csum due to unset skb->transport_header.
--- net/bridge/br_netfilter_hooks.c | 1 + net/bridge/br_netfilter_ipv6.c | 2 ++ 2 files changed, 3 insertions(+)
net/bridge/br_netfilter_hooks.c +1 -0
@@ -507,6 +507,7 @@ static unsigned int br_nf_pre_routing(void *priv, nf_bridge->ipv4_daddr =ip_hdr (skb)->daddr; skb->protocol =htons (ETH_P_IP ); + skb->transport_header = skb->network_header +ip_hdr (skb)->ihl *4 ; NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb, skb->dev, NULL,
net/bridge/br_netfilter_ipv6.c +2 -0
@@ -237,6 +237,8 @@ unsigned int br_nf_pre_routing_ipv6(void *priv, nf_bridge->ipv6_daddr =ipv6_hdr (skb)->daddr; skb->protocol =htons (ETH_P_IPV6 ); + skb->transport_header = skb->network_header +sizeof (struct ipv6hdr ); +NF_HOOK (NFPROTO_IPV6 ,NF_INET_PRE_ROUTING , state->net, state->sk, skb, skb->dev,NULL , br_nf_pre_routing_finish_ipv6);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 92/266 usb: gadget: net2280: Fix overrun of OUT messages
In reply to Greg Kroah-Hartman[ Upstream commit 9d6a54c1430647355a5e23434881b2ca3d192b48 ]
The OUT endpoint normally blocks (NAK) subsequent packets when a short packet was received and returns an incomplete queue entry to the gadget driver. Thereby the gadget driver can detect a short packet when reading queue entries with a length that is not equal to a multiple of packet size.
The start_queue() function enables receiving OUT packets regardless of the content of the OUT FIFO. This results in a race: With the current code, it's possible that the "!ep->is_in && (readl(&ep->regs->ep_stat) & BIT(NAK_OUT_PACKETS))" test in start_dma() will fail, then a short packet will be received, and then start_queue() will call stop_out_naking(). That's what we don't want (OUT naking gets turned off while there is data in the FIFO) because then the next driver request might receive a mixture of old and new packets.
With the patch, this race can't occur because the FIFO's state is tested after we know that OUT naking is already turned on, and OUT naking is stopped only when both of the conditions are met. This ensures that all received data is delivered to the gadget driver, which can detect a short packet now before new packets are appended to the last short packet.
--- drivers/usb/gadget/udc/net2280.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/udc/net2280.c +1 -3
@@ -870,9 +870,6 @@ static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma) (void )readl (&ep->dev->pci->pcimstctl);writel (BIT (DMA_START ), &dma->dmastat); - -if (!ep->is_in) -stop_out_naking (ep); }static void start_dma (struct net2280_ep *ep,struct net2280_request *req)
@@ -911,6 +908,7 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)writel (BIT (DMA_START ), &dma->dmastat);return ; } +stop_out_naking (ep); } tmp = dmactl_default;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 93/266 usb: gadget: net2280: Fix net2280_dequeue()
In reply to Greg Kroah-Hartman[ Upstream commit f1d3fba17cd4eeea20397f1324b7b9c69a6a935c ]
When a request must be dequeued with net2280_dequeue() e.g. due to a device clear action and the same request is finished by the function scan_dma_completions() then the function net2280_dequeue() does not find the request in the following search loop and returns the error -EINVAL without restoring the status ep->stopped. Thus the endpoint keeps blocked and does not receive any data anymore.
This fix restores the status and does not issue an error message.
--- drivers/usb/gadget/udc/net2280.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/net2280.c +2 -2
@@ -1270,9 +1270,9 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)break ; }if (&req->req != _req) { + ep->stopped = stopped;spin_unlock_irqrestore (&ep->dev->lock, flags); -dev_err (&ep->dev->pdev->dev,"%s: Request mismatch\n" , - __func__); +ep_dbg (ep->dev,"%s: Request mismatch\n" , __func__);return -EINVAL ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 95/266 ARM: dts: pfla02: increase phy reset duration
In reply to Greg Kroah-Hartman[ Upstream commit 032f85c9360fb1a08385c584c2c4ed114b33c260 ]
Increase the reset duration to ensure correct phy functionality. The reset duration is taken from barebox commit 52fdd510de ("ARM: dts:
pfla02: use long enough reset for ethernet phy"):
Use a longer reset time for ethernet phy Micrel KSZ9031RNX. Otherwise a small percentage of modules have 'transmission timeouts' errors like
barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ ifup eth0
warning: No MAC address set. Using random address 7e:94:4d:02:f8:f3
eth0: 1000Mbps full duplex link detected
eth0: transmission timeout
T eth0: transmission timeout
T eth0: transmission timeout
T eth0: transmission timeout
T eth0: transmission timeout
--- arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi +1 -0
@@ -90,6 +90,7 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet>; phy-mode = "rgmii"; + phy-reset-duration = <10>; /* in msecs */ phy-reset-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>; phy-supply = <&vdd_eth_io_reg>; status = "disabled";
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 70/266 netfilter: ebtables: CONFIG_COMPAT: drop a bogus WARN_ON
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
commit 7caa56f006e9d712b44f27b32520c66420d5cbc6 upstream.
It means userspace gave us a ruleset where there is some other data after the ebtables target but before the beginning of the next rule.
--- net/bridge/netfilter/ebtables.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/netfilter/ebtables.c +2 -1
@@ -2046,7 +2046,8 @@ static int ebt_size_mwt(struct compat_ebif (match_kern) match_kern->match_size = ret; -if (WARN_ON (type ==EBT_COMPAT_TARGET && size_left)) +/* rule should have no remaining data after target */ +if (type ==EBT_COMPAT_TARGET && size_left)return -EINVAL ; match32 = (struct compat_ebt_entry_mwt *) buf;
Greg Kroah-Hartman
maintainerPATCH 96/266 net: ks8851: Dequeue RX packets explicitly
In reply to Greg Kroah-Hartman[ Upstream commit 536d3680fd2dab5c39857d62a3e084198fc74ff9 ]
The ks8851 driver lets the chip auto-dequeue received packets once they have been read in full. It achieves that by setting the ADRFE flag in the RXQCR register ("Auto-Dequeue RXQ Frame Enable").
However if allocation of a packet's socket buffer or retrieval of the packet over the SPI bus fails, the packet will not have been read in full and is not auto-dequeued. Such partial retrieval of a packet confuses the chip's RX queue management: On the next RX interrupt, the first packet read from the queue will be the one left there previously and this one can be retrieved without issues. But for any newly received packets, the frame header status and byte count registers (RXFHSR and RXFHBCR) contain bogus values, preventing their retrieval.
The chip allows explicitly dequeueing a packet from the RX queue by setting the RRXEF flag in the RXQCR register ("Release RX Error Frame"). This could be used to dequeue the packet in case of an error, but if that error is a failed SPI transfer, it is unknown if the packet was transferred in full and was auto-dequeued or if it was only transferred in part and requires an explicit dequeue. The safest approach is thus to always dequeue packets explicitly and forgo auto-dequeueing.
Without this change, I've witnessed packet retrieval break completely when an SPI DMA transfer fails, requiring a chip reset. Explicit dequeueing magically fixes this and makes packet retrieval absolutely robust for me.
The chip's documentation suggests auto-dequeuing and uses the RRXEF flag only to dequeue error frames which the driver doesn't want to retrieve. But that seems to be a fair-weather approach.
--- drivers/net/ethernet/micrel/ks8851.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/micrel/ks8851.c +4 -4
@@ -547,9 +547,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)/* set dma read address */ ks8851_wrreg16 (ks,KS_RXFDPR ,RXFDPR_RXFPAI |0x00 ); -/* start the packet dma process, and set auto-dequeue rx */ -ks8851_wrreg16 (ks,KS_RXQCR , - ks->rc_rxqcr |RXQCR_SDA |RXQCR_ADRFE ); +/* start DMA access */ +ks8851_wrreg16 (ks,KS_RXQCR , ks->rc_rxqcr |RXQCR_SDA );if (rxlen >4 ) {unsigned int rxalign;
@@ -580,7 +579,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) } } -ks8851_wrreg16 (ks,KS_RXQCR , ks->rc_rxqcr); +/* end DMA access and dequeue packet */ +ks8851_wrreg16 (ks,KS_RXQCR , ks->rc_rxqcr |RXQCR_RRXEF ); } }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 94/266 usb: gadget: net2272: Fix net2272_dequeue()
In reply to Greg Kroah-Hartman[ Upstream commit 091dacc3cc10979ab0422f0a9f7fcc27eee97e69 ]
Restore the status of ep->stopped in function net2272_dequeue().
When the given request is not found in the endpoint queue the function returns -EINVAL without restoring the state of ep->stopped. Thus the endpoint keeps blocked and does not transfer any data anymore.
This fix is only compile-tested, since we do not have a corresponding hardware. An analogous fix was tested in the sibling driver. See "usb: gadget: net2280: Fix net2280_dequeue()"
--- drivers/usb/gadget/udc/net2272.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/net2272.c +1 -0
@@ -962,6 +962,7 @@ net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)break ; }if (&req->req != _req) { + ep->stopped = stopped;spin_unlock_irqrestore (&ep->dev->lock, flags);return -EINVAL ; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 98/266 net: ks8851: Delay requesting IRQ until opened
In reply to Greg Kroah-Hartman[ Upstream commit d268f31552794abf5b6aa5af31021643411f25f5 ]
The ks8851 driver currently requests the IRQ before registering the net_device. Because the net_device name is used as IRQ name and is still "eth%d" when the IRQ is requested, it's impossibe to tell IRQs apart if multiple ks8851 chips are present. Most other drivers delay requesting the IRQ until the net_device is opened. Do the same.
The driver doesn't enable interrupts on the chip before opening the net_device and disables them when closing it, so there doesn't seem to be a need to request the IRQ already on probe.
--- drivers/net/ethernet/micrel/ks8851.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/ethernet/micrel/ks8851.c +11 -13
@@ -797,6 +797,15 @@ static void ks8851_tx_work(struct work_struct *work)static int ks8851_net_open (struct net_device *dev) {struct ks8851_net *ks =netdev_priv (dev); +int ret; + + ret =request_threaded_irq (dev->irq,NULL , ks8851_irq, +IRQF_TRIGGER_LOW |IRQF_ONESHOT , + dev->name, ks); +if (ret <0 ) { +netdev_err (dev,"failed to get irq\n" ); +return ret; + }/* lock the card, even if we may not actually be doing anything * else at the moment */
@@ -911,6 +920,8 @@ static int ks8851_net_stop(struct net_device *dev)dev_kfree_skb (txb); } +free_irq (dev->irq, ks); +return 0 ; }
@@ -1542,14 +1553,6 @@ static int ks8851_probe(struct spi_device *spi)ks8851_read_selftest (ks);ks8851_init_mac (ks); - ret =request_threaded_irq (spi->irq,NULL , ks8851_irq, -IRQF_TRIGGER_LOW |IRQF_ONESHOT , - ndev->name, ks); -if (ret <0 ) { -dev_err (&spi->dev,"failed to get irq\n" ); - goto err_irq; - } - ret =register_netdev (ndev);if (ret) {dev_err (&spi->dev,"failed to register network device\n" );
@@ -1562,11 +1565,7 @@ static int ks8851_probe(struct spi_device *spi)return 0 ; - err_netdev: -free_irq (ndev->irq, ks); - -err_irq: err_id:if (gpio_is_valid (gpio))gpio_set_value (gpio,0 );
@@ -1587,7 +1586,6 @@ static int ks8851_remove(struct spi_device *spi)dev_info (&spi->dev,"remove\n" );unregister_netdev (priv->netdev); -free_irq (spi->irq, priv);if (gpio_is_valid (priv->gpio))gpio_set_value (priv->gpio,0 );regulator_disable (priv->vdd_reg);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 99/266 net: ks8851: Set initial carrier state to down
In reply to Greg Kroah-Hartman[ Upstream commit 9624bafa5f6418b9ca5b3f66d1f6a6a2e8bf6d4c ]
The ks8851 chip's initial carrier state is down. A Link Change Interrupt is signaled once interrupts are enabled if the carrier is up.
The ks8851 driver has it backwards by assuming that the initial carrier state is up. The state is therefore misrepresented if the interface is opened with no cable attached. Fix it.
The Link Change interrupt is sometimes not signaled unless the P1MBSR register (which contains the Link Status bit) is read on ->ndo_open(). This might be a hardware erratum. Read the register by calling mii_check_link(), which has the desirable side effect of setting the carrier state to down if the cable was detached while the interface was closed.
--- drivers/net/ethernet/micrel/ks8851.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/micrel/ks8851.c +2 -0
@@ -870,6 +870,7 @@ static int ks8851_net_open(struct net_device *dev)netif_dbg (ks, ifup, ks->netdev,"network device up\n" );mutex_unlock (&ks->lock); +mii_check_link (&ks->mii);return 0 ; }
@@ -1527,6 +1528,7 @@ static int ks8851_probe(struct spi_device *spi)spi_set_drvdata (spi, ks); +netif_carrier_off (ks->netdev); ndev->if_port =IF_PORT_100BASET ; ndev->netdev_ops = &ks8851_netdev_ops; ndev->irq = spi->irq;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 100/266 net: xilinx: fix possible object reference leak
In reply to Greg Kroah-Hartman[ Upstream commit fa3a419d2f674b431d38748cb58fb7da17ee8949 ]
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
./drivers/net/ethernet/xilinx/xilinx_axienet_main.c:1624:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1569, but without a corresponding object release within this function.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -0
@@ -1595,12 +1595,14 @@ static int axienet_probe(struct platform_device *pdev) ret =of_address_to_resource (np,0 , &dmares);if (ret) {dev_err (&pdev->dev,"unable to get DMA resource\n" ); +of_node_put (np); goto free_netdev; } lp->dma_regs =devm_ioremap_resource (&pdev->dev, &dmares);if (IS_ERR (lp->dma_regs)) {dev_err (&pdev->dev,"could not map DMA regs\n" ); ret =PTR_ERR (lp->dma_regs); +of_node_put (np); goto free_netdev; } lp->rx_irq =irq_of_parse_and_map (np,1 );
Signature · 9 lines
2.19.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 102/266 net: ethernet: ti: fix possible object reference leak
In reply to Greg Kroah-Hartman[ Upstream commit 75eac7b5f68b0a0671e795ac636457ee27cc11d8 ]
The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
./drivers/net/ethernet/ti/netcp_ethss.c:3661:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3654, but without a corresponding object release within this function. ./drivers/net/ethernet/ti/netcp_ethss.c:3665:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3654, but without a corresponding object release within this function.
--- drivers/net/ethernet/ti/netcp_ethss.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/netcp_ethss.c +6 -2
@@ -3122,12 +3122,16 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, ret =netcp_txpipe_init (&gbe_dev->tx_pipe, netcp_device, gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); -if (ret) +if (ret) { +of_node_put (interfaces);return ret; + } ret =netcp_txpipe_open (&gbe_dev->tx_pipe); -if (ret) +if (ret) { +of_node_put (interfaces);return ret; + }/* Create network interfaces */ INIT_LIST_HEAD (&gbe_dev->gbe_intf_head);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 104/266 usb: u132-hcd: fix resource leak
In reply to Greg Kroah-Hartman[ Upstream commit f276e002793cdb820862e8ea8f76769d56bba575 ]
if platform_driver_register fails, cleanup the allocated resource gracefully.
--- drivers/usb/host/u132-hcd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/host/u132-hcd.c +3 -0
@@ -3214,6 +3214,9 @@ static int __init u132_hcd_init(void)printk (KERN_INFO "driver %s\n" , hcd_name); workqueue =create_singlethread_workqueue ("u132" ); retval =platform_driver_register (&u132_platform_driver); +if (retval) +destroy_workqueue (workqueue); +return retval; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 105/266 ceph: fix use-after-free on symlink traversal
In reply to Greg Kroah-Hartman[ Upstream commit daf5cc27eed99afdea8d96e71b89ba41f5406ef6 ]
free the symlink body after the same RCU delay we have for freeing the struct inode itself, so that traversal during RCU pathwalk wouldn't step into freed memory.
--- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +1 -1
@@ -474,6 +474,7 @@ static void ceph_i_callback(struct rcu_head *head) struct inode *inode = container_of(head, struct inode, i_rcu);struct ceph_inode_info *ci =ceph_inode (inode); +kfree (ci->i_symlink);kmem_cache_free (ceph_inode_cachep, ci); }
@@ -505,7 +506,6 @@ void ceph_destroy_inode(struct inode *inode)ceph_put_snap_realm (mdsc, realm); } -kfree (ci->i_symlink);while ((n =rb_first (&ci->i_fragtree)) !=NULL ) { frag = rb_entry(n, struct ceph_inode_frag, node);rb_erase (n, &ci->i_fragtree);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 71/266 tipc: check bearer name with right length in tipc_nl_compat_bearer_enable
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
commit 6f07e5f06c8712acc423485f657799fc8e11e56c upstream.
Syzbot reported the following crash:
BUG: KMSAN: uninit-value in memchr+0xce/0x110 lib/string.c:961 memchr+0xce/0x110 lib/string.c:961 string_is_valid net/tipc/netlink_compat.c:176 [inline] tipc_nl_compat_bearer_enable+0x2c4/0x910 net/tipc/netlink_compat.c:401 __tipc_nl_compat_doit net/tipc/netlink_compat.c:321 [inline] tipc_nl_compat_doit+0x3aa/0xaf0 net/tipc/netlink_compat.c:354 tipc_nl_compat_handle net/tipc/netlink_compat.c:1162 [inline] tipc_nl_compat_recv+0x1ae7/0x2750 net/tipc/netlink_compat.c:1265 genl_family_rcv_msg net/netlink/genetlink.c:601 [inline] genl_rcv_msg+0x185f/0x1a60 net/netlink/genetlink.c:626 netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2477 genl_rcv+0x63/0x80 net/netlink/genetlink.c:637 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] netlink_unicast+0xf3e/0x1020 net/netlink/af_netlink.c:1336 netlink_sendmsg+0x127f/0x1300 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:622 [inline] sock_sendmsg net/socket.c:632 [inline]
Uninit was created at:
__alloc_skb+0x309/0xa20 net/core/skbuff.c:208 alloc_skb include/linux/skbuff.h:1012 [inline] netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline] netlink_sendmsg+0xb82/0x1300 net/netlink/af_netlink.c:1892 sock_sendmsg_nosec net/socket.c:622 [inline] sock_sendmsg net/socket.c:632 [inline]
It was triggered when the bearer name size < TIPC_MAX_BEARER_NAME, it would check with a wrong len/TLV_GET_DATA_LEN(msg->req), which also includes priority and disc_domain length.
This patch is to fix it by checking it with a right length:
'TLV_GET_DATA_LEN(msg->req) - offsetof(struct tipc_bearer_config, name)'.
--- net/tipc/netlink_compat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/tipc/netlink_compat.c +6 -1
@@ -388,7 +388,12 @@ static int tipc_nl_compat_bearer_enable(if (!bearer)return -EMSGSIZE ; - len =min_t (int,TLV_GET_DATA_LEN (msg->req),TIPC_MAX_BEARER_NAME ); + len =TLV_GET_DATA_LEN (msg->req); + len -= offsetof(struct tipc_bearer_config , name); +if (len <=0 ) +return -EINVAL ; + + len =min_t (int, len,TIPC_MAX_BEARER_NAME );if (!string_is_valid (b->name, len))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 107/266 libata: fix using DMA buffers on stack
In reply to Greg Kroah-Hartman[ Upstream commit dd08a8d9a66de4b54575c294a92630299f7e0fe7 ]
When CONFIG_VMAP_STACK=y, __pa() returns incorrect physical address for a stack virtual address. Stack DMA buffers must be avoided.
--- drivers/ata/libata-zpodd.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/ata/libata-zpodd.c +24 -10
@@ -51,38 +51,52 @@ static int eject_tray(struct ata_device *dev)/* Per the spec, only slot type and drawer type ODD can be supported */ static enum odd_mech_type zpodd_get_mech_type (struct ata_device *dev) { -char buf[16 ]; +char *buf;unsigned int ret; -struct rm_feature_desc *desc = (void *)(buf +8 ); +struct rm_feature_desc *desc;struct ata_taskfile tf;static const char cdb[] = {GPCMD_GET_CONFIGURATION ,2 ,/* only 1 feature descriptor requested */ 0 ,3 ,/* 3, removable medium feature */ 0 ,0 ,0 ,/* reserved */ -0 ,sizeof (buf), +0 ,16 ,0 ,0 ,0 , }; + buf =kzalloc (16 ,GFP_KERNEL ); +if (!buf) +return ODD_MECH_TYPE_UNSUPPORTED ; + desc = (void *)(buf +8 ); +ata_tf_init (dev, &tf); tf.flags =ATA_TFLAG_ISADDR |ATA_TFLAG_DEVICE ; tf.command =ATA_CMD_PACKET ; tf.protocol =ATAPI_PROT_PIO ; - tf.lbam =sizeof (buf); + tf.lbam =16 ; ret =ata_exec_internal (dev, &tf, cdb,DMA_FROM_DEVICE , - buf,sizeof (buf),0 ); -if (ret) + buf,16 ,0 ); +if (ret) { +kfree (buf);return ODD_MECH_TYPE_UNSUPPORTED ; + } -if (be16_to_cpu (desc->feature_code) !=3 ) +if (be16_to_cpu (desc->feature_code) !=3 ) { +kfree (buf);return ODD_MECH_TYPE_UNSUPPORTED ; + } -if (desc->mech_type ==0 && desc->load ==0 && desc->eject ==1 ) +if (desc->mech_type ==0 && desc->load ==0 && desc->eject ==1 ) { +kfree (buf);return ODD_MECH_TYPE_SLOT ; -else if (desc->mech_type ==1 && desc->load ==0 && desc->eject ==1 ) + }else if (desc->mech_type ==1 && desc->load ==0 && + desc->eject ==1 ) { +kfree (buf);return ODD_MECH_TYPE_DRAWER ; -else + }else { +kfree (buf);return ODD_MECH_TYPE_UNSUPPORTED ; + } }/* Test if ODD is zero power ready by sense code */
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 108/266 kconfig/[mn]conf: handle backspace (^H) key
In reply to Greg Kroah-Hartman[ Upstream commit 9c38f1f044080392603c497ecca4d7d09876ff99 ]
Backspace is not working on some terminal emulators which do not send the key code defined by terminfo. Terminals either send '^H' (8) or '^?' (127). But currently only '^?' is handled. Let's also handle '^H' for those terminals.
--- scripts/kconfig/lxdialog/inputbox.c | 3 ++- scripts/kconfig/nconf.c | 2 +- scripts/kconfig/nconf.gui.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +2 -1
@@ -126,7 +126,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int widthcase KEY_DOWN :break ;case KEY_BACKSPACE : -case 127 : +case 8 :/* ^H */ +case 127 :/* ^? */ if (pos) {wattrset (dialog, dlg.inputbox.atr);if (input_x ==0 ) {
scripts/kconfig/nconf.c +1 -1
@@ -1046,7 +1046,7 @@ static int do_match(int key, struct match_state *state, int *ans) state->match_direction =FIND_NEXT_MATCH_UP ; *ans =get_mext_match (state->pattern, state->match_direction); - }else if (key ==KEY_BACKSPACE || key ==127 ) { + }else if (key ==KEY_BACKSPACE || key ==8 || key ==127 ) { state->pattern[strlen (state->pattern)-1 ] ='\0' ;adj_match_dir (&state->match_direction); }else
scripts/kconfig/nconf.gui.c +2 -1
@@ -439,7 +439,8 @@ int dialog_inputbox(WINDOW *main_window,case KEY_F (F_EXIT ):case KEY_F (F_BACK ):break ; -case 127 : +case 8 :/* ^H */ +case 127 :/* ^? */ case KEY_BACKSPACE :if (cursor_position >0 ) { memmove(&result[cursor_position-1],
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerPATCH 111/266 ipv4: ip_do_fragment: Preserve skb_iif during fragmentation
In reply to Greg Kroah-HartmanFrom: Shmulik Ladkani <[email protected]>
[ Upstream commit d2f0c961148f65bc73eda72b9fa3a4e80973cb49 ]
Previously, during fragmentation after forwarding, skb->skb_iif isn't preserved, i.e. 'ip_copy_metadata' does not copy skb_iif from given 'from' skb.
As a result, ip_do_fragment's creates fragments with zero skb_iif, leading to inconsistent behavior.
Assume for example an eBPF program attached at tc egress (post forwarding) that examines __sk_buff->ingress_ifindex:
- the correct iif is observed if forwarding path does not involve fragmentation/refragmentation
- a bogus iif is observed if forwarding path involves fragmentation/refragmentatiom
Fix, by preserving skb_iif during 'ip_copy_metadata'.
--- net/ipv4/ip_output.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/ip_output.c +1 -0
@@ -475,6 +475,7 @@ static void ip_copy_metadata(struct sk_b to->pkt_type = from->pkt_type; to->priority = from->priority; to->protocol = from->protocol; + to->skb_iif = from->skb_iif;skb_dst_drop (to);skb_dst_copy (to, from); to->dev = from->dev;
Greg Kroah-Hartman
maintainerPATCH 72/266 tipc: check link name with right length in tipc_nl_compat_link_set
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
commit 8c63bf9ab4be8b83bd8c34aacfd2f1d2c8901c8a upstream.
A similar issue as fixed by Patch "tipc: check bearer name with right length in tipc_nl_compat_bearer_enable" was also found by syzbot in tipc_nl_compat_link_set().
The length to check with should be 'TLV_GET_DATA_LEN(msg->req) - offsetof(struct tipc_link_config, name)'.
--- net/tipc/netlink_compat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/tipc/netlink_compat.c +6 -1
@@ -738,7 +738,12 @@ static int tipc_nl_compat_link_set(struc lc = (struct tipc_link_config *)TLV_DATA (msg->req); - len =min_t (int,TLV_GET_DATA_LEN (msg->req),TIPC_MAX_LINK_NAME ); + len =TLV_GET_DATA_LEN (msg->req); + len -= offsetof(struct tipc_link_config , name); +if (len <=0 ) +return -EINVAL ; + + len =min_t (int, len,TIPC_MAX_LINK_NAME );if (!string_is_valid (lc->name, len))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 73/266 bpf: reject wrong sized filters earlier
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
commit f7bd9e36ee4a4ce38e1cddd7effe6c0d9943285b upstream.
Add a bpf_check_basics_ok() and reject filters that are of invalid size much earlier, so we don't do any useless work such as invoking bpf_prog_alloc(). Currently, rejection happens in bpf_check_classic() only, but it's really unnecessarily late and they should be rejected at earliest point. While at it, also clean up one bpf_prog_size() to make it consistent with the remaining invocations.
--- net/core/filter.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
net/core/filter.c +15 -8
@@ -742,6 +742,17 @@ static bool chk_code_allowed(u16 code_toreturn codes[code_to_probe]; } +static bool bpf_check_basics_ok (const struct sock_filter *filter, +unsigned int flen) +{ +if (filter ==NULL ) +return false; +if (flen ==0 || flen >BPF_MAXINSNS ) +return false; + +return true; +} +/** * bpf_check_classic - verify socket filter code * @filter: filter to verify
@@ -762,9 +773,6 @@ static int bpf_check_classic(const strucbool anc_found;int pc; -if (flen ==0 || flen >BPF_MAXINSNS ) -return -EINVAL ; -/* Check the filter code now */ for (pc =0 ; pc < flen; pc++) {const struct sock_filter *ftest = &filter[pc];
@@ -1057,7 +1065,7 @@ int bpf_prog_create(struct bpf_prog **pfstruct bpf_prog *fp;/* Make sure new filter is there and in the right amounts. */ -if (fprog->filter ==NULL ) +if (!bpf_check_basics_ok (fprog->filter, fprog->len))return -EINVAL ; fp =bpf_prog_alloc (bpf_prog_size (fprog->len),0 );
@@ -1104,7 +1112,7 @@ int bpf_prog_create_from_user(struct bpfint err;/* Make sure new filter is there and in the right amounts. */ -if (fprog->filter ==NULL ) +if (!bpf_check_basics_ok (fprog->filter, fprog->len))return -EINVAL ; fp =bpf_prog_alloc (bpf_prog_size (fprog->len),0 );
@@ -1184,7 +1192,6 @@ int __sk_attach_filter(struct sock_fprog bool locked) {unsigned int fsize =bpf_classic_proglen (fprog); -unsigned int bpf_fsize =bpf_prog_size (fprog->len);struct bpf_prog *prog;int err;
@@ -1192,10 +1199,10 @@ int __sk_attach_filter(struct sock_fprogreturn -EPERM ;/* Make sure new filter is there and in the right amounts. */ -if (fprog->filter ==NULL ) +if (!bpf_check_basics_ok (fprog->filter, fprog->len))return -EINVAL ; - prog =bpf_prog_alloc (bpf_fsize,0 ); + prog =bpf_prog_alloc (bpf_prog_size (fprog->len),0 );if (!prog)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 74/266 Revert "block/loop: Use global lock for ioctl() operation."
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
This reverts commit b3f3107fbd928fed6e4fecbe3da2ed5f43216439 which is commit 310ca162d779efee8a2dc3731439680f3e9c1e86 upstream.
Jan Kara has reported seeing problems with this patch applied, as has Salvatore Bonaccorso, so let's drop it for now.
--- drivers/block/loop.c | 42 +++++++++++++++++++++--------------------- drivers/block/loop.h | 1 + 2 files changed, 22 insertions(+), 21 deletions(-)
drivers/block/loop.c +21 -21
@@ -82,7 +82,6 @@static DEFINE_IDR (loop_index_idr);static DEFINE_MUTEX (loop_index_mutex); -static DEFINE_MUTEX (loop_ctl_mutex);static int max_part;static int part_shift;
@@ -1045,7 +1044,7 @@ static int loop_clr_fd(struct loop_devic*/ if (atomic_read (&lo->lo_refcnt) >1 ) { lo->lo_flags |=LO_FLAGS_AUTOCLEAR ; -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);return 0 ; }
@@ -1094,12 +1093,12 @@ static int loop_clr_fd(struct loop_devicif (!part_shift) lo->lo_disk->flags |=GENHD_FL_NO_PART_SCAN ;loop_unprepare_queue (lo); -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);/* -* Need not hold loop_ctl_mutex to fput backing file. -* Calling fput holding loop_ctl_mutex triggers a circular +* Need not hold lo_ctl_mutex to fput backing file. +* Calling fput holding lo_ctl_mutex triggers a circular * lock dependency possibility warning as fput can take -* bd_mutex which is usually taken before loop_ctl_mutex. +* bd_mutex which is usually taken before lo_ctl_mutex. */ fput (filp);return 0 ;
@@ -1362,7 +1361,7 @@ static int lo_ioctl(struct block_devicestruct loop_device *lo = bdev->bd_disk->private_data;int err; -mutex_lock_nested (&loop_ctl_mutex,1 ); +mutex_lock_nested (&lo->lo_ctl_mutex,1 );switch (cmd) {case LOOP_SET_FD : err =loop_set_fd (lo, mode, bdev, arg);
@@ -1371,7 +1370,7 @@ static int lo_ioctl(struct block_device err =loop_change_fd (lo, bdev, arg);break ;case LOOP_CLR_FD : -/* loop_clr_fd would have unlocked loop_ctl_mutex on success */ +/* loop_clr_fd would have unlocked lo_ctl_mutex on success */ err =loop_clr_fd (lo);if (!err) goto out_unlocked;
@@ -1407,7 +1406,7 @@ static int lo_ioctl(struct block_devicedefault : err = lo->ioctl ? lo->ioctl (lo, cmd, arg) : -EINVAL ; } -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex); out_unlocked:return err;
@@ -1540,16 +1539,16 @@ static int lo_compat_ioctl(struct block_switch (cmd) {case LOOP_SET_STATUS : -mutex_lock (&loop_ctl_mutex); +mutex_lock (&lo->lo_ctl_mutex); err =loop_set_status_compat ( lo, (const struct compat_loop_info __user *) arg); -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);break ;case LOOP_GET_STATUS : -mutex_lock (&loop_ctl_mutex); +mutex_lock (&lo->lo_ctl_mutex); err =loop_get_status_compat ( lo, (struct compat_loop_info __user *) arg); -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);break ;case LOOP_SET_CAPACITY :case LOOP_CLR_FD :
@@ -1593,7 +1592,7 @@ static void __lo_release(struct loop_devif (atomic_dec_return (&lo->lo_refcnt))return ; -mutex_lock (&loop_ctl_mutex); +mutex_lock (&lo->lo_ctl_mutex);if (lo->lo_flags &LO_FLAGS_AUTOCLEAR ) {/* * In autoclear mode, stop the loop thread
@@ -1610,7 +1609,7 @@ static void __lo_release(struct loop_devloop_flush (lo); } -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex); }static void lo_release (struct gendisk *disk,fmode_t mode)
@@ -1656,10 +1655,10 @@ static int unregister_transfer_cb(int idstruct loop_device *lo = ptr;struct loop_func_table *xfer = data; -mutex_lock (&loop_ctl_mutex); +mutex_lock (&lo->lo_ctl_mutex);if (lo->lo_encryption == xfer)loop_release_xfer (lo); -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);return 0 ; }
@@ -1821,6 +1820,7 @@ static int loop_add(struct loop_device *if (!part_shift) disk->flags |=GENHD_FL_NO_PART_SCAN ; disk->flags |=GENHD_FL_EXT_DEVT ; +mutex_init (&lo->lo_ctl_mutex);atomic_set (&lo->lo_refcnt,0 ); lo->lo_number = i;spin_lock_init (&lo->lo_lock);
@@ -1933,19 +1933,19 @@ static long loop_control_ioctl(struct fi ret =loop_lookup (&lo, parm);if (ret <0 )break ; -mutex_lock (&loop_ctl_mutex); +mutex_lock (&lo->lo_ctl_mutex);if (lo->lo_state != Lo_unbound) { ret = -EBUSY ; -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);break ; }if (atomic_read (&lo->lo_refcnt) >0 ) { ret = -EBUSY ; -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);break ; } lo->lo_disk->private_data =NULL ; -mutex_unlock (&loop_ctl_mutex); +mutex_unlock (&lo->lo_ctl_mutex);idr_remove (&loop_index_idr, lo->lo_number);loop_remove (lo);break ;
drivers/block/loop.h +1 -0
@@ -55,6 +55,7 @@ struct loop_device {spinlock_t lo_lock;int lo_state; +struct mutex lo_ctl_mutex;struct kthread_worker worker;struct task_struct *worker_task;bool use_dio;
Greg Kroah-Hartman
maintainerPATCH 75/266 ipv4: add sanity checks in ipv4_link_failure()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 20ff83f10f113c88d0bb74589389b05250994c16 ]
Before calling __ip_options_compile(), we need to ensure the network header is a an IPv4 one, and that it is already pulled in skb->head.
RAW sockets going through a tunnel can end up calling ipv4_link_failure() with total garbage in the skb, or arbitrary lengthes.
syzbot report :
BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:355 [inline]
BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0x294/0x1120 net/ipv4/ip_options.c:123
Write of size 69 at addr ffff888096abf068 by task syz-executor.4/9204
CPU: 0 PID: 9204 Comm: syz-executor.4 Not tainted 5.1.0-rc5+ #77
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
check_memory_region_inline mm/kasan/generic.c:185 [inline]
check_memory_region+0x123/0x190 mm/kasan/generic.c:191
memcpy+0x38/0x50 mm/kasan/common.c:133
memcpy include/linux/string.h:355 [inline]
__ip_options_echo+0x294/0x1120 net/ipv4/ip_options.c:123
__icmp_send+0x725/0x1400 net/ipv4/icmp.c:695
ipv4_link_failure+0x29f/0x550 net/ipv4/route.c:1204
dst_link_failure include/net/dst.h:427 [inline]
vti6_xmit net/ipv6/ip6_vti.c:514 [inline]
vti6_tnl_xmit+0x10d4/0x1c0c net/ipv6/ip6_vti.c:553
__netdev_start_xmit include/linux/netdevice.h:4414 [inline]
netdev_start_xmit include/linux/netdevice.h:4423 [inline]
xmit_one net/core/dev.c:3292 [inline]
dev_hard_start_xmit+0x1b2/0x980 net/core/dev.c:3308
__dev_queue_xmit+0x271d/0x3060 net/core/dev.c:3878
dev_queue_xmit+0x18/0x20 net/core/dev.c:3911
neigh_direct_output+0x16/0x20 net/core/neighbour.c:1527
neigh_output include/net/neighbour.h:508 [inline]
ip_finish_output2+0x949/0x1740 net/ipv4/ip_output.c:229
ip_finish_output+0x73c/0xd50 net/ipv4/ip_output.c:317
NF_HOOK_COND include/linux/netfilter.h:278 [inline]
ip_output+0x21f/0x670 net/ipv4/ip_output.c:405
dst_output include/net/dst.h:444 [inline]
NF_HOOK include/linux/netfilter.h:289 [inline]
raw_send_hdrinc net/ipv4/raw.c:432 [inline]
raw_sendmsg+0x1d2b/0x2f20 net/ipv4/raw.c:663
inet_sendmsg+0x147/0x5d0 net/ipv4/af_inet.c:798
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xdd/0x130 net/socket.c:661
sock_write_iter+0x27c/0x3e0 net/socket.c:988
call_write_iter include/linux/fs.h:1866 [inline]
new_sync_write+0x4c7/0x760 fs/read_write.c:474
__vfs_write+0xe4/0x110 fs/read_write.c:487
vfs_write+0x20c/0x580 fs/read_write.c:549
ksys_write+0x14f/0x2d0 fs/read_write.c:599
__do_sys_write fs/read_write.c:611 [inline]
__se_sys_write fs/read_write.c:608 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:608
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x458c29
Code: ad b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f293b44bc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000458c29
RDX: 0000000000000014 RSI: 00000000200002c0 RDI: 0000000000000003
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f293b44c6d4
R13: 00000000004c8623 R14: 00000000004ded68 R15: 00000000ffffffff
The buggy address belongs to the page:
page:ffffea00025aafc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x1fffc0000000000()
raw: 01fffc0000000000 0000000000000000 ffffffff025a0101 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888096abef80: 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 f2
ffff888096abf000: f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888096abf080: 00 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00
^
ffff888096abf100: 00 00 00 00 f1 f1 f1 f1 00 00 f3 f3 00 00 00 00
ffff888096abf180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00--- net/ipv4/route.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
net/ipv4/route.c +24 -10
@@ -1162,25 +1162,39 @@ static struct dst_entry *ipv4_dst_check(return dst; } -static void ipv4_link_failure (struct sk_buff *skb) +static void ipv4_send_dest_unreach (struct sk_buff *skb) {struct ip_options opt; -struct rtable *rt;int res;/* Recompile ip options since IPCB may not be valid anymore. +* Also check we have a reasonable ipv4 header. */ -memset (&opt,0 ,sizeof (opt)); - opt.optlen =ip_hdr (skb)->ihl*4 -sizeof (struct iphdr ); - -rcu_read_lock (); - res =__ip_options_compile (dev_net (skb->dev), &opt, skb,NULL ); -rcu_read_unlock (); - -if (res) +if (!pskb_network_may_pull (skb,sizeof (struct iphdr )) || +ip_hdr (skb)->version !=4 ||ip_hdr (skb)->ihl <5 )return ; +memset (&opt,0 ,sizeof (opt)); +if (ip_hdr (skb)->ihl >5 ) { +if (!pskb_network_may_pull (skb,ip_hdr (skb)->ihl *4 )) +return ; + opt.optlen =ip_hdr (skb)->ihl *4 -sizeof (struct iphdr ); + +rcu_read_lock (); + res =__ip_options_compile (dev_net (skb->dev), &opt, skb,NULL ); +rcu_read_unlock (); + +if (res) +return ; + }__icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_HOST_UNREACH ,0 , &opt); +} + +static void ipv4_link_failure (struct sk_buff *skb) +{ +struct rtable *rt; + +ipv4_send_dest_unreach (skb); rt =skb_rtable (skb);if (rt)
Greg Kroah-Hartman
maintainerPATCH 114/266 bnxt_en: Improve multicast address setup logic.
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit b4e30e8e7ea1d1e35ffd64ca46f7d9a7f227b4bf ]
The driver builds a list of multicast addresses and sends it to the firmware when the driver's ndo_set_rx_mode() is called. In rare cases, the firmware can fail this call if internal resources to add multicast addresses are exhausted. In that case, we should try the call again by setting the ALL_MCAST flag which is more guaranteed to succeed.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -1
@@ -4957,8 +4957,15 @@ static int bnxt_cfg_rx_mode(struct bnxt skip_uc: rc =bnxt_hwrm_cfa_l2_set_rx_mask (bp,0 ); +if (rc && vnic->mc_list_count) { +netdev_info (bp->dev,"Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n" , + rc); + vnic->rx_mask |=CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST ; + vnic->mc_list_count =0 ; + rc =bnxt_hwrm_cfa_l2_set_rx_mask (bp,0 ); + }if (rc) -netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %x\n" , +netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %d\n" , rc);return rc;
Greg Kroah-Hartman
maintainerPATCH 123/266 bonding: show full hw address in sysfs for slave entries
In reply to Greg Kroah-Hartman[ Upstream commit 18bebc6dd3281955240062655a4df35eef2c46b3 ]
Bond expects ethernet hwaddr for its slave, but it can be longer than 6 bytes - infiniband interface for example.
# cat /sys/devices/<skipped>/net/ib0/address 80:00:02:08:fe:80:00:00:00:00:00:00:7c:fe:90:03:00:be:5d:e1
# cat /sys/devices/<skipped>/net/ib0/bonding_slave/perm_hwaddr 80:00:02:08:fe:80
So print full hwaddr in sysfs "bonding_slave/perm_hwaddr" as well.
--- drivers/net/bonding/bond_sysfs_slave.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_sysfs_slave.c +3 -1
@@ -55,7 +55,9 @@ static SLAVE_ATTR_RO(link_failure_count);static ssize_t perm_hwaddr_show (struct slave *slave,char *buf) { -return sprintf (buf,"%pM\n" , slave->perm_hwaddr); +return sprintf (buf,"%*phC\n" , + slave->dev->addr_len, + slave->perm_hwaddr); }static SLAVE_ATTR_RO (perm_hwaddr);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 124/266 jffs2: fix use-after-free on symlink traversal
In reply to Greg Kroah-Hartman[ Upstream commit 4fdcfab5b5537c21891e22e65996d4d0dd8ab4ca ]
free the symlink body after the same RCU delay we have for freeing the struct inode itself, so that traversal during RCU pathwalk wouldn't step into freed memory.
--- fs/jffs2/readinode.c | 5 ----- fs/jffs2/super.c | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-)
fs/jffs2/readinode.c +0 -5
@@ -1414,11 +1414,6 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)jffs2_kill_fragtree (&f->fragtree, deleted?c:NULL ); -if (f->target) { -kfree (f->target); - f->target =NULL ; - } - fds = f->dents;while (fds) { fd = fds;
fs/jffs2/super.c +4 -1
@@ -47,7 +47,10 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)static void jffs2_i_callback (struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); -kmem_cache_free (jffs2_inode_cachep,JFFS2_INODE_INFO (inode)); +struct jffs2_inode_info *f =JFFS2_INODE_INFO (inode); + +kfree (f->target); +kmem_cache_free (jffs2_inode_cachep, f); }static void jffs2_destroy_inode (struct inode *inode)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 126/266 rtc: da9063: set uie_unsupported when relevant
In reply to Greg Kroah-Hartman[ Upstream commit 882c5e552ffd06856de42261460f46e18319d259 ]
The DA9063AD doesn't support alarms on any seconds and its granularity is the minute. Set uie_unsupported in that case.
--- drivers/rtc/rtc-da9063.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/rtc/rtc-da9063.c +7 -0
@@ -491,6 +491,13 @@ static int da9063_rtc_probe(struct platform_device *pdev)da9063_data_to_tm (data, &rtc->alarm_time, rtc); rtc->rtc_sync = false; +/* +* TODO: some models have alarms on a minute boundary but still support +* real hardware interrupts. Add this once the core supports it. +*/ +if (config->rtc_data_start !=RTC_SEC ) + rtc->rtc_dev->uie_unsupported =1 ; + irq_alarm =platform_get_irq_byname (pdev,"ALARM" ); ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL, da9063_alarm_event,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 127/266 vfio/pci: use correct format characters
In reply to Greg Kroah-Hartman[ Upstream commit 426b046b748d1f47e096e05bdcc6fb4172791307 ]
When compiling with -Wformat, clang emits the following warnings:
drivers/vfio/pci/vfio_pci.c:1601:5: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice, ^~~~~~
drivers/vfio/pci/vfio_pci.c:1601:13: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~
drivers/vfio/pci/vfio_pci.c:1601:21: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~~~~
drivers/vfio/pci/vfio_pci.c:1601:32: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~~~~
drivers/vfio/pci/vfio_pci.c:1605:5: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice, ^~~~~~
drivers/vfio/pci/vfio_pci.c:1605:13: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~
drivers/vfio/pci/vfio_pci.c:1605:21: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~~~~
drivers/vfio/pci/vfio_pci.c:1605:32: warning: format specifies type
'unsigned short' but the argument has type 'unsigned int' [-Wformat]
vendor, device, subvendor, subdevice,
^~~~~~~~~
The types of these arguments are unconditionally defined, so this patch updates the format character to the correct ones for unsigned ints.
--- drivers/vfio/pci/vfio_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci.c +2 -2
@@ -1191,11 +1191,11 @@ static void __init vfio_pci_fill_ids(void) rc =pci_add_dynid (&vfio_pci_driver, vendor, device, subvendor, subdevice, class, class_mask,0 );if (rc) -pr_warn ("failed to add dynamic id [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x (%d)\n" , +pr_warn ("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n" , vendor, device, subvendor, subdevice, class, class_mask, rc);else -pr_info ("add [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x\n" , +pr_info ("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n" , vendor, device, subvendor, subdevice, class, class_mask); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 128/266 scsi: storvsc: Fix calculation of sub-channel count
In reply to Greg Kroah-Hartman[ Upstream commit 382e06d11e075a40b4094b6ef809f8d4bcc7ab2a ]
When the number of sub-channels offered by Hyper-V is >= the number of CPUs in the VM, calculate the correct number of sub-channels. The current code produces one too many.
This scenario arises only when the number of CPUs is artificially restricted (for example, with maxcpus=<n> on the kernel boot line), because Hyper-V normally offers a sub-channel count < number of CPUs. While the current code doesn't break, the extra sub-channel is unbalanced across the CPUs (for example, a total of 5 channels on a VM with 4 CPUs).
--- drivers/scsi/storvsc_drv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/storvsc_drv.c +11 -2
@@ -613,13 +613,22 @@ static void handle_sc_creation(struct vmbus_channel *new_sc)static void handle_multichannel_storage (struct hv_device *device,int max_chns) {struct storvsc_device *stor_device; -int num_cpus =num_online_cpus ();int num_sc;struct storvsc_cmd_request *request;struct vstor_packet *vstor_packet;int ret, t; - num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns); +/* +* If the number of CPUs is artificially restricted, such as +* with maxcpus=1 on the kernel boot line, Hyper-V could offer +* sub-channels >= the number of CPUs. These sub-channels +* should not be created. The primary channel is already created +* and assigned to one CPU, so check against # CPUs - 1. +*/ + num_sc =min ((int )(num_online_cpus () -1 ), max_chns); +if (!num_sc) +return ; + stor_device =get_out_stor_device (device);if (!stor_device)return ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 129/266 net: hns: Use NAPI_POLL_WEIGHT for hns driver
In reply to Greg Kroah-Hartman[ Upstream commit acb1ce15a61154aa501891d67ebf79bc9ea26818 ]
When the HNS driver loaded, always have an error print:
"netif_napi_add() called with weight 256"
This is because the kernel checks the NAPI polling weights requested by drivers and it prints an error message if a driver requests a weight bigger than 64.
So use NAPI_POLL_WEIGHT to fix it.
--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/hisilicon/hns/hns_enet.c +2 -5
@@ -28,9 +28,6 @@#define SERVICE_TIMER_HZ (1 * HZ) -#define NIC_TX_CLEAN_MAX_NUM 256 -#define NIC_RX_CLEAN_MAX_NUM 64 -#define RCB_IRQ_NOT_INITED 0#define RCB_IRQ_INITED 1
@@ -1408,7 +1405,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) rd->fini_process = hns_nic_tx_fini_pro;netif_napi_add (priv->netdev, &rd->napi, - hns_nic_common_poll,NIC_TX_CLEAN_MAX_NUM ); + hns_nic_common_poll,NAPI_POLL_WEIGHT ); rd->ring->irq_init_flag =RCB_IRQ_NOT_INITED ; }for (i = h->q_num; i < h->q_num *2 ; i++) {
@@ -1420,7 +1417,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) rd->fini_process = hns_nic_rx_fini_pro;netif_napi_add (priv->netdev, &rd->napi, - hns_nic_common_poll,NIC_RX_CLEAN_MAX_NUM ); + hns_nic_common_poll,NAPI_POLL_WEIGHT ); rd->ring->irq_init_flag =RCB_IRQ_NOT_INITED ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 132/266 xsysace: Fix error handling in ace_setup
In reply to Greg Kroah-Hartman[ Upstream commit 47b16820c490149c2923e8474048f2c6e7557cab ]
If xace hardware reports a bad version number, the error handling code in ace_setup() calls put_disk(), followed by queue cleanup. However, since the disk data structure has the queue pointer set, put_disk() also cleans and releases the queue. This results in blk_cleanup_queue() accessing an already released data structure, which in turn may result in a crash such as the following.
[ 10.681671] BUG: Kernel NULL pointer dereference at 0x00000040 [ 10.681826] Faulting instruction address: 0xc0431480 [ 10.682072] Oops: Kernel access of bad area, sig: 11 [#1] [ 10.682251] BE PAGE_SIZE=4K PREEMPT Xilinx Virtex440 [ 10.682387] Modules linked in: [ 10.682528] CPU: 0 PID: 1 Comm: swapper Tainted: G W 5.0.0-rc6-next-20190218+ #2 [ 10.682733] NIP: c0431480 LR: c043147c CTR: c0422ad8 [ 10.682863] REGS: cf82fbe0 TRAP: 0300 Tainted: G W (5.0.0-rc6-next-20190218+) [ 10.683065] MSR: 00029000 <CE,EE,ME> CR: 22000222 XER: 00000000 [ 10.683236] DEAR: 00000040 ESR: 00000000 [ 10.683236] GPR00: c043147c cf82fc90 cf82ccc0 00000000 00000000 00000000 00000002 00000000 [ 10.683236] GPR08: 00000000 00000000 c04310bc 00000000 22000222 00000000 c0002c54 00000000 [ 10.683236] GPR16: 00000000 00000001 c09aa39c c09021b0 c09021dc 00000007 c0a68c08 00000000 [ 10.683236] GPR24: 00000001 ced6d400 ced6dcf0 c0815d9c 00000000 00000000 00000000 cedf0800 [ 10.684331] NIP [c0431480] blk_mq_run_hw_queue+0x28/0x114 [ 10.684473] LR [c043147c] blk_mq_run_hw_queue+0x24/0x114 [ 10.684602] Call Trace: [ 10.684671] [cf82fc90] [c043147c] blk_mq_run_hw_queue+0x24/0x114 (unreliable) [ 10.684854] [cf82fcc0] [c04315bc] blk_mq_run_hw_queues+0x50/0x7c [ 10.685002] [cf82fce0] [c0422b24] blk_set_queue_dying+0x30/0x68 [ 10.685154] [cf82fcf0] [c0423ec0] blk_cleanup_queue+0x34/0x14c [ 10.685306] [cf82fd10] [c054d73c] ace_probe+0x3dc/0x508 [ 10.685445] [cf82fd50] [c052d740] platform_drv_probe+0x4c/0xb8 [ 10.685592] [cf82fd70] [c052abb0] really_probe+0x20c/0x32c [ 10.685728] [cf82fda0] [c052ae58] driver_probe_device+0x68/0x464 [ 10.685877] [cf82fdc0] [c052b500] device_driver_attach+0xb4/0xe4 [ 10.686024] [cf82fde0] [c052b5dc] __driver_attach+0xac/0xfc [ 10.686161] [cf82fe00] [c0528428] bus_for_each_dev+0x80/0xc0 [ 10.686314] [cf82fe30] [c0529b3c] bus_add_driver+0x144/0x234 [ 10.686457] [cf82fe50] [c052c46c] driver_register+0x88/0x15c [ 10.686610] [cf82fe60] [c09de288] ace_init+0x4c/0xac [ 10.686742] [cf82fe80] [c0002730] do_one_initcall+0xac/0x330 [ 10.686888] [cf82fee0] [c09aafd0] kernel_init_freeable+0x34c/0x478 [ 10.687043] [cf82ff30] [c0002c6c] kernel_init+0x18/0x114 [ 10.687188] [cf82ff40] [c000f2f0] ret_from_kernel_thread+0x14/0x1c [ 10.687349] Instruction dump: [ 10.687435] 3863ffd4 4bfffd70 9421ffd0 7c0802a6 93c10028 7c9e2378 93e1002c 38810008 [ 10.687637] 7c7f1b78 90010034 4bfffc25 813f008c <81290040> 75290100 4182002c 80810008 [ 10.688056] ---[ end trace 13c9ff51d41b9d40 ]---
Fix the problem by setting the disk queue pointer to NULL before calling put_disk(). A more comprehensive fix might be to rearrange the code to check the hardware version before initializing data structures, but I don't know if this would have undesirable side effects, and it would increase the complexity of backporting the fix to older kernels.
--- drivers/block/xsysace.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/xsysace.c +2 -0
@@ -1062,6 +1062,8 @@ static int ace_setup(struct ace_device *ace)return 0 ; err_read: +/* prevent double queue cleanup */ + ace->gd->queue =NULL ;put_disk (ace->gd); err_alloc_disk:blk_cleanup_queue (ace->queue);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 115/266 packet: validate msg_namelen in send directly
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 486efdc8f6ce802b27e15921d2353cc740c55451 ]
Packet sockets in datagram mode take a destination address. Verify its length before passing to dev_hard_header.
Prior to 2.6.14-rc3, the send code ignored sll_halen. This is established behavior. Directly compare msg_namelen to dev->addr_len.
Change v1->v2: initialize addr in all paths
--- net/packet/af_packet.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/packet/af_packet.c +14 -9
@@ -2490,8 +2490,8 @@ static int tpacket_snd(struct packet_socvoid *ph; DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name);bool need_wait = !(msg->msg_flags &MSG_DONTWAIT ); +unsigned char *addr =NULL ;int tp_len, size_max; -unsigned char *addr;int len_sum =0 ;int status =TP_STATUS_AVAILABLE ;int hlen, tlen;
@@ -2511,10 +2511,13 @@ static int tpacket_snd(struct packet_soc sll_addr))) goto out; proto = saddr->sll_protocol; - addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (&po->sk), saddr->sll_ifindex); -if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out_put; +if (po->sk.sk_socket->type ==SOCK_DGRAM ) { +if (dev && msg->msg_namelen < dev->addr_len + + offsetof(struct sockaddr_ll , sll_addr)) + goto out_put; + addr = saddr->sll_addr; + } } err = -ENXIO ;
@@ -2652,7 +2655,7 @@ static int packet_snd(struct socket *socstruct sk_buff *skb;struct net_device *dev;__be16 proto; -unsigned char *addr; +unsigned char *addr =NULL ;int err, reserve =0 ;struct sockcm_cookie sockc;struct virtio_net_hdr vnet_hdr = {0 };
@@ -2672,7 +2675,6 @@ static int packet_snd(struct socket *socif (likely (saddr ==NULL )) { dev =packet_cached_dev_get (po); proto = po->num; - addr =NULL ; }else { err = -EINVAL ;if (msg->msg_namelen <sizeof (struct sockaddr_ll ))
@@ -2680,10 +2682,13 @@ static int packet_snd(struct socket *socif (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll , sll_addr))) goto out; proto = saddr->sll_protocol; - addr = saddr->sll_halen ? saddr->sll_addr :NULL ; dev =dev_get_by_index (sock_net (sk), saddr->sll_ifindex); -if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out_unlock; +if (sock->type ==SOCK_DGRAM ) { +if (dev && msg->msg_namelen < dev->addr_len + + offsetof(struct sockaddr_ll , sll_addr)) + goto out_unlock; + addr = saddr->sll_addr; + } } err = -ENXIO ;
Greg Kroah-Hartman
maintainerPATCH 133/266 ARM: orion: dont use using 64-bit DMA masks
In reply to Greg Kroah-Hartman[ Upstream commit cd92d74d67c811dc22544430b9ac3029f5bd64c5 ]
clang warns about statically defined DMA masks from the DMA_BIT_MASK macro with length 64:
arch/arm/plat-orion/common.c:625:29: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
.coherent_dma_mask = DMA_BIT_MASK(64),
^~~~~~~~~~~~~~~~include/linux/dma-mapping.h:141:54: note: expanded from macro 'DMA_BIT_MASK'
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
The ones in orion shouldn't really be 64 bit masks, so changing them to what the driver can support avoids the warning.
--- arch/arm/plat-orion/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-orion/common.c +2 -2
@@ -645,7 +645,7 @@ static struct platform_device orion_xor0_shared = { .resource = orion_xor0_shared_resources, .dev = { .dma_mask = &orion_xor_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(64), + .coherent_dma_mask = DMA_BIT_MASK(32), .platform_data = &orion_xor0_pdata, }, };
@@ -706,7 +706,7 @@ static struct platform_device orion_xor1_shared = { .resource = orion_xor1_shared_resources, .dev = { .dma_mask = &orion_xor_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(64), + .coherent_dma_mask = DMA_BIT_MASK(32), .platform_data = &orion_xor1_pdata, }, };
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 135/266 usb: usbip: fix isoc packet num validation in get_pipe
In reply to Greg Kroah-Hartmancommit c409ca3be3c6ff3a1eeb303b191184e80d412862 upstream.
Backport of the upstream commit, which fixed c6688ef9f297. c6688ef9f297 got backported as commit b6f826ba10dc, as the unavailable function usb_endpoint_maxp_mult had to be replaced. The upstream commit removed the call to this function, so the backport is straightforward.
Original commit message:
Change the validation of number_of_packets in get_pipe to compare the number of packets to a fixed maximum number of packets allowed, set to be 1024. This number was chosen due to it being used by other drivers as well, for example drivers/usb/host/uhci-q.c
Background/reason:
The get_pipe function in stub_rx.c validates the number of packets in isochronous mode and aborts with an error if that number is too large, in order to prevent malicious input from possibly triggering large memory allocations. This was previously done by checking whether pdu->u.cmd_submit.number_of_packets is bigger than the number of packets that would be needed for pdu->u.cmd_submit.transfer_buffer_length bytes if all except possibly the last packet had maximum length, given by usb_endpoint_maxp(epd) * usb_endpoint_maxp_mult(epd). This leads to an error if URBs with packets shorter than the maximum possible length are submitted, which is allowed according to Documentation/driver-api/usb/URB.rst and occurs for example with the snd-usb-audio driver.
--- drivers/usb/usbip/stub_rx.c | 18 +++--------------- drivers/usb/usbip/usbip_common.h | 7 +++++++ 2 files changed, 10 insertions(+), 15 deletions(-)
drivers/usb/usbip/stub_rx.c +3 -15
@@ -380,22 +380,10 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu) }if (usb_endpoint_xfer_isoc (epd)) { -/* validate packet size and number of packets */ -unsigned int maxp, packets, bytes; - -#define USB_EP_MAXP_MULT_SHIFT 11 -#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT) -#define USB_EP_MAXP_MULT (m) \ - (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT) - - maxp =usb_endpoint_maxp (epd); - maxp *= (USB_EP_MAXP_MULT ( -__le16_to_cpu (epd->wMaxPacketSize)) +1 ); - bytes = pdu->u.cmd_submit.transfer_buffer_length; - packets =DIV_ROUND_UP (bytes, maxp); - +/* validate number of packets */ if (pdu->u.cmd_submit.number_of_packets <0 || - pdu->u.cmd_submit.number_of_packets > packets) { + pdu->u.cmd_submit.number_of_packets > +USBIP_MAX_ISO_PACKETS ) {dev_err (&sdev->udev->dev,"CMD_SUBMIT: isoc invalid num packets %d\n" , pdu->u.cmd_submit.number_of_packets);
drivers/usb/usbip/usbip_common.h +7 -0
@@ -134,6 +134,13 @@ extern struct device_attribute dev_attr_usbip_debug;#define USBIP_DIR_OUT 0x00#define USBIP_DIR_IN 0x01 +/* +* Arbitrary limit for the maximum number of isochronous packets in an URB, +* compare for example the uhci_submit_isochronous function in +* drivers/usb/host/uhci-q.c +*/ +#define USBIP_MAX_ISO_PACKETS 1024 +/** * struct usbip_header_basic - data pertinent to every request * @command: the usbip request type
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 136/266 staging: iio: adt7316: allow adt751x to use internal vref for all dacs
In reply to Greg Kroah-HartmanFrom: Jeremy Fertic <[email protected]>
commit 10bfe7cc1739c22f0aa296b39e53f61e9e3f4d99 upstream.
With adt7516/7/9, internal vref is available for dacs a and b, dacs c and d, or all dacs. The driver doesn't currently support internal vref for all dacs. Change the else if to an if so both bits are checked rather than just one or the other.
--- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/addac/adt7316.c +1 -1
@@ -1092,7 +1092,7 @@ static ssize_t adt7316_store_DAC_interna ldac_config = chip->ldac_config & (~ADT7516_DAC_IN_VREF_MASK );if (data &0x1 ) ldac_config |=ADT7516_DAC_AB_IN_VREF ; -else if (data &0x2 ) +if (data &0x2 ) ldac_config |=ADT7516_DAC_CD_IN_VREF ; }else { ret =kstrtou8 (buf,16 , &data);
Greg Kroah-Hartman
maintainerPATCH 138/266 staging: iio: adt7316: fix the dac write calculation
In reply to Greg Kroah-HartmanFrom: Jeremy Fertic <[email protected]>
commit 78accaea117c1ae878774974fab91ac4a0b0e2b0 upstream.
The lsb calculation is not masking the correct bits from the user input. Subtract 1 from (1 << offset) to correctly set up the mask to be applied to user input.
The lsb register stores its value starting at the bit 7 position. adt7316_store_DAC() currently assumes the value is at the other end of the register. Shift the lsb value before storing it in a new variable lsb_reg, and write this variable to the lsb register.
--- drivers/staging/iio/addac/adt7316.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/staging/iio/addac/adt7316.c +7 -3
@@ -1453,7 +1453,7 @@ static ssize_t adt7316_show_DAC(struct astatic ssize_t adt7316_store_DAC (struct adt7316_chip_info *chip,int channel,const char *buf,size_t len) { -u8 msb, lsb, offset; +u8 msb, lsb, lsb_reg, offset;u16 data;int ret;
@@ -1471,9 +1471,13 @@ static ssize_t adt7316_store_DAC(structreturn -EINVAL ;if (chip->dac_bits >8 ) { - lsb = data & (1 << offset); + lsb = data & ((1 << offset) -1 ); +if (chip->dac_bits ==12 ) + lsb_reg = lsb <<ADT7316_DA_12_BIT_LSB_SHIFT ; +else + lsb_reg = lsb <<ADT7316_DA_10_BIT_LSB_SHIFT ; ret = chip->bus.write (chip->bus.client, -ADT7316_DA_DATA_BASE + channel *2 , lsb); +ADT7316_DA_DATA_BASE + channel *2 , lsb_reg);if (ret)return -EIO ; }
Greg Kroah-Hartman
maintainerPATCH 140/266 selinux: never allow relabeling on context mounts
In reply to Greg Kroah-HartmanFrom: Ondrej Mosnacek <[email protected]>
commit a83d6ddaebe541570291205cb538e35ad4ff94f9 upstream.
In the SECURITY_FS_USE_MNTPOINT case we never want to allow relabeling files/directories, so we should never set the SBLABEL_MNT flag. The 'special handling' in selinux_is_sblabel_mnt() is only intended for when the behavior is set to SECURITY_FS_USE_GENFS.
While there, make the logic in selinux_is_sblabel_mnt() more explicit and add a BUILD_BUG_ON() to make sure that introducing a new SECURITY_FS_USE_* forces a review of the logic.
--- security/selinux/hooks.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-)
security/selinux/hooks.c +31 -9
@@ -396,21 +396,43 @@ static int may_context_mount_inode_relabreturn rc; } -static int selinux_is_sblabel_mnt (struct super_block *sb) +static int selinux_is_genfs_special_handling (struct super_block *sb) { -struct superblock_security_struct *sbsec = sb->s_security; - -return sbsec->behavior ==SECURITY_FS_USE_XATTR || - sbsec->behavior ==SECURITY_FS_USE_TRANS || - sbsec->behavior ==SECURITY_FS_USE_TASK || - sbsec->behavior ==SECURITY_FS_USE_NATIVE || -/* Special handling. Genfs but also in-core setxattr handler */ - !strcmp (sb->s_type->name,"sysfs" ) || +/* Special handling. Genfs but also in-core setxattr handler */ +return !strcmp (sb->s_type->name,"sysfs" ) || !strcmp (sb->s_type->name,"pstore" ) || !strcmp (sb->s_type->name,"debugfs" ) || !strcmp (sb->s_type->name,"rootfs" ); } +static int selinux_is_sblabel_mnt (struct super_block *sb) +{ +struct superblock_security_struct *sbsec = sb->s_security; + +/* +* IMPORTANT: Double-check logic in this function when adding a new +* SECURITY_FS_USE_* definition! +*/ +BUILD_BUG_ON (SECURITY_FS_USE_MAX !=7 ); + +switch (sbsec->behavior) { +case SECURITY_FS_USE_XATTR : +case SECURITY_FS_USE_TRANS : +case SECURITY_FS_USE_TASK : +case SECURITY_FS_USE_NATIVE : +return 1 ; + +case SECURITY_FS_USE_GENFS : +return selinux_is_genfs_special_handling (sb); + +/* Never allow relabeling on context mounts */ +case SECURITY_FS_USE_MNTPOINT : +case SECURITY_FS_USE_NONE : +default : +return 0 ; + } +} +static int sb_finish_set_opts (struct super_block *sb) {struct superblock_security_struct *sbsec = sb->s_security;
Greg Kroah-Hartman
maintainerPATCH 142/266 media: v4l2: i2c: ov7670: Fix PLL bypass register values
In reply to Greg Kroah-HartmanFrom: Jacopo Mondi <[email protected]>
commit 61da76beef1e4f0b6ba7be4f8d0cf0dac7ce1f55 upstream.
The following commits:
commit f6dd927f34d6 ("[media] media: ov7670: calculate framerate properly for ov7675") commit 04ee6d92047e ("[media] media: ov7670: add possibility to bypass pll for ov7675") introduced the ability to bypass PLL multiplier and use input clock (xvclk) as pixel clock output frequency for ov7675 sensor.
PLL is bypassed using register DBLV[7:6], according to ov7670 and ov7675 sensor manuals. Macros used to set DBLV register seem wrong in the driver, as their values do not match what reported in the datasheet.
Fix by changing DBLV_* macros to use bits [7:6] and set bits [3:0] to default 0x0a reserved value (according to datasheets).
While at there, remove a write to DBLV register in "ov7675_set_framerate()" that over-writes the previous one to the same register that takes "info->pll_bypass" flag into account instead of setting PLL multiplier to 4x unconditionally.
And, while at there, since "info->pll_bypass" is only used in set/get_framerate() functions used by ov7675 only, it is not necessary to check for the device id at probe time to make sure that when using ov7670 "info->pll_bypass" is set to false.
--- drivers/media/i2c/ov7670.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/media/i2c/ov7670.c +6 -10
@@ -155,10 +155,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-#define REG_GFIX 0x69/* Fix gain control */ #define REG_DBLV 0x6b/* PLL control an debugging */ -#define DBLV_BYPASS 0x00/* Bypass PLL */ -#define DBLV_X4 0x01/* clock x4 */ -#define DBLV_X6 0x10/* clock x6 */ -#define DBLV_X8 0x11/* clock x8 */ +#define DBLV_BYPASS 0x0a/* Bypass PLL */ +#define DBLV_X4 0x4a/* clock x4 */ +#define DBLV_X6 0x8a/* clock x6 */ +#define DBLV_X8 0xca/* clock x8 */ #define REG_REG76 0x76/* OV's name */ #define R76_BLKPCOR 0x80/* Black pixel correction enable */
@@ -833,7 +833,7 @@ static int ov7675_set_framerate(struct vif (ret <0 )return ret; -return ov7670_write (sd,REG_DBLV ,DBLV_X4 ); +return 0 ; } static void ov7670_get_framerate_legacy(struct v4l2_subdev *sd,
@@ -1578,11 +1578,7 @@ static int ov7670_probe(struct i2c_clienif (config->clock_speed) info->clock_speed = config->clock_speed; -/* -* It should be allowed for ov7670 too when it is migrated to -* the new frame rate formula. -*/ -if (config->pll_bypass && id->driver_data !=MODEL_OV7670 ) +if (config->pll_bypass) info->pll_bypass = true;if (config->pclk_hb_disable)
Greg Kroah-Hartman
maintainerPATCH 143/266 scsi: libsas: fix a race condition when smp task timeout
In reply to Greg Kroah-HartmanFrom: Jason Yan <[email protected]>
commit b90cd6f2b905905fb42671009dc0e27c310a16ae upstream.
When the lldd is processing the complete sas task in interrupt and set the task stat as SAS_TASK_STATE_DONE, the smp timeout timer is able to be triggered at the same time. And smp_task_timedout() will complete the task wheter the SAS_TASK_STATE_DONE is set or not. Then the sas task may freed before lldd end the interrupt process. Thus a use-after-free will happen.
Fix this by calling the complete() only when SAS_TASK_STATE_DONE is not set. And remove the check of the return value of the del_timer(). Once the LLDD sets DONE, it must call task->done(), which will call smp_task_done()->complete() and the task will be completed and freed correctly.
--- drivers/scsi/libsas/sas_expander.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/libsas/sas_expander.c +4 -5
@@ -47,17 +47,16 @@ static void smp_task_timedout(unsigned lunsigned long flags;spin_lock_irqsave (&task->task_state_lock, flags); -if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) +if (!(task->task_state_flags &SAS_TASK_STATE_DONE )) { task->task_state_flags |=SAS_TASK_STATE_ABORTED ; +complete (&task->slow_task->completion); + }spin_unlock_irqrestore (&task->task_state_lock, flags); - -complete (&task->slow_task->completion); }static void smp_task_done (struct sas_task *task) { -if (!del_timer (&task->slow_task->timer)) -return ; +del_timer (&task->slow_task->timer);complete (&task->slow_task->completion); }
Greg Kroah-Hartman
maintainerPATCH 116/266 USB: yurex: Fix protection fault after device removal
In reply to Greg Kroah-HartmanFrom: Alan Stern <[email protected]>
commit ef61eb43ada6c1d6b94668f0f514e4c268093ff3 upstream.
The syzkaller USB fuzzer found a general-protection-fault bug in the yurex driver. The fault occurs when a device has been unplugged; the driver's interrupt-URB handler logs an error message referring to the device by name, after the device has been unregistered and its name deallocated.
This problem is caused by the fact that the interrupt URB isn't cancelled until the driver's private data structure is released, which can happen long after the device is gone. The cure is to make sure that the interrupt URB is killed before yurex_disconnect() returns; this is exactly the sort of thing that usb_poison_urb() was meant for.
--- drivers/usb/misc/yurex.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/misc/yurex.c +1 -0
@@ -332,6 +332,7 @@ static void yurex_disconnect(struct usb_usb_deregister_dev (interface, &yurex_class);/* prevent more I/O from starting */ +usb_poison_urb (dev->urb);mutex_lock (&dev->io_mutex); dev->interface =NULL ;mutex_unlock (&dev->io_mutex);
Greg Kroah-Hartman
maintainerPATCH 144/266 ASoC:soc-pcm:fix a codec fixup issue in TDM case
In reply to Greg Kroah-Hartman[ Upstream commit 570f18b6a8d1f0e60e8caf30e66161b6438dcc91 ]
On HDaudio platforms, if playback is started when capture is working, there is no audible output.
This can be root-caused to the use of the rx|tx_mask to store an HDaudio stream tag.
If capture is stared before playback, rx_mask would be non-zero on HDaudio platform, then the channel number of playback, which is in the same codec dai with the capture, would be changed by soc_pcm_codec_params_fixup based on the tx_mask at first, then overwritten by this function based on rx_mask at last.
According to the author of tx|rx_mask, tx_mask is for playback and rx_mask is for capture. And stream direction is checked at all other references of tx|rx_mask in ASoC, so here should be an error. This patch checks stream direction for tx|rx_mask for fixup function.
This issue would affect not only HDaudio+ASoC, but also I2S codecs if the channel number based on rx_mask is not equal to the one for tx_mask. It could be rarely reproduecd because most drivers in kernel set the same channel number to tx|rx_mask or rx_mask is zero.
Tested on all platforms using stream_tag & HDaudio and intel I2S platforms.
--- sound/soc/soc-pcm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/soc-pcm.c +5 -2
@@ -882,10 +882,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_params = *params;/* fixup params based on TDM slot masks */ -if (codec_dai->tx_mask) +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK && + codec_dai->tx_mask)soc_pcm_codec_params_fixup (&codec_params, codec_dai->tx_mask); -if (codec_dai->rx_mask) + +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE && + codec_dai->rx_mask)soc_pcm_codec_params_fixup (&codec_params, codec_dai->rx_mask);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 147/266 perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS
In reply to Greg Kroah-Hartman[ Upstream commit 583feb08e7f7ac9d533b446882eb3a54737a6dbb ]
When an event is programmed with attr.wakeup_events=N (N>0), it means the caller is interested in getting a user level notification after N samples have been recorded in the kernel sampling buffer.
With precise events on Intel processors, the kernel uses PEBS. The kernel tries minimize sampling overhead by verifying
if the event configuration is compatible with multi-entry PEBS mode. If so, the kernel is notified only when the buffer has reached its threshold. Other PEBS operates in single-entry mode, the kenrel is notified for each PEBS sample.
The problem is that the current implementation look at frequency mode and event sample_type but ignores the wakeup_events field. Thus, it may not be possible to receive a notification after each precise event.
This patch fixes this problem by disabling multi-entry PEBS if wakeup_events is non-zero.
--- arch/x86/kernel/cpu/perf_event_intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel.c +1 -1
@@ -2513,7 +2513,7 @@ static int intel_pmu_hw_config(struct perf_event *event)return ret;if (event->attr.precise_ip) { -if (!event->attr.freq) { +if (!(event->attr.freq || event->attr.wakeup_events)) { event->hw.flags |=PERF_X86_EVENT_AUTO_RELOAD ;if (!(event->attr.sample_type & ~intel_pmu_free_running_flags (event)))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 149/266 iommu/amd: Set exclusion range correctly
In reply to Greg Kroah-Hartman[ Upstream commit 3c677d206210f53a4be972211066c0f1cd47fe12 ]
The exlcusion range limit register needs to contain the base-address of the last page that is part of the range, as bits 0-11 of this register are treated as 0xfff by the hardware for comparisons.
So correctly set the exclusion range in the hardware to the last page which is _in_ the range.
--- drivers/iommu/amd_iommu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd_iommu_init.c +1 -1
@@ -295,7 +295,7 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val)static void iommu_set_exclusion_range (struct amd_iommu *iommu) {u64 start = iommu->exclusion_start &PAGE_MASK ; -u64 limit = (start + iommu->exclusion_length) &PAGE_MASK ; +u64 limit = (start + iommu->exclusion_length -1 ) &PAGE_MASK ;u64 entry;if (!iommu->exclusion_start)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 150/266 genirq: Prevent use-after-free and work list corruption
In reply to Greg Kroah-Hartman[ Upstream commit 59c39840f5abf4a71e1810a8da71aaccd6c17d26 ]
When irq_set_affinity_notifier() replaces the notifier, then the reference count on the old notifier is dropped which causes it to be freed. But nothing ensures that the old notifier is not longer queued in the work list. If it is queued this results in a use after free and possibly in work list corruption.
Ensure that the work is canceled before the reference is dropped.
--- kernel/irq/manage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/irq/manage.c +3 -1
@@ -319,8 +319,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) desc->affinity_notify = notify;raw_spin_unlock_irqrestore (&desc->lock, flags); -if (old_notify) +if (old_notify) { +cancel_work_sync (&old_notify->work);kref_put (&old_notify->kref, old_notify->release); + }return 0 ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 151/266 usb: dwc3: Fix default lpm_nyet_threshold value
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit 8d791929b2fbdf7734c1596d808e55cb457f4562 upstream.
The max possible value for DCTL.LPM_NYET_THRES is 15 and not 255. Change the default value to 15.
--- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/core.c +1 -1
@@ -867,7 +867,7 @@ static int dwc3_probe(struct platform_de dwc->regs_size =resource_size (res);/* default to highest possible threshold */ - lpm_nyet_threshold =0xff ; + lpm_nyet_threshold =0xf ;/* default to -3.5dB de-emphasis */ tx_de_emphasis =1 ;
Greg Kroah-Hartman
maintainerPATCH 152/266 scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines
In reply to Greg Kroah-HartmanFrom: Andrew Vasquez <[email protected]>
commit 5cbdae10bf11f96e30b4d14de7b08c8b490e903c upstream.
Commit e6f77540c067 ("scsi: qla2xxx: Fix an integer overflow in sysfs code") incorrectly set 'optrom_region_size' to 'start+size', which can overflow option-rom boundaries when 'start' is non-zero. Continue setting optrom_region_size to the proper adjusted value of 'size'.
--- drivers/scsi/qla2xxx/qla_attr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +2 -2
@@ -431,7 +431,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi } ha->optrom_region_start = start; - ha->optrom_region_size = start + size; + ha->optrom_region_size = size; ha->optrom_state =QLA_SREADING ; ha->optrom_buffer =vmalloc (ha->optrom_region_size);
@@ -504,7 +504,7 @@ qla2x00_sysfs_write_optrom_ctl(struct fi } ha->optrom_region_start = start; - ha->optrom_region_size = start + size; + ha->optrom_region_size = size; ha->optrom_state =QLA_SWRITING ; ha->optrom_buffer =vmalloc (ha->optrom_region_size);
Greg Kroah-Hartman
maintainerPATCH 117/266 USB: w1 ds2490: Fix bug caused by improper use of altsetting array
In reply to Greg Kroah-HartmanFrom: Alan Stern <[email protected]>
commit c114944d7d67f24e71562fcfc18d550ab787e4d4 upstream.
The syzkaller USB fuzzer spotted a slab-out-of-bounds bug in the ds2490 driver. This bug is caused by improper use of the altsetting array in the usb_interface structure (the array's entries are not always stored in numerical order), combined with a naive assumption that all interfaces probed by the driver will have the expected number of altsettings.
The bug can be fixed by replacing references to the possibly non-existent intf->altsetting[alt] entry with the guaranteed-to-exist intf->cur_altsetting entry.
--- drivers/w1/masters/ds2490.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/w1/masters/ds2490.c +3 -3
@@ -1039,15 +1039,15 @@ static int ds_probe(struct usb_interface/* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */ alt =3 ; err =usb_set_interface (dev->udev, - intf->altsetting[alt].desc.bInterfaceNumber, alt); + intf->cur_altsetting->desc.bInterfaceNumber, alt);if (err) {dev_err (&dev->udev->dev,"Failed to set alternative setting %d " "for %d interface: err=%d.\n" , alt, - intf->altsetting[alt].desc.bInterfaceNumber, err); + intf->cur_altsetting->desc.bInterfaceNumber, err); goto err_out_clear; } - iface_desc = &intf->altsetting[alt]; + iface_desc = intf->cur_altsetting;if (iface_desc->desc.bNumEndpoints !=NUM_EP -1 ) {pr_info ("Num endpoints=%d. It is not DS9490R.\n" , iface_desc->desc.bNumEndpoints);
Greg Kroah-Hartman
maintainerPATCH 154/266 Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
In reply to Greg Kroah-HartmanFrom: Marcel Holtmann <[email protected]>
commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream.
The minimum encryption key size for LE connections is 56 bits and to align LE with BR/EDR, enforce 56 bits of minimum encryption key size for BR/EDR connections as well.
--- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_conn.c | 8 ++++++++ 2 files changed, 11 insertions(+)
include/net/bluetooth/hci_core.h +3 -0
@@ -174,6 +174,9 @@ struct adv_info {#define HCI_MAX_SHORT_NAME_LENGTH 10 +/* Min encryption key size to match with SMP */ +#define HCI_MIN_ENC_KEY_SIZE 7 +/* Default LE RPA expiry time, 15 minutes */ #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
net/bluetooth/hci_conn.c +8 -0
@@ -1177,6 +1177,14 @@ int hci_conn_check_link_mode(struct hci_ !test_bit(HCI_CONN_ENCRYPT, &conn->flags))return 0 ; +/* The minimum encryption key size needs to be enforced by the +* host stack before establishing any L2CAP connections. The +* specification in theory allows a minimum of 1, but to align +* BR/EDR and LE transports, a minimum of 7 is chosen. +*/ +if (conn->enc_key_size <HCI_MIN_ENC_KEY_SIZE ) +return 0 ; +return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 155/266 UAS: fix alignment of scatter/gather segments
In reply to Greg Kroah-HartmanFrom: Oliver Neukum <[email protected]>
commit 3ae62a42090f1ed48e2313ed256a1182a85fb575 upstream.
This is the UAS version of
747668dbc061b3e62bc1982767a3a1f9815fcf0e
usb-storage: Set virt_boundary_mask to avoid SG overflows
We are not as likely to be vulnerable as storage, as it is unlikelier that UAS is run over a controller without native support for SG, but the issue exists.
The issue has been existing since the inception of the driver.
--- drivers/usb/storage/uas.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-)
drivers/usb/storage/uas.c +24 -14
@@ -772,23 +772,33 @@ static int uas_slave_alloc(struct scsi_d {struct uas_dev_info *devinfo = (struct uas_dev_info *)sdev->host->hostdata; +int maxp; sdev->hostdata = devinfo; -/* USB has unusual DMA-alignment requirements: Although the -* starting address of each scatter-gather element doesn't matter, -* the length of each element except the last must be divisible -* by the Bulk maxpacket value. There's currently no way to -* express this by block-layer constraints, so we'll cop out -* and simply require addresses to be aligned at 512-byte -* boundaries. This is okay since most block I/O involves -* hardware sectors that are multiples of 512 bytes in length, -* and since host controllers up through USB 2.0 have maxpacket -* values no larger than 512. -* -* But it doesn't suffice for Wireless USB, where Bulk maxpacket -* values can be as large as 2048. To make that work properly -* will require changes to the block layer. +/* +* We have two requirements here. We must satisfy the requirements +* of the physical HC and the demands of the protocol, as we +* definitely want no additional memory allocation in this path +* ruling out using bounce buffers. +* +* For a transmission on USB to continue we must never send +* a package that is smaller than maxpacket. Hence the length of each +* scatterlist element except the last must be divisible by the +* Bulk maxpacket value. +* If the HC does not ensure that through SG, +* the upper layer must do that. We must assume nothing +* about the capabilities off the HC, so we use the most +* pessimistic requirement. +*/ + + maxp =usb_maxpacket (devinfo->udev, devinfo->data_in_pipe,0 ); +blk_queue_virt_boundary (sdev->request_queue, maxp -1 ); + +/* +* The protocol has no requirements on alignment in the strict sense. +* Controllers may or may not have alignment restrictions. +* As this is not exported, we use an extremely conservative guess. */ blk_queue_update_dma_alignment (sdev->request_queue, (512 -1 ));
Greg Kroah-Hartman
maintainerPATCH 156/266 ipv6: fix a potential deadlock in do_ipv6_setsockopt()
In reply to Greg Kroah-HartmanFrom: WANG Cong <[email protected]>
commit 8651be8f14a12d24f203f283601d9b0418c389ff upstream.
Baozeng reported this deadlock case:
CPU0 CPU1
---- ----
lock([ 165.136033] sk_lock-AF_INET6);
lock([ 165.136033] rtnl_mutex);
lock([ 165.136033] sk_lock-AF_INET6); lock([ 165.136033] rtnl_mutex);
Similar to commit 87e9f0315952
("ipv4: fix a potential deadlock in mcast getsockopt() path") this is due to we still have a case, ipv6_sock_mc_close(), where we acquire sk_lock before rtnl_lock. Close this deadlock with the similar solution, that is always acquire rtnl lock first.
--- include/net/addrconf.h | 1 + net/ipv6/ipv6_sockglue.c | 3 ++- net/ipv6/mcast.c | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-)
include/net/addrconf.h +1 -0
@@ -162,6 +162,7 @@ int ipv6_sock_mc_join(struct sock *sk, i const struct in6_addr *addr);int ipv6_sock_mc_drop (struct sock *sk,int ifindex,const struct in6_addr *addr); +void __ipv6_sock_mc_close (struct sock *sk);void ipv6_sock_mc_close (struct sock *sk);bool inet6_mc_check (struct sock *sk,const struct in6_addr *mc_addr,const struct in6_addr *src_addr);
net/ipv6/ipv6_sockglue.c +2 -1
@@ -121,6 +121,7 @@ struct ipv6_txoptions *ipv6_update_optiostatic bool setsockopt_needs_rtnl (int optname) {switch (optname) { +case IPV6_ADDRFORM :case IPV6_ADD_MEMBERSHIP :case IPV6_DROP_MEMBERSHIP :case IPV6_JOIN_ANYCAST :
@@ -199,7 +200,7 @@ static int do_ipv6_setsockopt(struct soc }fl6_free_socklist (sk); -ipv6_sock_mc_close (sk); +__ipv6_sock_mc_close (sk);/* * Sock is moving from IPv6 to IPv4 (sk_prot), so
net/ipv6/mcast.c +12 -5
@@ -276,16 +276,14 @@ static struct inet6_dev *ip6_mc_find_devreturn idev; } -void ipv6_sock_mc_close (struct sock *sk) +void __ipv6_sock_mc_close (struct sock *sk) {struct ipv6_pinfo *np =inet6_sk (sk);struct ipv6_mc_socklist *mc_lst;struct net *net =sock_net (sk); -if (!rcu_access_pointer (np->ipv6_mc_list)) -return ; +ASSERT_RTNL (); -rtnl_lock ();while ((mc_lst =rtnl_dereference (np->ipv6_mc_list)) !=NULL ) {struct net_device *dev;
@@ -303,8 +301,17 @@ void ipv6_sock_mc_close(struct sock *sk)atomic_sub (sizeof (*mc_lst), &sk->sk_omem_alloc);kfree_rcu (mc_lst, rcu); - } +} + +void ipv6_sock_mc_close (struct sock *sk) +{ +struct ipv6_pinfo *np =inet6_sk (sk); + +if (!rcu_access_pointer (np->ipv6_mc_list)) +return ; +rtnl_lock (); +__ipv6_sock_mc_close (sk);rtnl_unlock (); }
Greg Kroah-Hartman
maintainerPATCH 159/266 netfilter: compat: initialize all fields in xt_init
In reply to Greg Kroah-Hartmancommit 8d29d16d21342a0c86405d46de0c4ac5daf1760f upstream
If a non zero value happens to be in xt[NFPROTO_BRIDGE].cur at init time, the following panic can be caused by running
% ebtables -t broute -F BROUTING
from a 32-bit user level on a 64-bit kernel. This patch replaces kmalloc_array with kcalloc when allocating xt.
[ 474.680846] BUG: unable to handle kernel paging request at 0000000009600920 [ 474.687869] PGD 2037006067 P4D 2037006067 PUD 2038938067 PMD 0 [ 474.693838] Oops: 0000 [#1] SMP [ 474.697055] CPU: 9 PID: 4662 Comm: ebtables Kdump: loaded Not tainted 4.19.17-11302235.AroraKernelnext.fc18.x86_64 #1 [ 474.707721] Hardware name: Supermicro X9DRT/X9DRT, BIOS 3.0 06/28/2013 [ 474.714313] RIP: 0010:xt_compat_calc_jump+0x2f/0x63 [x_tables] [ 474.720201] Code: 40 0f b6 ff 55 31 c0 48 6b ff 70 48 03 3d dc 45 00 00 48 89 e5 8b 4f 6c 4c 8b 47 60 ff c9 39 c8 7f 2f 8d 14 08 d1 fa 48 63 fa <41> 39 34 f8 4c 8d 0c fd 00 00 00 00 73 05 8d 42 01 eb e1 76 05 8d [ 474.739023] RSP: 0018:ffffc9000943fc58 EFLAGS: 00010207 [ 474.744296] RAX: 0000000000000000 RBX: ffffc90006465000 RCX: 0000000002580249 [ 474.751485] RDX: 00000000012c0124 RSI: fffffffff7be17e9 RDI: 00000000012c0124 [ 474.758670] RBP: ffffc9000943fc58 R08: 0000000000000000 R09: ffffffff8117cf8f [ 474.765855] R10: ffffc90006477000 R11: 0000000000000000 R12: 0000000000000001 [ 474.773048] R13: 0000000000000000 R14: ffffc9000943fcb8 R15: ffffc9000943fcb8 [ 474.780234] FS: 0000000000000000(0000) GS:ffff88a03f840000(0063) knlGS:00000000f7ac7700 [ 474.788612] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 [ 474.794632] CR2: 0000000009600920 CR3: 0000002037422006 CR4: 00000000000606e0 [ 474.802052] Call Trace: [ 474.804789] compat_do_replace+0x1fb/0x2a3 [ebtables] [ 474.810105] compat_do_ebt_set_ctl+0x69/0xe6 [ebtables] [ 474.815605] ? try_module_get+0x37/0x42 [ 474.819716] compat_nf_setsockopt+0x4f/0x6d [ 474.824172] compat_ip_setsockopt+0x7e/0x8c [ 474.828641] compat_raw_setsockopt+0x16/0x3a [ 474.833220] compat_sock_common_setsockopt+0x1d/0x24 [ 474.838458] __compat_sys_setsockopt+0x17e/0x1b1 [ 474.843343] ? __check_object_size+0x76/0x19a [ 474.847960] __ia32_compat_sys_socketcall+0x1cb/0x25b [ 474.853276] do_fast_syscall_32+0xaf/0xf6 [ 474.857548] entry_SYSENTER_compat+0x6b/0x7a
--- net/netfilter/x_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/x_tables.c +1 -1
@@ -1699,7 +1699,7 @@ static int __init xt_init(void)seqcount_init (&per_cpu (xt_recseq, i)); } - xt =kmalloc (sizeof (struct xt_af ) *NFPROTO_NUMPROTO ,GFP_KERNEL ); + xt =kcalloc (NFPROTO_NUMPROTO ,sizeof (struct xt_af ),GFP_KERNEL );if (!xt)return -ENOMEM ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 119/266 USB: core: Fix bug caused by duplicate interface PM usage counter
In reply to Greg Kroah-HartmanFrom: Alan Stern <[email protected]>
commit c2b71462d294cf517a0bc6e4fd6424d7cee5596f upstream.
The syzkaller fuzzer reported a bug in the USB hub driver which turned out to be caused by a negative runtime-PM usage counter. This allowed a hub to be runtime suspended at a time when the driver did not expect it. The symptom is a WARNING issued because the hub's status URB is submitted while it is already active:
URB 0000000031fb463e submitted while active WARNING: CPU: 0 PID: 2917 at drivers/usb/core/urb.c:363
The negative runtime-PM usage count was caused by an unfortunate design decision made when runtime PM was first implemented for USB. At that time, USB class drivers were allowed to unbind from their interfaces without balancing the usage counter (i.e., leaving it with a positive count). The core code would take care of setting the counter back to 0 before allowing another driver to bind to the interface.
Later on when runtime PM was implemented for the entire kernel, the opposite decision was made: Drivers were required to balance their runtime-PM get and put calls. In order to maintain backward compatibility, however, the USB subsystem adapted to the new implementation by keeping an independent usage counter for each interface and using it to automatically adjust the normal usage counter back to 0 whenever a driver was unbound.
This approach involves duplicating information, but what is worse, it doesn't work properly in cases where a USB class driver delays decrementing the usage counter until after the driver's disconnect() routine has returned and the counter has been adjusted back to 0. Doing so would cause the usage counter to become negative. There's even a warning about this in the USB power management documentation!
As it happens, this is exactly what the hub driver does. The kick_hub_wq() routine increments the runtime-PM usage counter, and the corresponding decrement is carried out by hub_event() in the context of the hub_wq work-queue thread. This work routine may sometimes run after the driver has been unbound from its interface, and when it does it causes the usage counter to go negative.
It is not possible for hub_disconnect() to wait for a pending hub_event() call to finish, because hub_disconnect() is called with the device lock held and hub_event() acquires that lock. The only feasible fix is to reverse the original design decision: remove the duplicate interface-specific usage counter and require USB drivers to balance their runtime PM gets and puts. As far as I know, all existing drivers currently do this.
--- Documentation/usb/power-management.txt | 14 +++++++++----- drivers/usb/core/driver.c | 13 ------------- drivers/usb/storage/realtek_cr.c | 13 +++++-------- include/linux/usb.h | 2 -- 4 files changed, 14 insertions(+), 28 deletions(-)
Documentation/usb/power-management.txt +9 -5
@@ -365,11 +365,15 @@ autosuspend the interface's device. Whe then the interface is considered to be idle, and the kernel may autosuspend the device. -Drivers need not be concerned about balancing changes to the usage -counter; the USB core will undo any remaining "get"s when a driver -is unbound from its interface. As a corollary, drivers must not call -any of the usb_autopm_* functions after their disconnect() routine has -returned. +Drivers must be careful to balance their overall changes to the usage +counter. Unbalanced "get"s will remain in effect when a driver is +unbound from its interface, preventing the device from going into +runtime suspend should the interface be bound to a driver again. On +the other hand, drivers are allowed to achieve this balance by calling +the ``usb_autopm_*`` functions even after their ``disconnect`` routine +has returned -- say from within a work-queue routine -- provided they +retain an active reference to the interface (via ``usb_get_intf`` and +``usb_put_intf``). Drivers using the async routines are responsible for their own synchronization and mutual exclusion.
drivers/usb/core/driver.c +0 -13
@@ -470,11 +470,6 @@ static int usb_unbind_interface(struct dpm_runtime_disable (dev);pm_runtime_set_suspended (dev); -/* Undo any residual pm_autopm_get_interface_* calls */ -for (r =atomic_read (&intf->pm_usage_cnt); r >0 ; --r) -usb_autopm_put_interface_no_suspend (intf); -atomic_set (&intf->pm_usage_cnt,0 ); -if (!error)usb_autosuspend_device (udev);
@@ -1625,7 +1620,6 @@ void usb_autopm_put_interface(struct usbint status;usb_mark_last_busy (udev); -atomic_dec (&intf->pm_usage_cnt); status =pm_runtime_put_sync (&intf->dev); dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", __func__, atomic_read(&intf->dev.power.usage_count),
@@ -1654,7 +1648,6 @@ void usb_autopm_put_interface_async(struint status;usb_mark_last_busy (udev); -atomic_dec (&intf->pm_usage_cnt); status =pm_runtime_put (&intf->dev); dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", __func__, atomic_read(&intf->dev.power.usage_count),
@@ -1676,7 +1669,6 @@ void usb_autopm_put_interface_no_suspendstruct usb_device *udev =interface_to_usbdev (intf);usb_mark_last_busy (udev); -atomic_dec (&intf->pm_usage_cnt);pm_runtime_put_noidle (&intf->dev); }EXPORT_SYMBOL_GPL (usb_autopm_put_interface_no_suspend);
@@ -1707,8 +1699,6 @@ int usb_autopm_get_interface(struct usb_ status =pm_runtime_get_sync (&intf->dev);if (status <0 )pm_runtime_put_sync (&intf->dev); -else -atomic_inc (&intf->pm_usage_cnt);dev_vdbg (&intf->dev,"%s: cnt %d -> %d\n" , __func__,atomic_read (&intf->dev.power.usage_count), status);
@@ -1742,8 +1732,6 @@ int usb_autopm_get_interface_async(struc status =pm_runtime_get (&intf->dev);if (status <0 && status != -EINPROGRESS )pm_runtime_put_noidle (&intf->dev); -else -atomic_inc (&intf->pm_usage_cnt);dev_vdbg (&intf->dev,"%s: cnt %d -> %d\n" , __func__,atomic_read (&intf->dev.power.usage_count), status);
@@ -1767,7 +1755,6 @@ void usb_autopm_get_interface_no_resume(struct usb_device *udev =interface_to_usbdev (intf);usb_mark_last_busy (udev); -atomic_inc (&intf->pm_usage_cnt);pm_runtime_get_noresume (&intf->dev); }EXPORT_SYMBOL_GPL (usb_autopm_get_interface_no_resume);
drivers/usb/storage/realtek_cr.c +5 -8
@@ -772,18 +772,16 @@ static void rts51x_suspend_timer_fn(unsibreak ;case RTS51X_STAT_IDLE :case RTS51X_STAT_SS : -usb_stor_dbg (us,"RTS51X_STAT_SS, intf->pm_usage_cnt:%d, power.usage:%d\n" , -atomic_read (&us->pusb_intf->pm_usage_cnt), +usb_stor_dbg (us,"RTS51X_STAT_SS, power.usage:%d\n" ,atomic_read (&us->pusb_intf->dev.power.usage_count)); -if (atomic_read (&us->pusb_intf->pm_usage_cnt) >0 ) { +if (atomic_read (&us->pusb_intf->dev.power.usage_count) >0 ) {usb_stor_dbg (us,"Ready to enter SS state\n" );rts51x_set_stat (chip,RTS51X_STAT_SS );/* ignore mass storage interface's children */ pm_suspend_ignore_children (&us->pusb_intf->dev, true);usb_autopm_put_interface_async (us->pusb_intf); -usb_stor_dbg (us,"RTS51X_STAT_SS 01, intf->pm_usage_cnt:%d, power.usage:%d\n" , -atomic_read (&us->pusb_intf->pm_usage_cnt), +usb_stor_dbg (us,"RTS51X_STAT_SS 01, power.usage:%d\n" ,atomic_read (&us->pusb_intf->dev.power.usage_count)); }break ;
@@ -816,11 +814,10 @@ static void rts51x_invoke_transport(struint ret;if (working_scsi (srb)) { -usb_stor_dbg (us,"working scsi, intf->pm_usage_cnt:%d, power.usage:%d\n" , -atomic_read (&us->pusb_intf->pm_usage_cnt), +usb_stor_dbg (us,"working scsi, power.usage:%d\n" ,atomic_read (&us->pusb_intf->dev.power.usage_count)); -if (atomic_read (&us->pusb_intf->pm_usage_cnt) <=0 ) { +if (atomic_read (&us->pusb_intf->dev.power.usage_count) <=0 ) { ret =usb_autopm_get_interface (us->pusb_intf);usb_stor_dbg (us,"working scsi, ret=%d\n" , ret); }
include/linux/usb.h +0 -2
@@ -127,7 +127,6 @@ enum usb_interface_condition {* @dev: driver model's view of this device * @usb_dev: if an interface is bound to the USB major, this will point * to the sysfs representation for that device. -* @pm_usage_cnt: PM usage counter for this interface * @reset_ws: Used for scheduling resets from atomic context. * @resetting_device: USB core reset the device, so use alt setting 0 as * current; needs bandwidth alloc after reset.
@@ -184,7 +183,6 @@ struct usb_interface {struct device dev;/* interface specific device info */ struct device *usb_dev; -atomic_t pm_usage_cnt;/* usage counter for autosuspend */ struct work_struct reset_ws;/* for resets in atomic context */ };#define to_usb_interface (d) container_of(d, struct usb_interface, dev)
Greg Kroah-Hartman
maintainerPATCH 121/266 rtc: sh: Fix invalid alarm warning for non-enabled alarm
In reply to Greg Kroah-Hartman[ Upstream commit 15d82d22498784966df8e4696174a16b02cc1052 ]
When no alarm has been programmed on RSK-RZA1, an error message is printed during boot:
rtc rtc0: invalid alarm value: 2019-03-14T255:255:255
sh_rtc_read_alarm_value() returns 0xff when querying a hardware alarm field that is not enabled. __rtc_read_alarm() validates the received alarm values, and fills in missing fields when needed.
While 0xff is handled fine for the year, month, and day fields, and corrected as considered being out-of-range, this is not the case for the hour, minute, and second fields, where -1 is expected for missing fields.
Fix this by returning -1 instead, as this value is handled fine for all fields.
--- drivers/rtc/rtc-sh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-sh.c +1 -1
@@ -455,7 +455,7 @@ static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)static inline int sh_rtc_read_alarm_value (struct sh_rtc *rtc,int reg_off) {unsigned int byte; -int value =0xff ;/* return 0xff for ignored values */ +int value =-1 ;/* return -1 for ignored values */ byte =readb (rtc->regbase + reg_off);if (byte &AR_ENB ) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 122/266 igb: Fix WARN_ONCE on runtime suspend
In reply to Greg Kroah-Hartman[ Upstream commit dabb8338be533c18f50255cf39ff4f66d4dabdbe ]
The runtime_suspend device callbacks are not supposed to save configuration state or change the power state. Commit fb29f76cc566 ("igb: Fix an issue that PME is not enabled during runtime suspend") changed the driver to not save configuration state during runtime suspend, however the driver callback still put the device into a low-power state. This causes a warning in the pci pm core and results in pci_pm_runtime_suspend not calling pci_save_state or pci_finish_runtime_suspend.
Fix this by not changing the power state either, leaving that to pci pm core, and make the same change for suspend callback as well.
Also move a couple of defines into the appropriate header file instead of inline in the .c file.
--- .../net/ethernet/intel/igb/e1000_defines.h | 2 + drivers/net/ethernet/intel/igb/igb_main.c | 57 +++---------------- 2 files changed, 10 insertions(+), 49 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +2 -0
@@ -193,6 +193,8 @@/* enable link status from external LINK_0 and LINK_1 pins */ #define E1000_CTRL_SWDPIN0 0x00040000/* SWDPIN 0 value */ #define E1000_CTRL_SWDPIN1 0x00080000/* SWDPIN 1 value */ +#define E1000_CTRL_ADVD3WUC 0x00100000/* D3 WUC */ +#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000/* PHY PM enable */ #define E1000_CTRL_SDP0_DIR 0x00400000/* SDP0 Data direction */ #define E1000_CTRL_SDP1_DIR 0x00800000/* SDP1 Data direction */ #define E1000_CTRL_RST 0x04000000/* Global reset */
drivers/net/ethernet/intel/igb/igb_main.c +8 -49
97 lines not on this page · raw message
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 113/266 ipv6: invert flowlabel sharing check in process and user mode
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit 95c169251bf734aa555a1e8043e4d88ec97a04ec ]
A request for a flowlabel fails in process or user exclusive mode must fail if the caller pid or uid does not match. Invert the test.
Previously, the test was unsafe wrt PID recycling, but indeed tested for inequality: fl1->owner != fl->owner
--- net/ipv6/ip6_flowlabel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_flowlabel.c +2 -2
@@ -639,9 +639,9 @@ recheck:if (fl1->share ==IPV6_FL_S_EXCL || fl1->share != fl->share || ((fl1->share ==IPV6_FL_S_PROCESS ) && - (fl1->owner.pid == fl->owner.pid)) || + (fl1->owner.pid != fl->owner.pid)) || ((fl1->share ==IPV6_FL_S_USER ) && -uid_eq (fl1->owner.uid, fl->owner.uid))) + !uid_eq (fl1->owner.uid, fl->owner.uid))) goto release; err = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 171/266 ipvs: do not schedule icmp errors from tunnels
In reply to Greg Kroah-Hartman[ Upstream commit 0261ea1bd1eb0da5c0792a9119b8655cf33c80a3 ]
We can receive ICMP errors from client or from
tunneling real server. While the former can be
scheduled to real server, the latter should
not be scheduled, they are decapsulated only when
existing connection is found.
--- net/netfilter/ipvs/ip_vs_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_core.c +1 -1
@@ -1484,7 +1484,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (!cp) {int v; -if (!sysctl_schedule_icmp (ipvs)) +if (ipip || !sysctl_schedule_icmp (ipvs))return NF_ACCEPT ;if (!ip_vs_try_to_schedule (ipvs,AF_INET , skb, pd, &v, &cp, &ciph))
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 172/266 s390: ctcm: fix ctcm_new_device error return code
In reply to Greg Kroah-Hartman[ Upstream commit 27b141fc234a3670d21bd742c35d7205d03cbb3a ]
clang points out that the return code from this function is undefined for one of the error paths:
../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
if (priv->channel[direction] == NULL) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here
return result;
^~~~~~
../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false
if (priv->channel[direction] == NULL) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning
int result;
^Make it return -ENODEV here, as in the related failure cases. gcc has a known bug in underreporting some of these warnings when it has already eliminated the assignment of the return code based on some earlier optimization step.
--- drivers/s390/net/ctcm_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/s390/net/ctcm_main.c +1 -0
@@ -1595,6 +1595,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)if (priv->channel[direction] ==NULL ) {if (direction ==CTCM_WRITE )channel_free (priv->channel[CTCM_READ ]); + result = -ENODEV ; goto out_dev; } priv->channel[direction]->netdev = dev;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 174/266 gpu: ipu-v3: dp: fix CSC handling
In reply to Greg Kroah-Hartman[ Upstream commit d4fad0a426c6e26f48c9a7cdd21a7fe9c198d645 ]
Initialize the flow input colorspaces to unknown and reset to that value when the channel gets disabled. This avoids the state getting mixed up with a previous mode.
Also keep the CSC settings for the background flow intact when disabling the foreground flow.
--- drivers/gpu/ipu-v3/ipu-dp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/ipu-v3/ipu-dp.c +9 -3
@@ -195,7 +195,8 @@ int ipu_dp_setup_channel(struct ipu_dp *ipu_dp_csc_init (flow, flow->foreground.in_cs, flow->out_cs,DP_COM_CONF_CSC_DEF_BOTH ); }else { -if (flow->foreground.in_cs == flow->out_cs) +if (flow->foreground.in_cs ==IPUV3_COLORSPACE_UNKNOWN || + flow->foreground.in_cs == flow->out_cs)/* * foreground identical to output, apply color * conversion on background
@@ -261,6 +262,8 @@ void ipu_dp_disable_channel(struct ipu_dstruct ipu_dp_priv *priv = flow->priv;u32 reg, csc; + dp->in_cs =IPUV3_COLORSPACE_UNKNOWN ; +if (!dp->foreground)return ;
@@ -268,8 +271,9 @@ void ipu_dp_disable_channel(struct ipu_d reg =readl (flow->base +DP_COM_CONF ); csc = reg &DP_COM_CONF_CSC_DEF_MASK ; -if (csc ==DP_COM_CONF_CSC_DEF_FG ) - reg &= ~DP_COM_CONF_CSC_DEF_MASK ; + reg &= ~DP_COM_CONF_CSC_DEF_MASK ; +if (csc ==DP_COM_CONF_CSC_DEF_BOTH || csc ==DP_COM_CONF_CSC_DEF_BG ) + reg |=DP_COM_CONF_CSC_DEF_BG ; reg &= ~DP_COM_CONF_FG_EN ;writel (reg, flow->base +DP_COM_CONF );
@@ -350,6 +354,8 @@ int ipu_dp_init(struct ipu_soc *ipu, strmutex_init (&priv->mutex);for (i =0 ; i <IPUV3_NUM_FLOWS ; i++) { + priv->flow[i].background.in_cs =IPUV3_COLORSPACE_UNKNOWN ; + priv->flow[i].foreground.in_cs =IPUV3_COLORSPACE_UNKNOWN ; priv->flow[i].foreground.foreground = true; priv->flow[i].base = priv->base + ipu_dp_flow_base[i]; priv->flow[i].priv = priv;
Greg Kroah-Hartman
maintainerPATCH 175/266 cw1200: fix missing unlock on error in cw1200_hw_scan()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
commit 51c8d24101c79ffce3e79137e2cee5dfeb956dd7 upstream.
Add the missing unlock before return from function cw1200_hw_scan() in the error handling case.
[iwamatsu: Change the patching file from drivers/net/wireless/st/cw1200/scan.c to drivers/net/wireless/cw1200/scan.c]
--- drivers/net/wireless/cw1200/scan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/cw1200/scan.c +4 -1
@@ -84,8 +84,11 @@ int cw1200_hw_scan(struct ieee80211_hw * frame.skb =ieee80211_probereq_get (hw, priv->vif->addr,NULL ,0 , req->ie_len); -if (!frame.skb) +if (!frame.skb) { +mutex_unlock (&priv->conf_mutex); +up (&priv->scan.lock);return -ENOMEM ; + }if (req->ie_len)memcpy (skb_put (frame.skb, req->ie_len), req->ie, req->ie_len);
Greg Kroah-Hartman
maintainerPATCH 176/266 x86/vdso: Pass --eh-frame-hdr to the linker
In reply to Greg Kroah-HartmanFrom: Alistair Strachan <[email protected]>
commit cd01544a268ad8ee5b1dfe42c4393f1095f86879 upstream.
Commit
379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link")
accidentally broke unwinding from userspace, because ld would strip the .eh_frame sections when linking.
Originally, the compiler would implicitly add --eh-frame-hdr when invoking the linker, but when this Makefile was converted from invoking ld via the compiler, to invoking it directly (like vmlinux does), the flag was missed. (The EH_FRAME section is important for the VDSO shared libraries, but not for vmlinux.)
Fix the problem by explicitly specifying --eh-frame-hdr, which restores parity with the old method.
See relevant bug reports for additional info:
https://bugzilla.kernel.org/show_bug.cgi?id=201741
https://bugzilla.redhat.com/show_bug.cgi?id=1659295
--- arch/x86/entry/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/entry/vdso/Makefile +2 -1
@@ -159,7 +159,8 @@ quiet_cmd_vdso = VDSO $@ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ - $(call ld-option, --build-id) -Bsymbolic + $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \ + -Bsymbolic GCOV_PROFILE := n #
Greg Kroah-Hartman
maintainerPATCH 177/266 Dont jump to compute_result state from check_result state
In reply to Greg Kroah-HartmanFrom: Nigel Croxon <[email protected]>
commit 4f4fd7c5798bbdd5a03a60f6269cf1177fbd11ef upstream.
Changing state from check_state_check_result to check_state_compute_result not only is unsafe but also doesn't appear to serve a valid purpose. A raid6 check should only be pushing out extra writes if doing repair and a mis-match occurs. The stripe dev management will already try and do repair writes for failing sectors.
This patch makes the raid6 check_state_check_result handling work more like raid5's. If somehow too many failures for a check, just quit the check operation for the stripe. When any checks pass, don't try and use check_state_compute_result for a purpose it isn't needed for and is unsafe for. Just mark the stripe as in sync for passing its parity checks and let the stripe dev read/write code and the bad blocks list do their job handling I/O errors.
Repro steps from Xiao:
These are the steps to reproduce this problem:
1. redefined OPT_MEDIUM_ERR_ADDR to 12000 in scsi_debug.c
2. insmod scsi_debug.ko dev_size_mb=11000 max_luns=1 num_tgts=1
3. mdadm --create /dev/md127 --level=6 --raid-devices=5 /dev/sde1 /dev/sde2 /dev/sde3 /dev/sde5 /dev/sde6 sde is the disk created by scsi_debug
4. echo "2" >/sys/module/scsi_debug/parameters/opts
5. raid-check
It panic:
[ 4854.730899] md: data-check of RAID array md127 [ 4854.857455] sd 5:0:0:0: [sdr] tag#80 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [ 4854.859246] sd 5:0:0:0: [sdr] tag#80 Sense Key : Medium Error [current] [ 4854.860694] sd 5:0:0:0: [sdr] tag#80 Add. Sense: Unrecovered read error [ 4854.862207] sd 5:0:0:0: [sdr] tag#80 CDB: Read(10) 28 00 00 00 2d 88 00 04 00 00 [ 4854.864196] print_req_error: critical medium error, dev sdr, sector 11656 flags 0 [ 4854.867409] sd 5:0:0:0: [sdr] tag#100 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [ 4854.869469] sd 5:0:0:0: [sdr] tag#100 Sense Key : Medium Error [current] [ 4854.871206] sd 5:0:0:0: [sdr] tag#100 Add. Sense: Unrecovered read error [ 4854.872858] sd 5:0:0:0: [sdr] tag#100 CDB: Read(10) 28 00 00 00 2e e0 00 00 08 00 [ 4854.874587] print_req_error: critical medium error, dev sdr, sector 12000 flags 4000 [ 4854.876456] sd 5:0:0:0: [sdr] tag#101 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [ 4854.878552] sd 5:0:0:0: [sdr] tag#101 Sense Key : Medium Error [current] [ 4854.880278] sd 5:0:0:0: [sdr] tag#101 Add. Sense: Unrecovered read error [ 4854.881846] sd 5:0:0:0: [sdr] tag#101 CDB: Read(10) 28 00 00 00 2e e8 00 00 08 00 [ 4854.883691] print_req_error: critical medium error, dev sdr, sector 12008 flags 4000 [ 4854.893927] sd 5:0:0:0: [sdr] tag#166 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [ 4854.896002] sd 5:0:0:0: [sdr] tag#166 Sense Key : Medium Error [current] [ 4854.897561] sd 5:0:0:0: [sdr] tag#166 Add. Sense: Unrecovered read error [ 4854.899110] sd 5:0:0:0: [sdr] tag#166 CDB: Read(10) 28 00 00 00 2e e0 00 00 10 00 [ 4854.900989] print_req_error: critical medium error, dev sdr, sector 12000 flags 0 [ 4854.902757] md/raid:md127: read error NOT corrected!! (sector 9952 on sdr1). [ 4854.904375] md/raid:md127: read error NOT corrected!! (sector 9960 on sdr1). [ 4854.906201] ------------[ cut here ]------------ [ 4854.907341] kernel BUG at drivers/md/raid5.c:4190!
raid5.c:4190 above is this BUG_ON:
handle_parity_checks6()
...
BUG_ON(s->uptodate < disks - 1); /* We don't need Q to recover */Cc: <[email protected]> # v3.16+
OriginalAuthor: David Jeffery <[email protected]>
--- drivers/md/raid5.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/md/raid5.c +4 -15
@@ -3897,26 +3897,15 @@ static void handle_parity_checks6(structcase check_state_check_result: sh->check_state = check_state_idle; +if (s->failed >1 ) +break ;/* handle a successful check operation, if parity is correct * we are done. Otherwise update the mismatch count and repair * parity if !MD_RECOVERY_CHECK */ if (sh->ops.zero_sum_result ==0 ) { -/* both parities are correct */ -if (!s->failed) -set_bit (STRIPE_INSYNC , &sh->state); -else { -/* in contrast to the raid5 case we can validate -* parity, but still have a failure to write -* back -*/ - sh->check_state = check_state_compute_result; -/* Returning at this point means that we may go -* off and bring p and/or q uptodate again so -* we make sure to check zero_sum_result again -* to verify if p or q need writeback -*/ - } +/* Any parity checked was correct */ +set_bit (STRIPE_INSYNC , &sh->state); }else {atomic64_add (STRIPE_SECTORS , &conf->mddev->resync_mismatches);if (test_bit (MD_RECOVERY_CHECK , &conf->mddev->recovery))
Greg Kroah-Hartman
maintainerPATCH 179/266 x86/microcode/intel: Add a helper which gives the microcode revision
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
commit 4167709bbf826512a52ebd6aafda2be104adaec9 upstream.
Since on Intel we're required to do CPUID(1) first, before reading the microcode revision MSR, let's add a special helper which does the required steps so that we don't forget to do them next time, when we want to read the microcode revision.
[bwh: Backported to 4.4:
- Don't touch prev_rev variable in apply_microcode()
- Keep using sync_core(), which will alway includes the necessary CPUID
- Adjust context]
--- arch/x86/include/asm/microcode_intel.h | 15 ++++++++++++ arch/x86/kernel/cpu/intel.c | 11 ++------- arch/x86/kernel/cpu/microcode/intel.c | 39 +++++++++------------------------ 3 files changed, 29 insertions(+), 36 deletions(-)
arch/x86/include/asm/microcode_intel.h +15 -0
@@ -53,6 +53,21 @@ struct extended_sigtable {#define exttable_size (et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) +static inline u32 intel_get_microcode_revision (void ) +{ +u32 rev, dummy; + +native_wrmsrl (MSR_IA32_UCODE_REV ,0 ); + +/* As documented in the SDM: Do a CPUID 1 here */ +sync_core (); + +/* get the current revision from MSR 0x8B */ +native_rdmsr (MSR_IA32_UCODE_REV , dummy, rev); + +return rev; +} +extern int has_newer_microcode (void *mc,unsigned int csig,int cpf,int rev);extern int microcode_sanity_check (void *mc,int print_err);extern int find_matching_signature (void *mc,unsigned int csig,int cpf);
arch/x86/kernel/cpu/intel.c +3 -8
@@ -14,6 +14,7 @@#include <asm/bugs.h> #include <asm/cpu.h> #include <asm/intel-family.h> +#include <asm/microcode_intel.h> #ifdef CONFIG_X86_64 #include <linux/topology.h>
@@ -102,14 +103,8 @@ static void early_init_intel(struct cpui (c->x86 == 0x6 && c->x86_model >= 0x0e))set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC ); -if (c->x86 >=6 && !cpu_has (c,X86_FEATURE_IA64 )) { -unsigned lower_word; - -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); -/* Required by the SDM */ -sync_core (); -rdmsr (MSR_IA32_UCODE_REV , lower_word, c->microcode); - } +if (c->x86 >=6 && !cpu_has (c,X86_FEATURE_IA64 )) + c->microcode =intel_get_microcode_revision ();/* Now if any of them are set, check the blacklist and clear the lot */ if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) ||
arch/x86/kernel/cpu/microcode/intel.c +11 -28
@@ -376,15 +376,8 @@ static int collect_cpu_info_early(structnative_rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); csig.pf =1 << ((val[1 ] >>18 ) &7 ); } -native_wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); -/* As documented in the SDM: Do a CPUID 1 here */ -sync_core (); - -/* get the current revision from MSR 0x8B */ -native_rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); - - csig.rev = val[1 ]; + csig.rev =intel_get_microcode_revision (); uci->cpu_sig = csig; uci->valid =1 ;
@@ -654,7 +647,7 @@ static inline void print_ucode(struct ucstatic int apply_microcode_early (struct ucode_cpu_info *uci,bool early) {struct microcode_intel *mc_intel; -unsigned int val[2 ]; +u32 rev; mc_intel = uci->mc;if (mc_intel ==NULL )
@@ -664,21 +657,16 @@ static int apply_microcode_early(structnative_wrmsr (MSR_IA32_UCODE_WRITE , (unsigned long ) mc_intel->bits, (unsigned long ) mc_intel->bits >>16 >>16 ); -native_wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); -/* As documented in the SDM: Do a CPUID 1 here */ -sync_core (); - -/* get the current revision from MSR 0x8B */ -native_rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); -if (val[1 ] != mc_intel->hdr.rev) + rev =intel_get_microcode_revision (); +if (rev != mc_intel->hdr.rev)return -1 ;#ifdef CONFIG_X86_64 /* Flush global tlb. This is precaution. */ flush_tlb_early ();#endif - uci->cpu_sig.rev = val[1 ]; + uci->cpu_sig.rev = rev;if (early)print_ucode (uci);
@@ -852,7 +840,7 @@ static int apply_microcode_intel(int cpu {struct microcode_intel *mc_intel;struct ucode_cpu_info *uci; -unsigned int val[2 ]; +u32 rev;int cpu_num =raw_smp_processor_id ();struct cpuinfo_x86 *c = &cpu_data (cpu_num);
@@ -877,27 +865,22 @@ static int apply_microcode_intel(int cpuwrmsr (MSR_IA32_UCODE_WRITE , (unsigned long ) mc_intel->bits, (unsigned long ) mc_intel->bits >>16 >>16 ); -wrmsr (MSR_IA32_UCODE_REV ,0 ,0 ); - -/* As documented in the SDM: Do a CPUID 1 here */ -sync_core (); -/* get the current revision from MSR 0x8B */ -rdmsr (MSR_IA32_UCODE_REV , val[0 ], val[1 ]); + rev =intel_get_microcode_revision (); -if (val[1 ] != mc_intel->hdr.rev) { +if (rev != mc_intel->hdr.rev) {pr_err ("CPU%d update to revision 0x%x failed\n" , cpu_num, mc_intel->hdr.rev);return -1 ; }pr_info ("CPU%d updated to revision 0x%x, date = %04x-%02x-%02x\n" , - cpu_num, val[1 ], + cpu_num, rev, mc_intel->hdr.date &0xffff , mc_intel->hdr.date >>24 , (mc_intel->hdr.date >>16 ) &0xff ); - uci->cpu_sig.rev = val[1 ]; - c->microcode = val[1 ]; + uci->cpu_sig.rev = rev; + c->microcode = rev;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 162/266 iio: adc: xilinx: fix potential use-after-free on remove
In reply to Greg Kroah-Hartman[ Upstream commit 62039b6aef63380ba7a37c113bbaeee8a55c5342 ]
When cancel_delayed_work() returns, the delayed work may still be running. This means that the core could potentially free the private structure (struct xadc) while the delayed work is still using it. This is a potential use-after-free.
Fix by calling cancel_delayed_work_sync(), which waits for any residual work to finish before returning.
--- drivers/iio/adc/xilinx-xadc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/xilinx-xadc-core.c +1 -1
@@ -1299,7 +1299,7 @@ static int xadc_remove(struct platform_device *pdev) }free_irq (irq, indio_dev);clk_disable_unprepare (xadc->clk); -cancel_delayed_work (&xadc->zynq_unmask_work); +cancel_delayed_work_sync (&xadc->zynq_unmask_work);kfree (xadc->data);kfree (indio_dev->channels);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 180/266 x86: stop exporting msr-index.h to userland
In reply to Greg Kroah-HartmanFrom: Nicolas Dichtel <[email protected]>
commit 25dc1d6cc3082aab293e5dad47623b550f7ddd2a upstream.
Even if this file was not in an uapi directory, it was exported because it was listed in the Kbuild file.
--- arch/x86/include/uapi/asm/Kbuild | 1 - 1 file changed, 1 deletion(-)
arch/x86/include/uapi/asm/Kbuild +0 -1
@@ -27,7 +27,6 @@ header-y += ldt.h header-y += mce.h header-y += mman.h header-y += msgbuf.h -header-y += msr-index.h header-y += msr.h header-y += mtrr.h header-y += param.h
Greg Kroah-Hartman
maintainerPATCH 181/266 bitops: avoid integer overflow in GENMASK(_ULL)
In reply to Greg Kroah-HartmanFrom: Matthias Kaehlcke <[email protected]>
commit c32ee3d9abd284b4fcaacc250b101f93829c7bae upstream.
GENMASK(_ULL) performs a left-shift of ~0UL(L), which technically results in an integer overflow. clang raises a warning if the overflow occurs in a preprocessor expression. Clear the low-order bits through a substraction instead of the left-shift to avoid the overflow.
(akpm: no change in .text size in my testing)
--- include/linux/bitops.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/bitops.h +3 -2
@@ -19,10 +19,11 @@* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. */ #define GENMASK (h, l) \ - (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))#define GENMASK_ULL (h, l) \ - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))extern unsigned int __sw_hweight8 (unsigned int w);extern unsigned int __sw_hweight16 (unsigned int w);
Greg Kroah-Hartman
maintainerPATCH 182/266 x86/microcode/intel: Check microcode revision before updating sibling threads
In reply to Greg Kroah-HartmanFrom: Ashok Raj <[email protected]>
commit c182d2b7d0ca48e0d6ff16f7d883161238c447ed upstream.
After updating microcode on one of the threads of a core, the other thread sibling automatically gets the update since the microcode resources on a hyperthreaded core are shared between the two threads.
Check the microcode revision on the CPU before performing a microcode update and thus save us the WRMSR 0x79 because it is a particularly expensive operation.
[ Borislav: Massage changelog and coding style. ]
[bwh: Backported to 4.4:
- s/mc->/mc_intel->/
- Return 0 in this case
- Adjust context]
--- arch/x86/kernel/cpu/microcode/intel.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/x86/kernel/cpu/microcode/intel.c +23 -0
@@ -653,6 +653,17 @@ static int apply_microcode_early(structif (mc_intel ==NULL )return 0 ; +/* +* Save us the MSR write below - which is a particular expensive +* operation - when the other hyperthread has updated the microcode +* already. +*/ + rev =intel_get_microcode_revision (); +if (rev >= mc_intel->hdr.rev) { + uci->cpu_sig.rev = rev; +return 0 ; + } +/* write microcode via MSR 0x79 */ native_wrmsr(MSR_IA32_UCODE_WRITE, (unsigned long) mc_intel->bits,
@@ -861,6 +872,18 @@ static int apply_microcode_intel(int cpuif (get_matching_mc (mc_intel, cpu) ==0 )return 0 ; +/* +* Save us the MSR write below - which is a particular expensive +* operation - when the other hyperthread has updated the microcode +* already. +*/ + rev =intel_get_microcode_revision (); +if (rev >= mc_intel->hdr.rev) { + uci->cpu_sig.rev = rev; + c->microcode = rev; +return 0 ; + } +/* write microcode via MSR 0x79 */ wrmsr(MSR_IA32_UCODE_WRITE, (unsigned long) mc_intel->bits,
Greg Kroah-Hartman
maintainerPATCH 183/266 x86/MCE: Save microcode revision in machine check records
In reply to Greg Kroah-HartmanFrom: Tony Luck <[email protected]>
commit fa94d0c6e0f3431523f5701084d799c77c7d4a4f upstream.
Updating microcode used to be relatively rare. Now that it has become more common we should save the microcode version in a machine check record to make sure that those people looking at the error have this important information bundled with the rest of the logged information.
[ Borislav: Simplify a bit. ]
[bwh: Backported to 4.4:
- Also add earlier fields to struct mce, to match upstream UAPI
- Adjust context]
--- arch/x86/include/uapi/asm/mce.h | 4 ++++ arch/x86/kernel/cpu/mcheck/mce.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/include/uapi/asm/mce.h +4 -0
@@ -26,6 +26,10 @@ struct mce {__u32 socketid;/* CPU socket ID */ __u32 apicid;/* CPU initial apic ID */ __u64 mcgcap;/* MCGCAP MSR: machine check capabilities of CPU */ +__u64 synd;/* MCA_SYND MSR: only valid on SMCA systems */ +__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ +__u64 ppin;/* Protected Processor Inventory Number */ +__u32 microcode;/* Microcode revision */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
arch/x86/kernel/cpu/mcheck/mce.c +3 -1
@@ -138,6 +138,8 @@ void mce_setup(struct mce *m) m->socketid =cpu_data (m->extcpu).phys_proc_id; m->apicid =cpu_data (m->extcpu).initial_apicid;rdmsrl (MSR_IA32_MCG_CAP , m->mcgcap); + + m->microcode = boot_cpu_data.microcode; } DEFINE_PER_CPU(struct mce, injectm);
@@ -258,7 +260,7 @@ static void print_mce(struct mce *m)*/ pr_emerg (HW_ERR "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x microcode %x\n" , m->cpuvendor, m->cpuid, m->time, m->socketid, m->apicid, -cpu_data (m->extcpu).microcode); + m->microcode);/* * Print out human-readable details about the MCE error,
Greg Kroah-Hartman
maintainerPATCH 185/266 x86/speculation: Support Enhanced IBRS on future CPUs
In reply to Greg Kroah-HartmanFrom: Sai Praneeth <[email protected]>
commit 706d51681d636a0c4a5ef53395ec3b803e45ed4d upstream.
Future Intel processors will support "Enhanced IBRS" which is an "always on" mode i.e. IBRS bit in SPEC_CTRL MSR is enabled once and never disabled.
Quoted 1 line
From the specification [1]:
"With enhanced IBRS, the predicted targets of indirect branches
executed cannot be controlled by software that was executed in a less privileged predictor mode or on another logical processor. As a result, software operating on a processor with enhanced IBRS need not use WRMSR to set IA32_SPEC_CTRL.IBRS after every transition to a more privileged predictor mode. Software can isolate predictor modes effectively simply by setting the bit once. Software need not disable enhanced IBRS prior to entering a sleep state such as MWAIT or HLT."
If Enhanced IBRS is supported by the processor then use it as the preferred spectre v2 mitigation mechanism instead of Retpoline. Intel's Retpoline white paper [2] states:
"Retpoline is known to be an effective branch target injection (Spectre
variant 2) mitigation on Intel processors belonging to family 6 (enumerated by the CPUID instruction) that do not have support for enhanced IBRS. On processors that support enhanced IBRS, it should be used for mitigation instead of retpoline."
The reason why Enhanced IBRS is the recommended mitigation on processors which support it is that these processors also support CET which provides a defense against ROP attacks. Retpoline is very similar to ROP techniques and might trigger false positives in the CET defense.
If Enhanced IBRS is selected as the mitigation technique for spectre v2, the IBRS bit in SPEC_CTRL MSR is set once at boot time and never cleared. Kernel also has to make sure that IBRS bit remains set after VMEXIT because the guest might have cleared the bit. This is already covered by the existing x86_spec_ctrl_set_guest() and x86_spec_ctrl_restore_host() speculation control functions.
Enhanced IBRS still requires IBPB for full mitigation.
[1] Speculative-Execution-Side-Channel-Mitigations.pdf
[2] Retpoline-A-Branch-Target-Injection-Mitigation.pdf Both documents are available at:
https://bugzilla.kernel.org/show_bug.cgi?id=199511
[bwh: Backported to 4.4:
- Use the next bit from feature word 7
- Adjust context]
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/nospec-branch.h | 1 + arch/x86/kernel/cpu/bugs.c | 20 ++++++++++++++++++-- arch/x86/kernel/cpu/common.c | 3 +++ 4 files changed, 23 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -214,6 +214,7 @@#define X86_FEATURE_STIBP ( 7*32+27)/* Single Thread Indirect Branch Predictors */ #define X86_FEATURE_ZEN ( 7*32+28)/* "" CPU is AMD family 0x17 (Zen) */ #define X86_FEATURE_L1TF_PTEINV ( 7*32+29)/* "" L1TF workaround PTE inversion */ +#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30)/* Enhanced IBRS */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0)/* Intel TPR Shadow */
arch/x86/include/asm/nospec-branch.h +1 -0
@@ -170,6 +170,7 @@ enum spectre_v2_mitigation {SPECTRE_V2_RETPOLINE_GENERIC ,SPECTRE_V2_RETPOLINE_AMD ,SPECTRE_V2_IBRS , + SPECTRE_V2_IBRS_ENHANCED, };/* The Speculative Store Bypass disable variants */
arch/x86/kernel/cpu/bugs.c +18 -2
@@ -132,6 +132,7 @@ static const char *spectre_v2_strings[] [SPECTRE_V2_RETPOLINE_MINIMAL_AMD] = "Vulnerable: Minimal AMD ASM retpoline", [SPECTRE_V2_RETPOLINE_GENERIC] = "Mitigation: Full generic retpoline", [SPECTRE_V2_RETPOLINE_AMD] = "Mitigation: Full AMD retpoline", + [SPECTRE_V2_IBRS_ENHANCED] = "Mitigation: Enhanced IBRS", };#undef pr_fmt
@@ -332,6 +333,13 @@ static void __init spectre_v2_select_mitcase SPECTRE_V2_CMD_FORCE :case SPECTRE_V2_CMD_AUTO : +if (boot_cpu_has (X86_FEATURE_IBRS_ENHANCED )) { + mode =SPECTRE_V2_IBRS_ENHANCED ; +/* Force it so VMEXIT will restore correctly */ + x86_spec_ctrl_base |=SPEC_CTRL_IBRS ; +wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); + goto specv2_set_mode; + }if (IS_ENABLED (CONFIG_RETPOLINE )) goto retpoline_auto;break ;
@@ -369,6 +377,7 @@ retpoline_auto:setup_force_cpu_cap (X86_FEATURE_RETPOLINE ); } +specv2_set_mode: spectre_v2_enabled = mode;pr_info ("%s\n" , spectre_v2_strings[mode]);
@@ -391,9 +400,16 @@ retpoline_auto:/* * Retpoline means the kernel is safe because it has no indirect -* branches. But firmware isn't, so use IBRS to protect that. +* branches. Enhanced IBRS protects firmware too, so, enable restricted +* speculation around firmware calls only when Enhanced IBRS isn't +* supported. +* +* Use "mode" to check Enhanced IBRS instead of boot_cpu_has(), because +* the user might select retpoline on the kernel command line and if +* the CPU supports Enhanced IBRS, kernel might un-intentionally not +* enable IBRS around firmware calls. */ -if (boot_cpu_has (X86_FEATURE_IBRS )) { +if (boot_cpu_has (X86_FEATURE_IBRS ) && mode !=SPECTRE_V2_IBRS_ENHANCED ) {setup_force_cpu_cap (X86_FEATURE_USE_IBRS_FW );pr_info ("Enabling Restricted Speculation for firmware calls\n" ); }
arch/x86/kernel/cpu/common.c +3 -0
@@ -915,6 +915,9 @@ static void __init cpu_set_bug_bits(strusetup_force_cpu_bug (X86_BUG_SPECTRE_V1 );setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); +if (ia32_cap &ARCH_CAP_IBRS_ALL ) +setup_force_cpu_cap (X86_FEATURE_IBRS_ENHANCED ); +if (x86_match_cpu (cpu_no_meltdown))return ;
Greg Kroah-Hartman
maintainerPATCH 186/266 x86/speculation: Simplify the CPU bug detection logic
In reply to Greg Kroah-HartmanFrom: Dominik Brodowski <[email protected]>
commit 8ecc4979b1bd9c94168e6fc92960033b7a951336 upstream.
Only CPUs which speculate can speculate. Therefore, it seems prudent to test for cpu_no_speculation first and only then determine whether a specific speculating CPU is susceptible to store bypass speculation. This is underlined by all CPUs currently listed in cpu_no_speculation were present in cpu_no_spec_store_bypass as well.
--- arch/x86/kernel/cpu/common.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
arch/x86/kernel/cpu/common.c +7 -15
@@ -859,12 +859,8 @@ static const __initconst struct x86_cpu_ {} }; +/* Only list CPUs which speculate but are non susceptible to SSB */ static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = { - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_PINEVIEW }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_LINCROFT }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_PENWELL }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_CLOVERVIEW }, - {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_CEDARVIEW }, {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_SILVERMONT1 }, {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_AIRMONT }, {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_ATOM_SILVERMONT2 },
@@ -872,14 +868,10 @@ static const __initconst struct x86_cpu_ { X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH }, { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL }, { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM }, - { X86_VENDOR_CENTAUR, 5, }, - { X86_VENDOR_INTEL, 5, }, - { X86_VENDOR_NSC, 5, }, { X86_VENDOR_AMD, 0x12, }, { X86_VENDOR_AMD, 0x11, }, { X86_VENDOR_AMD, 0x10, }, { X86_VENDOR_AMD, 0xf, }, - { X86_VENDOR_ANY, 4, }, {} };
@@ -902,6 +894,12 @@ static void __init cpu_set_bug_bits(stru {u64 ia32_cap =0 ; +if (x86_match_cpu (cpu_no_speculation)) +return ; + +setup_force_cpu_bug (X86_BUG_SPECTRE_V1 ); +setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); +if (cpu_has (c,X86_FEATURE_ARCH_CAPABILITIES ))rdmsrl (MSR_IA32_ARCH_CAPABILITIES , ia32_cap);
@@ -909,12 +907,6 @@ static void __init cpu_set_bug_bits(stru !(ia32_cap & ARCH_CAP_SSB_NO))setup_force_cpu_bug (X86_BUG_SPEC_STORE_BYPASS ); -if (x86_match_cpu (cpu_no_speculation)) -return ; - -setup_force_cpu_bug (X86_BUG_SPECTRE_V1 ); -setup_force_cpu_bug (X86_BUG_SPECTRE_V2 ); -if (ia32_cap &ARCH_CAP_IBRS_ALL )setup_force_cpu_cap (X86_FEATURE_IBRS_ENHANCED );
Greg Kroah-Hartman
maintainerPATCH 189/266 x86/bugs: Switch the selection of mitigation from CPU vendor to CPU features
In reply to Greg Kroah-HartmanFrom: Konrad Rzeszutek Wilk <[email protected]>
commit 108fab4b5c8f12064ef86e02cb0459992affb30f upstream.
Both AMD and Intel can have SPEC_CTRL_MSR for SSBD.
However AMD also has two more other ways of doing it - which are !SPEC_CTRL MSR ways.
--- arch/x86/kernel/cpu/bugs.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -8
@@ -526,17 +526,12 @@ static enum ssb_mitigation __init __ssb_* Intel uses the SPEC CTRL MSR Bit(2) for this, while AMD may * use a completely different MSR and bit dependent on family. */ -switch (boot_cpu_data.x86_vendor) { -case X86_VENDOR_INTEL : -case X86_VENDOR_AMD : -if (!static_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) { -x86_amd_ssb_disable (); -break ; - } +if (!static_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) +x86_amd_ssb_disable (); +else { x86_spec_ctrl_base |=SPEC_CTRL_SSBD ; x86_spec_ctrl_mask |=SPEC_CTRL_SSBD ;wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); -break ; } }
Greg Kroah-Hartman
maintainerPATCH 163/266 HID: input: add mapping for Expose/Overview key
In reply to Greg Kroah-Hartman[ Upstream commit 96dd86871e1fffbc39e4fa61c9c75ec54ee9af0f ]
According to HUTRR77 usage 0x29f from the consumer page is reserved for the Desktop application to present all running user’s application windows. Linux defines KEY_SCALE to request Compiz Scale (Expose) mode, so let's add the mapping.
--- drivers/hid/hid-input.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-input.c +2 -0
@@ -913,6 +913,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielcase 0x2cb :map_key_clear (KEY_KBDINPUTASSIST_ACCEPT );break ;case 0x2cc :map_key_clear (KEY_KBDINPUTASSIST_CANCEL );break ; +case 0x29f :map_key_clear (KEY_SCALE );break ; +default :map_key_clear (KEY_UNKNOWN ); }break ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 190/266 locking/atomics, asm-generic: Move some macros from <linux/bitops.h> to a new <linux/bits.h> file
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit 8bd9cb51daac89337295b6f037b0486911e1b408 upstream.
In preparation for implementing the asm-generic atomic bitops in terms of atomic_long_*(), we need to prevent <asm/atomic.h> implementations from pulling in <linux/bitops.h>. A common reason for this include is for the BITS_PER_BYTE definition, so move this and some other BIT() and masking macros into a new header file, <linux/bits.h>.
--- include/linux/bitops.h | 22 +--------------------- include/linux/bits.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 include/linux/bits.h
include/linux/bitops.h +1 -21
@@ -1,29 +1,9 @@#ifndef _LINUX_BITOPS_H#define _LINUX_BITOPS_H#include <asm/types.h> +#include <linux/bits.h> -#ifdef __KERNEL__ -#define BIT (nr) (1UL << (nr)) -#define BIT_ULL (nr) (1ULL << (nr)) -#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) -#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) -#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG) -#define BITS_PER_BYTE 8#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -#endif - -/* -* Create a contiguous bitmask starting at bit position @l and ending at -* position @h. For example -* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. -*/ -#define GENMASK (h, l) \ - (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) - -#define GENMASK_ULL (h, l) \ - (((~0ULL) - (1ULL << (l)) + 1) & \ - (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))extern unsigned int __sw_hweight8 (unsigned int w);extern unsigned int __sw_hweight16 (unsigned int w);
include/linux/bits.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_BITS_H +#define __LINUX_BITS_H +#include <asm/bitsperlong.h> + +#define BIT (nr) (1UL << (nr)) +#define BIT_ULL (nr) (1ULL << (nr)) +#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) +#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG) +#define BITS_PER_BYTE 8 + +/* +* Create a contiguous bitmask starting at bit position @l and ending at +* position @h. For example +* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. +*/ +#define GENMASK (h, l) \ + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL (h, l) \ + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + +#endif /* __LINUX_BITS_H */
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 191/266 x86/bugs: Fix the AMD SSBD usage of the SPEC_CTRL MSR
In reply to Greg Kroah-HartmanFrom: Tom Lendacky <[email protected]>
commit 612bc3b3d4be749f73a513a17d9b3ee1330d3487 upstream.
On AMD, the presence of the MSR_SPEC_CTRL feature does not imply that the SSBD mitigation support should use the SPEC_CTRL MSR. Other features could have caused the MSR_SPEC_CTRL feature to be set, while a different SSBD mitigation option is in place.
Update the SSBD support to check for the actual SSBD features that will use the SPEC_CTRL MSR.
--- arch/x86/kernel/cpu/bugs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +5 -3
@@ -157,7 +157,8 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, guestval |= guest_spec_ctrl & x86_spec_ctrl_mask;/* SSBD controlled in MSR_SPEC_CTRL */ -if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD )) +if (static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) || +static_cpu_has (X86_FEATURE_AMD_SSBD )) hostval |=ssbd_tif_to_spec_ctrl (ti->flags);if (hostval != guestval) {
@@ -526,9 +527,10 @@ static enum ssb_mitigation __init __ssb_* Intel uses the SPEC CTRL MSR Bit(2) for this, while AMD may * use a completely different MSR and bit dependent on family. */ -if (!static_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) +if (!static_cpu_has (X86_FEATURE_SPEC_CTRL_SSBD ) && + !static_cpu_has (X86_FEATURE_AMD_SSBD )) {x86_amd_ssb_disable (); -else { + }else { x86_spec_ctrl_base |=SPEC_CTRL_SSBD ; x86_spec_ctrl_mask |=SPEC_CTRL_SSBD ;wrmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base);
Greg Kroah-Hartman
maintainerPATCH 192/266 x86/speculation: Remove SPECTRE_V2_IBRS in enum spectre_v2_mitigation
In reply to Greg Kroah-HartmanFrom: Jiang Biao <[email protected]>
commit d9f4426c73002957be5dd39936f44a09498f7560 upstream.
SPECTRE_V2_IBRS in enum spectre_v2_mitigation is never used. Remove it.
--- arch/x86/include/asm/nospec-branch.h | 1 - 1 file changed, 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +0 -1
@@ -169,7 +169,6 @@ enum spectre_v2_mitigation {SPECTRE_V2_RETPOLINE_MINIMAL_AMD ,SPECTRE_V2_RETPOLINE_GENERIC ,SPECTRE_V2_RETPOLINE_AMD , -SPECTRE_V2_IBRS , SPECTRE_V2_IBRS_ENHANCED, };
Greg Kroah-Hartman
maintainerPATCH 194/266 x86/microcode: Update the new microcode revision unconditionally
In reply to Greg Kroah-HartmanFrom: Filippo Sironi <[email protected]>
commit 8da38ebaad23fe1b0c4a205438676f6356607cfc upstream.
Handle the case where microcode gets loaded on the BSP's hyperthread sibling first and the boot_cpu_data's microcode revision doesn't get updated because of early exit due to the siblings sharing a microcode engine.
For that, simply write the updated revision on all CPUs unconditionally.
[bwh: Backported to 4.4:
- Keep returning 0 on success
- Adjust context]
--- arch/x86/kernel/cpu/microcode/amd.c | 20 ++++++++++---------- arch/x86/kernel/cpu/microcode/intel.c | 10 ++++------ 2 files changed, 14 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +10 -10
@@ -695,26 +695,26 @@ int apply_microcode_amd(int cpu)return -1 ;/* need to apply patch? */ -if (rev >= mc_amd->hdr.patch_id) { - c->microcode = rev; - uci->cpu_sig.rev = rev; -return 0 ; - } +if (rev >= mc_amd->hdr.patch_id) + goto out;if (__apply_microcode_amd (mc_amd)) {pr_err ("CPU%d: update failed for patch_level=0x%08x\n" , cpu, mc_amd->hdr.patch_id);return -1 ; } -pr_info ("CPU%d: new patch_level=0x%08x\n" , cpu, - mc_amd->hdr.patch_id); - uci->cpu_sig.rev = mc_amd->hdr.patch_id; - c->microcode = mc_amd->hdr.patch_id; + rev = mc_amd->hdr.patch_id; + +pr_info ("CPU%d: new patch_level=0x%08x\n" , cpu, rev); + +out: + uci->cpu_sig.rev = rev; + c->microcode = rev;/* Update boot_cpu_data's revision too, if we're on the BSP: */ if (c->cpu_index == boot_cpu_data.cpu_index) - boot_cpu_data.microcode = mc_amd->hdr.patch_id; + boot_cpu_data.microcode = rev;return 0 ; }
arch/x86/kernel/cpu/microcode/intel.c +4 -6
@@ -878,11 +878,8 @@ static int apply_microcode_intel(int cpu* already. */ rev =intel_get_microcode_revision (); -if (rev >= mc_intel->hdr.rev) { - uci->cpu_sig.rev = rev; - c->microcode = rev; -return 0 ; - } +if (rev >= mc_intel->hdr.rev) + goto out;/* write microcode via MSR 0x79 */ wrmsr(MSR_IA32_UCODE_WRITE,
@@ -902,8 +899,9 @@ static int apply_microcode_intel(int cpu mc_intel->hdr.date >>24 , (mc_intel->hdr.date >> 16) & 0xff); +out: uci->cpu_sig.rev = rev; - c->microcode = rev; + c->microcode = rev;/* Update boot_cpu_data's revision too, if we're on the BSP: */ if (c->cpu_index == boot_cpu_data.cpu_index)
Greg Kroah-Hartman
maintainerPATCH 198/266 x86/speculation: Apply IBPB more strictly to avoid cross-process data leak
In reply to Greg Kroah-HartmanFrom: Jiri Kosina <[email protected]>
commit dbfe2953f63c640463c630746cd5d9de8b2f63ae upstream.
Currently, IBPB is only issued in cases when switching into a non-dumpable process, the rationale being to protect such 'important and security sensitive' processess (such as GPG) from data leaking into a different userspace process via spectre v2.
This is however completely insufficient to provide proper userspace-to-userpace spectrev2 protection, as any process can poison branch buffers before being scheduled out, and the newly scheduled process immediately becomes spectrev2 victim.
In order to minimize the performance impact (for usecases that do require spectrev2 protection), issue the barrier only in cases when switching between processess where the victim can't be ptraced by the potential attacker (as in such cases, the attacker doesn't have to bother with branch buffers at all).
[ tglx: Split up PTRACE_MODE_NOACCESS_CHK into PTRACE_MODE_SCHED and
PTRACE_MODE_IBPB to be able to do ptrace() context tracking reasonably fine-grained ]
--- arch/x86/mm/tlb.c | 31 ++++++++++++++++++++----------- include/linux/ptrace.h | 21 +++++++++++++++++++-- kernel/ptrace.c | 10 ++++++++++ 3 files changed, 49 insertions(+), 13 deletions(-)
arch/x86/mm/tlb.c +20 -11
@@ -7,6 +7,7 @@#include <linux/module.h> #include <linux/cpu.h> #include <linux/debugfs.h> +#include <linux/ptrace.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h>
@@ -101,6 +102,19 @@ void switch_mm(struct mm_struct *prev, slocal_irq_restore (flags); } +static bool ibpb_needed (struct task_struct *tsk,u64 last_ctx_id) +{ +/* +* Check if the current (previous) task has access to the memory +* of the @tsk (next) task. If access is denied, make sure to +* issue a IBPB to stop user->user Spectre-v2 attacks. +* +* Note: __ptrace_may_access() returns 0 or -ERRNO. +*/ +return (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id && +ptrace_may_access_sched (tsk,PTRACE_MODE_SPEC_IBPB )); +} +void switch_mm_irqs_off (struct mm_struct *prev,struct mm_struct *next,struct task_struct *tsk) {
@@ -115,18 +129,13 @@ void switch_mm_irqs_off(struct mm_struct* one process from doing Spectre-v2 attacks on another. * * As an optimization, flush indirect branches only when -* switching into processes that disable dumping. This -* protects high value processes like gpg, without having -* too high performance overhead. IBPB is *expensive*! -* -* This will not flush branches when switching into kernel -* threads. It will also not flush if we switch to idle -* thread and back to the same process. It will flush if we -* switch to a different non-dumpable process. +* switching into a processes that can't be ptrace by the +* current one (as in such case, attacker has much more +* convenient way how to tamper with the next process than +* branch buffer poisoning). */ -if (tsk && tsk->mm && - tsk->mm->context.ctx_id != last_ctx_id && -get_dumpable (tsk->mm) !=SUID_DUMP_USER ) +if (static_cpu_has (X86_FEATURE_USE_IBPB ) && +ibpb_needed (tsk, last_ctx_id))indirect_branch_prediction_barrier ();/*
include/linux/ptrace.h +19 -2
@@ -57,14 +57,17 @@ extern void exit_ptrace(struct task_stru#define PTRACE_MODE_READ 0x01#define PTRACE_MODE_ATTACH 0x02#define PTRACE_MODE_NOAUDIT 0x04 -#define PTRACE_MODE_FSCREDS 0x08 -#define PTRACE_MODE_REALCREDS 0x10 +#define PTRACE_MODE_FSCREDS 0x08 +#define PTRACE_MODE_REALCREDS 0x10 +#define PTRACE_MODE_SCHED 0x20 +#define PTRACE_MODE_IBPB 0x40/* shorthands for READ/ATTACH and FSCREDS/REALCREDS combinations */ #define PTRACE_MODE_READ_FSCREDS (PTRACE_MODE_READ | PTRACE_MODE_FSCREDS)#define PTRACE_MODE_READ_REALCREDS (PTRACE_MODE_READ | PTRACE_MODE_REALCREDS)#define PTRACE_MODE_ATTACH_FSCREDS (PTRACE_MODE_ATTACH | PTRACE_MODE_FSCREDS)#define PTRACE_MODE_ATTACH_REALCREDS (PTRACE_MODE_ATTACH | PTRACE_MODE_REALCREDS) +#define PTRACE_MODE_SPEC_IBPB (PTRACE_MODE_ATTACH_REALCREDS | PTRACE_MODE_IBPB)/** * ptrace_may_access - check whether the caller is permitted to access
@@ -82,6 +85,20 @@ extern void exit_ptrace(struct task_stru*/ extern bool ptrace_may_access (struct task_struct *task,unsigned int mode); +/** +* ptrace_may_access - check whether the caller is permitted to access +* a target task. +* @task: target task +* @mode: selects type of access and caller credentials +* +* Returns true on success, false on denial. +* +* Similar to ptrace_may_access(). Only to be called from context switch +* code. Does not call into audit and the regular LSM hooks due to locking +* constraints. +*/ +extern bool ptrace_may_access_sched (struct task_struct *task,unsigned int mode); +static inline int ptrace_reparented (struct task_struct *child) {return !same_thread_group (child->real_parent, child->parent);
kernel/ptrace.c +10 -0
@@ -228,6 +228,9 @@ static int ptrace_check_attach(struct tastatic int ptrace_has_cap (struct user_namespace *ns,unsigned int mode) { +if (mode &PTRACE_MODE_SCHED ) +return false; +if (mode &PTRACE_MODE_NOAUDIT )return has_ns_capability_noaudit (current, ns,CAP_SYS_PTRACE );else
@@ -295,9 +298,16 @@ ok: !ptrace_has_cap(mm->user_ns, mode)))return -EPERM ; +if (mode &PTRACE_MODE_SCHED ) +return 0 ;return security_ptrace_access_check (task, mode); } +bool ptrace_may_access_sched (struct task_struct *task,unsigned int mode) +{ +return __ptrace_may_access (task, mode |PTRACE_MODE_SCHED ); +} +bool ptrace_may_access (struct task_struct *task,unsigned int mode) {int err;
Greg Kroah-Hartman
maintainerPATCH 164/266 HID: input: add mapping for keyboard Brightness Up/Down/Toggle keys
In reply to Greg Kroah-Hartman[ Upstream commit 7975a1d6a7afeb3eb61c971a153d24dd8fa032f3 ]
According to HUTRR73 usages 0x79, 0x7a and 0x7c from the consumer page correspond to Brightness Up/Down/Toggle keys, so let's add the mappings.
--- drivers/hid/hid-input.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hid/hid-input.c +4 -0
@@ -783,6 +783,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fielcase 0x074 :map_key_clear (KEY_BRIGHTNESS_MAX );break ;case 0x075 :map_key_clear (KEY_BRIGHTNESS_AUTO );break ; +case 0x079 :map_key_clear (KEY_KBDILLUMUP );break ; +case 0x07a :map_key_clear (KEY_KBDILLUMDOWN );break ; +case 0x07c :map_key_clear (KEY_KBDILLUMTOGGLE );break ; +case 0x082 :map_key_clear (KEY_VIDEO_NEXT );break ;case 0x083 :map_key_clear (KEY_LAST );break ;case 0x084 :map_key_clear (KEY_ENTER );break ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 200/266 x86/speculation: Propagate information about RSB filling mitigation to sysfs
In reply to Greg Kroah-HartmanFrom: Jiri Kosina <[email protected]>
commit bb4b3b7762735cdaba5a40fd94c9303d9ffa147a upstream.
If spectrev2 mitigation has been enabled, RSB is filled on context switch in order to protect from various classes of spectrev2 attacks.
If this mitigation is enabled, say so in sysfs for spectrev2.
--- arch/x86/kernel/cpu/bugs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/bugs.c +2 -1
@@ -779,10 +779,11 @@ static ssize_t cpu_show_common(struct dereturn sprintf (buf,"Mitigation: __user pointer sanitization\n" );case X86_BUG_SPECTRE_V2 : - ret =sprintf (buf,"%s%s%s%s%s\n" , spectre_v2_strings[spectre_v2_enabled], + ret =sprintf (buf,"%s%s%s%s%s%s\n" , spectre_v2_strings[spectre_v2_enabled],boot_cpu_has (X86_FEATURE_USE_IBPB ) ?", IBPB" :"" ,boot_cpu_has (X86_FEATURE_USE_IBRS_FW ) ?", IBRS_FW" :"" , (x86_spec_ctrl_base &SPEC_CTRL_STIBP ) ?", STIBP" :"" , +boot_cpu_has (X86_FEATURE_RSB_CTXSW ) ?", RSB filling" :"" ,spectre_v2_module_string ());return ret;
Greg Kroah-Hartman
maintainerPATCH 201/266 x86/speculation: Update the TIF_SSBD comment
In reply to Greg Kroah-HartmanFrom: Tim Chen <[email protected]>
commit 8eb729b77faf83ac4c1f363a9ad68d042415f24c upstream.
"Reduced Data Speculation" is an obsolete term. The correct new name is "Speculative store bypass disable" - which is abbreviated into SSBD.
--- arch/x86/include/asm/thread_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/thread_info.h +1 -1
@@ -92,7 +92,7 @@ struct thread_info {#define TIF_SIGPENDING 2/* signal pending */ #define TIF_NEED_RESCHED 3/* rescheduling necessary */ #define TIF_SINGLESTEP 4/* reenable singlestep on user return*/ -#define TIF_SSBD 5/* Reduced data speculation */ +#define TIF_SSBD 5/* Speculative store bypass disable */ #define TIF_SYSCALL_EMU 6/* syscall emulation active */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SECCOMP 8/* secure computing */
Greg Kroah-Hartman
maintainerPATCH 202/266 x86/speculation: Clean up spectre_v2_parse_cmdline()
In reply to Greg Kroah-HartmanFrom: Tim Chen <[email protected]>
commit 24848509aa55eac39d524b587b051f4e86df3c12 upstream.
Remove the unnecessary 'else' statement in spectre_v2_parse_cmdline() to save an indentation level.
--- arch/x86/kernel/cpu/bugs.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
arch/x86/kernel/cpu/bugs.c +13 -14
@@ -273,22 +273,21 @@ static enum spectre_v2_mitigation_cmd __if (cmdline_find_option_bool (boot_command_line,"nospectre_v2" ))return SPECTRE_V2_CMD_NONE ; -else { - ret =cmdline_find_option (boot_command_line,"spectre_v2" , arg,sizeof (arg)); -if (ret <0 ) -return SPECTRE_V2_CMD_AUTO ; -for (i =0 ; i <ARRAY_SIZE (mitigation_options); i++) { -if (!match_option (arg, ret, mitigation_options[i].option)) -continue ; - cmd = mitigation_options[i].cmd; -break ; - } + ret =cmdline_find_option (boot_command_line,"spectre_v2" , arg,sizeof (arg)); +if (ret <0 ) +return SPECTRE_V2_CMD_AUTO ; -if (i >=ARRAY_SIZE (mitigation_options)) { -pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); -return SPECTRE_V2_CMD_AUTO ; - } +for (i =0 ; i <ARRAY_SIZE (mitigation_options); i++) { +if (!match_option (arg, ret, mitigation_options[i].option)) +continue ; + cmd = mitigation_options[i].cmd; +break ; + } + +if (i >=ARRAY_SIZE (mitigation_options)) { +pr_err ("unknown option (%s). Switching to AUTO select\n" , arg); +return SPECTRE_V2_CMD_AUTO ; } if ((cmd == SPECTRE_V2_CMD_RETPOLINE ||
Greg Kroah-Hartman
maintainerPATCH 204/266 x86/speculation: Move STIPB/IBPB string conditionals out of cpu_show_common()
In reply to Greg Kroah-HartmanFrom: Tim Chen <[email protected]>
commit a8f76ae41cd633ac00be1b3019b1eb4741be3828 upstream.
The Spectre V2 printout in cpu_show_common() handles conditionals for the various mitigation methods directly in the sprintf() argument list. That's hard to read and will become unreadable if more complex decisions need to be made for a particular method.
Move the conditionals for STIBP and IBPB string selection into helper functions, so they can be extended later on.
--- arch/x86/kernel/cpu/bugs.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +18 -2
@@ -759,6 +759,22 @@ static void __init l1tf_select_mitigatio#ifdef CONFIG_SYSFS +static char *stibp_state (void ) +{ +if (x86_spec_ctrl_base &SPEC_CTRL_STIBP ) +return ", STIBP" ; +else +return "" ; +} + +static char *ibpb_state (void ) +{ +if (boot_cpu_has (X86_FEATURE_USE_IBPB )) +return ", IBPB" ; +else +return "" ; +} +static ssize_t cpu_show_common (struct device *dev,struct device_attribute *attr,char *buf,unsigned int bug) {
@@ -777,9 +793,9 @@ static ssize_t cpu_show_common(struct decase X86_BUG_SPECTRE_V2 :return sprintf (buf,"%s%s%s%s%s%s\n" , spectre_v2_strings[spectre_v2_enabled], -boot_cpu_has (X86_FEATURE_USE_IBPB ) ?", IBPB" :"" , +ibpb_state (),boot_cpu_has (X86_FEATURE_USE_IBRS_FW ) ?", IBRS_FW" :"" , - (x86_spec_ctrl_base &SPEC_CTRL_STIBP ) ?", STIBP" :"" , +stibp_state (),boot_cpu_has (X86_FEATURE_RSB_CTXSW ) ?", RSB filling" :"" ,spectre_v2_module_string ());
Greg Kroah-Hartman
maintainerPATCH 165/266 libnvdimm/btt: Fix a kmemdup failure check
In reply to Greg Kroah-Hartman[ Upstream commit 486fa92df4707b5df58d6508728bdb9321a59766 ]
In case kmemdup fails, the fix releases resources and returns to avoid the NULL pointer dereference.
--- drivers/nvdimm/btt_devs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/nvdimm/btt_devs.c +13 -5
@@ -170,14 +170,15 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,return NULL ; nd_btt->id =ida_simple_get (&nd_region->btt_ida,0 ,0 ,GFP_KERNEL ); -if (nd_btt->id <0 ) { -kfree (nd_btt); -return NULL ; - } +if (nd_btt->id <0 ) + goto out_nd_btt; nd_btt->lbasize = lbasize; -if (uuid) +if (uuid) { uuid =kmemdup (uuid,16 ,GFP_KERNEL ); +if (!uuid) + goto out_put_id; + } nd_btt->uuid = uuid; dev = &nd_btt->dev;dev_set_name (dev,"btt%d.%d" , nd_region->id, nd_btt->id);
@@ -192,6 +193,13 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,return NULL ; }return dev; + +out_put_id: +ida_simple_remove (&nd_region->btt_ida, nd_btt->id); + +out_nd_btt: +kfree (nd_btt); +return NULL ; }struct device *nd_btt_create (struct nd_region *nd_region)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 166/266 s390/dasd: Fix capacity calculation for large volumes
In reply to Greg Kroah-Hartman[ Upstream commit 2cc9637ce825f3a9f51f8f78af7474e9e85bfa5f ]
The DASD driver incorrectly limits the maximum number of blocks of ECKD DASD volumes to 32 bit numbers. Volumes with a capacity greater than 2^32-1 blocks are incorrectly recognized as smaller volumes.
This results in the following volume capacity limits depending on the formatted block size:
BLKSIZE MAX_GB MAX_CYL
512 2047 5843492
1024 4095 8676701
2048 8191 13634816
4096 16383 23860929The same problem occurs when a volume with more than 17895697 cylinders is accessed in raw-track-access mode.
Fix this problem by adding an explicit type cast when calculating the maximum number of blocks.
--- drivers/s390/block/dasd_eckd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/s390/block/dasd_eckd.c +3 -3
@@ -2066,14 +2066,14 @@ static int dasd_eckd_end_analysis(struct dasd_block *block) blk_per_trk =recs_per_track (&private->rdc_data,0 , block->bp_block); raw: - block->blocks = (private->real_cyl * + block->blocks = ((unsigned long ) private->real_cyl * private->rdc_data.trk_per_cyl * blk_per_trk); dev_info(&device->cdev->dev, - "DASD with %d KB/block, %d KB total size, %d KB/track, " + "DASD with %u KB/block, %lu KB total size, %u KB/track, " "%s\n", (block->bp_block >> 10), - ((private->real_cyl * + (((unsigned long) private->real_cyl * private->rdc_data.trk_per_cyl * blk_per_trk * (block->bp_block >> 9)) >> 1), ((blk_per_trk * block->bp_block) >> 10),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 168/266 KVM: x86: avoid misreporting level-triggered irqs as edge-triggered in tracing
In reply to Greg Kroah-Hartman[ Upstream commit 7a223e06b1a411cef6c4cd7a9b9a33c8d225b10e ]
In __apic_accept_irq() interface trig_mode is int and actually on some code paths it is set above u8:
kvm_apic_set_irq() extracts it from 'struct kvm_lapic_irq' where trig_mode is u16. This is done on purpose as e.g. kvm_set_msi_irq() sets it to (1 << 15) & e->msi.data
kvm_apic_local_deliver sets it to reg & (1 << 15).
Fix the immediate issue by making 'tm' into u16. We may also want to adjust __apic_accept_irq() interface and use proper sizes for vector, level, trig_mode but this is not urgent.
--- arch/x86/kvm/trace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/trace.h +2 -2
@@ -434,13 +434,13 @@ TRACE_EVENT(kvm_apic_ipi, ); TRACE_EVENT(kvm_apic_accept_irq, - TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec), + TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec), TP_ARGS(apicid, dm, tm, vec), TP_STRUCT__entry( __field( __u32, apicid ) __field( __u16, dm ) - __field( __u8, tm ) + __field( __u16, tm ) __field( __u8, vec ) ),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 160/266 mm, vmstat: make quiet_vmstat lighter
In reply to Greg Kroah-HartmanFrom: Michal Hocko <[email protected]>
commit f01f17d3705bb6081c9e5728078f64067982be36 upstream.
Mike has reported a considerable overhead of refresh_cpu_vm_stats from the idle entry during pipe test:
12.89% [kernel] [k] refresh_cpu_vm_stats.isra.12
4.75% [kernel] [k] __schedule
4.70% [kernel] [k] mutex_unlock
3.14% [kernel] [k] __switch_toThis is caused by commit 0eb77e988032 ("vmstat: make vmstat_updater deferrable again and shut down on idle") which has placed quiet_vmstat into cpu_idle_loop. The main reason here seems to be that the idle entry has to get over all zones and perform atomic operations for each vmstat entry even though there might be no per cpu diffs. This is a pointless overhead for _each_ idle entry.
Make sure that quiet_vmstat is as light as possible.
First of all it doesn't make any sense to do any local sync if the current cpu is already set in oncpu_stat_off because vmstat_update puts itself there only if there is nothing to do.
Then we can check need_update which should be a cheap way to check for potential per-cpu diffs and only then do refresh_cpu_vm_stats.
The original patch also did cancel_delayed_work which we are not doing here. There are two reasons for that. Firstly cancel_delayed_work from idle context will blow up on RT kernels (reported by Mike):
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.5.0-rt3 #7
Hardware name: MEDION MS-7848/MS-7848, BIOS M7848W08.20C 09/23/2013
Call Trace:
dump_stack+0x49/0x67
___might_sleep+0xf5/0x180
rt_spin_lock+0x20/0x50
try_to_grab_pending+0x69/0x240
cancel_delayed_work+0x26/0xe0
quiet_vmstat+0x75/0xa0
cpu_idle_loop+0x38/0x3e0
cpu_startup_entry+0x13/0x20
start_secondary+0x114/0x140And secondly, even on !RT kernels it might add some non trivial overhead which is not necessary. Even if the vmstat worker wakes up and preempts idle then it will be most likely a single shot noop because the stats were already synced and so it would end up on the oncpu_stat_off anyway. We just need to teach both vmstat_shepherd and vmstat_update to stop scheduling the worker if there is nothing to do.
--- mm/vmstat.c | 68 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 22 deletions(-)
mm/vmstat.c +46 -22
@@ -1395,10 +1395,15 @@ static void vmstat_update(struct work_st* Counters were updated so we expect more updates * to occur in the future. Keep on running the * update worker thread. +* If we were marked on cpu_stat_off clear the flag +* so that vmstat_shepherd doesn't schedule us again. */ -queue_delayed_work_on (smp_processor_id (), vmstat_wq, -this_cpu_ptr (&vmstat_work), -round_jiffies_relative (sysctl_stat_interval)); +if (!cpumask_test_and_clear_cpu (smp_processor_id (), + cpu_stat_off)) { +queue_delayed_work_on (smp_processor_id (), vmstat_wq, +this_cpu_ptr (&vmstat_work), +round_jiffies_relative (sysctl_stat_interval)); + } }else {/* * We did not update any counters so the app may be in
@@ -1426,18 +1431,6 @@ static void vmstat_update(struct work_st* until the diffs stay at zero. The function is used by NOHZ and can only be * invoked when tick processing is not active. */ -void quiet_vmstat (void ) -{ -if (system_state !=SYSTEM_RUNNING ) -return ; - -do { -if (!cpumask_test_and_set_cpu (smp_processor_id (), cpu_stat_off)) -cancel_delayed_work (this_cpu_ptr (&vmstat_work)); - - }while (refresh_cpu_vm_stats (false)); -} -/* * Check if the diffs for a certain cpu indicate that * an update is needed.
@@ -1461,6 +1454,30 @@ static bool need_update(int cpu)return false; } +void quiet_vmstat (void ) +{ +if (system_state !=SYSTEM_RUNNING ) +return ; + +/* +* If we are already in hands of the shepherd then there +* is nothing for us to do here. +*/ +if (cpumask_test_and_set_cpu (smp_processor_id (), cpu_stat_off)) +return ; + +if (!need_update (smp_processor_id ())) +return ; + +/* +* Just refresh counters and do not care about the pending delayed +* vmstat_update. It doesn't fire that often to matter and canceling +* it would be too expensive from this path. +* vmstat_shepherd will take care about that for us. +*/ +refresh_cpu_vm_stats (false); +} +/* * Shepherd worker thread that checks the
@@ -1478,18 +1495,25 @@ static void vmstat_shepherd(struct work_get_online_cpus ();/* Check processors whose vmstat worker threads have been disabled */ -for_each_cpu (cpu, cpu_stat_off) -if (need_update (cpu) && -cpumask_test_and_clear_cpu (cpu, cpu_stat_off)) - -queue_delayed_work_on (cpu, vmstat_wq, - &per_cpu (vmstat_work, cpu),0 ); +for_each_cpu (cpu, cpu_stat_off) { +struct delayed_work *dw = &per_cpu (vmstat_work, cpu); +if (need_update (cpu)) { +if (cpumask_test_and_clear_cpu (cpu, cpu_stat_off)) +queue_delayed_work_on (cpu, vmstat_wq, dw,0 ); + }else { +/* +* Cancel the work if quiet_vmstat has put this +* cpu on cpu_stat_off because the work item might +* be still scheduled +*/ +cancel_delayed_work (dw); + } + }put_online_cpus ();schedule_delayed_work (&shepherd,round_jiffies_relative (sysctl_stat_interval)); - }static void __init start_shepherd_timer (void )
Greg Kroah-Hartman
maintainerPATCH 215/266 x86/speculation: Add command line control for indirect branch speculation
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit fa1202ef224391b6f5b26cdd44cc50495e8fab54 upstream.
Add command line control for user space indirect branch speculation mitigations. The new option is: spectre_v2_user=
The initial options are:
- on: Unconditionally enabled
- off: Unconditionally disabled
-auto: Kernel selects mitigation (default off for now)When the spectre_v2= command line argument is either 'on' or 'off' this implies that the application to application control follows that state even if a contradicting spectre_v2_user= argument is supplied.
[bwh: Backported to 4.4:
- Don't use __ro_after_init or cpu_smt_control
- Adjust filename]
--- Documentation/kernel-parameters.txt | 32 ++++++++ arch/x86/include/asm/nospec-branch.h | 10 ++ arch/x86/kernel/cpu/bugs.c | 131 ++++++++++++++++++++++++++++++----- 3 files changed, 154 insertions(+), 19 deletions(-)
Documentation/kernel-parameters.txt +30 -2
@@ -3604,9 +3604,13 @@ bytes respectively. Such letter suffixes spectre_v2= [X86] Control mitigation of Spectre variant 2 (indirect branch speculation) vulnerability. + The default operation protects the kernel from + user space attacks. - on - unconditionally enable - off - unconditionally disable + on - unconditionally enable, implies + spectre_v2_user=on + off - unconditionally disable, implies + spectre_v2_user=off auto - kernel detects whether your CPU model is vulnerable
@@ -3616,6 +3620,12 @@ bytes respectively. Such letter suffixes CONFIG_RETPOLINE configuration option, and the compiler with which the kernel was built. + Selecting 'on' will also enable the mitigation + against user space to user space task attacks. + + Selecting 'off' will disable both the kernel and + the user space protections. + Specific mitigations can also be selected manually: retpoline - replace indirect branches
@@ -3625,6 +3635,24 @@ bytes respectively. Such letter suffixes Not specifying this option is equivalent to spectre_v2=auto. + spectre_v2_user= + [X86] Control mitigation of Spectre variant 2 + (indirect branch speculation) vulnerability between + user space tasks + + on - Unconditionally enable mitigations. Is + enforced by spectre_v2=on + + off - Unconditionally disable mitigations. Is + enforced by spectre_v2=off + + auto - Kernel selects the mitigation depending on + the available CPU features and vulnerability. + Default is off. + + Not specifying this option is equivalent to + spectre_v2_user=auto. + spec_store_bypass_disable= [HW] Control Speculative Store Bypass (SSB) Disable mitigation (Speculative Store Bypass vulnerability)
arch/x86/include/asm/nospec-branch.h +10 -0
@@ -3,6 +3,8 @@#ifndef _ASM_X86_NOSPEC_BRANCH_H_#define _ASM_X86_NOSPEC_BRANCH_H_ +#include <linux/static_key.h> +#include <asm/alternative.h> #include <asm/alternative-asm.h> #include <asm/cpufeatures.h>
@@ -172,6 +174,12 @@ enum spectre_v2_mitigation { SPECTRE_V2_IBRS_ENHANCED, }; +/* The indirect branch speculation control variants */ +enum spectre_v2_user_mitigation { +SPECTRE_V2_USER_NONE , +SPECTRE_V2_USER_STRICT , +}; +/* The Speculative Store Bypass disable variants */ enum ssb_mitigation {SPEC_STORE_BYPASS_NONE ,
@@ -248,6 +256,8 @@ do { \ preempt_enable(); \ }while (0 ) +DECLARE_STATIC_KEY_FALSE (switch_to_cond_stibp); +#endif /* __ASSEMBLY__ */ /*
arch/x86/kernel/cpu/bugs.c +114 -17
177 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 206/266 x86/speculation: Rename SSBD update functions
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 26c4d75b234040c11728a8acb796b3a85ba7507c upstream.
During context switch, the SSBD bit in SPEC_CTRL MSR is updated according to changes of the TIF_SSBD flag in the current and next running task.
Currently, only the bit controlling speculative store bypass disable in SPEC_CTRL MSR is updated and the related update functions all have "speculative_store" or "ssb" in their names.
For enhanced mitigation control other bits in SPEC_CTRL MSR need to be updated as well, which makes the SSB names inadequate.
Rename the "speculative_store*" functions to a more generic name. No functional change.
--- arch/x86/include/asm/spec-ctrl.h | 6 +++--- arch/x86/kernel/cpu/bugs.c | 4 ++-- arch/x86/kernel/process.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/include/asm/spec-ctrl.h +3 -3
@@ -70,11 +70,11 @@ extern void speculative_store_bypass_ht_static inline void speculative_store_bypass_ht_init (void ) { }#endif -extern void speculative_store_bypass_update (unsigned long tif); +extern void speculation_ctrl_update (unsigned long tif); -static inline void speculative_store_bypass_update_current (void ) +static inline void speculation_ctrl_update_current (void ) { -speculative_store_bypass_update (current_thread_info ()->flags); +speculation_ctrl_update (current_thread_info ()->flags); }#endif
arch/x86/kernel/cpu/bugs.c +2 -2
@@ -192,7 +192,7 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, tif = setguest ?ssbd_spec_ctrl_to_tif (guestval) :ssbd_spec_ctrl_to_tif (hostval); -speculative_store_bypass_update (tif); +speculation_ctrl_update (tif); } }EXPORT_SYMBOL_GPL (x86_virt_spec_ctrl);
@@ -629,7 +629,7 @@ static int ssb_prctl_set(struct task_str* mitigation until it is next scheduled. */ if (task == current && update) -speculative_store_bypass_update_current (); +speculation_ctrl_update_current ();return 0 ; }
arch/x86/kernel/process.c +6 -6
@@ -317,27 +317,27 @@ static __always_inline void amd_set_ssb_wrmsrl (MSR_AMD64_VIRT_SPEC_CTRL ,ssbd_tif_to_spec_ctrl (tifn)); } -static __always_inline void intel_set_ssb_state(unsigned long tifn) +static __always_inline void spec_ctrl_update_msr(unsigned long tifn) {u64 msr = x86_spec_ctrl_base |ssbd_tif_to_spec_ctrl (tifn);wrmsrl (MSR_IA32_SPEC_CTRL , msr); } -static __always_inline void __speculative_store_bypass_update(unsigned long tifn) +static __always_inline void __speculation_ctrl_update(unsigned long tifn) {if (static_cpu_has (X86_FEATURE_VIRT_SSBD ))amd_set_ssb_virt_state (tifn);else if (static_cpu_has (X86_FEATURE_LS_CFG_SSBD ))amd_set_core_ssb_state (tifn);else -intel_set_ssb_state (tifn); +spec_ctrl_update_msr (tifn); } -void speculative_store_bypass_update (unsigned long tif) +void speculation_ctrl_update (unsigned long tif) {preempt_disable (); -__speculative_store_bypass_update (tif); +__speculation_ctrl_update (tif);preempt_enable (); }
@@ -371,7 +371,7 @@ void __switch_to_xtra(struct task_structcr4_toggle_bits (X86_CR4_TSD );if ((tifp ^ tifn) & _TIF_SSBD) -__speculative_store_bypass_update (tifn); +__speculation_ctrl_update (tifn); }/*
Greg Kroah-Hartman
maintainerPATCH 217/266 x86/process: Consolidate and simplify switch_to_xtra() code
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit ff16701a29cba3aafa0bd1656d766813b2d0a811 upstream.
Move the conditional invocation of __switch_to_xtra() into an inline function so the logic can be shared between 32 and 64 bit.
Remove the handthrough of the TSS pointer and retrieve the pointer directly in the bitmap handling function. Use this_cpu_ptr() instead of the per_cpu() indirection.
This is a preparatory change so integration of conditional indirect branch speculation optimization happens only in one place.
[bwh: Backported to 4.4:
- Use cpu_tss instead of cpu_tss_rw
- __switch_to() still uses the tss variable, so don't delete it
- Adjust context]
--- arch/x86/include/asm/switch_to.h | 3 --- arch/x86/kernel/process.c | 12 +++++++----- arch/x86/kernel/process.h | 24 ++++++++++++++++++++++++ arch/x86/kernel/process_32.c | 9 +++------ arch/x86/kernel/process_64.c | 9 +++------ 5 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 arch/x86/kernel/process.h
arch/x86/include/asm/switch_to.h +0 -3
@@ -6,9 +6,6 @@struct task_struct ;/* one of the stranger aspects of C forward declarations */ __visible struct task_struct *__switch_to(struct task_struct *prev,struct task_struct *next); -struct tss_struct ; -void __switch_to_xtra (struct task_struct *prev_p,struct task_struct *next_p, -struct tss_struct *tss);#ifdef CONFIG_X86_32
arch/x86/kernel/process.c +7 -5
@@ -33,6 +33,8 @@#include <asm/vm86.h> #include <asm/spec-ctrl.h> +#include "process.h" +/* * per-CPU TSS segments. Threads are completely 'soft' on Linux, * no more per-task TSS's. The TSS size is kept cacheline-aligned
@@ -179,11 +181,12 @@ int set_tsc_mode(unsigned int val)return 0 ; } -static inline void switch_to_bitmap (struct tss_struct *tss, -struct thread_struct *prev, +static inline void switch_to_bitmap (struct thread_struct *prev,struct thread_struct *next,unsigned long tifp,unsigned long tifn) { +struct tss_struct *tss =this_cpu_ptr (&cpu_tss); +if (tifn & _TIF_IO_BITMAP) {/* * Copy the relevant range of the IO bitmap.
@@ -370,8 +373,7 @@ void speculation_ctrl_update(unsigned lopreempt_enable (); } -void __switch_to_xtra (struct task_struct *prev_p,struct task_struct *next_p, -struct tss_struct *tss) +void __switch_to_xtra (struct task_struct *prev_p,struct task_struct *next_p) {struct thread_struct *prev, *next;unsigned long tifp, tifn;
@@ -381,7 +383,7 @@ void __switch_to_xtra(struct task_struct tifn =READ_ONCE (task_thread_info (next_p)->flags); tifp =READ_ONCE (task_thread_info (prev_p)->flags); -switch_to_bitmap (tss, prev, next, tifp, tifn); +switch_to_bitmap (prev, next, tifp, tifn);propagate_user_return_notify (prev_p, next_p);
arch/x86/kernel/process.h new file +24 -0
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Code shared between 32 and 64 bit + +void __switch_to_xtra (struct task_struct *prev_p,struct task_struct *next_p); + +/* +* This needs to be inline to optimize for the common case where no extra +* work needs to be done. +*/ +static inline void switch_to_extra (struct task_struct *prev, +struct task_struct *next) +{ +unsigned long next_tif =task_thread_info (next)->flags; +unsigned long prev_tif =task_thread_info (prev)->flags; + +/* +* __switch_to_xtra() handles debug registers, i/o bitmaps, +* speculation mitigations etc. +*/ +if (unlikely (next_tif & _TIF_WORK_CTXSW_NEXT || + prev_tif & _TIF_WORK_CTXSW_PREV)) +__switch_to_xtra (prev, next); +}
arch/x86/kernel/process_32.c +3 -6
@@ -55,6 +55,8 @@#include <asm/switch_to.h> #include <asm/vm86.h> +#include "process.h" + asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
@@ -279,12 +281,7 @@ __switch_to(struct task_struct *prev_p,if (get_kernel_rpl () &&unlikely (prev->iopl != next->iopl))set_iopl_mask (next->iopl); -/* -* Now maybe handle debug registers and/or IO bitmaps -*/ -if (unlikely (task_thread_info (prev_p)->flags & _TIF_WORK_CTXSW_PREV || -task_thread_info (next_p)->flags & _TIF_WORK_CTXSW_NEXT)) -__switch_to_xtra (prev_p, next_p, tss); +switch_to_extra (prev_p, next_p);/* * Leave lazy mode, flushing any hypercalls made here.
arch/x86/kernel/process_64.c +3 -6
@@ -50,6 +50,8 @@#include <asm/switch_to.h> #include <asm/xen/hypervisor.h> +#include "process.h" + asmlinkage extern void ret_from_fork(void);__visible DEFINE_PER_CPU (unsigned long ,rsp_scratch );
@@ -406,12 +408,7 @@ __switch_to(struct task_struct *prev_p,/* Reload esp0 and ss1. This changes current_thread_info(). */ load_sp0 (tss, next); -/* -* Now maybe reload the debug registers and handle I/O bitmaps -*/ -if (unlikely (task_thread_info (next_p)->flags & _TIF_WORK_CTXSW_NEXT || -task_thread_info (prev_p)->flags & _TIF_WORK_CTXSW_PREV)) -__switch_to_xtra (prev_p, next_p, tss); +switch_to_extra (prev_p, next_p);#ifdef CONFIG_XEN /*