4.17.19-stable review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 173/324 HID: wacom: Correct touch maximum XY of 2nd-gen Intuos
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gerecke <[email protected]>
[ Upstream commit 3b8d573586d1b9dee33edf6cb6f2ca05f4bca568 ]
The touch sensors on the 2nd-gen Intuos tablets don't use a 4096x4096 sensor like other similar tablets (3rd-gen Bamboo, Intuos5, etc.). The incorrect maximum XY values don't normally affect userspace since touch input from these devices is typically relative rather than absolute. It does, however, cause problems when absolute distances need to be measured, e.g. for gesture recognition. Since the resolution of the touch sensor on these devices is 10 units / mm (versus 100 for the pen sensor), the proper maximum values can be calculated by simply dividing by 10.
--- drivers/hid/wacom_wac.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +8 -2
@@ -3361,8 +3361,14 @@ void wacom_setup_device_quirks(struct waif (features->type >=INTUOSHT && features->type <=BAMBOO_PT ) features->device_type |=WACOM_DEVICETYPE_PAD ; - features->x_max =4096 ; - features->y_max =4096 ; +if (features->type ==INTUOSHT2 ) { + features->x_max = features->x_max /10 ; + features->y_max = features->y_max /10 ; + } +else { + features->x_max =4096 ; + features->y_max =4096 ; + } }else if (features->pktlen ==WACOM_PKGLEN_BBTOUCH ) { features->device_type |=WACOM_DEVICETYPE_PAD ;
Greg Kroah-Hartman
maintainerPATCH 174/324 ARM: imx_v6_v7_defconfig: Select ULPI support
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 157bcc06094c3c5800d3f4676527047b79b618e7 ]
Select CONFIG_USB_CHIPIDEA_ULPI and CONFIG_USB_ULPI_BUS so that USB ULPI can be functional on some boards like imx51-babbge.
This fixes a kernel hang in 4.18-rc1 on i.mx51-babbage, caused by commit 03e6275ae381 ("usb: chipidea: Fix ULPI on imx51").
--- arch/arm/configs/imx_v6_v7_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/imx_v6_v7_defconfig +2 -0
@@ -294,6 +294,7 @@ CONFIG_USB_STORAGE=y CONFIG_USB_CHIPIDEA=y CONFIG_USB_CHIPIDEA_UDC=y CONFIG_USB_CHIPIDEA_HOST=y +CONFIG_USB_CHIPIDEA_ULPI=y CONFIG_USB_SERIAL=m CONFIG_USB_SERIAL_GENERIC=y CONFIG_USB_SERIAL_FTDI_SIO=m
@@ -330,6 +331,7 @@ CONFIG_USB_GADGETFS=m CONFIG_USB_FUNCTIONFS=m CONFIG_USB_MASS_STORAGE=m CONFIG_USB_G_SERIAL=m +CONFIG_USB_ULPI_BUS=y CONFIG_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_PLTFM=y
Greg Kroah-Hartman
maintainerPATCH 175/324 ARM: imx_v4_v5_defconfig: Select ULPI support
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 2ceb2780b790b74bc408a949f6aedbad8afa693e ]
Select CONFIG_USB_CHIPIDEA_ULPI and CONFIG_USB_ULPI_BUS so that USB ULPI can be functional on some boards like that use ULPI interface.
--- arch/arm/configs/imx_v4_v5_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/imx_v4_v5_defconfig +2 -0
@@ -141,9 +141,11 @@ CONFIG_USB_STORAGE=y CONFIG_USB_CHIPIDEA=y CONFIG_USB_CHIPIDEA_UDC=y CONFIG_USB_CHIPIDEA_HOST=y +CONFIG_USB_CHIPIDEA_ULPI=y CONFIG_NOP_USB_XCEIV=y CONFIG_USB_GADGET=y CONFIG_USB_ETH=m +CONFIG_USB_ULPI_BUS=y CONFIG_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_PLTFM=y
Greg Kroah-Hartman
maintainerPATCH 176/324 tls: fix skb_to_sgvec returning unhandled error.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doron Roberts-Kedes <[email protected]>
[ Upstream commit 52ee6ef36ee10dd493cf2067311e56ca8015eb8d ]
The current code does not inspect the return value of skb_to_sgvec. This can cause a nullptr kernel panic when the malformed sgvec is passed into the crypto request.
Checking the return value of skb_to_sgvec and skipping decryption if it is negative fixes this problem.
--- net/tls/tls_sw.c | 5 +++++ 1 file changed, 5 insertions(+)
net/tls/tls_sw.c +5 -0
@@ -705,6 +705,10 @@ static int decrypt_skb(struct sock *sk, nsg =skb_to_sgvec (skb, &sgin[1 ], rxm->offset + tls_ctx->rx.prepend_size, rxm->full_len - tls_ctx->rx.prepend_size); +if (nsg <0 ) { + ret = nsg; + goto out; + } tls_make_aad(ctx->rx_aad_ciphertext, rxm->full_len - tls_ctx->rx.overhead_size,
@@ -716,6 +720,7 @@ static int decrypt_skb(struct sock *sk, rxm->full_len - tls_ctx->rx.overhead_size, skb, sk->sk_allocation); +out:if (sgin != &sgin_arr[0 ])kfree (sgin);
Greg Kroah-Hartman
maintainerPATCH 177/324 r8169: fix mac address change
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit 2d0ec5440bef4a0a8858d52d45c31725540c3e74 ]
Network core refuses to change mac address because flag IFF_LIVE_ADDR_CHANGE isn't set. Set this missing flag.
--- drivers/net/ethernet/realtek/r8169.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/realtek/r8169.c +1 -0
@@ -8345,6 +8345,7 @@ static int rtl_init_one(struct pci_dev *NETIF_F_HW_VLAN_CTAG_RX ; dev->vlan_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO |NETIF_F_HIGHDMA ; + dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; tp->cp_cmd |= RxChkSum | RxVlan;
Greg Kroah-Hartman
maintainerPATCH 178/324 bpf: hash map: decrement counter on error
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Vasquez B <[email protected]>
[ Upstream commit ed2b82c03dc187018307c7c6bf9299705f3db383 ]
Decrement the number of elements in the map in case the allocation of a new node fails.
--- kernel/bpf/hashtab.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
kernel/bpf/hashtab.c +11 -5
@@ -743,13 +743,15 @@ static struct htab_elem *alloc_htab_elem* old element will be freed immediately. * Otherwise return an error */ -atomic_dec (&htab->count); -return ERR_PTR (-E2BIG ); + l_new =ERR_PTR (-E2BIG ); + goto dec_count; } l_new =kmalloc_node (htab->elem_size,GFP_ATOMIC | __GFP_NOWARN, htab->map.numa_node); -if (!l_new) -return ERR_PTR (-ENOMEM ); +if (!l_new) { + l_new =ERR_PTR (-ENOMEM ); + goto dec_count; + } }memcpy (l_new->key, key, key_size);
@@ -762,7 +764,8 @@ static struct htab_elem *alloc_htab_elem GFP_ATOMIC | __GFP_NOWARN);if (!pptr) {kfree (l_new); -return ERR_PTR (-ENOMEM ); + l_new =ERR_PTR (-ENOMEM ); + goto dec_count; } }
@@ -776,6 +779,9 @@ static struct htab_elem *alloc_htab_elem l_new->hash = hash;return l_new; +dec_count: +atomic_dec (&htab->count); +return l_new; } static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
Greg Kroah-Hartman
maintainerPATCH 180/324 kasan: fix shadow_size calculation error in kasan_module_alloc
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhen Lei <[email protected]>
[ Upstream commit 1e8e18f694a52d703665012ca486826f64bac29d ]
There is a special case that the size is "(N << KASAN_SHADOW_SCALE_SHIFT) Pages plus X", the value of X is [1, KASAN_SHADOW_SCALE_SIZE-1]. The operation "size >> KASAN_SHADOW_SCALE_SHIFT" will drop X, and the roundup operation can not retrieve the missed one page. For example:
size=0x28006, PAGE_SIZE=0x1000, KASAN_SHADOW_SCALE_SHIFT=3, we will get shadow_size=0x5000, but actually we need 6 pages.
shadow_size = round_up(size >> KASAN_SHADOW_SCALE_SHIFT, PAGE_SIZE);
This can lead to a kernel crash when kasan is enabled and the value of mod->core_layout.size or mod->init_layout.size is like above. Because the shadow memory of X has not been allocated and mapped.
move_module:
ptr = module_alloc(mod->core_layout.size);
...
memset(ptr, 0, mod->core_layout.size); //crashed
Unable to handle kernel paging request at virtual address ffff0fffff97b000
......
Call trace:
__asan_storeN+0x174/0x1a8
memset+0x24/0x48
layout_and_allocate+0xcd8/0x1800
load_module+0x190/0x23e8
SyS_finit_module+0x148/0x180--- mm/kasan/kasan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/kasan/kasan.c +3 -2
@@ -619,12 +619,13 @@ void kasan_kfree_large(void *ptr, unsignint kasan_module_alloc (void *addr,size_t size) {void *ret; +size_t scaled_size;size_t shadow_size;unsigned long shadow_start; shadow_start = (unsigned long )kasan_mem_to_shadow (addr); - shadow_size =round_up (size >>KASAN_SHADOW_SCALE_SHIFT , -PAGE_SIZE ); + scaled_size = (size +KASAN_SHADOW_MASK ) >>KASAN_SHADOW_SCALE_SHIFT ; + shadow_size =round_up (scaled_size,PAGE_SIZE );if (WARN_ON (!PAGE_ALIGNED (shadow_start)))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 181/324 net: phy: marvell: change default m88e1510 LED configuration
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Dongsheng <[email protected]>
[ Upstream commit 077772468ec141b22e1e7c0c58bc09e2f9dc8762 ]
The m88e1121 LED default configuration does not apply m88e151x. So add a function to relpace m88e1121 LED configuration.
--- drivers/net/phy/marvell.c | 54 +++++++++++++++++++++++++++++--------------- include/linux/marvell_phy.h | 2 + 2 files changed, 38 insertions(+), 18 deletions(-)
drivers/net/phy/marvell.c +36 -18
@@ -130,8 +130,9 @@#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14) -#define MII_88E1121_PHY_LED_CTRL 16 +#define MII_PHY_LED_CTRL 16#define MII_88E1121_PHY_LED_DEF 0x0030 +#define MII_88E1510_PHY_LED_DEF 0x1177#define MII_M1011_PHY_STATUS 0x11#define MII_M1011_PHY_STATUS_1000 0x8000
@@ -632,8 +633,40 @@ error:return err; } +static void marvell_config_led (struct phy_device *phydev) +{ +u16 def_config; +int err; + +switch (MARVELL_PHY_FAMILY_ID (phydev->phy_id)) { +/* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */ +case MARVELL_PHY_FAMILY_ID (MARVELL_PHY_ID_88E1121R ): +case MARVELL_PHY_FAMILY_ID (MARVELL_PHY_ID_88E1318S ): + def_config =MII_88E1121_PHY_LED_DEF ; +break ; +/* Default PHY LED config: +* LED[0] .. 1000Mbps Link +* LED[1] .. 100Mbps Link +* LED[2] .. Blink, Activity +*/ +case MARVELL_PHY_FAMILY_ID (MARVELL_PHY_ID_88E1510 ): + def_config =MII_88E1510_PHY_LED_DEF ; +break ; +default : +return ; + } + + err =phy_write_paged (phydev,MII_MARVELL_LED_PAGE ,MII_PHY_LED_CTRL , + def_config); +if (err <0 ) +pr_warn ("Fail to config marvell phy LED.\n" ); +} +static int marvell_config_init (struct phy_device *phydev) { +/* Set defalut LED */ +marvell_config_led (phydev); +/* Set registers from marvell,reg-init DT property */ return marvell_of_reg_init (phydev); }
@@ -813,21 +846,6 @@ static int m88e1111_config_init(struct preturn genphy_soft_reset (phydev); } -static int m88e1121_config_init (struct phy_device *phydev) -{ -int err; - -/* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */ - err =phy_write_paged (phydev,MII_MARVELL_LED_PAGE , -MII_88E1121_PHY_LED_CTRL , -MII_88E1121_PHY_LED_DEF ); -if (err <0 ) -return err; - -/* Set marvell,reg-init configuration from device tree */ -return marvell_config_init (phydev); -} -static int m88e1318_config_init (struct phy_device *phydev) {if (phy_interrupt_is_valid (phydev)) {
@@ -841,7 +859,7 @@ static int m88e1318_config_init(struct preturn err; } -return m88e1121_config_init (phydev); +return marvell_config_init (phydev); }static int m88e1510_config_init (struct phy_device *phydev)
@@ -2090,7 +2108,7 @@ static struct phy_driver marvell_drivers .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, .probe = &m88e1121_probe, - .config_init = &m88e1121_config_init, + .config_init = &marvell_config_init, .config_aneg = &m88e1121_config_aneg, .read_status = &marvell_read_status, .ack_interrupt = &marvell_ack_interrupt,
include/linux/marvell_phy.h +2 -0
@@ -27,6 +27,8 @@*/ #define MARVELL_PHY_ID_88E6390 0x01410f90 +#define MARVELL_PHY_FAMILY_ID (id) ((id) >> 4) +/* struct phy_device dev_flags definitions */ #define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001#define MARVELL_PHY_M1118_DNS323_LEDS 0x00000002
Greg Kroah-Hartman
maintainerPATCH 182/324 smsc75xx: Add workaround for gigabit link up hardware errata.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuiko Oshino <[email protected]>
[ Upstream commit d461e3da905332189aad546b2ad9adbe6071c7cc ]
In certain conditions, the device may not be able to link in gigabit mode. This software workaround ensures that the device will not enter the failure state.
--- drivers/net/usb/smsc75xx.c | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/net/usb/smsc75xx.c +62 -0
@@ -82,6 +82,9 @@ static bool turbo_mode = true;module_param (turbo_mode, bool,0644 );MODULE_PARM_DESC (turbo_mode,"Enable multiple frames per Rx transaction" ); +static int smsc75xx_link_ok_nopm (struct usbnet *dev); +static int smsc75xx_phy_gig_workaround (struct usbnet *dev); +static int __must_check __smsc75xx_read_reg (struct usbnet *dev,u32 index,u32 *data,int in_pm) {
@@ -852,6 +855,9 @@ static int smsc75xx_phy_initialize(strucreturn -EIO ; } +/* phy workaround for gig link */ +smsc75xx_phy_gig_workaround (dev); +smsc75xx_mdio_write (dev->net, dev->mii.phy_id,MII_ADVERTISE ,ADVERTISE_ALL |ADVERTISE_CSMA |ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM );
@@ -987,6 +993,62 @@ static int smsc75xx_wait_ready(struct usreturn -EIO ; } +static int smsc75xx_phy_gig_workaround (struct usbnet *dev) +{ +struct mii_if_info *mii = &dev->mii; +int ret =0 , timeout =0 ; +u32 buf, link_up =0 ; + +/* Set the phy in Gig loopback */ +smsc75xx_mdio_write (dev->net, mii->phy_id,MII_BMCR ,0x4040 ); + +/* Wait for the link up */ +do { + link_up =smsc75xx_link_ok_nopm (dev); +usleep_range (10000 ,20000 ); + timeout++; + }while ((!link_up) && (timeout <1000 )); + +if (timeout >=1000 ) { +netdev_warn (dev->net,"Timeout waiting for PHY link up\n" ); +return -EIO ; + } + +/* phy reset */ + ret =smsc75xx_read_reg (dev,PMT_CTL , &buf); +if (ret <0 ) { +netdev_warn (dev->net,"Failed to read PMT_CTL: %d\n" , ret); +return ret; + } + + buf |=PMT_CTL_PHY_RST ; + + ret =smsc75xx_write_reg (dev,PMT_CTL , buf); +if (ret <0 ) { +netdev_warn (dev->net,"Failed to write PMT_CTL: %d\n" , ret); +return ret; + } + + timeout =0 ; +do { +usleep_range (10000 ,20000 ); + ret =smsc75xx_read_reg (dev,PMT_CTL , &buf); +if (ret <0 ) { +netdev_warn (dev->net,"Failed to read PMT_CTL: %d\n" , + ret); +return ret; + } + timeout++; + }while ((buf &PMT_CTL_PHY_RST ) && (timeout <100 )); + +if (timeout >=100 ) { +netdev_warn (dev->net,"timeout waiting for PHY Reset\n" ); +return -EIO ; + } + +return 0 ; +} +static int smsc75xx_reset (struct usbnet *dev) {struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0 ]);
Greg Kroah-Hartman
maintainerPATCH 183/324 drm/bridge/sii8620: Fix display of packed pixel modes
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Purski <[email protected]>
[ Upstream commit fdddc65ab35d575b42aab411b2dc687601eab680 ]
Current implementation does not guarantee packed pixel modes working with every dongle. There are some dongles, which require selecting the output mode explicitly.
Write proper values to registers in packed_pixel mode, based on how it is done in vendor's code. Select output color space: RGB (no packed pixel) or YCBCR422 (packed pixel).
This reverts commit e8b92efa629dac0e70ea4145c5e70616de5f89c8 ("drm/bridge/sii8620: fix display of packed pixel modes in MHL2").
--- drivers/gpu/drm/bridge/sil-sii8620.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/sil-sii8620.c +16 -1
@@ -1060,21 +1060,36 @@ static void sii8620_stop_video(struct sistatic void sii8620_set_format (struct sii8620 *ctx) { +u8 out_fmt; +if (sii8620_is_mhl3 (ctx)) {sii8620_setbits (ctx,REG_M3_P0CTRL ,BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED , ctx->use_packed_pixel ? ~0 :0 ); }else { +if (ctx->use_packed_pixel) { +sii8620_write_seq_static (ctx, +REG_VID_MODE ,BIT_VID_MODE_M1080P , +REG_MHL_TOP_CTL ,BIT_MHL_TOP_CTL_MHL_PP_SEL |1 , +REG_MHLTX_CTL6 ,0x60 + ); + }else {sii8620_write_seq_static (ctx,REG_VID_MODE ,0 ,REG_MHL_TOP_CTL ,1 ,REG_MHLTX_CTL6 ,0xa0 ); + } } +if (ctx->use_packed_pixel) + out_fmt =VAL_TPI_FORMAT (YCBCR422 ,FULL ); +else + out_fmt =VAL_TPI_FORMAT (RGB ,FULL ); +sii8620_write_seq (ctx,REG_TPI_INPUT ,VAL_TPI_FORMAT (RGB ,FULL ), - REG_TPI_OUTPUT, VAL_TPI_FORMAT(RGB, FULL), + REG_TPI_OUTPUT, out_fmt, ); }
Greg Kroah-Hartman
maintainerPATCH 184/324 RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Schwab <[email protected]>
[ Upstream commit 781c8fe2da3d2c7c95cd7ffddbab63b80a79da4d ]
The R_RISCV_ADD32/R_RISCV_SUB32 relocations should add/subtract the address of the symbol (without overflow check), not its contents.
--- arch/riscv/kernel/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/module.c +2 -2
@@ -252,14 +252,14 @@ static int apply_r_riscv_align_rela(strustatic int apply_r_riscv_add32_rela (struct module *me,u32 *location,Elf_Addr v) { - *(u32 *)location += (*(u32 *)v); + *(u32 *)location += (u32 )v;return 0 ; }static int apply_r_riscv_sub32_rela (struct module *me,u32 *location,Elf_Addr v) { - *(u32 *)location -= (*(u32 *)v); + *(u32 *)location -= (u32 )v;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 185/324 RISC-V: Dont include irq-riscv-intc.h
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palmer Dabbelt <[email protected]>
[ Upstream commit 8606544890d7dc4f7a740963f70dc1e1d54f8e30 ]
This file has never existed in the upstream kernel, but it's guarded by an #ifdef that's also never existed in the upstream kernel. As a part of our interrupt controller refactoring this header is no longer necessary, but this reference managed to sneak in anyway.
--- arch/riscv/kernel/irq.c | 4 ---- 1 file changed, 4 deletions(-)
arch/riscv/kernel/irq.c +0 -4
@@ -16,10 +16,6 @@#include <linux/irqchip.h> #include <linux/irqdomain.h> -#ifdef CONFIG_RISCV_INTC -#include <linux/irqchip/irq-riscv-intc.h> -#endif -void __init init_IRQ (void ) {irqchip_init ();
Greg Kroah-Hartman
maintainerPATCH 186/324 RISC-V: Fix PTRACE_SETREGSET bug.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Wilson <[email protected]>
[ Upstream commit 1db9b80980d26fe95c942e0bb8bde2ca715029ad ]
In riscv_gpr_set, pass regs instead of ®s to user_regset_copyin to fix gdb segfault.
--- arch/riscv/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/ptrace.c +1 -1
@@ -50,7 +50,7 @@ static int riscv_gpr_set(struct task_strstruct pt_regs *regs; regs =task_pt_regs (target); - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, ®s,0 ,-1 ); + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, regs,0 ,-1 );return ret; }
Greg Kroah-Hartman
maintainerPATCH 187/324 samples/bpf: add missing <linux/if_vlan.h>
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taeung Song <[email protected]>
[ Upstream commit 4d5d33a085335ef469c9a87792bcaaaa8e64d8c4 ]
This fixes build error regarding redefinition:
CLANG-bpf samples/bpf/parse_varlen.o
samples/bpf/parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
struct vlan_hdr {
^ ./include/linux/if_vlan.h:38:8: note: previous definition is here
So remove duplicate 'struct vlan_hdr' in sample code and include if_vlan.h
--- samples/bpf/parse_varlen.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
samples/bpf/parse_varlen.c +1 -5
@@ -6,6 +6,7 @@*/ #define KBUILD_MODNAME "foo"#include <linux/if_ether.h> +#include <linux/if_vlan.h> #include <linux/ip.h> #include <linux/ipv6.h> #include <linux/in.h>
@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64return 0 ; } -struct vlan_hdr { -uint16_t h_vlan_TCI; -uint16_t h_vlan_encapsulated_proto; -}; - SEC("varlen")int handle_ingress (struct __sk_buff *skb) {
Greg Kroah-Hartman
maintainerPATCH 189/324 samples/bpf: Check the error of write() and read()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taeung Song <[email protected]>
[ Upstream commit 02a2f000a3629274bfad60bfc4de9edec49e63e7 ]
test_task_rename() and test_urandom_read()
can be failed during write() and read(),
So check the result of them.
--- samples/bpf/test_overhead_user.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
samples/bpf/test_overhead_user.c +15 -4
@@ -6,6 +6,7 @@*/ #define _GNU_SOURCE#include <sched.h> +#include <errno.h> #include <stdio.h> #include <sys/types.h> #include <asm/unistd.h>
@@ -44,8 +45,13 @@ static void test_task_rename(int cpu)exit (1 ); } start_time =time_get_ns (); -for (i =0 ; i <MAX_CNT ; i++) -write (fd, buf,sizeof (buf)); +for (i =0 ; i <MAX_CNT ; i++) { +if (write (fd, buf,sizeof (buf)) <0 ) { +printf ("task rename failed: %s\n" ,strerror (errno)); +close (fd); +return ; + } + }printf ("task_rename:%d: %lld events per sec\n" , cpu,MAX_CNT *1000000000ll / (time_get_ns () - start_time));close (fd);
@@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)exit (1 ); } start_time =time_get_ns (); -for (i =0 ; i <MAX_CNT ; i++) -read (fd, buf,sizeof (buf)); +for (i =0 ; i <MAX_CNT ; i++) { +if (read (fd, buf,sizeof (buf)) <0 ) { +printf ("failed to read from /dev/urandom: %s\n" ,strerror (errno)); +close (fd); +return ; + } + }printf ("urandom_read:%d: %lld events per sec\n" , cpu,MAX_CNT *1000000000ll / (time_get_ns () - start_time));close (fd);
Greg Kroah-Hartman
maintainerPATCH 190/324 ieee802154: mcr20a: add missing includes
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit a6032120d341badd9b034cb64411e7089d8f4285 ]
Without CONFIG_GPIOLIB, some headers are not included implicitly, leading to a build failure:
drivers/net/ieee802154/mcr20a.c: In function 'mcr20a_probe':drivers/net/ieee802154/mcr20a.c:1347:13: error: implicit declaration of function 'irq_get_trigger_type'; did you mean 'irq_get_irqchip_state'? [-Werror=implicit-function-declaration]
This includes gpio/consumer.h and irq.h directly rather through the gpiolib header.
--- drivers/net/ieee802154/mcr20a.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ieee802154/mcr20a.c +2 -1
@@ -15,10 +15,11 @@*/ #include <linux/kernel.h> #include <linux/module.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/spi/spi.h> #include <linux/workqueue.h> #include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/skbuff.h> #include <linux/of_gpio.h> #include <linux/regmap.h>
Greg Kroah-Hartman
maintainerPATCH 191/324 ieee802154: 6lowpan: set IFLA_LINK
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lubomir Rintel <[email protected]>
[ Upstream commit b30c122c0bbb0a1dc413085e177ea09467e65fdb ]
Otherwise NetworkManager (and iproute alike) is not able to identify the parent IEEE 802.15.4 interface of a 6LoWPAN link.
--- net/ieee802154/6lowpan/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ieee802154/6lowpan/core.c +6 -0
@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(structreturn 0 ; } +static int lowpan_get_iflink (const struct net_device *dev) +{ +return lowpan_802154_dev (dev)->wdev->ifindex; +} +static const struct net_device_ops lowpan_netdev_ops = { .ndo_init = lowpan_dev_init, .ndo_start_xmit = lowpan_xmit, .ndo_open = lowpan_open, .ndo_stop = lowpan_stop, .ndo_neigh_construct = lowpan_neigh_construct, + .ndo_get_iflink = lowpan_get_iflink, };static void lowpan_setup (struct net_device *ldev)
Greg Kroah-Hartman
maintainerPATCH 192/324 netfilter: x_tables: set module owner for icmp(6) matches
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit d376bef9c29b3c65aeee4e785fffcd97ef0a9a81 ]
nft_compat relies on xt_request_find_match to increment refcount of the module that provides the match/target.
The (builtin) icmp matches did't set the module owner so it was possible to rmmod ip(6)tables while icmp extensions were still in use.
--- net/ipv4/netfilter/ip_tables.c | 1 + net/ipv6/netfilter/ip6_tables.c | 1 + 2 files changed, 2 insertions(+)
net/ipv4/netfilter/ip_tables.c +1 -0
@@ -1895,6 +1895,7 @@ static struct xt_match ipt_builtin_mt[] .checkentry = icmp_checkentry, .proto = IPPROTO_ICMP, .family = NFPROTO_IPV4, + .me = THIS_MODULE, }, };
net/ipv6/netfilter/ip6_tables.c +1 -0
@@ -1907,6 +1907,7 @@ static struct xt_match ip6t_builtin_mt[] .checkentry = icmp6_checkentry, .proto = IPPROTO_ICMPV6, .family = NFPROTO_IPV6, + .me = THIS_MODULE, }, };
Greg Kroah-Hartman
maintainerPATCH 193/324 qed: off by one in qed_parse_mcp_trace_buf()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 0df8adbb88db8283f102a2afa91610a502245cb2 ]
If format_idx == s_mcp_trace_meta.formats_num then we read one element beyond the end of the s_mcp_trace_meta.formats[] array.
--- drivers/net/ethernet/qlogic/qed/qed_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -1
@@ -6663,7 +6663,7 @@ static enum dbg_status qed_parse_mcp_tra format_idx = header &MFW_TRACE_EVENTID_MASK ;/* Skip message if its index doesn't exist in the meta data */ -if (format_idx > s_mcp_trace_meta.formats_num) { +if (format_idx >= s_mcp_trace_meta.formats_num) {u8 format_size = (u8)((header &MFW_TRACE_PRM_SIZE_MASK ) >>MFW_TRACE_PRM_SIZE_SHIFT );
Greg Kroah-Hartman
maintainerPATCH 194/324 ipv6: make ipv6_renew_options() interrupt/kernel safe
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
[ Upstream commit a9ba23d48dbc6ffd08426bb10f05720e0b9f5c14 ]
At present the ipv6_renew_options_kern() function ends up calling into access_ok() which is problematic if done from inside an interrupt as access_ok() calls WARN_ON_IN_IRQ() on some (all?) architectures (x86-64 is affected). Example warning/backtrace is shown below:
WARNING: CPU: 1 PID: 3144 at lib/usercopy.c:11 _copy_from_user+0x85/0x90 ... Call Trace: <IRQ> ipv6_renew_option+0xb2/0xf0 ipv6_renew_options+0x26a/0x340 ipv6_renew_options_kern+0x2c/0x40 calipso_req_setattr+0x72/0xe0 netlbl_req_setattr+0x126/0x1b0 selinux_netlbl_inet_conn_request+0x80/0x100 selinux_inet_conn_request+0x6d/0xb0 security_inet_conn_request+0x32/0x50 tcp_conn_request+0x35f/0xe00 ? __lock_acquire+0x250/0x16c0 ? selinux_socket_sock_rcv_skb+0x1ae/0x210 ? tcp_rcv_state_process+0x289/0x106b tcp_rcv_state_process+0x289/0x106b ? tcp_v6_do_rcv+0x1a7/0x3c0 tcp_v6_do_rcv+0x1a7/0x3c0 tcp_v6_rcv+0xc82/0xcf0 ip6_input_finish+0x10d/0x690 ip6_input+0x45/0x1e0 ? ip6_rcv_finish+0x1d0/0x1d0 ipv6_rcv+0x32b/0x880 ? ip6_make_skb+0x1e0/0x1e0 __netif_receive_skb_core+0x6f2/0xdf0 ? process_backlog+0x85/0x250 ? process_backlog+0x85/0x250 ? process_backlog+0xec/0x250 process_backlog+0xec/0x250 net_rx_action+0x153/0x480 __do_softirq+0xd9/0x4f7 do_softirq_own_stack+0x2a/0x40 </IRQ> ...
While not present in the backtrace, ipv6_renew_option() ends up calling access_ok() via the following chain:
access_ok()
_copy_from_user()
copy_from_user()
ipv6_renew_option()
The fix presented in this patch is to perform the userspace copy earlier in the call chain such that it is only called when the option data is actually coming from userspace; that place is do_ipv6_setsockopt(). Not only does this solve the problem seen in the backtrace above, it also allows us to simplify the code quite a bit by removing ipv6_renew_options_kern() completely. We also take this opportunity to cleanup ipv6_renew_options()/ipv6_renew_option() a small amount as well.
This patch is heavily based on a rough patch by Al Viro. I've taken his original patch, converted a kmemdup() call in do_ipv6_setsockopt() to a memdup_user() call, made better use of the e_inval jump target in the same function, and cleaned up the use ipv6_renew_option() by ipv6_renew_options().
--- include/net/ipv6.h | 9 --- net/ipv6/calipso.c | 9 +-- net/ipv6/exthdrs.c | 111 ++++++++++++----------------------------------- net/ipv6/ipv6_sockglue.c | 27 ++++++++--- 4 files changed, 53 insertions(+), 103 deletions(-)
include/net/ipv6.h +1 -8
@@ -354,14 +354,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct ipv6_txoptions *ipv6_renew_options (struct sock *sk,struct ipv6_txoptions *opt,int newtype, -struct ipv6_opt_hdr __user *newopt, -int newoptlen); -struct ipv6_txoptions * -ipv6_renew_options_kern (struct sock *sk, -struct ipv6_txoptions *opt, -int newtype, -struct ipv6_opt_hdr *newopt, -int newoptlen); +struct ipv6_opt_hdr *newopt);struct ipv6_txoptions *ipv6_fixup_options (struct ipv6_txoptions *opt_space,struct ipv6_txoptions *opt);
net/ipv6/calipso.c +3 -6
@@ -799,8 +799,7 @@ static int calipso_opt_update(struct soc {struct ipv6_txoptions *old =txopt_get (inet6_sk (sk)), *txopts; - txopts =ipv6_renew_options_kern (sk, old,IPV6_HOPOPTS , - hop, hop ?ipv6_optlen (hop) :0 ); + txopts =ipv6_renew_options (sk, old,IPV6_HOPOPTS , hop);txopt_put (old);if (IS_ERR (txopts))return PTR_ERR (txopts);
@@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct reif (IS_ERR (new))return PTR_ERR (new); - txopts =ipv6_renew_options_kern (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , - new, new ?ipv6_optlen (new) :0 ); + txopts =ipv6_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new);kfree (new);
@@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct rif (calipso_opt_del (req_inet->ipv6_opt->hopopt, &new))return ;/* Nothing to do */ - txopts =ipv6_renew_options_kern (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , - new, new ?ipv6_optlen (new) :0 ); + txopts =ipv6_renew_options (sk, req_inet->ipv6_opt,IPV6_HOPOPTS , new);if (!IS_ERR (txopts)) { txopts =xchg (&req_inet->ipv6_opt, txopts);
net/ipv6/exthdrs.c +30 -81
146 lines not on this page · raw message
net/ipv6/ipv6_sockglue.c +19 -8
@@ -398,6 +398,12 @@ static int do_ipv6_setsockopt(struct soccase IPV6_DSTOPTS : {struct ipv6_txoptions *opt; +struct ipv6_opt_hdr *new =NULL ; + +/* hop-by-hop / destination options are privileged option */ + retv = -EPERM ; +if (optname !=IPV6_RTHDR && !ns_capable (net->user_ns,CAP_NET_RAW )) +break ;/* remove any sticky options header with a zero option * length, per RFC3542.
@@ -409,17 +415,22 @@ static int do_ipv6_setsockopt(struct socelse if (optlen <sizeof (struct ipv6_opt_hdr ) || optlen &0x7 || optlen >8 *255 ) goto e_inval; - -/* hop-by-hop / destination options are privileged option */ - retv = -EPERM ; -if (optname !=IPV6_RTHDR && !ns_capable (net->user_ns,CAP_NET_RAW )) -break ; +else { + new =memdup_user (optval, optlen); +if (IS_ERR (new)) { + retv =PTR_ERR (new); +break ; + } +if (unlikely (ipv6_optlen (new) > optlen)) { +kfree (new); + goto e_inval; + } + } opt =rcu_dereference_protected (np->opt,lockdep_sock_is_held (sk)); - opt =ipv6_renew_options (sk, opt, optname, - (struct ipv6_opt_hdr __user *)optval, - optlen); + opt =ipv6_renew_options (sk, opt, optname, new); +kfree (new);if (IS_ERR (opt)) { retv =PTR_ERR (opt);break ;
Greg Kroah-Hartman
maintainerPATCH 195/324 net: qrtr: Broadcast messages only from control port
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arun Kumar Neelakantam <[email protected]>
[ Upstream commit fdf5fd3975666804118e62c69de25dc85cc0909c ]
The broadcast node id should only be sent with the control port id.
--- net/qrtr/qrtr.c | 4 ++++ 1 file changed, 4 insertions(+)
net/qrtr/qrtr.c +4 -0
@@ -764,6 +764,10 @@ static int qrtr_sendmsg(struct socket *s node =NULL ;if (addr->sq_node ==QRTR_NODE_BCAST ) { enqueue_fn = qrtr_bcast_enqueue; +if (addr->sq_port !=QRTR_PORT_CTRL ) { +release_sock (sk); +return -ENOTCONN ; + } }else if (addr->sq_node == ipc->us.sq_node) { enqueue_fn = qrtr_local_enqueue; }else {
Greg Kroah-Hartman
maintainerPATCH 196/324 net: qrtr: Reset the node and port ID of broadcast messages
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arun Kumar Neelakantam <[email protected]>
[ Upstream commit d27e77a3de2866b0a772803fd03cd667b5ff8a9a ]
All the control messages broadcast to remote routers are using QRTR_NODE_BCAST instead of using local router NODE ID which cause the packets to be dropped on remote router due to invalid NODE ID.
--- net/qrtr/qrtr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/qrtr/qrtr.c +7 -2
@@ -191,8 +191,13 @@ static int qrtr_node_enqueue(struct qrtr hdr->type =cpu_to_le32 (type); hdr->src_node_id =cpu_to_le32 (from->sq_node); hdr->src_port_id =cpu_to_le32 (from->sq_port); - hdr->dst_node_id =cpu_to_le32 (to->sq_node); - hdr->dst_port_id =cpu_to_le32 (to->sq_port); +if (to->sq_port ==QRTR_PORT_CTRL ) { + hdr->dst_node_id =cpu_to_le32 (node->nid); + hdr->dst_port_id =cpu_to_le32 (QRTR_NODE_BCAST ); + }else { + hdr->dst_node_id =cpu_to_le32 (to->sq_node); + hdr->dst_port_id =cpu_to_le32 (to->sq_port); + } hdr->size =cpu_to_le32 (len); hdr->confirm_rx =0 ;
Greg Kroah-Hartman
maintainerPATCH 197/324 sh_eth: fix invalid context bug while calling auto-negotiation by ethtool
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 53a710b5044d8475faa6813000b6dd659400ef7b ]
Since commit 35b5f6b1a82b ("PHYLIB: Locking fixes for PHY I/O potentially sleeping") phy_start_aneg() function utilizes a mutex to serialize changes to phy state, however the helper function is called in atomic context.
The bug can be reproduced by running "ethtool -r" command, the bug is reported if CONFIG_DEBUG_ATOMIC_SLEEP build option is enabled.
--- drivers/net/ethernet/renesas/sh_eth.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +1 -9
@@ -2193,18 +2193,10 @@ static void sh_eth_get_regs(struct net_dstatic int sh_eth_nway_reset (struct net_device *ndev) { -struct sh_eth_private *mdp =netdev_priv (ndev); -unsigned long flags; -int ret; -if (!ndev->phydev)return -ENODEV ; -spin_lock_irqsave (&mdp->lock, flags); - ret =phy_start_aneg (ndev->phydev); -spin_unlock_irqrestore (&mdp->lock, flags); - -return ret; +return phy_start_aneg (ndev->phydev); }static u32 sh_eth_get_msglevel (struct net_device *ndev)
Greg Kroah-Hartman
maintainerPATCH 198/324 sh_eth: fix invalid context bug while changing link options by ethtool
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 5cb3f52a11e18628fc4bee76dd14b1f0b76349de ]
The change fixes sleep in atomic context bug, which is encountered every time when link settings are changed by ethtool.
Since commit 35b5f6b1a82b ("PHYLIB: Locking fixes for PHY I/O potentially sleeping") phy_start_aneg() function utilizes a mutex to serialize changes to phy state, however that helper function is called in atomic context under a grabbed spinlock, because phy_start_aneg() is called by phy_ethtool_ksettings_set() and by replaced phy_ethtool_sset() helpers from phylib.
Now duplex mode setting is enforced in sh_eth_adjust_link() only, also now RX/TX is disabled when link is put down or modifications to E-MAC registers ECMR and GECMR are expected for both cases of checked and ignored link status pin state from E-MAC interrupt handler.
For reference the change is a partial rework of commit 1e1b812bbe10 ("sh_eth: fix handling of no LINK signal").
--- drivers/net/ethernet/renesas/sh_eth.c | 49 ++++++++++------------------------ 1 file changed, 15 insertions(+), 34 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +15 -34
@@ -1855,8 +1855,15 @@ static void sh_eth_adjust_link(struct ne {struct sh_eth_private *mdp =netdev_priv (ndev);struct phy_device *phydev = ndev->phydev; +unsigned long flags;int new_state =0 ; +spin_lock_irqsave (&mdp->lock, flags); + +/* Disable TX and RX right over here, if E-MAC change is ignored */ +if (mdp->cd->no_psr || mdp->no_ether_link) +sh_eth_rcv_snd_disable (ndev); +if (phydev->link) {if (phydev->duplex != mdp->duplex) { new_state =1 ;
@@ -1875,18 +1882,21 @@ static void sh_eth_adjust_link(struct nesh_eth_modify (ndev,ECMR ,ECMR_TXF ,0 ); new_state =1 ; mdp->link = phydev->link; -if (mdp->cd->no_psr || mdp->no_ether_link) -sh_eth_rcv_snd_enable (ndev); } }else if (mdp->link) { new_state =1 ; mdp->link =0 ; mdp->speed =0 ; mdp->duplex =-1 ; -if (mdp->cd->no_psr || mdp->no_ether_link) -sh_eth_rcv_snd_disable (ndev); } +/* Enable TX and RX right over here, if E-MAC change is ignored */ +if ((mdp->cd->no_psr || mdp->no_ether_link) && phydev->link) +sh_eth_rcv_snd_enable (ndev); + +mmiowb (); +spin_unlock_irqrestore (&mdp->lock, flags); +if (new_state &&netif_msg_link (mdp))phy_print_status (phydev); }
@@ -1977,39 +1987,10 @@ static int sh_eth_get_link_ksettings(strstatic int sh_eth_set_link_ksettings (struct net_device *ndev,const struct ethtool_link_ksettings *cmd) { -struct sh_eth_private *mdp =netdev_priv (ndev); -unsigned long flags; -int ret; -if (!ndev->phydev)return -ENODEV ; -spin_lock_irqsave (&mdp->lock, flags); - -/* disable tx and rx */ -sh_eth_rcv_snd_disable (ndev); - - ret =phy_ethtool_ksettings_set (ndev->phydev, cmd); -if (ret) - goto error_exit; - -if (cmd->base.duplex ==DUPLEX_FULL ) - mdp->duplex =1 ; -else - mdp->duplex =0 ; - -if (mdp->cd->set_duplex) - mdp->cd->set_duplex (ndev); - -error_exit: -mdelay (1 ); - -/* enable tx and rx */ -sh_eth_rcv_snd_enable (ndev); - -spin_unlock_irqrestore (&mdp->lock, flags); - -return ret; +return phy_ethtool_ksettings_set (ndev->phydev, cmd); }/* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the
Greg Kroah-Hartman
maintainerPATCH 199/324 ravb: fix invalid context bug while calling auto-negotiation by ethtool
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 0973a4dd79fe56a3beecfcff675ba4c01df0b0c1 ]
Since commit 35b5f6b1a82b ("PHYLIB: Locking fixes for PHY I/O potentially sleeping") phy_start_aneg() function utilizes a mutex to serialize changes to phy state, however the helper function is called in atomic context.
The bug can be reproduced by running "ethtool -r" command, the bug is reported if CONFIG_DEBUG_ATOMIC_SLEEP build option is enabled.
--- drivers/net/ethernet/renesas/ravb_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +1 -6
@@ -1152,15 +1152,10 @@ error_exit:static int ravb_nway_reset (struct net_device *ndev) { -struct ravb_private *priv =netdev_priv (ndev);int error = -ENODEV ; -unsigned long flags; -if (ndev->phydev) { -spin_lock_irqsave (&priv->lock, flags); +if (ndev->phydev) error =phy_start_aneg (ndev->phydev); -spin_unlock_irqrestore (&priv->lock, flags); - }return error; }
Greg Kroah-Hartman
maintainerPATCH 200/324 ravb: fix invalid context bug while changing link options by ethtool
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 05925e52a7d379192a5fdff2c33710f573190ead ]
The change fixes sleep in atomic context bug, which is encountered every time when link settings are changed by ethtool.
Since commit 35b5f6b1a82b ("PHYLIB: Locking fixes for PHY I/O potentially sleeping") phy_start_aneg() function utilizes a mutex to serialize changes to phy state, however that helper function is called in atomic context under a grabbed spinlock, because phy_start_aneg() is called by phy_ethtool_ksettings_set() and by replaced phy_ethtool_sset() helpers from phylib.
Now duplex mode setting is enforced in ravb_adjust_link() only, also now RX/TX is disabled when link is put down or modifications to E-MAC registers ECMR and GECMR are expected for both cases of checked and ignored link status pin state from E-MAC interrupt handler.
--- drivers/net/ethernet/renesas/ravb_main.c | 49 +++++++++---------------------- 1 file changed, 15 insertions(+), 34 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +15 -34
@@ -980,6 +980,13 @@ static void ravb_adjust_link(struct net_struct ravb_private *priv =netdev_priv (ndev);struct phy_device *phydev = ndev->phydev;bool new_state = false; +unsigned long flags; + +spin_lock_irqsave (&priv->lock, flags); + +/* Disable TX and RX right over here, if E-MAC change is ignored */ +if (priv->no_avb_link) +ravb_rcv_snd_disable (ndev);if (phydev->link) {if (phydev->duplex != priv->duplex) {
@@ -997,18 +1004,21 @@ static void ravb_adjust_link(struct net_ravb_modify (ndev,ECMR ,ECMR_TXF ,0 ); new_state = true; priv->link = phydev->link; -if (priv->no_avb_link) -ravb_rcv_snd_enable (ndev); } }else if (priv->link) { new_state = true; priv->link =0 ; priv->speed =0 ; priv->duplex =-1 ; -if (priv->no_avb_link) -ravb_rcv_snd_disable (ndev); } +/* Enable TX and RX right over here, if E-MAC change is ignored */ +if (priv->no_avb_link && phydev->link) +ravb_rcv_snd_enable (ndev); + +mmiowb (); +spin_unlock_irqrestore (&priv->lock, flags); +if (new_state &&netif_msg_link (priv))phy_print_status (phydev); }
@@ -1115,39 +1125,10 @@ static int ravb_get_link_ksettings(strucstatic int ravb_set_link_ksettings (struct net_device *ndev,const struct ethtool_link_ksettings *cmd) { -struct ravb_private *priv =netdev_priv (ndev); -unsigned long flags; -int error; -if (!ndev->phydev)return -ENODEV ; -spin_lock_irqsave (&priv->lock, flags); - -/* Disable TX and RX */ -ravb_rcv_snd_disable (ndev); - - error =phy_ethtool_ksettings_set (ndev->phydev, cmd); -if (error) - goto error_exit; - -if (cmd->base.duplex ==DUPLEX_FULL ) - priv->duplex =1 ; -else - priv->duplex =0 ; - -ravb_set_duplex (ndev); - -error_exit: -mdelay (1 ); - -/* Enable TX and RX */ -ravb_rcv_snd_enable (ndev); - -mmiowb (); -spin_unlock_irqrestore (&priv->lock, flags); - -return error; +return phy_ethtool_ksettings_set (ndev->phydev, cmd); }static int ravb_nway_reset (struct net_device *ndev)
Greg Kroah-Hartman
maintainerPATCH 201/324 tipc: fix wrong return value from function tipc_node_try_addr()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maloy <[email protected]>
[ Upstream commit 2a57f182420174c7fd4b19db979a2d135231a963 ]
The function for checking if there is an node address conflict is supposed to return a suggestion for a new address if it finds a conflict, and zero otherwise. But in case the peer being checked is previously unknown it does instead return a "suggestion" for the checked address itself. This results in a DSC_TRIAL_FAIL_MSG being sent unecessarily to the peer, and sometimes makes the trial period starting over again.
--- net/tipc/node.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/tipc/node.c +5 -2
@@ -776,6 +776,7 @@ static u32 tipc_node_suggest_addr(struct }/* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not +* Returns suggested address if any, otherwise 0 */ u32 tipc_node_try_addr (struct net *net,u8 *id,u32 addr) {
@@ -798,12 +799,14 @@ u32 tipc_node_try_addr(struct net *net,if (n) { addr = n->addr;tipc_node_put (n); +return addr; } -/* Even this node may be in trial phase */ + +/* Even this node may be in conflict */ if (tn->trial_addr == addr)return tipc_node_suggest_addr (net, addr); -return addr; +return 0 ; } void tipc_node_check_dest(struct net *net, u32 addr,
Greg Kroah-Hartman
maintainerPATCH 202/324 tipc: correct discovery message handling during address trial period
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maloy <[email protected]>
[ Upstream commit e415577f57f4452150642500364cbe5fa6112813 ]
With the duplicate address discovery protocol for tipc nodes addresses we introduced a one second trial period before a node is allocated a hash number to use as address.
Unfortunately, we miss to handle the case when a regular LINK REQUEST/ RESPONSE arrives from a cluster node during the trial period. Such messages are not ignored as they should be, leading to links setup attempts while the node still has no address.
--- net/tipc/discover.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/tipc/discover.c +4 -1
@@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_ }/* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer +* Returns true if message should be dropped by caller, i.e., if it is a +* trial message or we are inside trial period. Otherwise false. */ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, struct tipc_media_addr *maddr,
@@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(strmsg_set_type (buf_msg (d->skb),DSC_REQ_MSG ); } +/* Accept regular link requests/responses only after trial period */ if (mtyp !=DSC_TRIAL_MSG ) -return false; +return trial; sugg_addr =tipc_node_try_addr (net, peer_id, src);if (sugg_addr)
Greg Kroah-Hartman
maintainerPATCH 203/324 tipc: fix correct setting of message type in second discoverer
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maloy <[email protected]>
[ Upstream commit 92018c7ca959ccd346d6235dac03cf7fc1ba51f7 ]
The duplicate address discovery protocol is not safe against two discoverers running in parallel. The one executing first after the trial period is over will set the node address and change its own message type to DSC_REQ_MSG. The one executing last may find that the node address is already set, and never change message type, with the result that its links may never be established.
In this commmit we ensure that the message type always is set correctly after the trial period is over.
--- net/tipc/discover.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/tipc/discover.c +7 -6
@@ -287,7 +287,6 @@ static void tipc_disc_timeout(struct tim {struct tipc_discoverer *d =from_timer (d, t, timer);struct tipc_net *tn =tipc_net (d->net); -u32 self =tipc_own_addr (d->net);struct tipc_media_addr maddr;struct sk_buff *skb =NULL ;struct net *net = d->net;
@@ -301,12 +300,14 @@ static void tipc_disc_timeout(struct tim goto exit; } -/* Did we just leave the address trial period ? */ -if (!self && !time_before (jiffies, tn->addr_trial_end)) { - self = tn->trial_addr; -tipc_net_finalize (net, self); -msg_set_prevnode (buf_msg (d->skb), self); +/* Trial period over ? */ +if (!time_before (jiffies, tn->addr_trial_end)) { +/* Did we just leave it ? */ +if (!tipc_own_addr (net)) +tipc_net_finalize (net, tn->trial_addr); +msg_set_type (buf_msg (d->skb),DSC_REQ_MSG ); +msg_set_prevnode (buf_msg (d->skb),tipc_own_addr (net)); }/* Adjust timeout interval according to discovery phase */
Greg Kroah-Hartman
maintainerPATCH 204/324 tipc: make function tipc_net_finalize() thread safe
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maloy <[email protected]>
[ Upstream commit 9faa89d4ed9d7d326f4763d262842270450f9b1f ]
The setting of the node address is not thread safe, meaning that two discoverers may decide to set it simultanously, with a duplicate entry in the name table as result. We fix that with this commit.
--- net/tipc/net.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/tipc/net.c +11 -6
@@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *nvoid tipc_net_finalize (struct net *net,u32 addr) { -tipc_set_node_addr (net, addr); -smp_mb (); -tipc_named_reinit (net); -tipc_sk_reinit (net); -tipc_nametbl_publish (net,TIPC_CFG_SRV , addr, addr, -TIPC_CLUSTER_SCOPE ,0 , addr); +struct tipc_net *tn =tipc_net (net); + +spin_lock_bh (&tn->node_list_lock); +if (!tipc_own_addr (net)) { +tipc_set_node_addr (net, addr); +tipc_named_reinit (net); +tipc_sk_reinit (net); +tipc_nametbl_publish (net,TIPC_CFG_SRV , addr, addr, +TIPC_CLUSTER_SCOPE ,0 , addr); + } +spin_unlock_bh (&tn->node_list_lock); }void tipc_net_stop (struct net *net)
Greg Kroah-Hartman
maintainerPATCH 205/324 cxgb4: assume flash part size to be 4MB, if it cant be determined
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Casey Leedom <[email protected]>
[ Upstream commit 843789f6dd6ae1651a77ac99c13bcaf191ebe05c ]
t4_get_flash_params() fails in a fatal fashion if the FLASH part isn't one of the recognized parts. But this leads to desperate efforts to update drivers when various FLASH parts which we are using suddenly become unavailable and we need to substitute new FLASH parts. This has lead to more than one Customer Field Emergency when a Customer has an old driver and suddenly can't use newly shipped adapters.
This commit fixes this by simply assuming that the FLASH part is 4MB in size if it can't be identified. Note that all Chelsio adapters will have flash parts which are at least 4MB in size.
--- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 35 ++++++++++------------------- 1 file changed, 13 insertions(+), 22 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +13 -22
@@ -8526,7 +8526,7 @@ static int t4_get_flash_params(struct ad };unsigned int part, manufacturer; -unsigned int density, size; +unsigned int density, size =0 ;u32 flashid =0 ;int ret;
@@ -8596,11 +8596,6 @@ static int t4_get_flash_params(struct adcase 0x22 :/* 256MB */ size =1 <<28 ;break ; - -default : -dev_err (adap->pdev_dev,"Micron Flash Part has bad size, ID = %#x, Density code = %#x\n" , - flashid, density); -return -EINVAL ; }break ; }
@@ -8616,10 +8611,6 @@ static int t4_get_flash_params(struct adcase 0x17 :/* 64MB */ size =1 <<26 ;break ; -default : -dev_err (adap->pdev_dev,"ISSI Flash Part has bad size, ID = %#x, Density code = %#x\n" , - flashid, density); -return -EINVAL ; }break ; }
@@ -8635,10 +8626,6 @@ static int t4_get_flash_params(struct adcase 0x18 :/* 16MB */ size =1 <<24 ;break ; -default : -dev_err (adap->pdev_dev,"Macronix Flash Part has bad size, ID = %#x, Density code = %#x\n" , - flashid, density); -return -EINVAL ; }break ; }
@@ -8654,17 +8641,21 @@ static int t4_get_flash_params(struct adcase 0x18 :/* 16MB */ size =1 <<24 ;break ; -default : -dev_err (adap->pdev_dev,"Winbond Flash Part has bad size, ID = %#x, Density code = %#x\n" , - flashid, density); -return -EINVAL ; }break ; } -default : -dev_err (adap->pdev_dev,"Unsupported Flash Part, ID = %#x\n" , - flashid); -return -EINVAL ; + } + +/* If we didn't recognize the FLASH part, that's no real issue: the +* Hardware/Software contract says that Hardware will _*ALWAYS*_ +* use a FLASH part which is at least 4MB in size and has 64KB +* sectors. The unrecognized FLASH part is likely to be much larger +* than 4MB, but that's all we really need. +*/ +if (size ==0 ) { +dev_warn (adap->pdev_dev,"Unknown Flash Part, ID = %#x, assuming 4MB\n" , + flashid); + size =1 <<22 ; }/* Store decoded Flash size and fall through into vetting code. */
Greg Kroah-Hartman
maintainerPATCH 206/324 ARM: pxa: irq: fix handling of ICMR registers in suspend/resume
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mack <[email protected]>
[ Upstream commit 0c1049dcb4ceec640d8bd797335bcbebdcab44d2 ]
PXA3xx platforms have 56 interrupts that are stored in two ICMR registers. The code in pxa_irq_suspend() and pxa_irq_resume() however does a simple division by 32 which only leads to one register being saved at suspend and restored at resume time. The NAND interrupt setting, for instance, is lost.
Fix this by using DIV_ROUND_UP() instead.
--- arch/arm/mach-pxa/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/irq.c +2 -2
@@ -185,7 +185,7 @@ static int pxa_irq_suspend(void) {int i; -for (i =0 ; i < pxa_internal_irq_nr /32 ; i++) { +for (i =0 ; i <DIV_ROUND_UP (pxa_internal_irq_nr,32 ); i++) {void __iomem *base =irq_base (i); saved_icmr[i] =__raw_readl (base +ICMR );
@@ -204,7 +204,7 @@ static void pxa_irq_resume(void) {int i; -for (i =0 ; i < pxa_internal_irq_nr /32 ; i++) { +for (i =0 ; i <DIV_ROUND_UP (pxa_internal_irq_nr,32 ); i++) {void __iomem *base =irq_base (i);__raw_writel (saved_icmr[i], base +ICMR );
Greg Kroah-Hartman
maintainerPATCH 207/324 net: macb: Free RX ring for all queues
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harini Katakam <[email protected]>
[ Upstream commit e50b770ea5c9eff0013e8ae714d20182ed50d5e6 ]
rx ring is allocated for all queues in macb_alloc_consistent. Free the same for all queues instead of just Q0.
--- drivers/net/ethernet/cadence/macb_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +5 -6
@@ -1818,13 +1818,7 @@ static void macb_free_consistent(structstruct macb_queue *queue;unsigned int q; - queue = &bp->queues[0 ]; bp->macbgem_ops.mog_free_rx_buffers (bp); -if (queue->rx_ring) { -dma_free_coherent (&bp->pdev->dev,RX_RING_BYTES (bp), - queue->rx_ring, queue->rx_ring_dma); - queue->rx_ring =NULL ; - }for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) {kfree (queue->tx_skb);
@@ -1834,6 +1828,11 @@ static void macb_free_consistent(struct queue->tx_ring, queue->tx_ring_dma); queue->tx_ring =NULL ; } +if (queue->rx_ring) { +dma_free_coherent (&bp->pdev->dev,RX_RING_BYTES (bp), + queue->rx_ring, queue->rx_ring_dma); + queue->rx_ring =NULL ; + } } }
Greg Kroah-Hartman
maintainerPATCH 208/324 net/sched: act_csum: fix NULL dereference when goto chain is used
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davide Caratti <[email protected]>
[ Upstream commit 11a245e2f7bf25fc21f47e4c9c8491841b128890 ]
the control action in the common member of struct tcf_csum must be a valid value, as it can contain the chain index when 'goto chain' is used. Ensure that the control action can be read as x->tcfa_action, when x is a pointer to struct tc_action and x->ops->type is TCA_ACT_CSUM, to prevent the following command:
# tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
Quoted 1 line
$tcflags
dst_mac$h2mac action csum ip or tcp or udp or sctp goto chain 1
from triggering a NULL pointer dereference when a matching packet is received.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 800000010416b067 P4D 800000010416b067 PUD 1041be067 PMD 0 Oops: 0000 [#1] SMP PTI CPU: 0 PID: 3072 Comm: mausezahn Tainted: G E 4.18.0-rc2.auguri+ #421 Hardware name: Hewlett-Packard HP Z220 CMT Workstation/1790, BIOS K51 v01.58 02/07/2013 RIP: 0010:tcf_action_exec+0xb8/0x100 Code: 00 00 00 20 74 1d 83 f8 03 75 09 49 83 c4 08 4d 39 ec 75 bc 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 49 8b 97 a8 00 00 00 <48> 8b 12 48 89 55 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 RSP: 0018:ffffa020dea03c40 EFLAGS: 00010246 RAX: 0000000020000001 RBX: ffffa020d7ccef00 RCX: 0000000000000054 RDX: 0000000000000000 RSI: ffffa020ca5ae000 RDI: ffffa020d7ccef00 RBP: ffffa020dea03e60 R08: 0000000000000000 R09: ffffa020dea03c9c R10: ffffa020dea03c78 R11: 0000000000000008 R12: ffffa020d3fe4f00 R13: ffffa020d3fe4f08 R14: 0000000000000001 R15: ffffa020d53ca300 FS: 00007f5a46942740(0000) GS:ffffa020dea00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000104218002 CR4: 00000000001606f0 Call Trace: <IRQ> fl_classify+0x1ad/0x1c0 [cls_flower] ? arp_rcv+0x121/0x1b0 ? __x2apic_send_IPI_dest+0x40/0x40 ? smp_reschedule_interrupt+0x1c/0xd0 ? reschedule_interrupt+0xf/0x20 ? reschedule_interrupt+0xa/0x20 ? device_is_rmrr_locked+0xe/0x50 ? iommu_should_identity_map+0x49/0xd0 ? __intel_map_single+0x30/0x140 ? e1000e_update_rdt_wa.isra.52+0x22/0xb0 [e1000e] ? e1000_alloc_rx_buffers+0x233/0x250 [e1000e] ? kmem_cache_alloc+0x38/0x1c0 tcf_classify+0x89/0x140 __netif_receive_skb_core+0x5ea/0xb70 ? enqueue_task_fair+0xb6/0x7d0 ? process_backlog+0x97/0x150 process_backlog+0x97/0x150 net_rx_action+0x14b/0x3e0 __do_softirq+0xde/0x2b4 do_softirq_own_stack+0x2a/0x40 </IRQ> do_softirq.part.18+0x49/0x50 __local_bh_enable_ip+0x49/0x50 __dev_queue_xmit+0x4ab/0x8a0 ? wait_woken+0x80/0x80 ? packet_sendmsg+0x38f/0x810 ? __dev_queue_xmit+0x8a0/0x8a0 packet_sendmsg+0x38f/0x810 sock_sendmsg+0x36/0x40 __sys_sendto+0x10e/0x140 ? do_vfs_ioctl+0xa4/0x630 ? syscall_trace_enter+0x1df/0x2e0 ? __audit_syscall_exit+0x22a/0x290 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x5b/0x180 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f5a45cbec93 Code: 48 8b 0d 18 83 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c7 20 00 00 75 13 49 89 ca b8 2c 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 34 c3 48 83 ec 08 e8 2b f7 ff ff 48 89 04 24 RSP: 002b:00007ffd0ee6d748 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 0000000001161010 RCX: 00007f5a45cbec93 RDX: 0000000000000062 RSI: 0000000001161322 RDI: 0000000000000003 RBP: 00007ffd0ee6d780 R08: 00007ffd0ee6d760 R09: 0000000000000014 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000062 R13: 0000000001161322 R14: 00007ffd0ee6d760 R15: 0000000000000003 Modules linked in: act_csum act_gact cls_flower sch_ingress vrf veth act_tunnel_key(E) xt_CHECKSUM iptable_mangle ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel snd_hda_codec_hdmi snd_hda_codec_realtek kvm snd_hda_codec_generic hp_wmi iTCO_wdt sparse_keymap rfkill mei_wdt iTCO_vendor_support wmi_bmof gpio_ich irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc aesni_intel snd_hda_intel crypto_simd cryptd snd_hda_codec glue_helper snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm pcspkr i2c_i801 snd_timer snd sg lpc_ich soundcore wmi mei_me mei ie31200_edac nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sr_mod cdrom sd_mod ahci libahci crc32c_intel i915 ixgbe serio_raw libata video dca i2c_algo_bit sfc drm_kms_helper syscopyarea mtd sysfillrect mdio sysimgblt fb_sys_fops drm e1000e i2c_core CR2: 0000000000000000 ---[ end trace 3c9e9d1a77df4026 ]--- RIP: 0010:tcf_action_exec+0xb8/0x100 Code: 00 00 00 20 74 1d 83 f8 03 75 09 49 83 c4 08 4d 39 ec 75 bc 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 49 8b 97 a8 00 00 00 <48> 8b 12 48 89 55 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 RSP: 0018:ffffa020dea03c40 EFLAGS: 00010246 RAX: 0000000020000001 RBX: ffffa020d7ccef00 RCX: 0000000000000054 RDX: 0000000000000000 RSI: ffffa020ca5ae000 RDI: ffffa020d7ccef00 RBP: ffffa020dea03e60 R08: 0000000000000000 R09: ffffa020dea03c9c R10: ffffa020dea03c78 R11: 0000000000000008 R12: ffffa020d3fe4f00 R13: ffffa020d3fe4f08 R14: 0000000000000001 R15: ffffa020d53ca300 FS: 00007f5a46942740(0000) GS:ffffa020dea00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000104218002 CR4: 00000000001606f0 Kernel panic - not syncing: Fatal exception in interrupt Kernel Offset: 0x26400000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
--- include/net/tc_act/tc_csum.h | 1 - net/sched/act_csum.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)
include/net/tc_act/tc_csum.h +0 -1
@@ -7,7 +7,6 @@#include <linux/tc_act/tc_csum.h> struct tcf_csum_params { -int action;u32 update_flags;struct rcu_head rcu; };
net/sched/act_csum.c +3 -3
@@ -91,7 +91,7 @@ static int tcf_csum_init(struct net *net } params_old =rtnl_dereference (p->params); - params_new->action = parm->action; + p->tcf_action = parm->action; params_new->update_flags = parm->update_flags;rcu_assign_pointer (p->params, params_new);if (params_old)
@@ -561,7 +561,7 @@ static int tcf_csum(struct sk_buff *skb,tcf_lastuse_update (&p->tcf_tm);bstats_cpu_update (this_cpu_ptr (p->common.cpu_bstats), skb); - action = params->action; + action =READ_ONCE (p->tcf_action);if (unlikely (action ==TC_ACT_SHOT )) goto drop_stats;
@@ -599,11 +599,11 @@ static int tcf_csum_dump(struct sk_buff .index = p->tcf_index, .refcnt = p->tcf_refcnt - ref, .bindcnt = p->tcf_bindcnt - bind, + .action = p->tcf_action, };struct tcf_t t; params =rtnl_dereference (p->params); - opt.action = params->action; opt.update_flags = params->update_flags;if (nla_put (skb,TCA_CSUM_PARMS ,sizeof (opt), &opt))
Greg Kroah-Hartman
maintainerPATCH 209/324 net/sched: act_tunnel_key: fix NULL dereference when goto chain is used
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davide Caratti <[email protected]>
[ Upstream commit 38230a3e0e0933bbcf5df6fa469ba0667f667568 ]
the control action in the common member of struct tcf_tunnel_key must be a valid value, as it can contain the chain index when 'goto chain' is used. Ensure that the control action can be read as x->tcfa_action, when x is a pointer to struct tc_action and x->ops->type is TCA_ACT_TUNNEL_KEY, to prevent the following command:
# tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
Quoted 1 line
$tcflags
dst_mac$h2mac actiontunnel_keyunset goto chain 1
from causing a NULL dereference when a matching packet is received:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 80000001097ac067 P4D 80000001097ac067 PUD 103b0a067 PMD 0 Oops: 0000 [#1] SMP PTI CPU: 0 PID: 3491 Comm: mausezahn Tainted: G E 4.18.0-rc2.auguri+ #421 Hardware name: Hewlett-Packard HP Z220 CMT Workstation/1790, BIOS K51 v01.58 02/07/2013 RIP: 0010:tcf_action_exec+0xb8/0x100 Code: 00 00 00 20 74 1d 83 f8 03 75 09 49 83 c4 08 4d 39 ec 75 bc 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 49 8b 97 a8 00 00 00 <48> 8b 12 48 89 55 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 RSP: 0018:ffff95145ea03c40 EFLAGS: 00010246 RAX: 0000000020000001 RBX: ffff9514499e5800 RCX: 0000000000000001 RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000 RBP: ffff95145ea03e60 R08: 0000000000000000 R09: ffff95145ea03c9c R10: ffff95145ea03c78 R11: 0000000000000008 R12: ffff951456a69800 R13: ffff951456a69808 R14: 0000000000000001 R15: ffff95144965ee40 FS: 00007fd67ee11740(0000) GS:ffff95145ea00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000001038a2006 CR4: 00000000001606f0 Call Trace: <IRQ> fl_classify+0x1ad/0x1c0 [cls_flower] ? __update_load_avg_se.isra.47+0x1ca/0x1d0 ? __update_load_avg_se.isra.47+0x1ca/0x1d0 ? update_load_avg+0x665/0x690 ? update_load_avg+0x665/0x690 ? kmem_cache_alloc+0x38/0x1c0 tcf_classify+0x89/0x140 __netif_receive_skb_core+0x5ea/0xb70 ? enqueue_entity+0xd0/0x270 ? process_backlog+0x97/0x150 process_backlog+0x97/0x150 net_rx_action+0x14b/0x3e0 __do_softirq+0xde/0x2b4 do_softirq_own_stack+0x2a/0x40 </IRQ> do_softirq.part.18+0x49/0x50 __local_bh_enable_ip+0x49/0x50 __dev_queue_xmit+0x4ab/0x8a0 ? wait_woken+0x80/0x80 ? packet_sendmsg+0x38f/0x810 ? __dev_queue_xmit+0x8a0/0x8a0 packet_sendmsg+0x38f/0x810 sock_sendmsg+0x36/0x40 __sys_sendto+0x10e/0x140 ? do_vfs_ioctl+0xa4/0x630 ? syscall_trace_enter+0x1df/0x2e0 ? __audit_syscall_exit+0x22a/0x290 __x64_sys_sendto+0x24/0x30 do_syscall_64+0x5b/0x180 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fd67e18dc93 Code: 48 8b 0d 18 83 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 59 c7 20 00 00 75 13 49 89 ca b8 2c 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 34 c3 48 83 ec 08 e8 2b f7 ff ff 48 89 04 24 RSP: 002b:00007ffe0189b748 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00000000020ca010 RCX: 00007fd67e18dc93 RDX: 0000000000000062 RSI: 00000000020ca322 RDI: 0000000000000003 RBP: 00007ffe0189b780 R08: 00007ffe0189b760 R09: 0000000000000014 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000062 R13: 00000000020ca322 R14: 00007ffe0189b760 R15: 0000000000000003 Modules linked in: act_tunnel_key act_gact cls_flower sch_ingress vrf veth act_csum(E) xt_CHECKSUM iptable_mangle ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter intel_rapl snd_hda_codec_hdmi x86_pkg_temp_thermal intel_powerclamp snd_hda_codec_realtek coretemp snd_hda_codec_generic kvm_intel kvm irqbypass snd_hda_intel crct10dif_pclmul crc32_pclmul hp_wmi ghash_clmulni_intel pcbc snd_hda_codec aesni_intel sparse_keymap rfkill snd_hda_core snd_hwdep snd_seq crypto_simd iTCO_wdt gpio_ich iTCO_vendor_support wmi_bmof cryptd mei_wdt glue_helper snd_seq_device snd_pcm pcspkr snd_timer snd i2c_i801 lpc_ich sg soundcore wmi mei_me mei ie31200_edac nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sd_mod sr_mod cdrom i915 video i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ahci crc32c_intel libahci serio_raw sfc libata mtd drm ixgbe mdio i2c_core e1000e dca CR2: 0000000000000000 ---[ end trace 1ab8b5b5d4639dfc ]--- RIP: 0010:tcf_action_exec+0xb8/0x100 Code: 00 00 00 20 74 1d 83 f8 03 75 09 49 83 c4 08 4d 39 ec 75 bc 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 49 8b 97 a8 00 00 00 <48> 8b 12 48 89 55 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 RSP: 0018:ffff95145ea03c40 EFLAGS: 00010246 RAX: 0000000020000001 RBX: ffff9514499e5800 RCX: 0000000000000001 RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000 RBP: ffff95145ea03e60 R08: 0000000000000000 R09: ffff95145ea03c9c R10: ffff95145ea03c78 R11: 0000000000000008 R12: ffff951456a69800 R13: ffff951456a69808 R14: 0000000000000001 R15: ffff95144965ee40 FS: 00007fd67ee11740(0000) GS:ffff95145ea00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000001038a2006 CR4: 00000000001606f0 Kernel panic - not syncing: Fatal exception in interrupt Kernel Offset: 0x11400000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
--- include/net/tc_act/tc_tunnel_key.h | 1 - net/sched/act_tunnel_key.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)
include/net/tc_act/tc_tunnel_key.h +0 -1
@@ -18,7 +18,6 @@struct tcf_tunnel_key_params {struct rcu_head rcu;int tcft_action; -int action;struct metadata_dst *tcft_enc_metadata; };
net/sched/act_tunnel_key.c +3 -3
@@ -36,7 +36,7 @@ static int tunnel_key_act(struct sk_bufftcf_lastuse_update (&t->tcf_tm);bstats_cpu_update (this_cpu_ptr (t->common.cpu_bstats), skb); - action = params->action; + action =READ_ONCE (t->tcf_action);switch (params->tcft_action) {case TCA_TUNNEL_KEY_ACT_RELEASE :
@@ -182,7 +182,7 @@ static int tunnel_key_init(struct net *n params_old =rtnl_dereference (t->params); - params_new->action = parm->action; + t->tcf_action = parm->action; params_new->tcft_action = parm->t_action; params_new->tcft_enc_metadata = metadata;
@@ -254,13 +254,13 @@ static int tunnel_key_dump(struct sk_buf .index = t->tcf_index, .refcnt = t->tcf_refcnt - ref, .bindcnt = t->tcf_bindcnt - bind, + .action = t->tcf_action, };struct tcf_t tm; params =rtnl_dereference (t->params); opt.t_action = params->tcft_action; - opt.action = params->action;if (nla_put (skb,TCA_TUNNEL_KEY_PARMS ,sizeof (opt), &opt)) goto nla_put_failure;
Greg Kroah-Hartman
maintainerPATCH 210/324 nvmem: Dont let a NULL cell_id for nvmem_cell_get() crash us
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit 87ed1405ef09d29a14df43295f7b6a93b63bfe6e ]
In commit ca04d9d3e1b1 ("phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips") you can see a call like:
devm_nvmem_cell_get(dev, NULL);
Note that the cell ID passed to the function is NULL. This is because the qcom-qusb2 driver is expected to work only on systems where the PHY node is hooked up via device-tree and is nameless.
This works OK for the most part. The first thing nvmem_cell_get() does is to call of_nvmem_cell_get() and there it's documented that a NULL name is fine. The problem happens when the call to of_nvmem_cell_get() returns -EINVAL. In such a case we'll fall back to nvmem_cell_get_from_list() and eventually might (if nvmem_cells isn't an empty list) crash with something that looks like:
strcmp
nvmem_find_cell
__nvmem_device_get
nvmem_cell_get_from_list
nvmem_cell_get
devm_nvmem_cell_get
qusb2_phy_probe
There are several different ways we could fix this problem:
One could argue that perhaps the qcom-qusb2 driver should be changed to use of_nvmem_cell_get() which is allowed to have a NULL name. In that case, we'd need to add a patche to introduce devm_of_nvmem_cell_get() since the qcom-qusb2 driver is using devm managed resources.
One could also argue that perhaps we could just add a name to qcom-qusb2. That would be OK but I believe it effectively changes the device tree bindings, so maybe it's a no-go.
In this patch I have chosen to fix the problem by simply not crashing when a NULL cell_id is passed to nvmem_cell_get().
NOTE: that for the qcom-qusb2 driver the "nvmem-cells" property is defined to be optional and thus it's expected to be a common case that we would hit this crash and this is more than just a theoretical fix.
--- drivers/nvmem/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvmem/core.c +4 -0
@@ -924,6 +924,10 @@ struct nvmem_cell *nvmem_cell_get(structreturn cell; } +/* NULL cell_id only allowed for device tree; invalid otherwise */ +if (!cell_id) +return ERR_PTR (-EINVAL ); +return nvmem_cell_get_from_list (cell_id); }EXPORT_SYMBOL_GPL (nvmem_cell_get);
Greg Kroah-Hartman
maintainerPATCH 211/324 bpf: fix sk_skb programs without skb->dev assigned
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Fastabend <[email protected]>
[ Upstream commit 0c6bc6e531a6db36f49622f1f115770160f7afb0 ]
Multiple BPF helpers in use by sk_skb programs calculate the max skb length using the __bpf_skb_max_len function. However, this calculates the max length using the skb->dev pointer which can be NULL when an sk_skb program is paired with an sk_msg program.
To force this a sk_msg program needs to redirect into the ingress path of a sock with an attach sk_skb program. Then the the sk_skb program would need to call one of the helpers that adjust the skb size.
To fix the null ptr dereference use SKB_MAX_ALLOC size if no dev is available.
--- net/core/filter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/filter.c +2 -1
@@ -2516,7 +2516,8 @@ static int bpf_skb_net_shrink(struct sk_static u32 __bpf_skb_max_len (const struct sk_buff *skb) { -return skb->dev->mtu + skb->dev->hard_header_len; +return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len : +SKB_MAX_ALLOC ; }static int bpf_skb_adjust_net (struct sk_buff *skb,s32 len_diff)
Greg Kroah-Hartman
maintainerPATCH 212/324 ipfrag: really prevent allocation on netns exit
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit f6f2a4a2eb92bc73671204198bb2f8ab53ff59fb ]
Setting the low threshold to 0 has no effect on frags allocation, we need to clear high_thresh instead.
The code was pre-existent to commit 648700f76b03 ("inet: frags:
use rhashtables for reassembly units"), but before the above, such assignment had a different role: prevent concurrent eviction from the worker and the netns cleanup helper.
--- net/ipv4/inet_fragment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_fragment.c +1 -1
@@ -90,7 +90,7 @@ static void inet_frags_free_cb(void *ptrvoid inet_frags_exit_net (struct netns_frags *nf) { - nf->low_thresh =0 ;/* prevent creation of new frags */ + nf->high_thresh =0 ;/* prevent creation of new frags */ rhashtable_free_and_destroy (&nf->rhashtable, inet_frags_free_cb,NULL ); }
Greg Kroah-Hartman
maintainerPATCH 213/324 drm/sun4i: link in front-end code if needed
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 3156b53c2e2fadafa1a16412a8791b38f94b5bdc ]
When the base sun4i DRM driver is built-in but the back-end is a loadable module, we run into a link error:
drivers/gpu/drm/sun4i/sun4i_drv.o: In function `sun4i_drv_probe':
sun4i_drv.c:(.text+0x60c): undefined reference to `sun4i_frontend_of_table'
The dependency is a bit tricky, the best workaround I have come up with is to use a Makefile hack to to interpret both CONFIG_DRM_SUN4I_BACKEND=m and CONFIG_DRM_SUN4I_BACKEND=y as a directive to build the front-end the same way as the main module.
--- drivers/gpu/drm/sun4i/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/Makefile +4 -1
@@ -29,7 +29,10 @@ obj-$(CONFIG_DRM_SUN4I) += sun4i-tcon.o obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o -obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o sun4i-frontend.o +obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o +ifdef CONFIG_DRM_SUN4I_BACKEND +obj-$(CONFIG_DRM_SUN4I) += sun4i-frontend.o +endif obj-$(CONFIG_DRM_SUN4I_HDMI) += sun4i-drm-hdmi.o obj-$(CONFIG_DRM_SUN8I_DW_HDMI) += sun8i-drm-hdmi.o obj-$(CONFIG_DRM_SUN8I_MIXER) += sun8i-mixer.o
Greg Kroah-Hartman
maintainerPATCH 214/324 ieee802154: at86rf230: switch from BUG_ON() to WARN_ON() on problem
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Schmidt <[email protected]>
[ Upstream commit 20f330452ad8814f2289a589baf65e21270879a7 ]
The check is valid but it does not warrant to crash the kernel. A WARN_ON() is good enough here.
Found by checkpatch.
--- drivers/net/ieee802154/at86rf230.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/at86rf230.c +1 -1
@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw,static int at86rf230_ed (struct ieee802154_hw *hw,u8 *level) { -BUG_ON (!level); +WARN_ON (!level); *level =0xbe ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 215/324 ieee802154: at86rf230: use __func__ macro for debug messages
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Schmidt <[email protected]>
[ Upstream commit 8a81388ec27c4c0adbdecd20e67bb5f411ab46b2 ]
Instead of having the function name hard-coded (it might change and we forgot to update them in the debug output) we can use __func__ instead and also shorter the line so we do not need to break it. Also fix an extra blank line while being here.
Found by checkpatch.
--- drivers/net/ieee802154/at86rf230.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ieee802154/at86rf230.c +4 -9
@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee80if (changed &IEEE802154_AFILT_SADDR_CHANGED ) {u16 addr =le16_to_cpu (filt->short_addr); -dev_vdbg (&lp->spi->dev, -"at86rf230_set_hw_addr_filt called for saddr\n" ); +dev_vdbg (&lp->spi->dev,"%s called for saddr\n" , __func__);__at86rf230_write (lp,RG_SHORT_ADDR_0 , addr);__at86rf230_write (lp,RG_SHORT_ADDR_1 , addr >>8 ); }
@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee80if (changed &IEEE802154_AFILT_PANID_CHANGED ) {u16 pan =le16_to_cpu (filt->pan_id); -dev_vdbg (&lp->spi->dev, -"at86rf230_set_hw_addr_filt called for pan id\n" ); +dev_vdbg (&lp->spi->dev,"%s called for pan id\n" , __func__);__at86rf230_write (lp,RG_PAN_ID_0 , pan);__at86rf230_write (lp,RG_PAN_ID_1 , pan >>8 ); }
@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee80u8 i, addr[8 ];memcpy (addr, &filt->ieee_addr,8 ); -dev_vdbg (&lp->spi->dev, -"at86rf230_set_hw_addr_filt called for IEEE addr\n" ); +dev_vdbg (&lp->spi->dev,"%s called for IEEE addr\n" , __func__);for (i =0 ; i <8 ; i++)__at86rf230_write (lp,RG_IEEE_ADDR_0 + i, addr[i]); }if (changed &IEEE802154_AFILT_PANC_CHANGED ) { -dev_vdbg (&lp->spi->dev, -"at86rf230_set_hw_addr_filt called for panc change\n" ); +dev_vdbg (&lp->spi->dev,"%s called for panc change\n" , __func__);if (filt->pan_coord)at86rf230_write_subreg (lp,SR_AACK_I_AM_COORD ,1 );else
@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154return at86rf230_write_subreg (lp,SR_CCA_MODE , val); } -static int at86rf230_set_cca_ed_level (struct ieee802154_hw *hw,s32 mbm) {
Greg Kroah-Hartman
maintainerPATCH 216/324 ieee802154: fakelb: switch from BUG_ON() to WARN_ON() on problem
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Schmidt <[email protected]>
[ Upstream commit 8f2fbc6c60ff213369e06a73610fc882a42fdf20 ]
The check is valid but it does not warrant to crash the kernel. A WARN_ON() is good enough here.
Found by checkpatch.
--- drivers/net/ieee802154/fakelb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/fakelb.c +1 -1
@@ -49,7 +49,7 @@ struct fakelb_phy {static int fakelb_hw_ed (struct ieee802154_hw *hw,u8 *level) { -BUG_ON (!level); +WARN_ON (!level); *level =0xbe ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 217/324 gpu: host1x: Skip IOMMU initialization if firewall is enabled
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Osipenko <[email protected]>
[ Upstream commit 4466b1f0e022f94a026bd700fee34bff15cdc4ef ]
Host1x's CDMA can't access the command buffers if IOMMU and Host1x firewall are enabled in the kernels config because firewall doesn't map the copied buffer into IOVA space. Fix this by skipping IOMMU initialization if firewall is enabled as firewall merges sparse cmdbufs into a single contiguous buffer and hence IOMMU isn't needed in this case.
--- drivers/gpu/host1x/dev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/host1x/dev.c +3 -0
@@ -218,6 +218,9 @@ static int host1x_probe(struct platform_return err; } +if (IS_ENABLED (CONFIG_TEGRA_HOST1X_FIREWALL )) + goto skip_iommu; + host->group =iommu_group_get (&pdev->dev);if (host->group) {struct iommu_domain_geometry *geometry;
Greg Kroah-Hartman
maintainerPATCH 218/324 gpu: host1x: Check whether size of unpin isnt 0
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Osipenko <[email protected]>
[ Upstream commit ec58923215dbbeef59ee82923ee94d745f73db58 ]
Only gather pins are mapped by the Host1x driver, regular BO relocations are not. Check whether size of unpin isn't 0, otherwise IOVA allocation at 0x0 could be erroneously released.
--- drivers/gpu/host1x/job.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/host1x/job.c +2 -1
@@ -686,7 +686,8 @@ void host1x_job_unpin(struct host1x_jobfor (i =0 ; i < job->num_unpins; i++) {struct host1x_job_unpin_data *unpin = &job->unpins[i]; -if (!IS_ENABLED (CONFIG_TEGRA_HOST1X_FIREWALL ) && host->domain) { +if (!IS_ENABLED (CONFIG_TEGRA_HOST1X_FIREWALL ) && + unpin->size && host->domain) {iommu_unmap (host->domain, job->addr_phys[i], unpin->size); free_iova(&host->iova,
Greg Kroah-Hartman
maintainerPATCH 219/324 drm/tegra: Fix comparison operator for buffer size
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 5265f0338bc0feec6c0d544dfe005dec1a93cb93 ]
Here we are checking for the buffer length, not an offset for writing to, so using > is correct. The current code incorrectly rejects a command buffer ending at the memory buffer's end.
--- drivers/gpu/drm/tegra/drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/drm.c +1 -1
@@ -436,7 +436,7 @@ int tegra_drm_submit(struct tegra_drm_co* unaligned offset is malformed and cause commands stream * corruption on the buffer address relocation. */ -if (offset &3 || offset >= obj->gem.size) { +if (offset &3 || offset > obj->gem.size) { err = -EINVAL ; goto fail; }
Greg Kroah-Hartman
maintainerPATCH 220/324 net: ieee802154: adf7242: Fix erroneous RX enable
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Hennerich <[email protected]>
[ Upstream commit 36d26d6b6208399070a9d7993534fef9fc26b1ba ]
Only enable RX mode if the netdev is opened.
--- drivers/net/ieee802154/adf7242.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ieee802154/adf7242.c +4 -1
@@ -719,7 +719,10 @@ static int adf7242_channel(struct ieee80adf7242_write_reg (lp,REG_CH_FREQ1 , freq >>8 );adf7242_write_reg (lp,REG_CH_FREQ2 , freq >>16 ); -return adf7242_cmd (lp,CMD_RC_RX ); +if (test_bit (FLAG_START , &lp->flags)) +return adf7242_cmd_rx (lp); +else +return adf7242_cmd (lp,CMD_RC_PHY_RDY ); } static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw,
Greg Kroah-Hartman
maintainerPATCH 221/324 net: ieee802154: adf7242: Fix OCL calibration runs
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Hennerich <[email protected]>
[ Upstream commit 58e9683d14752debc6f22daf6b23e031787df31f ]
Reissuing RC_RX every 400ms - to adjust for offset drift in receiver see datasheet page 61, OCL section.
--- drivers/net/ieee802154/adf7242.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/net/ieee802154/adf7242.c +28 -1
@@ -275,6 +275,8 @@ struct adf7242_local {struct spi_message stat_msg;struct spi_transfer stat_xfer;struct dentry *debugfs_root; +struct delayed_work work; +struct workqueue_struct *wqueue;unsigned long flags;int tx_stat;bool promiscuous;
@@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242/* Wait until the ACK is sent */ adf7242_wait_status (lp,RC_STATUS_PHY_RDY ,RC_STATUS_MASK , __LINE__);adf7242_clear_irqstat (lp); +mod_delayed_work (lp->wqueue, &lp->work,msecs_to_jiffies (400 ));return adf7242_cmd (lp,CMD_RC_RX ); } +static void adf7242_rx_cal_work (struct work_struct *work) +{ +struct adf7242_local *lp = + container_of(work, struct adf7242_local, work.work); + +/* Reissuing RC_RX every 400ms - to adjust for offset +* drift in receiver (datasheet page 61, OCL section) +*/ + +if (!test_bit (FLAG_XMIT , &lp->flags)) { +adf7242_cmd (lp,CMD_RC_PHY_RDY ); +adf7242_cmd_rx (lp); + } +} +static int adf7242_set_txpower (struct ieee802154_hw *hw,int mbm) {struct adf7242_local *lp = hw->priv;
@@ -686,7 +704,7 @@ static int adf7242_start(struct ieee8021enable_irq (lp->spi->irq);set_bit (FLAG_START , &lp->flags); -return adf7242_cmd (lp,CMD_RC_RX ); +return adf7242_cmd_rx (lp); }static void adf7242_stop (struct ieee802154_hw *hw)
@@ -694,6 +712,7 @@ static void adf7242_stop(struct ieee8021struct adf7242_local *lp = hw->priv;disable_irq (lp->spi->irq); +cancel_delayed_work_sync (&lp->work);adf7242_cmd (lp,CMD_RC_IDLE );clear_bit (FLAG_START , &lp->flags);adf7242_clear_irqstat (lp);
@@ -817,6 +836,7 @@ static int adf7242_xmit(struct ieee80215/* ensure existing instances of the IRQ handler have completed */ disable_irq (lp->spi->irq);set_bit (FLAG_XMIT , &lp->flags); +cancel_delayed_work_sync (&lp->work);reinit_completion (&lp->tx_complete);adf7242_cmd (lp,CMD_RC_PHY_RDY );adf7242_clear_irqstat (lp);
@@ -955,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq,unsigned int xmit;u8 irq1; +mod_delayed_work (lp->wqueue, &lp->work,msecs_to_jiffies (400 ));adf7242_read_reg (lp,REG_IRQ1_SRC1 , &irq1);if (!(irq1 & (IRQ_RX_PKT_RCVD |IRQ_CSMA_CA )))
@@ -1244,6 +1265,9 @@ static int adf7242_probe(struct spi_devispi_message_add_tail (&lp->stat_xfer, &lp->stat_msg);spi_set_drvdata (spi, lp); +INIT_DELAYED_WORK (&lp->work, adf7242_rx_cal_work); + lp->wqueue =alloc_ordered_workqueue (dev_name (&spi->dev), +WQ_MEM_RECLAIM ); ret =adf7242_hw_init (lp);if (ret)
@@ -1287,6 +1311,9 @@ static int adf7242_remove(struct spi_devif (!IS_ERR_OR_NULL (lp->debugfs_root))debugfs_remove_recursive (lp->debugfs_root); +cancel_delayed_work_sync (&lp->work); +destroy_workqueue (lp->wqueue); +ieee802154_unregister_hw (lp->hw);mutex_destroy (&lp->bmux);ieee802154_free_hw (lp->hw);
Greg Kroah-Hartman
maintainerPATCH 222/324 drm/armada: fix colorkey mode property
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit d378859a667edc99e3473704847698cae97ca2b1 ]
The colorkey mode property was not correctly disabling the colorkeying when "disabled" mode was selected. Arrange for this to work as one would expect.
--- drivers/gpu/drm/armada/armada_hw.h | 1 + drivers/gpu/drm/armada/armada_overlay.c | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-)
drivers/gpu/drm/armada/armada_hw.h +1 -0
@@ -160,6 +160,7 @@ enum {CFG_ALPHAM_GRA =0x1 <<16 ,CFG_ALPHAM_CFG =0x2 <<16 ,CFG_ALPHA_MASK =0xff <<8 , +#define CFG_ALPHA(x) ((x) << 8) CFG_PIXCMD_MASK = 0xff, };
drivers/gpu/drm/armada/armada_overlay.c +22 -8
@@ -28,6 +28,7 @@ struct armada_ovl_plane_properties {uint16_t contrast;uint16_t saturation;uint32_t colorkey_mode; +uint32_t colorkey_enable; };struct armada_ovl_plane {
@@ -54,11 +55,13 @@ armada_ovl_update_attr(struct armada_ovlwritel_relaxed (0x00002000 , dcrtc->base +LCD_SPU_CBSH_HUE );spin_lock_irq (&dcrtc->irq_lock); -armada_updatel (prop->colorkey_mode |CFG_ALPHAM_GRA , -CFG_CKMODE_MASK |CFG_ALPHAM_MASK |CFG_ALPHA_MASK , - dcrtc->base +LCD_SPU_DMA_CTRL1 ); - -armada_updatel (ADV_GRACOLORKEY ,0 , dcrtc->base +LCD_SPU_ADV_REG ); +armada_updatel (prop->colorkey_mode, +CFG_CKMODE_MASK |CFG_ALPHAM_MASK |CFG_ALPHA_MASK , + dcrtc->base +LCD_SPU_DMA_CTRL1 ); +if (dcrtc->variant->has_spu_adv_reg) +armada_updatel (prop->colorkey_enable, +ADV_GRACOLORKEY |ADV_VIDCOLORKEY , + dcrtc->base +LCD_SPU_ADV_REG );spin_unlock_irq (&dcrtc->irq_lock); }
@@ -321,8 +324,17 @@ static int armada_ovl_plane_set_property dplane->prop.colorkey_vb |=K2B (val); update_attr = true; }else if (property == priv->colorkey_mode_prop) { - dplane->prop.colorkey_mode &= ~CFG_CKMODE_MASK ; - dplane->prop.colorkey_mode |=CFG_CKMODE (val); +if (val ==CKMODE_DISABLE ) { + dplane->prop.colorkey_mode = +CFG_CKMODE (CKMODE_DISABLE ) | +CFG_ALPHAM_CFG |CFG_ALPHA (255 ); + dplane->prop.colorkey_enable =0 ; + }else { + dplane->prop.colorkey_mode = +CFG_CKMODE (val) | +CFG_ALPHAM_GRA |CFG_ALPHA (0 ); + dplane->prop.colorkey_enable =ADV_GRACOLORKEY ; + } update_attr = true; }else if (property == priv->brightness_prop) { dplane->prop.brightness = val -256 ;
@@ -453,7 +465,9 @@ int armada_overlay_plane_create(struct d dplane->prop.colorkey_yr =0xfefefe00 ; dplane->prop.colorkey_ug =0x01010100 ; dplane->prop.colorkey_vb =0x01010100 ; - dplane->prop.colorkey_mode =CFG_CKMODE (CKMODE_RGB ); + dplane->prop.colorkey_mode =CFG_CKMODE (CKMODE_RGB ) | +CFG_ALPHAM_GRA |CFG_ALPHA (0 ); + dplane->prop.colorkey_enable =ADV_GRACOLORKEY ; dplane->prop.brightness =0 ; dplane->prop.contrast =0x4000 ; dplane->prop.saturation =0x4000 ;
Greg Kroah-Hartman
maintainerPATCH 223/324 drm/armada: fix irq handling
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit 92298c1cd8e8a6b56322b602ad72b54e6237631d ]
Add the missing locks to the IRQ enable/disable paths, and fix a comment in the interrupt handler: reading the ISR clears down the status bits, but does not reset the interrupt so it can signal again. That seems to require a write.
--- drivers/gpu/drm/armada/armada_crtc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/armada/armada_crtc.c +10 -2
@@ -519,8 +519,9 @@ static irqreturn_t armada_drm_irq(int iru32 v, stat =readl_relaxed (dcrtc->base +LCD_SPU_IRQ_ISR );/* -* This is rediculous - rather than writing bits to clear, we -* have to set the actual status register value. This is racy. +* Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR +* is set. Writing has some other effect to acknowledge the IRQ - +* without this, we only get a single IRQ. */ writel_relaxed (0 , dcrtc->base +LCD_SPU_IRQ_ISR );
@@ -1116,16 +1117,22 @@ armada_drm_crtc_set_property(struct drm_static int armada_drm_crtc_enable_vblank (struct drm_crtc *crtc) {struct armada_crtc *dcrtc =drm_to_armada_crtc (crtc); +unsigned long flags; +spin_lock_irqsave (&dcrtc->irq_lock, flags);armada_drm_crtc_enable_irq (dcrtc,VSYNC_IRQ_ENA ); +spin_unlock_irqrestore (&dcrtc->irq_lock, flags);return 0 ; }static void armada_drm_crtc_disable_vblank (struct drm_crtc *crtc) {struct armada_crtc *dcrtc =drm_to_armada_crtc (crtc); +unsigned long flags; +spin_lock_irqsave (&dcrtc->irq_lock, flags);armada_drm_crtc_disable_irq (dcrtc,VSYNC_IRQ_ENA ); +spin_unlock_irqrestore (&dcrtc->irq_lock, flags); }static const struct drm_crtc_funcs armada_crtc_funcs = {
@@ -1415,6 +1422,7 @@ static int armada_drm_crtc_create(struct CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);writel_relaxed (0x2032ff81 , dcrtc->base +LCD_SPU_DMA_CTRL1 );writel_relaxed (dcrtc->irq_ena, dcrtc->base +LCD_SPU_IRQ_ENA ); +readl_relaxed (dcrtc->base +LCD_SPU_IRQ_ISR );writel_relaxed (0 , dcrtc->base +LCD_SPU_IRQ_ISR ); ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
Greg Kroah-Hartman
maintainerPATCH 224/324 netfilter: nft_compat: explicitly reject ERROR and standard target
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 21d5e078192d244df3d6049f9464fff2f72cfd68 ]
iptables-nft never requests these, but make this explicitly illegal. If it were quested, kernel could oops as ->eval is NULL, furthermore, the builtin targets have no owning module so its possible to rmmod eb/ip/ip6_tables module even if they would be loaded.
--- net/netfilter/nft_compat.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/netfilter/nft_compat.c +13 -0
@@ -825,10 +825,18 @@ nft_target_select_ops(const struct nft_c rev =ntohl (nla_get_be32 (tb[NFTA_TARGET_REV ])); family = ctx->family; +if (strcmp (tg_name,XT_ERROR_TARGET ) ==0 || +strcmp (tg_name,XT_STANDARD_TARGET ) ==0 || +strcmp (tg_name,"standard" ) ==0 ) +return ERR_PTR (-EINVAL ); +/* Re-use the existing target if it's already loaded. */ list_for_each_entry (nft_target, &nft_target_list, head) {struct xt_target *target = nft_target->ops.data; +if (!target->target) +continue ; +if (nft_target_cmp (target, tg_name, rev, family))return &nft_target->ops; }
@@ -837,6 +845,11 @@ nft_target_select_ops(const struct nft_cif (IS_ERR (target))return ERR_PTR (-ENOENT ); +if (!target->target) { + err = -EINVAL ; + goto err; + } +if (target->targetsize >nla_len (tb[NFTA_TARGET_INFO ])) { err = -EINVAL ; goto err;
Greg Kroah-Hartman
maintainerPATCH 225/324 netfilter: nf_conntrack: Fix possible possible crash on module loading.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Ryabinin <[email protected]>
[ Upstream commit 2045cdfa1b40d66f126f3fd05604fc7c754f0022 ]
Loading the nf_conntrack module with doubled hashsize parameter, i.e.
modprobe nf_conntrack hashsize=12345 hashsize=12345
causes NULL-ptr deref.
If 'hashsize' specified twice, the nf_conntrack_set_hashsize() function will be called also twice.
The first nf_conntrack_set_hashsize() call will set the 'nf_conntrack_htable_size' variable:
nf_conntrack_set_hashsize() ... /* On boot, we can set this without any fancy locking. */ if (!nf_conntrack_htable_size) return param_set_uint(val, kp);
But on the second invocation, the nf_conntrack_htable_size is already set, so the nf_conntrack_set_hashsize() will take a different path and call the nf_conntrack_hash_resize() function. Which will crash on the attempt to dereference 'nf_conntrack_hash' pointer:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 RIP: 0010:nf_conntrack_hash_resize+0x255/0x490 [nf_conntrack] Call Trace: nf_conntrack_set_hashsize+0xcd/0x100 [nf_conntrack] parse_args+0x1f9/0x5a0 load_module+0x1281/0x1a50 __se_sys_finit_module+0xbe/0xf0 do_syscall_64+0x7c/0x390 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fix this, by checking !nf_conntrack_hash instead of !nf_conntrack_htable_size. nf_conntrack_hash will be initialized only after the module loaded, so the second invocation of the nf_conntrack_set_hashsize() won't crash, it will just reinitialize nf_conntrack_htable_size again.
--- net/netfilter/nf_conntrack_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_core.c +1 -1
@@ -1972,7 +1972,7 @@ int nf_conntrack_set_hashsize(const charreturn -EOPNOTSUPP ;/* On boot, we can set this without any fancy locking. */ -if (!nf_conntrack_htable_size) +if (!nf_conntrack_hash)return param_set_uint (val, kp); rc =kstrtouint (val,0 , &hashsize);
Greg Kroah-Hartman
maintainerPATCH 226/324 ARC: [plat-hsdk]: Configure APB GPIO controller on ARC HSDK platform
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo Pimentel <[email protected]>
[ Upstream commit ec58ba16e174d7ca24c8955a21cd0a53e0c32fdf ]
In case of HSDK we have intermediate INTC in for of DW APB GPIO controller which is used as a de-bounce logic for interrupt wires that come from outside the board.
We cannot use existing "irq-dw-apb-ictl" driver here because all input lines are routed to corresponding output lines but not muxed into one line (this is configured in RTL and we cannot change this in software).
But even if we add such a feature to "irq-dw-apb-ictl" driver that won't benefit us as higher-level INTC (in case of HSDK it is IDU) anyways has per-input control so adding fully-controller intermediate INTC will only bring some overhead on interrupt processing but no other benefits.
Thus we just do one-time configuration of DW APB GPIO controller and forget about it.
Based on implementation available on arch/arc/plat-axs10x/axs10x.c file.
--- arch/arc/plat-hsdk/platform.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
arch/arc/plat-hsdk/platform.c +62 -0
@@ -42,6 +42,66 @@ static void __init hsdk_init_per_cpu(uns#define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108)#define SDIO_UHS_REG_EXT_DIV_2 (2 << 30) +#define HSDK_GPIO_INTC (ARC_PERIPHERAL_BASE + 0x3000) + +static void __init hsdk_enable_gpio_intc_wire (void ) +{ +/* +* Peripherals on CPU Card are wired to cpu intc via intermediate +* DW APB GPIO blocks (mainly for debouncing) +* +* --------------------- +* | snps,archs-intc | +* --------------------- +* | +* ---------------------- +* | snps,archs-idu-intc | +* ---------------------- +* | | | | | +* | [eth] [USB] [... other peripherals] +* | +* ------------------- +* | snps,dw-apb-intc | +* ------------------- +* | | | | +* [Bt] [HAPS] [... other peripherals] +* +* Current implementation of "irq-dw-apb-ictl" driver doesn't work well +* with stacked INTCs. In particular problem happens if its master INTC +* not yet instantiated. See discussion here - +* https://lkml.org/lkml/2015/3/4/755 +* +* So setup the first gpio block as a passive pass thru and hide it from +* DT hardware topology - connect intc directly to cpu intc +* The GPIO "wire" needs to be init nevertheless (here) +* +* One side adv is that peripheral interrupt handling avoids one nested +* intc ISR hop +* +* According to HSDK User's Manual [1], "Table 2 Interrupt Mapping" +* we have the following GPIO input lines used as sources of interrupt: +* - GPIO[0] - Bluetooth interrupt of RS9113 module +* - GPIO[2] - HAPS interrupt (on HapsTrak 3 connector) +* - GPIO[3] - Audio codec (MAX9880A) interrupt +* - GPIO[8-23] - Available on Arduino and PMOD_x headers +* For now there's no use of Arduino and PMOD_x headers in Linux +* use-case so we only enable lines 0, 2 and 3. +* +* [1] https://github.com/foss-for-synopsys-dwc-arc-processors/ARC-Development-Systems-Forum/wiki/docs/ARC_HSDK_User_Guide.pdf +*/ +#define GPIO_INTEN (HSDK_GPIO_INTC + 0x30) +#define GPIO_INTMASK (HSDK_GPIO_INTC + 0x34) +#define GPIO_INTTYPE_LEVEL (HSDK_GPIO_INTC + 0x38) +#define GPIO_INT_POLARITY (HSDK_GPIO_INTC + 0x3c) +#define GPIO_INT_CONNECTED_MASK 0x0d + +iowrite32 (0xffffffff , (void __iomem *)GPIO_INTMASK ); +iowrite32 (~GPIO_INT_CONNECTED_MASK , (void __iomem *)GPIO_INTMASK ); +iowrite32 (0x00000000 , (void __iomem *)GPIO_INTTYPE_LEVEL ); +iowrite32 (0xffffffff , (void __iomem *)GPIO_INT_POLARITY ); +iowrite32 (GPIO_INT_CONNECTED_MASK , (void __iomem *)GPIO_INTEN ); +} +static void __init hsdk_init_early (void ) {/*
@@ -62,6 +122,8 @@ static void __init hsdk_init_early(void)* minimum possible div-by-2. */ iowrite32 (SDIO_UHS_REG_EXT_DIV_2 , (void __iomem *)SDIO_UHS_REG_EXT ); + +hsdk_enable_gpio_intc_wire (); }static const char *hsdk_compat[]__initconst = {
Greg Kroah-Hartman
maintainerPATCH 227/324 ARC: Improve cmpxchg syscall implementation
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
[ Upstream commit e8708786d4fe21c043d38d760f768949a3d71185 ]
This is used in configs lacking hardware atomics to emulate atomic r-m-w for user space, implemented by disabling preemption in kernel.
However there are issues in current implementation:
1. Process not terminated if invalid user pointer passed:
i.e. __get_user() failed.
2. The reason for this patch was __put_user() failure not being handled either, specifically for the COW break scenario.
The zero page is initially wired up and read from __get_user() succeeds. A subsequent write by __put_user() induces a Protection Violation, but COW can't finish as Linux page fault handler is disabled due to preempt disable.
And what's worse is we silently return the stale value to user space. Fix this specific case by re-enabling preemption and explicitly fixing up the fault and retrying the whole sequence over.
--- arch/arc/kernel/process.c | 47 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)
arch/arc/kernel/process.c +36 -11
@@ -47,7 +47,8 @@ SYSCALL_DEFINE0(arc_gettls) SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new) {struct pt_regs *regs =current_pt_regs (); -int uval = -EFAULT ; +u32 uval; +int ret;/* * This is only for old cores lacking LLOCK/SCOND, which by defintion
@@ -60,23 +61,47 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *,/* Z indicates to userspace if operation succeded */ regs->status32 &= ~STATUS_Z_MASK ; -if (!access_ok (VERIFY_WRITE , uaddr,sizeof (int ))) -return -EFAULT ; + ret =access_ok (VERIFY_WRITE , uaddr,sizeof (*uaddr)); +if (!ret) + goto fail; +again:preempt_disable (); -if (__get_user (uval, uaddr)) - goto done; + ret =__get_user (uval, uaddr); +if (ret) + goto fault; -if (uval == expected) { -if (!__put_user (new, uaddr)) - regs->status32 |=STATUS_Z_MASK ; - } +if (uval != expected) + goto out; -done: -preempt_enable (); + ret =__put_user (new, uaddr); +if (ret) + goto fault; + + regs->status32 |=STATUS_Z_MASK ; +out: +preempt_enable ();return uval; + +fault: +preempt_enable (); + +if (unlikely (ret != -EFAULT )) + goto fail; + +down_read (¤t->mm->mmap_sem); + ret =fixup_user_fault (current, current->mm, (unsigned long ) uaddr, +FAULT_FLAG_WRITE ,NULL ); +up_read (¤t->mm->mmap_sem); + +if (likely (!ret)) + goto again; + +fail: +force_sig (SIGSEGV , current); +return ret; }#ifdef CONFIG_ISA_ARCV2
Greg Kroah-Hartman
maintainerPATCH 229/324 bnxt_en: Fix inconsistent BNXT_FLAG_AGG_RINGS logic.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit 07f4fde53d12eb8d921b465bb298e964e0bdc38c ]
If there aren't enough RX rings available, the driver will attempt to use a single RX ring without the aggregation ring. If that also fails, the BNXT_FLAG_AGG_RINGS flag is cleared but the other ring parameters are not set consistently to reflect that. If more RX rings become available at the next open, the RX rings will be in an inconsistent state and may crash when freeing the RX rings.
Fix it by restoring the BNXT_FLAG_AGG_RINGS if not enough RX rings are available to run without aggregation rings.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -1
@@ -8485,8 +8485,11 @@ static int bnxt_get_dflt_rings(struct bn/* Not enough rings, try disabling agg rings. */ bp->flags &= ~BNXT_FLAG_AGG_RINGS ; rc =bnxt_get_max_rings (bp, max_rx, max_tx, shared); -if (rc) +if (rc) { +/* set BNXT_FLAG_AGG_RINGS back for consistency */ + bp->flags |=BNXT_FLAG_AGG_RINGS ;return rc; + } bp->flags |=BNXT_FLAG_NO_AGG_RINGS ; bp->dev->hw_features &= ~(NETIF_F_LRO |NETIF_F_GRO_HW ); bp->dev->features &= ~(NETIF_F_LRO |NETIF_F_GRO_HW );
Greg Kroah-Hartman
maintainerPATCH 230/324 bnxt_en: Always set output parameters in bnxt_get_max_rings().
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit 78f058a4aa0f2280dc4d45d2c4a95728398ef857 ]
The current code returns -ENOMEM and does not bother to set the output parameters to 0 when no rings are available. Some callers, such as bnxt_get_channels() will display garbage ring numbers when that happens. Fix it by always setting the output parameters.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -2
@@ -8467,11 +8467,11 @@ int bnxt_get_max_rings(struct bnxt *bp,int rx, tx, cp;_bnxt_get_max_rings (bp, &rx, &tx, &cp); + *max_rx = rx; + *max_tx = tx;if (!rx || !tx || !cp)return -ENOMEM ; - *max_rx = rx; - *max_tx = tx;return bnxt_trim_rings (bp, max_rx, max_tx, cp, shared); }
Greg Kroah-Hartman
maintainerPATCH 231/324 bnxt_en: Do not modify max IRQ count after RDMA driver requests/frees IRQs.
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Chan <[email protected]>
[ Upstream commit 30f529473ec962102e8bcd33a6a04f1e1b490ae2 ]
Calling bnxt_set_max_func_irqs() to modify the max IRQ count requested or freed by the RDMA driver is flawed. The max IRQ count is checked when re-initializing the IRQ vectors and this can happen multiple times during ifup or ethtool -L. If the max IRQ is reduced and the RDMA driver is operational, we may not initailize IRQs correctly. This problem shows up on VFs with very small number of MSIX.
There is no other logic that relies on the IRQ count excluding the ones used by RDMA. So we fix it by just removing the call to subtract or add the IRQs used by RDMA.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -5915,7 +5915,7 @@ unsigned int bnxt_get_max_func_irqs(stru return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); } -void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max_irqs) +static void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max_irqs) { bp->hw_resc.max_irqs = max_irqs; }
drivers/net/ethernet/broadcom/bnxt/bnxt.h +0 -1
@@ -1455,7 +1455,6 @@ void bnxt_set_max_func_stat_ctxs(structunsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp);void bnxt_set_max_func_cp_rings (struct bnxt *bp,unsigned int max);unsigned int bnxt_get_max_func_irqs (struct bnxt *bp); -void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max);int bnxt_get_avail_msix (struct bnxt *bp,int num);int bnxt_reserve_rings (struct bnxt *bp);void bnxt_tx_disable (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +0 -2
@@ -169,7 +169,6 @@ static int bnxt_req_msix_vecs(struct bnx edev->ulp_tbl[ulp_id].msix_requested = avail_msix; }bnxt_fill_msix_vecs (bp, ent); -bnxt_set_max_func_irqs (bp,bnxt_get_max_func_irqs (bp) - avail_msix);bnxt_set_max_func_cp_rings (bp, max_cp_rings - avail_msix); edev->flags |=BNXT_EN_FLAG_MSIX_REQUESTED ;return avail_msix;
@@ -192,7 +191,6 @@ static int bnxt_free_msix_vecs(struct bn msix_requested = edev->ulp_tbl[ulp_id].msix_requested;bnxt_set_max_func_cp_rings (bp, max_cp_rings + msix_requested); edev->ulp_tbl[ulp_id].msix_requested =0 ; -bnxt_set_max_func_irqs (bp,bnxt_get_max_func_irqs (bp) + msix_requested); edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED ;if (netif_running (dev)) {bnxt_close_nic (bp, true, false);
Greg Kroah-Hartman
maintainerPATCH 232/324 bnxt_en: Fix for system hang if request_irq fails
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikas Gupta <[email protected]>
[ Upstream commit c58387ab1614f6d7fb9e244f214b61e7631421fc ]
Fix bug in the error code path when bnxt_request_irq() returns failure. bnxt_disable_napi() should not be called in this error path because NAPI has not been enabled yet.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -1
@@ -6875,7 +6875,7 @@ static int __bnxt_open_nic(struct bnxt * rc =bnxt_request_irq (bp);if (rc) {netdev_err (bp->dev,"bnxt_request_irq err: %x\n" , rc); - goto open_err; + goto open_err_irq; } }
@@ -6913,6 +6913,8 @@ static int __bnxt_open_nic(struct bnxt * open_err:bnxt_disable_napi (bp); + +open_err_irq:bnxt_del_napi (bp); open_err_free_mem:
Greg Kroah-Hartman
maintainerPATCH 233/324 samples/bpf: Fix tc and ip paths in xdp2skb_meta.sh
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taeung Song <[email protected]>
[ Upstream commit b9626f45abccd044f8048269c67720f0719f2d4e ]
The below path error can occur:
# ./xdp2skb_meta.sh --dev eth0 --list ./xdp2skb_meta.sh: line 61: /usr/sbin/tc: No such file or directory
So just use command names instead of absolute paths of tc and ip. In addition, it allow callers to redefine $TC and $IP paths
--- samples/bpf/xdp2skb_meta.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
samples/bpf/xdp2skb_meta.sh +3 -3
@@ -16,8 +16,8 @@ BPF_FILE=xdp2skb_meta_kern.o DIR=$(dirname $0) -export TC=/usr/sbin/tc -export IP=/usr/sbin/ip +[ -z "$TC" ] && TC=tc +[ -z "$IP" ] && IP=ip function usage() { echo ""
@@ -53,7 +53,7 @@ function _call_cmd() { local allow_fail="$2" shift 2 if [[ -n "$VERBOSE" ]]; then - echo "$(basename $cmd) $@" + echo "$cmd $@" fi if [[ -n "$DRYRUN" ]]; then return
Greg Kroah-Hartman
maintainerPATCH 234/324 scsi: hpsa: correct enclosure sas address
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Don Brace <[email protected]>
[ Upstream commit 01d0e789a14aa735ddcfddd468ef06d4f917e06d ]
The original complaint was the lsscsi -t showed the same SAS address of the two enclosures (SEP devices). In fact the SAS address was being set to the Enclosure Logical Identifier (ELI).
--- drivers/scsi/hpsa.c | 25 +++++++++++++++++++++---- drivers/scsi/hpsa.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-)
drivers/scsi/hpsa.c +21 -4
@@ -3438,11 +3438,11 @@ static void hpsa_get_enclosure_info(strustruct ext_report_lun_entry *rle = &rlep->LUN[rle_index];u16 bmic_device_index =0 ; - bmic_device_index =GET_BMIC_DRIVE_NUMBER (&rle->lunid[0 ]); - - encl_dev->sas_address = + encl_dev->eli =hpsa_get_enclosure_logical_identifier (h, scsi3addr); + bmic_device_index =GET_BMIC_DRIVE_NUMBER (&rle->lunid[0 ]); +if (encl_dev->target ==-1 || encl_dev->lun ==-1 ) { rc =IO_OK ; goto out;
@@ -9695,7 +9695,24 @@ hpsa_sas_get_linkerrors(struct sas_phy *static int hpsa_sas_get_enclosure_identifier (struct sas_rphy *rphy,u64 *identifier) { - *identifier = rphy->identify.sas_address; +struct Scsi_Host *shost =phy_to_shost (rphy); +struct ctlr_info *h; +struct hpsa_scsi_dev_t *sd; + +if (!shost) +return -ENXIO ; + + h =shost_to_hba (shost); + +if (!h) +return -ENXIO ; + + sd =hpsa_find_device_by_sas_rphy (h, rphy); +if (!sd) +return -ENXIO ; + + *identifier = sd->eli; +return 0 ; }
drivers/scsi/hpsa.h +1 -0
@@ -68,6 +68,7 @@ struct hpsa_scsi_dev_t {#define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"unsigned char device_id[16 ];/* from inquiry pg. 0x83 */ u64 sas_address; +u64 eli;/* from report diags. */ unsigned char vendor[8 ];/* bytes 8-15 of inquiry data */ unsigned char model[16 ];/* bytes 16-31 of inquiry data */ unsigned char rev;/* byte 2 of inquiry data */
Greg Kroah-Hartman
maintainerPATCH 235/324 scsi: qedf: Send the driver state to MFW
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
[ Upstream commit 6ac174756dfc9884f08b23af840ca911155f5578 ]
Need to notify firmware when driver is loaded and unloaded.
--- drivers/scsi/qedf/qedf_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/scsi/qedf/qedf_main.c +12 -0
@@ -3241,6 +3241,11 @@ static int __qedf_probe(struct pci_dev *init_completion (&qedf->flogi_compl); + status = qed_ops->common->update_drv_state (qedf->cdev, true); +if (status) +QEDF_ERR (&(qedf->dbg_ctx), +"Failed to send drv state to MFW.\n" ); +memset (&link_params,0 ,sizeof (struct qed_link_params )); link_params.link_up = true; status = qed_ops->common->set_link (qedf->cdev, &link_params);
@@ -3289,6 +3294,7 @@ static int qedf_probe(struct pci_dev *pdstatic void __qedf_remove (struct pci_dev *pdev,int mode) {struct qedf_ctx *qedf; +int rc;if (!pdev) {QEDF_ERR (NULL ,"pdev is NULL.\n" );
@@ -3383,6 +3389,12 @@ static void __qedf_remove(struct pci_dev qed_ops->common->set_power_state (qedf->cdev,PCI_D0 );pci_set_drvdata (pdev,NULL ); } + + rc = qed_ops->common->update_drv_state (qedf->cdev, false); +if (rc) +QEDF_ERR (&(qedf->dbg_ctx), +"Failed to send drv state to MFW.\n" ); + qed_ops->common->slowpath_stop (qedf->cdev); qed_ops->common->remove (qedf->cdev);
Greg Kroah-Hartman
maintainerPATCH 236/324 scsi: qedi: Send driver state to MFW
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manish Rangankar <[email protected]>
[ Upstream commit a3440d0d2f57f7ba102fc332086961cf261180af ]
In case of iSCSI offload BFS environment, MFW requires to mark virtual link based upon qedi load status.
--- drivers/scsi/qedi/qedi_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/scsi/qedi/qedi_main.c +11 -0
@@ -2075,6 +2075,7 @@ kset_free:static void __qedi_remove (struct pci_dev *pdev,int mode) {struct qedi_ctx *qedi =pci_get_drvdata (pdev); +int rval;if (qedi->tmf_thread) {flush_workqueue (qedi->tmf_thread);
@@ -2104,6 +2105,10 @@ static void __qedi_remove(struct pci_devif (mode ==QEDI_MODE_NORMAL )qedi_free_iscsi_pf_param (qedi); + rval = qedi_ops->common->update_drv_state (qedi->cdev, false); +if (rval) +QEDI_ERR (&qedi->dbg_ctx,"Failed to send drv state to MFW\n" ); +if (!test_bit (QEDI_IN_OFFLINE , &qedi->flags)) { qedi_ops->common->slowpath_stop (qedi->cdev); qedi_ops->common->remove (qedi->cdev);
@@ -2378,6 +2383,12 @@ static int __qedi_probe(struct pci_dev *if (qedi_setup_boot_info (qedi))QEDI_ERR (&qedi->dbg_ctx,"No iSCSI boot target configured\n" ); + + rc = qedi_ops->common->update_drv_state (qedi->cdev, true); +if (rc) +QEDI_ERR (&qedi->dbg_ctx, +"Failed to send drv state to MFW\n" ); + }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 237/324 perf llvm-utils: Remove bashism from kernel include fetch script
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <[email protected]>
[ Upstream commit f6432b9f65001651412dbc3589d251534822d4ab ]
Like system(), popen() calls /bin/sh, which may/may not be bash.
Script when run on dash and encounters the line, yields:
exit: Illegal number: -1
checkbashisms report on script content:
possible bashism (exit|return with negative status code):
exit -1
Remove the bashism and use the more portable non-zero failure status code 1.
--- tools/perf/util/llvm-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/llvm-utils.c +3 -3
@@ -265,16 +265,16 @@ static const char *kinc_fetch_script ="#!/usr/bin/env sh\n" "if ! test -d \"$KBUILD_DIR\"\n" "then\n" -" exit -1\n" +" exit 1\n" "fi\n" "if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n" "then\n" -" exit -1\n" +" exit 1\n" "fi\n" "TMPDIR=`mktemp -d`\n" "if test -z \"$TMPDIR\"\n" "then\n" -" exit -1\n" +" exit 1\n" "fi\n" "cat << EOF > $TMPDIR/Makefile\n" "obj-y := dummy.o\n"
Greg Kroah-Hartman
maintainerPATCH 238/324 perf test shell: Prevent temporary editor files from being considered test scripts
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <[email protected]>
[ Upstream commit db8fec583f250557ddd6def1505a6c466c9747aa ]
Allows a perf shell test developer to concurrently edit and run their test scripts, avoiding perf test attempts to execute their editor temporary files, such as seen here:
$ sudo taskset -c 0 ./perf test -vvvvvvvv -F 63 63: 0VIM 8.0 : --- start --- sh: 1: ./tests/shell/.record+probe_libc_inet_pton.sh.swp: Permission denied ---- end ---- 0VIM 8.0: FAILED!
--- tools/perf/tests/builtin-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +1 -1
@@ -422,7 +422,7 @@ static const char *shell_test__descripti#define for_each_shell_test (dir, base, ent) \ while ((ent = readdir(dir)) != NULL) \ - if (!is_directory(base, ent)) + if (!is_directory(base, ent) && ent->d_name[0] != '.')static const char *shell_tests__dir (char *path,size_t size) {
Greg Kroah-Hartman
maintainerPATCH 240/324 perf script python: Fix dict reference counting
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janne Huttunen <[email protected]>
[ Upstream commit db0ba84c04ef2cf293aaada5ae97531127844d9d ]
The dictionaries are attached to the parameter tuple that steals the references and takes care of releasing them when appropriate. The code should not decrement the reference counts explicitly. E.g. if libpython has been built with reference debugging enabled, the superfluous DECREFs will trigger this error when running perf script:
Fatal Python error: Objects/tupleobject.c:238 object at 0x7f10f2041b40 has negative ref count -1 Aborted (core dumped)
If the reference debugging is not enabled, the superfluous DECREFs might cause the dict objects to be silently released while they are still in use. This may trigger various other assertions or just cause perf crashes and/or weird and unexpected data changes in the stored Python objects.
--- tools/perf/util/scripting-engines/trace-event-python.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/perf/util/scripting-engines/trace-event-python.c +2 -6
@@ -676,14 +676,11 @@ static void python_process_tracepoint(stif (_PyTuple_Resize (&t, n) ==-1 )Py_FatalError ("error resizing Python tuple" ); -if (!dict) { +if (!dict)call_object (handler, t, handler_name); - }else { +else call_object (handler, t, default_handler_name); -Py_DECREF (dict); - } -Py_XDECREF (all_entries_dict);Py_DECREF (t); }
@@ -1003,7 +1000,6 @@ static void python_process_general_eventcall_object (handler, t, handler_name); -Py_DECREF (dict);Py_DECREF (t); }
Greg Kroah-Hartman
maintainerPATCH 241/324 perf tools: Use python-config --includes rather than --cflags
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Cline <[email protected]>
[ Upstream commit 32aa928a7b817140c84987b726d5014911808fa4 ]
Builds started failing in Fedora on Python 3.7 with:
.gnu.debuglto_.debug_macro' referenced in section .gnu.debuglto_.debug_macro' of util/scripting-engines/trace-event-python.o: defined in discarded section
In Fedora, Python 3.7 added -flto to the list of --cflags and since it was only applied to util/scripting-engines/trace-event-python.c and scripts/python/Perf-Trace-Util/Context.c, linking failed.
It's not the first time the addition of flags has broken builds: commit c6707fdef7e2 ("perf tools: Fix up build in hardnened environments") appears to have fixed a similar problem. "python-config --includes" provides the proper -I flags and doesn't introduce additional CFLAGS.
--- tools/perf/Makefile.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/Makefile.config +1 -2
@@ -207,8 +207,7 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil - PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) - PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) + PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif
Greg Kroah-Hartman
maintainerPATCH 242/324 nfit: fix unchecked dereference in acpi_nfit_ctl
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit ee6581ceba7f8314b81b2f2a81f1cf3f67c679e2 ]
Incremental patch to fix the unchecked dereference in acpi_nfit_ctl. Reported by Dan Carpenter:
"acpi/nfit: fix cmd_rc for acpi_nfit_ctl to
always return a value" from Jun 28, 2018, leads to the following Smatch complaint:
drivers/acpi/nfit/core.c:578 acpi_nfit_ctl()
warn: variable dereferenced before check 'cmd_rc' (see line 411)
drivers/acpi/nfit/core.c
410
411 *cmd_rc = -EINVAL;
^^^^^^^^^^^^^^^^^^Patch adds unchecked dereference.
--- drivers/acpi/nfit/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/nfit/core.c +4 -2
@@ -408,7 +408,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descconst guid_t *guid;int rc, i; - *cmd_rc = -EINVAL ; +if (cmd_rc) + *cmd_rc = -EINVAL ; func = cmd;if (cmd ==ND_CMD_CALL ) { call_pkg = buf;
@@ -519,7 +520,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_desc* If we return an error (like elsewhere) then caller wouldn't * be able to rely upon data returned to make calculation. */ - *cmd_rc =0 ; +if (cmd_rc) + *cmd_rc =0 ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 243/324 RDMA/mlx5: Fix memory leak in mlx5_ib_create_srq() error path
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Heib <[email protected]>
[ Upstream commit d63c46734c545ad0488761059004a65c46efdde3 ]
Fix memory leak in the error path of mlx5_ib_create_srq() by making sure to free the allocated srq.
--- drivers/infiniband/hw/mlx5/srq.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +12 -6
@@ -266,18 +266,24 @@ struct ib_srq *mlx5_ib_create_srq(struct desc_size =sizeof (struct mlx5_wqe_srq_next_seg ) + srq->msrq.max_gs *sizeof (struct mlx5_wqe_data_seg ); -if (desc_size ==0 || srq->msrq.max_gs > desc_size) -return ERR_PTR (-EINVAL ); +if (desc_size ==0 || srq->msrq.max_gs > desc_size) { + err = -EINVAL ; + goto err_srq; + } desc_size =roundup_pow_of_two (desc_size); desc_size =max_t (size_t,32 , desc_size); -if (desc_size <sizeof (struct mlx5_wqe_srq_next_seg )) -return ERR_PTR (-EINVAL ); +if (desc_size <sizeof (struct mlx5_wqe_srq_next_seg )) { + err = -EINVAL ; + goto err_srq; + } srq->msrq.max_avail_gather = (desc_size -sizeof (struct mlx5_wqe_srq_next_seg )) /sizeof (struct mlx5_wqe_data_seg ); srq->msrq.wqe_shift =ilog2 (desc_size); buf_size = srq->msrq.max * desc_size; -if (buf_size < desc_size) -return ERR_PTR (-EINVAL ); +if (buf_size < desc_size) { + err = -EINVAL ; + goto err_srq; + } in.type = init_attr->srq_type;if (pd->uobject)
Greg Kroah-Hartman
maintainerPATCH 244/324 ARM: 8780/1: ftrace: Only set kernel memory back to read-only after boot
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (VMware)" <[email protected]>
[ Upstream commit b4c7e2bd2eb4764afe3af9409ff3b1b87116fa30 ]
Dynamic ftrace requires modifying the code segments that are usually set to read-only. To do this, a per arch function is called both before and after the ftrace modifications are performed. The "before" function will set kernel code text to read-write to allow for ftrace to make the modifications, and the "after" function will set the kernel code text back to "read-only" to keep the kernel code text protected.
The issue happens when dynamic ftrace is tested at boot up. The test is done before the kernel code text has been set to read-only. But the "before" and "after" calls are still performed. The "after" call will change the kernel code text to read-only prematurely, and other boot code that expects this code to be read-write will fail.
The solution is to add a variable that is set when the kernel code text is expected to be converted to read-only, and make the ftrace "before" and "after" calls do nothing if that variable is not yet set. This is similar to the x86 solution from commit 162396309745 ("ftrace, x86:
make kernel text writable only for conversions").
--- arch/arm/mm/init.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/mm/init.c +9 -0
@@ -736,20 +736,29 @@ static int __mark_rodata_ro(void *unusedreturn 0 ; } +static int kernel_set_to_readonly__read_mostly ; +void mark_rodata_ro (void ) { + kernel_set_to_readonly =1 ;stop_machine (__mark_rodata_ro,NULL ,NULL );debug_checkwx (); }void set_kernel_text_rw (void ) { +if (!kernel_set_to_readonly) +return ; +set_section_perms (ro_perms,ARRAY_SIZE (ro_perms), false, current->active_mm); }void set_kernel_text_ro (void ) { +if (!kernel_set_to_readonly) +return ; +set_section_perms (ro_perms,ARRAY_SIZE (ro_perms), true, current->active_mm); }
Greg Kroah-Hartman
maintainerPATCH 245/324 sfp: ensure we clean up properly on bus registration failure
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit f20a4c46b984331a509528fa2b84125c617ef98b ]
We fail to correctly clean up after a bus registration failure, which can lead to an incorrect assumption about the registration state of the upstream or sfp cage.
--- drivers/net/phy/sfp-bus.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/net/phy/sfp-bus.c +24 -7
@@ -436,6 +436,13 @@ void sfp_upstream_stop(struct sfp_bus *b }EXPORT_SYMBOL_GPL (sfp_upstream_stop); +static void sfp_upstream_clear (struct sfp_bus *bus) +{ + bus->upstream_ops =NULL ; + bus->upstream =NULL ; + bus->netdev =NULL ; +} +/** * sfp_register_upstream() - Register the neighbouring device * @fwnode: firmware node for the SFP bus
@@ -462,8 +469,11 @@ struct sfp_bus *sfp_register_upstream(st bus->upstream = upstream; bus->netdev = ndev; -if (bus->sfp) +if (bus->sfp) { ret =sfp_register_bus (bus); +if (ret) +sfp_upstream_clear (bus); + }rtnl_unlock (); }
@@ -488,8 +498,7 @@ void sfp_unregister_upstream(struct sfp_rtnl_lock ();if (bus->sfp)sfp_unregister_bus (bus); - bus->upstream =NULL ; - bus->netdev =NULL ; +sfp_upstream_clear (bus);rtnl_unlock ();sfp_bus_put (bus);
@@ -561,6 +570,13 @@ void sfp_module_remove(struct sfp_bus *b }EXPORT_SYMBOL_GPL (sfp_module_remove); +static void sfp_socket_clear (struct sfp_bus *bus) +{ + bus->sfp_dev =NULL ; + bus->sfp =NULL ; + bus->socket_ops =NULL ; +} +struct sfp_bus *sfp_register_socket (struct device *dev,struct sfp *sfp,const struct sfp_socket_ops *ops) {
@@ -573,8 +589,11 @@ struct sfp_bus *sfp_register_socket(stru bus->sfp = sfp; bus->socket_ops = ops; -if (bus->netdev) +if (bus->netdev) { ret =sfp_register_bus (bus); +if (ret) +sfp_socket_clear (bus); + }rtnl_unlock (); }
@@ -592,9 +611,7 @@ void sfp_unregister_socket(struct sfp_burtnl_lock ();if (bus->netdev)sfp_unregister_bus (bus); - bus->sfp_dev =NULL ; - bus->sfp =NULL ; - bus->socket_ops =NULL ; +sfp_socket_clear (bus);rtnl_unlock ();sfp_bus_put (bus);
Greg Kroah-Hartman
maintainerPATCH 246/324 sfp: fix module initialisation with netdev already up
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
[ Upstream commit 576cd32082351620a4e76b8babc4d5ae9b4bbb98 ]
It was been observed that with a particular order of initialisation, the netdev can be up, but the SFP module still has its TX_DISABLE signal asserted. This occurs when the network device brought up before the SFP kernel module has been inserted by userspace.
This occurs because sfp-bus layer does not hear about the change in network device state, and so assumes that it is still down. Set netdev->sfp when the upstream is registered to work around this problem.
--- drivers/net/phy/sfp-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/sfp-bus.c +2 -2
@@ -349,7 +349,6 @@ static int sfp_register_bus(struct sfp_b }if (bus->started) bus->socket_ops->start (bus->sfp); - bus->netdev->sfp_bus = bus; bus->registered = true;return 0 ; }
@@ -364,7 +363,6 @@ static void sfp_unregister_bus(struct sfif (bus->phydev && ops && ops->disconnect_phy) ops->disconnect_phy (bus->upstream); } - bus->netdev->sfp_bus =NULL ; bus->registered = false; }
@@ -440,6 +438,7 @@ static void sfp_upstream_clear(struct sf { bus->upstream_ops =NULL ; bus->upstream =NULL ; + bus->netdev->sfp_bus =NULL ; bus->netdev =NULL ; }
@@ -468,6 +467,7 @@ struct sfp_bus *sfp_register_upstream(st bus->upstream_ops = ops; bus->upstream = upstream; bus->netdev = ndev; + ndev->sfp_bus = bus;if (bus->sfp) { ret =sfp_register_bus (bus);
Greg Kroah-Hartman
maintainerPATCH 247/324 ARM: DRA7/OMAP5: Enable ACTLR[0] (Enable invalidates of BTB) for secondary cores
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nishanth Menon <[email protected]>
[ Upstream commit 2f8b5b21830aea95989a6e67d8a971297272a086 ]
Call secure services to enable ACTLR[0] (Enable invalidates of BTB with ICIALLU) when branch hardening is enabled for kernel.
On GP devices OMAP5/DRA7, there is no possibility to update secure side since "secure world" is ROM and there are no override mechanisms possible. On HS devices, appropriate PPA should do the workarounds as well.
However, the configuration is only done for secondary core, since it is expected that firmware/bootloader will have enabled the required configuration for the primary boot core (note: bootloaders typically will NOT enable secondary processors, since it has no need to do so).
--- arch/arm/mach-omap2/omap-smp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/arm/mach-omap2/omap-smp.c +41 -0
@@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(voistatic inline void omap5_erratum_workaround_801819 (void ) { }#endif +#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR +/* +* Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with +* ICIALLU) to activate the workaround for secondary Core. +* NOTE: it is assumed that the primary core's configuration is done +* by the boot loader (kernel will detect a misconfiguration and complain +* if this is not done). +* +* In General Purpose(GP) devices, ACR bit settings can only be done +* by ROM code in "secure world" using the smc call and there is no +* option to update the "firmware" on such devices. This also works for +* High security(HS) devices, as a backup option in case the +* "update" is not done in the "security firmware". +*/ +static void omap5_secondary_harden_predictor (void ) +{ +u32 acr, acr_mask; + + asmvolatile ("mrc p15, 0, %0, c1, c0, 1" :"=r" (acr)); + +/* +* ACTLR[0] (Enable invalidates of BTB with ICIALLU) +*/ + acr_mask =BIT (0 ); + +/* Do we already have it done.. if yes, skip expensive smc */ +if ((acr & acr_mask) == acr_mask) +return ; + + acr |= acr_mask; +omap_smc1 (OMAP5_DRA7_MON_SET_ACR_INDEX , acr); + +pr_debug ("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n" , + __func__,smp_processor_id ()); +} +#else +static inline void omap5_secondary_harden_predictor (void ) { } +#endif +static void omap4_secondary_init (unsigned int cpu) {/*
@@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigneset_cntfreq ();/* Configure ACR to disable streaming WA for 801819 */ omap5_erratum_workaround_801819 (); +/* Enable ACR to allow for ICUALLU workaround */ +omap5_secondary_harden_predictor (); }/*
Greg Kroah-Hartman
maintainerPATCH 248/324 ARM: dts: am3517.dtsi: Disable reference to OMAP3 OTG controller
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit 923847413f7316b5ced3491769b3fefa6c56a79a ]
The AM3517 has a different OTG controller location than the OMAP3, which is included from omap3.dtsi. This results in a hwmod error. Since the AM3517 has a different OTG controller address, this patch disabes one that is isn't available.
--- arch/arm/boot/dts/am3517.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/am3517.dtsi +5 -0
@@ -91,6 +91,11 @@ }; }; +/* Table Table 5-79 of the TRM shows 480ab000 is reserved */ +&usb_otg_hs { + status = "disabled"; +}; + &iva { status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 249/324 ixgbe: Be more careful when modifying MAC filters
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <[email protected]>
[ Upstream commit d14c780c11fbc10f66c43e7b64eefe87ca442bd3 ]
This change makes it so that we are much more explicit about the ordering of updates to the receive address register (RAR) table. Prior to this patch I believe we may have been updating the table while entries were still active, or possibly allowing for reordering of things since we weren't explicitly flushing writes to either the lower or upper portion of the register prior to accessing the other half.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +11 -1
@@ -1897,7 +1897,12 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hif (enable_addr !=0 ) rar_high |=IXGBE_RAH_AV ; +/* Record lower 32 bits of MAC address and then make +* sure that write is flushed to hardware before writing +* the upper 16 bits and setting the valid bit. +*/ IXGBE_WRITE_REG (hw,IXGBE_RAL (index), rar_low); +IXGBE_WRITE_FLUSH (hw);IXGBE_WRITE_REG (hw,IXGBE_RAH (index), rar_high);return 0 ;
@@ -1929,8 +1934,13 @@ s32 ixgbe_clear_rar_generic(struct ixgbe rar_high =IXGBE_READ_REG (hw,IXGBE_RAH (index)); rar_high &= ~(0x0000FFFF |IXGBE_RAH_AV ); -IXGBE_WRITE_REG (hw,IXGBE_RAL (index),0 ); +/* Clear the address valid bit and upper 16 bits of the address +* before clearing the lower bits. This way we aren't updating +* a live filter. +*/ IXGBE_WRITE_REG (hw,IXGBE_RAH (index), rar_high); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_RAL (index),0 );/* clear VMDq pool/queue selection for this RAR */ hw->mac.ops.clear_vmdq (hw, index,IXGBE_CLEAR_VMDQ_ALL );
Greg Kroah-Hartman
maintainerPATCH 250/324 amd/dc/dce100: On dce100, set clocks to 0 on suspend
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Francis <[email protected]>
[ Upstream commit 8d4235f71513cdccd9dc52b674323c3591552bc1 ]
[Why]
When a dce100 asic was suspended, the clocks were not set to 0. Upon resume, the new clock was compared to the existing clock, they were found to be the same, and so the clock was not set. This resulted in a pernicious blackscreen.
[How]
In atomic commit, check to see if there are any active pipes. If no, set clocks to 0
--- drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 19 +++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +16 -3
@@ -678,9 +678,22 @@ bool dce100_validate_bandwidth(struct dc *dc, struct dc_state *context) { -/* TODO implement when needed but for now hardcode max value*/ - context->bw.dce.dispclk_khz = 681000; - context->bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER ; + int i; +bool at_least_one_pipe = false; + +for (i =0 ; i < dc->res_pool->pipe_count; i++) { +if (context->res_ctx.pipe_ctx[i].stream) + at_least_one_pipe = true; + } + +if (at_least_one_pipe) { +/* TODO implement when needed but for now hardcode max value*/ + context->bw.dce.dispclk_khz =681000 ; + context->bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER ; + }else { + context->bw.dce.dispclk_khz =0 ; + context->bw.dce.yclk_khz =0 ; + }return true; }
Greg Kroah-Hartman
maintainerPATCH 251/324 ixgbe: Off by one in ixgbe_ipsec_tx()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c411104115e6821f26fc8f6de8b235ddf98de688 ]
The ipsec->tx_tbl[] has IXGBE_IPSEC_MAX_SA_COUNT elements so the > needs to be changed to >= so we don't read one element beyond the end of the array.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +1 -1
@@ -759,7 +759,7 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx } itd->sa_idx = xs->xso.offload_handle -IXGBE_IPSEC_BASE_TX_INDEX ; -if (unlikely (itd->sa_idx >IXGBE_IPSEC_MAX_SA_COUNT )) { +if (unlikely (itd->sa_idx >=IXGBE_IPSEC_MAX_SA_COUNT )) {netdev_err (tx_ring->netdev,"%s: bad sa_idx=%d handle=%lu\n" , __func__, itd->sa_idx, xs->xso.offload_handle);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 252/324 tools: build: Fixup host c flags
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laura Abbott <[email protected]>
[ Upstream commit 6fdbd824fd7a3876aac43d32fdf1f30b9ef72ce4 ]
Commit 0c3b7e42616f ("tools build: Add support for host programs format") introduced host_c_flags which referenced CHOSTFLAGS. The actual name of the variable is HOSTCFLAGS. Fix this up.
--- tools/build/Build.include | 2 +- tools/perf/pmu-events/Build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/build/Build.include +1 -1
@@ -98,4 +98,4 @@ cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$ ### ## HOSTCC C flags -host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj)) +host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(HOSTCFLAGS) -D"BUILD_STR(s)=\#s" $(HOSTCFLAGS_$(basetarget).o) $(HOSTCFLAGS_$(obj))
tools/perf/pmu-events/Build +1 -1
@@ -1,7 +1,7 @@ hostprogs := jevents jevents-y += json.o jsmn.o jevents.o -CHOSTFLAGS_jevents.o = -I$(srctree)/tools/include +HOSTCFLAGS_jevents.o = -I$(srctree)/tools/include pmu-events-y += pmu-events.o JDIR = pmu-events/arch/$(SRCARCH) JSON = $(shell [ -d $(JDIR) ] && \
Greg Kroah-Hartman
maintainerPATCH 253/324 tools: build: Use HOSTLDFLAGS with fixdep
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laura Abbott <[email protected]>
[ Upstream commit 8b247a92ebd0cda7dec49a6f771d9c4950f3d3ad ]
The final link of fixdep uses LDFLAGS but not the existing HOSTLDFLAGS. Fix this.
--- tools/build/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Makefile +1 -1
@@ -43,7 +43,7 @@ $(OUTPUT)fixdep-in.o: FORCE $(Q)$(MAKE) $(build)=fixdep $(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o - $(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o $@ $< + $(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $< FORCE:
Greg Kroah-Hartman
maintainerPATCH 255/324 sfc: avoid hang from nested use of the filter_sem
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bert Kenward <[email protected]>
[ Upstream commit 1c56c0994a533ce564843a0d17af7a3e6e68f269 ]
In some situations we may end up calling down_read while already holding the semaphore for write, thus hanging. This has been seen when setting the MAC address for the interface. The hung task log in this situation includes this stack:
down_read
efx_ef10_filter_insert efx_ef10_filter_insert_addr_list efx_ef10_filter_vlan_sync_rx_mode efx_ef10_filter_add_vlan
efx_ef10_filter_table_probe
efx_ef10_set_mac_address
efx_set_mac_address
dev_set_mac_address
In addition, lockdep rightly points out that nested calling of down_read is incorrect.
--- drivers/net/ethernet/sfc/ef10.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/net/ethernet/sfc/ef10.c +21 -9
@@ -4288,9 +4288,9 @@ static int efx_ef10_filter_pri(struct efreturn -EPROTONOSUPPORT ; } -static s32 efx_ef10_filter_insert (struct efx_nic *efx, -struct efx_filter_spec *spec, -bool replace_equal) +static s32 efx_ef10_filter_insert_locked (struct efx_nic *efx, +struct efx_filter_spec *spec, +bool replace_equal) {DECLARE_BITMAP (mc_rem_map,EFX_EF10_FILTER_SEARCH_LIMIT );struct efx_ef10_nic_data *nic_data = efx->nic_data;
@@ -4307,7 +4307,7 @@ static s32 efx_ef10_filter_insert(structbool is_mc_recip;s32 rc; -down_read (&efx->filter_sem); +WARN_ON (!rwsem_is_locked (&efx->filter_sem)); table = efx->filter_state;down_write (&table->lock);
@@ -4498,10 +4498,22 @@ out_unlock:if (rss_locked)mutex_unlock (&efx->rss_lock);up_write (&table->lock); -up_read (&efx->filter_sem);return rc; } +static s32 efx_ef10_filter_insert (struct efx_nic *efx, +struct efx_filter_spec *spec, +bool replace_equal) +{ +s32 ret; + +down_read (&efx->filter_sem); + ret =efx_ef10_filter_insert_locked (efx, spec, replace_equal); +up_read (&efx->filter_sem); + +return ret; +} +static void efx_ef10_filter_update_rx_scatter (struct efx_nic *efx) {/* no need to do anything here on EF10 */
@@ -5284,7 +5296,7 @@ static int efx_ef10_filter_insert_addr_lEFX_WARN_ON_PARANOID (ids[i] !=EFX_EF10_FILTER_ID_INVALID );efx_filter_init_rx (&spec,EFX_FILTER_PRI_AUTO , filter_flags,0 );efx_filter_set_eth_local (&spec, vlan->vid, addr_list[i].addr); - rc =efx_ef10_filter_insert (efx, &spec, true); + rc =efx_ef10_filter_insert_locked (efx, &spec, true);if (rc <0 ) {if (rollback) { netif_info(efx, drv, efx->net_dev,
@@ -5313,7 +5325,7 @@ static int efx_ef10_filter_insert_addr_lefx_filter_init_rx (&spec,EFX_FILTER_PRI_AUTO , filter_flags,0 );eth_broadcast_addr (baddr);efx_filter_set_eth_local (&spec, vlan->vid, baddr); - rc =efx_ef10_filter_insert (efx, &spec, true); + rc =efx_ef10_filter_insert_locked (efx, &spec, true);if (rc <0 ) {netif_warn (efx, drv, efx->net_dev,"Broadcast filter insert failed rc=%d\n" , rc);
@@ -5369,7 +5381,7 @@ static int efx_ef10_filter_insert_def(stif (vlan->vid !=EFX_FILTER_VID_UNSPEC )efx_filter_set_eth_local (&spec, vlan->vid,NULL ); - rc =efx_ef10_filter_insert (efx, &spec, true); + rc =efx_ef10_filter_insert_locked (efx, &spec, true);if (rc <0 ) {const char *um = multicast ?"Multicast" :"Unicast" ;const char *encap_name ="" ;
@@ -5429,7 +5441,7 @@ static int efx_ef10_filter_insert_def(st filter_flags, 0);eth_broadcast_addr (baddr);efx_filter_set_eth_local (&spec, vlan->vid, baddr); - rc =efx_ef10_filter_insert (efx, &spec, true); + rc =efx_ef10_filter_insert_locked (efx, &spec, true);if (rc <0 ) { netif_warn(efx, drv, efx->net_dev, "Broadcast filter insert failed rc=%d\n",
Greg Kroah-Hartman
maintainerPATCH 256/324 sfc: hold filter_sem consistently during reset
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bert Kenward <[email protected]>
[ Upstream commit 193f20033c54db0dc9563f722fbafbcd5fa0e80d ]
We should take and release the filter_sem consistently during the reset process, in the same manner as the mac_lock and reset_lock.
For lockdep consistency we also take the filter_sem for write around other calls to efx->type->init().
--- drivers/net/ethernet/sfc/efx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/sfc/efx.c +8 -9
@@ -1840,12 +1840,6 @@ static void efx_remove_filters(struct efup_write (&efx->filter_sem); } -static void efx_restore_filters (struct efx_nic *efx) -{ -down_read (&efx->filter_sem); - efx->type->filter_table_restore (efx); -up_read (&efx->filter_sem); -}/************************************************************************** *
@@ -2657,6 +2651,7 @@ void efx_reset_down(struct efx_nic *efx,efx_disable_interrupts (efx);mutex_lock (&efx->mac_lock); +down_write (&efx->filter_sem);mutex_lock (&efx->rss_lock);if (efx->port_initialized && method !=RESET_TYPE_INVISIBLE && method !=RESET_TYPE_DATAPATH )
@@ -2714,9 +2709,8 @@ int efx_reset_up(struct efx_nic *efx, enif (efx->type->rx_restore_rss_contexts) efx->type->rx_restore_rss_contexts (efx);mutex_unlock (&efx->rss_lock); -down_read (&efx->filter_sem); -efx_restore_filters (efx); -up_read (&efx->filter_sem); + efx->type->filter_table_restore (efx); +up_write (&efx->filter_sem);if (efx->type->sriov_reset) efx->type->sriov_reset (efx);
@@ -2733,6 +2727,7 @@ fail: efx->port_initialized = false;mutex_unlock (&efx->rss_lock); +up_write (&efx->filter_sem);mutex_unlock (&efx->mac_lock);return rc;
@@ -3440,7 +3435,9 @@ static int efx_pci_probe_main(struct efxefx_init_napi (efx); +down_write (&efx->filter_sem); rc = efx->type->init (efx); +up_write (&efx->filter_sem);if (rc) {netif_err (efx, probe, efx->net_dev,"failed to initialise NIC\n" );
@@ -3729,7 +3726,9 @@ static int efx_pm_resume(struct device * rc = efx->type->reset (efx,RESET_TYPE_ALL );if (rc)return rc; +down_write (&efx->filter_sem); rc = efx->type->init (efx); +up_write (&efx->filter_sem);if (rc)return rc; rc =efx_pm_thaw (dev);
Greg Kroah-Hartman
maintainerPATCH 257/324 packet: reset network header if packet shorter than ll reserved space
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit 993675a3100b16a4c80dfd70cbcde8ea7127b31d ]
If variable length link layer headers result in a packet shorter than dev->hard_header_len, reset the network header offset. Else skb->mac_len may exceed skb->len after skb_mac_reset_len.
packet_sendmsg_spkt already has similar logic.
--- net/packet/af_packet.c | 2 ++ 1 file changed, 2 insertions(+)
net/packet/af_packet.c +2 -0
@@ -2910,6 +2910,8 @@ static int packet_snd(struct socket *soc goto out_free; }else if (reserve) {skb_reserve (skb, -reserve); +if (len < reserve) +skb_reset_network_header (skb); }/* Returns -EFAULT on error */
Greg Kroah-Hartman
maintainerPATCH 258/324 rtc: fix alarm read and set offset
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
[ Upstream commit fd6792bb022e43faa0c4a45b6f25285e21206f9d ]
The offset needs to be added after reading the alarm value.
It also needs to be subtracted after the now < alarm test.
--- drivers/rtc/interface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/interface.c +5 -3
@@ -265,8 +265,10 @@ int __rtc_read_alarm(struct rtc_device *return err;/* full-function RTCs won't have such missing fields */ -if (rtc_valid_tm (&alarm->time) ==0 ) +if (rtc_valid_tm (&alarm->time) ==0 ) { +rtc_add_offset (rtc, &alarm->time);return 0 ; + }/* get the "after" timestamp, to detect wrapped fields */ err =rtc_read_time (rtc, &now);
@@ -409,7 +411,6 @@ static int __rtc_set_alarm(struct rtc_deif (err)return err; -rtc_subtract_offset (rtc, &alarm->time); scheduled =rtc_tm_to_time64 (&alarm->time);/* Make sure we're not setting alarms in the past */
@@ -426,6 +427,8 @@ static int __rtc_set_alarm(struct rtc_de* over right here, before we set the alarm. */ +rtc_subtract_offset (rtc, &alarm->time); +if (!rtc->ops) err = -ENODEV ;else if (!rtc->ops->set_alarm)
@@ -467,7 +470,6 @@ int rtc_set_alarm(struct rtc_device *rtcmutex_unlock (&rtc->ops_lock); -rtc_add_offset (rtc, &alarm->time);return err; }EXPORT_SYMBOL_GPL (rtc_set_alarm);
Greg Kroah-Hartman
maintainerPATCH 259/324 qlogic: check kstrtoul() for errors
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 5fc853cc01c68f84984ecc2d5fd777ecad78240f ]
We accidentally left out the error handling for kstrtoul().
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +2 -0
@@ -1128,6 +1128,8 @@ static ssize_t qlcnic_83xx_sysfs_flash_wstruct qlcnic_adapter *adapter =dev_get_drvdata (dev); ret =kstrtoul (buf,16 , &data); +if (ret) +return ret;switch (data) {case QLC_83XX_FLASH_SECTOR_ERASE_CMD :
Greg Kroah-Hartman
maintainerPATCH 260/324 tcp: remove DELAYED ACK events in DCTCP
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchung Cheng <[email protected]>
[ Upstream commit a69258f7aa2623e0930212f09c586fd06674ad79 ]
After fixing the way DCTCP tracking delayed ACKs, the delayed-ACK related callbacks are no longer needed
--- include/net/tcp.h | 2 -- net/ipv4/tcp_dctcp.c | 25 ------------------------- net/ipv4/tcp_output.c | 4 ---- 3 files changed, 31 deletions(-)
include/net/tcp.h +0 -2
@@ -907,8 +907,6 @@ enum tcp_ca_event {CA_EVENT_LOSS ,/* loss timeout */ CA_EVENT_ECN_NO_CE ,/* ECT set, but not CE marked */ CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */ -CA_EVENT_DELAYED_ACK ,/* Delayed ack is sent */ - CA_EVENT_NON_DELAYED_ACK, };/* Information about inbound ACK, passed to cong_ops->in_ack_event() */
net/ipv4/tcp_dctcp.c +0 -25
@@ -55,7 +55,6 @@ struct dctcp {u32 dctcp_alpha;u32 next_seq;u32 ce_state; -u32 delayed_ack_reserved;u32 loss_cwnd; };
@@ -96,7 +95,6 @@ static void dctcp_init(struct sock *sk) ca->dctcp_alpha =min (dctcp_alpha_on_init,DCTCP_MAX_ALPHA ); - ca->delayed_ack_reserved =0 ; ca->loss_cwnd =0 ; ca->ce_state =0 ;
@@ -230,25 +228,6 @@ static void dctcp_state(struct sock *sk, } } -static void dctcp_update_ack_reserved (struct sock *sk,enum tcp_ca_event ev) -{ -struct dctcp *ca =inet_csk_ca (sk); - -switch (ev) { -case CA_EVENT_DELAYED_ACK : -if (!ca->delayed_ack_reserved) - ca->delayed_ack_reserved =1 ; -break ; -case CA_EVENT_NON_DELAYED_ACK : -if (ca->delayed_ack_reserved) - ca->delayed_ack_reserved =0 ; -break ; -default : -/* Don't care for the rest. */ -break ; - } -} -static void dctcp_cwnd_event (struct sock *sk,enum tcp_ca_event ev) {switch (ev) {
@@ -258,10 +237,6 @@ static void dctcp_cwnd_event(struct sockcase CA_EVENT_ECN_NO_CE :dctcp_ce_state_1_to_0 (sk);break ; -case CA_EVENT_DELAYED_ACK : -case CA_EVENT_NON_DELAYED_ACK : -dctcp_update_ack_reserved (sk, ev); -break ;default :/* Don't care for the rest. */ break ;
net/ipv4/tcp_output.c +0 -4
@@ -3545,8 +3545,6 @@ void tcp_send_delayed_ack(struct sock *sint ato = icsk->icsk_ack.ato;unsigned long timeout; -tcp_ca_event (sk,CA_EVENT_DELAYED_ACK ); -if (ato >TCP_DELACK_MIN ) {const struct tcp_sock *tp =tcp_sk (sk);int max_ato =HZ /2 ;
@@ -3603,8 +3601,6 @@ void __tcp_send_ack(struct sock *sk, u32if (sk->sk_state ==TCP_CLOSE )return ; -tcp_ca_event (sk,CA_EVENT_NON_DELAYED_ACK ); -/* We are not putting this on the write queue, so * tcp_transmit_skb() will set the ownership to this * sock.
Greg Kroah-Hartman
maintainerPATCH 261/324 pinctrl: ingenic: Fix inverted direction for < JZ4770
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Cercueil <[email protected]>
[ Upstream commit 0084a786ca8c84b443f67c4a697b4f2552761650 ]
The .gpio_set_direction() callback was setting inverted direction for SoCs older than the JZ4770, this restores the correct behaviour.
--- drivers/pinctrl/pinctrl-ingenic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-ingenic.c +1 -1
@@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direcingenic_config_pin (jzpc, pin,JZ4770_GPIO_PAT1 , input); }else {ingenic_config_pin (jzpc, pin,JZ4740_GPIO_SELECT , false); -ingenic_config_pin (jzpc, pin,JZ4740_GPIO_DIR , input); +ingenic_config_pin (jzpc, pin,JZ4740_GPIO_DIR , !input);ingenic_config_pin (jzpc, pin,JZ4740_GPIO_FUNC , false); }
Greg Kroah-Hartman
maintainerPATCH 262/324 pinctrl: nsp: off by ones in nsp_pinmux_enable()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f90a21c898db58eaea14b8ad7e9af3b9e15e5f8a ]
The > comparisons should be >= or else we read beyond the end of the pinctrl->functions[] array.
--- drivers/pinctrl/bcm/pinctrl-nsp-mux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-nsp-mux.c +2 -2
@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pincconst struct nsp_pin_function *func;const struct nsp_pin_group *grp; -if (grp_select > pinctrl->num_groups || - func_select > pinctrl->num_functions) +if (grp_select >= pinctrl->num_groups || + func_select >= pinctrl->num_functions)return -EINVAL ; func = &pinctrl->functions[func_select];
Greg Kroah-Hartman
maintainerPATCH 263/324 pinctrl: nsp: Fix potential NULL dereference
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Yongjun <[email protected]>
[ Upstream commit c29e9da56bebb4c2c794e871b0dc0298bbf08142 ]
platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code.
This is detected by Coccinelle semantic patch.
@@
expression pdev, res, n, t, e, e1, e2;
@@
res = platform_get_resource(pdev, t, n);
+ if (!res)
+ return -EINVAL;
... when != res == NULL
e = devm_ioremap_nocache(e1, res->start, e2);
--- drivers/pinctrl/bcm/pinctrl-nsp-mux.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/bcm/pinctrl-nsp-mux.c +2 -0
@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platfreturn PTR_ERR (pinctrl->base0); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (!res) +return -EINVAL ; pinctrl->base1 =devm_ioremap_nocache (&pdev->dev, res->start,resource_size (res));if (!pinctrl->base1) {
Greg Kroah-Hartman
maintainerPATCH 264/324 net/9p/client.c: put refcount of trans_mod in error case in parse_opts()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: piaojun <[email protected]>
[ Upstream commit c290fba8c4ce6530cd941ea14db5a4ac2f77183f ]
In my testing, the second mount will fail after umounting successfully. The reason is that we put refcount of trans_mod in the correct case rather than the error case in parse_opts() at last. That will cause the refcount decrease to -1, and when we try to get trans_mod again in try_module_get(), we could only increase refcount to 0 which will cause failure as follows:
parse_opts
v9fs_get_trans_by_name
try_module_get : return NULL to caller which cause error
So we should put refcount of trans_mod in error case.
--- net/9p/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/9p/client.c +2 -1
@@ -228,7 +228,8 @@ static int parse_opts(char *opts, struct } free_and_return: -v9fs_put_trans (clnt->trans_mod); +if (ret) +v9fs_put_trans (clnt->trans_mod);kfree (tmp_options);return ret; }
Greg Kroah-Hartman
maintainerPATCH 265/324 kvm: nVMX: Restore exit qual for VM-entry failure due to MSR loading
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Mattson <[email protected]>
[ Upstream commit 0b88abdc3f964c28ec03bc69eb17cb6b3b034564 ]
This exit qualification was inadvertently dropped when the two VM-entry failure blocks were coalesced.
--- arch/x86/kvm/vmx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx.c +4 -5
@@ -11791,7 +11791,6 @@ static int enter_vmx_non_root_mode(struc {struct vcpu_vmx *vmx =to_vmx (vcpu);struct vmcs12 *vmcs12 =get_vmcs12 (vcpu); -u32 msr_entry_idx;u32 exit_qual;int r;
@@ -11813,10 +11812,10 @@ static int enter_vmx_non_root_mode(strucnested_get_vmcs12_pages (vcpu, vmcs12); r =EXIT_REASON_MSR_LOAD_FAIL ; - msr_entry_idx =nested_vmx_load_msr (vcpu, - vmcs12->vm_entry_msr_load_addr, - vmcs12->vm_entry_msr_load_count); -if (msr_entry_idx) + exit_qual =nested_vmx_load_msr (vcpu, + vmcs12->vm_entry_msr_load_addr, + vmcs12->vm_entry_msr_load_count); +if (exit_qual) goto fail;/*
Greg Kroah-Hartman
maintainerPATCH 266/324 sched/deadline: Fix switched_from_dl() warning
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juri Lelli <[email protected]>
[ Upstream commit e117cb52bdb4d376b711bee34af6434c9e314b3b ]
Mark noticed that syzkaller is able to reliably trigger the following warning:
dl_rq->running_bw > dl_rq->this_bw
WARNING: CPU: 1 PID: 153 at kernel/sched/deadline.c:124 switched_from_dl+0x454/0x608 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 153 Comm: syz-executor253 Not tainted 4.18.0-rc3+ #29 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x0/0x458 show_stack+0x20/0x30 dump_stack+0x180/0x250 panic+0x2dc/0x4ec __warn_printk+0x0/0x150 report_bug+0x228/0x2d8 bug_handler+0xa0/0x1a0 brk_handler+0x2f0/0x568 do_debug_exception+0x1bc/0x5d0 el1_dbg+0x18/0x78 switched_from_dl+0x454/0x608 __sched_setscheduler+0x8cc/0x2018 sys_sched_setattr+0x340/0x758 el0_svc_naked+0x30/0x34
syzkaller reproducer runs a bunch of threads that constantly switch between DEADLINE and NORMAL classes while interacting through futexes.
The splat above is caused by the fact that if a DEADLINE task is setattr back to NORMAL while in non_contending state (blocked on a futex - inactive timer armed), its contribution to running_bw is not removed before sub_rq_bw() gets called (!task_on_rq_queued() branch) and the latter sees running_bw > this_bw.
Fix it by removing a task contribution from running_bw if the task is not queued and in non_contending state while switched to a different class.
--- kernel/sched/deadline.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +10 -1
@@ -2296,8 +2296,17 @@ static void switched_from_dl(struct rq *if (task_on_rq_queued (p) && p->dl.dl_runtime)task_non_contending (p); -if (!task_on_rq_queued (p)) +if (!task_on_rq_queued (p)) { +/* +* Inactive timer is armed. However, p is leaving DEADLINE and +* might migrate away from this rq while continuing to run on +* some other class. We need to remove its contribution from +* this rq running_bw now, or sub_rq_bw (below) will complain. +*/ +if (p->dl.dl_non_contending) +sub_running_bw (&p->dl, &rq->dl);sub_rq_bw (&p->dl, &rq->dl); + }/* * We cannot use inactive_task_timer() to invoke sub_running_bw()
Greg Kroah-Hartman
maintainerPATCH 267/324 drm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 7f073d011f93e92d4d225526b9ab6b8b0bbd6613 ]
The bo array has req->nr_buffers elements so the > should be >= so we don't read beyond the end of the array.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +2 -2
@@ -617,7 +617,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nstruct nouveau_bo *nvbo;uint32_t data; -if (unlikely (r->bo_index > req->nr_buffers)) { +if (unlikely (r->bo_index >= req->nr_buffers)) {NV_PRINTK (err, cli,"reloc bo index invalid\n" ); ret = -EINVAL ;break ;
@@ -627,7 +627,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nif (b->presumed.valid)continue ; -if (unlikely (r->reloc_bo_index > req->nr_buffers)) { +if (unlikely (r->reloc_bo_index >= req->nr_buffers)) {NV_PRINTK (err, cli,"reloc container bo index invalid\n" ); ret = -EINVAL ;break ;
Greg Kroah-Hartman
maintainerPATCH 268/324 of: overlay: update phandle cache on overlay apply and remove
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Rowand <[email protected]>
[ Upstream commit b9952b5218added5577e4a3443969bc20884cea9 ]
A comment in the review of the patch adding the phandle cache said that the cache would have to be updated when modules are applied and removed. This patch implements the cache updates.
--- drivers/of/base.c | 6 +++--- drivers/of/of_private.h | 2 ++ drivers/of/overlay.c | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-)
drivers/of/base.c +3 -3
@@ -102,7 +102,7 @@ static u32 phandle_cache_mask;* - the phandle lookup overhead reduction provided by the cache * will likely be less */ -static void of_populate_phandle_cache (void ) +void of_populate_phandle_cache (void ) {unsigned long flags;u32 cache_entries;
@@ -134,8 +134,7 @@ out:raw_spin_unlock_irqrestore (&devtree_lock, flags); } -#ifndef CONFIG_MODULES -static int __init of_free_phandle_cache (void ) +int of_free_phandle_cache (void ) {unsigned long flags;
@@ -148,6 +147,7 @@ static int __init of_free_phandle_cache(return 0 ; } +#if !defined(CONFIG_MODULES )late_initcall_sync (of_free_phandle_cache);#endif
drivers/of/of_private.h +2 -0
@@ -79,6 +79,8 @@ int of_resolve_phandles(struct device_no#if defined(CONFIG_OF_OVERLAY )void of_overlay_mutex_lock (void );void of_overlay_mutex_unlock (void ); +int of_free_phandle_cache (void ); +void of_populate_phandle_cache (void );#else static inline void of_overlay_mutex_lock (void ) {};static inline void of_overlay_mutex_unlock (void ) {};
drivers/of/overlay.c +11 -0
@@ -804,6 +804,8 @@ static int of_overlay_apply(const void * goto err_free_overlay_changeset; } +of_populate_phandle_cache (); + ret =__of_changeset_apply_notify (&ovcs->cset);if (ret)pr_err ("overlay changeset entry notify error %d\n" , ret);
@@ -1046,8 +1048,17 @@ int of_overlay_remove(int *ovcs_id)list_del (&ovcs->ovcs_list); +/* +* Disable phandle cache. Avoids race condition that would arise +* from removing cache entry when the associated node is deleted. +*/ +of_free_phandle_cache (); + ret_apply =0 ; ret =__of_changeset_revert_entries (&ovcs->cset, &ret_apply); + +of_populate_phandle_cache (); +if (ret) {if (ret_apply) devicetree_state_flags |=DTSF_REVERT_FAIL ;
Greg Kroah-Hartman
maintainerPATCH 269/324 ibmvnic: Revise RX/TX queue error messages
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Falcon <[email protected]>
[ Upstream commit 2d14d3795294d42aacc278948984a480569bcc23 ]
During a device failover, there may be latency between the loss of the current backing device and a notification from firmware that a failover has occurred. This latency can result in a large amount of error printouts as firmware returns outgoing traffic with a generic error code. These are not necessarily errors in this case as the firmware is busy swapping in a new backing adapter and is not ready to send packets yet. This patch reclassifies those error codes as warnings with an explanation that a failover may be pending. All other return codes will be considered errors.
--- drivers/net/ethernet/ibm/ibmvnic.c | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +27 -12
@@ -319,7 +319,8 @@ static void replenish_rx_pool(struct ibmreturn ; failure: -dev_info (dev,"replenish pools failure\n" ); +if (lpar_rc !=H_PARAMETER && lpar_rc !=H_CLOSED ) +dev_err_ratelimited (dev,"rx: replenish packet buffer failed\n" ); pool->free_map[pool->next_free] = index; pool->rx_buff[index].skb =NULL ;
@@ -1594,7 +1595,8 @@ static int ibmvnic_xmit(struct sk_buff * &tx_crq); }if (lpar_rc !=H_SUCCESS ) { -dev_err (dev,"tx failed with code %ld\n" , lpar_rc); +if (lpar_rc !=H_CLOSED && lpar_rc !=H_PARAMETER ) +dev_err_ratelimited (dev,"tx: send failed\n" );dev_kfree_skb_any (skb); tx_buff->skb =NULL ;
@@ -3085,6 +3087,25 @@ static union ibmvnic_crq *ibmvnic_next_creturn crq; } +static void print_subcrq_error (struct device *dev,int rc,const char *func) +{ +switch (rc) { +case H_PARAMETER : +dev_warn_ratelimited (dev, +"%s failed: Send request is malformed or adapter failover pending. (rc=%d)\n" , + func, rc); +break ; +case H_CLOSED : +dev_warn_ratelimited (dev, +"%s failed: Backing queue closed. Adapter is down or failover pending. (rc=%d)\n" , + func, rc); +break ; +default : +dev_err_ratelimited (dev,"%s failed: (rc=%d)\n" , func, rc); +break ; + } +} +static int send_subcrq (struct ibmvnic_adapter *adapter,u64 remote_handle,union sub_crq *sub_crq) {
@@ -3111,11 +3132,8 @@ static int send_subcrq(struct ibmvnic_adcpu_to_be64 (u64_crq[2 ]), cpu_to_be64(u64_crq[3])); -if (rc) { -if (rc ==H_CLOSED ) -dev_warn (dev,"CRQ Queue closed\n" ); -dev_err (dev,"Send error (rc=%d)\n" , rc); - } +if (rc) +print_subcrq_error (dev, rc, __func__);return rc; }
@@ -3133,11 +3151,8 @@ static int send_subcrq_indirect(struct icpu_to_be64 (remote_handle), ioba, num_entries); -if (rc) { -if (rc ==H_CLOSED ) -dev_warn (dev,"CRQ Queue closed\n" ); -dev_err (dev,"Send (indirect) error (rc=%d)\n" , rc); - } +if (rc) +print_subcrq_error (dev, rc, __func__);return rc; }
Greg Kroah-Hartman
maintainerPATCH 270/324 hv/netvsc: fix handling of fallback to single queue mode
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit 916c5e1413be058d1c1f6e502db350df890730ce ]
The netvsc device may need to fallback to running in single queue mode if host side only wants to support single queue.
Recent change for handling mtu broke this in setup logic.
--- drivers/net/hyperv/rndis_filter.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/hyperv/rndis_filter.c +1 -0
@@ -1307,6 +1307,7 @@ out:/* setting up multiple channels failed */ net_device->max_chn =1 ; net_device->num_chn =1 ; +return 0 ; err_dev_remv:rndis_filter_device_remove (dev, net_device);
Greg Kroah-Hartman
maintainerPATCH 271/324 net/ethernet/freescale/fman: fix cross-build error
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit c133459765fae249ba482f62e12f987aec4376f0 ]
CC [M] drivers/net/ethernet/freescale/fman/fman.o
In file included from ../drivers/net/ethernet/freescale/fman/fman.c:35:../include/linux/fsl/guts.h: In function 'guts_set_dmacr':../include/linux/fsl/guts.h:165:2: error: implicit declaration of function 'clrsetbits_be32' [-Werror=implicit-function-declaration]
clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
^~~~~~~~~~~~~~~
--- include/linux/fsl/guts.h | 1 + 1 file changed, 1 insertion(+)
include/linux/fsl/guts.h +1 -0
@@ -16,6 +16,7 @@#define __FSL_GUTS_H__#include <linux/types.h> +#include <linux/io.h> /** * Global Utility Registers.
Greg Kroah-Hartman
maintainerPATCH 272/324 ibmvnic: Fix error recovery on login failure
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Allen <[email protected]>
[ Upstream commit 3578a7ecb69920efc3885dbd610e98c00dbdf5db ]
Testing has uncovered a failure case that is not handled properly. In the event that a login fails and we are not able to recover on the spot, we return 0 from do_reset, preventing any error recovery code from being triggered. Additionally, the state is set to "probed" meaning that when we are able to trigger the error recovery, the driver always comes up in the probed state. To handle the case properly, we need to return a failure code here and set the adapter state to the state that we entered the reset in indicating the state that we would like to come out of the recovery reset in.
--- drivers/net/ethernet/ibm/ibmvnic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +2 -2
@@ -1801,8 +1801,8 @@ static int do_reset(struct ibmvnic_adapt rc =ibmvnic_login (netdev);if (rc) { - adapter->state =VNIC_PROBED ; -return 0 ; + adapter->state = reset_state; +return rc; } if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM ||
Greg Kroah-Hartman
maintainerPATCH 273/324 ARM: dts: omap4-droid4: fix dts w.r.t. pwm
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Machek <[email protected]>
[ Upstream commit d3f6daede246038cf2ea38b78d732f9dd8feb1d6 ]
pwm node should not be under gpio6 node in the device tree.
This fixes detection of the pwm on Droid 4.
--- arch/arm/boot/dts/omap4-droid4-xt894.dts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/arm/boot/dts/omap4-droid4-xt894.dts +3 -6
@@ -159,13 +159,7 @@ dais = <&mcbsp2_port>, <&mcbsp3_port>; }; -}; - -&dss { - status = "okay"; -}; -&gpio6 { pwm8: dmtimer-pwm-8 { pinctrl-names = "default"; pinctrl-0 = <&vibrator_direction_pin>;
@@ -192,7 +186,10 @@ pwm-names = "enable", "direction"; direction-duty-cycle-ns = <10000000>; }; +}; +&dss { + status = "okay"; }; &dsi1 {
Greg Kroah-Hartman
maintainerPATCH 274/324 btrfs: scrub: Dont use inode page cache in scrub_handle_errored_block()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 665d4953cde6d9e75c62a07ec8f4f8fd7d396ade ]
In commit ac0b4145d662 ("btrfs: scrub: Don't use inode pages for device replace") we removed the branch of copy_nocow_pages() to avoid corruption for compressed nodatasum extents.
However above commit only solves the problem in scrub_extent(), if during scrub_pages() we failed to read some pages, sctx->no_io_error_seen will be non-zero and we go to fixup function scrub_handle_errored_block().
In scrub_handle_errored_block(), for sctx without csum (no matter if we're doing replace or scrub) we go to scrub_fixup_nodatasum() routine, which does the similar thing with copy_nocow_pages(), but does it without the extra check in copy_nocow_pages() routine.
So for test cases like btrfs/100, where we emulate read errors during replace/scrub, we could corrupt compressed extent data again.
This patch will fix it just by avoiding any "optimization" for nodatasum, just falls back to the normal fixup routine by try read from any good copy.
This also solves WARN_ON() or dead lock caused by lame backref iteration in scrub_fixup_nodatasum() routine.
The deadlock or WARN_ON() won't be triggered before commit ac0b4145d662 ("btrfs: scrub: Don't use inode pages for device replace") since copy_nocow_pages() have better locking and extra check for data extent, and it's already doing the fixup work by try to read data from any good copy, so it won't go scrub_fixup_nodatasum() anyway.
This patch disables the faulty code and will be removed completely in a followup patch.
--- fs/btrfs/scrub.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
fs/btrfs/scrub.c +9 -8
@@ -1151,11 +1151,6 @@ static int scrub_handle_errored_block(streturn ret; } -if (sctx->is_dev_replace && !is_metadata && !have_csum) { - sblocks_for_recheck =NULL ; - goto nodatasum_case; - } -/* * read all mirrors one after the other. This includes to * re-read the extent or metadata block that failed (that was
@@ -1268,13 +1263,19 @@ static int scrub_handle_errored_block(st goto out; } -if (!is_metadata && !have_csum) { +/* +* NOTE: Even for nodatasum case, it's still possible that it's a +* compressed data extent, thus scrub_fixup_nodatasum(), which write +* inode page cache onto disk, could cause serious data corruption. +* +* So here we could only read from disk, and hope our recovery could +* reach disk before the newer write. +*/ +if (0 && !is_metadata && !have_csum) {struct scrub_fixup_nodatasum *fixup_nodatasum;WARN_ON (sctx->is_dev_replace); -nodatasum_case: -/* * !is_metadata and !have_csum, this means that the data * might not be COWed, that it might be modified
Greg Kroah-Hartman
maintainerPATCH 275/324 nvme: ensure forward progress during Admin passthru
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Bauer <[email protected]>
[ Upstream commit cf39a6bc342b980f10f344d88035829638a89a48 ]
If the controller supports effects and goes down during the passthru admin command we will deadlock during namespace revalidation.
[ 363.488275] INFO: task kworker/u16:5:231 blocked for more than 120 seconds. [ 363.488290] Not tainted 4.17.0+ #2 [ 363.488296] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 363.488303] kworker/u16:5 D 0 231 2 0x80000000 [ 363.488331] Workqueue: nvme-reset-wq nvme_reset_work [nvme] [ 363.488338] Call Trace: [ 363.488385] schedule+0x75/0x190 [ 363.488396] rwsem_down_read_failed+0x1c3/0x2f0 [ 363.488481] call_rwsem_down_read_failed+0x14/0x30 [ 363.488504] down_read+0x1d/0x80 [ 363.488523] nvme_stop_queues+0x1e/0xa0 [nvme_core] [ 363.488536] nvme_dev_disable+0xae4/0x1620 [nvme] [ 363.488614] nvme_reset_work+0xd1e/0x49d9 [nvme] [ 363.488911] process_one_work+0x81a/0x1400 [ 363.488934] worker_thread+0x87/0xe80 [ 363.488955] kthread+0x2db/0x390 [ 363.488977] ret_from_fork+0x35/0x40
--- drivers/nvme/host/core.c | 50 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-)
drivers/nvme/host/core.c +26 -24
@@ -100,6 +100,22 @@ static struct class *nvme_subsys_class;static void nvme_ns_remove (struct nvme_ns *ns);static int nvme_revalidate_disk (struct gendisk *disk);static void nvme_put_subsystem (struct nvme_subsystem *subsys); +static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl, +unsigned nsid); + +static void nvme_set_queue_dying (struct nvme_ns *ns) +{ +/* +* Revalidating a dead namespace sets capacity to 0. This will end +* buffered writers dirtying pages that can't be synced. +*/ +if (!ns->disk ||test_and_set_bit (NVME_NS_DEAD , &ns->flags)) +return ; +revalidate_disk (ns->disk); +blk_set_queue_dying (ns->queue); +/* Forcibly unquiesce queues to avoid blocking dispatch */ +blk_mq_unquiesce_queue (ns->queue); +}int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {
@@ -1130,19 +1146,15 @@ static u32 nvme_passthru_start(struct nvstatic void nvme_update_formats (struct nvme_ctrl *ctrl) { -struct nvme_ns *ns, *next; -LIST_HEAD (rm_list); +struct nvme_ns *ns; -down_write (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { -if (ns->disk &&nvme_revalidate_disk (ns->disk)) { -list_move_tail (&ns->list, &rm_list); - } - } -up_write (&ctrl->namespaces_rwsem); +down_read (&ctrl->namespaces_rwsem); +list_for_each_entry (ns, &ctrl->namespaces, list) +if (ns->disk &&nvme_revalidate_disk (ns->disk)) +nvme_set_queue_dying (ns); +up_read (&ctrl->namespaces_rwsem); -list_for_each_entry_safe (ns, next, &rm_list, list) -nvme_ns_remove (ns); +nvme_remove_invalid_namespaces (ctrl,NVME_NSID_ALL ); }static void nvme_passthru_end (struct nvme_ctrl *ctrl,u32 effects)
@@ -3110,7 +3122,7 @@ static void nvme_remove_invalid_namespacdown_write (&ctrl->namespaces_rwsem);list_for_each_entry_safe (ns, next, &ctrl->namespaces, list) { -if (ns->head->ns_id > nsid) +if (ns->head->ns_id > nsid ||test_bit (NVME_NS_DEAD , &ns->flags))list_move_tail (&ns->list, &rm_list); }up_write (&ctrl->namespaces_rwsem);
@@ -3488,19 +3500,9 @@ void nvme_kill_queues(struct nvme_ctrl *if (ctrl->admin_q)blk_mq_unquiesce_queue (ctrl->admin_q); -list_for_each_entry (ns, &ctrl->namespaces, list) { -/* -* Revalidating a dead namespace sets capacity to 0. This will -* end buffered writers dirtying pages that can't be synced. -*/ -if (!ns->disk ||test_and_set_bit (NVME_NS_DEAD , &ns->flags)) -continue ; -revalidate_disk (ns->disk); -blk_set_queue_dying (ns->queue); +list_for_each_entry (ns, &ctrl->namespaces, list) +nvme_set_queue_dying (ns); -/* Forcibly unquiesce queues to avoid blocking dispatch */ -blk_mq_unquiesce_queue (ns->queue); - }up_read (&ctrl->namespaces_rwsem); }EXPORT_SYMBOL_GPL (nvme_kill_queues);
Greg Kroah-Hartman
maintainerPATCH 276/324 octeon_mgmt: Fix MIX registers configuration on MTU setup
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit 4aac0b43474d18f6160302a3caa147d77fa3baa1 ]
octeon_mgmt driver doesn't drop RX frames that are 1-4 bytes bigger than MTU set for the corresponding interface. The problem is in the AGL_GMX_RX0/1_FRM_MAX register setting, which should not account for VLAN tagging.
According to Octeon HW manual:
"For tagged frames, MAX increases by four bytes for each VLAN found up to a maximum of two VLANs, or MAX + 8 bytes."
OCTEON_FRAME_HEADER_LEN "define" is fine for ring buffer management, but should not be used for AGL_GMX_RX0/1_FRM_MAX.
The problem could be easily reproduced using "ping" command. If affected system has default MTU 1500, other host (having MTU >= 1504) can successfully "ping" the affected system with payload size 1473-1476, resulting in IP packets of size 1501-1504 accepted by the mgmt driver. Fixed system still accepts IP packets of 1500 bytes even with VLAN tagging, because the limits are lifted in HW as expected, for every VLAN tag.
--- drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c +11 -3
@@ -643,13 +643,21 @@ static int octeon_mgmt_set_mac_address(sstatic int octeon_mgmt_change_mtu (struct net_device *netdev,int new_mtu) {struct octeon_mgmt *p =netdev_priv (netdev); -int size_without_fcs = new_mtu +OCTEON_MGMT_RX_HEADROOM ; +int max_packet = new_mtu +ETH_HLEN +ETH_FCS_LEN ; netdev->mtu = new_mtu; -cvmx_write_csr (p->agl +AGL_GMX_RX_FRM_MAX , size_without_fcs); +/* HW lifts the limit if the frame is VLAN tagged +* (+4 bytes per each tag, up to two tags) +*/ +cvmx_write_csr (p->agl +AGL_GMX_RX_FRM_MAX , max_packet); +/* Set the hardware to truncate packets larger than the MTU. The jabber +* register must be set to a multiple of 8 bytes, so round up. JABBER is +* an unconditional limit, so we need to account for two possible VLAN +* tags. +*/ cvmx_write_csr (p->agl +AGL_GMX_RX_JABBER , - (size_without_fcs +7 ) &0xfff8 ); + (max_packet +7 +VLAN_HLEN *2 ) &0xfff8 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 277/324 net: usb: rtl8150: demote allmulti message to dev_dbg()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lechner <[email protected]>
[ Upstream commit 3a9b0455062ffb9d2f6cd4473a76e3456f318c9f ]
This driver can spam the kernel log with multiple messages of:
net eth0: eth0: allmulti set
Usually 4 or 8 at a time (probably because of using ConnMan).
This message doesn't seem useful, so let's demote it from dev_info() to dev_dbg().
--- drivers/net/usb/rtl8150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/rtl8150.c +1 -1
@@ -681,7 +681,7 @@ static void rtl8150_set_multicast(struct (netdev->flags & IFF_ALLMULTI)) { rx_creg &= 0xfffe; rx_creg |= 0x0002; - dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); + dev_dbg(&netdev->dev, "%s: allmulti set\n", netdev->name); } else {/* ~RX_MULTICAST, ~RX_PROMISCUOUS */ rx_creg &=0x00fc ;
Greg Kroah-Hartman
maintainerPATCH 278/324 kvmclock: fix TSC calibration for nested guests
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Hao <[email protected]>
[ Upstream commit e10f7805032365cc11c739a97f226ebb48aee042 ]
Inside a nested guest, access to hardware can be slow enough that tsc_read_refs always return ULLONG_MAX, causing tsc_refine_calibration_work to be called periodically and the nested guest to spend a lot of time reading the ACPI timer.
However, if the TSC frequency is available from the pvclock page, we can just set X86_FEATURE_TSC_KNOWN_FREQ and avoid the recalibration. 'refine' operation.
--- arch/x86/kernel/kvmclock.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/kvmclock.c +1 -0
@@ -138,6 +138,7 @@ static unsigned long kvm_get_tsc_khz(voi src = &hv_clock[cpu].pvti; tsc_khz =pvclock_tsc_khz (src);put_cpu (); +setup_force_cpu_cap (X86_FEATURE_TSC_KNOWN_FREQ );return tsc_khz; }
Greg Kroah-Hartman
maintainerPATCH 279/324 net/smc: reset recv timeout after clc handshake
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karsten Graul <[email protected]>
[ Upstream commit f6bdc42f021194ec095914b92c7a8b1a09789e6d ]
During clc handshake the receive timeout is set to CLC_WAIT_TIME. Remember and reset the original timeout value after the receive calls, and remove a duplicate assignment of CLC_WAIT_TIME.
--- net/smc/smc_clc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/smc/smc_clc.c +2 -1
@@ -250,6 +250,7 @@ out:int smc_clc_wait_msg (struct smc_sock *smc,void *buf,int buflen,u8 expected_type) { +long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo;struct sock *clc_sk = smc->clcsock->sk;struct smc_clc_msg_hdr *clcm = buf;struct msghdr msg = {NULL ,0 };
@@ -306,7 +307,6 @@ int smc_clc_wait_msg(struct smc_sock *smmemset (&msg,0 ,sizeof (struct msghdr ));iov_iter_kvec (&msg.msg_iter,READ |ITER_KVEC , &vec,1 , datlen); krflags =MSG_WAITALL ; - smc->clcsock->sk->sk_rcvtimeo =CLC_WAIT_TIME ; len =sock_recvmsg (smc->clcsock, &msg, krflags);if (len < datlen || !smc_clc_msg_hdr_valid (clcm)) { smc->sk.sk_err =EPROTO ;
@@ -322,6 +322,7 @@ int smc_clc_wait_msg(struct smc_sock *sm } out: + smc->clcsock->sk->sk_rcvtimeo = rcvtimeo;return reason_code; }
Greg Kroah-Hartman
maintainerPATCH 280/324 PCI: OF: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit a5fb9fb023a1435f2b42bccd7f547560f3a21dc3 ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
Introduce the devm_pci_remap_iospace() managed API and replace the pci_remap_iospace() call with it to fix the bug.
--- drivers/pci/of.c | 2 +- drivers/pci/pci.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-)
drivers/pci/of.c +1 -1
@@ -617,7 +617,7 @@ int pci_parse_request_of_pci_ranges(struswitch (resource_type (res)) {case IORESOURCE_IO : - err =pci_remap_iospace (res, iobase); + err =devm_pci_remap_iospace (dev, res, iobase);if (err) {dev_warn (dev,"error %d: failed to map resource %pR\n" , err, res);
drivers/pci/pci.c +38 -0
@@ -3573,6 +3573,44 @@ void pci_unmap_iospace(struct resource * }EXPORT_SYMBOL (pci_unmap_iospace); +static void devm_pci_unmap_iospace (struct device *dev,void *ptr) +{ +struct resource **res = ptr; + +pci_unmap_iospace (*res); +} + +/** +* devm_pci_remap_iospace - Managed pci_remap_iospace() +* @dev: Generic device to remap IO address for +* @res: Resource describing the I/O space +* @phys_addr: physical address of range to be mapped +* +* Managed pci_remap_iospace(). Map is automatically unmapped on driver +* detach. +*/ +int devm_pci_remap_iospace (struct device *dev,const struct resource *res, +phys_addr_t phys_addr) +{ +const struct resource **ptr; +int error; + + ptr =devres_alloc (devm_pci_unmap_iospace,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return -ENOMEM ; + + error =pci_remap_iospace (res, phys_addr); +if (error) { +devres_free (ptr); + }else { + *ptr = res; +devres_add (dev, ptr); + } + +return error; +} +EXPORT_SYMBOL (devm_pci_remap_iospace); +/** * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() * @dev: Generic device to remap IO address for
include/linux/pci.h +2 -0
@@ -1236,6 +1236,8 @@ int pci_register_io_range(struct fwnode_unsigned long pci_address_to_pio (phys_addr_t addr);phys_addr_t pci_pio_to_address (unsigned long pio);int pci_remap_iospace (const struct resource *res,phys_addr_t phys_addr); +int devm_pci_remap_iospace (struct device *dev,const struct resource *res, +phys_addr_t phys_addr);void pci_unmap_iospace (struct resource *res); void __iomem *devm_pci_remap_cfgspace(struct device *dev, resource_size_t offset,
Greg Kroah-Hartman
maintainerPATCH 281/324 PCI: xgene: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 925652d03589084850023d8924b376b7ee3c1b1b ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The X-Gene PCI controller driver has the same issue. Replace pci_remap_iospace() with the devm_ managed version so that the pages get unmapped automagically on any probe failure.
--- drivers/pci/host/pci-xgene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-xgene.c +1 -1
@@ -421,7 +421,7 @@ static int xgene_pcie_map_ranges(structcase IORESOURCE_IO :xgene_pcie_setup_ob_reg (port, res,OMR3BARL , io_base, res->start - window->offset); - ret =pci_remap_iospace (res, io_base); + ret =devm_pci_remap_iospace (dev, res, io_base);if (ret <0 )return ret;break ;
Greg Kroah-Hartman
maintainerPATCH 282/324 PCI: versatile: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 0018b265adf7e251f90d3ca1c7c0e32e2a0ad262 ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The Versatile PCI controller driver has the same issue. Replace pci_remap_iospace() with the devm_ managed version to fix the bug.
--- drivers/pci/host/pci-versatile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-versatile.c +1 -1
@@ -81,7 +81,7 @@ static int versatile_pci_parse_request_oswitch (resource_type (res)) {case IORESOURCE_IO : - err =pci_remap_iospace (res, iobase); + err =devm_pci_remap_iospace (dev, res, iobase);if (err) {dev_warn (dev,"error %d: failed to map resource %pR\n" , err, res);
Greg Kroah-Hartman
maintainerPATCH 283/324 PCI: designware: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit fd07f5e19c6fcdfa318944764248cf44eb06e532 ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver is left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The DesignWare PCIe controller driver has the same issue.
Replace devm_pci_remap_iospace() with a devm_ managed version to fix the bug.
--- drivers/pci/dwc/pcie-designware-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/dwc/pcie-designware-host.c +2 -1
@@ -355,7 +355,8 @@ int dw_pcie_host_init(struct pcie_port *resource_list_for_each_entry_safe (win, tmp, &bridge->windows) {switch (resource_type (win->res)) {case IORESOURCE_IO : - ret =pci_remap_iospace (win->res, pp->io_base); + ret =devm_pci_remap_iospace (dev, win->res, + pp->io_base);if (ret) {dev_warn (dev,"error %d: failed to map resource %pR\n" , ret, win->res);
Greg Kroah-Hartman
maintainerPATCH 284/324 PCI: aardvark: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 1df3e5b3feebf29a3ecfa0c0f06f79544ca573e4 ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The Aardvark PCI controller driver has the same issue.
Replace pci_remap_iospace() with its devm_ managed version to fix the bug.
--- drivers/pci/host/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-aardvark.c +1 -1
@@ -848,7 +848,7 @@ static int advk_pcie_parse_request_of_pc0 ,0xF8000000 ,0 ,lower_32_bits (res->start), OB_PCIE_IO); - err =pci_remap_iospace (res, iobase); + err =devm_pci_remap_iospace (dev, res, iobase);if (err) {dev_warn (dev,"error %d: failed to map resource %pR\n" , err, res);
Greg Kroah-Hartman
maintainerPATCH 285/324 PCI: faraday: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit e30609454b39139a91faf631685f503b7ea3f27d ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The Faraday PCI driver has the same issue. Replace pci_remap_iospace() with its devm_ managed version to fix the bug.
--- drivers/pci/host/pci-ftpci100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-ftpci100.c +1 -1
@@ -501,7 +501,7 @@ static int faraday_pci_probe(struct platdev_err (dev,"illegal IO mem size\n" );return -EINVAL ; } - ret =pci_remap_iospace (io, io_base); + ret =devm_pci_remap_iospace (dev, io, io_base);if (ret) {dev_warn (dev,"error %d: failed to map resource %pR\n" , ret, io);
Greg Kroah-Hartman
maintainerPATCH 286/324 PCI: mediatek: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 438477b9a089e45ea7c8fb549553e52833117ed8 ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The MediaTek PCIe driver has the same issue.
Replace devm_pci_remap_iospace() with its devm_ managed counterpart to fix the bug.
--- drivers/pci/host/pcie-mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pcie-mediatek.c +1 -1
@@ -1063,7 +1063,7 @@ static int mtk_pcie_request_resources(stif (err <0 )return err; -pci_remap_iospace (&pcie->pio, pcie->io.start); +devm_pci_remap_iospace (dev, &pcie->pio, pcie->io.start);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 287/324 PCI: v3-semi: Fix I/O space page leak
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Shtylyov <[email protected]>
[ Upstream commit 270ed733e68955049b693bea8f4a1efb293a96ae ]
When testing the R-Car PCIe driver on the Condor board, if the PCIe PHY driver was left disabled, the kernel crashed with this BUG:
kernel BUG at lib/ioremap.c:72!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 39 Comm: kworker/0:1 Not tainted 4.17.0-dirty #1092 Hardware name: Renesas Condor board based on r8a77980 (DT) Workqueue: events deferred_probe_work_func pstate: 80000005 (Nzcv daif -PAN -UAO) pc : ioremap_page_range+0x370/0x3c8 lr : ioremap_page_range+0x40/0x3c8 sp : ffff000008da39e0 x29: ffff000008da39e0 x28: 00e8000000000f07 x27: ffff7dfffee00000 x26: 0140000000000000 x25: ffff7dfffef00000 x24: 00000000000fe100 x23: ffff80007b906000 x22: ffff000008ab8000 x21: ffff000008bb1d58 x20: ffff7dfffef00000 x19: ffff800009c30fb8 x18: 0000000000000001 x17: 00000000000152d0 x16: 00000000014012d0 x15: 0000000000000000 x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720 x11: 0720072007300730 x10: 00000000000000ae x9 : 0000000000000000 x8 : ffff7dffff000000 x7 : 0000000000000000 x6 : 0000000000000100 x5 : 0000000000000000 x4 : 000000007b906000 x3 : ffff80007c61a880 x2 : ffff7dfffeefffff x1 : 0000000040000000 x0 : 00e80000fe100f07 Process kworker/0:1 (pid: 39, stack limit = 0x (ptrval)) Call trace: ioremap_page_range+0x370/0x3c8 pci_remap_iospace+0x7c/0xac pci_parse_request_of_pci_ranges+0x13c/0x190 rcar_pcie_probe+0x4c/0xb04 platform_drv_probe+0x50/0xbc driver_probe_device+0x21c/0x308 __device_attach_driver+0x98/0xc8 bus_for_each_drv+0x54/0x94 __device_attach+0xc4/0x12c device_initial_probe+0x10/0x18 bus_probe_device+0x90/0x98 deferred_probe_work_func+0xb0/0x150 process_one_work+0x12c/0x29c worker_thread+0x200/0x3fc kthread+0x108/0x134 ret_from_fork+0x10/0x18 Code: f9004ba2 54000080 aa0003fb 17ffff48 (d4210000)
It turned out that pci_remap_iospace() wasn't undone when the driver's probe failed, and since devm_phy_optional_get() returned -EPROBE_DEFER, the probe was retried, finally causing the BUG due to trying to remap already remapped pages.
The V3 Semiconductor PCI driver has the same issue.
Replace devm_pci_remap_iospace() with its devm_ managed version to fix the bug.
--- drivers/pci/host/pci-v3-semi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/host/pci-v3-semi.c +1 -1
@@ -535,7 +535,7 @@ static int v3_pci_setup_resource(struct v3->io_bus_addr = io->start - win->offset;dev_dbg (dev,"I/O window %pR, bus addr %pap\n" , io, &v3->io_bus_addr); - ret =pci_remap_iospace (io, io_base); + ret =devm_pci_remap_iospace (dev, io, io_base);if (ret) { dev_warn(dev, "error %d: failed to map resource %pR\n",
Greg Kroah-Hartman
maintainerPATCH 288/324 net: qca_spi: Avoid packet drop during initial sync
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit b2bab426dc715de147f8039a3fccff27d795f4eb ]
As long as the synchronization with the QCA7000 isn't finished, we cannot accept packets from the upper layers. So let the SPI thread enable the TX queue after sync and avoid unwanted packet drop.
--- drivers/net/ethernet/qualcomm/qca_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qualcomm/qca_spi.c +1 -1
@@ -658,7 +658,7 @@ qcaspi_netdev_open(struct net_device *dereturn ret; } -netif_start_queue (qca->net_dev); +/* SPI thread takes care of TX queue */ return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 289/324 net: qca_spi: Make sure the QCA7000 reset is triggered
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 711c62dfa6bdb4326ca6c587f295ea5c4f7269de ]
In case the SPI thread is not running, a simple reset of sync state won't fix the transmit timeout. We also need to wake up the kernel thread.
--- drivers/net/ethernet/qualcomm/qca_spi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/qualcomm/qca_spi.c +3 -0
@@ -760,6 +760,9 @@ qcaspi_netdev_tx_timeout(struct net_devi qca->net_dev->stats.tx_errors++;/* Trigger tx queue flush and QCA7000 reset */ qca->sync =QCASPI_SYNC_UNKNOWN ; + +if (qca->spi_thread) +wake_up_process (qca->spi_thread); } static int
Greg Kroah-Hartman
maintainerPATCH 290/324 net: qca_spi: Fix log level if probe fails
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 50973993260a6934f0a00da53d9b746cfbea89ab ]
In cases the probing fails the log level of the messages should be an error.
--- drivers/net/ethernet/qualcomm/qca_spi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/qualcomm/qca_spi.c +8 -8
@@ -881,22 +881,22 @@ qca_spi_probe(struct spi_device *spi)if ((qcaspi_clkspeed <QCASPI_CLK_SPEED_MIN ) || (qcaspi_clkspeed >QCASPI_CLK_SPEED_MAX )) { -dev_info (&spi->dev,"Invalid clkspeed: %d\n" , - qcaspi_clkspeed); +dev_err (&spi->dev,"Invalid clkspeed: %d\n" , + qcaspi_clkspeed);return -EINVAL ; }if ((qcaspi_burst_len <QCASPI_BURST_LEN_MIN ) || (qcaspi_burst_len >QCASPI_BURST_LEN_MAX )) { -dev_info (&spi->dev,"Invalid burst len: %d\n" , - qcaspi_burst_len); +dev_err (&spi->dev,"Invalid burst len: %d\n" , + qcaspi_burst_len);return -EINVAL ; }if ((qcaspi_pluggable <QCASPI_PLUGGABLE_MIN ) || (qcaspi_pluggable >QCASPI_PLUGGABLE_MAX )) { -dev_info (&spi->dev,"Invalid pluggable: %d\n" , - qcaspi_pluggable); +dev_err (&spi->dev,"Invalid pluggable: %d\n" , + qcaspi_pluggable);return -EINVAL ; }
@@ -958,8 +958,8 @@ qca_spi_probe(struct spi_device *spi) }if (register_netdev (qcaspi_devs)) { -dev_info (&spi->dev,"Unable to register net device %s\n" , - qcaspi_devs->name); +dev_err (&spi->dev,"Unable to register net device %s\n" , + qcaspi_devs->name);free_netdev (qcaspi_devs);return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 291/324 net: cavium: Add fine-granular dependencies on PCI
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit e40562abdf81f32356218d4196c33f5f93c040f7 ]
Add dependencies on PCI where necessary.
--- drivers/net/ethernet/cavium/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/cavium/Kconfig +6 -6
@@ -15,7 +15,7 @@ if NET_VENDOR_CAVIUM config THUNDER_NIC_PF tristate "Thunder Physical function driver" - depends on 64BIT + depends on 64BIT && PCI select THUNDER_NIC_BGX ---help--- This driver supports Thunder's NIC physical function.
@@ -28,13 +28,13 @@ config THUNDER_NIC_PF config THUNDER_NIC_VF tristate "Thunder Virtual function driver" imply CAVIUM_PTP - depends on 64BIT + depends on 64BIT && PCI ---help--- This driver supports Thunder's NIC virtual function config THUNDER_NIC_BGX tristate "Thunder MAC interface driver (BGX)" - depends on 64BIT + depends on 64BIT && PCI select PHYLIB select MDIO_THUNDER select THUNDER_NIC_RGX
@@ -44,7 +44,7 @@ config THUNDER_NIC_BGX config THUNDER_NIC_RGX tristate "Thunder MAC interface driver (RGX)" - depends on 64BIT + depends on 64BIT && PCI select PHYLIB select MDIO_THUNDER ---help---
@@ -53,7 +53,7 @@ config THUNDER_NIC_RGX config CAVIUM_PTP tristate "Cavium PTP coprocessor as PTP clock" - depends on 64BIT + depends on 64BIT && PCI imply PTP_1588_CLOCK default y ---help---
@@ -65,7 +65,7 @@ config CAVIUM_PTP config LIQUIDIO tristate "Cavium LiquidIO support" - depends on 64BIT + depends on 64BIT && PCI depends on MAY_USE_DEVLINK imply PTP_1588_CLOCK select FW_LOADER
Greg Kroah-Hartman
maintainerPATCH 293/324 soc: imx: gpc: restrict register range for regmap access
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anson Huang <[email protected]>
[ Upstream commit de2d9b5284bcb5c159c5882ac69f6bfd4dec7c67 ]
GPC registers are NOT continuous, some registers are reserved and accessing them from userspace will trigger external abort, add regmap register access table to avoid below abort:
root@imx6slevk:~# cat /sys/kernel/debug/regmap/20dc000.gpc/registers [ 108.480477] Unhandled fault: imprecise external abort (0x1406) at 0xb6db5004 [ 108.487985] pgd = 42b54bfd [ 108.490741] [b6db5004] *pgd=ba1b7831 [ 108.494386] Internal error: : 1406 [#1] SMP ARM [ 108.498943] Modules linked in: [ 108.502043] CPU: 0 PID: 389 Comm: cat Not tainted 4.18.0-rc1-00074-gc9f1f60-dirty #482 [ 108.509982] Hardware name: Freescale i.MX6 SoloLite (Device Tree) [ 108.516123] PC is at regmap_mmio_read32le+0x20/0x24 [ 108.521031] LR is at regmap_mmio_read+0x40/0x60 [ 108.525586] pc : [<c059cf74>] lr : [<c059d1ac>] psr: 20060093 [ 108.531875] sp : eccf1d98 ip : eccf1da8 fp : eccf1da4 [ 108.537122] r10: ec2d3800 r9 : eccf1f60 r8 : ecfc0000 [ 108.542370] r7 : eccf1e2c r6 : eccf1e2c r5 : 00000028 r4 : ec338e00 [ 108.548920] r3 : 00000000 r2 : eccf1e2c r1 : f0980028 r0 : 00000000 [ 108.555474] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none [ 108.562720] Control: 10c5387d Table: acf4004a DAC: 00000051 [ 108.568491] Process cat (pid: 389, stack limit = 0xd4318a65) [ 108.574174] Stack: (0xeccf1d98 to 0xeccf2000)
--- drivers/soc/imx/gpc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/soc/imx/gpc.c +21 -0
@@ -27,9 +27,16 @@#define GPC_PGC_SW2ISO_SHIFT 0x8#define GPC_PGC_SW_SHIFT 0x0 +#define GPC_PGC_PCI_PDN 0x200 +#define GPC_PGC_PCI_SR 0x20c +#define GPC_PGC_GPU_PDN 0x260#define GPC_PGC_GPU_PUPSCR 0x264#define GPC_PGC_GPU_PDNSCR 0x268 +#define GPC_PGC_GPU_SR 0x26c + +#define GPC_PGC_DISP_PDN 0x240 +#define GPC_PGC_DISP_SR 0x24c#define GPU_VPU_PUP_REQ BIT(1)#define GPU_VPU_PDN_REQ BIT(0)
@@ -318,10 +325,24 @@ static const struct of_device_id imx_gpc { } }; +static const struct regmap_range yes_ranges[] = { +regmap_reg_range (GPC_CNTR ,GPC_CNTR ), +regmap_reg_range (GPC_PGC_PCI_PDN ,GPC_PGC_PCI_SR ), +regmap_reg_range (GPC_PGC_GPU_PDN ,GPC_PGC_GPU_SR ), +regmap_reg_range (GPC_PGC_DISP_PDN ,GPC_PGC_DISP_SR ), +}; + +static const struct regmap_access_table access_table = { + .yes_ranges = yes_ranges, + .n_yes_ranges =ARRAY_SIZE (yes_ranges), +}; +static const struct regmap_config imx_gpc_regmap_config = { .reg_bits =32 , .val_bits =32 , .reg_stride =4 , + .rd_table = &access_table, + .wr_table = &access_table, .max_register =0x2ac , };
Greg Kroah-Hartman
maintainerPATCH 294/324 ACPI / EC: Use ec_no_wakeup on more Thinkpad X1 Carbon 6th systems
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Robin H. Johnson" <[email protected]>
[ Upstream commit 2c4d6baf1bc4f7729773ffcee9ba2a9781578633 ]
The ec_no_wakeup matcher added for Thinkpad X1 Carbon 6th gen systems beyond matched only a single DMI model (20KGS3JF01), that didn't cover my laptop (20KH002JUS). Change to match based on DMI product family to cover all X1 6th gen systems.
--- drivers/acpi/ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/ec.c +1 -1
@@ -2036,7 +2036,7 @@ static const struct dmi_system_id acpi_e .ident = "Thinkpad X1 Carbon 6th", .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "20KGS3JF01"), + DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"), }, }, { },
Greg Kroah-Hartman
maintainerPATCH 297/324 nvme: fix handling of metadata_len for NVME_IOCTL_IO_CMD
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roland Dreier <[email protected]>
[ Upstream commit 9b382768135ee3ff282f828c906574a8478e036b ]
The old code in nvme_user_cmd() passed the userspace virtual address from nvme_passthru_cmd.metadata as the length of the metadata buffer as well as the address to nvme_submit_user_cmd().
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -1209,7 +1209,7 @@ static int nvme_user_cmd(struct nvme_ctr effects =nvme_passthru_start (ctrl, ns, cmd.opcode); status =nvme_submit_user_cmd (ns ? ns->queue : ctrl->admin_q, &c, (void __user *)(uintptr_t )cmd.addr, cmd.data_len, - (void __user *)(uintptr_t )cmd.metadata, cmd.metadata, + (void __user *)(uintptr_t )cmd.metadata, cmd.metadata_len,0 , &cmd.result, timeout);nvme_passthru_end (ctrl, effects);
Greg Kroah-Hartman
maintainerPATCH 298/324 mm: use helper functions for allocating and freeing vm_area structs
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 3928d4f5ee37cdc523894f6e549e6aae521d8980 ]
The vm_area_struct is one of the most fundamental memory management objects, but the management of it is entirely open-coded evertwhere, ranging from allocation and freeing (using kmem_cache_[z]alloc and kmem_cache_free) to initializing all the fields.
We want to unify this in order to end up having some unified initialization of the vmas, and the first step to this is to at least have basic allocation functions.
Right now those functions are literally just wrappers around the kmem_cache_*() calls. This is a purely mechanical conversion:
# new vma:
kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL) -> vm_area_alloc() # copy old vma
kmem_cache_alloc(vm_area_cachep, GFP_KERNEL) -> vm_area_dup(old) # free vma
kmem_cache_free(vm_area_cachep, vma) -> vm_area_free(vma)to the point where the old vma passed in to the vm_area_dup() function isn't even used yet (because I've left all the old manual initialization alone).
--- arch/ia64/kernel/perfmon.c | 4 ++-- arch/ia64/mm/init.c | 8 ++++---- fs/exec.c | 4 ++-- include/linux/mm.h | 4 +++- kernel/fork.c | 21 ++++++++++++++++++--- mm/mmap.c | 22 +++++++++++----------- mm/nommu.c | 8 ++++---- 7 files changed, 44 insertions(+), 27 deletions(-)
arch/ia64/kernel/perfmon.c +2 -2
@@ -2278,7 +2278,7 @@ pfm_smpl_buffer_alloc(struct task_structDPRINT (("smpl_buf @%p\n" , smpl_buf));/* allocate vma */ - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (!vma) {DPRINT (("Cannot allocate vma\n" )); goto error_kmem;
@@ -2346,7 +2346,7 @@ pfm_smpl_buffer_alloc(struct task_structreturn 0 ; error: -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma); error_kmem:pfm_rvfree (smpl_buf, size);
arch/ia64/mm/init.c +4 -4
@@ -114,7 +114,7 @@ ia64_init_addr_space (void)* the problem. When the process attempts to write to the register backing store * for the first time, it will get a SEGFAULT in this case. */ - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (vma) {INIT_LIST_HEAD (&vma->anon_vma_chain); vma->vm_mm = current->mm;
@@ -125,7 +125,7 @@ ia64_init_addr_space (void)down_write (¤t->mm->mmap_sem);if (insert_vm_struct (current->mm, vma)) {up_write (¤t->mm->mmap_sem); -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return ; }up_write (¤t->mm->mmap_sem);
@@ -133,7 +133,7 @@ ia64_init_addr_space (void)/* map NaT-page at address zero to speed up speculative dereferencing of NULL: */ if (!(current->personality &MMAP_PAGE_ZERO )) { - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (vma) {INIT_LIST_HEAD (&vma->anon_vma_chain); vma->vm_mm = current->mm;
@@ -144,7 +144,7 @@ ia64_init_addr_space (void)down_write (¤t->mm->mmap_sem);if (insert_vm_struct (current->mm, vma)) {up_write (¤t->mm->mmap_sem); -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return ; }up_write (¤t->mm->mmap_sem);
fs/exec.c +2 -2
@@ -290,7 +290,7 @@ static int __bprm_mm_init(struct linux_bstruct vm_area_struct *vma =NULL ;struct mm_struct *mm = bprm->mm; - bprm->vma = vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + bprm->vma = vma =vm_area_alloc ();if (!vma)return -ENOMEM ;
@@ -326,7 +326,7 @@ err:up_write (&mm->mmap_sem); err_free: bprm->vma =NULL ; -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return err; }
include/linux/mm.h +3 -1
@@ -154,7 +154,9 @@ extern int overcommit_kbytes_handler(str* mmap() functions). */ -extern struct kmem_cache *vm_area_cachep; +struct vm_area_struct *vm_area_alloc (void ); +struct vm_area_struct *vm_area_dup (struct vm_area_struct *); +void vm_area_free (struct vm_area_struct *);#ifndef CONFIG_MMU extern struct rb_root nommu_region_tree;
kernel/fork.c +18 -3
@@ -303,11 +303,26 @@ struct kmem_cache *files_cachep;struct kmem_cache *fs_cachep;/* SLAB cache for vm_area_struct structures */ -struct kmem_cache *vm_area_cachep; +static struct kmem_cache *vm_area_cachep;/* SLAB cache for mm_struct structures (tsk->mm) */ static struct kmem_cache *mm_cachep; +struct vm_area_struct *vm_area_alloc (void ) +{ +return kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); +} + +struct vm_area_struct *vm_area_dup (struct vm_area_struct *orig) +{ +return kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); +} + +void vm_area_free (struct vm_area_struct *vma) +{ +kmem_cache_free (vm_area_cachep, vma); +} +static void account_kernel_stack (struct task_struct *tsk,int account) {void *stack =task_stack_page (tsk);
@@ -455,7 +470,7 @@ static __latent_entropy int dup_mmap(str goto fail_nomem; charge = len; } - tmp =kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); + tmp =vm_area_dup (mpnt);if (!tmp) goto fail_nomem; *tmp = *mpnt;
@@ -539,7 +554,7 @@ fail_uprobe_end: fail_nomem_anon_vma_fork:mpol_put (vma_policy (tmp)); fail_nomem_policy: -kmem_cache_free (vm_area_cachep, tmp); +vm_area_free (tmp); fail_nomem: retval = -ENOMEM ;vm_unacct_memory (charge);
mm/mmap.c +11 -11
@@ -182,7 +182,7 @@ static struct vm_area_struct *remove_vmaif (vma->vm_file)fput (vma->vm_file);mpol_put (vma_policy (vma)); -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return next; }
@@ -911,7 +911,7 @@ again:anon_vma_merge (vma, next); mm->map_count--;mpol_put (vma_policy (next)); -kmem_cache_free (vm_area_cachep, next); +vm_area_free (next);/* * In mprotect's case 6 (see comments on vma_merge), * we must remove another next too. It would clutter
@@ -1729,7 +1729,7 @@ unsigned long mmap_region(struct file *f* specific mapper. the address has already been validated, but * not unmapped, but the maps are removed from the list. */ - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (!vma) { error = -ENOMEM ; goto unacct_error;
@@ -1832,7 +1832,7 @@ allow_write_and_free_vma:if (vm_flags &VM_DENYWRITE )allow_write_access (file); free_vma: -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma); unacct_error:if (charged)vm_unacct_memory (charged);
@@ -2620,7 +2620,7 @@ int __split_vma(struct mm_struct *mm, streturn err; } - new =kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); + new =vm_area_dup (vma);if (!new)return -ENOMEM ;
@@ -2669,7 +2669,7 @@ int __split_vma(struct mm_struct *mm, st out_free_mpol:mpol_put (vma_policy (new)); out_free_vma: -kmem_cache_free (vm_area_cachep, new); +vm_area_free (new);return err; }
@@ -2984,7 +2984,7 @@ static int do_brk_flags(unsigned long ad/* * create a vma struct for an anonymous mapping */ - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (!vma) {vm_unacct_memory (len >>PAGE_SHIFT );return -ENOMEM ;
@@ -3202,7 +3202,7 @@ struct vm_area_struct *copy_vma(struct v } *need_rmap_locks = (new_vma->vm_pgoff <= vma->vm_pgoff); }else { - new_vma =kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); + new_vma =vm_area_dup (vma);if (!new_vma) goto out; *new_vma = *vma;
@@ -3226,7 +3226,7 @@ struct vm_area_struct *copy_vma(struct v out_free_mempol:mpol_put (vma_policy (new_vma)); out_free_vma: -kmem_cache_free (vm_area_cachep, new_vma); +vm_area_free (new_vma); out:return NULL ; }
@@ -3350,7 +3350,7 @@ static struct vm_area_struct *__install_int ret;struct vm_area_struct *vma; - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (unlikely (vma ==NULL ))return ERR_PTR (-ENOMEM );
@@ -3376,7 +3376,7 @@ static struct vm_area_struct *__install_return vma; out: -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return ERR_PTR (ret); }
mm/nommu.c +4 -4
@@ -769,7 +769,7 @@ static void delete_vma(struct mm_structif (vma->vm_file)fput (vma->vm_file);put_nommu_region (vma->vm_region); -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma); }/*
@@ -1204,7 +1204,7 @@ unsigned long do_mmap(struct file *file,if (!region) goto error_getting_region; - vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + vma =vm_area_alloc ();if (!vma) goto error_getting_vma;
@@ -1368,7 +1368,7 @@ error:kmem_cache_free (vm_region_jar, region);if (vma->vm_file)fput (vma->vm_file); -kmem_cache_free (vm_area_cachep, vma); +vm_area_free (vma);return ret; sharing_violation:
@@ -1469,7 +1469,7 @@ int split_vma(struct mm_struct *mm, struif (!region)return -ENOMEM ; - new =kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); + new =vm_area_dup (vma);if (!new) {kmem_cache_free (vm_region_jar, region);return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 299/324 mm: make vm_area_dup() actually copy the old vma data
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 95faf6992df468f617edb788da8c21c6eed0dfa7 ]
.. and re-initialize th eanon_vma_chain head.
This removes some boiler-plate from the users, and also makes it clear why it didn't need use the 'zalloc()' version.
--- kernel/fork.c | 10 +++++++--- mm/mmap.c | 7 ------- mm/nommu.c | 1 - 3 files changed, 7 insertions(+), 11 deletions(-)
kernel/fork.c +7 -3
@@ -315,7 +315,13 @@ struct vm_area_struct *vm_area_alloc(voistruct vm_area_struct *vm_area_dup (struct vm_area_struct *orig) { -return kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); +struct vm_area_struct *new =kmem_cache_alloc (vm_area_cachep,GFP_KERNEL ); + +if (new) { + *new = *orig; +INIT_LIST_HEAD (&new->anon_vma_chain); + } +return new; }void vm_area_free (struct vm_area_struct *vma)
@@ -473,8 +479,6 @@ static __latent_entropy int dup_mmap(str tmp =vm_area_dup (mpnt);if (!tmp) goto fail_nomem; - *tmp = *mpnt; -INIT_LIST_HEAD (&tmp->anon_vma_chain); retval =vma_dup_policy (mpnt, tmp);if (retval) goto fail_nomem_policy;
mm/mmap.c +0 -7
@@ -2624,11 +2624,6 @@ int __split_vma(struct mm_struct *mm, stif (!new)return -ENOMEM ; -/* most fields are the same, copy all, and then fixup */ - *new = *vma; - -INIT_LIST_HEAD (&new->anon_vma_chain); -if (new_below) new->vm_end = addr;else {
@@ -3205,13 +3200,11 @@ struct vm_area_struct *copy_vma(struct v new_vma =vm_area_dup (vma);if (!new_vma) goto out; - *new_vma = *vma; new_vma->vm_start = addr; new_vma->vm_end = addr + len; new_vma->vm_pgoff = pgoff;if (vma_dup_policy (vma, new_vma)) goto out_free_vma; -INIT_LIST_HEAD (&new_vma->anon_vma_chain);if (anon_vma_clone (new_vma, vma)) goto out_free_mempol;if (new_vma->vm_file)
mm/nommu.c +0 -1
@@ -1476,7 +1476,6 @@ int split_vma(struct mm_struct *mm, stru }/* most fields are the same, copy all, and then fixup */ - *new = *vma; *region = *vma->vm_region; new->vm_region = region;
Greg Kroah-Hartman
maintainerPATCH 300/324 mm: make vm_area_alloc() initialize core fields
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 490fc053865c9cc40f1085ef8a5504f5341f79d2 ]
Like vm_area_dup(), it initializes the anon_vma_chain head, and the basic mm pointer.
The rest of the fields end up being different for different users, although the plan is to also initialize the 'vm_ops' field to a dummy entry.
--- arch/ia64/kernel/perfmon.c | 4 +--- arch/ia64/mm/init.c | 8 ++------ fs/exec.c | 4 +--- include/linux/mm.h | 2 +- kernel/fork.c | 10 ++++++++-- mm/mmap.c | 12 +++--------- mm/nommu.c | 3 +-- 7 files changed, 17 insertions(+), 26 deletions(-)
arch/ia64/kernel/perfmon.c +1 -3
@@ -2278,17 +2278,15 @@ pfm_smpl_buffer_alloc(struct task_structDPRINT (("smpl_buf @%p\n" , smpl_buf));/* allocate vma */ - vma =vm_area_alloc (); + vma =vm_area_alloc (mm);if (!vma) {DPRINT (("Cannot allocate vma\n" )); goto error_kmem; } -INIT_LIST_HEAD (&vma->anon_vma_chain);/* * partially initialize the vma for the sampling buffer */ - vma->vm_mm = mm; vma->vm_file =get_file (filp); vma->vm_flags =VM_READ |VM_MAYREAD |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_page_prot =PAGE_READONLY ;/* XXX may need to change */
arch/ia64/mm/init.c +2 -6
@@ -114,10 +114,8 @@ ia64_init_addr_space (void)* the problem. When the process attempts to write to the register backing store * for the first time, it will get a SEGFAULT in this case. */ - vma =vm_area_alloc (); + vma =vm_area_alloc (current->mm);if (vma) { -INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_mm = current->mm; vma->vm_start = current->thread.rbs_bot &PAGE_MASK ; vma->vm_end = vma->vm_start +PAGE_SIZE ; vma->vm_flags =VM_DATA_DEFAULT_FLAGS |VM_GROWSUP |VM_ACCOUNT ;
@@ -133,10 +131,8 @@ ia64_init_addr_space (void)/* map NaT-page at address zero to speed up speculative dereferencing of NULL: */ if (!(current->personality &MMAP_PAGE_ZERO )) { - vma =vm_area_alloc (); + vma =vm_area_alloc (current->mm);if (vma) { -INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_mm = current->mm; vma->vm_end =PAGE_SIZE ; vma->vm_page_prot =__pgprot (pgprot_val (PAGE_READONLY ) | _PAGE_MA_NAT); vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO |
fs/exec.c +1 -3
@@ -290,7 +290,7 @@ static int __bprm_mm_init(struct linux_bstruct vm_area_struct *vma =NULL ;struct mm_struct *mm = bprm->mm; - bprm->vma = vma =vm_area_alloc (); + bprm->vma = vma =vm_area_alloc (mm);if (!vma)return -ENOMEM ;
@@ -298,7 +298,6 @@ static int __bprm_mm_init(struct linux_b err = -EINTR ; goto err_free; } - vma->vm_mm = mm;/* * Place the stack at the largest stack address the architecture
@@ -311,7 +310,6 @@ static int __bprm_mm_init(struct linux_b vma->vm_start = vma->vm_end -PAGE_SIZE ; vma->vm_flags =VM_SOFTDIRTY |VM_STACK_FLAGS |VM_STACK_INCOMPLETE_SETUP ; vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); -INIT_LIST_HEAD (&vma->anon_vma_chain); err =insert_vm_struct (mm, vma);if (err)
include/linux/mm.h +1 -1
@@ -154,7 +154,7 @@ extern int overcommit_kbytes_handler(str* mmap() functions). */ -struct vm_area_struct *vm_area_alloc (void ); +struct vm_area_struct *vm_area_alloc (struct mm_struct *);struct vm_area_struct *vm_area_dup (struct vm_area_struct *);void vm_area_free (struct vm_area_struct *);
kernel/fork.c +8 -2
@@ -308,9 +308,15 @@ static struct kmem_cache *vm_area_cachep/* SLAB cache for mm_struct structures (tsk->mm) */ static struct kmem_cache *mm_cachep; -struct vm_area_struct *vm_area_alloc (void ) +struct vm_area_struct *vm_area_alloc (struct mm_struct *mm) { -return kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); +struct vm_area_struct *vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL ); + +if (vma) { + vma->vm_mm = mm; +INIT_LIST_HEAD (&vma->anon_vma_chain); + } +return vma; }struct vm_area_struct *vm_area_dup (struct vm_area_struct *orig)
mm/mmap.c +3 -9
@@ -1729,19 +1729,17 @@ unsigned long mmap_region(struct file *f* specific mapper. the address has already been validated, but * not unmapped, but the maps are removed from the list. */ - vma =vm_area_alloc (); + vma =vm_area_alloc (mm);if (!vma) { error = -ENOMEM ; goto unacct_error; } - vma->vm_mm = mm; vma->vm_start = addr; vma->vm_end = addr + len; vma->vm_flags = vm_flags; vma->vm_page_prot =vm_get_page_prot (vm_flags); vma->vm_pgoff = pgoff; -INIT_LIST_HEAD (&vma->anon_vma_chain);if (file) {if (vm_flags &VM_DENYWRITE ) {
@@ -2979,14 +2977,12 @@ static int do_brk_flags(unsigned long ad/* * create a vma struct for an anonymous mapping */ - vma =vm_area_alloc (); + vma =vm_area_alloc (mm);if (!vma) {vm_unacct_memory (len >>PAGE_SHIFT );return -ENOMEM ; } -INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_mm = mm; vma->vm_start = addr; vma->vm_end = addr + len; vma->vm_pgoff = pgoff;
@@ -3343,12 +3339,10 @@ static struct vm_area_struct *__install_int ret;struct vm_area_struct *vma; - vma =vm_area_alloc (); + vma =vm_area_alloc (mm);if (unlikely (vma ==NULL ))return ERR_PTR (-ENOMEM ); -INIT_LIST_HEAD (&vma->anon_vma_chain); - vma->vm_mm = mm; vma->vm_start = addr; vma->vm_end = addr + len;
mm/nommu.c +1 -2
@@ -1204,7 +1204,7 @@ unsigned long do_mmap(struct file *file,if (!region) goto error_getting_region; - vma =vm_area_alloc (); + vma =vm_area_alloc (current->mm);if (!vma) goto error_getting_vma;
@@ -1212,7 +1212,6 @@ unsigned long do_mmap(struct file *file, region->vm_flags = vm_flags; region->vm_pgoff = pgoff; -INIT_LIST_HEAD (&vma->anon_vma_chain); vma->vm_flags = vm_flags; vma->vm_pgoff = pgoff;
Greg Kroah-Hartman
maintainerPATCH 301/324 EDAC: Add missing MEM_LRDDR4 entry in edac_mem_types[]
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit b748f2de4b2f578599f46c6000683a8da755bf68 upstream.
The edac_mem_types[] array misses a MEM_LRDDR4 entry, which leads to NULL pointer dereference when accessed via sysfs or such.
--- drivers/edac/edac_mc.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/edac_mc.c +1 -0
@@ -215,6 +215,7 @@ const char * const edac_mem_types[] = { [MEM_LRDDR3] = "Load-Reduced-DDR3-RAM", [MEM_DDR4] = "Unbuffered-DDR4", [MEM_RDDR4] = "Registered-DDR4", + [MEM_LRDDR4] = "Load-Reduced-DDR4-RAM", [MEM_NVDIMM ] ="Non-volatile-RAM" , };EXPORT_SYMBOL_GPL (edac_mem_types);
Greg Kroah-Hartman
maintainerPATCH 302/324 pty: fix O_CLOEXEC for TIOCGPTPEER
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthijs van Duin <[email protected]>
commit 36ecc1481dc8d8c52d43ba18c6b642c1d2fde789 upstream.
It was being ignored because the flags were not passed to fd allocation.
--- drivers/tty/pty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/pty.c +1 -1
@@ -625,7 +625,7 @@ int ptm_open_peer(struct file *master, sif (tty->driver != ptm_driver)return -EIO ; - fd =get_unused_fd_flags (0 ); + fd =get_unused_fd_flags (flags);if (fd <0 ) { retval = fd; goto err;
Greg Kroah-Hartman
maintainerPATCH 303/324 mm: Allow non-direct-map arguments to free_reserved_area()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 0d83432811f26871295a9bc24d3c387924da6071 upstream.
free_reserved_area() takes pointers as arguments to show which addresses should be freed. However, it does this in a somewhat ambiguous way. If it gets a kernel direct map address, it always works. However, if it gets an address that is part of the kernel image alias mapping, it can fail.
It fails if all of the following happen:
* The specified address is part of the kernel image alias
* Poisoning is requested (forcing a memset())
* The address is in a read-only portion of the kernel image
The memset() fails on the read-only mapping, of course. free_reserved_area() *is* called both on the direct map and on kernel image alias addresses. We've just lucked out thus far that the kernel image alias areas it gets used on are read-write. I'm fairly sure this has been just a happy accident.
It is quite easy to make free_reserved_area() work for all cases: just convert the address to a direct map address before doing the memset(), and do this unconditionally. There is little chance of a regression here because we previously did a virt_to_page() on the address for the memset, so we know these are not highmem pages for which virt_to_page() would fail.
--- mm/page_alloc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
mm/page_alloc.c +14 -2
@@ -6933,9 +6933,21 @@ unsigned long free_reserved_area(void *s start = (void *)PAGE_ALIGN ((unsigned long )start); end = (void *)((unsigned long )end &PAGE_MASK );for (pos = start; pos < end; pos +=PAGE_SIZE , pages++) { +struct page *page =virt_to_page (pos); +void *direct_map_addr; + +/* +* 'direct_map_addr' might be different from 'pos' +* because some architectures' virt_to_page() +* work with aliases. Getting the direct map +* address ensures that we get a _writeable_ +* alias for the memset(). +*/ + direct_map_addr =page_address (page);if ((unsigned int )poison <=0xFF ) -memset (pos, poison,PAGE_SIZE ); -free_reserved_page (virt_to_page (pos)); +memset (direct_map_addr, poison,PAGE_SIZE ); + +free_reserved_page (page); }if (pages && s)
Greg Kroah-Hartman
maintainerPATCH 304/324 x86/mm/init: Pass unconverted symbol addresses to free_init_pages()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 9f515cdb411ef34f1aaf4c40bb0c932cf6db5de1 upstream.
The x86 code has several places where it frees parts of kernel image:
1. Unused SMP alternative
2. __init code
3. The hole between text and rodata
4. The hole between rodata and data
We call free_init_pages() to do this. Strangely, we convert the symbol addresses to kernel direct map addresses in some cases (#3, #4) but not others (#1, #2).
The virt_to_page() and the other code in free_reserved_area() now works fine for for symbol addresses on x86, so don't bother converting the addresses to direct map addresses before freeing them.
--- arch/x86/mm/init_64.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/mm/init_64.c +2 -6
@@ -1283,12 +1283,8 @@ void mark_rodata_ro(void)set_memory_ro (start, (end-start) >>PAGE_SHIFT );#endif -free_init_pages ("unused kernel" , - (unsigned long )__va (__pa_symbol (text_end)), - (unsigned long )__va (__pa_symbol (rodata_start))); -free_init_pages ("unused kernel" , - (unsigned long )__va (__pa_symbol (rodata_end)), - (unsigned long )__va (__pa_symbol (_sdata))); +free_init_pages ("unused kernel" , text_end, rodata_start); +free_init_pages ("unused kernel" , rodata_end, _sdata);debug_checkwx ();
Greg Kroah-Hartman
maintainerPATCH 305/324 x86/mm/init: Add helper for freeing kernel image pages
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit 6ea2738e0ca0e626c75202fb051c1e88d7a950fa upstream.
When chunks of the kernel image are freed, free_init_pages() is used directly. Consolidate the three sites that do this. Also update the string to give an incrementally better description of that memory versus what was there before.
--- arch/x86/include/asm/processor.h | 1 + arch/x86/mm/init.c | 15 ++++++++++++--- arch/x86/mm/init_64.c | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/include/asm/processor.h +1 -0
@@ -980,6 +980,7 @@ static inline uint32_t hypervisor_cpuid_extern unsigned long arch_align_stack (unsigned long sp);extern void free_init_pages (char *what,unsigned long begin,unsigned long end); +extern void free_kernel_image_pages (void *begin,void *end);void default_idle (void );#ifdef CONFIG_XEN
arch/x86/mm/init.c +12 -3
@@ -775,13 +775,22 @@ void free_init_pages(char *what, unsigne } } +/* +* begin/end can be in the direct map or the "high kernel mapping" +* used for the kernel image only. free_init_pages() will do the +* right thing for either kind of address. +*/ +void free_kernel_image_pages (void *begin,void *end) +{ +free_init_pages ("unused kernel image" , + (unsigned long )begin, (unsigned long )end); +} +void __ref free_initmem (void ) {e820__reallocate_tables (); -free_init_pages ("unused kernel" , - (unsigned long )(&__init_begin), - (unsigned long )(&__init_end)); +free_kernel_image_pages (&__init_begin, &__init_end); }#ifdef CONFIG_BLK_DEV_INITRD
arch/x86/mm/init_64.c +2 -2
@@ -1283,8 +1283,8 @@ void mark_rodata_ro(void)set_memory_ro (start, (end-start) >>PAGE_SHIFT );#endif -free_init_pages ("unused kernel" , text_end, rodata_start); -free_init_pages ("unused kernel" , rodata_end, _sdata); +free_kernel_image_pages ((void *)text_end, (void *)rodata_start); +free_kernel_image_pages ((void *)rodata_end, (void *)_sdata);debug_checkwx ();
Greg Kroah-Hartman
maintainerPATCH 306/324 x86/mm/init: Remove freed kernel image areas from alias mapping
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Hansen <[email protected]>
commit c40a56a7818cfe735fc93a69e1875f8bba834483 upstream.
The kernel image is mapped into two places in the virtual address space (addresses without KASLR, of course):
1. The kernel direct map (0xffff880000000000)
2. The "high kernel map" (0xffffffff81000000)
We actually execute out of #2. If we get the address of a kernel symbol, it points to #2, but almost all physical-to-virtual translations point to
Parts of the "high kernel map" alias are mapped in the userspace page tables with the Global bit for performance reasons. The parts that we map to userspace do not (er, should not) have secrets. When PTI is enabled then the global bit is usually not set in the high mapping and just used to compensate for poor performance on systems which lack PCID.
This is fine, except that some areas in the kernel image that are adjacent to the non-secret-containing areas are unused holes. We free these holes back into the normal page allocator and reuse them as normal kernel memory. The memory will, of course, get *used* via the normal map, but the alias mapping is kept.
This otherwise unused alias mapping of the holes will, by default keep the Global bit, be mapped out to userspace, and be vulnerable to Meltdown.
Remove the alias mapping of these pages entirely. This is likely to fracture the 2M page mapping the kernel image near these areas, but this should affect a minority of the area.
The pageattr code changes *all* aliases mapping the physical pages that it operates on (by default). We only want to modify a single alias, so we need to tweak its behavior.
This unmapping behavior is currently dependent on PTI being in place. Going forward, we should at least consider doing this for all configurations. Having an extra read-write alias for memory is not exactly ideal for debugging things like random memory corruption and this does undercut features like DEBUG_PAGEALLOC or future work like eXclusive Page Frame Ownership (XPFO).
Before this patch:
current_kernel:---[ High Kernel Mapping ]---
current_kernel-0xffffffff80000000-0xffffffff81000000 16M pmd current_kernel-0xffffffff81000000-0xffffffff81e00000 14M ro PSE GLB x pmd current_kernel-0xffffffff81e00000-0xffffffff81e11000 68K ro GLB x pte current_kernel-0xffffffff81e11000-0xffffffff82000000 1980K RW NX pte current_kernel-0xffffffff82000000-0xffffffff82600000 6M ro PSE GLB NX pmd current_kernel-0xffffffff82600000-0xffffffff82c00000 6M RW PSE NX pmd current_kernel-0xffffffff82c00000-0xffffffff82e00000 2M RW NX pte current_kernel-0xffffffff82e00000-0xffffffff83200000 4M RW PSE NX pmd
current_kernel-0xffffffff83200000-0xffffffffa0000000 462M pmd
current_user:---[ High Kernel Mapping ]---
current_user-0xffffffff80000000-0xffffffff81000000 16M pmd current_user-0xffffffff81000000-0xffffffff81e00000 14M ro PSE GLB x pmd current_user-0xffffffff81e00000-0xffffffff81e11000 68K ro GLB x pte
current_user-0xffffffff81e11000-0xffffffff82000000 1980K RW NX pte
current_user-0xffffffff82000000-0xffffffff82600000 6M ro PSE GLB NX pmd
current_user-0xffffffff82600000-0xffffffffa0000000 474M pmd
After this patch:
current_kernel:---[ High Kernel Mapping ]---
current_kernel-0xffffffff80000000-0xffffffff81000000 16M pmd current_kernel-0xffffffff81000000-0xffffffff81e00000 14M ro PSE GLB x pmd current_kernel-0xffffffff81e00000-0xffffffff81e11000 68K ro GLB x pte current_kernel-0xffffffff81e11000-0xffffffff82000000 1980K pte current_kernel-0xffffffff82000000-0xffffffff82400000 4M ro PSE GLB NX pmd current_kernel-0xffffffff82400000-0xffffffff82488000 544K ro NX pte current_kernel-0xffffffff82488000-0xffffffff82600000 1504K pte current_kernel-0xffffffff82600000-0xffffffff82c00000 6M RW PSE NX pmd current_kernel-0xffffffff82c00000-0xffffffff82c0d000 52K RW NX pte
current_kernel-0xffffffff82c0d000-0xffffffff82dc0000 1740K pte
current_user:---[ High Kernel Mapping ]---
current_user-0xffffffff80000000-0xffffffff81000000 16M pmd current_user-0xffffffff81000000-0xffffffff81e00000 14M ro PSE GLB x pmd current_user-0xffffffff81e00000-0xffffffff81e11000 68K ro GLB x pte current_user-0xffffffff81e11000-0xffffffff82000000 1980K pte
current_user-0xffffffff82000000-0xffffffff82400000 4M ro PSE GLB NX pmd
current_user-0xffffffff82400000-0xffffffff82488000 544K ro NX pte
current_user-0xffffffff82488000-0xffffffff82600000 1504K pte
current_user-0xffffffff82600000-0xffffffffa0000000 474M pmd
[ tglx: Do not unmap on 32bit as there is only one mapping ]
--- arch/x86/include/asm/set_memory.h | 1 + arch/x86/mm/init.c | 26 ++++++++++++++++++++++++-- arch/x86/mm/pageattr.c | 13 +++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-)
arch/x86/include/asm/set_memory.h +1 -0
@@ -46,6 +46,7 @@ int set_memory_np(unsigned long addr, inint set_memory_4k (unsigned long addr,int numpages);int set_memory_encrypted (unsigned long addr,int numpages);int set_memory_decrypted (unsigned long addr,int numpages); +int set_memory_np_noalias (unsigned long addr,int numpages);int set_memory_array_uc (unsigned long *addr,int addrinarray);int set_memory_array_wc (unsigned long *addr,int addrinarray);
arch/x86/mm/init.c +24 -2
@@ -782,8 +782,30 @@ void free_init_pages(char *what, unsigne*/ void free_kernel_image_pages (void *begin,void *end) { -free_init_pages ("unused kernel image" , - (unsigned long )begin, (unsigned long )end); +unsigned long begin_ul = (unsigned long )begin; +unsigned long end_ul = (unsigned long )end; +unsigned long len_pages = (end_ul - begin_ul) >>PAGE_SHIFT ; + + +free_init_pages ("unused kernel image" , begin_ul, end_ul); + +/* +* PTI maps some of the kernel into userspace. For performance, +* this includes some kernel areas that do not contain secrets. +* Those areas might be adjacent to the parts of the kernel image +* being freed, which may contain secrets. Remove the "high kernel +* image mapping" for these freed areas, ensuring they are not even +* potentially vulnerable to Meltdown regardless of the specific +* optimizations PTI is currently using. +* +* The "noalias" prevents unmapping the direct map alias which is +* needed to access the freed pages. +* +* This is only valid for 64bit kernels. 32bit has only one mapping +* which can't be treated in this way for obvious reasons. +*/ +if (IS_ENABLED (CONFIG_X86_64 ) &&cpu_feature_enabled (X86_FEATURE_PTI )) +set_memory_np_noalias (begin_ul, len_pages); }void __ref free_initmem (void )
arch/x86/mm/pageattr.c +13 -0
@@ -53,6 +53,7 @@ static DEFINE_SPINLOCK(cpa_lock);#define CPA_FLUSHTLB 1#define CPA_ARRAY 2#define CPA_PAGES_ARRAY 4 +#define CPA_NO_CHECK_ALIAS 8/* Do not search for aliases */ #ifdef CONFIG_PROC_FS static unsigned long direct_pages_count[PG_LEVEL_NUM ];
@@ -1486,6 +1487,9 @@ static int change_page_attr_set_clr(unsi/* No alias checking for _NX bit modifications */ checkalias = (pgprot_val (mask_set) |pgprot_val (mask_clr)) != _PAGE_NX; +/* Has caller explicitly disabled alias checking? */ +if (in_flag &CPA_NO_CHECK_ALIAS ) + checkalias =0 ; ret =__change_page_attr_set_clr (&cpa, checkalias);
@@ -1772,6 +1776,15 @@ int set_memory_np(unsigned long addr, inreturn change_page_attr_clear (&addr, numpages,__pgprot (_PAGE_PRESENT),0 ); } +int set_memory_np_noalias (unsigned long addr,int numpages) +{ +int cpa_flags =CPA_NO_CHECK_ALIAS ; + +return change_page_attr_set_clr (&addr, numpages,__pgprot (0 ), +__pgprot (_PAGE_PRESENT),0 , + cpa_flags,NULL ); +} +int set_memory_4k (unsigned long addr,int numpages) { return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
Greg Kroah-Hartman
maintainerPATCH 307/324 ext4: fix spectre gadget in ext4_mb_regular_allocator()
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Cline <[email protected]>
commit 1a5d5e5d51e75a5bca67dadbcea8c841934b7b85 upstream.
'ac->ac_g_ex.fe_len' is a user-controlled value which is used in the derivation of 'ac->ac_2order'. 'ac->ac_2order', in turn, is used to index arrays which makes it a potential spectre gadget. Fix this by sanitizing the value assigned to 'ac->ac2_order'. This covers the following accesses found with the help of smatch:
* fs/ext4/mballoc.c:1896 ext4_mb_simple_scan_group() warn: potential spectre issue 'grp->bb_counters' [w] (local cap)
* fs/ext4/mballoc.c:445 mb_find_buddy() warn: potential spectre issue 'EXT4_SB(e4b->bd_sb)->s_mb_offsets' [r] (local cap)
* fs/ext4/mballoc.c:446 mb_find_buddy() warn: potential spectre issue 'EXT4_SB(e4b->bd_sb)->s_mb_maxs' [r] (local cap)
--- fs/ext4/mballoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +3 -1
@@ -14,6 +14,7 @@#include <linux/log2.h> #include <linux/module.h> #include <linux/slab.h> +#include <linux/nospec.h> #include <linux/backing-dev.h> #include <trace/events/ext4.h>
@@ -2140,7 +2141,8 @@ ext4_mb_regular_allocator(struct ext4_al* This should tell if fe_len is exactly power of 2 */ if ((ac->ac_g_ex.fe_len & (~(1 << (i -1 )))) ==0 ) - ac->ac_2order = i -1 ; + ac->ac_2order =array_index_nospec (i -1 , + sb->s_blocksize_bits +2 ); }/* if stream allocation is enabled, use global goal */
Greg Kroah-Hartman
maintainerPATCH 308/324 drm/i915/kvmgt: Fix potential Spectre v1
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit de5372da605d3bca46e3102bab51b7e1c0e0a6f6 upstream.
info.index can be indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was detected with the help of Smatch:
drivers/gpu/drm/i915/gvt/kvmgt.c:1232 intel_vgpu_ioctl() warn:
potential spectre issue 'vgpu->vdev.region' [r]
Fix this by sanitizing info.index before indirectly using it to index vgpu->vdev.region
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
--- drivers/gpu/drm/i915/gvt/kvmgt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/kvmgt.c +8 -1
@@ -43,6 +43,8 @@#include <linux/mdev.h> #include <linux/debugfs.h> +#include <linux/nospec.h> +#include "i915_drv.h" #include "gvt.h"
@@ -1064,7 +1066,8 @@ static long intel_vgpu_ioctl(struct mdev }else if (cmd ==VFIO_DEVICE_GET_REGION_INFO ) {struct vfio_region_info info;struct vfio_info_cap caps = { .buf =NULL , .size =0 }; -int i, ret; +unsigned int i; +int ret;struct vfio_region_info_cap_sparse_mmap *sparse =NULL ;size_t size;int nr_areas =1 ;
@@ -1149,6 +1152,10 @@ static long intel_vgpu_ioctl(struct mdevif (info.index >=VFIO_PCI_NUM_REGIONS + vgpu->vdev.num_regions)return -EINVAL ; + info.index = +array_index_nospec (info.index, +VFIO_PCI_NUM_REGIONS + + vgpu->vdev.num_regions); i = info.index -VFIO_PCI_NUM_REGIONS ;
Greg Kroah-Hartman
maintainerPATCH 309/324 drm/amdgpu/pm: Fix potential Spectre v1
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit ddf74e79a54070f277ae520722d3bab7f7a6c67a upstream.
idx can be indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability.
This issue was detected with the help of Smatch:
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:408 amdgpu_set_pp_force_state()
warn: potential spectre issue 'data.states'
Fix this by sanitizing idx before using it to index data.states
Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1].
[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -1
@@ -31,7 +31,7 @@#include <linux/power_supply.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> - +#include <linux/nospec.h> static int amdgpu_debugfs_pm_init (struct amdgpu_device *adev);
@@ -309,6 +309,7 @@ static ssize_t amdgpu_set_pp_force_state count = -EINVAL ; goto fail; } + idx =array_index_nospec (idx,ARRAY_SIZE (data.states));amdgpu_dpm_get_pp_num_states (adev, &data); state = data.states[idx];
Greg Kroah-Hartman
maintainerPATCH 312/324 xfrm_user: prevent leaking 2 bytes of kernel memory
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 45c180bc29babbedd6b8c01b975780ef44d9d09c upstream.
struct xfrm_userpolicy_type has two holes, so we should not use C99 style initializer.
KMSAN report:
BUG: KMSAN: kernel-infoleak in copyout lib/iov_iter.c:140 [inline] BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571 CPU: 1 PID: 4520 Comm: syz-executor841 Not tainted 4.17.0+ #5 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+0x185/0x1d0 lib/dump_stack.c:113 kmsan_report+0x188/0x2a0 mm/kmsan/kmsan.c:1117 kmsan_internal_check_memory+0x138/0x1f0 mm/kmsan/kmsan.c:1211 kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253 copyout lib/iov_iter.c:140 [inline] _copy_to_iter+0x1b14/0x2800 lib/iov_iter.c:571 copy_to_iter include/linux/uio.h:106 [inline] skb_copy_datagram_iter+0x422/0xfa0 net/core/datagram.c:431 skb_copy_datagram_msg include/linux/skbuff.h:3268 [inline] netlink_recvmsg+0x6f1/0x1900 net/netlink/af_netlink.c:1959 sock_recvmsg_nosec net/socket.c:802 [inline] sock_recvmsg+0x1d6/0x230 net/socket.c:809 ___sys_recvmsg+0x3fe/0x810 net/socket.c:2279 __sys_recvmmsg+0x58e/0xe30 net/socket.c:2391 do_sys_recvmmsg+0x2a6/0x3e0 net/socket.c:2472 __do_sys_recvmmsg net/socket.c:2485 [inline] __se_sys_recvmmsg net/socket.c:2481 [inline] __x64_sys_recvmmsg+0x15d/0x1c0 net/socket.c:2481 do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x446ce9 RSP: 002b:00007fc307918db8 EFLAGS: 00000293 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00000000006dbc24 RCX: 0000000000446ce9 RDX: 000000000000000a RSI: 0000000020005040 RDI: 0000000000000003 RBP: 00000000006dbc20 R08: 0000000020004e40 R09: 0000000000000000 R10: 0000000040000000 R11: 0000000000000293 R12: 0000000000000000 R13: 00007ffc8d2df32f R14: 00007fc3079199c0 R15: 0000000000000001
Uninit was stored to memory at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 [inline] kmsan_save_stack mm/kmsan/kmsan.c:294 [inline] kmsan_internal_chain_origin+0x12b/0x210 mm/kmsan/kmsan.c:685 kmsan_memcpy_origins+0x11d/0x170 mm/kmsan/kmsan.c:527 __msan_memcpy+0x109/0x160 mm/kmsan/kmsan_instr.c:413 __nla_put lib/nlattr.c:569 [inline] nla_put+0x276/0x340 lib/nlattr.c:627 copy_to_user_policy_type net/xfrm/xfrm_user.c:1678 [inline] dump_one_policy+0xbe1/0x1090 net/xfrm/xfrm_user.c:1708 xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013 xfrm_dump_policy+0x1c0/0x2a0 net/xfrm/xfrm_user.c:1749 netlink_dump+0x9b5/0x1550 net/netlink/af_netlink.c:2226 __netlink_dump_start+0x1131/0x1270 net/netlink/af_netlink.c:2323 netlink_dump_start include/linux/netlink.h:214 [inline] xfrm_user_rcv_msg+0x8a3/0x9b0 net/xfrm/xfrm_user.c:2577 netlink_rcv_skb+0x37e/0x600 net/netlink/af_netlink.c:2448 xfrm_netlink_rcv+0xb2/0xf0 net/xfrm/xfrm_user.c:2598 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] netlink_unicast+0x1680/0x1750 net/netlink/af_netlink.c:1336 netlink_sendmsg+0x104f/0x1350 net/netlink/af_netlink.c:1901 sock_sendmsg_nosec net/socket.c:629 [inline] sock_sendmsg net/socket.c:639 [inline] ___sys_sendmsg+0xec8/0x1320 net/socket.c:2117 __sys_sendmsg net/socket.c:2155 [inline] __do_sys_sendmsg net/socket.c:2164 [inline] __se_sys_sendmsg net/socket.c:2162 [inline] __x64_sys_sendmsg+0x331/0x460 net/socket.c:2162 do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Local variable description: ----upt.i@dump_one_policy Variable was created at: dump_one_policy+0x78/0x1090 net/xfrm/xfrm_user.c:1689 xfrm_policy_walk+0x45a/0xd00 net/xfrm/xfrm_policy.c:1013
Byte 130 of 137 is uninitialized
Memory access starts at ffff88019550407f
--- net/xfrm/xfrm_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/xfrm/xfrm_user.c +5 -3
@@ -1671,9 +1671,11 @@ static inline unsigned int userpolicy_ty#ifdef CONFIG_XFRM_SUB_POLICY static int copy_to_user_policy_type (u8 type,struct sk_buff *skb) { -struct xfrm_userpolicy_type upt = { - .type = type, - }; +struct xfrm_userpolicy_type upt; + +/* Sadly there are two holes in struct xfrm_userpolicy_type */ +memset (&upt,0 ,sizeof (upt)); + upt.type = type;return nla_put (skb,XFRMA_POLICY_TYPE ,sizeof (upt), &upt); }
Greg Kroah-Hartman
maintainerPATCH 313/324 netfilter: conntrack: dccp: treat SYNC/SYNCACK as invalid if no prior state
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 6613b6173dee098997229caf1f3b961c49da75e6 upstream.
When first DCCP packet is SYNC or SYNCACK, we insert a new conntrack that has an un-initialized timeout value, i.e. such entry could be reaped at any time.
Mark them as INVALID and only ignore SYNC/SYNCACK when connection had an old state.
--- net/netfilter/nf_conntrack_proto_dccp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_proto_dccp.c +4 -4
@@ -243,14 +243,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][D* We currently ignore Sync packets * * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG, }, [DCCP_PKT_SYNCACK] = {/* * We currently ignore SyncAck packets * * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG, }, }, [CT_DCCP_ROLE_SERVER] = {
@@ -371,14 +371,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][D* We currently ignore Sync packets * * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG, }, [DCCP_PKT_SYNCACK] = {/* * We currently ignore SyncAck packets * * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ - sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, + sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG, }, }, };
Greg Kroah-Hartman
maintainerPATCH 314/324 packet: refine ring v3 block size test to hold one frame
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
commit 4576cd469d980317c4edd9173f8b694aa71ea3a3 upstream.
TPACKET_V3 stores variable length frames in fixed length blocks. Blocks must be able to store a block header, optional private space and at least one minimum sized frame.
Frames, even for a zero snaplen packet, store metadata headers and optional reserved space.
In the block size bounds check, ensure that the frame of the chosen configuration fits. This includes sockaddr_ll and optional tp_reserve.
Syzbot was able to construct a ring with insuffient room for the sockaddr_ll in the header of a zero-length frame, triggering an out-of-bounds write in dev_parse_header.
Convert the comparison to less than, as zero is a valid snap len. This matches the test for minimum tp_frame_size immediately below.
--- net/packet/af_packet.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/packet/af_packet.c +6 -4
@@ -4258,6 +4258,8 @@ static int packet_set_ring(struct sock * }if (req->tp_block_nr) { +unsigned int min_frame_size; +/* Sanity tests and some calculations */ err = -EBUSY ;if (unlikely (rb->pg_vec))
@@ -4280,12 +4282,12 @@ static int packet_set_ring(struct sock * goto out;if (unlikely (!PAGE_ALIGNED (req->tp_block_size))) goto out; + min_frame_size = po->tp_hdrlen + po->tp_reserve;if (po->tp_version >=TPACKET_V3 && - req->tp_block_size <= -BLK_PLUS_PRIV ((u64 )req_u->req3.tp_sizeof_priv) +sizeof (struct tpacket3_hdr )) + req->tp_block_size < +BLK_PLUS_PRIV ((u64 )req_u->req3.tp_sizeof_priv) + min_frame_size) goto out; -if (unlikely (req->tp_frame_size < po->tp_hdrlen + - po->tp_reserve)) +if (unlikely (req->tp_frame_size < min_frame_size)) goto out;if (unlikely (req->tp_frame_size & (TPACKET_ALIGNMENT -1 ))) goto out;
Greg Kroah-Hartman
maintainerPATCH 315/324 net/smc: no shutdown in state SMC_LISTEN
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ursula Braun <[email protected]>
commit caa21e19e08d7a1445116a93f7ab4e187ebbbadb upstream.
Invoking shutdown for a socket in state SMC_LISTEN does not make sense. Nevertheless programs like syzbot fuzzing the kernel may try to do this. For SMC this means a socket refcounting problem. This patch makes sure a shutdown call for an SMC socket in state SMC_LISTEN simply returns with -ENOTCONN.
--- net/smc/af_smc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/smc/af_smc.c +1 -2
@@ -1231,8 +1231,7 @@ static int smc_shutdown(struct socket *slock_sock (sk); rc = -ENOTCONN ; - if ((sk->sk_state != SMC_LISTEN) && - (sk->sk_state != SMC_ACTIVE) && + if ((sk->sk_state != SMC_ACTIVE) && (sk->sk_state != SMC_PEERCLOSEWAIT1) && (sk->sk_state != SMC_PEERCLOSEWAIT2) && (sk->sk_state != SMC_APPCLOSEWAIT1) &&
Greg Kroah-Hartman
maintainerPATCH 317/324 PCI / ACPI / PM: Resume all bridges on suspend-to-RAM
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 9d64b539b738fc181442caab95f1f76d9bd58539 upstream.
Commit 26112ddc254c (PCI / ACPI / PM: Resume bridges w/o drivers on suspend-to-RAM) attempted to fix a functional regression resulting from commit c62ec4610c40 (PM / core: Fix direct_complete handling for devices with no callbacks) by resuming PCI bridges without drivers (that is, "parallel PCI" ones) during system-wide suspend if the target system state is not ACPI S0 (working state).
That turns out insufficient, however, as it is reported that, at least in one case, the platform firmware gets confused if a PCIe root port is suspended before entering the ACPI S3 sleep state. That issue was exposed by commit 77b3729ca03 (PCI / PM: Use SMART_SUSPEND and LEAVE_SUSPENDED flags for PCIe ports) that allowed PCIe ports to stay in runtime suspend during system-wide suspend (which is OK for suspend-to-idle, but turns out to be problematic otherwise).
For this reason, drop the driver check from acpi_pci_need_resume() and resume all bridges (including PCIe ports with drivers) during system-wide suspend if the target system state is not ACPI S0.
[If the target system state is ACPI S0, it means suspend-to-idle
and the platform firmware is not going to be invoked to actually suspend the system, so there is no need to resume the bridges in that case.]
--- drivers/pci/pci-acpi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/pci-acpi.c +2 -4
@@ -601,13 +601,11 @@ static bool acpi_pci_need_resume(struct/* * In some cases (eg. Samsung 305V4A) leaving a bridge in suspend over * system-wide suspend/resume confuses the platform firmware, so avoid -* doing that, unless the bridge has a driver that should take care of -* the PM handling. According to Section 16.1.6 of ACPI 6.2, endpoint +* doing that. According to Section 16.1.6 of ACPI 6.2, endpoint * devices are expected to be in D3 before invoking the S3 entry path * from the firmware, so they should not be affected by this issue. */ -if (pci_is_bridge (dev) && !dev->driver && -acpi_target_system_state () !=ACPI_STATE_S0 ) +if (pci_is_bridge (dev) &&acpi_target_system_state () !=ACPI_STATE_S0 )return true;if (!adev || !acpi_device_power_manageable (adev))
Greg Kroah-Hartman
maintainerPATCH 318/324 PCI: hotplug: Dont leak pci_slot on registration failure
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 4ce6435820d1f1cc2c2788e232735eb244bcc8a3 upstream.
If addition of sysfs files fails on registration of a hotplug slot, the struct pci_slot as well as the entry in the slot_list is leaked. The issue has been present since the hotplug core was introduced in 2002:
https://git.kernel.org/tglx/history/c/a8a2069f432c
Perhaps the idea was that even though sysfs addition fails, the slot should still be usable. But that's not how drivers use the interface, they abort probe if a non-zero value is returned.
--- drivers/pci/hotplug/pci_hotplug_core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pci/hotplug/pci_hotplug_core.c +9 -0
@@ -438,8 +438,17 @@ int __pci_hp_register(struct hotplug_slolist_add (&slot->slot_list, &pci_hotplug_slot_list); result =fs_add_slot (pci_slot); +if (result) + goto err_list_del; +kobject_uevent (&pci_slot->kobj,KOBJ_ADD );dbg ("Added slot %s to the list\n" , name); + goto out; + +err_list_del: +list_del (&slot->slot_list); + pci_slot->hotplug =NULL ; +pci_destroy_slot (pci_slot); out:mutex_unlock (&pci_hp_mutex);return result;
Greg Kroah-Hartman
maintainerPATCH 319/324 PCI: Skip MPS logic for Virtual Functions (VFs)
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myron Stowe <[email protected]>
commit 3dbe97efe8bf450b183d6dee2305cbc032e6b8a4 upstream.
PCIe r4.0, sec 9.3.5.4, "Device Control Register", shows both Max_Payload_Size (MPS) and Max_Read_request_Size (MRRS) to be 'RsvdP' for VFs. Just prior to the table it states:
"PF and VF functionality is defined in Section 7.5.3.4 except where
noted in Table 9-16. For VF fields marked 'RsvdP', the PF setting applies to the VF."
All of which implies that with respect to Max_Payload_Size Supported (MPSS), MPS, and MRRS values, we should not be paying any attention to the VF's fields, but rather only to the PF's. Only looking at the PF's fields also logically makes sense as it's the sole physical interface to the PCIe bus.
--- drivers/pci/probe.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/probe.c +4 -0
@@ -1677,6 +1677,10 @@ static void pci_configure_mps(struct pciif (!pci_is_pcie (dev) || !bridge || !pci_is_pcie (bridge))return ; +/* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */ +if (dev->is_virtfn) +return ; + mps =pcie_get_mps (dev); p_mps =pcie_get_mps (bridge);
Greg Kroah-Hartman
maintainerPATCH 320/324 PCI: pciehp: Fix use-after-free on unplug
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 281e878eab191cce4259abbbf1a0322e3adae02c upstream.
When pciehp is unbound (e.g. on unplug of a Thunderbolt device), the hotplug_slot struct is deregistered and thus freed before freeing the IRQ. The IRQ handler and the work items it schedules print the slot name referenced from the freed structure in various informational and debug log messages, each time resulting in a quadruple dereference of freed pointers (hotplug_slot -> pci_slot -> kobject -> name).
At best the slot name is logged as "(null)", at worst kernel memory is exposed in logs or the driver crashes:
pciehp 0000:10:00.0:pcie204: Slot((null)): Card not present
An attacker may provoke the bug by unplugging multiple devices on a Thunderbolt daisy chain at once. Unplugging can also be simulated by powering down slots via sysfs. The bug is particularly easy to trigger in poll mode.
It has been present since the driver's introduction in 2004:
https://git.kernel.org/tglx/history/c/c16b4b14d980
Fix by rearranging teardown such that the IRQ is freed first. Run the work items queued by the IRQ handler to completion before freeing the hotplug_slot struct by draining the work queue from the ->release_slot callback which is invoked by pci_hp_deregister().
--- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_core.c | 7 +++++++ drivers/pci/hotplug/pciehp_hpc.c | 5 ++--- 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/pci/hotplug/pciehp.h +1 -0
@@ -119,6 +119,7 @@ int pciehp_unconfigure_device(struct slovoid pciehp_queue_pushbutton_work (struct work_struct *work);struct controller *pcie_init (struct pcie_device *dev);int pcie_init_notification (struct controller *ctrl); +void pcie_shutdown_notification (struct controller *ctrl);int pciehp_enable_slot (struct slot *p_slot);int pciehp_disable_slot (struct slot *p_slot);void pcie_reenable_notification (struct controller *ctrl);
drivers/pci/hotplug/pciehp_core.c +7 -0
@@ -62,6 +62,12 @@ static int reset_slot(struct hotplug_slo*/ static void release_slot (struct hotplug_slot *hotplug_slot) { +struct slot *slot = hotplug_slot->private; + +/* queued work needs hotplug_slot name */ +cancel_delayed_work (&slot->work); +drain_workqueue (slot->wq); +kfree (hotplug_slot->ops);kfree (hotplug_slot->info);kfree (hotplug_slot);
@@ -264,6 +270,7 @@ static void pciehp_remove(struct pcie_de {struct controller *ctrl =get_service_data (dev); +pcie_shutdown_notification (ctrl);cleanup_slot (ctrl);pciehp_release_ctrl (ctrl); }
drivers/pci/hotplug/pciehp_hpc.c +2 -3
@@ -771,7 +771,7 @@ int pcie_init_notification(struct controreturn 0 ; } -static void pcie_shutdown_notification (struct controller *ctrl) +void pcie_shutdown_notification (struct controller *ctrl) {if (ctrl->notification_enabled) {pcie_disable_notification (ctrl);
@@ -806,7 +806,7 @@ abort:static void pcie_cleanup_slot (struct controller *ctrl) {struct slot *slot = ctrl->slot; -cancel_delayed_work (&slot->work); +destroy_workqueue (slot->wq);kfree (slot); }
@@ -898,7 +898,6 @@ abort:void pciehp_release_ctrl (struct controller *ctrl) { -pcie_shutdown_notification (ctrl);pcie_cleanup_slot (ctrl);kfree (ctrl); }
Greg Kroah-Hartman
maintainerPATCH 321/324 PCI: pciehp: Fix unprotected list iteration in IRQ handler
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 1204e35bedf4e5015cda559ed8c84789a6dae24e upstream.
Commit b440bde74f04 ("PCI: Add pci_ignore_hotplug() to ignore hotplug events for a device") iterates over the devices on a hotplug port's subordinate bus in pciehp's IRQ handler without acquiring pci_bus_sem. It is thus possible for a user to cause a crash by concurrently manipulating the device list, e.g. by disabling slot power via sysfs on a different CPU or by initiating a remove/rescan via sysfs.
This can't be fixed by acquiring pci_bus_sem because it may sleep. The simplest fix is to avoid the list iteration altogether and just check the ignore_hotplug flag on the port itself. This works because pci_ignore_hotplug() sets the flag both on the device as well as on its parent bridge.
We do lose the ability to print the name of the device blocking hotplug in the debug message, but that's probably bearable.
--- drivers/pci/hotplug/pciehp_hpc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +3 -10
@@ -545,8 +545,6 @@ static irqreturn_t pciehp_isr(int irq, v {struct controller *ctrl = (struct controller *)dev_id;struct pci_dev *pdev =ctrl_dev (ctrl); -struct pci_bus *subordinate = pdev->subordinate; -struct pci_dev *dev;struct slot *slot = ctrl->slot;u16 status, events;u8 present;
@@ -594,14 +592,9 @@ static irqreturn_t pciehp_isr(int irq, vwake_up (&ctrl->queue); } -if (subordinate) { -list_for_each_entry (dev, &subordinate->devices, bus_list) { -if (dev->ignore_hotplug) { -ctrl_dbg (ctrl,"ignoring hotplug event %#06x (%s requested no hotplug)\n" , - events,pci_name (dev)); -return IRQ_HANDLED ; - } - } +if (pdev->ignore_hotplug) { +ctrl_dbg (ctrl,"ignoring hotplug event %#06x\n" , events); +return IRQ_HANDLED ; }/* Check Attention Button Pressed */
Greg Kroah-Hartman
maintainerPATCH 322/324 i2c: core: ACPI: Properly set status byte to 0 for multi-byte writes
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit c463a158cb6c5d9a85b7d894cd4f8116e8bd6be0 upstream.
acpi_gsb_i2c_write_bytes() returns i2c_transfer()'s return value, which is the number of transfers executed on success, so 1.
The ACPI code expects us to store 0 in gsb->status for success, not 1.
Specifically this breaks the following code in the Thinkpad 8 DSDT:
ECWR = I2CW = ECWR /* \_SB_.I2C1.BAT0.ECWR */
If ((ECST == Zero))
{
ECRD = I2CR /* \_SB_.I2C1.I2CR */
}Before this commit we set ECST to 1, causing the read to never happen breaking battery monitoring on the Thinkpad 8.
This commit makes acpi_gsb_i2c_write_bytes() return 0 when i2c_transfer() returns 1, so the single write transfer completed successfully, and makes it return -EIO on for other (unexpected) return values >= 0.
--- drivers/i2c/i2c-core-acpi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/i2c/i2c-core-acpi.c +8 -3
@@ -482,11 +482,16 @@ static int acpi_gsb_i2c_write_bytes(stru msgs[0 ].buf = buffer; ret =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs)); -if (ret <0 ) -dev_err (&client->adapter->dev,"i2c write failed\n" );kfree (buffer); -return ret; + +if (ret <0 ) { +dev_err (&client->adapter->dev,"i2c write failed: %d\n" , ret); +return ret; + } + +/* 1 transfer must have completed successfully */ +return (ret ==1 ) ?0 : -EIO ; } static acpi_status
Greg Kroah-Hartman
maintainerPATCH 324/324 reiserfs: fix broken xattr handling (heap corruption, bad retval)
In reply to Greg Kroah-Hartman4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit a13f085d111e90469faf2d9965eb39b11c114d7e upstream.
This fixes the following issues:
- When a buffer size is supplied to reiserfs_listxattr() such that each individual name fits, but the concatenation of all names doesn't fit, reiserfs_listxattr() overflows the supplied buffer. This leads to a kernel heap overflow (verified using KASAN) followed by an out-of-bounds usercopy and is therefore a security bug.
- When a buffer size is supplied to reiserfs_listxattr() such that a name doesn't fit, -ERANGE should be returned. But reiserfs instead just truncates the list of names; I have verified that if the only xattr on a file has a longer name than the supplied buffer length, listxattr() incorrectly returns zero.
With my patch applied, -ERANGE is returned in both cases and the memory corruption doesn't happen anymore.
Credit for making me clean this code up a bit goes to Al Viro, who pointed out that the ->actor calling convention is suboptimal and should be changed.
--- fs/reiserfs/xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/reiserfs/xattr.c +3 -1
@@ -792,8 +792,10 @@ static int listxattr_filler(struct dir_creturn 0 ; size = namelen +1 ;if (b->buf) { -if (size > b->size) +if (b->pos + size > b->size) { + b->pos = -ERANGE ;return -ERANGE ; + }memcpy (b->buf + b->pos, name, namelen); b->buf[b->pos + namelen] =0 ; }
Quoted 13 lines · Greg Kroah-Hartman
NOTE, this is going to be the LAST 4.17.y kernel release. Please move to the 4.18.y tree at this point in time if you have not already. After this release, 4.17.y will be end-of-life.
This is the start of the stable review cycle for the 4.17.19 release. There are 324 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 Sat Aug 25 07:48:40 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.17.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.17.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 4 lines · Greg Kroah-Hartman
NOTE, this is going to be the LAST 4.17.y kernel release. Please move to the 4.18.y tree at this point in time if you have not already. After this release, 4.17.y will be end-of-life.
Quoted 8 lines
This is the start of the stable review cycle for the 4.17.19 release. There are 324 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 Sat Aug 25 07:48:40 UTC 2018. Anything received after that time might be too late.
Build results:
total: 134 pass: 134 fail: 0 Qemu test results: total: 302 pass: 302 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Quoted 13 lines · Greg Kroah-Hartman
NOTE, this is going to be the LAST 4.17.y kernel release. Please move to the 4.18.y tree at this point in time if you have not already. After this release, 4.17.y will be end-of-life.
This is the start of the stable review cycle for the 4.17.19 release. There are 324 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 Sat Aug 25 07:48:40 UTC 2018. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.17.19-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.17.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm and x86_64.
Summary
------------------------------------------------------------------------
kernel: 4.17.19-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.17.y
git commit: 0314fad8be8cd755a7b9c59f9c4441bb6b9c29e6
git describe: v4.17.18-325-g0314fad8be8c
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.17-oe/build/v4.17.18-325-g0314fad8be8c
No regressions (compared to build v4.17.17)
Ran 12244 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- juno-r2 - arm64
- x15 - arm
- x86_64
Test Suites
-----------
* boot
* kselftest
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-containers-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-timers-tests
* ltp-cve-tests
* ltp-open-posix-tests
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org