Bluetooth: btusb: fix QCA Rome suspend/resume
Subsystems (215)
[added to the 4.1 stable tree] netlink: fix nla_put_{u8,u16,u32} for KASAN
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b4391db42308c9940944b5d7be5ca4b78fb88dd0 ]
When CONFIG_KASAN is enabled, the "--param asan-stack=1" causes rather large stack frames in some functions. This goes unnoticed normally because CONFIG_FRAME_WARN is disabled with CONFIG_KASAN by default as of commit 3f181b4d8652 ("lib/Kconfig.debug: disable -Wframe-larger-than warnings with KASAN=y").
The kernelci.org build bot however has the warning enabled and that led me to investigate it a little further, as every build produces these warnings:
net/wireless/nl80211.c:4389:1: warning: the frame size of 2240 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1895:1: warning: the frame size of 3776 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1410:1: warning: the frame size of 2208 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/bridge/br_netlink.c:1282:1: warning: the frame size of 2544 bytes is larger than 2048 bytes [-Wframe-larger-than=]
Most of this problem is now solved in gcc-8, which can consolidate the stack slots for the inline function arguments. On older compilers we can add a workaround by declaring a local variable in each function to pass the inline function argument.
--- include/net/netlink.h | 73 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 18 deletions(-)
include/net/netlink.h +55 -18
@@ -745,7 +745,10 @@ static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,*/ static inline int nla_put_u8 (struct sk_buff *skb,int attrtype,u8 value) { -return nla_put (skb, attrtype,sizeof (u8), &value); +/* temporary variables to work around GCC PR81715 with asan-stack=1 */ +u8 tmp = value; + +return nla_put (skb, attrtype,sizeof (u8), &tmp); }/**
@@ -756,7 +759,9 @@ static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value)*/ static inline int nla_put_u16 (struct sk_buff *skb,int attrtype,u16 value) { -return nla_put (skb, attrtype,sizeof (u16), &value); +u16 tmp = value; + +return nla_put (skb, attrtype,sizeof (u16), &tmp); }/**
@@ -767,7 +772,9 @@ static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value)*/ static inline int nla_put_be16 (struct sk_buff *skb,int attrtype,__be16 value) { -return nla_put (skb, attrtype,sizeof (__be16), &value); +__be16 tmp = value; + +return nla_put (skb, attrtype,sizeof (__be16), &tmp); }/**
@@ -778,7 +785,9 @@ static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)*/ static inline int nla_put_net16 (struct sk_buff *skb,int attrtype,__be16 value) { -return nla_put_be16 (skb, attrtype |NLA_F_NET_BYTEORDER , value); +__be16 tmp = value; + +return nla_put_be16 (skb, attrtype |NLA_F_NET_BYTEORDER , tmp); }/**
@@ -789,7 +798,9 @@ static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value)*/ static inline int nla_put_le16 (struct sk_buff *skb,int attrtype,__le16 value) { -return nla_put (skb, attrtype,sizeof (__le16), &value); +__le16 tmp = value; + +return nla_put (skb, attrtype,sizeof (__le16), &tmp); }/**
@@ -800,7 +811,9 @@ static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value)*/ static inline int nla_put_u32 (struct sk_buff *skb,int attrtype,u32 value) { -return nla_put (skb, attrtype,sizeof (u32), &value); +u32 tmp = value; + +return nla_put (skb, attrtype,sizeof (u32), &tmp); }/**
@@ -811,7 +824,9 @@ static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value)*/ static inline int nla_put_be32 (struct sk_buff *skb,int attrtype,__be32 value) { -return nla_put (skb, attrtype,sizeof (__be32), &value); +__be32 tmp = value; + +return nla_put (skb, attrtype,sizeof (__be32), &tmp); }/**
@@ -822,7 +837,9 @@ static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)*/ static inline int nla_put_net32 (struct sk_buff *skb,int attrtype,__be32 value) { -return nla_put_be32 (skb, attrtype |NLA_F_NET_BYTEORDER , value); +__be32 tmp = value; + +return nla_put_be32 (skb, attrtype |NLA_F_NET_BYTEORDER , tmp); }/**
@@ -833,7 +850,9 @@ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value)*/ static inline int nla_put_le32 (struct sk_buff *skb,int attrtype,__le32 value) { -return nla_put (skb, attrtype,sizeof (__le32), &value); +__le32 tmp = value; + +return nla_put (skb, attrtype,sizeof (__le32), &tmp); }/**
@@ -844,7 +863,9 @@ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value)*/ static inline int nla_put_u64 (struct sk_buff *skb,int attrtype,u64 value) { -return nla_put (skb, attrtype,sizeof (u64), &value); +u64 tmp = value; + +return nla_put (skb, attrtype,sizeof (u64), &tmp); }/**
@@ -855,7 +876,9 @@ static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value)*/ static inline int nla_put_be64 (struct sk_buff *skb,int attrtype,__be64 value) { -return nla_put (skb, attrtype,sizeof (__be64), &value); +__be64 tmp = value; + +return nla_put (skb, attrtype,sizeof (__be64), &tmp); }/**
@@ -866,7 +889,9 @@ static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)*/ static inline int nla_put_net64 (struct sk_buff *skb,int attrtype,__be64 value) { -return nla_put_be64 (skb, attrtype |NLA_F_NET_BYTEORDER , value); +__be64 tmp = value; + +return nla_put_be64 (skb, attrtype |NLA_F_NET_BYTEORDER , tmp); }/**
@@ -877,7 +902,9 @@ static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value)*/ static inline int nla_put_le64 (struct sk_buff *skb,int attrtype,__le64 value) { -return nla_put (skb, attrtype,sizeof (__le64), &value); +__le64 tmp = value; + +return nla_put (skb, attrtype,sizeof (__le64), &tmp); }/**
@@ -888,7 +915,9 @@ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value)*/ static inline int nla_put_s8 (struct sk_buff *skb,int attrtype,s8 value) { -return nla_put (skb, attrtype,sizeof (s8), &value); +s8 tmp = value; + +return nla_put (skb, attrtype,sizeof (s8), &tmp); }/**
@@ -899,7 +928,9 @@ static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value)*/ static inline int nla_put_s16 (struct sk_buff *skb,int attrtype,s16 value) { -return nla_put (skb, attrtype,sizeof (s16), &value); +s16 tmp = value; + +return nla_put (skb, attrtype,sizeof (s16), &tmp); }/**
@@ -910,7 +941,9 @@ static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value)*/ static inline int nla_put_s32 (struct sk_buff *skb,int attrtype,s32 value) { -return nla_put (skb, attrtype,sizeof (s32), &value); +s32 tmp = value; + +return nla_put (skb, attrtype,sizeof (s32), &tmp); }/**
@@ -921,7 +954,9 @@ static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value)*/ static inline int nla_put_s64 (struct sk_buff *skb,int attrtype,s64 value) { -return nla_put (skb, attrtype,sizeof (s64), &value); +s64 tmp = value; + +return nla_put (skb, attrtype,sizeof (s64), &tmp); }/**
@@ -969,7 +1004,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,static inline int nla_put_in_addr (struct sk_buff *skb,int attrtype,__be32 addr) { -return nla_put_be32 (skb, attrtype, addr); +__be32 tmp = addr; + +return nla_put_be32 (skb, attrtype, tmp); }/**
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] [media] v4l: remove MEDIA_TUNER dependency for VIDEO_TUNER
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7c8fe516bd81d991feb73ccd969ec29850af3013 ]
em28xx selects VIDEO_TUNER, which has a dependency on MEDIA_TUNER, so we get a Kconfig warning if that is disabled:
warning: (VIDEO_PVRUSB2 && VIDEO_USBVISION && VIDEO_GO7007 && VIDEO_AU0828_V4L2 && VIDEO_CX231XX && VIDEO_TM6000 && VIDEO_EM28XX && VIDEO_IVTV && VIDEO_MXB && VIDEO_CX18 && VIDEO_CX23885 && VIDEO_CX88 && VIDEO_BT848 && VIDEO_SAA7134 && VIDEO_SAA7164) selects VIDEO_TUNER which has unmet direct dependencies (MEDIA_SUPPORT && MEDIA_TUNER)
VIDEO_TUNER does not actually depend on MEDIA_TUNER, and the dependency does nothing except cause the above warning, so let's remove it.
--- drivers/media/v4l2-core/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/media/v4l2-core/Kconfig +0 -1
@@ -37,7 +37,6 @@ config VIDEO_PCI_SKELETON # Used by drivers that need tuner.ko config VIDEO_TUNER tristate - depends on MEDIA_TUNER # Used by drivers that need v4l2-mem2mem.ko config V4L2_MEM2MEM_DEV
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cw1200: fix bogus maybe-uninitialized warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7fc1503c906f0fac62d3506a6e993e49fb996248 ]
On x86, the cw1200 driver produces a rather silly warning about the possible use of the 'ret' variable without an initialization presumably after being confused by the architecture specific definition of WARN_ON:
drivers/net/wireless/st/cw1200/wsm.c: In function ‘wsm_handle_rx’:drivers/net/wireless/st/cw1200/wsm.c:1457:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
We have already checked that 'count' is larger than 0 here, so we know that 'ret' is initialized. Changing the 'for' loop into do/while also makes this clear to the compiler.
--- drivers/net/wireless/cw1200/wsm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/wireless/cw1200/wsm.c +3 -5
@@ -379,7 +379,6 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv, {int ret;int count; -int i; count =WSM_GET32 (buf);if (WARN_ON (count <=0 ))
@@ -395,11 +394,10 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv, }cw1200_debug_txed_multi (priv, count); -for (i =0 ; i < count; ++i) { +do { ret =wsm_tx_confirm (priv, buf, link_id); -if (ret) -return ret; - } + }while (!ret && --count); +return ret; underflow:
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] dell-wmi, dell-laptop: depends DMI
In reply to Sasha LevinFrom: Andy Lutomirski <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a570af4850043260b87fb1b8aa27a4484e648878 ]
dell-wmi and dell-laptop will compile but won't work right if DMI isn't selected.
[arnd: Use depends instead of selects to avoid recursive dependencies]
--- drivers/platform/x86/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/x86/Kconfig +2 -0
@@ -94,6 +94,7 @@ config DELL_LAPTOP tristate "Dell Laptop Extras" depends on X86 depends on DCDBAS + depends on DMI depends on BACKLIGHT_CLASS_DEVICE depends on RFKILL || RFKILL = n depends on SERIO_I8042
@@ -108,6 +109,7 @@ config DELL_LAPTOP config DELL_WMI tristate "Dell WMI extras" depends on ACPI_WMI + depends on DMI depends on INPUT select INPUT_SPARSEKMAP ---help---
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] perf/x86: Shut up false-positive -Wmaybe-uninitialized warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 11d8b05855f3749bcb6c57e2c4052921b9605c77 ]
The intialization function checks for various failure scenarios, but unfortunately the compiler gets a little confused about the possible combinations, leading to a false-positive build warning when -Wmaybe-uninitialized is set:
arch/x86/events/core.c: In function ‘init_hw_perf_events’:
arch/x86/events/core.c:264:3: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/events/core.c:264:3: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized]
pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n",
We can't actually run into this case, so this shuts up the warning by initializing the variables to a known-invalid state.
--- arch/x86/kernel/cpu/perf_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event.c +2 -2
@@ -187,8 +187,8 @@ static void release_pmc_hardware(void) {}static bool check_hw_exists (void ) { -u64 val, val_fail, val_new= ~0 ; -int i, reg, reg_fail, ret =0 ; +u64 val, val_fail =-1 , val_new= ~0 ; +int i, reg, reg_fail =-1 , ret =0 ;int bios_fail =0 ;int reg_safe =-1 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] ncpfs: fix unused variable warning
In reply to Sasha LevinFrom: Miklos Szeredi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9a232de4999666b2e8ea6775b2b0e3e4feb09b7a ]
Without CONFIG_NCPFS_NLS the following warning is seen:
fs/ncpfs/dir.c: In function 'ncp_hash_dentry':fs/ncpfs/dir.c:136:23: warning: unused variable 'sb' [-Wunused-variable]
struct super_block *sb = dentry->d_sb;
--- fs/ncpfs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ncpfs/dir.c +1 -2
@@ -133,12 +133,11 @@ ncp_hash_dentry(const struct dentry *dentry, struct qstr *this)return 0 ;if (!ncp_case_sensitive (inode)) { -struct super_block *sb = dentry->d_sb;struct nls_table *t;unsigned long hash;int i; - t =NCP_IO_TABLE (sb); + t =NCP_IO_TABLE (dentry->d_sb); hash =init_name_hash ();for (i=0 ; i<this->len ; i++) hash = partial_name_hash(ncp_tolower(t, this->name[i]),
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Documentation: Document array_index_nospec
In reply to Sasha LevinFrom: Mark Rutland <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f84a56f73dddaeac1dba8045b007f742f61cd2da ]
Document the rationale and usage of the new array_index_nospec() helper.
--- Documentation/speculation.txt | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/speculation.txt
Documentation/speculation.txt new file +90 -0
@@ -0,0 +1,90 @@ +This document explains potential effects of speculation, and how undesirable +effects can be mitigated portably using common APIs. + +=========== +Speculation +=========== + +To improve performance and minimize average latencies, many contemporary CPUs +employ speculative execution techniques such as branch prediction, performing +work which may be discarded at a later stage. + +Typically speculative execution cannot be observed from architectural state, +such as the contents of registers. However, in some cases it is possible to +observe its impact on microarchitectural state, such as the presence or +absence of data in caches. Such state may form side-channels which can be +observed to extract secret information. + +For example, in the presence of branch prediction, it is possible for bounds +checks to be ignored by code which is speculatively executed. Consider the +following code: + + int load_array(int *array, unsigned int index) + { + if (index >= MAX_ARRAY_ELEMS) + return 0; + else + return array[index]; + } + +Which, on arm64, may be compiled to an assembly sequence such as: + + CMP <index>, #MAX_ARRAY_ELEMS + B.LT less + MOV <returnval>, #0 + RET + less: + LDR <returnval>, [<array>, <index>] + RET + +It is possible that a CPU mis-predicts the conditional branch, and +speculatively loads array[index], even if index >= MAX_ARRAY_ELEMS. This +value will subsequently be discarded, but the speculated load may affect +microarchitectural state which can be subsequently measured. + +More complex sequences involving multiple dependent memory accesses may +result in sensitive information being leaked. Consider the following +code, building on the prior example: + + int load_dependent_arrays(int *arr1, int *arr2, int index) + { + int val1, val2, + + val1 = load_array(arr1, index); + val2 = load_array(arr2, val1); + + return val2; + } + +Under speculation, the first call to load_array() may return the value +of an out-of-bounds address, while the second call will influence +microarchitectural state dependent on this value. This may provide an +arbitrary read primitive. + +==================================== +Mitigating speculation side-channels +==================================== + +The kernel provides a generic API to ensure that bounds checks are +respected even under speculation. Architectures which are affected by +speculation-based side-channels are expected to implement these +primitives. + +The array_index_nospec() helper in <linux/nospec.h> can be used to +prevent information from being leaked via side-channels. + +A call to array_index_nospec(index, size) returns a sanitized index +value that is bounded to [0, size) even under cpu speculation +conditions. + +This can be used to protect the earlier load_array() example: + + int load_array(int *array, unsigned int index) + { + if (index >= MAX_ARRAY_ELEMS) + return 0; + else { + index = array_index_nospec(index, MAX_ARRAY_ELEMS); + return array[index]; + } + }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] net: hp100: remove unnecessary #ifdefs
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 747a11279a442b913a57bf38934879babab3b58b ]
Building the hp100 ethernet driver causes warnings when both the PCI and EISA drivers are disabled:
ethernet/hp/hp100.c: In function 'hp100_module_init':ethernet/hp/hp100.c:3047:2: warning: label 'out3' defined but not used [-Wunused-label] ethernet/hp/hp100.c: At top level:ethernet/hp/hp100.c:2828:13: warning: 'cleanup_dev' defined but not used [-Wunused-function]
We can easily avoid the warnings and make the driver look slightly nicer by removing the #ifdefs that check for the CONFIG_PCI and CONFIG_EISA, as all the registration functions are designed to have no effect when the buses are disabled.
--- drivers/net/ethernet/hp/hp100.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/net/ethernet/hp/hp100.c +0 -18
@@ -194,7 +194,6 @@ static const char *hp100_isa_tbl[] = { };#endif -#ifdef CONFIG_EISA static struct eisa_device_id hp100_eisa_tbl[] = { {"HWPF180" },/* HP J2577 rev A */ {"HWP1920" },/* HP 27248B */
@@ -205,9 +204,7 @@ static struct eisa_device_id hp100_eisa_tbl[] = { { "" } /* Mandatory final entry ! */ };MODULE_DEVICE_TABLE (eisa, hp100_eisa_tbl); -#endif -#ifdef CONFIG_PCI static const struct pci_device_id hp100_pci_tbl[] = { {PCI_VENDOR_ID_HP ,PCI_DEVICE_ID_HP_J2585A ,PCI_ANY_ID ,PCI_ANY_ID ,}, {PCI_VENDOR_ID_HP ,PCI_DEVICE_ID_HP_J2585B ,PCI_ANY_ID ,PCI_ANY_ID ,},
@@ -219,7 +216,6 @@ static const struct pci_device_id hp100_pci_tbl[] = { {}/* Terminating entry */ };MODULE_DEVICE_TABLE (pci, hp100_pci_tbl); -#endif static int hp100_rx_ratio =HP100_DEFAULT_RX_RATIO ;static int hp100_priority_tx =HP100_DEFAULT_PRIORITY_TX ;
@@ -2842,7 +2838,6 @@ static void cleanup_dev(struct net_device *d)free_netdev (d); } -#ifdef CONFIG_EISA static int hp100_eisa_probe (struct device *gendev) {struct net_device *dev =alloc_etherdev (sizeof (struct hp100_private ));
@@ -2884,9 +2879,7 @@ static struct eisa_driver hp100_eisa_driver = { .remove = hp100_eisa_remove, } }; -#endif -#ifdef CONFIG_PCI static int hp100_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {
@@ -2955,7 +2948,6 @@ static struct pci_driver hp100_pci_driver = { .probe = hp100_pci_probe, .remove = hp100_pci_remove, }; -#endif /* * module section
@@ -3032,23 +3024,17 @@ static int __init hp100_module_init(void) err =hp100_isa_init ();if (err && err != -ENODEV ) goto out; -#ifdef CONFIG_EISA err =eisa_driver_register (&hp100_eisa_driver);if (err && err != -ENODEV ) goto out2; -#endif -#ifdef CONFIG_PCI err =pci_register_driver (&hp100_pci_driver);if (err && err != -ENODEV ) goto out3; -#endif out:return err; out3: -#ifdef CONFIG_EISA eisa_driver_unregister (&hp100_eisa_driver); out2: -#endif hp100_isa_cleanup (); goto out; }
@@ -3057,12 +3043,8 @@ static int __init hp100_module_init(void) static void __exit hp100_module_exit(void) {hp100_isa_cleanup (); -#ifdef CONFIG_EISA eisa_driver_unregister (&hp100_eisa_driver); -#endif -#ifdef CONFIG_PCI pci_unregister_driver (&hp100_pci_driver); -#endif }module_init (hp100_module_init)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] drm/gma500: remove helper function
In reply to Sasha LevinFrom: Sudip Mukherjee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit db9b60400f9253c25ae639797df2d0ff7a35d9d8 ]
We were getting build warning about:drivers/gpu/drm/gma500/mdfld_dsi_output.c:407:2: warning: initialization
from incompatible pointer type
The callback to dpms was pointing to a helper function which had a return type of void, whereas the callback should point to a function which has a return type of int.
On closer look it turned out that we do not need the helper function since if we call drm_helper_connector_dpms() directly, the first check that drm_helper_connector_dpms() does is: if (mode == connector->dpms)
--- drivers/gpu/drm/gma500/mdfld_dsi_output.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/gma500/mdfld_dsi_output.c +1 -11
@@ -382,16 +382,6 @@ static int mdfld_dsi_connector_mode_valid(struct drm_connector *connector,return MODE_OK ; } -static void mdfld_dsi_connector_dpms (struct drm_connector *connector,int mode) -{ -if (mode == connector->dpms) -return ; - -/*first, execute dpms*/ - -drm_helper_connector_dpms (connector, mode); -} -static struct drm_encoder *mdfld_dsi_connector_best_encoder (struct drm_connector *connector) {
@@ -404,7 +394,7 @@ static struct drm_encoder *mdfld_dsi_connector_best_encoder(/*DSI connector funcs*/ static const struct drm_connector_funcs mdfld_dsi_connector_funcs = { - .dpms =/*drm_helper_connector_dpms*/ mdfld_dsi_connector_dpms, + .dpms = drm_helper_connector_dpms, .save = mdfld_dsi_connector_save, .restore = mdfld_dsi_connector_restore, .detect = mdfld_dsi_connector_detect,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9a6e7c39810e4a8bc7fc95056cefb40583fe07ef ]
qemu-system-x86-8600 [004] d..1 7205.687530: kvm_entry: vcpu 2
qemu-system-x86-8600 [004] .... 7205.687532: kvm_exit: reason EXCEPTION_NMI rip 0xffffffffa921297d info ffffeb2c0e44e018 80000b0e
qemu-system-x86-8600 [004] .... 7205.687532: kvm_page_fault: address ffffeb2c0e44e018 error_code 0
qemu-system-x86-8600 [004] .... 7205.687620: kvm_try_async_get_page: gva = 0xffffeb2c0e44e018, gfn = 0x427e4e
qemu-system-x86-8600 [004] .N.. 7205.687628: kvm_async_pf_not_present: token 0x8b002 gva 0xffffeb2c0e44e018
kworker/4:2-7814 [004] .... 7205.687655: kvm_async_pf_completed: gva 0xffffeb2c0e44e018 address 0x7fcc30c4e000
qemu-system-x86-8600 [004] .... 7205.687703: kvm_async_pf_ready: token 0x8b002 gva 0xffffeb2c0e44e018
qemu-system-x86-8600 [004] d..1 7205.687711: kvm_entry: vcpu 2After running some memory intensive workload in guest, I catch the kworker which completes the GUP too quickly, and queues an "Page Ready" #PF exception after the "Page not Present" exception before the next vmentry as the above trace which will result in #DF injected to guest.
This patch fixes it by clearing the queue for "Page not Present" if "Page Ready" occurs before the next vmentry since the GUP has already got the required page and shadow page table has already been fixed by "Page Ready" handler.
--- arch/x86/kvm/x86.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
arch/x86/kvm/x86.c +26 -8
@@ -7927,6 +7927,13 @@ static int apf_put_user(struct kvm_vcpu *vcpu, u32 val) sizeof(val)); } +static int apf_get_user (struct kvm_vcpu *vcpu,u32 *val) +{ + +return kvm_read_guest_cached (vcpu->kvm, &vcpu->arch.apf.data, val, +sizeof (u32)); +} +void kvm_arch_async_page_not_present (struct kvm_vcpu *vcpu,struct kvm_async_pf *work) {
@@ -7953,6 +7960,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, struct kvm_async_pf *work) {struct x86_exception fault; +u32 val;if (work->wakeup_all) work->arch.token = ~0 ;/* broadcast wakeup */
@@ -7960,14 +7968,24 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,kvm_del_async_pf_gfn (vcpu, work->arch.gfn);trace_kvm_async_pf_ready (work->arch.token, work->gva); -if ((vcpu->arch.apf.msr_val &KVM_ASYNC_PF_ENABLED ) && - !apf_put_user (vcpu,KVM_PV_REASON_PAGE_READY )) { - fault.vector =PF_VECTOR ; - fault.error_code_valid = true; - fault.error_code =0 ; - fault.nested_page_fault = false; - fault.address = work->arch.token; -kvm_inject_page_fault (vcpu, &fault); +if (vcpu->arch.apf.msr_val &KVM_ASYNC_PF_ENABLED && + !apf_get_user (vcpu, &val)) { +if (val ==KVM_PV_REASON_PAGE_NOT_PRESENT && + vcpu->arch.exception.pending && + vcpu->arch.exception.nr ==PF_VECTOR && + !apf_put_user (vcpu,0 )) { + vcpu->arch.exception.pending = false; + vcpu->arch.exception.nr =0 ; + vcpu->arch.exception.has_error_code = false; + vcpu->arch.exception.error_code =0 ; + }else if (!apf_put_user (vcpu,KVM_PV_REASON_PAGE_READY )) { + fault.vector =PF_VECTOR ; + fault.error_code_valid = true; + fault.error_code =0 ; + fault.nested_page_fault = false; + fault.address = work->arch.token; +kvm_inject_page_fault (vcpu, &fault); + } } vcpu->arch.apf.halted = false; vcpu->arch.mp_state =KVM_MP_STATE_RUNNABLE ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] array_index_nospec: Sanitize speculative array de-references
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f3804203306e098dae9ca51540fcd5eb700d7f40 ]
array_index_nospec() is proposed as a generic mechanism to mitigate against Spectre-variant-1 attacks, i.e. an attack that bypasses boundary checks via speculative execution. The array_index_nospec() implementation is expected to be safe for current generation CPUs across multiple architectures (ARM, x86).
Based on an original implementation by Linus Torvalds, tweaked to remove speculative flows by Alexei Starovoitov, and tweaked again by Linus to introduce an x86 assembly implementation for the mask generation.
--- include/linux/nospec.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 include/linux/nospec.h
include/linux/nospec.h new file +72 -0
@@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2018 Linus Torvalds. All rights reserved. +// Copyright(c) 2018 Alexei Starovoitov. All rights reserved. +// Copyright(c) 2018 Intel Corporation. All rights reserved. + +#ifndef _LINUX_NOSPEC_H +#define _LINUX_NOSPEC_H + +/** +* array_index_mask_nospec() - generate a ~0 mask when index < size, 0 otherwise +* @index: array element index +* @size: number of elements in array +* +* When @index is out of bounds (@index >= @size), the sign bit will be +* set. Extend the sign bit to all bits and invert, giving a result of +* zero for an out of bounds index, or ~0 if within bounds [0, @size). +*/ +#ifndef array_index_mask_nospec +static inline unsigned long array_index_mask_nospec (unsigned long index, +unsigned long size) +{ +/* +* Warn developers about inappropriate array_index_nospec() usage. +* +* Even if the CPU speculates past the WARN_ONCE branch, the +* sign bit of @index is taken into account when generating the +* mask. +* +* This warning is compiled out when the compiler can infer that +* @index and @size are less than LONG_MAX. +*/ +if (WARN_ONCE (index >LONG_MAX || size >LONG_MAX , +"array_index_nospec() limited to range of [0, LONG_MAX]\n" )) +return 0 ; + +/* +* Always calculate and emit the mask even if the compiler +* thinks the mask is not needed. The compiler does not take +* into account the value of @index under speculation. +*/ +OPTIMIZER_HIDE_VAR (index); +return ~(long )(index | (size -1UL - index)) >> (BITS_PER_LONG -1 ); +} +#endif + +/* +* array_index_nospec - sanitize an array index after a bounds check +* +* For a code sequence like: +* +* if (index < size) { +* index = array_index_nospec(index, size); +* val = array[index]; +* } +* +* ...if the CPU speculates past the bounds check then +* array_index_nospec() will clamp the index within the range of [0, +* size). +*/ +#define array_index_nospec (index, size) \ +({ \ + typeof(index) _i = (index); \ + typeof(size) _s = (size); \ + unsigned long _mask = array_index_mask_nospec(_i, _s); \ + \ + BUILD_BUG_ON(sizeof(_i) > sizeof(long)); \ + BUILD_BUG_ON(sizeof(_s) > sizeof(long)); \ + \ + _i &= _mask; \ + _i; \ +}) +#endif /* _LINUX_NOSPEC_H */
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/get_user: Use pointer masking to limit speculation
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c7f631cb07e7da06ac1d231ca178452339e32a94 ]
Quoting Linus:
I do think that it would be a good idea to very expressly document the fact that it's not that the user access itself is unsafe. I do agree that things like "get_user()" want to be protected, but not because of any direct bugs or problems with get_user() and friends, but simply because get_user() is an excellent source of a pointer that is obviously controlled from a potentially attacking user space. So it's a prime candidate for then finding _subsequent_ accesses that can then be used to perturb the cache.
Unlike the __get_user() case get_user() includes the address limit check near the pointer de-reference. With that locality the speculation can be mitigated with pointer narrowing rather than a barrier, i.e. array_index_nospec(). Where the narrowing is performed by:
cmp %limit, %ptr
sbb %mask, %mask
and %mask, %ptr
With respect to speculation the value of %ptr is either less than %limit or NULL.
--- arch/x86/lib/getuser.S | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/lib/getuser.S +10 -0
@@ -40,6 +40,8 @@ ENTRY(__get_user_1) GET_THREAD_INFO(%_ASM_DX) cmp TI_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 1: movzbl (%_ASM_AX),%edx xor %eax,%eax
@@ -55,6 +57,8 @@ ENTRY(__get_user_2) GET_THREAD_INFO(%_ASM_DX) cmp TI_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 2: movzwl -1(%_ASM_AX),%edx xor %eax,%eax
@@ -70,6 +74,8 @@ ENTRY(__get_user_4) GET_THREAD_INFO(%_ASM_DX) cmp TI_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 3: movl -3(%_ASM_AX),%edx xor %eax,%eax
@@ -86,6 +92,8 @@ ENTRY(__get_user_8) GET_THREAD_INFO(%_ASM_DX) cmp TI_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 4: movq -7(%_ASM_AX),%rdx xor %eax,%eax
@@ -97,6 +105,8 @@ ENTRY(__get_user_8) GET_THREAD_INFO(%_ASM_DX) cmp TI_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user_8 + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 4: movl -7(%_ASM_AX),%edx 5: movl -3(%_ASM_AX),%ecx
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] vfs, fdtable: Prevent bounds-check bypass via speculative execution
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 56c30ba7b348b90484969054d561f711ba196507 ]
'fd' is a user controlled value that is used as a data dependency to read from the 'fdt->fd' array. In order to avoid potential leaks of kernel memory values, block speculative execution of the instruction stream that could issue reads based on an invalid 'file *' returned from __fcheck_files.
--- include/linux/fdtable.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/fdtable.h +4 -1
@@ -9,6 +9,7 @@#include <linux/compiler.h> #include <linux/spinlock.h> #include <linux/rcupdate.h> +#include <linux/nospec.h> #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h>
@@ -76,8 +77,10 @@ static inline struct file *__fcheck_files(struct files_struct *files, unsigned i {struct fdtable *fdt =rcu_dereference_raw (files->fdt); -if (fd < fdt->max_fds) +if (fd < fdt->max_fds) { + fd =array_index_nospec (fd, fdt->max_fds);return rcu_dereference_raw (fdt->fd[fd]); + }return NULL ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86: Implement array_index_mask_nospec
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit babdde2698d482b6c0de1eab4f697cf5856c5859 ]
array_index_nospec() uses a mask to sanitize user controllable array indexes, i.e. generate a 0 mask if 'index' >= 'size', and a ~0 mask otherwise. While the default array_index_mask_nospec() handles the carry-bit from the (index - size) result in software.
The x86 array_index_mask_nospec() does the same, but the carry-bit is handled in the processor CF flag without conditional instructions in the control flow.
--- arch/x86/include/asm/barrier.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/x86/include/asm/barrier.h +24 -0
@@ -24,6 +24,30 @@#define wmb () asm volatile("sfence" ::: "memory")#endif +/** +* array_index_mask_nospec() - generate a mask that is ~0UL when the +* bounds check succeeds and 0 otherwise +* @index: array element index +* @size: number of elements in array +* +* Returns: +* 0 - (index < size) +*/ +static inline unsigned long array_index_mask_nospec (unsigned long index, +unsigned long size) +{ +unsigned long mask; + + asm ("cmp %1,%2; sbb %0,%0;" + :"=r" (mask) + :"r" (size),"r" (index) + :"cc" ); +return mask; +} + +/* Override the default implementation from linux/nospec.h. */ +#define array_index_mask_nospec array_index_mask_nospec +#ifdef CONFIG_X86_PPRO_FENCE #define dma_rmb () rmb()#else
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/paravirt: Remove 'noreplace-paravirt' cmdline option
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 12c69f1e94c89d40696e83804dd2f0965b5250cd ]
The 'noreplace-paravirt' option disables paravirt patching, leaving the original pv indirect calls in place.
That's highly incompatible with retpolines, unless we want to uglify paravirt even further and convert the paravirt calls to retpolines.
As far as I can tell, the option doesn't seem to be useful for much other than introducing surprising corner cases and making the kernel vulnerable to Spectre v2. It was probably a debug option from the early paravirt days. So just remove it.
--- Documentation/kernel-parameters.txt | 2 -- arch/x86/kernel/alternative.c | 14 -------------- 2 files changed, 16 deletions(-)
Documentation/kernel-parameters.txt +0 -2
@@ -2476,8 +2476,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted. norandmaps Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space - noreplace-paravirt [X86,IA-64,PV_OPS] Don't patch paravirt_ops - noreplace-smp [X86-32,SMP] Don't replace SMP instructions with UP alternatives
arch/x86/kernel/alternative.c +0 -14
@@ -41,17 +41,6 @@ static int __init setup_noreplace_smp(char *str) }__setup ("noreplace-smp" , setup_noreplace_smp); -#ifdef CONFIG_PARAVIRT -static int __initdata_or_module noreplace_paravirt = 0; - -static int __init setup_noreplace_paravirt (char *str) -{ - noreplace_paravirt =1 ; -return 1 ; -} -__setup ("noreplace-paravirt" , setup_noreplace_paravirt); -#endif - #define DPRINTK(fmt, args...) \ do { \ if (debug_alternative) \
@@ -574,9 +563,6 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,struct paravirt_patch_site *p;char insnbuf[MAX_PATCH_LEN ]; -if (noreplace_paravirt) -return ; -for (p = start; p < end; p++) {unsigned int used;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/kvm: Update spectre-v1 mitigation
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 085331dfc6bbe3501fb936e657331ca943827600 ]
Commit 75f139aaf896 "KVM: x86: Add memory barrier on vmcs field lookup" added a raw 'asm("lfence");' to prevent a bounds check bypass of 'vmcs_field_to_offset_table'.
The lfence can be avoided in this path by using the array_index_nospec() helper designed for these types of fixes.
--- arch/x86/kvm/vmx.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/x86/kvm/vmx.c +9 -11
@@ -32,6 +32,7 @@#include <linux/slab.h> #include <linux/tboot.h> #include <linux/hrtimer.h> +#include <linux/nospec.h> #include "kvm_cache_regs.h" #include "x86.h"
@@ -770,21 +771,18 @@ static const unsigned short vmcs_field_to_offset_table[] = {static inline short vmcs_field_to_offset (unsigned long field) { -BUILD_BUG_ON (ARRAY_SIZE (vmcs_field_to_offset_table) >SHRT_MAX ); +const size_t size =ARRAY_SIZE (vmcs_field_to_offset_table); +unsigned short offset; -if (field >=ARRAY_SIZE (vmcs_field_to_offset_table)) +BUILD_BUG_ON (size >SHRT_MAX ); +if (field >= size)return -ENOENT ; -/* -* FIXME: Mitigation for CVE-2017-5753. To be replaced with a -* generic mechanism. -*/ - asm("lfence" ); - -if (vmcs_field_to_offset_table[field] ==0 ) + field =array_index_nospec (field, size); + offset = vmcs_field_to_offset_table[field]; +if (offset ==0 )return -ENOENT ; - -return vmcs_field_to_offset_table[field]; +return offset; }static inline struct vmcs12 *get_vmcs12 (struct kvm_vcpu *vcpu)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] nl80211: Sanitize array index in parse_txq_params
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 259d8c1e984318497c84eef547bbb6b1d9f4eb05 ]
Wireless drivers rely on parse_txq_params to validate that txq_params->ac is less than NL80211_NUM_ACS by the time the low-level driver's ->conf_tx() handler is called. Use a new helper, array_index_nospec(), to sanitize txq_params->ac with respect to speculation. I.e. ensure that any speculation into ->conf_tx() handlers is done with a value of txq_params->ac that is within the bounds of [0, NL80211_NUM_ACS).
--- net/wireless/nl80211.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/wireless/nl80211.c +6 -3
@@ -15,6 +15,7 @@#include <linux/nl80211.h> #include <linux/rtnetlink.h> #include <linux/netlink.h> +#include <linux/nospec.h> #include <linux/etherdevice.h> #include <net/net_namespace.h> #include <net/genetlink.h>
@@ -1874,20 +1875,22 @@ static const struct nla_policy txq_params_policy[NL80211_TXQ_ATTR_MAX + 1] = {static int parse_txq_params (struct nlattr *tb[],struct ieee80211_txq_params *txq_params) { +u8 ac; +if (!tb[NL80211_TXQ_ATTR_AC ] || !tb[NL80211_TXQ_ATTR_TXOP ] || !tb[NL80211_TXQ_ATTR_CWMIN ] || !tb[NL80211_TXQ_ATTR_CWMAX ] || !tb[NL80211_TXQ_ATTR_AIFS ])return -EINVAL ; - txq_params->ac =nla_get_u8 (tb[NL80211_TXQ_ATTR_AC ]); + ac =nla_get_u8 (tb[NL80211_TXQ_ATTR_AC ]); txq_params->txop =nla_get_u16 (tb[NL80211_TXQ_ATTR_TXOP ]); txq_params->cwmin =nla_get_u16 (tb[NL80211_TXQ_ATTR_CWMIN ]); txq_params->cwmax =nla_get_u16 (tb[NL80211_TXQ_ATTR_CWMAX ]); txq_params->aifs =nla_get_u8 (tb[NL80211_TXQ_ATTR_AIFS ]); -if (txq_params->ac >=NL80211_NUM_ACS ) +if (ac >=NL80211_NUM_ACS )return -EINVAL ; - + txq_params->ac =array_index_nospec (ac,NL80211_NUM_ACS );return 0 ; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/retpoline: Avoid retpolines for built-in __init functions
In reply to Sasha LevinFrom: David Woodhouse <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 66f793099a636862a71c59d4a6ba91387b155e0c ]
There's no point in building init code with retpolines, since it runs before any potentially hostile userspace does. And before the retpoline is actually ALTERNATIVEd into place, for much of it.
--- include/linux/init.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/init.h +8 -1
@@ -4,6 +4,13 @@#include <linux/compiler.h> #include <linux/types.h> +/* Built-in __init functions needn't be compiled with retpoline */ +#if defined(RETPOLINE ) && !defined(MODULE ) +#define __noretpoline __attribute__((indirect_branch("keep"))) +#else +#define __noretpoline +#endif +/* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data) * as `initialization' functions. The kernel can take this
@@ -39,7 +46,7 @@/* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold notrace +#define __init __section(.init.text) __cold notrace __noretpoline#define __initdata __section(.init.data)#define __initconst __constsection(.init.rodata)#define __exitdata __section(.exit.data)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: nVMX: kmap() can't fail
In reply to Sasha LevinFrom: David Hildenbrand <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 42cf014d38d8822cce63703a467e00f65d000952 ]
kmap() can't fail, therefore it will always return a valid pointer. Let's just get rid of the unnecessary checks.
--- arch/x86/kvm/vmx.c | 9 --------- 1 file changed, 9 deletions(-)
arch/x86/kvm/vmx.c +0 -9
@@ -4382,10 +4382,6 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)return 0 ; vapic_page =kmap (vmx->nested.virtual_apic_page); -if (!vapic_page) { -WARN_ON (1 ); -return -ENOMEM ; - }__kvm_apic_update_irr (vmx->nested.pi_desc->pir, vapic_page);kunmap (vmx->nested.virtual_apic_page);
@@ -8825,11 +8821,6 @@ static inline bool nested_vmx_merge_msr_bitmap(struct kvm_vcpu *vcpu,return false; } msr_bitmap = (unsigned long *)kmap (page); -if (!msr_bitmap) { -nested_release_page_clean (page); -WARN_ON (1 ); -return false; - }if (nested_cpu_has_virt_x2apic_mode (vmcs12)) {if (nested_cpu_has_apic_reg_virt (vmcs12))
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] KVM: nVMX: vmx_complete_nested_posted_interrupt() can't fail
In reply to Sasha LevinFrom: David Hildenbrand <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6342c50ad12e8ce0736e722184a7dbdea4a3477f ]
vmx_complete_nested_posted_interrupt() can't fail, let's turn it into a void function.
--- arch/x86/kvm/vmx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx.c +5 -5
@@ -4362,7 +4362,7 @@ static int vmx_vm_has_apicv(struct kvm *kvm)return enable_apicv &&irqchip_in_kernel (kvm); } -static int vmx_complete_nested_posted_interrupt (struct kvm_vcpu *vcpu) +static void vmx_complete_nested_posted_interrupt (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu);int max_irr;
@@ -4373,13 +4373,13 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) vmx->nested.pi_pending) { vmx->nested.pi_pending = false;if (!pi_test_and_clear_on (vmx->nested.pi_desc)) -return 0 ; +return ; max_irr =find_last_bit ( (unsigned long *)vmx->nested.pi_desc->pir,256 );if (max_irr ==256 ) -return 0 ; +return ; vapic_page =kmap (vmx->nested.virtual_apic_page);__kvm_apic_update_irr (vmx->nested.pi_desc->pir, vapic_page);
@@ -4392,7 +4392,6 @@ static int vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu)vmcs_write16 (GUEST_INTR_STATUS , status); } } -return 0 ; }static inline bool kvm_vcpu_trigger_posted_interrupt (struct kvm_vcpu *vcpu)
@@ -9730,7 +9729,8 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr)return 0 ; } -return vmx_complete_nested_posted_interrupt (vcpu); +vmx_complete_nested_posted_interrupt (vcpu); +return 0 ; }static u32 vmx_get_preemption_timer_value (struct kvm_vcpu *vcpu)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode
In reply to Sasha LevinFrom: Kamil Konieczny <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c927b080c67e3e97193c81fc1d27f4251bf4e036 ]
In AES-ECB mode crypt is done with key only, so any use of IV can cause kernel Oops. Use IV only in AES-CBC and AES-CTR.
--- drivers/crypto/s5p-sss.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/crypto/s5p-sss.c +9 -4
@@ -419,16 +419,21 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode)uint32_t aes_control;int err;unsigned long flags; +u8 *iv; aes_control =SSS_AES_KEY_CHANGE_MODE ;if (mode &FLAGS_AES_DECRYPT ) aes_control |=SSS_AES_MODE_DECRYPT ; -if ((mode &FLAGS_AES_MODE_MASK ) ==FLAGS_AES_CBC ) +if ((mode &FLAGS_AES_MODE_MASK ) ==FLAGS_AES_CBC ) { aes_control |=SSS_AES_CHAIN_MODE_CBC ; -else if ((mode &FLAGS_AES_MODE_MASK ) ==FLAGS_AES_CTR ) + iv = req->info; + }else if ((mode &FLAGS_AES_MODE_MASK ) ==FLAGS_AES_CTR ) { aes_control |=SSS_AES_CHAIN_MODE_CTR ; - + iv = req->info; + }else { + iv =NULL ;/* AES_ECB */ + }if (dev->ctx->keylen ==AES_KEYSIZE_192 ) aes_control |=SSS_AES_KEY_SIZE_192 ;else if (dev->ctx->keylen ==AES_KEYSIZE_256 )
@@ -458,7 +463,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) goto outdata_error;SSS_AES_WRITE (dev,AES_CONTROL , aes_control); -s5p_set_aes (dev, dev->ctx->aes_key, req->info, dev->ctx->keylen); +s5p_set_aes (dev, dev->ctx->aes_key, iv, dev->ctx->keylen);s5p_set_dma_indata (dev, req->src);s5p_set_dma_outdata (dev, req->dst);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] netfilter: drop outermost socket lock in getsockopt()
In reply to Sasha LevinFrom: Paolo Abeni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 01ea306f2ac2baff98d472da719193e738759d93 ]
The Syzbot reported a possible deadlock in the netfilter area caused by rtnl lock, xt lock and socket lock being acquired with a different order on different code paths, leading to the following backtrace:
======================================================
WARNING: possible circular locking dependency detected 4.15.0+ #301 Not tainted
------------------------------------------------------
syzkaller233489/4179 is trying to acquire lock:
(rtnl_mutex){+.+.}, at: [<0000000048e996fd>] rtnl_lock+0x17/0x20net/core/rtnetlink.c:74
but task is already holding lock:
(&xt[i].mutex){+.+.}, at: [<00000000328553a2>]xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1041
which lock already depends on the new lock.
===
Since commit 3f34cfae1230 ("netfilter: on sockopt() acquire sock lock only in the required scope"), we already acquire the socket lock in the innermost scope, where needed. In such commit I forgot to remove the outer-most socket lock from the getsockopt() path, this commit addresses the issues dropping it now.
v1 -> v2: fix bad subj, added relavant 'fixes' tag
--- net/ipv4/ip_sockglue.c | 7 +------ net/ipv6/ipv6_sockglue.c | 10 ++-------- 2 files changed, 3 insertions(+), 14 deletions(-)
net/ipv4/ip_sockglue.c +1 -6
@@ -1491,10 +1491,7 @@ int ip_getsockopt(struct sock *sk, int level,if (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =nf_getsockopt (sk,PF_INET , optname, optval, - &len); -release_sock (sk); + err =nf_getsockopt (sk,PF_INET , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen);return err;
@@ -1526,9 +1523,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname,if (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); err =compat_nf_getsockopt (sk,PF_INET , optname, optval, &len); -release_sock (sk);if (err >=0 ) err =put_user (len, optlen);return err;
net/ipv6/ipv6_sockglue.c +2 -8
@@ -1331,10 +1331,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,if (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =nf_getsockopt (sk,PF_INET6 , optname, optval, - &len); -release_sock (sk); + err =nf_getsockopt (sk,PF_INET6 , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen); }
@@ -1373,10 +1370,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,if (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =compat_nf_getsockopt (sk,PF_INET6 , - optname, optval, &len); -release_sock (sk); + err =compat_nf_getsockopt (sk,PF_INET6 , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen); }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] PCI: keystone: Fix interrupt-controller-node lookup
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit eac56aa3bc8af3d9b9850345d0f2da9d83529134 ]
Fix child-node lookup during initialisation which was using the wrong OF-helper and ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent pci node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument. Any matching child interrupt-controller node was also leaked.
--- drivers/pci/host/pci-keystone.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/pci/host/pci-keystone.c +7 -2
@@ -179,14 +179,16 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, }/* interrupt controller is in a child node */ - *np_temp =of_find_node_by_name (np_pcie, controller); + *np_temp =of_get_child_by_name (np_pcie, controller);if (!(*np_temp)) {dev_err (dev,"Node for %s is absent\n" , controller); goto out; } temp =of_irq_count (*np_temp); -if (!temp) +if (!temp) { +of_node_put (*np_temp); goto out; + }if (temp > max_host_irqs)dev_warn (dev,"Too many %s interrupts defined %u\n" , (legacy ?"legacy" :"MSI" ), temp);
@@ -200,6 +202,9 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie,if (!host_irqs[temp])break ; } + +of_node_put (*np_temp); +if (temp) { *num_irqs = temp; ret =0 ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] scsi: ibmvfc: fix misdefined reserved field in ibmvfc_fcp_rsp_info
In reply to Sasha LevinFrom: Tyrel Datwyler <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c39813652700f3df552b6557530f1e5f782dbe2f ]
The fcp_rsp_info structure as defined in the FC spec has an initial 3 bytes reserved field. The ibmvfc driver mistakenly defined this field as 4 bytes resulting in the rsp_code field being defined in what should be the start of the second reserved field and thus always being reported as zero by the driver.
Ideally, we should wire ibmvfc up with libfc for the sake of code deduplication, and ease of maintaining standardized structures in a single place. However, for now simply fixup the definition in ibmvfc for backporting to distros on older kernels. Wiring up with libfc will be done in a followup patch.
--- drivers/scsi/ibmvscsi/ibmvfc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ibmvscsi/ibmvfc.h +1 -1
@@ -366,7 +366,7 @@ enum ibmvfc_fcp_rsp_info_codes { };struct ibmvfc_fcp_rsp_info { -__be16 reserved; +u8 reserved[3 ];u8 rsp_code;u8 reserved2[4 ]; }__attribute__((packed,aligned (2 )));
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] cfg80211: fix cfg80211_beacon_dup
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bee92d06157fc39d5d7836a061c7d41289a55797 ]
gcc-8 warns about some obviously incorrect code:
net/mac80211/cfg.c: In function 'cfg80211_beacon_dup':net/mac80211/cfg.c:2896:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
Quoted 1 line
From the context, I conclude that we want to copy from beacon into
new_beacon, as we do in the rest of the function.
--- net/mac80211/cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/cfg.c +1 -1
@@ -2857,7 +2857,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) }if (beacon->probe_resp_len) { new_beacon->probe_resp_len = beacon->probe_resp_len; - beacon->probe_resp = pos; + new_beacon->probe_resp = pos;memcpy (pos, beacon->probe_resp, beacon->probe_resp_len); pos += beacon->probe_resp_len; }
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] iio: buffer: check if a buffer has been set up when poll is called
In reply to Sasha LevinFrom: Stefan Windfeldt-Prytz <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4cd140bda6494543f1c1b0ccceceaa44b676eef6 ]
If no iio buffer has been set up and poll is called return 0. Without this check there will be a null pointer dereference when calling poll on a iio driver without an iio buffer.
--- drivers/iio/industrialio-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/industrialio-buffer.c +1 -1
@@ -150,7 +150,7 @@ unsigned int iio_buffer_poll(struct file *filp,struct iio_dev *indio_dev = filp->private_data;struct iio_buffer *rb = indio_dev->buffer; -if (!indio_dev->info) +if (!indio_dev->info || rb ==NULL )return 0 ;poll_wait (filp, &rb->pollq, wait);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] iio: adis_lib: Initialize trigger before requesting interrupt
In reply to Sasha LevinFrom: Lars-Peter Clausen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f027e0b3a774e10302207e91d304bbf99e3a8b36 ]
The adis_probe_trigger() creates a new IIO trigger and requests an interrupt associated with the trigger. The interrupt uses the generic iio_trigger_generic_data_rdy_poll() function as its interrupt handler.
Currently the driver initializes some fields of the trigger structure after the interrupt has been requested. But an interrupt can fire as soon as it has been requested. This opens up a race condition.
iio_trigger_generic_data_rdy_poll() will access the trigger data structure and dereference the ops field. If the ops field is not yet initialized this will result in a NULL pointer deref.
It is not expected that the device generates an interrupt at this point, so typically this issue did not surface unless e.g. due to a hardware misconfiguration (wrong interrupt number, wrong polarity, etc.).
But some newer devices from the ADIS family start to generate periodic interrupts in their power-on reset configuration and unfortunately the interrupt can not be masked in the device. This makes the race condition much more visible and the following crash has been observed occasionally when booting a system using the ADIS16460.
Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = c0004000 [00000008] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.0-04126-gf9739f0-dirty #257 Hardware name: Xilinx Zynq Platform task: ef04f640 task.stack: ef050000 PC is at iio_trigger_notify_done+0x30/0x68 LR is at iio_trigger_generic_data_rdy_poll+0x18/0x20 pc : [<c042d868>] lr : [<c042d924>] psr: 60000193 sp : ef051bb8 ip : 00000000 fp : ef106400 r10: c081d80a r9 : ef3bfa00 r8 : 00000087 r7 : ef051bec r6 : 00000000 r5 : ef3bfa00 r4 : ee92ab00 r3 : 00000000 r2 : 00000000 r1 : 00000000 r0 : ee97e400 Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none Control: 18c5387d Table: 0000404a DAC: 00000051 Process swapper/0 (pid: 1, stack limit = 0xef050210) [<c042d868>] (iio_trigger_notify_done) from [<c0065b10>] (__handle_irq_event_percpu+0x88/0x118) [<c0065b10>] (__handle_irq_event_percpu) from [<c0065bbc>] (handle_irq_event_percpu+0x1c/0x58) [<c0065bbc>] (handle_irq_event_percpu) from [<c0065c30>] (handle_irq_event+0x38/0x5c) [<c0065c30>] (handle_irq_event) from [<c0068e28>] (handle_level_irq+0xa4/0x130) [<c0068e28>] (handle_level_irq) from [<c0064e74>] (generic_handle_irq+0x24/0x34) [<c0064e74>] (generic_handle_irq) from [<c021ab7c>] (zynq_gpio_irqhandler+0xb8/0x13c) [<c021ab7c>] (zynq_gpio_irqhandler) from [<c0064e74>] (generic_handle_irq+0x24/0x34) [<c0064e74>] (generic_handle_irq) from [<c0065370>] (__handle_domain_irq+0x5c/0xb4) [<c0065370>] (__handle_domain_irq) from [<c000940c>] (gic_handle_irq+0x48/0x8c) [<c000940c>] (gic_handle_irq) from [<c0013e8c>] (__irq_svc+0x6c/0xa8)
To fix this make sure that the trigger is fully initialized before requesting the interrupt.
--- drivers/iio/imu/adis_trigger.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iio/imu/adis_trigger.c +4 -3
@@ -47,6 +47,10 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)if (adis->trig ==NULL )return -ENOMEM ; + adis->trig->dev.parent = &adis->spi->dev; + adis->trig->ops = &adis_trigger_ops; +iio_trigger_set_drvdata (adis->trig, adis); + ret = request_irq(adis->spi->irq, &iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING,
@@ -55,9 +59,6 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)if (ret) goto error_free_trig; - adis->trig->dev.parent = &adis->spi->dev; - adis->trig->ops = &adis_trigger_ops; -iio_trigger_set_drvdata (adis->trig, adis); ret =iio_trigger_register (adis->trig); indio_dev->trig =iio_trigger_get (adis->trig);
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] x86/oprofile: Fix bogus GCC-8 warning in nmi_setup()
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 85c615eb52222bc5fab6c7190d146bc59fac289e ]
GCC-8 shows a warning for the x86 oprofile code that copies per-CPU data from CPU 0 to all other CPUs, which when building a non-SMP kernel turns into a memcpy() with identical source and destination pointers:
arch/x86/oprofile/nmi_int.c: In function 'mux_clone':
arch/x86/oprofile/nmi_int.c:285:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
memcpy(per_cpu(cpu_msrs, cpu).multiplex,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
per_cpu(cpu_msrs, 0).multiplex,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(struct op_msr) * model->num_virt_counters);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/oprofile/nmi_int.c: In function 'nmi_setup':
arch/x86/oprofile/nmi_int.c:466:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict] arch/x86/oprofile/nmi_int.c:470:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict]
I have analyzed a number of such warnings now: some are valid and the GCC warning is welcome. Others turned out to be false-positives, and GCC was changed to not warn about those any more. This is a corner case that is a false-positive but the GCC developers feel it's better to keep warning about it.
In this case, it seems best to work around it by telling GCC a little more clearly that this code path is never hit with an IS_ENABLED() configuration check.
--- arch/x86/oprofile/nmi_int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/oprofile/nmi_int.c +1 -1
@@ -471,7 +471,7 @@ static int nmi_setup(void) goto fail;for_each_possible_cpu (cpu) { -if (!cpu) +if (!IS_ENABLED (CONFIG_SMP ) || !cpu)continue ; memcpy(per_cpu(cpu_msrs, cpu).counters,
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] irqchip/gic-v3: Use wmb() instead of smb_wmb() in gic_raise_softirq()
In reply to Sasha LevinFrom: Shanker Donthineni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 21ec30c0ef5234fb1039cc7c7737d885bf875a9e ]
A DMB instruction can be used to ensure the relative order of only memory accesses before and after the barrier. Since writes to system registers are not memory operations, barrier DMB is not sufficient for observability of memory accesses that occur before ICC_SGI1R_EL1 writes.
A DSB instruction ensures that no instructions that appear in program order after the DSB instruction, can execute until the DSB instruction has completed.
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -584,7 +584,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)* Ensure that stores to Normal memory are visible to the * other CPUs before issuing the IPI. */ -smp_wmb (); +wmb ();for_each_cpu (cpu, mask) {u64 cluster_id =cpu_logical_map (cpu) & ~0xffUL ;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: ohci: Proper handling of ed_rm_list to handle race condition between usb_kill_urb() and finish_unlinks()
In reply to Sasha LevinFrom: AMAN DEEP <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 46408ea558df13b110e0866b99624384a33bdeba ]
There is a race condition between finish_unlinks->finish_urb() function and usb_kill_urb() in ohci controller case. The finish_urb calls spin_unlock(&ohci->lock) before usb_hcd_giveback_urb() function call, then if during this time, usb_kill_urb is called for another endpoint, then new ed will be added to ed_rm_list at beginning for unlink, and ed_rm_list will point to newly added.
When finish_urb() is completed in finish_unlinks() and ed->td_list becomes empty as in below code (in finish_unlinks() function):
if (list_empty(&ed->td_list)) {
*last = ed->ed_next;
ed->ed_next = NULL;
} else if (ohci->rh_state == OHCI_RH_RUNNING) {
*last = ed->ed_next;
ed->ed_next = NULL;
ed_schedule(ohci, ed);
}The *last = ed->ed_next will make ed_rm_list to point to ed->ed_next and previously added ed by usb_kill_urb will be left unreferenced by ed_rm_list. This causes usb_kill_urb() hang forever waiting for finish_unlink to remove added ed from ed_rm_list.
The main reason for hang in this race condtion is addition and removal of ed from ed_rm_list in the beginning during usb_kill_urb and later last* is modified in finish_unlinks().
As suggested by Alan Stern, the solution for proper handling of ohci->ed_rm_list is to remove ed from the ed_rm_list before finishing any URBs. Then at the end, we can add ed back to the list if necessary.
This properly handle the updated ohci->ed_rm_list in usb_kill_urb().
--- drivers/usb/host/ohci-q.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/usb/host/ohci-q.c +10 -7
@@ -1017,6 +1017,8 @@ static void finish_unlinks(struct ohci_hcd *ohci)* have modified this list. normally it's just prepending * entries (which we'd ignore), but paranoia won't hurt. */ + *last = ed->ed_next; + ed->ed_next =NULL ; modified =0 ;/* unlink urbs as requested, but rescan the list after
@@ -1075,21 +1077,22 @@ static void finish_unlinks(struct ohci_hcd *ohci) goto rescan_this;/* -* If no TDs are queued, take ED off the ed_rm_list. +* If no TDs are queued, ED is now idle. * Otherwise, if the HC is running, reschedule. -* If not, leave it on the list for further dequeues. +* If the HC isn't running, add ED back to the +* start of the list for later processing. */ if (list_empty (&ed->td_list)) { - *last = ed->ed_next; - ed->ed_next =NULL ; ed->state =ED_IDLE ;list_del (&ed->in_use_list); }else if (ohci->rh_state ==OHCI_RH_RUNNING ) { - *last = ed->ed_next; - ed->ed_next =NULL ;ed_schedule (ohci, ed); }else { - last = &ed->ed_next; + ed->ed_next = ohci->ed_rm_list; + ohci->ed_rm_list = ed; +/* Don't loop on the same ED */ +if (last == &ohci->ed_rm_list) + last = &ed->ed_next; }if (modified)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] arm64: Disable unhandled signal log messages by default
In reply to Sasha LevinFrom: Michael Weiser <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5ee39a71fd89ab7240c5339d04161c44a8e03269 ]
aarch64 unhandled signal kernel messages are very verbose, suggesting them to be more of a debugging aid:
sigsegv[33]: unhandled level 2 translation fault (11) at 0x00000000, esr 0x92000046, in sigsegv[400000+71000]
CPU: 1 PID: 33 Comm: sigsegv Tainted: G W 4.15.0-rc3+ #3 Hardware name: linux,dummy-virt (DT) pstate: 60000000 (nZCv daif -PAN -UAO) pc : 0x4003f4 lr : 0x4006bc
sp : 0000fffffe94a060
x29: 0000fffffe94a070 x28: 0000000000000000
x27: 0000000000000000 x26: 0000000000000000
x25: 0000000000000000 x24: 00000000004001b0
x23: 0000000000486ac8 x22: 00000000004001c8
x21: 0000000000000000 x20: 0000000000400be8
x19: 0000000000400b30 x18: 0000000000484728
x17: 000000000865ffc8 x16: 000000000000270f
x15: 00000000000000b0 x14: 0000000000000002
x13: 0000000000000001 x12: 0000000000000000
x11: 0000000000000000 x10: 0008000020008008 x9 : 000000000000000f x8 : ffffffffffffffff x7 : 0004000000000000 x6 : ffffffffffffffff x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000004003e4 x2 : 0000fffffe94a1e8 x1 : 000000000000000a x0 : 0000000000000000
Disable them by default, so they can be enabled using /proc/sys/debug/exception-trace.
--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/traps.c +1 -1
@@ -46,7 +46,7 @@ static const char *handler[]= { "Error" }; -int show_unhandled_signals =1 ; +int show_unhandled_signals =0 ;/* * Dump out the contents of some memory nicely...
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] Add delay-init quirk for Corsair K70 RGB keyboards
In reply to Sasha LevinFrom: Jack Stocker <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7a1646d922577b5b48c0d222e03831141664bb59 ]
Following on from this patch: https://lkml.org/lkml/2017/11/3/516,
Corsair K70 RGB keyboards also require the DELAY_INIT quirk to start correctly at boot.
Device ids found here:
usb 3-3: New USB device found, idVendor=1b1c, idProduct=1b13 usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 3-3: Product: Corsair K70 RGB Gaming Keyboard
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -225,6 +225,9 @@ static const struct usb_device_id usb_quirk_list[] = { { USB_DEVICE(0x1a0a, 0x0200), .driver_info = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, + /* Corsair K70 RGB */ + { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, + /* Corsair Strafe RGB */ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: dwc3: gadget: Set maxpacket size for ep0 IN
In reply to Sasha LevinFrom: Thinh Nguyen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6180026341e852a250e1f97ebdcf71684a3c81b9 ]
There are 2 control endpoint structures for DWC3. However, the driver only updates the OUT direction control endpoint structure during ConnectDone event. DWC3 driver needs to update the endpoint max packet size for control IN endpoint as well. If the max packet size is not properly set, then the driver will incorrectly calculate the data transfer size and fail to send ZLP for HS/FS 3-stage control read transfer.
The fix is simply to update the max packet size for the ep0 IN direction during ConnectDone event.
--- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/dwc3/gadget.c +2 -0
@@ -2376,6 +2376,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)break ; } + dwc->eps[1 ]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket; +/* Enable USB2 LPM Capability */ if ((dwc->revision > DWC3_REVISION_194A)
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: ldusb: add PIDs for new CASSY devices supported by this driver
In reply to Sasha LevinFrom: Karsten Koop <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 52ad2bd8918158266fc88a05f95429b56b6a33c5 ]
This patch adds support for new CASSY devices to the ldusb driver. The PIDs are also added to the ignore list in hid-quirks.
--- drivers/hid/hid-core.c | 3 +++ drivers/hid/hid-ids.h | 3 +++ drivers/usb/misc/ldusb.c | 6 ++++++ 3 files changed, 12 insertions(+)
drivers/hid/hid-core.c +3 -0
@@ -2350,6 +2350,9 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
drivers/hid/hid-ids.h +3 -0
@@ -559,6 +559,9 @@#define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033#define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035#define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 +#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 +#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 +#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043#define USB_DEVICE_ID_LD_JWM 0x1080#define USB_DEVICE_ID_LD_DMMP 0x1081#define USB_DEVICE_ID_LD_UMIP 0x1090
drivers/usb/misc/ldusb.c +6 -0
@@ -46,6 +46,9 @@#define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033/* USB Product ID of Micro-CASSY Time (reserved) */ #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035/* USB Product ID of Micro-CASSY Temperature */ #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038/* USB Product ID of Micro-CASSY pH */ +#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040/* USB Product ID of Power Analyser CASSY */ +#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042/* USB Product ID of Converter Controller CASSY */ +#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043/* USB Product ID of Machine Test CASSY */ #define USB_DEVICE_ID_LD_JWM 0x1080/* USB Product ID of Joule and Wattmeter */ #define USB_DEVICE_ID_LD_DMMP 0x1081/* USB Product ID of Digital Multimeter P (reserved) */ #define USB_DEVICE_ID_LD_UMIP 0x1090/* USB Product ID of UMI P */
@@ -94,6 +97,9 @@ static const struct usb_device_id ld_usb_table[] = { { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, + { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: gadget: f_fs: Process all descriptors during bind
In reply to Sasha LevinFrom: Jack Pham <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6cf439e0d37463e42784271179c8a308fd7493c6 ]
During _ffs_func_bind(), the received descriptors are evaluated to prepare for binding with the gadget in order to allocate endpoints and optionally set up OS descriptors. However, the high- and super-speed descriptors are only parsed based on whether the gadget_is_dualspeed() and gadget_is_superspeed() calls are true, respectively.
This is a problem in case a userspace program always provides all of the {full,high,super,OS} descriptors when configuring a function. Then, for example if a gadget device is not capable of SuperSpeed, the call to ffs_do_descs() for the SS descriptors is skipped, resulting in an incorrect offset calculation for the vla_ptr when moving on to the OS descriptors that follow. This causes ffs_do_os_descs() to fail as it is now looking at the SS descriptors' offset within the raw_descs buffer instead.
_ffs_func_bind() should evaluate the descriptors unconditionally, so remove the checks for gadget speed.
--- drivers/usb/gadget/function/f_fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/f_fs.c +2 -4
@@ -2756,10 +2756,8 @@ static int _ffs_func_bind(struct usb_configuration *c,struct ffs_data *ffs = func->ffs;const int full = !!func->ffs->fs_descs_count; -const int high =gadget_is_dualspeed (func->gadget) && - func->ffs->hs_descs_count; -const int super =gadget_is_superspeed (func->gadget) && - func->ffs->ss_descs_count; +const int high = !!func->ffs->hs_descs_count; +const int super = !!func->ffs->ss_descs_count;int fs_len, hs_len, ss_len, ret, i;
Signature · 1 line
2.14.1
[added to the 4.1 stable tree] usb: renesas_usbhs: missed the "running" flag in usb_dmac with rx path
In reply to Sasha LevinFrom: Yoshihiro Shimoda <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 17aa31f13cad25daa19d3f923323f552e87bc874 ]
This fixes an issue that a gadget driver (usb_f_fs) is possible to stop rx transactions after the usb-dmac is used because the following functions missed to set/check the "running" flag.
- usbhsf_dma_prepare_pop_with_usb_dmac()
- usbhsf_dma_pop_done_with_usb_dmac()
So, if next transaction uses pio, the usbhsf_prepare_pop() can not start the transaction because the "running" flag is 0.
--- drivers/usb/renesas_usbhs/fifo.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/renesas_usbhs/fifo.c +5 -0
@@ -999,6 +999,10 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,if ((uintptr_t )pkt->buf & (USBHS_USB_DMAC_XFER_SIZE -1 )) goto usbhsf_pio_prepare_pop; +/* return at this time if the pipe is running */ +if (usbhs_pipe_is_running (pipe)) +return 0 ; +usbhs_pipe_config_change_bfre (pipe,1 ); ret =usbhsf_fifo_select (pipe, fifo,0 );
@@ -1189,6 +1193,7 @@ static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt,usbhsf_fifo_clear (pipe, fifo); pkt->actual =usbhs_dma_calc_received_size (pkt, chan, rcv_len); +usbhs_pipe_running (pipe,0 );usbhsf_dma_stop (pipe, fifo);usbhsf_dma_unmap (pkt);usbhsf_fifo_unselect (pipe, pipe->fifo);
Signature · 1 line
2.14.1