4.14.153-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 4.14.153-stable review
This is the start of the stable review cycle for the 4.14.153 release. There are 62 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 Sun 10 Nov 2019 05:42:11 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.153-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.153-rc1
Desnes A. Nunes do Rosario <[email protected]>
selftests/powerpc: Fix compile error on tlbie_test due to newer gcc
Aneesh Kumar K.V <[email protected]>
selftests/powerpc: Add test case for tlbie vs mtpidr ordering issue
Aneesh Kumar K.V <[email protected]>
powerpc/mm: Fixup tlbie vs mtpidr/mtlpidr ordering issue on POWER9
Aneesh Kumar K.V <[email protected]>
powerpc/book3s64/radix: Rename CPU_FTR_P9_TLBIE_BUG feature flag
Aneesh Kumar K.V <[email protected]>
powerpc/book3s64/mm: Don't do tlbie fixup for some hardware revisions
Aneesh Kumar K.V <[email protected]>
powerpc/mm: Fixup tlbie vs store ordering issue on POWER9
Fabrice Gasnier <[email protected]>
iio: adc: stm32-adc: fix a race when using several adcs with dma and irq
Fabrice Gasnier <[email protected]>
iio: adc: stm32-adc: move registers definitions
Jan Kiszka <[email protected]>
platform/x86: pmc_atom: Add Siemens SIMATIC IPC227E to critclk_systems DMI table
Seth Forshee <[email protected]>
kbuild: add -fcf-protection=none when using retpoline flags
Masahiro Yamada <[email protected]>
kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
Peter Zijlstra <[email protected]>
sched/wake_q: Fix wakeup ordering for wake_q
Jeffrey Hugo <[email protected]>
dmaengine: qcom: bam_dma: Fix resource leak
Eric Dumazet <[email protected]>
net/flow_dissector: switch to siphash
Eric Dumazet <[email protected]>
inet: stop leaking jiffies on the wire
Xin Long <[email protected]>
erspan: fix the tun_info options_len check for erspan
Xin Long <[email protected]>
vxlan: check tun_info options_len properly
Eric Dumazet <[email protected]>
net: use skb_queue_empty_lockless() in busy poll contexts
Eric Dumazet <[email protected]>
net: use skb_queue_empty_lockless() in poll() handlers
Eric Dumazet <[email protected]>
udp: use skb_queue_empty_lockless()
Eric Dumazet <[email protected]>
net: add skb_queue_empty_lockless()
Doug Berger <[email protected]>
net: bcmgenet: reset 40nm EPHY on energy detect
Vivien Didelot <[email protected]>
net: dsa: fix switch tree list
Kazutoshi Noguchi <[email protected]>
r8152: add device id for Lenovo ThinkPad USB-C Dock Gen 2
Andrew Lunn <[email protected]>
net: usb: lan78xx: Connect PHY before registering MAC
Florian Fainelli <[email protected]>
net: dsa: b53: Do not clear existing mirrored port mask
Maxim Mikityanskiy <[email protected]>
net/mlx5e: Fix handling of compressed CQEs in case of low NAPI budget
Eric Dumazet <[email protected]>
net: add READ_ONCE() annotation in __skb_wait_for_more_packets()
Eric Dumazet <[email protected]>
udp: fix data-race in udp_set_dev_scratch()
Wei Wang <[email protected]>
selftests: net: reuseport_dualstack: fix uninitalized parameter
zhanglin <[email protected]>
net: Zeroing the structure ethtool_wolinfo in ethtool_get_wol()
Eran Ben Elisha <[email protected]>
net/mlx4_core: Dynamically set guaranteed amount of counters per VF
Jiangfeng Xiao <[email protected]>
net: hisilicon: Fix ping latency when deal with high throughput
Tejun Heo <[email protected]>
net: fix sk_page_frag() recursion from memory reclaim
Benjamin Herrenschmidt <[email protected]>
net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum
Florian Fainelli <[email protected]>
net: dsa: bcm_sf2: Fix IMP setup for port different than 8
Eric Dumazet <[email protected]>
net: annotate lockless accesses to sk->sk_napi_id
Eric Dumazet <[email protected]>
net: annotate accesses to sk->sk_incoming_cpu
Eric Dumazet <[email protected]>
dccp: do not leak jiffies on the wire
Vishal Kulkarni <[email protected]>
cxgb4: fix panic when attaching to ULD fail
Josef Bacik <[email protected]>
nbd: handle racing with error'ed out commands
Dave Wysochanski <[email protected]>
cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs
Alain Volmat <[email protected]>
i2c: stm32f7: remove warning when compiling with W=1
Jonas Gorski <[email protected]>
MIPS: bmips: mark exception vectors as char arrays
Navid Emamdoost <[email protected]>
of: unittest: fix memory leak in unittest_data_add
afzal mohammed <[email protected]>
ARM: 8926/1: v7m: remove register save to stack before svc
Bodo Stroesser <[email protected]>
scsi: target: core: Do not overwrite CDB byte 1
Peter Ujfalusi <[email protected]>
ARM: davinci: dm365: Fix McBSP dma_slave_map entry
Yunfeng Ye <[email protected]>
perf kmem: Fix memory leak in compact_gfp_flags()
Yunfeng Ye <[email protected]>
perf c2c: Fix memory leak in build_cl_output()
Anson Huang <[email protected]>
ARM: dts: imx7s: Correct GPT's ipg clock source
Thomas Bogendoerfer <[email protected]>
scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE
Thomas Bogendoerfer <[email protected]>
scsi: sni_53c710: fix compilation error
Hannes Reinecke <[email protected]>
scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions
Russell King <[email protected]>
ARM: mm: fix alignment handler faults under memory pressure
Dan Carpenter <[email protected]>
pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable()
Adam Ford <[email protected]>
ARM: dts: logicpd-torpedo-som: Remove twl_keypad
Robin Murphy <[email protected]>
ASoc: rockchip: i2s: Fix RPM imbalance
Stuart Henderson <[email protected]>
ASoC: wm_adsp: Don't generate kcontrols without READ flags
Yizhuo <[email protected]>
regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized
Axel Lin <[email protected]>
regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone
Rayagonda Kokatanur <[email protected]>
arm64: dts: Fix gpio to pinmux mapping
-------------
Diffstat:
Makefile | 13 +- arch/arm/boot/dts/imx7s.dtsi | 8 +- arch/arm/boot/dts/logicpd-torpedo-som.dtsi | 4 + arch/arm/mach-davinci/dm365.c | 4 +- arch/arm/mm/alignment.c | 44 +- arch/arm/mm/proc-v7m.S | 1 - .../dts/broadcom/stingray/stingray-pinctrl.dtsi | 5 +- .../arm64/boot/dts/broadcom/stingray/stingray.dtsi | 3 +- arch/mips/bcm63xx/prom.c | 2 +- arch/mips/include/asm/bmips.h | 10 +- arch/mips/kernel/smp-bmips.c | 8 +- arch/powerpc/include/asm/cputable.h | 5 +- arch/powerpc/kernel/dt_cpu_ftrs.c | 32 +- arch/powerpc/kvm/book3s_64_mmu_radix.c | 3 + arch/powerpc/kvm/book3s_hv_rm_mmu.c | 33 + arch/powerpc/mm/hash_native_64.c | 38 +- arch/powerpc/mm/pgtable_64.c | 1 + arch/powerpc/mm/tlb-radix.c | 94 ++- drivers/block/nbd.c | 6 + drivers/dma/qcom/bam_dma.c | 14 + drivers/i2c/busses/i2c-stm32f7.c | 2 +- drivers/iio/adc/stm32-adc-core.c | 70 +- drivers/iio/adc/stm32-adc-core.h | 135 ++++ drivers/iio/adc/stm32-adc.c | 107 --- drivers/isdn/capi/capi.c | 2 +- drivers/net/dsa/b53/b53_common.c | 1 - drivers/net/dsa/bcm_sf2.c | 36 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 29 +- drivers/net/ethernet/faraday/ftgmac100.c | 25 +- drivers/net/ethernet/hisilicon/hip04_eth.c | 15 +- .../net/ethernet/mellanox/mlx4/resource_tracker.c | 42 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 5 +- drivers/net/usb/cdc_ether.c | 7 + drivers/net/usb/lan78xx.c | 12 +- drivers/net/usb/r8152.c | 1 + drivers/net/vxlan.c | 5 +- drivers/of/unittest.c | 1 + drivers/pinctrl/bcm/pinctrl-ns2-mux.c | 4 +- drivers/platform/x86/pmc_atom.c | 7 + drivers/regulator/pfuze100-regulator.c | 8 +- drivers/regulator/ti-abb-regulator.c | 26 +- drivers/scsi/Kconfig | 2 +- drivers/scsi/device_handler/scsi_dh_alua.c | 21 +- drivers/scsi/sni_53c710.c | 4 +- drivers/target/target_core_device.c | 21 - fs/cifs/cifsglob.h | 5 + fs/cifs/cifsproto.h | 1 + fs/cifs/file.c | 23 +- fs/cifs/smb2file.c | 2 +- include/linux/gfp.h | 23 + include/linux/skbuff.h | 36 +- include/net/busy_poll.h | 6 +- include/net/flow_dissector.h | 3 +- include/net/fq.h | 2 +- include/net/fq_impl.h | 4 +- include/net/sock.h | 15 +- kernel/sched/core.c | 7 +- net/atm/common.c | 2 +- net/bluetooth/af_bluetooth.c | 4 +- net/caif/caif_socket.c | 2 +- net/core/datagram.c | 8 +- net/core/ethtool.c | 4 +- net/core/flow_dissector.c | 48 +- net/core/sock.c | 6 +- net/dccp/ipv4.c | 4 +- net/dsa/dsa2.c | 2 +- net/ipv4/datagram.c | 2 +- net/ipv4/inet_hashtables.c | 2 +- net/ipv4/ip_gre.c | 3 + net/ipv4/tcp.c | 4 +- net/ipv4/tcp_ipv4.c | 4 +- net/ipv4/udp.c | 29 +- net/ipv6/inet6_hashtables.c | 2 +- net/ipv6/udp.c | 2 +- net/nfc/llcp_sock.c | 4 +- net/phonet/socket.c | 4 +- net/sched/sch_hhf.c | 8 +- net/sched/sch_sfb.c | 13 +- net/sched/sch_sfq.c | 14 +- net/sctp/socket.c | 8 +- net/tipc/socket.c | 4 +- net/unix/af_unix.c | 6 +- net/vmw_vsock/af_vsock.c | 2 +- sound/soc/codecs/wm_adsp.c | 3 +- sound/soc/rockchip/rockchip_i2s.c | 2 +- tools/perf/builtin-c2c.c | 14 +- tools/perf/builtin-kmem.c | 1 + tools/testing/selftests/net/reuseport_dualstack.c | 3 +- tools/testing/selftests/powerpc/mm/Makefile | 2 + tools/testing/selftests/powerpc/mm/tlbie_test.c | 734 +++++++++++++++++++++ 91 files changed, 1557 insertions(+), 445 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/62 arm64: dts: Fix gpio to pinmux mapping
From: Rayagonda Kokatanur <[email protected]>
[ Upstream commit 965f6603e3335a953f4f876792074cb36bf65f7f ]
There are total of 151 non-secure gpio (0-150) and four pins of pinmux (91, 92, 93 and 94) are not mapped to any gpio pin, hence update same in DT.
--- arch/arm64/boot/dts/broadcom/stingray/stingray-pinctrl.dtsi | 5 +++-- arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/broadcom/stingray/stingray-pinctrl.dtsi +3 -2
@@ -42,13 +42,14 @@ pinmux: pinmux@0014029c { compatible = "pinctrl-single"; - reg = <0x0014029c 0x250>; + reg = <0x0014029c 0x26c>; #address-cells = <1>; #size-cells = <1>; pinctrl-single,register-width = <32>; pinctrl-single,function-mask = <0xf>; pinctrl-single,gpio-range = < - &range 0 154 MODE_GPIO + &range 0 91 MODE_GPIO + &range 95 60 MODE_GPIO >; range: gpio-range { #pinctrl-single,gpio-range-cells = <3>;
arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi +1 -2
@@ -444,8 +444,7 @@ <&pinmux 108 16 27>, <&pinmux 135 77 6>, <&pinmux 141 67 4>, - <&pinmux 145 149 6>, - <&pinmux 151 91 4>; + <&pinmux 145 149 6>; }; i2c1: i2c@000e0000 {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 2/62 regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone
In reply to Greg Kroah-HartmanFrom: Axel Lin <[email protected]>
[ Upstream commit f64db548799e0330897c3203680c2ee795ade518 ]
ti_abb_wait_txdone() may return -ETIMEDOUT when ti_abb_check_txdone() returns true in the latest iteration of the while loop because the timeout value is abb->settling_time + 1. Similarly, ti_abb_clear_all_txdone() may return -ETIMEDOUT when ti_abb_check_txdone() returns false in the latest iteration of the while loop. Fix it.
--- drivers/regulator/ti-abb-regulator.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
drivers/regulator/ti-abb-regulator.c +8 -18
@@ -173,19 +173,14 @@ static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb)while (timeout++ <= abb->settling_time) { status =ti_abb_check_txdone (abb);if (status) -break ; +return 0 ;udelay (1 ); } -if (timeout > abb->settling_time) { -dev_warn_ratelimited (dev, -"%s:TRANXDONE timeout(%duS) int=0x%08x\n" , - __func__, timeout,readl (abb->int_base)); -return -ETIMEDOUT ; - } - -return 0 ; +dev_warn_ratelimited (dev,"%s:TRANXDONE timeout(%duS) int=0x%08x\n" , + __func__, timeout,readl (abb->int_base)); +return -ETIMEDOUT ; }/**
@@ -205,19 +200,14 @@ static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb) status =ti_abb_check_txdone (abb);if (!status) -break ; +return 0 ;udelay (1 ); } -if (timeout > abb->settling_time) { -dev_warn_ratelimited (dev, -"%s:TRANXDONE timeout(%duS) int=0x%08x\n" , - __func__, timeout,readl (abb->int_base)); -return -ETIMEDOUT ; - } - -return 0 ; +dev_warn_ratelimited (dev,"%s:TRANXDONE timeout(%duS) int=0x%08x\n" , + __func__, timeout,readl (abb->int_base)); +return -ETIMEDOUT ; }/**
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 3/62 regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized
In reply to Greg Kroah-HartmanFrom: Yizhuo <[email protected]>
[ Upstream commit 1252b283141f03c3dffd139292c862cae10e174d ]
In function pfuze100_regulator_probe(), variable "val" could be initialized if regmap_read() fails. However, "val" is used to decide the control flow later in the if statement, which is potentially unsafe.
--- drivers/regulator/pfuze100-regulator.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/regulator/pfuze100-regulator.c +7 -1
@@ -632,7 +632,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client,/* SW2~SW4 high bit check and modify the voltage value table */ if (i >= sw_check_start && i <= sw_check_end) { -regmap_read (pfuze_chip->regmap, desc->vsel_reg, &val); + ret =regmap_read (pfuze_chip->regmap, + desc->vsel_reg, &val); +if (ret) { +dev_err (&client->dev,"Fails to read from the register.\n" ); +return ret; + } +if (val & sw_hi) {if (pfuze_chip->chip_id ==PFUZE3000 ) { desc->volt_table = pfuze3000_sw2hi;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 4/62 ASoC: wm_adsp: Dont generate kcontrols without READ flags
In reply to Greg Kroah-HartmanFrom: Stuart Henderson <[email protected]>
[ Upstream commit 3ae7359c0e39f42a96284d6798fc669acff38140 ]
User space always expects to be able to read ALSA controls, so ensure no kcontrols are generated without an appropriate READ flag. In the case of a read of such a control zeros will be returned.
--- sound/soc/codecs/wm_adsp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +1 -2
@@ -1169,8 +1169,7 @@ static unsigned int wmfw_convert_flags(unsigned int in, unsigned int len) }if (in) { -if (in &WMFW_CTL_FLAG_READABLE ) - out |= rd; + out |= rd;if (in &WMFW_CTL_FLAG_WRITEABLE ) out |= wr;if (in &WMFW_CTL_FLAG_VOLATILE )
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 5/62 ASoc: rockchip: i2s: Fix RPM imbalance
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit b1e620e7d32f5aad5353cc3cfc13ed99fea65d3a ]
If rockchip_pcm_platform_register() fails, e.g. upon deferring to wait for an absent DMA channel, we return without disabling RPM, which makes subsequent re-probe attempts scream with errors about the unbalanced enable. Don't do that.
--- sound/soc/rockchip/rockchip_i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/rockchip/rockchip_i2s.c +1 -1
@@ -676,7 +676,7 @@ static int rockchip_i2s_probe(struct platform_device *pdev) ret =devm_snd_dmaengine_pcm_register (&pdev->dev,NULL ,0 );if (ret) {dev_err (&pdev->dev,"Could not register PCM\n" ); -return ret; + goto err_suspend; }return 0 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 6/62 ARM: dts: logicpd-torpedo-som: Remove twl_keypad
In reply to Greg Kroah-HartmanFrom: Adam Ford <[email protected]>
[ Upstream commit 6b512b0ee091edcb8e46218894e4c917d919d3dc ]
The TWL4030 used on the Logit PD Torpedo SOM does not have the keypad pins routed. This patch disables the twl_keypad driver to remove some splat during boot:
twl4030_keypad 48070000.i2c:twl@48:keypad: missing or malformed property linux,keymap: -22 twl4030_keypad 48070000.i2c:twl@48:keypad: Failed to build keymaptwl4030_keypad: probe of 48070000.i2c:twl@48:keypad failed with error -22
--- arch/arm/boot/dts/logicpd-torpedo-som.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/logicpd-torpedo-som.dtsi +4 -0
@@ -270,3 +270,7 @@ &twl_gpio { ti,use-leds; }; + +&twl_keypad { + status = "disabled"; +};
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 7/62 pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 39b65fbb813089e366b376bd8acc300b6fd646dc ]
The pinctrl->functions[] array has pinctrl->num_functions elements and the pinctrl->groups[] array is the same way. These are set in ns2_pinmux_probe(). So the > comparisons should be >= so that we don't read one element beyond the end of the array.
--- drivers/pinctrl/bcm/pinctrl-ns2-mux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-ns2-mux.c +2 -2
@@ -640,8 +640,8 @@ static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev,const struct ns2_pin_function *func;const struct ns2_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];
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 8/62 ARM: mm: fix alignment handler faults under memory pressure
In reply to Greg Kroah-HartmanFrom: Russell King <[email protected]>
[ Upstream commit 67e15fa5b487adb9b78a92789eeff2d6ec8f5cee ]
When the system has high memory pressure, the page containing the instruction may be paged out. Using probe_kernel_address() means that if the page is swapped out, the resulting page fault will not be handled because page faults are disabled by this function.
Use get_user() to read the instruction instead.
--- arch/arm/mm/alignment.c | 44 +++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-)
arch/arm/mm/alignment.c +36 -8
@@ -768,6 +768,36 @@ do_alignment_t32_to_handler(unsigned long *pinstr, struct pt_regs *regs,return NULL ; } +static int alignment_get_arm (struct pt_regs *regs,u32 *ip,unsigned long *inst) +{ +u32 instr =0 ; +int fault; + +if (user_mode (regs)) + fault =get_user (instr, ip); +else + fault =probe_kernel_address (ip, instr); + + *inst =__mem_to_opcode_arm (instr); + +return fault; +} + +static int alignment_get_thumb (struct pt_regs *regs,u16 *ip,u16 *inst) +{ +u16 instr =0 ; +int fault; + +if (user_mode (regs)) + fault =get_user (instr, ip); +else + fault =probe_kernel_address (ip, instr); + + *inst =__mem_to_opcode_thumb16 (instr); + +return fault; +} +static int do_alignment (unsigned long addr,unsigned int fsr,struct pt_regs *regs) {
@@ -775,10 +805,10 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)unsigned long instr =0 , instrptr;int (*handler)(unsigned long addr,unsigned long instr,struct pt_regs *regs);unsigned int type; -unsigned int fault;u16 tinstr =0 ;int isize =4 ;int thumb2_32b =0 ; +int fault;if (interrupts_enabled (regs))local_irq_enable ();
@@ -787,15 +817,14 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)if (thumb_mode (regs)) {u16 *ptr = (u16 *)(instrptr & ~1 ); - fault =probe_kernel_address (ptr, tinstr); - tinstr =__mem_to_opcode_thumb16 (tinstr); + + fault =alignment_get_thumb (regs, ptr, &tinstr);if (!fault) {if (cpu_architecture () >= CPU_ARCH_ARMv7 &&IS_T32 (tinstr)) {/* Thumb-2 32-bit */ -u16 tinst2 =0 ; - fault =probe_kernel_address (ptr +1 , tinst2); - tinst2 =__mem_to_opcode_thumb16 (tinst2); +u16 tinst2; + fault =alignment_get_thumb (regs, ptr +1 , &tinst2); instr =__opcode_thumb32_compose (tinstr, tinst2); thumb2_32b =1 ; }else {
@@ -804,8 +833,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs) } } }else { - fault =probe_kernel_address ((void *)instrptr, instr); - instr =__mem_to_opcode_arm (instr); + fault =alignment_get_arm (regs, (void *)instrptr, &instr); }if (fault) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 9/62 scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions
In reply to Greg Kroah-HartmanFrom: Hannes Reinecke <[email protected]>
[ Upstream commit b6ce6fb121a655aefe41dccc077141c102145a37 ]
Some arrays are not capable of returning RTPG data during state transitioning, but rather return an 'LUN not accessible, asymmetric access state transition' sense code. In these cases we can set the state to 'transitioning' directly and don't need to evaluate the RTPG data (which we won't have anyway).
--- drivers/scsi/device_handler/scsi_dh_alua.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +16 -5
@@ -523,6 +523,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)unsigned int tpg_desc_tbl_off;unsigned char orig_transition_tmo;unsigned long flags; +bool transitioning_sense = false;if (!pg->expiry) {unsigned long transition_tmo =ALUA_FAILOVER_TIMEOUT *HZ ;
@@ -567,13 +568,19 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) goto retry; }/* -* Retry on ALUA state transition or if any -* UNIT ATTENTION occurred. +* If the array returns with 'ALUA state transition' +* sense code here it cannot return RTPG data during +* transition. So set the state to 'transitioning' directly. */ if (sense_hdr.sense_key ==NOT_READY && - sense_hdr.asc ==0x04 && sense_hdr.ascq ==0x0a ) - err =SCSI_DH_RETRY ; -else if (sense_hdr.sense_key ==UNIT_ATTENTION ) + sense_hdr.asc ==0x04 && sense_hdr.ascq ==0x0a ) { + transitioning_sense = true; + goto skip_rtpg; + } +/* +* Retry on any other UNIT ATTENTION occurred. +*/ +if (sense_hdr.sense_key ==UNIT_ATTENTION ) err =SCSI_DH_RETRY ;if (err ==SCSI_DH_RETRY && pg->expiry !=0 &&time_before (jiffies, pg->expiry)) {
@@ -661,7 +668,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) off =8 + (desc[7 ] *4 ); } + skip_rtpg:spin_lock_irqsave (&pg->lock, flags); +if (transitioning_sense) + pg->state =SCSI_ACCESS_STATE_TRANSITIONING ; + sdev_printk(KERN_INFO, sdev, "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n", ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 10/62 scsi: sni_53c710: fix compilation error
In reply to Greg Kroah-HartmanFrom: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 0ee6211408a8e939428f662833c7301394125b80 ]
Drop out memory dev_printk() with wrong device pointer argument.
[mkp: typo]
--- drivers/scsi/sni_53c710.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/sni_53c710.c +1 -3
@@ -78,10 +78,8 @@ static int snirm710_probe(struct platform_device *dev) base = res->start; hostdata =kzalloc (sizeof (*hostdata),GFP_KERNEL ); -if (!hostdata) { -dev_printk (KERN_ERR , dev,"Failed to allocate host data\n" ); +if (!hostdata)return -ENOMEM ; - } hostdata->dev = &dev->dev;dma_set_mask (&dev->dev,DMA_BIT_MASK (32 ));
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 11/62 scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE
In reply to Greg Kroah-HartmanFrom: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 8cbf0c173aa096dda526d1ccd66fc751c31da346 ]
When building a kernel with SCSI_SNI_53C710 enabled, Kconfig warns:
WARNING: unmet direct dependencies detected for 53C700_LE_ON_BE
Depends on [n]: SCSI_LOWLEVEL [=y] && SCSI [=y] && SCSI_LASI700 [=n] Selected by [y]:
- SCSI_SNI_53C710 [=y] && SCSI_LOWLEVEL [=y] && SNI_RM [=y] && SCSI [=y]
Add the missing depends SCSI_SNI_53C710 to 53C700_LE_ON_BE to fix it.
--- drivers/scsi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/Kconfig +1 -1
@@ -966,7 +966,7 @@ config SCSI_SNI_53C710 config 53C700_LE_ON_BE bool - depends on SCSI_LASI700 + depends on SCSI_LASI700 || SCSI_SNI_53C710 default y config SCSI_STEX
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 12/62 ARM: dts: imx7s: Correct GPTs ipg clock source
In reply to Greg Kroah-HartmanFrom: Anson Huang <[email protected]>
[ Upstream commit 252b9e21bcf46b0d16f733f2e42b21fdc60addee ]
i.MX7S/D's GPT ipg clock should be from GPT clock root and controlled by CCM's GPT CCGR, using correct clock source for GPT ipg clock instead of IMX7D_CLK_DUMMY.
--- arch/arm/boot/dts/imx7s.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx7s.dtsi +4 -4
@@ -450,7 +450,7 @@ compatible = "fsl,imx7d-gpt", "fsl,imx6sx-gpt"; reg = <0x302d0000 0x10000>; interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, + clocks = <&clks IMX7D_GPT1_ROOT_CLK>, <&clks IMX7D_GPT1_ROOT_CLK>; clock-names = "ipg", "per"; };
@@ -459,7 +459,7 @@ compatible = "fsl,imx7d-gpt", "fsl,imx6sx-gpt"; reg = <0x302e0000 0x10000>; interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, + clocks = <&clks IMX7D_GPT2_ROOT_CLK>, <&clks IMX7D_GPT2_ROOT_CLK>; clock-names = "ipg", "per"; status = "disabled";
@@ -469,7 +469,7 @@ compatible = "fsl,imx7d-gpt", "fsl,imx6sx-gpt"; reg = <0x302f0000 0x10000>; interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, + clocks = <&clks IMX7D_GPT3_ROOT_CLK>, <&clks IMX7D_GPT3_ROOT_CLK>; clock-names = "ipg", "per"; status = "disabled";
@@ -479,7 +479,7 @@ compatible = "fsl,imx7d-gpt", "fsl,imx6sx-gpt"; reg = <0x30300000 0x10000>; interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, + clocks = <&clks IMX7D_GPT4_ROOT_CLK>, <&clks IMX7D_GPT4_ROOT_CLK>; clock-names = "ipg", "per"; status = "disabled";
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 13/62 perf c2c: Fix memory leak in build_cl_output()
In reply to Greg Kroah-HartmanFrom: Yunfeng Ye <[email protected]>
[ Upstream commit ae199c580da1754a2b051321eeb76d6dacd8707b ]
There is a memory leak problem in the failure paths of build_cl_output(), so fix it.
--- tools/perf/builtin-c2c.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
tools/perf/builtin-c2c.c +9 -5
@@ -2454,6 +2454,7 @@ static int build_cl_output(char *cl_sort, bool no_source)bool add_sym = false;bool add_dso = false;bool add_src = false; +int ret =0 ;if (!buf)return -ENOMEM ;
@@ -2472,7 +2473,8 @@ static int build_cl_output(char *cl_sort, bool no_source) add_dso = true; }else if (strcmp (tok,"offset" )) {pr_err ("unrecognized sort token: %s\n" , tok); -return -EINVAL ; + ret = -EINVAL ; + goto err; } }
@@ -2495,13 +2497,15 @@ static int build_cl_output(char *cl_sort, bool no_source) add_sym ? "symbol," : "", add_dso ? "dso," : "", add_src ? "cl_srcline," : "", - "node") < 0) -return -ENOMEM ; + "node") < 0) { + ret = -ENOMEM ; + goto err; + } c2c.show_src = add_src; - +err:free (buf); -return 0 ; +return ret; }static int setup_coalesce (const char *coalesce,bool no_source)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 14/62 perf kmem: Fix memory leak in compact_gfp_flags()
In reply to Greg Kroah-HartmanFrom: Yunfeng Ye <[email protected]>
[ Upstream commit 1abecfcaa7bba21c9985e0136fa49836164dd8fd ]
The memory @orig_flags is allocated by strdup(), it is freed on the normal path, but leak to free on the error path.
Fix this by adding free(orig_flags) on the error path.
--- tools/perf/builtin-kmem.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/builtin-kmem.c +1 -0
@@ -687,6 +687,7 @@ static char *compact_gfp_flags(char *gfp_flags) new =realloc (new_flags, len +strlen (cpt) +2 );if (new ==NULL ) {free (new_flags); +free (orig_flags);return NULL ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 15/62 ARM: davinci: dm365: Fix McBSP dma_slave_map entry
In reply to Greg Kroah-HartmanFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 564b6bb9d42d31fc80c006658cf38940a9b99616 ]
dm365 have only single McBSP, so the device name is without .0
--- arch/arm/mach-davinci/dm365.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-davinci/dm365.c +2 -2
@@ -856,8 +856,8 @@ static s8 dm365_queue_priority_mapping[][2] = { };static const struct dma_slave_map dm365_edma_map[] = { - {"davinci-mcbsp.0" ,"tx" ,EDMA_FILTER_PARAM (0 ,2 ) }, - {"davinci-mcbsp.0" ,"rx" ,EDMA_FILTER_PARAM (0 ,3 ) }, + {"davinci-mcbsp" ,"tx" ,EDMA_FILTER_PARAM (0 ,2 ) }, + {"davinci-mcbsp" ,"rx" ,EDMA_FILTER_PARAM (0 ,3 ) }, {"davinci_voicecodec" ,"tx" ,EDMA_FILTER_PARAM (0 ,2 ) }, {"davinci_voicecodec" ,"rx" ,EDMA_FILTER_PARAM (0 ,3 ) }, {"spi_davinci.2" ,"tx" ,EDMA_FILTER_PARAM (0 ,10 ) },
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 16/62 scsi: target: core: Do not overwrite CDB byte 1
In reply to Greg Kroah-HartmanFrom: Bodo Stroesser <[email protected]>
[ Upstream commit 27e84243cb63601a10e366afe3e2d05bb03c1cb5 ]
passthrough_parse_cdb() - used by TCMU and PSCSI - attepts to reset the LUN field of SCSI-2 CDBs (bits 5,6,7 of byte 1). The current code is wrong as for newer commands not having the LUN field it overwrites relevant command bits (e.g. for SECURITY PROTOCOL IN / OUT). We think this code was unnecessary from the beginning or at least it is no longer useful. So we remove it entirely.
--- drivers/target/target_core_device.c | 21 --------------------- 1 file changed, 21 deletions(-)
drivers/target/target_core_device.c +0 -21
@@ -1151,27 +1151,6 @@ passthrough_parse_cdb(struct se_cmd *cmd,struct se_device *dev = cmd->se_dev;unsigned int size; -/* -* Clear a lun set in the cdb if the initiator talking to use spoke -* and old standards version, as we can't assume the underlying device -* won't choke up on it. -*/ -switch (cdb[0 ]) { -case READ_10 :/* SBC - RDProtect */ -case READ_12 :/* SBC - RDProtect */ -case READ_16 :/* SBC - RDProtect */ -case SEND_DIAGNOSTIC :/* SPC - SELF-TEST Code */ -case VERIFY :/* SBC - VRProtect */ -case VERIFY_16 :/* SBC - VRProtect */ -case WRITE_VERIFY :/* SBC - VRProtect */ -case WRITE_VERIFY_12 :/* SBC - VRProtect */ -case MAINTENANCE_IN :/* SPC - Parameter Data Format for SA RTPG */ -break ; -default : - cdb[1 ] &=0x1f ;/* clear logical unit number */ -break ; - } -/* * For REPORT LUNS we always need to emulate the response, for everything * else, pass it up.
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 17/62 ARM: 8926/1: v7m: remove register save to stack before svc
In reply to Greg Kroah-HartmanFrom: afzal mohammed <[email protected]>
[ Upstream commit 2ecb287998a47cc0a766f6071f63bc185f338540 ]
r0-r3 & r12 registers are saved & restored, before & after svc respectively. Intention was to preserve those registers across thread to handler mode switch.
On v7-M, hardware saves the register context upon exception in AAPCS complaint way. Restoring r0-r3 & r12 is done from stack location where hardware saves it, not from the location on stack where these registers were saved.
To clarify, on stm32f429 discovery board:
1. before svc, sp - 0x90009ff8
2. r0-r3,r12 saved to 0x90009ff8 - 0x9000a00b
3. upon svc, h/w decrements sp by 32 & pushes registers onto stack
4. after svc, sp - 0x90009fd8
5. r0-r3,r12 restored from 0x90009fd8 - 0x90009feb
Above means r0-r3,r12 is not restored from the location where they are saved, but since hardware pushes the registers onto stack, the registers are restored correctly.
Note that during register saving to stack (step 2), it goes past 0x9000a000. And it seems, based on objdump, there are global symbols residing there, and it perhaps can cause issues on a non-XIP Kernel (on XIP, data section is setup later).
Based on the analysis above, manually saving registers onto stack is at best no-op and at worst can cause data section corruption. Hence remove storing of registers onto stack before svc.
--- arch/arm/mm/proc-v7m.S | 1 - 1 file changed, 1 deletion(-)
arch/arm/mm/proc-v7m.S +0 -1
@@ -135,7 +135,6 @@ __v7m_setup_cont: dsb mov r6, lr @ save LR ldr sp, =init_thread_union + THREAD_START_SP - stmia sp, {r0-r3, r12} cpsie i svc #0 1: cpsid i
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 18/62 of: unittest: fix memory leak in unittest_data_add
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit e13de8fe0d6a51341671bbe384826d527afe8d44 ]
In unittest_data_add, a copy buffer is created via kmemdup. This buffer is leaked if of_fdt_unflatten_tree fails. The release for the unittest_data buffer is added.
--- drivers/of/unittest.c | 1 + 1 file changed, 1 insertion(+)
drivers/of/unittest.c +1 -0
@@ -1002,6 +1002,7 @@ static int __init unittest_data_add(void)of_fdt_unflatten_tree (unittest_data,NULL , &unittest_data_node);if (!unittest_data_node) {pr_warn ("%s: No tree to attach; not running tests\n" , __func__); +kfree (unittest_data);return -ENODATA ; }of_node_set_flag (unittest_data_node,OF_DETACHED );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 19/62 MIPS: bmips: mark exception vectors as char arrays
In reply to Greg Kroah-HartmanFrom: Jonas Gorski <[email protected]>
[ Upstream commit e4f5cb1a9b27c0f94ef4f5a0178a3fde2d3d0e9e ]
The vectors span more than one byte, so mark them as arrays.
Fixes the following build error when building when using GCC 8.3:
In file included from ./include/linux/string.h:19,
from ./include/linux/bitmap.h:9,
from ./include/linux/cpumask.h:12,
from ./arch/mips/include/asm/processor.h:15,
from ./arch/mips/include/asm/thread_info.h:16,
from ./include/linux/thread_info.h:38,
from ./include/asm-generic/preempt.h:5,
from ./arch/mips/include/generated/asm/preempt.h:1,
from ./include/linux/preempt.h:81,
from ./include/linux/spinlock.h:51,
from ./include/linux/mmzone.h:8,
from ./include/linux/bootmem.h:8,
from arch/mips/bcm63xx/prom.c:10:
arch/mips/bcm63xx/prom.c: In function 'prom_init':
./arch/mips/include/asm/string.h:162:11: error: '__builtin_memcpy' forming offset [2, 32] is out of the bounds [0, 1] of object 'bmips_smp_movevec' with type 'char' [-Werror=array-bounds]
__ret = __builtin_memcpy((dst), (src), __len); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~arch/mips/bcm63xx/prom.c:97:3: note: in expansion of macro 'memcpy'
memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20);
^~~~~~
In file included from arch/mips/bcm63xx/prom.c:14:./arch/mips/include/asm/bmips.h:80:13: note: 'bmips_smp_movevec' declared here
extern char bmips_smp_movevec;
--- arch/mips/bcm63xx/prom.c | 2 +- arch/mips/include/asm/bmips.h | 10 +++++----- arch/mips/kernel/smp-bmips.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-)
arch/mips/bcm63xx/prom.c +1 -1
@@ -84,7 +84,7 @@ void __init prom_init(void)* Here we will start up CPU1 in the background and ask it to * reconfigure itself then go back to sleep. */ -memcpy ((void *)0xa0000200 , &bmips_smp_movevec,0x20 ); +memcpy ((void *)0xa0000200 , bmips_smp_movevec,0x20 );__sync ();set_c0_cause (C_SW0 );cpumask_set_cpu (1 , &bmips_booted_mask);
arch/mips/include/asm/bmips.h +5 -5
@@ -75,11 +75,11 @@ static inline int register_bmips_smp_ops(void)#endif } -extern char bmips_reset_nmi_vec; -extern char bmips_reset_nmi_vec_end; -extern char bmips_smp_movevec; -extern char bmips_smp_int_vec; -extern char bmips_smp_int_vec_end; +extern char bmips_reset_nmi_vec[]; +extern char bmips_reset_nmi_vec_end[]; +extern char bmips_smp_movevec[]; +extern char bmips_smp_int_vec[]; +extern char bmips_smp_int_vec_end[];extern int bmips_smp_enabled;extern int bmips_cpu_offset;
arch/mips/kernel/smp-bmips.c +4 -4
@@ -457,10 +457,10 @@ static void bmips_wr_vec(unsigned long dst, char *start, char *end)static inline void bmips_nmi_handler_setup (void ) { -bmips_wr_vec (BMIPS_NMI_RESET_VEC , &bmips_reset_nmi_vec, - &bmips_reset_nmi_vec_end); -bmips_wr_vec (BMIPS_WARM_RESTART_VEC , &bmips_smp_int_vec, - &bmips_smp_int_vec_end); +bmips_wr_vec (BMIPS_NMI_RESET_VEC , bmips_reset_nmi_vec, + bmips_reset_nmi_vec_end); +bmips_wr_vec (BMIPS_WARM_RESTART_VEC , bmips_smp_int_vec, + bmips_smp_int_vec_end); }struct reset_vec_info {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 20/62 i2c: stm32f7: remove warning when compiling with W=1
In reply to Greg Kroah-HartmanFrom: Alain Volmat <[email protected]>
[ Upstream commit 348e46fbb4cdb2aead79aee1fd8bb25ec5fd25db ]
Remove the following warning:
drivers/i2c/busses/i2c-stm32f7.c:315:
warning: cannot understand function prototype:
'struct stm32f7_i2c_spec i2c_specs[] =
Replace a comment starting with /** by simply /* to avoid having it interpreted as a kernel-doc comment.
--- drivers/i2c/busses/i2c-stm32f7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-stm32f7.c +1 -1
@@ -219,7 +219,7 @@ struct stm32f7_i2c_dev {struct stm32f7_i2c_timings timing; }; -/** +/* * All these values are coming from I2C Specification, Version 6.0, 4th of * April 2014. *
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 21/62 cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs
In reply to Greg Kroah-HartmanFrom: Dave Wysochanski <[email protected]>
[ Upstream commit d46b0da7a33dd8c99d969834f682267a45444ab3 ]
There's a deadlock that is possible and can easily be seen with a test where multiple readers open/read/close of the same file and a disruption occurs causing reconnect. The deadlock is due a reader thread inside cifs_strict_readv calling down_read and obtaining lock_sem, and then after reconnect inside cifs_reopen_file calling down_read a second time. If in between the two down_read calls, a down_write comes from another process, deadlock occurs.
CPU0 CPU1
---- ----
cifs_strict_readv()
down_read(&cifsi->lock_sem);
_cifsFileInfo_put
OR
cifs_new_fileinfo
down_write(&cifsi->lock_sem);cifs_reopen_file()
down_read(&cifsi->lock_sem);
Fix the above by changing all down_write(lock_sem) calls to down_write_trylock(lock_sem)/msleep() loop, which in turn makes the second down_read call benign since it will never block behind the writer while holding lock_sem.
--- fs/cifs/cifsglob.h | 5 +++++ fs/cifs/cifsproto.h | 1 + fs/cifs/file.c | 23 +++++++++++++++-------- fs/cifs/smb2file.c | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-)
fs/cifs/cifsglob.h +5 -0
@@ -1210,6 +1210,11 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file);struct cifsInodeInfo {bool can_cache_brlcks;struct list_head llist;/* locks helb by this inode */ +/* +* NOTE: Some code paths call down_read(lock_sem) twice, so +* we must always use use cifs_down_write() instead of down_write() +* for this semaphore to avoid deadlocks. +*/ struct rw_semaphore lock_sem;/* protect the fields above */ /* BB add in lists for dirty pages i.e. write caching info for oplock */ struct list_head openFileList;
fs/cifs/cifsproto.h +1 -0
@@ -149,6 +149,7 @@ extern int cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, const unsigned int xid);extern int cifs_push_mandatory_locks (struct cifsFileInfo *cfile); +extern void cifs_down_write (struct rw_semaphore *sem); extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, struct tcon_link *tlink,
fs/cifs/file.c +15 -8
@@ -280,6 +280,13 @@ cifs_has_mand_locks(struct cifsInodeInfo *cinode)return has_locks; } +void +cifs_down_write (struct rw_semaphore *sem) +{ +while (!down_write_trylock (sem)) +msleep (10 ); +} +struct cifsFileInfo *cifs_new_fileinfo (struct cifs_fid *fid,struct file *file,struct tcon_link *tlink,__u32 oplock)
@@ -305,7 +312,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,INIT_LIST_HEAD (&fdlocks->locks); fdlocks->cfile = cfile; cfile->llist = fdlocks; -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);list_add (&fdlocks->llist, &cinode->llist);up_write (&cinode->lock_sem);
@@ -457,7 +464,7 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_handler)* Delete any outstanding lock records. We'll lose them when the file * is closed anyway. */ -down_write (&cifsi->lock_sem); +cifs_down_write (&cifsi->lock_sem);list_for_each_entry_safe (li, tmp, &cifs_file->llist->locks, llist) {list_del (&li->llist);cifs_del_lock_waiters (li);
@@ -1011,7 +1018,7 @@ static void cifs_lock_add(struct cifsFileInfo *cfile, struct cifsLockInfo *lock) { struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);list_add_tail (&lock->llist, &cfile->llist->locks);up_write (&cinode->lock_sem); }
@@ -1033,7 +1040,7 @@ cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock, try_again: exist = false; -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem); exist =cifs_find_lock_conflict (cfile, lock->offset, lock->length, lock->type, &conf_lock,CIFS_LOCK_OP );
@@ -1055,7 +1062,7 @@ cifs_lock_add_if(struct cifsFileInfo *cfile, struct cifsLockInfo *lock, (lock->blist.next == &lock->blist));if (!rc) goto try_again; -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);list_del_init (&lock->blist); }
@@ -1108,7 +1115,7 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)return rc; try_again: -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);if (!cinode->can_cache_brlcks) {up_write (&cinode->lock_sem);return rc;
@@ -1314,7 +1321,7 @@ cifs_push_locks(struct cifsFileInfo *cfile)int rc =0 ;/* we are going to update can_cache_brlcks here - need a write access */ -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);if (!cinode->can_cache_brlcks) {up_write (&cinode->lock_sem);return rc;
@@ -1505,7 +1512,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,if (!buf)return -ENOMEM ; -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem);for (i =0 ; i <2 ; i++) { cur = buf; num =0 ;
fs/cifs/smb2file.c +1 -1
@@ -139,7 +139,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, cur = buf; -down_write (&cinode->lock_sem); +cifs_down_write (&cinode->lock_sem); list_for_each_entry_safe(li, tmp, &cfile->llist->locks, llist) { if (flock->fl_start > li->offset || (flock->fl_start + length) <
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 22/62 nbd: handle racing with errored out commands
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 7ce23e8e0a9cd38338fc8316ac5772666b565ca9 ]
We hit the following warning in production
print_req_error: I/O error, dev nbd0, sector 7213934408 flags 80700
------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 25 PID: 32407 at lib/refcount.c:190 refcount_sub_and_test_checked+0x53/0x60 Workqueue: knbd-recv recv_work [nbd] RIP: 0010:refcount_sub_and_test_checked+0x53/0x60 Call Trace: blk_mq_free_request+0xb7/0xf0 blk_mq_complete_request+0x62/0xf0 recv_work+0x29/0xa1 [nbd] process_one_work+0x1f5/0x3f0 worker_thread+0x2d/0x3d0 ? rescuer_thread+0x340/0x340 kthread+0x111/0x130 ? kthread_create_on_node+0x60/0x60 ret_from_fork+0x1f/0x30 ---[ end trace b079c3c67f98bb7c ]---
This was preceded by us timing out everything and shutting down the sockets for the device. The problem is we had a request in the queue at the same time, so we completed the request twice. This can actually happen in a lot of cases, we fail to get a ref on our config, we only have one connection and just error out the command, etc.
Fix this by checking cmd->status in nbd_read_stat. We only change this under the cmd->lock, so we are safe to check this here and see if we've already error'ed this command out, which would indicate that we've completed it as well.
--- drivers/block/nbd.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/block/nbd.c +6 -0
@@ -648,6 +648,12 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) ret = -ENOENT ; goto out; } +if (cmd->status !=BLK_STS_OK ) { +dev_err (disk_to_dev (nbd->disk),"Command already handled %p\n" , + req); + ret = -ENOENT ; + goto out; + }if (test_bit (NBD_CMD_REQUEUED , &cmd->flags)) {dev_err (disk_to_dev (nbd->disk),"Raced with timeout on req %p\n" , req);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 23/62 cxgb4: fix panic when attaching to ULD fail
In reply to Greg Kroah-HartmanFrom: Vishal Kulkarni <[email protected]>
[ Upstream commit fc89cc358fb64e2429aeae0f37906126636507ec ]
Release resources when attaching to ULD fail. Otherwise, data mismatch is seen between LLD and ULD later on, which lead to kernel panic when accessing resources that should not even exist in the first place.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 29 ++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +17 -12
@@ -670,10 +670,10 @@ static void uld_init(struct adapter *ada lld->fr_nsmr_tpte_wr_support = adap->params.fr_nsmr_tpte_wr_support; } -static void uld_attach (struct adapter *adap,unsigned int uld) +static int uld_attach (struct adapter *adap,unsigned int uld) { -void *handle;struct cxgb4_lld_info lli; +void *handle;uld_init (adap, &lli);uld_queue_init (adap, uld, &lli);
@@ -683,7 +683,7 @@ static void uld_attach(struct adapter *adev_warn (adap->pdev_dev,"could not attach to the %s driver, error %ld\n" , adap->uld[uld].name,PTR_ERR (handle)); -return ; +return PTR_ERR (handle); } adap->uld[uld].handle = handle;
@@ -691,23 +691,24 @@ static void uld_attach(struct adapter *aif (adap->flags &FULL_INIT_DONE ) adap->uld[uld].state_change (handle,CXGB4_STATE_UP ); + +return 0 ; } -/** -* cxgb4_register_uld - register an upper-layer driver -* @type: the ULD type -* @p: the ULD methods +/* cxgb4_register_uld - register an upper-layer driver +* @type: the ULD type +* @p: the ULD methods * -* Registers an upper-layer driver with this driver and notifies the ULD -* about any presently available devices that support its type. Returns -* %-EBUSY if a ULD of the same type is already registered. +* Registers an upper-layer driver with this driver and notifies the ULD +* about any presently available devices that support its type. Returns +* %-EBUSY if a ULD of the same type is already registered. */ int cxgb4_register_uld (enum cxgb4_uld type,const struct cxgb4_uld_info *p) { -int ret =0 ;unsigned int adap_idx =0 ;struct adapter *adap; +int ret =0 ;if (type >=CXGB4_ULD_MAX )return -EINVAL ;
@@ -741,12 +742,16 @@ int cxgb4_register_uld(enum cxgb4_uld tyif (ret) goto free_irq; adap->uld[type] = *p; -uld_attach (adap, type); + ret =uld_attach (adap, type); +if (ret) + goto free_txq; adap_idx++; }mutex_unlock (&uld_mutex);return 0 ; +free_txq: +release_sge_txq_uld (adap, type); free_irq:if (adap->flags &FULL_INIT_DONE )quiesce_rx_uld (adap, type);
Greg Kroah-Hartman
maintainerPATCH 24/62 dccp: do not leak jiffies on the wire
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 3d1e5039f5f87a8731202ceca08764ee7cb010d3 ]
For some reason I missed the case of DCCP passive
flows in my previous patch.
--- net/dccp/ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/dccp/ipv4.c +1 -1
@@ -417,7 +417,7 @@ struct sock *dccp_v4_request_recv_sock(cRCU_INIT_POINTER (newinet->inet_opt,rcu_dereference (ireq->ireq_opt)); newinet->mc_index =inet_iif (skb); newinet->mc_ttl =ip_hdr (skb)->ttl; - newinet->inet_id = jiffies; + newinet->inet_id =prandom_u32 ();if (dst ==NULL && (dst =inet_csk_route_child_sock (sk, newsk, req)) ==NULL ) goto put_and_exit;
Greg Kroah-Hartman
maintainerPATCH 25/62 net: annotate accesses to sk->sk_incoming_cpu
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 7170a977743b72cf3eb46ef6ef89885dc7ad3621 ]
This socket field can be read and written by concurrent cpus.
Use READ_ONCE() and WRITE_ONCE() annotations to document this, and avoid some compiler 'optimizations'.
KCSAN reported :
BUG: KCSAN: data-race in tcp_v4_rcv / tcp_v4_rcv
write to 0xffff88812220763c of 4 bytes by interrupt on cpu 0:
sk_incoming_cpu_update include/net/sock.h:953 [inline] tcp_v4_rcv+0x1b3c/0x1bb0 net/ipv4/tcp_ipv4.c:1934 ip_protocol_deliver_rcu+0x4d/0x420 net/ipv4/ip_input.c:204 ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252 dst_input include/net/dst.h:442 [inline] ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955 napi_poll net/core/dev.c:6392 [inline] net_rx_action+0x3ae/0xa90 net/core/dev.c:6460 __do_softirq+0x115/0x33f kernel/softirq.c:292 do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1082 do_softirq.part.0+0x6b/0x80 kernel/softirq.c:337 do_softirq kernel/softirq.c:329 [inline] __local_bh_enable_ip+0x76/0x80 kernel/softirq.c:189
read to 0xffff88812220763c of 4 bytes by interrupt on cpu 1:
sk_incoming_cpu_update include/net/sock.h:952 [inline] tcp_v4_rcv+0x181a/0x1bb0 net/ipv4/tcp_ipv4.c:1934 ip_protocol_deliver_rcu+0x4d/0x420 net/ipv4/ip_input.c:204 ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252 dst_input include/net/dst.h:442 [inline] ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955 napi_poll net/core/dev.c:6392 [inline] net_rx_action+0x3ae/0xa90 net/core/dev.c:6460 __do_softirq+0x115/0x33f kernel/softirq.c:292 run_ksoftirqd+0x46/0x60 kernel/softirq.c:603 smpboot_thread_fn+0x37d/0x4a0 kernel/smpboot.c:165
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- include/net/sock.h | 4 ++-- net/core/sock.c | 4 ++-- net/ipv4/inet_hashtables.c | 2 +- net/ipv4/udp.c | 2 +- net/ipv6/inet6_hashtables.c | 2 +- net/ipv6/udp.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
include/net/sock.h +2 -2
@@ -916,8 +916,8 @@ static inline void sk_incoming_cpu_updat {int cpu =raw_smp_processor_id (); -if (unlikely (sk->sk_incoming_cpu != cpu)) - sk->sk_incoming_cpu = cpu; +if (unlikely (READ_ONCE (sk->sk_incoming_cpu) != cpu)) +WRITE_ONCE (sk->sk_incoming_cpu, cpu); }static inline void sock_rps_record_flow_hash (__u32 hash)
net/core/sock.c +2 -2
@@ -1039,7 +1039,7 @@ set_rcvbuf:break ;case SO_INCOMING_CPU : - sk->sk_incoming_cpu = val; +WRITE_ONCE (sk->sk_incoming_cpu, val);break ;case SO_CNX_ADVICE :
@@ -1351,7 +1351,7 @@ int sock_getsockopt(struct socket *sock,break ;case SO_INCOMING_CPU : - v.val = sk->sk_incoming_cpu; + v.val =READ_ONCE (sk->sk_incoming_cpu);break ;case SO_MEMINFO :
net/ipv4/inet_hashtables.c +1 -1
@@ -193,7 +193,7 @@ static inline int compute_score(struct sif (sk->sk_bound_dev_if) score +=4 ; } -if (sk->sk_incoming_cpu ==raw_smp_processor_id ()) +if (READ_ONCE (sk->sk_incoming_cpu) ==raw_smp_processor_id ()) score++; }return score;
net/ipv4/udp.c +1 -1
@@ -419,7 +419,7 @@ static int compute_score(struct sock *sk score +=4 ; } -if (sk->sk_incoming_cpu ==raw_smp_processor_id ()) +if (READ_ONCE (sk->sk_incoming_cpu) ==raw_smp_processor_id ()) score++;return score; }
net/ipv6/inet6_hashtables.c +1 -1
@@ -118,7 +118,7 @@ static inline int compute_score(struct sif (sk->sk_bound_dev_if) score++; } -if (sk->sk_incoming_cpu ==raw_smp_processor_id ()) +if (READ_ONCE (sk->sk_incoming_cpu) ==raw_smp_processor_id ()) score++; }return score;
net/ipv6/udp.c +1 -1
@@ -170,7 +170,7 @@ static int compute_score(struct sock *sk score++; } -if (sk->sk_incoming_cpu ==raw_smp_processor_id ()) +if (READ_ONCE (sk->sk_incoming_cpu) ==raw_smp_processor_id ()) score++;return score;
Greg Kroah-Hartman
maintainerPATCH 26/62 net: annotate lockless accesses to sk->sk_napi_id
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit ee8d153d46a3b98c064ee15c0c0a3bbf1450e5a1 ]
We already annotated most accesses to sk->sk_napi_id
We missed sk_mark_napi_id() and sk_mark_napi_id_once() which might be called without socket lock held in UDP stack.
KCSAN reported :
BUG: KCSAN: data-race in udpv6_queue_rcv_one_skb / udpv6_queue_rcv_one_skb
write to 0xffff888121c6d108 of 4 bytes by interrupt on cpu 0:
sk_mark_napi_id include/net/busy_poll.h:125 [inline] __udpv6_queue_rcv_skb net/ipv6/udp.c:571 [inline] udpv6_queue_rcv_one_skb+0x70c/0xb40 net/ipv6/udp.c:672 udpv6_queue_rcv_skb+0xb5/0x400 net/ipv6/udp.c:689 udp6_unicast_rcv_skb.isra.0+0xd7/0x180 net/ipv6/udp.c:832 __udp6_lib_rcv+0x69c/0x1770 net/ipv6/udp.c:913 udpv6_rcv+0x2b/0x40 net/ipv6/udp.c:1015 ip6_protocol_deliver_rcu+0x22a/0xbe0 net/ipv6/ip6_input.c:409 ip6_input_finish+0x30/0x50 net/ipv6/ip6_input.c:450 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip6_input+0x177/0x190 net/ipv6/ip6_input.c:459 dst_input include/net/dst.h:442 [inline] ip6_rcv_finish+0x110/0x140 net/ipv6/ip6_input.c:76 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ipv6_rcv+0x1a1/0x1b0 net/ipv6/ip6_input.c:284 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955 napi_poll net/core/dev.c:6392 [inline] net_rx_action+0x3ae/0xa90 net/core/dev.c:6460
write to 0xffff888121c6d108 of 4 bytes by interrupt on cpu 1:
sk_mark_napi_id include/net/busy_poll.h:125 [inline] __udpv6_queue_rcv_skb net/ipv6/udp.c:571 [inline] udpv6_queue_rcv_one_skb+0x70c/0xb40 net/ipv6/udp.c:672 udpv6_queue_rcv_skb+0xb5/0x400 net/ipv6/udp.c:689 udp6_unicast_rcv_skb.isra.0+0xd7/0x180 net/ipv6/udp.c:832 __udp6_lib_rcv+0x69c/0x1770 net/ipv6/udp.c:913 udpv6_rcv+0x2b/0x40 net/ipv6/udp.c:1015 ip6_protocol_deliver_rcu+0x22a/0xbe0 net/ipv6/ip6_input.c:409 ip6_input_finish+0x30/0x50 net/ipv6/ip6_input.c:450 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip6_input+0x177/0x190 net/ipv6/ip6_input.c:459 dst_input include/net/dst.h:442 [inline] ip6_rcv_finish+0x110/0x140 net/ipv6/ip6_input.c:76 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ipv6_rcv+0x1a1/0x1b0 net/ipv6/ip6_input.c:284 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 10890 Comm: syz-executor.0 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- include/net/busy_poll.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/net/busy_poll.h +3 -3
@@ -134,7 +134,7 @@ static inline void skb_mark_napi_id(strustatic inline void sk_mark_napi_id (struct sock *sk,const struct sk_buff *skb) {#ifdef CONFIG_NET_RX_BUSY_POLL - sk->sk_napi_id = skb->napi_id; +WRITE_ONCE (sk->sk_napi_id, skb->napi_id);#endif }
@@ -143,8 +143,8 @@ static inline void sk_mark_napi_id_once( const struct sk_buff *skb) {#ifdef CONFIG_NET_RX_BUSY_POLL -if (!sk->sk_napi_id) - sk->sk_napi_id = skb->napi_id; +if (!READ_ONCE (sk->sk_napi_id)) +WRITE_ONCE (sk->sk_napi_id, skb->napi_id);#endif }
Greg Kroah-Hartman
maintainerPATCH 27/62 net: dsa: bcm_sf2: Fix IMP setup for port different than 8
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 5fc0f21246e50afdf318b5a3a941f7f4f57b8947 ]
Since it became possible for the DSA core to use a CPU port different than 8, our bcm_sf2_imp_setup() function was broken because it assumes that registers are applicable to port 8. In particular, the port's MAC is going to stay disabled, so make sure we clear the RX_DIS and TX_DIS bits if we are not configured for port 8.
--- drivers/net/dsa/bcm_sf2.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
drivers/net/dsa/bcm_sf2.c +21 -15
@@ -106,22 +106,11 @@ static void bcm_sf2_imp_setup(struct dsaunsigned int i;u32 reg, offset; -if (priv->type ==BCM7445_DEVICE_ID ) - offset =CORE_STS_OVERRIDE_IMP ; -else - offset =CORE_STS_OVERRIDE_IMP2 ; -/* Enable the port memories */ reg =core_readl (priv,CORE_MEM_PSM_VDD_CTRL ); reg &= ~P_TXQ_PSM_VDD (port);core_writel (priv, reg,CORE_MEM_PSM_VDD_CTRL ); -/* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ - reg =core_readl (priv,CORE_IMP_CTL ); - reg |= (RX_BCST_EN |RX_MCST_EN |RX_UCST_EN ); - reg &= ~(RX_DIS |TX_DIS ); -core_writel (priv, reg,CORE_IMP_CTL ); -/* Enable forwarding */ core_writel (priv,SW_FWDG_EN ,CORE_SWMODE );
@@ -140,10 +129,27 @@ static void bcm_sf2_imp_setup(struct dsabcm_sf2_brcm_hdr_setup (priv, port); -/* Force link status for IMP port */ - reg =core_readl (priv, offset); - reg |= (MII_SW_OR |LINK_STS ); -core_writel (priv, reg, offset); +if (port ==8 ) { +if (priv->type ==BCM7445_DEVICE_ID ) + offset =CORE_STS_OVERRIDE_IMP ; +else + offset =CORE_STS_OVERRIDE_IMP2 ; + +/* Force link status for IMP port */ + reg =core_readl (priv, offset); + reg |= (MII_SW_OR |LINK_STS ); +core_writel (priv, reg, offset); + +/* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ + reg =core_readl (priv,CORE_IMP_CTL ); + reg |= (RX_BCST_EN |RX_MCST_EN |RX_UCST_EN ); + reg &= ~(RX_DIS |TX_DIS ); +core_writel (priv, reg,CORE_IMP_CTL ); + }else { + reg =core_readl (priv,CORE_G_PCTL_PORT (port)); + reg &= ~(RX_DIS |TX_DIS ); +core_writel (priv, reg,CORE_G_PCTL_PORT (port)); + } }static void bcm_sf2_eee_enable_set (struct dsa_switch *ds,int port,bool enable)
Greg Kroah-Hartman
maintainerPATCH 28/62 net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum
In reply to Greg Kroah-HartmanFrom: Benjamin Herrenschmidt <[email protected]>
[ Upstream commit 88824e3bf29a2fcacfd9ebbfe03063649f0f3254 ]
We are calling the checksum helper after the dma_map_single() call to map the packet. This is incorrect as the checksumming code will touch the packet from the CPU. This means the cache won't be properly flushes (or the bounce buffering will leave us with the unmodified packet to DMA).
This moves the calculation of the checksum & vlan tags to before the DMA mapping.
This also has the side effect of fixing another bug: If the checksum helper fails, we goto "drop" to drop the packet, which will not unmap the DMA mapping.
--- drivers/net/ethernet/faraday/ftgmac100.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +12 -13
@@ -734,6 +734,18 @@ static int ftgmac100_hard_start_xmit(str*/ nfrags =skb_shinfo (skb)->nr_frags; +/* Setup HW checksumming */ + csum_vlan =0 ; +if (skb->ip_summed ==CHECKSUM_PARTIAL && + !ftgmac100_prep_tx_csum (skb, &csum_vlan)) + goto drop; + +/* Add VLAN tag */ +if (skb_vlan_tag_present (skb)) { + csum_vlan |=FTGMAC100_TXDES1_INS_VLANTAG ; + csum_vlan |=skb_vlan_tag_get (skb) &0xffff ; + } +/* Get header len */ len =skb_headlen (skb);
@@ -760,19 +772,6 @@ static int ftgmac100_hard_start_xmit(strif (nfrags ==0 ) f_ctl_stat |=FTGMAC100_TXDES0_LTS ; txdes->txdes3 =cpu_to_le32 (map); - -/* Setup HW checksumming */ - csum_vlan =0 ; -if (skb->ip_summed ==CHECKSUM_PARTIAL && - !ftgmac100_prep_tx_csum (skb, &csum_vlan)) - goto drop; - -/* Add VLAN tag */ -if (skb_vlan_tag_present (skb)) { - csum_vlan |=FTGMAC100_TXDES1_INS_VLANTAG ; - csum_vlan |=skb_vlan_tag_get (skb) &0xffff ; - } - txdes->txdes1 =cpu_to_le32 (csum_vlan);/* Next descriptor */
Greg Kroah-Hartman
maintainerPATCH 29/62 net: fix sk_page_frag() recursion from memory reclaim
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
[ Upstream commit 20eb4f29b60286e0d6dc01d9c260b4bd383c58fb ]
sk_page_frag() optimizes skb_frag allocations by using per-task skb_frag cache when it knows it's the only user. The condition is determined by seeing whether the socket allocation mask allows blocking - if the allocation may block, it obviously owns the task's context and ergo exclusively owns current->task_frag.
Unfortunately, this misses recursion through memory reclaim path. Please take a look at the following backtrace.
[2] RIP: 0010:tcp_sendmsg_locked+0xccf/0xe10
...
tcp_sendmsg+0x27/0x40
sock_sendmsg+0x30/0x40
sock_xmit.isra.24+0xa1/0x170 [nbd]
nbd_send_cmd+0x1d2/0x690 [nbd]
nbd_queue_rq+0x1b5/0x3b0 [nbd]
__blk_mq_try_issue_directly+0x108/0x1b0
blk_mq_request_issue_directly+0xbd/0xe0
blk_mq_try_issue_list_directly+0x41/0xb0
blk_mq_sched_insert_requests+0xa2/0xe0
blk_mq_flush_plug_list+0x205/0x2a0
blk_flush_plug_list+0xc3/0xf0
[1] blk_finish_plug+0x21/0x2e
_xfs_buf_ioapply+0x313/0x460
__xfs_buf_submit+0x67/0x220
xfs_buf_read_map+0x113/0x1a0
xfs_trans_read_buf_map+0xbf/0x330
xfs_btree_read_buf_block.constprop.42+0x95/0xd0
xfs_btree_lookup_get_block+0x95/0x170
xfs_btree_lookup+0xcc/0x470
xfs_bmap_del_extent_real+0x254/0x9a0
__xfs_bunmapi+0x45c/0xab0
xfs_bunmapi+0x15/0x30
xfs_itruncate_extents_flags+0xca/0x250
xfs_free_eofblocks+0x181/0x1e0
xfs_fs_destroy_inode+0xa8/0x1b0
destroy_inode+0x38/0x70
dispose_list+0x35/0x50
prune_icache_sb+0x52/0x70
super_cache_scan+0x120/0x1a0
do_shrink_slab+0x120/0x290
shrink_slab+0x216/0x2b0
shrink_node+0x1b6/0x4a0
do_try_to_free_pages+0xc6/0x370
try_to_free_mem_cgroup_pages+0xe3/0x1e0
try_charge+0x29e/0x790
mem_cgroup_charge_skmem+0x6a/0x100
__sk_mem_raise_allocated+0x18e/0x390
__sk_mem_schedule+0x2a/0x40
[0] tcp_sendmsg_locked+0x8eb/0xe10
tcp_sendmsg+0x27/0x40
sock_sendmsg+0x30/0x40
___sys_sendmsg+0x26d/0x2b0
__sys_sendmsg+0x57/0xa0
do_syscall_64+0x42/0x100
entry_SYSCALL_64_after_hwframe+0x44/0xa9In [0], tcp_send_msg_locked() was using current->page_frag when it called sk_wmem_schedule(). It already calculated how many bytes can be fit into current->page_frag. Due to memory pressure, sk_wmem_schedule() called into memory reclaim path which called into xfs and then IO issue path. Because the filesystem in question is backed by nbd, the control goes back into the tcp layer - back into tcp_sendmsg_locked().
nbd sets sk_allocation to (GFP_NOIO | __GFP_MEMALLOC) which makes sense - it's in the process of freeing memory and wants to be able to, e.g., drop clean pages to make forward progress. However, this confused sk_page_frag() called from [2]. Because it only tests whether the allocation allows blocking which it does, it now thinks current->page_frag can be used again although it already was being used in [0].
After [2] used current->page_frag, the offset would be increased by the used amount. When the control returns to [0], current->page_frag's offset is increased and the previously calculated number of bytes now may overrun the end of allocated memory leading to silent memory corruptions.
Fix it by adding gfpflags_normal_context() which tests sleepable && !reclaim and use it to determine whether to use current->task_frag.
v2: Eric didn't like gfp flags being tested twice. Introduce a new
helper gfpflags_normal_context() and combine the two tests.
--- include/linux/gfp.h | 23 +++++++++++++++++++++++ include/net/sock.h | 11 ++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-)
include/linux/gfp.h +23 -0
@@ -313,6 +313,29 @@ static inline bool gfpflags_allow_blockireturn !!(gfp_flags & __GFP_DIRECT_RECLAIM); } +/** +* gfpflags_normal_context - is gfp_flags a normal sleepable context? +* @gfp_flags: gfp_flags to test +* +* Test whether @gfp_flags indicates that the allocation is from the +* %current context and allowed to sleep. +* +* An allocation being allowed to block doesn't mean it owns the %current +* context. When direct reclaim path tries to allocate memory, the +* allocation context is nested inside whatever %current was doing at the +* time of the original allocation. The nested allocation may be allowed +* to block but modifying anything %current owns can corrupt the outer +* context's expectations. +* +* %true result from this function indicates that the allocation context +* can sleep and use anything that's associated with %current. +*/ +static inline bool gfpflags_normal_context (const gfp_t gfp_flags) +{ +return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) == + __GFP_DIRECT_RECLAIM; +} +#ifdef CONFIG_HIGHMEM #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM#else
include/net/sock.h +8 -3
@@ -2131,12 +2131,17 @@ struct sk_buff *sk_stream_alloc_skb(stru* sk_page_frag - return an appropriate page_frag * @sk: socket * -* If socket allocation mode allows current thread to sleep, it means its -* safe to use the per task page_frag instead of the per socket one. +* Use the per task page_frag instead of the per socket one for +* optimization when we know that we're in the normal context and owns +* everything that's associated with %current. +* +* gfpflags_allow_blocking() isn't enough here as direct reclaim may nest +* inside other socket operations and end up recursing into sk_page_frag() +* while it's already in use. */ static inline struct page_frag *sk_page_frag (struct sock *sk) { -if (gfpflags_allow_blocking (sk->sk_allocation)) +if (gfpflags_normal_context (sk->sk_allocation))return ¤t->task_frag;return &sk->sk_frag;
Greg Kroah-Hartman
maintainerPATCH 30/62 net: hisilicon: Fix ping latency when deal with high throughput
In reply to Greg Kroah-HartmanFrom: Jiangfeng Xiao <[email protected]>
[ Upstream commit e56bd641ca61beb92b135298d5046905f920b734 ]
This is due to error in over budget processing.
When dealing with high throughput, the used buffers
that exceeds the budget is not cleaned up. In addition, it takes a lot of cycles to clean up the used buffer,
and then the buffer where the valid data is located can take effect.
--- drivers/net/ethernet/hisilicon/hip04_eth.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ethernet/hisilicon/hip04_eth.c +9 -6
@@ -174,6 +174,7 @@ struct hip04_priv {dma_addr_t rx_phys[RX_DESC_NUM ];unsigned int rx_head;unsigned int rx_buf_size; +unsigned int rx_cnt_remaining;struct device_node *phy_node;struct phy_device *phy;
@@ -487,7 +488,6 @@ static int hip04_rx_poll(struct napi_str struct hip04_priv *priv = container_of(napi, struct hip04_priv, napi);struct net_device *ndev = priv->ndev;struct net_device_stats *stats = &ndev->stats; -unsigned int cnt =hip04_recv_cnt (priv);struct rx_desc *desc;struct sk_buff *skb;unsigned char *buf;
@@ -500,8 +500,8 @@ static int hip04_rx_poll(struct napi_str/* clean up tx descriptors */ tx_remaining =hip04_tx_reclaim (ndev, false); - -while (cnt && !last) { + priv->rx_cnt_remaining +=hip04_recv_cnt (priv); +while (priv->rx_cnt_remaining && !last) { buf = priv->rx_buf[priv->rx_head]; skb =build_skb (buf, priv->rx_buf_size);if (unlikely (!skb)) {
@@ -547,11 +547,13 @@ refill:hip04_set_recv_desc (priv, phys); priv->rx_head =RX_NEXT (priv->rx_head); -if (rx >= budget) +if (rx >= budget) { + --priv->rx_cnt_remaining; goto done; + } -if (--cnt ==0 ) - cnt =hip04_recv_cnt (priv); +if (--priv->rx_cnt_remaining ==0 ) + priv->rx_cnt_remaining +=hip04_recv_cnt (priv); }if (!(priv->reg_inten &RCV_INT )) {
@@ -636,6 +638,7 @@ static int hip04_mac_open(struct net_devint i; priv->rx_head =0 ; + priv->rx_cnt_remaining =0 ; priv->tx_head =0 ; priv->tx_tail =0 ;hip04_reset_ppe (priv);
Greg Kroah-Hartman
maintainerPATCH 31/62 net/mlx4_core: Dynamically set guaranteed amount of counters per VF
In reply to Greg Kroah-HartmanFrom: Eran Ben Elisha <[email protected]>
[ Upstream commit e19868efea0c103f23b4b7e986fd0a703822111f ]
Prior to this patch, the amount of counters guaranteed per VF in the resource tracker was MLX4_VF_COUNTERS_PER_PORT * MLX4_MAX_PORTS. It was set regardless if the VF was single or dual port.
This caused several VFs to have no guaranteed counters although the system could satisfy their request.
The fix is to dynamically guarantee counters, based on each VF specification.
--- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 42 +++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +26 -16
@@ -471,12 +471,31 @@ void mlx4_init_quotas(struct mlx4_dev *d priv->mfunc.master.res_tracker.res_alloc[RES_MPT ].quota[pf]; } -static int get_max_gauranteed_vfs_counter (struct mlx4_dev *dev) +static int +mlx4_calc_res_counter_guaranteed (struct mlx4_dev *dev, +struct resource_allocator *res_alloc, +int vf) { -/* reduce the sink counter */ -return (dev->caps.max_counters -1 - - (MLX4_PF_COUNTERS_PER_PORT *MLX4_MAX_PORTS )) - /MLX4_MAX_PORTS ; +struct mlx4_active_ports actv_ports; +int ports, counters_guaranteed; + +/* For master, only allocate according to the number of phys ports */ +if (vf ==mlx4_master_func_num (dev)) +return MLX4_PF_COUNTERS_PER_PORT * dev->caps.num_ports; + +/* calculate real number of ports for the VF */ + actv_ports =mlx4_get_active_ports (dev, vf); + ports =bitmap_weight (actv_ports.ports, dev->caps.num_ports); + counters_guaranteed = ports *MLX4_VF_COUNTERS_PER_PORT ; + +/* If we do not have enough counters for this VF, do not +* allocate any for it. '-1' to reduce the sink counter. +*/ +if ((res_alloc->res_reserved + counters_guaranteed) > + (dev->caps.max_counters -1 )) +return 0 ; + +return counters_guaranteed; }int mlx4_init_resource_tracker (struct mlx4_dev *dev)
@@ -484,7 +503,6 @@ int mlx4_init_resource_tracker(struct mlstruct mlx4_priv *priv =mlx4_priv (dev);int i, j;int t; -int max_vfs_guarantee_counter =get_max_gauranteed_vfs_counter (dev); priv->mfunc.master.res_tracker.slave_list = kzalloc(dev->num_slaves * sizeof(struct slave_list),
@@ -601,16 +619,8 @@ int mlx4_init_resource_tracker(struct mlbreak ;case RES_COUNTER : res_alloc->quota[t] = dev->caps.max_counters; -if (t ==mlx4_master_func_num (dev)) - res_alloc->guaranteed[t] = -MLX4_PF_COUNTERS_PER_PORT * -MLX4_MAX_PORTS ; -else if (t <= max_vfs_guarantee_counter) - res_alloc->guaranteed[t] = -MLX4_VF_COUNTERS_PER_PORT * -MLX4_MAX_PORTS ; -else - res_alloc->guaranteed[t] =0 ; + res_alloc->guaranteed[t] = +mlx4_calc_res_counter_guaranteed (dev, res_alloc, t);break ;default :break ;
Greg Kroah-Hartman
maintainerPATCH 32/62 net: Zeroing the structure ethtool_wolinfo in ethtool_get_wol()
In reply to Greg Kroah-HartmanFrom: zhanglin <[email protected]>
[ Upstream commit 5ff223e86f5addbfae26419cbb5d61d98f6fbf7d ]
memset() the structure ethtool_wolinfo that has padded bytes but the padded bytes have not been zeroed out.
--- net/core/ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/ethtool.c +3 -1
@@ -1450,11 +1450,13 @@ static int ethtool_reset(struct net_devistatic int ethtool_get_wol (struct net_device *dev,char __user *useraddr) { -struct ethtool_wolinfo wol = { .cmd =ETHTOOL_GWOL }; +struct ethtool_wolinfo wol;if (!dev->ethtool_ops->get_wol)return -EOPNOTSUPP ; +memset (&wol,0 ,sizeof (struct ethtool_wolinfo )); + wol.cmd =ETHTOOL_GWOL ; dev->ethtool_ops->get_wol (dev, &wol);if (copy_to_user (useraddr, &wol,sizeof (wol)))
Greg Kroah-Hartman
maintainerPATCH 33/62 selftests: net: reuseport_dualstack: fix uninitalized parameter
In reply to Greg Kroah-HartmanFrom: Wei Wang <[email protected]>
[ Upstream commit d64479a3e3f9924074ca7b50bd72fa5211dca9c1 ]
This test reports EINVAL for getsockopt(SOL_SOCKET, SO_DOMAIN) occasionally due to the uninitialized length parameter. Initialize it to fix this, and also use int for "test_family" to comply with the API standard.
--- tools/testing/selftests/net/reuseport_dualstack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/reuseport_dualstack.c +2 -1
@@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count {struct epoll_event ev;int epfd, i, test_fd; -uint16_t test_family; +int test_family;socklen_t len; epfd =epoll_create (1 );
@@ -146,6 +146,7 @@ static void test(int *rcv_fds, int countsend_from_v4 (proto); test_fd =receive_once (epfd, proto); + len =sizeof (test_family);if (getsockopt (test_fd,SOL_SOCKET ,SO_DOMAIN , &test_family, &len))error (1 , errno,"failed to read socket domain" );if (test_family !=AF_INET )
Greg Kroah-Hartman
maintainerPATCH 34/62 udp: fix data-race in udp_set_dev_scratch()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit a793183caa9afae907a0d7ddd2ffd57329369bf5 ]
KCSAN reported a data-race in udp_set_dev_scratch() [1]
The issue here is that we must not write over skb fields if skb is shared. A similar issue has been fixed in commit 89c22d8c3b27 ("net: Fix skb csum races when peeking")
While we are at it, use a helper only dealing with udp_skb_scratch(skb)->csum_unnecessary, as this allows udp_set_dev_scratch() to be called once and thus inlined.
[1]
BUG: KCSAN: data-race in udp_set_dev_scratch / udpv6_recvmsg
write to 0xffff888120278317 of 1 bytes by task 10411 on cpu 1:
udp_set_dev_scratch+0xea/0x200 net/ipv4/udp.c:1308 __first_packet_length+0x147/0x420 net/ipv4/udp.c:1556 first_packet_length+0x68/0x2a0 net/ipv4/udp.c:1579 udp_poll+0xea/0x110 net/ipv4/udp.c:2720 sock_poll+0xed/0x250 net/socket.c:1256 vfs_poll include/linux/poll.h:90 [inline] do_select+0x7d0/0x1020 fs/select.c:534 core_sys_select+0x381/0x550 fs/select.c:677 do_pselect.constprop.0+0x11d/0x160 fs/select.c:759 __do_sys_pselect6 fs/select.c:784 [inline] __se_sys_pselect6 fs/select.c:769 [inline] __x64_sys_pselect6+0x12e/0x170 fs/select.c:769 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
read to 0xffff888120278317 of 1 bytes by task 10413 on cpu 0:
udp_skb_csum_unnecessary include/net/udp.h:358 [inline] udpv6_recvmsg+0x43e/0xe90 net/ipv6/udp.c:310 inet6_recvmsg+0xbb/0x240 net/ipv6/af_inet6.c:592 sock_recvmsg_nosec+0x5c/0x70 net/socket.c:871 ___sys_recvmsg+0x1a0/0x3e0 net/socket.c:2480 do_recvmmsg+0x19a/0x5c0 net/socket.c:2601 __sys_recvmmsg+0x1ef/0x200 net/socket.c:2680 __do_sys_recvmmsg net/socket.c:2703 [inline] __se_sys_recvmmsg net/socket.c:2696 [inline] __x64_sys_recvmmsg+0x89/0xb0 net/socket.c:2696 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 10413 Comm: syz-executor.0 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- net/ipv4/udp.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
net/ipv4/udp.c +15 -4
@@ -1195,6 +1195,20 @@ static void udp_set_dev_scratch(struct s scratch->_tsize_state |=UDP_SKB_IS_STATELESS ; } +static void udp_skb_csum_unnecessary_set (struct sk_buff *skb) +{ +/* We come here after udp_lib_checksum_complete() returned 0. +* This means that __skb_checksum_complete() might have +* set skb->csum_valid to 1. +* On 64bit platforms, we can set csum_unnecessary +* to true, but only if the skb is not shared. +*/ +#if BITS_PER_LONG ==64 +if (!skb_shared (skb)) +udp_skb_scratch (skb)->csum_unnecessary = true; +#endif +} +static int udp_skb_truesize (struct sk_buff *skb) {return udp_skb_scratch (skb)->_tsize_state & ~UDP_SKB_IS_STATELESS ;
@@ -1430,10 +1444,7 @@ static struct sk_buff *__first_packet_le *total += skb->truesize;kfree_skb (skb); }else { -/* the csum related bits could be changed, refresh -* the scratch area -*/ -udp_set_dev_scratch (skb); +udp_skb_csum_unnecessary_set (skb);break ; } }
Greg Kroah-Hartman
maintainerPATCH 35/62 net: add READ_ONCE() annotation in __skb_wait_for_more_packets()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 7c422d0ce97552dde4a97e6290de70ec6efb0fc6 ]
__skb_wait_for_more_packets() can be called while other cpus can feed packets to the socket receive queue.
KCSAN reported :
BUG: KCSAN: data-race in __skb_wait_for_more_packets / __udp_enqueue_schedule_skb
write to 0xffff888102e40b58 of 8 bytes by interrupt on cpu 0:
__skb_insert include/linux/skbuff.h:1852 [inline] __skb_queue_before include/linux/skbuff.h:1958 [inline] __skb_queue_tail include/linux/skbuff.h:1991 [inline] __udp_enqueue_schedule_skb+0x2d7/0x410 net/ipv4/udp.c:1470 __udp_queue_rcv_skb net/ipv4/udp.c:1940 [inline] udp_queue_rcv_one_skb+0x7bd/0xc70 net/ipv4/udp.c:2057 udp_queue_rcv_skb+0xb5/0x400 net/ipv4/udp.c:2074 udp_unicast_rcv_skb.isra.0+0x7e/0x1c0 net/ipv4/udp.c:2233 __udp4_lib_rcv+0xa44/0x17c0 net/ipv4/udp.c:2300 udp_rcv+0x2b/0x40 net/ipv4/udp.c:2470 ip_protocol_deliver_rcu+0x4d/0x420 net/ipv4/ip_input.c:204 ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252 dst_input include/net/dst.h:442 [inline] ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955
read to 0xffff888102e40b58 of 8 bytes by task 13035 on cpu 1:
__skb_wait_for_more_packets+0xfa/0x320 net/core/datagram.c:100 __skb_recv_udp+0x374/0x500 net/ipv4/udp.c:1683 udp_recvmsg+0xe1/0xb10 net/ipv4/udp.c:1712 inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838 sock_recvmsg_nosec+0x5c/0x70 net/socket.c:871 ___sys_recvmsg+0x1a0/0x3e0 net/socket.c:2480 do_recvmmsg+0x19a/0x5c0 net/socket.c:2601 __sys_recvmmsg+0x1ef/0x200 net/socket.c:2680 __do_sys_recvmmsg net/socket.c:2703 [inline] __se_sys_recvmmsg net/socket.c:2696 [inline] __x64_sys_recvmmsg+0x89/0xb0 net/socket.c:2696 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 13035 Comm: syz-executor.3 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- net/core/datagram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/datagram.c +1 -1
@@ -97,7 +97,7 @@ int __skb_wait_for_more_packets(struct sif (error) goto out_err; -if (sk->sk_receive_queue.prev != skb) +if (READ_ONCE (sk->sk_receive_queue.prev) != skb) goto out;/* Socket shut down? */
Greg Kroah-Hartman
maintainerPATCH 36/62 net/mlx5e: Fix handling of compressed CQEs in case of low NAPI budget
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 9df86bdb6746d7fcfc2fda715f7a7c3d0ddb2654 ]
When CQE compression is enabled, compressed CQEs use the following
structure: a title is followed by one or many blocks, each containing 8 mini CQEs (except the last, which may contain fewer mini CQEs).
Due to NAPI budget restriction, a complete structure is not always parsed in one NAPI run, and some blocks with mini CQEs may be deferred to the next NAPI poll call - we have the mlx5e_decompress_cqes_cont call in the beginning of mlx5e_poll_rx_cq. However, if the budget is extremely low, some blocks may be left even after that, but the code that follows the mlx5e_decompress_cqes_cont call doesn't check it and assumes that a new CQE begins, which may not be the case. In such cases, random memory corruptions occur.
An extremely low NAPI budget of 8 is used when busy_poll or busy_read is active.
This commit adds a check to make sure that the previous compressed CQE has been completely parsed after mlx5e_decompress_cqes_cont, otherwise it prevents a new CQE from being fetched in the middle of a compressed CQE.
This commit fixes random crashes in __build_skb, __page_pool_put_page and other not-related-directly places, that used to happen when both CQE compression and busy_poll/busy_read were enabled.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -1
@@ -1093,8 +1093,11 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cqif (unlikely (!MLX5E_TEST_BIT (rq->state,MLX5E_RQ_STATE_ENABLED )))return 0 ; -if (cq->decmprs_left) +if (cq->decmprs_left) { work_done +=mlx5e_decompress_cqes_cont (rq, cq,0 , budget); +if (cq->decmprs_left || work_done >= budget) + goto out; + } cqe =mlx5_cqwq_get_cqe (&cq->wq);if (!cqe) {
Greg Kroah-Hartman
maintainerPATCH 37/62 net: dsa: b53: Do not clear existing mirrored port mask
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit c763ac436b668d7417f0979430ec0312ede4093d ]
Clearing the existing bitmask of mirrored ports essentially prevents us from capturing more than one port at any given time. This is clearly wrong, do not clear the bitmask prior to setting up the new port.
--- drivers/net/dsa/b53/b53_common.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +0 -1
@@ -1431,7 +1431,6 @@ int b53_mirror_add(struct dsa_switch *ds loc =B53_EG_MIR_CTL ;b53_read16 (dev,B53_MGMT_PAGE , loc, ®); - reg &= ~MIRROR_MASK ; reg |=BIT (port);b53_write16 (dev,B53_MGMT_PAGE , loc, reg);
Greg Kroah-Hartman
maintainerPATCH 38/62 net: usb: lan78xx: Connect PHY before registering MAC
In reply to Greg Kroah-HartmanFrom: Andrew Lunn <[email protected]>
[ Upstream commit 38b4fe320119859c11b1dc06f6b4987a16344fa1 ]
As soon as the netdev is registers, the kernel can start using the interface. If the driver connects the MAC to the PHY after the netdev is registered, there is a race condition where the interface can be opened without having the PHY connected.
Change the order to close this race condition.
--- drivers/net/usb/lan78xx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/usb/lan78xx.c +6 -6
@@ -3642,10 +3642,14 @@ static int lan78xx_probe(struct usb_inte/* driver requires remote-wakeup capability during autosuspend. */ intf->needs_remote_wakeup =1 ; + ret =lan78xx_phy_init (dev); +if (ret <0 ) + goto out4; + ret =register_netdev (netdev);if (ret !=0 ) {netif_err (dev, probe, netdev,"couldn't register the device\n" ); - goto out4; + goto out5; }usb_set_intfdata (intf, dev);
@@ -3658,14 +3662,10 @@ static int lan78xx_probe(struct usb_intepm_runtime_set_autosuspend_delay (&udev->dev,DEFAULT_AUTOSUSPEND_DELAY ); - ret =lan78xx_phy_init (dev); -if (ret <0 ) - goto out5; -return 0 ; out5: -unregister_netdev (netdev); +phy_disconnect (netdev->phydev); out4:usb_free_urb (dev->urb_intr); out3:
Greg Kroah-Hartman
maintainerPATCH 39/62 r8152: add device id for Lenovo ThinkPad USB-C Dock Gen 2
In reply to Greg Kroah-HartmanFrom: Kazutoshi Noguchi <[email protected]>
[ Upstream commit b3060531979422d5bb18d80226f978910284dc70 ]
This device is sold as 'ThinkPad USB-C Dock Gen 2 (40AS)'. Chipset is RTL8153 and works with r8152.
Without this, the generic cdc_ether grabs the device, and the device jam connected networks up when the machine suspends.
--- drivers/net/usb/cdc_ether.c | 7 +++++++ drivers/net/usb/r8152.c | 1 + 2 files changed, 8 insertions(+)
drivers/net/usb/cdc_ether.c +7 -0
@@ -800,6 +800,13 @@ static const struct usb_device_id produc .driver_info = 0, }, +/* ThinkPad USB-C Dock Gen 2 (based on Realtek RTL8153) */ +{ +USB_DEVICE_AND_INTERFACE_INFO (LENOVO_VENDOR_ID ,0xa387 ,USB_CLASS_COMM , + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), + .driver_info =0 , +}, + /* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ { USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM,
drivers/net/usb/r8152.c +1 -0
@@ -5324,6 +5324,7 @@ static const struct usb_device_id rtl815 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)}, {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c)}, {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214)}, + {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387)}, {REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041)}, {REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff)}, {REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601)},
Greg Kroah-Hartman
maintainerPATCH 40/62 net: dsa: fix switch tree list
In reply to Greg Kroah-HartmanFrom: Vivien Didelot <[email protected]>
[ Upstream commit 50c7d2ba9de20f60a2d527ad6928209ef67e4cdd ]
If there are multiple switch trees on the device, only the last one will be listed, because the arguments of list_add_tail are swapped.
--- net/dsa/dsa2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/dsa/dsa2.c +1 -1
@@ -62,7 +62,7 @@ static struct dsa_switch_tree *dsa_add_dreturn NULL ; dst->tree = tree;INIT_LIST_HEAD (&dst->list); -list_add_tail (&dsa_switch_trees, &dst->list); +list_add_tail (&dst->list, &dsa_switch_trees);kref_init (&dst->refcount);return dst;
Greg Kroah-Hartman
maintainerPATCH 41/62 net: bcmgenet: reset 40nm EPHY on energy detect
In reply to Greg Kroah-HartmanFrom: Doug Berger <[email protected]>
[ Upstream commit 25382b991d252aed961cd434176240f9de6bb15f ]
The EPHY integrated into the 40nm Set-Top Box devices can falsely detect energy when connected to a disabled peer interface. When the peer interface is enabled the EPHY will detect and report the link as active, but on occasion may get into a state where it is not able to exchange data with the connected GENET MAC. This issue has not been observed when the link parameters are auto-negotiated; however, it has been observed with a manually configured link.
It has been empirically determined that issuing a soft reset to the EPHY when energy is detected prevents it from getting into this bad state.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +7 -2
@@ -1985,6 +1985,8 @@ static void bcmgenet_link_intr_enable(st*/ if (priv->internal_phy) { int0_enable |=UMAC_IRQ_LINK_EVENT ; +if (GENET_IS_V1 (priv) ||GENET_IS_V2 (priv) ||GENET_IS_V3 (priv)) + int0_enable |=UMAC_IRQ_PHY_DET_R ; }else if (priv->ext_phy) { int0_enable |=UMAC_IRQ_LINK_EVENT ; }else if (priv->phy_interface ==PHY_INTERFACE_MODE_MOCA ) {
@@ -2608,6 +2610,10 @@ static void bcmgenet_irq_task(struct worbcmgenet_power_up (priv,GENET_POWER_WOL_MAGIC ); } +if (status &UMAC_IRQ_PHY_DET_R && + priv->dev->phydev->autoneg !=AUTONEG_ENABLE ) +phy_init_hw (priv->dev->phydev); +/* Link UP/DOWN event */ if (status &UMAC_IRQ_LINK_EVENT ) phy_mac_interrupt(priv->phydev,
@@ -2713,8 +2719,7 @@ static irqreturn_t bcmgenet_isr0(int irq }/* all other interested interrupts handled in bottom half */ - status &= (UMAC_IRQ_LINK_EVENT | -UMAC_IRQ_MPD_R ); + status &= (UMAC_IRQ_LINK_EVENT |UMAC_IRQ_MPD_R |UMAC_IRQ_PHY_DET_R );if (status) {/* Save irq status for bottom-half processing. */ spin_lock_irqsave (&priv->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 42/62 net: add skb_queue_empty_lockless()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d7d16a89350ab263484c0aa2b523dd3a234e4a80 ]
Some paths call skb_queue_empty() without holding the queue lock. We must use a barrier in order to not let the compiler do strange things, and avoid KCSAN splats.
Adding a barrier in skb_queue_empty() might be overkill, I prefer adding a new helper to clearly identify points where the callers might be lockless. This might help us finding real bugs.
The corresponding WRITE_ONCE() should add zero cost for current compilers.
--- include/linux/skbuff.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
include/linux/skbuff.h +24 -9
@@ -1346,6 +1346,19 @@ static inline int skb_queue_empty(const }/** +* skb_queue_empty_lockless - check if a queue is empty +* @list: queue head +* +* Returns true if the queue is empty, false otherwise. +* This variant can be used in lockless contexts. +*/ +static inline bool skb_queue_empty_lockless (const struct sk_buff_head *list) +{ +return READ_ONCE (list->next) == (const struct sk_buff *) list; +} + + +/** * skb_queue_is_last - check if skb is the last entry in the queue * @list: queue head * @skb: buffer
@@ -1709,9 +1722,11 @@ static inline void __skb_insert(struct s struct sk_buff *prev, struct sk_buff *next, struct sk_buff_head *list) { - newsk->next = next; - newsk->prev = prev; - next->prev = prev->next = newsk; +/* see skb_queue_empty_lockless() for the opposite READ_ONCE() */ + WRITE_ONCE(newsk->next, next); +WRITE_ONCE (newsk->prev, prev); +WRITE_ONCE (next->prev, newsk); +WRITE_ONCE (prev->next, newsk); list->qlen++; }
@@ -1722,11 +1737,11 @@ static inline void __skb_queue_splice(costruct sk_buff *first = list->next;struct sk_buff *last = list->prev; - first->prev = prev; - prev->next = first; +WRITE_ONCE (first->prev, prev); +WRITE_ONCE (prev->next, first); - last->next = next; - next->prev = last; +WRITE_ONCE (last->next, next); +WRITE_ONCE (next->prev, last); }/**
@@ -1867,8 +1882,8 @@ static inline void __skb_unlink(struct s next = skb->next; prev = skb->prev; skb->next = skb->prev =NULL ; - next->prev = prev; - prev->next = next; +WRITE_ONCE (next->prev, prev); +WRITE_ONCE (prev->next, next); }/**
Greg Kroah-Hartman
maintainerPATCH 43/62 udp: use skb_queue_empty_lockless()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 137a0dbe3426fd7bcfe3f8117b36a87b3590e4eb ]
syzbot reported a data-race [1].
We should use skb_queue_empty_lockless() to document that we are not ensuring a mutual exclusion and silence KCSAN.
[1]
BUG: KCSAN: data-race in __skb_recv_udp / __udp_enqueue_schedule_skb
write to 0xffff888122474b50 of 8 bytes by interrupt on cpu 0:
__skb_insert include/linux/skbuff.h:1852 [inline] __skb_queue_before include/linux/skbuff.h:1958 [inline] __skb_queue_tail include/linux/skbuff.h:1991 [inline] __udp_enqueue_schedule_skb+0x2c1/0x410 net/ipv4/udp.c:1470 __udp_queue_rcv_skb net/ipv4/udp.c:1940 [inline] udp_queue_rcv_one_skb+0x7bd/0xc70 net/ipv4/udp.c:2057 udp_queue_rcv_skb+0xb5/0x400 net/ipv4/udp.c:2074 udp_unicast_rcv_skb.isra.0+0x7e/0x1c0 net/ipv4/udp.c:2233 __udp4_lib_rcv+0xa44/0x17c0 net/ipv4/udp.c:2300 udp_rcv+0x2b/0x40 net/ipv4/udp.c:2470 ip_protocol_deliver_rcu+0x4d/0x420 net/ipv4/ip_input.c:204 ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252 dst_input include/net/dst.h:442 [inline] ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413 NF_HOOK include/linux/netfilter.h:305 [inline] NF_HOOK include/linux/netfilter.h:299 [inline] ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523 __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5010 __netif_receive_skb+0x37/0xf0 net/core/dev.c:5124 process_backlog+0x1d3/0x420 net/core/dev.c:5955
read to 0xffff888122474b50 of 8 bytes by task 8921 on cpu 1:
skb_queue_empty include/linux/skbuff.h:1494 [inline] __skb_recv_udp+0x18d/0x500 net/ipv4/udp.c:1653 udp_recvmsg+0xe1/0xb10 net/ipv4/udp.c:1712 inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838 sock_recvmsg_nosec+0x5c/0x70 net/socket.c:871 ___sys_recvmsg+0x1a0/0x3e0 net/socket.c:2480 do_recvmmsg+0x19a/0x5c0 net/socket.c:2601 __sys_recvmmsg+0x1ef/0x200 net/socket.c:2680 __do_sys_recvmmsg net/socket.c:2703 [inline] __se_sys_recvmmsg net/socket.c:2696 [inline] __x64_sys_recvmmsg+0x89/0xb0 net/socket.c:2696 do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 8921 Comm: syz-executor.4 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- net/ipv4/udp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv4/udp.c +3 -3
@@ -1468,7 +1468,7 @@ static int first_packet_length(struct sospin_lock_bh (&rcvq->lock); skb =__first_packet_length (sk, rcvq, &total); -if (!skb && !skb_queue_empty (sk_queue)) { +if (!skb && !skb_queue_empty_lockless (sk_queue)) {spin_lock (&sk_queue->lock);skb_queue_splice_tail_init (sk_queue, rcvq);spin_unlock (&sk_queue->lock);
@@ -1543,7 +1543,7 @@ struct sk_buff *__skb_recv_udp(struct soreturn skb; } -if (skb_queue_empty (sk_queue)) { +if (skb_queue_empty_lockless (sk_queue)) {spin_unlock_bh (&queue->lock); goto busy_check; }
@@ -1570,7 +1570,7 @@ busy_check:break ;sk_busy_loop (sk, flags &MSG_DONTWAIT ); - }while (!skb_queue_empty (sk_queue)); + }while (!skb_queue_empty_lockless (sk_queue));/* sk_queue is empty, reader_queue may contain peeked packets */ } while (timeo &&
Greg Kroah-Hartman
maintainerPATCH 44/62 net: use skb_queue_empty_lockless() in poll() handlers
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 3ef7cf57c72f32f61e97f8fa401bc39ea1f1a5d4 ]
Many poll() handlers are lockless. Using skb_queue_empty_lockless() instead of skb_queue_empty() is more appropriate.
--- drivers/isdn/capi/capi.c | 2 +- net/atm/common.c | 2 +- net/bluetooth/af_bluetooth.c | 4 ++-- net/caif/caif_socket.c | 2 +- net/core/datagram.c | 4 ++-- net/ipv4/tcp.c | 2 +- net/ipv4/udp.c | 2 +- net/nfc/llcp_sock.c | 4 ++-- net/phonet/socket.c | 4 ++-- net/sctp/socket.c | 4 ++-- net/tipc/socket.c | 4 ++-- net/unix/af_unix.c | 6 +++--- net/vmw_vsock/af_vsock.c | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-)
drivers/isdn/capi/capi.c +1 -1
@@ -743,7 +743,7 @@ capi_poll(struct file *file, poll_tablepoll_wait (file, &(cdev->recvwait), wait); mask =POLLOUT |POLLWRNORM ; -if (!skb_queue_empty (&cdev->recvqueue)) +if (!skb_queue_empty_lockless (&cdev->recvqueue)) mask |=POLLIN |POLLRDNORM ;return mask; }
net/atm/common.c +1 -1
@@ -667,7 +667,7 @@ unsigned int vcc_poll(struct file *file, mask |=POLLHUP ;/* readable? */ -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;/* writable? */
net/bluetooth/af_bluetooth.c +2 -2
@@ -460,7 +460,7 @@ unsigned int bt_sock_poll(struct file *fif (sk->sk_state ==BT_LISTEN )return bt_accept_poll (sk); -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR | (sock_flag (sk,SOCK_SELECT_ERR_QUEUE ) ?POLLPRI :0 );
@@ -470,7 +470,7 @@ unsigned int bt_sock_poll(struct file *fif (sk->sk_shutdown ==SHUTDOWN_MASK ) mask |=POLLHUP ; -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;if (sk->sk_state ==BT_CLOSED )
net/caif/caif_socket.c +1 -1
@@ -953,7 +953,7 @@ static unsigned int caif_poll(struct fil mask |=POLLRDHUP ;/* readable? */ -if (!skb_queue_empty (&sk->sk_receive_queue) || +if (!skb_queue_empty_lockless (&sk->sk_receive_queue) || (sk->sk_shutdown &RCV_SHUTDOWN )) mask |=POLLIN |POLLRDNORM ;
net/core/datagram.c +2 -2
@@ -844,7 +844,7 @@ unsigned int datagram_poll(struct file * mask =0 ;/* exceptional events? */ -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR | (sock_flag (sk,SOCK_SELECT_ERR_QUEUE ) ?POLLPRI :0 );
@@ -854,7 +854,7 @@ unsigned int datagram_poll(struct file * mask |=POLLHUP ;/* readable? */ -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;/* Connection-based need to check for termination and startup */
net/ipv4/tcp.c +1 -1
@@ -574,7 +574,7 @@ unsigned int tcp_poll(struct file *file, }/* This barrier is coupled with smp_wmb() in tcp_reset() */ smp_rmb (); -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR ;return mask;
net/ipv4/udp.c +1 -1
@@ -2550,7 +2550,7 @@ unsigned int udp_poll(struct file *file,unsigned int mask =datagram_poll (file, sock, wait);struct sock *sk = sock->sk; -if (!skb_queue_empty (&udp_sk (sk)->reader_queue)) +if (!skb_queue_empty_lockless (&udp_sk (sk)->reader_queue)) mask |=POLLIN |POLLRDNORM ;sock_rps_record_flow (sk);
net/nfc/llcp_sock.c +2 -2
@@ -567,11 +567,11 @@ static unsigned int llcp_sock_poll(strucif (sk->sk_state ==LLCP_LISTEN )return llcp_accept_poll (sk); -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR | (sock_flag (sk,SOCK_SELECT_ERR_QUEUE ) ?POLLPRI :0 ); -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;if (sk->sk_state ==LLCP_CLOSED )
net/phonet/socket.c +2 -2
@@ -352,9 +352,9 @@ static unsigned int pn_socket_poll(strucif (sk->sk_state ==TCP_CLOSE )return POLLERR ; -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ; -if (!skb_queue_empty (&pn->ctrlreq_queue)) +if (!skb_queue_empty_lockless (&pn->ctrlreq_queue)) mask |=POLLPRI ;if (!mask && sk->sk_state ==TCP_CLOSE_WAIT )return POLLHUP ;
net/sctp/socket.c +2 -2
@@ -7371,7 +7371,7 @@ unsigned int sctp_poll(struct file *file mask =0 ;/* Is there any exceptional events? */ -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR | (sock_flag (sk,SOCK_SELECT_ERR_QUEUE ) ?POLLPRI :0 );if (sk->sk_shutdown &RCV_SHUTDOWN )
@@ -7380,7 +7380,7 @@ unsigned int sctp_poll(struct file *file mask |=POLLHUP ;/* Is it readable? Reconsider this code with TCP-style support. */ -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;/* The association is either gone or not ready. */
net/tipc/socket.c +2 -2
@@ -714,14 +714,14 @@ static unsigned int tipc_poll(struct fil/* fall thru' */ case TIPC_LISTEN :case TIPC_CONNECTING : -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |= (POLLIN |POLLRDNORM );break ;case TIPC_OPEN :if (!tsk->cong_link_cnt) mask |=POLLOUT ;if (tipc_sk_type_connectionless (sk) && - (!skb_queue_empty (&sk->sk_receive_queue))) + (!skb_queue_empty_lockless (&sk->sk_receive_queue))) mask |= (POLLIN |POLLRDNORM );break ;case TIPC_DISCONNECTING :
net/unix/af_unix.c +3 -3
@@ -2665,7 +2665,7 @@ static unsigned int unix_poll(struct fil mask |=POLLRDHUP |POLLIN |POLLRDNORM ;/* readable? */ -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;/* Connection-based need to check for termination and startup */
@@ -2693,7 +2693,7 @@ static unsigned int unix_dgram_poll(stru mask =0 ;/* exceptional events? */ -if (sk->sk_err || !skb_queue_empty (&sk->sk_error_queue)) +if (sk->sk_err || !skb_queue_empty_lockless (&sk->sk_error_queue)) mask |=POLLERR | (sock_flag (sk,SOCK_SELECT_ERR_QUEUE ) ?POLLPRI :0 );
@@ -2703,7 +2703,7 @@ static unsigned int unix_dgram_poll(stru mask |=POLLHUP ;/* readable? */ -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue)) mask |=POLLIN |POLLRDNORM ;/* Connection-based need to check for termination and startup */
net/vmw_vsock/af_vsock.c +1 -1
@@ -880,7 +880,7 @@ static unsigned int vsock_poll(struct fi* the queue and write as long as the socket isn't shutdown for * sending. */ -if (!skb_queue_empty (&sk->sk_receive_queue) || +if (!skb_queue_empty_lockless (&sk->sk_receive_queue) || (sk->sk_shutdown &RCV_SHUTDOWN )) { mask |=POLLIN |POLLRDNORM ; }
Greg Kroah-Hartman
maintainerPATCH 45/62 net: use skb_queue_empty_lockless() in busy poll contexts
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 3f926af3f4d688e2e11e7f8ed04e277a14d4d4a4 ]
Busy polling usually runs without locks.
Let's use skb_queue_empty_lockless() instead of skb_queue_empty()
Also uses READ_ONCE() in __skb_try_recv_datagram() to address a similar potential problem.
--- net/core/datagram.c | 2 +- net/core/sock.c | 2 +- net/ipv4/tcp.c | 2 +- net/sctp/socket.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
net/core/datagram.c +1 -1
@@ -281,7 +281,7 @@ struct sk_buff *__skb_try_recv_datagram(break ;sk_busy_loop (sk, flags &MSG_DONTWAIT ); - }while (sk->sk_receive_queue.prev != *last); + }while (READ_ONCE (sk->sk_receive_queue.prev) != *last); error = -EAGAIN ;
net/core/sock.c +1 -1
@@ -3381,7 +3381,7 @@ bool sk_busy_loop_end(void *p, unsigned {struct sock *sk = p; -return !skb_queue_empty (&sk->sk_receive_queue) || +return !skb_queue_empty_lockless (&sk->sk_receive_queue) ||sk_busy_loop_timeout (sk, start_time); }EXPORT_SYMBOL (sk_busy_loop_end);
net/ipv4/tcp.c +1 -1
@@ -1787,7 +1787,7 @@ int tcp_recvmsg(struct sock *sk, structif (unlikely (flags &MSG_ERRQUEUE ))return inet_recv_error (sk, msg, len, addr_len); -if (sk_can_busy_loop (sk) &&skb_queue_empty (&sk->sk_receive_queue) && +if (sk_can_busy_loop (sk) &&skb_queue_empty_lockless (&sk->sk_receive_queue) && (sk->sk_state ==TCP_ESTABLISHED ))sk_busy_loop (sk, nonblock);
net/sctp/socket.c +1 -1
@@ -7716,7 +7716,7 @@ struct sk_buff *sctp_skb_recv_datagram(sif (sk_can_busy_loop (sk)) {sk_busy_loop (sk, noblock); -if (!skb_queue_empty (&sk->sk_receive_queue)) +if (!skb_queue_empty_lockless (&sk->sk_receive_queue))continue ; }
Greg Kroah-Hartman
maintainerPATCH 46/62 vxlan: check tun_info options_len properly
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit eadf52cf1852196a1363044dcda22fa5d7f296f7 ]
This patch is to improve the tun_info options_len by dropping the skb when TUNNEL_VXLAN_OPT is set but options_len is less than vxlan_metadata. This can void a potential out-of-bounds access on ip_tun_info.
--- drivers/net/vxlan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/vxlan.c +4 -1
@@ -2169,8 +2169,11 @@ static void vxlan_xmit_one(struct sk_buf vni =tunnel_id_to_key32 (info->key.tun_id); ifindex =0 ; dst_cache = &info->dst_cache; -if (info->options_len) +if (info->options_len) { +if (info->options_len <sizeof (*md)) + goto drop; md =ip_tunnel_info_opts (info); + } ttl = info->key.ttl; tos = info->key.tos; label = info->key.label;
Greg Kroah-Hartman
maintainerPATCH 47/62 erspan: fix the tun_info options_len check for erspan
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 2eb8d6d2910cfe3dc67dc056f26f3dd9c63d47cd ]
The check for !md doens't really work for ip_tunnel_info_opts(info) which only does info + 1. Also to avoid out-of-bounds access on info, it should ensure options_len is not less than erspan_metadata in both erspan_xmit() and ip6erspan_tunnel_xmit().
--- net/ipv4/ip_gre.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/ip_gre.c +3 -0
@@ -592,6 +592,9 @@ static void erspan_fb_xmit(struct sk_buf truncate = true; } +if (tun_info->options_len <sizeof (*md)) + goto err_free_rt; + md =ip_tunnel_info_opts (tun_info);if (!md) goto err_free_rt;
Greg Kroah-Hartman
maintainerPATCH 48/62 inet: stop leaking jiffies on the wire
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit a904a0693c189691eeee64f6c6b188bd7dc244e9 ]
Historically linux tried to stick to RFC 791, 1122, 2003 for IPv4 ID field generation.
RFC 6864 made clear that no matter how hard we try, we can not ensure unicity of IP ID within maximum lifetime for all datagrams with a given source address/destination address/protocol tuple.
Linux uses a per socket inet generator (inet_id), initialized at connection startup with a XOR of 'jiffies' and other fields that appear clear on the wire.
Thiemo Nagel pointed that this strategy is a privacy concern as this provides 16 bits of entropy to fingerprint devices.
Let's switch to a random starting point, this is just as good as far as RFC 6864 is concerned and does not leak anything critical.
--- net/dccp/ipv4.c | 2 +- net/ipv4/datagram.c | 2 +- net/ipv4/tcp_ipv4.c | 4 ++-- net/sctp/socket.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
net/dccp/ipv4.c +1 -1
@@ -121,7 +121,7 @@ int dccp_v4_connect(struct sock *sk, str inet->inet_daddr, inet->inet_sport, inet->inet_dport); - inet->inet_id = dp->dccps_iss ^ jiffies; + inet->inet_id =prandom_u32 (); err =dccp_connect (sk); rt =NULL ;
net/ipv4/datagram.c +1 -1
@@ -75,7 +75,7 @@ int __ip4_datagram_connect(struct sock * inet->inet_dport = usin->sin_port; sk->sk_state =TCP_ESTABLISHED ;sk_set_txhash (sk); - inet->inet_id = jiffies; + inet->inet_id =prandom_u32 ();sk_dst_set (sk, &rt->dst); err =0 ;
net/ipv4/tcp_ipv4.c +2 -2
@@ -245,7 +245,7 @@ int tcp_v4_connect(struct sock *sk, stru inet->inet_daddr); } - inet->inet_id = tp->write_seq ^ jiffies; + inet->inet_id =prandom_u32 ();if (tcp_fastopen_defer_connect (sk, &err))return err;
@@ -1368,7 +1368,7 @@ struct sock *tcp_v4_syn_recv_sock(constinet_csk (newsk)->icsk_ext_hdr_len =0 ;if (inet_opt)inet_csk (newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; - newinet->inet_id = newtp->write_seq ^ jiffies; + newinet->inet_id =prandom_u32 ();if (!dst) { dst =inet_csk_route_child_sock (sk, newsk, req);
net/sctp/socket.c +1 -1
@@ -8136,7 +8136,7 @@ void sctp_copy_sock(struct sock *newsk, newinet->inet_rcv_saddr = inet->inet_rcv_saddr; newinet->inet_dport =htons (asoc->peer.port); newinet->pmtudisc = inet->pmtudisc; - newinet->inet_id = asoc->next_tsn ^ jiffies; + newinet->inet_id =prandom_u32 (); newinet->uc_ttl = inet->uc_ttl; newinet->mc_loop =1 ;
Greg Kroah-Hartman
maintainerPATCH 49/62 net/flow_dissector: switch to siphash
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 55667441c84fa5e0911a0aac44fb059c15ba6da2 upstream.
UDP IPv6 packets auto flowlabels are using a 32bit secret (static u32 hashrnd in net/core/flow_dissector.c) and apply jhash() over fields known by the receivers.
Attackers can easily infer the 32bit secret and use this information to identify a device and/or user, since this 32bit secret is only set at boot time.
Really, using jhash() to generate cookies sent on the wire is a serious security concern.
Trying to change the rol32(hash, 16) in ip6_make_flowlabel() would be a dead end. Trying to periodically change the secret (like in sch_sfq.c) could change paths taken in the network for long lived flows.
Let's switch to siphash, as we did in commit df453700e8d8 ("inet: switch IP ID generator to siphash")
Using a cryptographically strong pseudo random function will solve this privacy issue and more generally remove other weak points in the stack.
Packet schedulers using skb_get_hash_perturb() benefit from this change.
--- include/linux/skbuff.h | 3 +- include/net/flow_dissector.h | 3 +- include/net/fq.h | 2 - include/net/fq_impl.h | 4 +-- net/core/flow_dissector.c | 48 +++++++++++++++++-------------------------- net/sched/sch_hhf.c | 8 +++---- net/sched/sch_sfb.c | 13 ++++++----- net/sched/sch_sfq.c | 14 +++++++----- 8 files changed, 46 insertions(+), 49 deletions(-)
include/linux/skbuff.h +2 -1
@@ -1228,7 +1228,8 @@ static inline __u32 skb_get_hash_flowi6(return skb->hash; } -__u32 skb_get_hash_perturb (const struct sk_buff *skb,u32 perturb); +__u32 skb_get_hash_perturb (const struct sk_buff *skb, +const siphash_key_t *perturb);static inline __u32 skb_get_hash_raw (const struct sk_buff *skb) {
include/net/flow_dissector.h +2 -1
@@ -4,6 +4,7 @@#include <linux/types.h> #include <linux/in6.h> +#include <linux/siphash.h> #include <uapi/linux/if_ether.h> /**
@@ -229,7 +230,7 @@ struct flow_dissector {struct flow_keys {struct flow_dissector_key_control control;#define FLOW_KEYS_HASH_START_FIELD basic -struct flow_dissector_key_basic basic; +struct flow_dissector_key_basic basic__aligned(SIPHASH_ALIGNMENT) ;struct flow_dissector_key_tags tags;struct flow_dissector_key_vlan vlan;struct flow_dissector_key_keyid keyid;
include/net/fq.h +1 -1
@@ -70,7 +70,7 @@ struct fq {struct list_head backlogs;spinlock_t lock;u32 flows_cnt; -u32 perturbation; +siphash_key_t perturbation;u32 limit;u32 memory_limit;u32 memory_usage;
include/net/fq_impl.h +2 -2
@@ -105,7 +105,7 @@ static struct fq_flow *fq_flow_classify(lockdep_assert_held (&fq->lock); - hash =skb_get_hash_perturb (skb, fq->perturbation); + hash =skb_get_hash_perturb (skb, &fq->perturbation); idx =reciprocal_scale (hash, fq->flows_cnt); flow = &fq->flows[idx];
@@ -255,7 +255,7 @@ static int fq_init(struct fq *fq, int flINIT_LIST_HEAD (&fq->backlogs);spin_lock_init (&fq->lock); fq->flows_cnt =max_t (u32, flows_cnt,1 ); - fq->perturbation =prandom_u32 (); +get_random_bytes (&fq->perturbation,sizeof (fq->perturbation)); fq->quantum =300 ; fq->limit =8192 ; fq->memory_limit =16 <<20 ;/* 16 MBytes */
net/core/flow_dissector.c +20 -28
111 lines not on this page · raw message
net/sched/sch_hhf.c +4 -4
@@ -4,11 +4,11 @@* Copyright (C) 2013 Nandita Dukkipati <[email protected]> */ -#include <linux/jhash.h> #include <linux/jiffies.h> #include <linux/module.h> #include <linux/skbuff.h> #include <linux/vmalloc.h> +#include <linux/siphash.h> #include <net/pkt_sched.h> #include <net/sock.h>
@@ -125,7 +125,7 @@ struct wdrr_bucket {struct hhf_sched_data {struct wdrr_bucket buckets[WDRR_BUCKET_CNT ]; -u32 perturbation;/* hash perturbation */ +siphash_key_t perturbation;/* hash perturbation */ u32 quantum;/* psched_mtu(qdisc_dev(sch)); */ u32 drop_overlimit;/* number of times max qdisc packet * limit was hit
@@ -263,7 +263,7 @@ static enum wdrr_bucket_idx hhf_classify }/* Get hashed flow-id of the skb. */ - hash =skb_get_hash_perturb (skb, q->perturbation); + hash =skb_get_hash_perturb (skb, &q->perturbation);/* Check if this packet belongs to an already established HH flow. */ flow_pos = hash &HHF_BIT_MASK ;
@@ -578,7 +578,7 @@ static int hhf_init(struct Qdisc *sch, s sch->limit =1000 ; q->quantum =psched_mtu (qdisc_dev (sch)); - q->perturbation =prandom_u32 (); +get_random_bytes (&q->perturbation,sizeof (q->perturbation));INIT_LIST_HEAD (&q->new_buckets);INIT_LIST_HEAD (&q->old_buckets);
net/sched/sch_sfb.c +7 -6
@@ -22,7 +22,7 @@#include <linux/errno.h> #include <linux/skbuff.h> #include <linux/random.h> -#include <linux/jhash.h> +#include <linux/siphash.h> #include <net/ip.h> #include <net/pkt_sched.h> #include <net/pkt_cls.h>
@@ -49,7 +49,7 @@ struct sfb_bucket {* (Section 4.4 of SFB reference : moving hash functions) */ struct sfb_bins { -u32 perturbation;/* jhash perturbation */ +siphash_key_t perturbation;/* siphash key */ struct sfb_bucket bins[SFB_LEVELS ][SFB_NUMBUCKETS ]; };
@@ -221,7 +221,8 @@ static u32 sfb_compute_qlen(u32 *prob_r,static void sfb_init_perturbation (u32 slot,struct sfb_sched_data *q) { - q->bins[slot].perturbation =prandom_u32 (); +get_random_bytes (&q->bins[slot].perturbation, +sizeof (q->bins[slot].perturbation)); }static void sfb_swap_slot (struct sfb_sched_data *q)
@@ -317,9 +318,9 @@ static int sfb_enqueue(struct sk_buff *s/* If using external classifiers, get result and record it. */ if (!sfb_classify (skb, fl, &ret, &salt)) goto other_drop; - sfbhash =jhash_1word (salt, q->bins[slot].perturbation); + sfbhash =siphash_1u32 (salt, &q->bins[slot].perturbation); }else { - sfbhash =skb_get_hash_perturb (skb, q->bins[slot].perturbation); + sfbhash =skb_get_hash_perturb (skb, &q->bins[slot].perturbation); }
@@ -355,7 +356,7 @@ static int sfb_enqueue(struct sk_buff *s/* Inelastic flow */ if (q->double_buffering) { sfbhash =skb_get_hash_perturb (skb, - q->bins[slot].perturbation); + &q->bins[slot].perturbation);if (!sfbhash) sfbhash =1 ;sfb_skb_cb (skb)->hashes[slot] = sfbhash;
net/sched/sch_sfq.c +8 -6
@@ -18,7 +18,7 @@#include <linux/errno.h> #include <linux/init.h> #include <linux/skbuff.h> -#include <linux/jhash.h> +#include <linux/siphash.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <net/netlink.h>
@@ -121,7 +121,7 @@ struct sfq_sched_data {u8 headdrop;u8 maxdepth;/* limit of packets per flow */ -u32 perturbation; +siphash_key_t perturbation;u8 cur_depth;/* depth of longest slot */ u8 flags;unsigned short scaled_quantum;/* SFQ_ALLOT_SIZE(quantum) */
@@ -160,7 +160,7 @@ static inline struct sfq_head *sfq_dep_hstatic unsigned int sfq_hash (const struct sfq_sched_data *q,const struct sk_buff *skb) { -return skb_get_hash_perturb (skb, q->perturbation) & (q->divisor -1 ); +return skb_get_hash_perturb (skb, &q->perturbation) & (q->divisor -1 ); } static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
@@ -609,9 +609,11 @@ static void sfq_perturbation(unsigned lostruct Qdisc *sch = (struct Qdisc *)arg;struct sfq_sched_data *q =qdisc_priv (sch);spinlock_t *root_lock =qdisc_lock (qdisc_root_sleeping (sch)); +siphash_key_t nkey; +get_random_bytes (&nkey,sizeof (nkey));spin_lock (root_lock); - q->perturbation =prandom_u32 (); + q->perturbation = nkey;if (!q->filter_list && q->tail)sfq_rehash (sch);spin_unlock (root_lock);
@@ -690,7 +692,7 @@ static int sfq_change(struct Qdisc *sch,del_timer (&q->perturb_timer);if (q->perturb_period) {mod_timer (&q->perturb_timer, jiffies + q->perturb_period); - q->perturbation =prandom_u32 (); +get_random_bytes (&q->perturbation,sizeof (q->perturbation)); }sch_tree_unlock (sch);kfree (p);
@@ -746,7 +748,7 @@ static int sfq_init(struct Qdisc *sch, s q->quantum =psched_mtu (qdisc_dev (sch)); q->scaled_quantum =SFQ_ALLOT_SIZE (q->quantum); q->perturb_period =0 ; - q->perturbation =prandom_u32 (); +get_random_bytes (&q->perturbation,sizeof (q->perturbation));if (opt) {int err =sfq_change (sch, opt);
Greg Kroah-Hartman
maintainerPATCH 50/62 dmaengine: qcom: bam_dma: Fix resource leak
In reply to Greg Kroah-HartmanFrom: Jeffrey Hugo <[email protected]>
commit 7667819385457b4aeb5fac94f67f52ab52cc10d5 upstream.
bam_dma_terminate_all() will leak resources if any of the transactions are committed to the hardware (present in the desc fifo), and not complete. Since bam_dma_terminate_all() does not cause the hardware to be updated, the hardware will still operate on any previously committed transactions. This can cause memory corruption if the memory for the transaction has been reassigned, and will cause a sync issue between the BAM and its client(s).
Fix this by properly updating the hardware in bam_dma_terminate_all().
--- drivers/dma/qcom/bam_dma.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/dma/qcom/bam_dma.c +14 -0
@@ -690,7 +690,21 @@ static int bam_dma_terminate_all(struct/* remove all transactions, including active transaction */ spin_lock_irqsave (&bchan->vc.lock, flag); +/* +* If we have transactions queued, then some might be committed to the +* hardware in the desc fifo. The only way to reset the desc fifo is +* to do a hardware reset (either by pipe or the entire block). +* bam_chan_init_hw() will trigger a pipe reset, and also reinit the +* pipe. If the pipe is left disabled (default state after pipe reset) +* and is accessed by a connected hardware engine, a fatal error in +* the BAM will occur. There is a small window where this could happen +* with bam_chan_init_hw(), but it is assumed that the caller has +* stopped activity on any attached hardware engine. Make sure to do +* this first so that the BAM hardware doesn't cause memory corruption +* by accessing freed resources. +*/ if (bchan->curr_txd) { +bam_chan_init_hw (bchan, bchan->curr_txd->dir);list_add (&bchan->curr_txd->vd.node, &bchan->vc.desc_issued); bchan->curr_txd =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 51/62 sched/wake_q: Fix wakeup ordering for wake_q
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 4c4e3731564c8945ac5ac90fc2a1e1f21cb79c92 upstream.
Notable cmpxchg() does not provide ordering when it fails, however wake_q_add() requires ordering in this specific case too. Without this it would be possible for the concurrent wakeup to not observe our prior state.
Andrea Parri provided:
C wake_up_q-wake_q_add
{
int next = 0;
int y = 0;}
P0(int *next, int *y)
{
int r0;
/* in wake_up_q() */
WRITE_ONCE(*next, 1); /* node->next = NULL */
smp_mb(); /* implied by wake_up_process() */
r0 = READ_ONCE(*y);}
P1(int *next, int *y)
{
int r1;
/* in wake_q_add() */
WRITE_ONCE(*y, 1); /* wake_cond = true */
smp_mb__before_atomic();
r1 = cmpxchg_relaxed(next, 1, 2);}
exists (0:r0=0 /\ 1:r1=0)
This "exists" clause cannot be satisfied according to the LKMM:
Test wake_up_q-wake_q_add Allowed States 3 0:r0=0; 1:r1=1; 0:r0=1; 1:r1=0; 0:r0=1; 1:r1=1; No Witnesses Positive: 0 Negative: 3 Condition exists (0:r0=0 /\ 1:r1=0) Observation wake_up_q-wake_q_add Never 0 3
--- kernel/sched/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/sched/core.c +4 -3
@@ -432,10 +432,11 @@ void wake_q_add(struct wake_q_head *head* its already queued (either by us or someone else) and will get the * wakeup due to that. * -* This cmpxchg() implies a full barrier, which pairs with the write -* barrier implied by the wakeup in wake_up_q(). +* In order to ensure that a pending wakeup will observe our pending +* state, even in the failed case, an explicit smp_mb() must be used. */ -if (cmpxchg (&node->next,NULL ,WAKE_Q_TAIL )) +smp_mb__before_atomic (); +if (cmpxchg_relaxed (&node->next,NULL ,WAKE_Q_TAIL ))return ;get_task_struct (task);
Greg Kroah-Hartman
maintainerPATCH 52/62 kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit a73619a845d5625079cc1b3b820f44c899618388 ]
The __FILE__ macro is used everywhere in the kernel to locate the file printing the log message, such as WARN_ON(), etc. If the kernel is built out of tree, this can be a long absolute path, like this:
WARNING: CPU: 1 PID: 1 at /path/to/build/directory/arch/arm64/kernel/foo.c:...
This is because Kbuild runs in the objtree instead of the srctree, then __FILE__ is expanded to a file path prefixed with $(srctree)/.
Commit 9da0763bdd82 ("kbuild: Use relative path when building in a subdir of the source tree") improved this to some extent; $(srctree) becomes ".." if the objtree is a child of the srctree.
For other cases of out-of-tree build, __FILE__ is still the absolute path. It also means the kernel image depends on where it was built.
A brand-new option from GCC, -fmacro-prefix-map, solves this problem. If your compiler supports it, __FILE__ is the relative path from the srctree regardless of O= option. This provides more readable log and more reproducible builds.
Please note __FILE__ is always an absolute path for external modules.
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -840,6 +840,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) # Require designated initializers for all marked structures KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) +# change __FILE__ to the relative path from the srctree +KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 53/62 kbuild: add -fcf-protection=none when using retpoline flags
In reply to Greg Kroah-HartmanFrom: Seth Forshee <[email protected]>
[ Upstream commit 29be86d7f9cb18df4123f309ac7857570513e8bc ]
The gcc -fcf-protection=branch option is not compatible with -mindirect-branch=thunk-extern. The latter is used when CONFIG_RETPOLINE is selected, and this will fail to build with a gcc which has -fcf-protection=branch enabled by default. Adding -fcf-protection=none when building with retpoline enabled prevents such build failures.
--- Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
Makefile +6 -0
@@ -843,6 +843,12 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) # change __FILE__ to the relative path from the srctree KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) +# ensure -fcf-protection is disabled when using retpoline as it is +# incompatible with -mindirect-branch=thunk-extern +ifdef CONFIG_RETPOLINE +KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) +endif + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 54/62 platform/x86: pmc_atom: Add Siemens SIMATIC IPC227E to critclk_systems DMI table
In reply to Greg Kroah-HartmanFrom: Jan Kiszka <[email protected]>
commit ad0d315b4d4e7138f43acf03308192ec00e9614d upstream.
The SIMATIC IPC227E uses the PMC clock for on-board components and gets stuck during boot if the clock is disabled. Therefore, add this device to the critical systems list.
--- drivers/platform/x86/pmc_atom.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/pmc_atom.c +7 -0
@@ -475,6 +475,13 @@ static const struct dmi_system_id critcl DMI_MATCH(DMI_BOARD_NAME, "CB6363"), }, }, + { + .ident = "SIMATIC IPC227E", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "SIEMENS AG"), + DMI_MATCH(DMI_PRODUCT_VERSION, "6ES7647-8B"), + }, + }, {/*sentinel*/ } };
Greg Kroah-Hartman
maintainerPATCH 55/62 iio: adc: stm32-adc: move registers definitions
In reply to Greg Kroah-HartmanFrom: Fabrice Gasnier <[email protected]>
commit 31922f62bb527d749b99dbc776e514bcba29b7fe upstream.
Move STM32 ADC registers definitions to common header.
This is precursor patch to:
- iio: adc: stm32-adc: fix a race when using several adcs with dma and irq
It keeps registers definitions as a whole block, to ease readability and allow simple access path to EOC bits (readl) in stm32-adc-core driver.
--- drivers/iio/adc/stm32-adc-core.c | 27 ------- drivers/iio/adc/stm32-adc-core.h | 134 +++++++++++++++++++++++++++++++++++++++ drivers/iio/adc/stm32-adc.c | 107 ------------------------------- 3 files changed, 134 insertions(+), 134 deletions(-)
drivers/iio/adc/stm32-adc-core.c +0 -27
@@ -33,36 +33,9 @@#include "stm32-adc-core.h" -/* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */ -#define STM32F4_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) -#define STM32F4_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x04) - -/* STM32F4_ADC_CSR - bit fields */ -#define STM32F4_EOC3 BIT(17) -#define STM32F4_EOC2 BIT(9) -#define STM32F4_EOC1 BIT(1) - -/* STM32F4_ADC_CCR - bit fields */ -#define STM32F4_ADC_ADCPRE_SHIFT 16 -#define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16) -/* STM32 F4 maximum analog clock rate (from datasheet) */ #define STM32F4_ADC_MAX_CLK_RATE 36000000 -/* STM32H7 - common registers for all ADC instances */ -#define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) -#define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08) - -/* STM32H7_ADC_CSR - bit fields */ -#define STM32H7_EOC_SLV BIT(18) -#define STM32H7_EOC_MST BIT(2) - -/* STM32H7_ADC_CCR - bit fields */ -#define STM32H7_PRESC_SHIFT 18 -#define STM32H7_PRESC_MASK GENMASK(21, 18) -#define STM32H7_CKMODE_SHIFT 16 -#define STM32H7_CKMODE_MASK GENMASK(17, 16) -/* STM32 H7 maximum analog clock rate (from datasheet) */ #define STM32H7_ADC_MAX_CLK_RATE 36000000
drivers/iio/adc/stm32-adc-core.h +134 -0
140 lines not on this page · raw message
drivers/iio/adc/stm32-adc.c +0 -107
113 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 56/62 iio: adc: stm32-adc: fix a race when using several adcs with dma and irq
In reply to Greg Kroah-HartmanFrom: Fabrice Gasnier <[email protected]>
commit dcb10920179ab74caf88a6f2afadecfc2743b910 upstream.
End of conversion may be handled by using IRQ or DMA. There may be a race when two conversions complete at the same time on several ADCs. EOC can be read as 'set' for several ADCs, with:
- an ADC configured to use IRQs. EOCIE bit is set. The handler is normally called in this case.
- an ADC configured to use DMA. EOCIE bit isn't set. EOC triggers the DMA request instead. It's then automatically cleared by DMA read. But the handler gets called due to status bit is temporarily set (IRQ triggered by the other ADC).
So both EOC status bit in CSR and EOCIE control bit must be checked before invoking the interrupt handler (e.g. call ISR only for IRQ-enabled ADCs).
--- drivers/iio/adc/stm32-adc-core.c | 43 ++++++++++++++++++++++++++++++++++++--- drivers/iio/adc/stm32-adc-core.h | 1 2 files changed, 41 insertions(+), 3 deletions(-)
drivers/iio/adc/stm32-adc-core.c +40 -3
@@ -45,12 +45,16 @@* @eoc1: adc1 end of conversion flag in @csr * @eoc2: adc2 end of conversion flag in @csr * @eoc3: adc3 end of conversion flag in @csr +* @ier: interrupt enable register offset for each adc +* @eocie_msk: end of conversion interrupt enable mask in @ier */ struct stm32_adc_common_regs {u32 csr;u32 eoc1_msk;u32 eoc2_msk;u32 eoc3_msk; +u32 ier; +u32 eocie_msk; };struct stm32_adc_priv ;
@@ -244,6 +248,8 @@ static const struct stm32_adc_common_reg .eoc1_msk = STM32F4_EOC1, .eoc2_msk = STM32F4_EOC2, .eoc3_msk = STM32F4_EOC3, + .ier = STM32F4_ADC_CR1, + .eocie_msk = STM32F4_EOCIE, };/* STM32H7 common registers definitions */
@@ -251,8 +257,24 @@ static const struct stm32_adc_common_reg .csr = STM32H7_ADC_CSR, .eoc1_msk = STM32H7_EOC_MST, .eoc2_msk = STM32H7_EOC_SLV, + .ier = STM32H7_ADC_IER, + .eocie_msk = STM32H7_EOCIE, }; +static const unsigned int stm32_adc_offset[STM32_ADC_MAX_ADCS ] = { +0 ,STM32_ADC_OFFSET ,STM32_ADC_OFFSET *2 , +}; + +static unsigned int stm32_adc_eoc_enabled (struct stm32_adc_priv *priv, +unsigned int adc) +{ +u32 ier, offset = stm32_adc_offset[adc]; + + ier =readl_relaxed (priv->common.base + offset + priv->cfg->regs->ier); + +return ier & priv->cfg->regs->eocie_msk; +} +/* ADC common interrupt for all instances */ static void stm32_adc_irq_handler (struct irq_desc *desc) {
@@ -263,13 +285,28 @@ static void stm32_adc_irq_handler(structchained_irq_enter (chip, desc); status =readl_relaxed (priv->common.base + priv->cfg->regs->csr); -if (status & priv->cfg->regs->eoc1_msk) +/* +* End of conversion may be handled by using IRQ or DMA. There may be a +* race here when two conversions complete at the same time on several +* ADCs. EOC may be read 'set' for several ADCs, with: +* - an ADC configured to use DMA (EOC triggers the DMA request, and +* is then automatically cleared by DR read in hardware) +* - an ADC configured to use IRQs (EOCIE bit is set. The handler must +* be called in this case) +* So both EOC status bit in CSR and EOCIE control bit must be checked +* before invoking the interrupt handler (e.g. call ISR only for +* IRQ-enabled ADCs). +*/ +if (status & priv->cfg->regs->eoc1_msk && +stm32_adc_eoc_enabled (priv,0 ))generic_handle_irq (irq_find_mapping (priv->domain,0 )); -if (status & priv->cfg->regs->eoc2_msk) +if (status & priv->cfg->regs->eoc2_msk && +stm32_adc_eoc_enabled (priv,1 ))generic_handle_irq (irq_find_mapping (priv->domain,1 )); -if (status & priv->cfg->regs->eoc3_msk) +if (status & priv->cfg->regs->eoc3_msk && +stm32_adc_eoc_enabled (priv,2 ))generic_handle_irq (irq_find_mapping (priv->domain,2 ));chained_irq_exit (chip, desc);
drivers/iio/adc/stm32-adc-core.h +1 -0
@@ -37,6 +37,7 @@* -------------------------------------------------------- */ #define STM32_ADC_MAX_ADCS 3 +#define STM32_ADC_OFFSET 0x100#define STM32_ADCX_COMN_OFFSET 0x300/* STM32F4 - Registers for each ADC instance */
Greg Kroah-Hartman
maintainerPATCH 57/62 powerpc/mm: Fixup tlbie vs store ordering issue on POWER9
In reply to Greg Kroah-HartmanFrom: "Aneesh Kumar K.V" <[email protected]>
commit a5d4b5891c2f1f865a2def1eb0030f534e77ff86 upstream.
On POWER9, under some circumstances, a broadcast TLB invalidation might complete before all previous stores have drained, potentially allowing stale stores from becoming visible after the invalidation. This works around it by doubling up those TLB invalidations which was verified by HW to be sufficient to close the risk window.
This will be documented in a yet-to-be-published errata.
[mpe: Enable the feature in the DT CPU features code for all Power9,
rename the feature to CPU_FTR_P9_TLBIE_BUG per benh.]
--- arch/powerpc/include/asm/cputable.h | 4 ++- arch/powerpc/kernel/dt_cpu_ftrs.c | 3 ++ arch/powerpc/kvm/book3s_64_mmu_radix.c | 3 ++ arch/powerpc/kvm/book3s_hv_rm_mmu.c | 11 ++++++++ arch/powerpc/mm/hash_native_64.c | 16 ++++++++++++ arch/powerpc/mm/pgtable_64.c | 1 arch/powerpc/mm/tlb-radix.c | 41 ++++++++++++++++++++++++--------- 7 files changed, 66 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/cputable.h +3 -1
@@ -215,6 +215,7 @@ enum {#define CPU_FTR_DAWR LONG_ASM_CONST(0x0400000000000000)#define CPU_FTR_DABRX LONG_ASM_CONST(0x0800000000000000)#define CPU_FTR_PMAO_BUG LONG_ASM_CONST(0x1000000000000000) +#define CPU_FTR_P9_TLBIE_BUG LONG_ASM_CONST(0x2000000000000000)#define CPU_FTR_POWER9_DD1 LONG_ASM_CONST(0x4000000000000000)#ifndef __ASSEMBLY__
@@ -475,7 +476,8 @@ enum { CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \ CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \ CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \ - CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP | CPU_FTR_ARCH_300) + CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP | CPU_FTR_ARCH_300 | \ + CPU_FTR_P9_TLBIE_BUG)#define CPU_FTRS_POWER9_DD1 ((CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1) & \ (~CPU_FTR_SAO))#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
arch/powerpc/kernel/dt_cpu_ftrs.c +3 -0
@@ -742,6 +742,9 @@ static __init void cpufeatures_cpu_quirk*/ if ((version &0xffffff00 ) ==0x004e0100 ) cur_cpu_spec->cpu_features |=CPU_FTR_POWER9_DD1 ; + +if ((version &0xffff0000 ) ==0x004e0000 ) + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; }static void __init cpufeatures_setup_finished (void )
arch/powerpc/kvm/book3s_64_mmu_radix.c +3 -0
@@ -160,6 +160,9 @@ static void kvmppc_radix_tlbie_page(stru asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1) : : "r" (addr), "r" (kvm->arch.lpid) : "memory"); +if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) + asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1) + : : "r" (addr), "r" (kvm->arch.lpid) : "memory"); asmvolatile ("ptesync" : : :"memory" ); }
arch/powerpc/kvm/book3s_hv_rm_mmu.c +11 -0
@@ -448,6 +448,17 @@ static void do_tlbies(struct kvm *kvm, u asm volatile(PPC_TLBIE_5(%0,%1,0,0,0) : : "r" (rbvalues[i]), "r" (kvm->arch.lpid)); } + +if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) { +/* +* Need the extra ptesync to make sure we don't +* re-order the tlbie +*/ + asmvolatile ("ptesync" : : :"memory" ); + asm volatile(PPC_TLBIE_5(%0,%1,0,0,0) : : + "r" (rbvalues[0]), "r" (kvm->arch.lpid)); + } + asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); kvm->arch.tlbie_lock =0 ; }else {
arch/powerpc/mm/hash_native_64.c +15 -1
@@ -104,6 +104,15 @@ static inline unsigned long ___tlbie(unreturn va; } +static inline void fixup_tlbie (unsigned long vpn,int psize,int apsize,int ssize) +{ +if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) { +/* Need the extra ptesync to ensure we don't reorder tlbie*/ + asmvolatile ("ptesync" : : :"memory" ); +___tlbie (vpn, psize, apsize, ssize); + } +} +static inline void __tlbie (unsigned long vpn,int psize,int apsize,int ssize) {unsigned long rb;
@@ -181,6 +190,7 @@ static inline void tlbie(unsigned long v asmvolatile ("ptesync" : : :"memory" ); }else {__tlbie (vpn, psize, apsize, ssize); +fixup_tlbie (vpn, psize, apsize, ssize); asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); }if (lock_tlbie && !use_local)
@@ -674,7 +684,7 @@ static void native_hpte_clear(void)*/ static void native_flush_hash_range (unsigned long number,int local) { -unsigned long vpn; +unsigned long vpn =0 ;unsigned long hash, index, hidx, shift, slot;struct hash_pte *hptep;unsigned long hpte_v;
@@ -746,6 +756,10 @@ static void native_flush_hash_range(unsi__tlbie (vpn, psize, psize, ssize); }pte_iterate_hashed_end (); } +/* +* Just do one more with the last used values. +*/ +fixup_tlbie (vpn, psize, psize, ssize); asmvolatile ("eieio; tlbsync; ptesync" :::"memory" );if (lock_tlbie)
arch/powerpc/mm/pgtable_64.c +1 -0
@@ -491,6 +491,7 @@ void mmu_partition_table_set_entry(unsig "r" (TLBIEL_INVAL_SET_LPID), "r" (lpid));trace_tlbie (lpid,0 ,TLBIEL_INVAL_SET_LPID , lpid,2 ,0 ,0 ); } +/* do we need fixup here ?*/ asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); }EXPORT_SYMBOL_GPL (mmu_partition_table_set_entry);
arch/powerpc/mm/tlb-radix.c +30 -11
61 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 58/62 powerpc/book3s64/mm: Dont do tlbie fixup for some hardware revisions
In reply to Greg Kroah-HartmanFrom: "Aneesh Kumar K.V" <[email protected]>
commit 677733e296b5c7a37c47da391fc70a43dc40bd67 upstream.
The store ordering vs tlbie issue mentioned in commit a5d4b5891c2f ("powerpc/mm: Fixup tlbie vs store ordering issue on POWER9") is fixed for Nimbus 2.3 and Cumulus 1.3 revisions. We don't need to apply the fixup if we are running on them
We can only do this on PowerNV. On pseries guest with kvm we still don't support redoing the feature fixup after migration. So we should be enabling all the workarounds needed, because whe can possibly migrate between DD 2.3 and DD 2.2
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
arch/powerpc/kernel/dt_cpu_ftrs.c +28 -3
@@ -733,9 +733,35 @@ static bool __init cpufeatures_process_freturn true; } +/* +* Handle POWER9 broadcast tlbie invalidation issue using +* cpu feature flag. +*/ +static __init void update_tlbie_feature_flag (unsigned long pvr) +{ +if (PVR_VER (pvr) ==PVR_POWER9 ) { +/* +* Set the tlbie feature flag for anything below +* Nimbus DD 2.3 and Cumulus DD 1.3 +*/ +if ((pvr &0xe000 ) ==0 ) { +/* Nimbus */ +if ((pvr &0xfff ) <0x203 ) + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + }else if ((pvr &0xc000 ) ==0 ) { +/* Cumulus */ +if ((pvr &0xfff ) <0x103 ) + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + }else { +WARN_ONCE (1 ,"Unknown PVR" ); + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + } + } +} +static __init void cpufeatures_cpu_quirks (void ) { -int version =mfspr (SPRN_PVR ); +unsigned long version =mfspr (SPRN_PVR );/* * Not all quirks can be derived from the cpufeatures device tree.
@@ -743,8 +769,7 @@ static __init void cpufeatures_cpu_quirkif ((version &0xffffff00 ) ==0x004e0100 ) cur_cpu_spec->cpu_features |=CPU_FTR_POWER9_DD1 ; -if ((version &0xffff0000 ) ==0x004e0000 ) - cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; +update_tlbie_feature_flag (version); }static void __init cpufeatures_setup_finished (void )
Greg Kroah-Hartman
maintainerPATCH 59/62 powerpc/book3s64/radix: Rename CPU_FTR_P9_TLBIE_BUG feature flag
In reply to Greg Kroah-HartmanFrom: "Aneesh Kumar K.V" <[email protected]>
commit 09ce98cacd51fcd0fa0af2f79d1e1d3192f4cbb0 upstream.
Rename the #define to indicate this is related to store vs tlbie ordering issue. In the next patch, we will be adding another feature flag that is used to handles ERAT flush vs tlbie ordering issue.
--- arch/powerpc/include/asm/cputable.h | 4 ++-- arch/powerpc/kernel/dt_cpu_ftrs.c | 6 +++--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- arch/powerpc/mm/hash_native_64.c | 2 +- arch/powerpc/mm/tlb-radix.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/cputable.h +2 -2
@@ -215,7 +215,7 @@ enum {#define CPU_FTR_DAWR LONG_ASM_CONST(0x0400000000000000)#define CPU_FTR_DABRX LONG_ASM_CONST(0x0800000000000000)#define CPU_FTR_PMAO_BUG LONG_ASM_CONST(0x1000000000000000) -#define CPU_FTR_P9_TLBIE_BUG LONG_ASM_CONST(0x2000000000000000) +#define CPU_FTR_P9_TLBIE_STQ_BUG LONG_ASM_CONST(0x0000400000000000)#define CPU_FTR_POWER9_DD1 LONG_ASM_CONST(0x4000000000000000)#ifndef __ASSEMBLY__
@@ -477,7 +477,7 @@ enum { CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \ CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \ CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP | CPU_FTR_ARCH_300 | \ - CPU_FTR_P9_TLBIE_BUG) + CPU_FTR_P9_TLBIE_STQ_BUG)#define CPU_FTRS_POWER9_DD1 ((CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1) & \ (~CPU_FTR_SAO))#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
arch/powerpc/kernel/dt_cpu_ftrs.c +3 -3
@@ -747,14 +747,14 @@ static __init void update_tlbie_feature_if ((pvr &0xe000 ) ==0 ) {/* Nimbus */ if ((pvr &0xfff ) <0x203 ) - cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_STQ_BUG ; }else if ((pvr &0xc000 ) ==0 ) {/* Cumulus */ if ((pvr &0xfff ) <0x103 ) - cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_STQ_BUG ; }else {WARN_ONCE (1 ,"Unknown PVR" ); - cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_BUG ; + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_STQ_BUG ; } } }
arch/powerpc/kvm/book3s_64_mmu_radix.c +1 -1
@@ -160,7 +160,7 @@ static void kvmppc_radix_tlbie_page(stru asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1) : : "r" (addr), "r" (kvm->arch.lpid) : "memory"); -if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1) : : "r" (addr), "r" (kvm->arch.lpid) : "memory"); asmvolatile ("ptesync" : : :"memory" );
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
@@ -449,7 +449,7 @@ static void do_tlbies(struct kvm *kvm, u "r" (rbvalues[i]), "r" (kvm->arch.lpid)); } -if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) { +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) {/* * Need the extra ptesync to make sure we don't * re-order the tlbie
arch/powerpc/mm/hash_native_64.c +1 -1
@@ -106,7 +106,7 @@ static inline unsigned long ___tlbie(unstatic inline void fixup_tlbie (unsigned long vpn,int psize,int apsize,int ssize) { -if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) { +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) {/* Need the extra ptesync to ensure we don't reorder tlbie*/ asmvolatile ("ptesync" : : :"memory" );___tlbie (vpn, psize, apsize, ssize);
arch/powerpc/mm/tlb-radix.c +1 -1
@@ -44,7 +44,7 @@ static inline void fixup_tlbie(void)unsigned long pid =0 ;unsigned long va = ((1UL <<52 ) -1 ); -if (cpu_has_feature (CPU_FTR_P9_TLBIE_BUG )) { +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) { asmvolatile ("ptesync" : : :"memory" );__tlbie_va (va, pid,mmu_get_ap (MMU_PAGE_64K ),RIC_FLUSH_TLB ); }
Greg Kroah-Hartman
maintainerPATCH 60/62 powerpc/mm: Fixup tlbie vs mtpidr/mtlpidr ordering issue on POWER9
In reply to Greg Kroah-HartmanFrom: "Aneesh Kumar K.V" <[email protected]>
commit 047e6575aec71d75b765c22111820c4776cd1c43 upstream.
On POWER9, under some circumstances, a broadcast TLB invalidation will fail to invalidate the ERAT cache on some threads when there are parallel mtpidr/mtlpidr happening on other threads of the same core. This can cause stores to continue to go to a page after it's unmapped.
The workaround is to force an ERAT flush using PID=0 or LPID=0 tlbie flush. This additional TLB flush will cause the ERAT cache invalidation. Since we are using PID=0 or LPID=0, we don't get filtered out by the TLB snoop filtering logic.
We need to still follow this up with another tlbie to take care of store vs tlbie ordering issue explained in commit:a5d4b5891c2f ("powerpc/mm: Fixup tlbie vs store ordering issue on POWER9"). The presence of ERAT cache implies we can still get new stores and they may miss store queue marking flush.
--- arch/powerpc/include/asm/cputable.h | 3 + arch/powerpc/kernel/dt_cpu_ftrs.c | 2 + arch/powerpc/kvm/book3s_hv_rm_mmu.c | 42 +++++++++++++++++------ arch/powerpc/mm/hash_native_64.c | 28 +++++++++++++-- arch/powerpc/mm/tlb-radix.c | 65 ++++++++++++++++++++++++++++++------ 5 files changed, 116 insertions(+), 24 deletions(-)
arch/powerpc/include/asm/cputable.h +2 -1
@@ -217,6 +217,7 @@ enum {#define CPU_FTR_PMAO_BUG LONG_ASM_CONST(0x1000000000000000)#define CPU_FTR_P9_TLBIE_STQ_BUG LONG_ASM_CONST(0x0000400000000000)#define CPU_FTR_POWER9_DD1 LONG_ASM_CONST(0x4000000000000000) +#define CPU_FTR_P9_TLBIE_ERAT_BUG LONG_ASM_CONST(0x0001000000000000)#ifndef __ASSEMBLY__
@@ -477,7 +478,7 @@ enum { CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \ CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \ CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP | CPU_FTR_ARCH_300 | \ - CPU_FTR_P9_TLBIE_STQ_BUG) + CPU_FTR_P9_TLBIE_STQ_BUG | CPU_FTR_P9_TLBIE_ERAT_BUG)#define CPU_FTRS_POWER9_DD1 ((CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1) & \ (~CPU_FTR_SAO))#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
arch/powerpc/kernel/dt_cpu_ftrs.c +2 -0
@@ -756,6 +756,8 @@ static __init void update_tlbie_feature_WARN_ONCE (1 ,"Unknown PVR" ); cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_STQ_BUG ; } + + cur_cpu_spec->cpu_features |=CPU_FTR_P9_TLBIE_ERAT_BUG ; } }
arch/powerpc/kvm/book3s_hv_rm_mmu.c +32 -10
54 lines not on this page · raw message
arch/powerpc/mm/hash_native_64.c +25 -3
@@ -104,8 +104,30 @@ static inline unsigned long ___tlbie(unreturn va; } -static inline void fixup_tlbie (unsigned long vpn,int psize,int apsize,int ssize) +static inline void fixup_tlbie_vpn (unsigned long vpn,int psize, +int apsize,int ssize) { +if (cpu_has_feature (CPU_FTR_P9_TLBIE_ERAT_BUG )) { +/* Radix flush for a hash guest */ + +unsigned long rb,rs,prs,r,ric; + + rb =PPC_BIT (52 );/* IS = 2 */ + rs =0 ;/* lpid = 0 */ + prs =0 ;/* partition scoped */ + r =1 ;/* radix format */ + ric =0 ;/* RIC_FLSUH_TLB */ + +/* +* Need the extra ptesync to make sure we don't +* re-order the tlbie +*/ + asmvolatile ("ptesync" : : :"memory" ); + asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) + : : "r"(rb), "i"(r), "i"(prs), + "i"(ric), "r"(rs) : "memory"); + } +if (cpu_has_feature (CPU_FTR_P9_TLBIE_STQ_BUG )) {/* Need the extra ptesync to ensure we don't reorder tlbie*/ asmvolatile ("ptesync" : : :"memory" );
@@ -190,7 +212,7 @@ static inline void tlbie(unsigned long v asmvolatile ("ptesync" : : :"memory" ); }else {__tlbie (vpn, psize, apsize, ssize); -fixup_tlbie (vpn, psize, apsize, ssize); +fixup_tlbie_vpn (vpn, psize, apsize, ssize); asmvolatile ("eieio; tlbsync; ptesync" : : :"memory" ); }if (lock_tlbie && !use_local)
@@ -759,7 +781,7 @@ static void native_flush_hash_range(unsi/* * Just do one more with the last used values. */ -fixup_tlbie (vpn, psize, psize, ssize); +fixup_tlbie_vpn (vpn, psize, psize, ssize); asmvolatile ("eieio; tlbsync; ptesync" :::"memory" );if (lock_tlbie)
arch/powerpc/mm/tlb-radix.c +55 -10
99 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 61/62 selftests/powerpc: Add test case for tlbie vs mtpidr ordering issue
In reply to Greg Kroah-HartmanFrom: "Aneesh Kumar K.V" <[email protected]>
commit 93cad5f789951eaa27c3392b15294b4e51253944 upstream.
--- tools/testing/selftests/powerpc/mm/Makefile | 2 tools/testing/selftests/powerpc/mm/tlbie_test.c | 734 ++++++++++++++++++++++++ 2 files changed, 736 insertions(+) create mode 100644 tools/testing/selftests/powerpc/mm/tlbie_test.c
tools/testing/selftests/powerpc/mm/Makefile +2 -0
@@ -3,6 +3,7 @@ noarg: $(MAKE) -C ../ TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao +TEST_GEN_PROGS_EXTENDED := tlbie_test TEST_GEN_FILES := tempfile include ../../lib.mk
@@ -14,3 +15,4 @@ $(OUTPUT)/prot_sao: ../utils.c $(OUTPUT)/tempfile: dd if=/dev/zero of=$@ bs=64k count=1 +$(OUTPUT)/tlbie_test: LDLIBS += -lpthread
tools/testing/selftests/powerpc/mm/tlbie_test.c new file +734 -0
734 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 62/62 selftests/powerpc: Fix compile error on tlbie_test due to newer gcc
In reply to Greg Kroah-HartmanFrom: Desnes A. Nunes do Rosario <[email protected]>
commit 5b216ea1c40cf06eead15054c70e238c9bd4729e upstream.
Newer versions of GCC (>= 9) demand that the size of the string to be copied must be explicitly smaller than the size of the destination. Thus, the NULL char has to be taken into account on strncpy.
This will avoid the following compiling error:
tlbie_test.c: In function 'main':
tlbie_test.c:639:4: error: 'strncpy' specified bound 100 equals destination size
strncpy(logdir, optarg, LOGDIR_NAME_SIZE);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
--- tools/testing/selftests/powerpc/mm/tlbie_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/powerpc/mm/tlbie_test.c +1 -1
@@ -636,7 +636,7 @@ int main(int argc, char *argv[]) nrthreads =strtoul (optarg,NULL ,10 );break ;case 'l' : -strncpy (logdir, optarg,LOGDIR_NAME_SIZE ); +strncpy (logdir, optarg,LOGDIR_NAME_SIZE -1 );break ;case 't' : run_time =strtoul (optarg,NULL ,10 );
stable-rc/linux-4.14.y boot: 110 boots: 0 failed, 103 passed with 7 offline (v4.14.152-63-g2cfe0b7bdeef)
stable-rc/linux-4.14.y boot: 110 boots: 0 failed, 103 passed with 7 offline (v4.14.152-63-g2cfe0b7bdeef)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.14.y/kernel/v4.14.152-63-g2cfe0b7bdeef/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.14.y/kernel/v4.14.152-63-g2cfe0b7bdeef/
Tree: stable-rc
Branch: linux-4.14.y
Git Describe: v4.14.152-63-g2cfe0b7bdeef
Git Commit: 2cfe0b7bdeef09a0ffe2895928288ebca332b8be
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 61 unique boards, 21 SoC families, 13 builds out of 201
Offline Platforms:
arm:
sunxi_defconfig:
gcc-8
sun5i-r8-chip: 1 offline lab
sun7i-a20-bananapi: 1 offline lab
multi_v7_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab
sun5i-r8-chip: 1 offline lab
sun7i-a20-bananapi: 1 offline lab
davinci_all_defconfig:
gcc-8
dm365evm,legacy: 1 offline lab
qcom_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab---
For more info write to <[email protected]>
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.153 release. There are 62 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 Sun 10 Nov 2019 05:42:11 PM UTC. 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.14.153-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 4.14.153-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.14.y
git commit: 2cfe0b7bdeef09a0ffe2895928288ebca332b8be
git describe: v4.14.152-63-g2cfe0b7bdeef
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.152-63-g2cfe0b7bdeef
No regressions (compared to build v4.14.152)
No fixes (compared to build v4.14.152)
Ran 24212 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* kselftest
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-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-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* ltp-dio-tests
* ltp-io-tests
* network-basic-tests
* ltp-open-posix-tests
* kvm-unit-tests
* ssuite
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.153 release. There are 62 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 Sun 10 Nov 2019 05:42:11 PM UTC. Anything received after that time might be too late.
Build results:
total: 172 pass: 172 fail: 0 Qemu test results: total: 372 pass: 372 fail: 0
Guenter