4.14.129-stable review
Subsystems (4)
Greg Kroah-Hartman
maintainercover 4.14.129-stable review
This is the start of the stable review cycle for the 4.14.129 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat 22 Jun 2019 05:42:15 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.129-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.129-rc1
Alexander Lochmann <[email protected]>
Abort file_remove_privs() for non-reg. files
Ajay Kaher <[email protected]>
infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
Andrea Arcangeli <[email protected]>
coredump: fix race condition between collapse_huge_page() and core dumping
Jason Gerecke <[email protected]>
HID: wacom: Send BTN_TOUCH in response to INTUOSP2_BT eraser contact
Jason Gerecke <[email protected]>
HID: wacom: Don't report anything prior to the tool entering range
Jason Gerecke <[email protected]>
HID: wacom: Don't set tool type until we're in range
Amit Cohen <[email protected]>
mlxsw: spectrum: Prevent force of 56G
Jason Yan <[email protected]>
scsi: libsas: delete sas port if expander discover failed
YueHaibing <[email protected]>
scsi: scsi_dh_alua: Fix possible null-ptr-deref
Lianbo Jiang <[email protected]>
scsi: smartpqi: properly set both the DMA mask and the coherent DMA mask
Varun Prakash <[email protected]>
scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()
Max Uvarov <[email protected]>
net: phy: dp83867: Set up RGMII TX delay
Yoshihiro Shimoda <[email protected]>
net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs
Paul Mackerras <[email protected]>
KVM: PPC: Book3S HV: Don't take kvm->lock around kvm_for_each_vcpu
Paul Mackerras <[email protected]>
KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list
Randy Dunlap <[email protected]>
ia64: fix build errors by exporting paddr_to_nid()
Thomas Richter <[email protected]>
perf record: Fix s390 missing module symbol and warning for non-root users
Shawn Landden <[email protected]>
perf data: Fix 'strncat may truncate' build failure with recent gcc
Sahitya Tummala <[email protected]>
configfs: Fix use-after-free when accessing sd->s_dentry
Bard Liao <[email protected]>
ALSA: hda - Force polling mode on CNL for fixing codec communication
Yingjoe Chen <[email protected]>
i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr
Dmitry Bogdanov <[email protected]>
net: aquantia: fix LRO with FCS error
Kees Cook <[email protected]>
net: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE()
Randy Dunlap <[email protected]>
gpio: fix gpio-adp5588 build errors
Peter Zijlstra <[email protected]>
perf/ring-buffer: Always use {READ,WRITE}_ONCE() for rb->user_page dataPeter Zijlstra <[email protected]>
perf/ring_buffer: Add ordering to rb->nest increment
Yabin Cui <[email protected]>
perf/ring_buffer: Fix exposing a temporarily decreased data_head
Frank van der Linden <[email protected]>
x86/CPU/AMD: Don't force the CPB cap when running under a hypervisor
Dan Carpenter <[email protected]>
mISDN: make sure device name is NUL terminated
Anju T Sudhakar <[email protected]>
powerpc/powernv: Return for invalid IMC domain
Tony Lindgren <[email protected]>
clk: ti: clkctrl: Fix clkdm_clk handling
Jeffrin Jose T <[email protected]>
selftests: netfilter: missing error check when setting up veth interface
YueHaibing <[email protected]>
ipvs: Fix use-after-free in ip_vs_in
Jagdish Motwani <[email protected]>
netfilter: nf_queue: fix reinject verdict handling
Stephane Eranian <[email protected]>
perf/x86/intel/ds: Fix EVENT vs. UEVENT PEBS constraints
Dan Carpenter <[email protected]>
Staging: vc04_services: Fix a couple error codes
John Paul Adrian Glaubitz <[email protected]>
sunhv: Fix device naming inconsistency between sunhv_console and sunhv_reg
Neil Horman <[email protected]>
sctp: Free cookie before we memdup a new one
Taehee Yoo <[email protected]>
net: openvswitch: do not free vport if register_netdevice() is failed.
Eric Dumazet <[email protected]>
neigh: fix use-after-free read in pneigh_get_next
Jeremy Sowden <[email protected]>
lapb: fixed leak of control-blocks.
Eric Dumazet <[email protected]>
ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero
Ivan Vecera <[email protected]>
be2net: Fix number of Rx queues used for flow hashing
Eric Dumazet <[email protected]>
ax25: fix inconsistent lock state in ax25_destroy_timer
Arnaldo Carvalho de Melo <[email protected]>
perf machine: Guard against NULL in machine__exit()
-------------
Diffstat:
Makefile | 4 +- arch/ia64/mm/numa.c | 1 + arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kvm/book3s.c | 1 + arch/powerpc/kvm/book3s_hv.c | 9 +--- arch/powerpc/kvm/book3s_rtas.c | 14 +++-- arch/powerpc/platforms/powernv/opal-imc.c | 4 ++ arch/x86/events/intel/ds.c | 28 +++++----- arch/x86/kernel/cpu/amd.c | 7 ++- drivers/clk/ti/clkctrl.c | 8 +-- drivers/gpio/Kconfig | 1 + drivers/hid/wacom_wac.c | 41 ++++++++++----- drivers/i2c/i2c-dev.c | 1 + drivers/infiniband/hw/mlx4/main.c | 4 +- drivers/infiniband/hw/mlx5/main.c | 3 ++ drivers/isdn/mISDN/socket.c | 5 +- .../ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 61 ++++++++++++---------- drivers/net/ethernet/dec/tulip/de4x5.c | 1 - drivers/net/ethernet/emulex/benet/be_ethtool.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++ drivers/net/ethernet/renesas/sh_eth.c | 4 ++ drivers/net/phy/dp83867.c | 4 +- drivers/scsi/cxgbi/libcxgbi.c | 4 ++ drivers/scsi/device_handler/scsi_dh_alua.c | 6 +-- drivers/scsi/libsas/sas_expander.c | 2 + drivers/scsi/smartpqi/smartpqi_init.c | 2 +- .../vc04_services/bcm2835-camera/controls.c | 4 +- drivers/tty/serial/sunhv.c | 2 +- fs/configfs/dir.c | 14 +++-- fs/inode.c | 9 +++- include/linux/sched/mm.h | 4 ++ kernel/events/ring_buffer.c | 39 +++++++++++--- mm/khugepaged.c | 3 ++ net/ax25/ax25_route.c | 2 + net/core/neighbour.c | 7 +++ net/ipv6/ip6_flowlabel.c | 7 +-- net/lapb/lapb_iface.c | 1 + net/netfilter/ipvs/ip_vs_core.c | 2 +- net/netfilter/nf_queue.c | 1 + net/openvswitch/vport-internal_dev.c | 18 ++++--- net/sctp/sm_make_chunk.c | 8 +++ sound/pci/hda/hda_intel.c | 5 +- tools/perf/arch/s390/util/machine.c | 9 ++-- tools/perf/util/data-convert-bt.c | 2 +- tools/perf/util/machine.c | 3 ++ tools/testing/selftests/netfilter/nft_nat.sh | 6 ++- 46 files changed, 239 insertions(+), 129 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/45 perf machine: Guard against NULL in machine__exit()
From: Arnaldo Carvalho de Melo <[email protected]>
commit 4a2233b194c77ae1ea8304cb7c00b551de4313f0 upstream.
A recent fix for 'perf trace' introduced a bug where machine__exit(trace->host) could be called while trace->host was still NULL, so make this more robust by guarding against NULL, just like free() does.
The problem happens, for instance, when !root users try to run 'perf trace':
[acme@jouet linux]$ trace
Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
perf: Segmentation fault
Obtained 7 stack frames.
[0x4f1b2e]
/lib64/libc.so.6(+0x3671f) [0x7f43a1dd971f] [0x4f3fec]
[0x47468b]
[0x42a2db] /lib64/libc.so.6(__libc_start_main+0xe9) [0x7f43a1dc3509] [0x42a6c9]
Segmentation fault (core dumped)
[acme@jouet linux]$
--- tools/perf/util/machine.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/machine.c +3 -0
@@ -156,6 +156,9 @@ void machine__delete_threads(struct machvoid machine__exit (struct machine *machine) { +if (machine ==NULL ) +return ; +machine__destroy_kernel_maps (machine);map_groups__exit (&machine->kmaps);dsos__exit (&machine->dsos);
Greg Kroah-Hartman
maintainerPATCH 2/45 ax25: fix inconsistent lock state in ax25_destroy_timer
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d4d5d8e83c9616aeef28a2869cea49cc3fb35526 ]
Before thread in process context uses bh_lock_sock() we must disable bh.
sysbot reported :
WARNING: inconsistent lock state
5.2.0-rc3+ #32 Not tainted
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
blkid/26581 [HC0[0]:SC1[1]:HE1:SE0] takes:00000000e0da85ee (slock-AF_AX25){+.?.}, at: spin_lock include/linux/spinlock.h:338 [inline] 00000000e0da85ee (slock-AF_AX25){+.?.}, at: ax25_destroy_timer+0x53/0xc0 net/ax25/af_ax25.c:275 {SOFTIRQ-ON-W} state was registered at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4303 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] ax25_rt_autobind+0x3ca/0x720 net/ax25/ax25_route.c:429 ax25_connect.cold+0x30/0xa4 net/ax25/af_ax25.c:1221 __sys_connect+0x264/0x330 net/socket.c:1834 __do_sys_connect net/socket.c:1845 [inline] __se_sys_connect net/socket.c:1842 [inline] __x64_sys_connect+0x73/0xb0 net/socket.c:1842 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe irq event stamp: 2272 hardirqs last enabled at (2272): [<ffffffff810065f3>] trace_hardirqs_on_thunk+0x1a/0x1c hardirqs last disabled at (2271): [<ffffffff8100660f>] trace_hardirqs_off_thunk+0x1a/0x1c softirqs last enabled at (1522): [<ffffffff87400654>] __do_softirq+0x654/0x94c kernel/softirq.c:320 softirqs last disabled at (2267): [<ffffffff81449010>] invoke_softirq kernel/softirq.c:374 [inline] softirqs last disabled at (2267): [<ffffffff81449010>] irq_exit+0x180/0x1d0 kernel/softirq.c:414
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(slock-AF_AX25);
<Interrupt>
lock(slock-AF_AX25);*** DEADLOCK ***
1 lock held by blkid/26581:
#0: 0000000010fd154d ((&ax25->dtimer)){+.-.}, at: lockdep_copy_map include/linux/lockdep.h:175 [inline] #0: 0000000010fd154d ((&ax25->dtimer)){+.-.}, at: call_timer_fn+0xe0/0x720 kernel/time/timer.c:1312
stack backtrace: CPU: 1 PID: 26581 Comm: blkid Not tainted 5.2.0-rc3+ #32 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x172/0x1f0 lib/dump_stack.c:113 print_usage_bug.cold+0x393/0x4a2 kernel/locking/lockdep.c:2935 valid_state kernel/locking/lockdep.c:2948 [inline] mark_lock_irq kernel/locking/lockdep.c:3138 [inline] mark_lock+0xd46/0x1370 kernel/locking/lockdep.c:3513 mark_irqflags kernel/locking/lockdep.c:3391 [inline] __lock_acquire+0x159f/0x5490 kernel/locking/lockdep.c:3745 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4303 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline] _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151 spin_lock include/linux/spinlock.h:338 [inline] ax25_destroy_timer+0x53/0xc0 net/ax25/af_ax25.c:275 call_timer_fn+0x193/0x720 kernel/time/timer.c:1322 expire_timers kernel/time/timer.c:1366 [inline] __run_timers kernel/time/timer.c:1685 [inline] __run_timers kernel/time/timer.c:1653 [inline] run_timer_softirq+0x66f/0x1740 kernel/time/timer.c:1698 __do_softirq+0x25c/0x94c kernel/softirq.c:293 invoke_softirq kernel/softirq.c:374 [inline] irq_exit+0x180/0x1d0 kernel/softirq.c:414 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0x13b/0x550 arch/x86/kernel/apic/apic.c:1068 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:806 </IRQ> RIP: 0033:0x7f858d5c3232 Code: 8b 61 08 48 8b 84 24 d8 00 00 00 4c 89 44 24 28 48 8b ac 24 d0 00 00 00 4c 8b b4 24 e8 00 00 00 48 89 7c 24 68 48 89 4c 24 78 <48> 89 44 24 58 8b 84 24 e0 00 00 00 89 84 24 84 00 00 00 8b 84 24 RSP: 002b:00007ffcaf0cf5c0 EFLAGS: 00000206 ORIG_RAX: ffffffffffffff13 RAX: 00007f858d7d27a8 RBX: 00007f858d7d8820 RCX: 00007f858d3940d8 RDX: 00007ffcaf0cf798 RSI: 00000000f5e616f3 RDI: 00007f858d394fee RBP: 0000000000000000 R08: 00007ffcaf0cf780 R09: 00007f858d7db480 R10: 0000000000000000 R11: 0000000009691a75 R12: 0000000000000005 R13: 00000000f5e616f3 R14: 0000000000000000 R15: 00007ffcaf0cf798
--- net/ax25/ax25_route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ax25/ax25_route.c +2 -0
@@ -443,9 +443,11 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25 }if (ax25->sk !=NULL ) { +local_bh_disable ();bh_lock_sock (ax25->sk);sock_reset_flag (ax25->sk,SOCK_ZAPPED );bh_unlock_sock (ax25->sk); +local_bh_enable (); } put:
Greg Kroah-Hartman
maintainerPATCH 3/45 be2net: Fix number of Rx queues used for flow hashing
In reply to Greg Kroah-HartmanFrom: Ivan Vecera <[email protected]>
[ Upstream commit 718f4a2537089ea41903bf357071306163bc7c04 ]
Number of Rx queues used for flow hashing returned by the driver is incorrect and this bug prevents user to use the last Rx queue in indirection table.
Let's say we have a NIC with 6 combined queues:
[root@sm-03 ~]# ethtool -l enp4s0f0
Channel parameters for enp4s0f0:
Pre-set maximums:
RX: 5 TX: 5 Other: 0 Combined: 6 Current hardware settings: RX: 0 TX: 0 Other: 0 Combined: 6
Default indirection table maps all (6) queues equally but the driver reports only 5 rings available.
[root@sm-03 ~]# ethtool -x enp4s0f0
RX flow hash indirection table for enp4s0f0 with 5 RX ring(s):
0: 0 1 2 3 4 5 0 1
8: 2 3 4 5 0 1 2 3
16: 4 5 0 1 2 3 4 5
24: 0 1 2 3 4 5 0 1...
Now change indirection table somehow:
[root@sm-03 ~]# ethtool -X enp4s0f0 weight 1 1 [root@sm-03 ~]# ethtool -x enp4s0f0
RX flow hash indirection table for enp4s0f0 with 6 RX ring(s):
0: 0 0 0 0 0 0 0 0
...
64: 1 1 1 1 1 1 1 1
...
Now it is not possible to change mapping back to equal (default) state:
[root@sm-03 ~]# ethtool -X enp4s0f0 equal 6 Cannot set RX flow hash configuration: Invalid argument
--- drivers/net/ethernet/emulex/benet/be_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/emulex/benet/be_ethtool.c +1 -1
@@ -1103,7 +1103,7 @@ static int be_get_rxnfc(struct net_devic cmd->data =be_get_rss_hash_opts (adapter, cmd->flow_type);break ;case ETHTOOL_GRXRINGS : - cmd->data = adapter->num_rx_qs -1 ; + cmd->data = adapter->num_rx_qs;break ;default :return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 4/45 ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 65a3c497c0e965a552008db8bc2653f62bc925a1 ]
Before taking a refcount, make sure the object is not already scheduled for deletion.
Same fix is needed in ipv6_flowlabel_opt()
--- net/ipv6/ip6_flowlabel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv6/ip6_flowlabel.c +4 -3
@@ -254,9 +254,9 @@ struct ip6_flowlabel *fl6_sock_lookup(strcu_read_lock_bh ();for_each_sk_fl_rcu (np, sfl) {struct ip6_flowlabel *fl = sfl->fl; -if (fl->label == label) { + +if (fl->label == label &&atomic_inc_not_zero (&fl->users)) { fl->lastuse = jiffies; -atomic_inc (&fl->users);rcu_read_unlock_bh ();return fl; }
@@ -623,7 +623,8 @@ int ipv6_flowlabel_opt(struct sock *sk, goto done; } fl1 = sfl->fl; -atomic_inc (&fl1->users); +if (!atomic_inc_not_zero (&fl1->users)) + fl1 =NULL ;break ; } }
Greg Kroah-Hartman
maintainerPATCH 5/45 lapb: fixed leak of control-blocks.
In reply to Greg Kroah-HartmanFrom: Jeremy Sowden <[email protected]>
[ Upstream commit 6be8e297f9bcea666ea85ac7a6cd9d52d6deaf92 ]
lapb_register calls lapb_create_cb, which initializes the control- block's ref-count to one, and __lapb_insert_cb, which increments it when adding the new block to the list of blocks.
lapb_unregister calls __lapb_remove_cb, which decrements the ref-count when removing control-block from the list of blocks, and calls lapb_put itself to decrement the ref-count before returning.
However, lapb_unregister also calls __lapb_devtostruct to look up the right control-block for the given net_device, and __lapb_devtostruct also bumps the ref-count, which means that when lapb_unregister returns the ref-count is still 1 and the control-block is leaked.
Call lapb_put after __lapb_devtostruct to fix leak.
--- net/lapb/lapb_iface.c | 1 + 1 file changed, 1 insertion(+)
net/lapb/lapb_iface.c +1 -0
@@ -182,6 +182,7 @@ int lapb_unregister(struct net_device *d lapb =__lapb_devtostruct (dev);if (!lapb) goto out; +lapb_put (lapb);lapb_stop_t1timer (lapb);lapb_stop_t2timer (lapb);
Greg Kroah-Hartman
maintainerPATCH 6/45 neigh: fix use-after-free read in pneigh_get_next
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit f3e92cb8e2eb8c27d109e6fd73d3a69a8c09e288 ]
Nine years ago, I added RCU handling to neighbours, not pneighbours. (pneigh are not commonly used)
Unfortunately I missed that /proc dump operations would use a common entry and exit point : neigh_seq_start() and neigh_seq_stop()
We need to read_lock(tbl->lock) or risk use-after-free while iterating the pneigh structures.
We might later convert pneigh to RCU and revert this patch.
sysbot reported :
BUG: KASAN: use-after-free in pneigh_get_next.isra.0+0x24b/0x280 net/core/neighbour.c:3158
Read of size 8 at addr ffff888097f2a700 by task syz-executor.0/9825
CPU: 1 PID: 9825 Comm: syz-executor.0 Not tainted 5.2.0-rc4+ #32
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
__kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
kasan_report+0x12/0x20 mm/kasan/common.c:614
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
pneigh_get_next.isra.0+0x24b/0x280 net/core/neighbour.c:3158
neigh_seq_next+0xdb/0x210 net/core/neighbour.c:3240
seq_read+0x9cf/0x1110 fs/seq_file.c:258
proc_reg_read+0x1fc/0x2c0 fs/proc/inode.c:221
do_loop_readv_writev fs/read_write.c:714 [inline]
do_loop_readv_writev fs/read_write.c:701 [inline]
do_iter_read+0x4a4/0x660 fs/read_write.c:935
vfs_readv+0xf0/0x160 fs/read_write.c:997
kernel_readv fs/splice.c:359 [inline]
default_file_splice_read+0x475/0x890 fs/splice.c:414
do_splice_to+0x127/0x180 fs/splice.c:877
splice_direct_to_actor+0x2d2/0x970 fs/splice.c:954
do_splice_direct+0x1da/0x2a0 fs/splice.c:1063
do_sendfile+0x597/0xd00 fs/read_write.c:1464
__do_sys_sendfile64 fs/read_write.c:1525 [inline]
__se_sys_sendfile64 fs/read_write.c:1511 [inline]
__x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1511
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4592c9
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f4aab51dc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00000000004592c9
RDX: 0000000000000000 RSI: 0000000000000004 RDI: 0000000000000005
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000080000000 R11: 0000000000000246 R12: 00007f4aab51e6d4
R13: 00000000004c689d R14: 00000000004db828 R15: 00000000ffffffff
Allocated by task 9827:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_kmalloc mm/kasan/common.c:489 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
__do_kmalloc mm/slab.c:3660 [inline]
__kmalloc+0x15c/0x740 mm/slab.c:3669
kmalloc include/linux/slab.h:552 [inline]
pneigh_lookup+0x19c/0x4a0 net/core/neighbour.c:731
arp_req_set_public net/ipv4/arp.c:1010 [inline]
arp_req_set+0x613/0x720 net/ipv4/arp.c:1026
arp_ioctl+0x652/0x7f0 net/ipv4/arp.c:1226
inet_ioctl+0x2a0/0x340 net/ipv4/af_inet.c:926
sock_do_ioctl+0xd8/0x2f0 net/socket.c:1043
sock_ioctl+0x3ed/0x780 net/socket.c:1194
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:509 [inline]
do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:696
ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
__do_sys_ioctl fs/ioctl.c:720 [inline]
__se_sys_ioctl fs/ioctl.c:718 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 9824:
save_stack+0x23/0x90 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
__cache_free mm/slab.c:3432 [inline]
kfree+0xcf/0x220 mm/slab.c:3755
pneigh_ifdown_and_unlock net/core/neighbour.c:812 [inline]
__neigh_ifdown+0x236/0x2f0 net/core/neighbour.c:356
neigh_ifdown+0x20/0x30 net/core/neighbour.c:372
arp_ifdown+0x1d/0x21 net/ipv4/arp.c:1274
inetdev_destroy net/ipv4/devinet.c:319 [inline]
inetdev_event+0xa14/0x11f0 net/ipv4/devinet.c:1544
notifier_call_chain+0xc2/0x230 kernel/notifier.c:95
__raw_notifier_call_chain kernel/notifier.c:396 [inline]
raw_notifier_call_chain+0x2e/0x40 kernel/notifier.c:403
call_netdevice_notifiers_info+0x3f/0x90 net/core/dev.c:1749
call_netdevice_notifiers_extack net/core/dev.c:1761 [inline]
call_netdevice_notifiers net/core/dev.c:1775 [inline]
rollback_registered_many+0x9b9/0xfc0 net/core/dev.c:8178
rollback_registered+0x109/0x1d0 net/core/dev.c:8220
unregister_netdevice_queue net/core/dev.c:9267 [inline]
unregister_netdevice_queue+0x1ee/0x2c0 net/core/dev.c:9260
unregister_netdevice include/linux/netdevice.h:2631 [inline]
__tun_detach+0xd8a/0x1040 drivers/net/tun.c:724
tun_detach drivers/net/tun.c:741 [inline]
tun_chr_close+0xe0/0x180 drivers/net/tun.c:3451
__fput+0x2ff/0x890 fs/file_table.c:280
____fput+0x16/0x20 fs/file_table.c:313
task_work_run+0x145/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:185 [inline]
exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:168
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
do_syscall_64+0x58e/0x680 arch/x86/entry/common.c:304
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff888097f2a700
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff888097f2a700, ffff888097f2a740)
The buggy address belongs to the page:
page:ffffea00025fca80 refcount:1 mapcount:0 mapping:ffff8880aa400340 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea000250d548 ffffea00025726c8 ffff8880aa400340
raw: 0000000000000000 ffff888097f2a000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888097f2a600: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff888097f2a680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff888097f2a700: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff888097f2a780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff888097f2a800: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc--- net/core/neighbour.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/neighbour.c +7 -0
@@ -2743,6 +2743,7 @@ static void *neigh_get_idx_any(struct se }void *neigh_seq_start (struct seq_file *seq,loff_t *pos,struct neigh_table *tbl,unsigned int neigh_seq_flags) + __acquires(tbl->lock)__acquires (rcu_bh) {struct neigh_seq_state *state = seq->private;
@@ -2753,6 +2754,7 @@ void *neigh_seq_start(struct seq_file *srcu_read_lock_bh (); state->nht =rcu_dereference_bh (tbl->nht); +read_lock (&tbl->lock);return *pos ?neigh_get_idx_any (seq, pos) :SEQ_START_TOKEN ; }
@@ -2786,8 +2788,13 @@ out:EXPORT_SYMBOL (neigh_seq_next);void neigh_seq_stop (struct seq_file *seq,void *v) + __releases(tbl->lock)__releases (rcu_bh) { +struct neigh_seq_state *state = seq->private; +struct neigh_table *tbl = state->tbl; + +read_unlock (&tbl->lock);rcu_read_unlock_bh (); }EXPORT_SYMBOL (neigh_seq_stop);
Greg Kroah-Hartman
maintainerPATCH 7/45 net: openvswitch: do not free vport if register_netdevice() is failed.
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 309b66970ee2abf721ecd0876a48940fa0b99a35 ]
In order to create an internal vport, internal_dev_create() is used and that calls register_netdevice() internally.
If register_netdevice() fails, it calls dev->priv_destructor() to free private data of netdev. actually, a private data of this is a vport.
Hence internal_dev_create() should not free and use a vport after failure of register_netdevice().
Test command
ovs-dpctl add-dp bonding_masters
Splat looks like:
[ 1035.667767] kasan: GPF could be caused by NULL-ptr deref or user memory access [ 1035.675958] general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 1035.676916] CPU: 1 PID: 1028 Comm: ovs-vswitchd Tainted: G B 5.2.0-rc3+ #240 [ 1035.676916] RIP: 0010:internal_dev_create+0x2e5/0x4e0 [openvswitch] [ 1035.676916] Code: 48 c1 ea 03 80 3c 02 00 0f 85 9f 01 00 00 4c 8b 23 48 b8 00 00 00 00 00 fc ff df 49 8d bc 24 60 05 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 86 01 00 00 49 8b bc 24 60 05 00 00 e8 e4 68 f4 [ 1035.713720] RSP: 0018:ffff88810dcb7578 EFLAGS: 00010206 [ 1035.713720] RAX: dffffc0000000000 RBX: ffff88810d13fe08 RCX: ffffffff84297704 [ 1035.713720] RDX: 00000000000000ac RSI: 0000000000000000 RDI: 0000000000000560 [ 1035.713720] RBP: 00000000ffffffef R08: fffffbfff0d3b881 R09: fffffbfff0d3b881 [ 1035.713720] R10: 0000000000000001 R11: fffffbfff0d3b880 R12: 0000000000000000 [ 1035.768776] R13: 0000607ee460b900 R14: ffff88810dcb7690 R15: ffff88810dcb7698 [ 1035.777709] FS: 00007f02095fc980(0000) GS:ffff88811b400000(0000) knlGS:0000000000000000 [ 1035.777709] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1035.777709] CR2: 00007ffdf01d2f28 CR3: 0000000108258000 CR4: 00000000001006e0 [ 1035.777709] Call Trace: [ 1035.777709] ovs_vport_add+0x267/0x4f0 [openvswitch] [ 1035.777709] new_vport+0x15/0x1e0 [openvswitch] [ 1035.777709] ovs_vport_cmd_new+0x567/0xd10 [openvswitch] [ 1035.777709] ? ovs_dp_cmd_dump+0x490/0x490 [openvswitch] [ 1035.777709] ? __kmalloc+0x131/0x2e0 [ 1035.777709] ? genl_family_rcv_msg+0xa54/0x1030 [ 1035.777709] genl_family_rcv_msg+0x63a/0x1030 [ 1035.777709] ? genl_unregister_family+0x630/0x630 [ 1035.841681] ? debug_show_all_locks+0x2d0/0x2d0
[ ... ]
--- net/openvswitch/vport-internal_dev.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
net/openvswitch/vport-internal_dev.c +12 -6
@@ -176,7 +176,9 @@ static struct vport *internal_dev_create {struct vport *vport;struct internal_dev *internal_dev; +struct net_device *dev;int err; +bool free_vport = true; vport =ovs_vport_alloc (0 , &ovs_internal_vport_ops, parms);if (IS_ERR (vport)) {
@@ -184,8 +186,9 @@ static struct vport *internal_dev_create goto error; } - vport->dev =alloc_netdev (sizeof (struct internal_dev ), - parms->name,NET_NAME_USER , do_setup); + dev =alloc_netdev (sizeof (struct internal_dev ), + parms->name,NET_NAME_USER , do_setup); + vport->dev = dev;if (!vport->dev) { err = -ENOMEM ; goto error_free_vport;
@@ -207,8 +210,10 @@ static struct vport *internal_dev_creatertnl_lock (); err =register_netdevice (vport->dev); -if (err) +if (err) { + free_vport = false; goto error_unlock; + }dev_set_promiscuity (vport->dev,1 );rtnl_unlock ();
@@ -218,11 +223,12 @@ static struct vport *internal_dev_create error_unlock:rtnl_unlock (); -free_percpu (vport->dev->tstats); +free_percpu (dev->tstats); error_free_netdev: -free_netdev (vport->dev); +free_netdev (dev); error_free_vport: -ovs_vport_free (vport); +if (free_vport) +ovs_vport_free (vport); error:return ERR_PTR (err); }
Greg Kroah-Hartman
maintainerPATCH 8/45 sctp: Free cookie before we memdup a new one
In reply to Greg Kroah-HartmanFrom: Neil Horman <[email protected]>
[ Upstream commit ce950f1050cece5e406a5cde723c69bba60e1b26 ]
Based on comments from Xin, even after fixes for our recent syzbot report of cookie memory leaks, its possible to get a resend of an INIT chunk which would lead to us leaking cookie memory.
To ensure that we don't leak cookie memory, free any previously allocated cookie first.
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)
v2->v3net->sctp
also free peer_chunks
v3->v4
fix subject tags
v4->v5
remove cut line
--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/sctp/sm_make_chunk.c +8 -0
@@ -2586,6 +2586,8 @@ do_addr_param:case SCTP_PARAM_STATE_COOKIE : asoc->peer.cookie_len =ntohs (param.p->length) -sizeof (struct sctp_paramhdr ); +if (asoc->peer.cookie) +kfree (asoc->peer.cookie); asoc->peer.cookie =kmemdup (param.cookie->body, asoc->peer.cookie_len, gfp);if (!asoc->peer.cookie) retval =0 ;
@@ -2650,6 +2652,8 @@ do_addr_param: goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {
@@ -2663,6 +2667,8 @@ do_addr_param: goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {
@@ -2678,6 +2684,8 @@ do_addr_param:if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks)
Greg Kroah-Hartman
maintainerPATCH 9/45 sunhv: Fix device naming inconsistency between sunhv_console and sunhv_reg
In reply to Greg Kroah-HartmanFrom: John Paul Adrian Glaubitz <[email protected]>
[ Upstream commit 07a6d63eb1b54b5fb38092780fe618dfe1d96e23 ]
In d5a2aa24, the name in struct console sunhv_console was changed from "ttyS" to "ttyHV" while the name in struct uart_ops sunhv_pops remained unchanged.
This results in the hypervisor console device to be listed as "ttyHV0" under /proc/consoles while the device node is still named "ttyS0":
root@osaka:~# cat /proc/consoles ttyHV0 -W- (EC p ) 4:64 tty0 -WU (E ) 4:1 root@osaka:~# readlink /sys/dev/char/4:64 ../../devices/root/f02836f0/f0285690/tty/ttyS0 root@osaka:~#
This means that any userland code which tries to determine the name of the device file of the hypervisor console device can not rely on the information provided by /proc/consoles. In particular, booting current versions of debian- installer inside a SPARC LDOM will fail with the installer unable to determine the console device.
After renaming the device in struct uart_ops sunhv_pops to "ttyHV" as well, the inconsistency is fixed and it is possible again to determine the name of the device file of the hypervisor console device by reading the contents of /proc/console:
root@osaka:~# cat /proc/consoles ttyHV0 -W- (EC p ) 4:64 tty0 -WU (E ) 4:1 root@osaka:~# readlink /sys/dev/char/4:64 ../../devices/root/f02836f0/f0285690/tty/ttyHV0 root@osaka:~#
With this change, debian-installer works correctly when installing inside a SPARC LDOM.
--- drivers/tty/serial/sunhv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sunhv.c +1 -1
@@ -396,7 +396,7 @@ static const struct uart_ops sunhv_popsstatic struct uart_driver sunhv_reg = { .owner =THIS_MODULE , .driver_name ="sunhv" , - .dev_name ="ttyS" , + .dev_name ="ttyHV" , .major =TTY_MAJOR , };
Greg Kroah-Hartman
maintainerPATCH 10/45 Staging: vc04_services: Fix a couple error codes
In reply to Greg Kroah-Hartman[ Upstream commit ca4e4efbefbbdde0a7bb3023ea08d491f4daf9b9 ]
These are accidentally returning positive EINVAL instead of negative -EINVAL. Some of the callers treat positive values as success.
--- drivers/staging/vc04_services/bcm2835-camera/controls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/controls.c +2 -2
@@ -579,7 +579,7 @@ static int ctrl_set_image_effect(struct bm2835_mmal_dev *dev, dev->colourfx.enable ?"true" :"false" , dev->colourfx.u, dev->colourfx.v, ret, (ret == 0 ? 0 : -EINVAL)); -return (ret ==0 ?0 :EINVAL ); +return (ret ==0 ?0 : -EINVAL ); } static int ctrl_set_colfx(struct bm2835_mmal_dev *dev,
@@ -603,7 +603,7 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev,"%s: After: mmal_ctrl:%p ctrl id:0x%x ctrl val:%d ret %d(%d)\n" , __func__, mmal_ctrl, ctrl->id, ctrl->val, ret, (ret == 0 ? 0 : -EINVAL)); -return (ret ==0 ?0 :EINVAL ); +return (ret ==0 ?0 : -EINVAL ); } static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 11/45 perf/x86/intel/ds: Fix EVENT vs. UEVENT PEBS constraints
In reply to Greg Kroah-Hartman[ Upstream commit 23e3983a466cd540ffdd2bbc6e0c51e31934f941 ]
This patch fixes an bug revealed by the following commit:
6b89d4c1ae85 ("perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking")
That patch modified INTEL_FLAGS_EVENT_CONSTRAINT() to only look at the event code when matching a constraint. If code+umask were needed, then the INTEL_FLAGS_UEVENT_CONSTRAINT() macro was needed instead.
This broke with some of the constraints for PEBS events.
Several of them, including the one used for cycles:p, cycles:pp, cycles:ppp fell in that category and caused the event to be rejected in PEBS mode. In other words, on some platforms a cmdline such as:
$ perf top -e cycles:pp
would fail with -EINVAL.
This patch fixes this bug by properly using INTEL_FLAGS_UEVENT_CONSTRAINT() when needed in the PEBS constraint tables.
--- arch/x86/events/intel/ds.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
arch/x86/events/intel/ds.c +14 -14
@@ -681,7 +681,7 @@ struct event_constraint intel_core2_pebs_event_constraints[] = {INTEL_FLAGS_UEVENT_CONSTRAINT (0x1fc7 ,0x1 ),/* SIMD_INST_RETURED.ANY */ INTEL_FLAGS_EVENT_CONSTRAINT (0xcb ,0x1 ),/* MEM_LOAD_RETIRED.* */ /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x01 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x01 ), EVENT_CONSTRAINT_END };
@@ -690,7 +690,7 @@ struct event_constraint intel_atom_pebs_event_constraints[] = {INTEL_FLAGS_UEVENT_CONSTRAINT (0x00c5 ,0x1 ),/* MISPREDICTED_BRANCH_RETIRED */ INTEL_FLAGS_EVENT_CONSTRAINT (0xcb ,0x1 ),/* MEM_LOAD_RETIRED.* */ /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x01 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x01 ),/* Allow all events as PEBS with no flags */ INTEL_ALL_EVENT_CONSTRAINT (0 ,0x1 ),EVENT_CONSTRAINT_END
@@ -698,7 +698,7 @@ struct event_constraint intel_atom_pebs_event_constraints[] = {struct event_constraint intel_slm_pebs_event_constraints[] = {/* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x1 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x1 ),/* Allow all events as PEBS with no flags */ INTEL_ALL_EVENT_CONSTRAINT (0 ,0x1 ),EVENT_CONSTRAINT_END
@@ -729,7 +729,7 @@ struct event_constraint intel_nehalem_pebs_event_constraints[] = {INTEL_FLAGS_EVENT_CONSTRAINT (0xcb ,0xf ),/* MEM_LOAD_RETIRED.* */ INTEL_FLAGS_EVENT_CONSTRAINT (0xf7 ,0xf ),/* FP_ASSIST.* */ /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x0f ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x0f ), EVENT_CONSTRAINT_END };
@@ -746,7 +746,7 @@ struct event_constraint intel_westmere_pebs_event_constraints[] = {INTEL_FLAGS_EVENT_CONSTRAINT (0xcb ,0xf ),/* MEM_LOAD_RETIRED.* */ INTEL_FLAGS_EVENT_CONSTRAINT (0xf7 ,0xf ),/* FP_ASSIST.* */ /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x0f ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x0f ), EVENT_CONSTRAINT_END };
@@ -755,7 +755,7 @@ struct event_constraint intel_snb_pebs_event_constraints[] = {INTEL_PLD_CONSTRAINT (0x01cd ,0x8 ),/* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ INTEL_PST_CONSTRAINT (0x02cd ,0x8 ),/* MEM_TRANS_RETIRED.PRECISE_STORES */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c2 ,0xf ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c2 ,0xf ),INTEL_EXCLEVT_CONSTRAINT (0xd0 ,0xf ),/* MEM_UOP_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT (0xd1 ,0xf ),/* MEM_LOAD_UOPS_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
@@ -770,9 +770,9 @@ struct event_constraint intel_ivb_pebs_event_constraints[] = {INTEL_PLD_CONSTRAINT (0x01cd ,0x8 ),/* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ INTEL_PST_CONSTRAINT (0x02cd ,0x8 ),/* MEM_TRANS_RETIRED.PRECISE_STORES */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c2 ,0xf ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c2 ,0xf ),/* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c0 ,0x2 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c0 ,0x2 ),INTEL_EXCLEVT_CONSTRAINT (0xd0 ,0xf ),/* MEM_UOP_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT (0xd1 ,0xf ),/* MEM_LOAD_UOPS_RETIRED.* */ INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
@@ -786,9 +786,9 @@ struct event_constraint intel_hsw_pebs_event_constraints[] = {INTEL_FLAGS_UEVENT_CONSTRAINT (0x01c0 ,0x2 ),/* INST_RETIRED.PRECDIST */ INTEL_PLD_CONSTRAINT (0x01cd ,0xf ),/* MEM_TRANS_RETIRED.* */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c2 ,0xf ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c2 ,0xf ),/* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c0 ,0x2 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c0 ,0x2 ),INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA (0x01c2 ,0xf ),/* UOPS_RETIRED.ALL */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD (0x11d0 ,0xf ),/* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */
@@ -809,9 +809,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = {INTEL_FLAGS_UEVENT_CONSTRAINT (0x01c0 ,0x2 ),/* INST_RETIRED.PRECDIST */ INTEL_PLD_CONSTRAINT (0x01cd ,0xf ),/* MEM_TRANS_RETIRED.* */ /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c2 ,0xf ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c2 ,0xf ),/* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c0 ,0x2 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c0 ,0x2 ),INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA (0x01c2 ,0xf ),/* UOPS_RETIRED.ALL */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD (0x11d0 ,0xf ),/* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */
@@ -832,9 +832,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = {struct event_constraint intel_skl_pebs_event_constraints[] = {INTEL_FLAGS_UEVENT_CONSTRAINT (0x1c0 ,0x2 ),/* INST_RETIRED.PREC_DIST */ /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108001c0 ,0x2 ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108001c0 ,0x2 ),/* INST_RETIRED.TOTAL_CYCLES_PS (inv=1, cmask=16) (cycles:p). */ -INTEL_FLAGS_EVENT_CONSTRAINT (0x108000c0 ,0x0f ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x108000c0 ,0x0f ),INTEL_PLD_CONSTRAINT (0x1cd ,0xf ),/* MEM_TRANS_RETIRED.* */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD (0x11d0 ,0xf ),/* MEM_INST_RETIRED.STLB_MISS_LOADS */ INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST (0x12d0 ,0xf ),/* MEM_INST_RETIRED.STLB_MISS_STORES */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 12/45 netfilter: nf_queue: fix reinject verdict handling
In reply to Greg Kroah-Hartman[ Upstream commit 946c0d8e6ed43dae6527e878d0077c1e11015db0 ]
This patch fixes netfilter hook traversal when there are more than 1 hooks returning NF_QUEUE verdict. When the first queue reinjects the packet, 'nf_reinject' starts traversing hooks with a proper hook_index. However, if it again receives a NF_QUEUE verdict (by some other netfilter hook), it queues the packet with a wrong hook_index. So, when the second queue reinjects the packet, it re-executes hooks in between.
--- net/netfilter/nf_queue.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_queue.c +1 -0
@@ -193,6 +193,7 @@ static unsigned int nf_iterate(struct sk_buff *skb, repeat: verdict =nf_hook_entry_hookfn (hook, skb, state);if (verdict !=NF_ACCEPT ) { + *index = i;if (verdict !=NF_REPEAT )return verdict; goto repeat;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 13/45 ipvs: Fix use-after-free in ip_vs_in
In reply to Greg Kroah-Hartman[ Upstream commit 719c7d563c17b150877cee03a4b812a424989dfa ]
BUG: KASAN: use-after-free in ip_vs_in.part.29+0xe8/0xd20 [ip_vs] Read of size 4 at addr ffff8881e9b26e2c by task sshd/5603 CPU: 0 PID: 5603 Comm: sshd Not tainted 4.19.39+ #30 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 Call Trace: dump_stack+0x71/0xab print_address_description+0x6a/0x270 kasan_report+0x179/0x2c0 ip_vs_in.part.29+0xe8/0xd20 [ip_vs] ip_vs_in+0xd8/0x170 [ip_vs] nf_hook_slow+0x5f/0xe0 __ip_local_out+0x1d5/0x250 ip_local_out+0x19/0x60 __tcp_transmit_skb+0xba1/0x14f0 tcp_write_xmit+0x41f/0x1ed0 ? _copy_from_iter_full+0xca/0x340 __tcp_push_pending_frames+0x52/0x140 tcp_sendmsg_locked+0x787/0x1600 ? tcp_sendpage+0x60/0x60 ? inet_sk_set_state+0xb0/0xb0 tcp_sendmsg+0x27/0x40 sock_sendmsg+0x6d/0x80 sock_write_iter+0x121/0x1c0 ? sock_sendmsg+0x80/0x80 __vfs_write+0x23e/0x370 vfs_write+0xe7/0x230 ksys_write+0xa1/0x120 ? __ia32_sys_read+0x50/0x50 ? __audit_syscall_exit+0x3ce/0x450 do_syscall_64+0x73/0x200 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7ff6f6147c60 Code: 73 01 c3 48 8b 0d 28 12 2d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 5d 73 2d 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 RSP: 002b:00007ffd772ead18 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000034 RCX: 00007ff6f6147c60 RDX: 0000000000000034 RSI: 000055df30a31270 RDI: 0000000000000003 RBP: 000055df30a31270 R08: 0000000000000000 R09: 0000000000000000 R10: 00007ffd772ead70 R11: 0000000000000246 R12: 00007ffd772ead74 R13: 00007ffd772eae20 R14: 00007ffd772eae24 R15: 000055df2f12ddc0 Allocated by task 6052: kasan_kmalloc+0xa0/0xd0 __kmalloc+0x10a/0x220 ops_init+0x97/0x190 register_pernet_operations+0x1ac/0x360 register_pernet_subsys+0x24/0x40 0xffffffffc0ea016d do_one_initcall+0x8b/0x253 do_init_module+0xe3/0x335 load_module+0x2fc0/0x3890 __do_sys_finit_module+0x192/0x1c0 do_syscall_64+0x73/0x200 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 6067: __kasan_slab_free+0x130/0x180 kfree+0x90/0x1a0 ops_free_list.part.7+0xa6/0xc0 unregister_pernet_operations+0x18b/0x1f0 unregister_pernet_subsys+0x1d/0x30 ip_vs_cleanup+0x1d/0xd2f [ip_vs] __x64_sys_delete_module+0x20c/0x300 do_syscall_64+0x73/0x200 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff8881e9b26600 which belongs to the cache kmalloc-4096 of size 4096 The buggy address is located 2092 bytes inside of 4096-byte region [ffff8881e9b26600, ffff8881e9b27600) The buggy address belongs to the page: page:ffffea0007a6c800 count:1 mapcount:0 mapping:ffff888107c0e600 index:0x0 compound_mapcount: 0 flags: 0x17ffffc0008100(slab|head) raw: 0017ffffc0008100 dead000000000100 dead000000000200 ffff888107c0e600 raw: 0000000000000000 0000000080070007 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected
while unregistering ipvs module, ops_free_list calls __ip_vs_cleanup, then nf_unregister_net_hooks be called to do remove nf hook entries. It need a RCU period to finish, however net->ipvs is set to NULL immediately, which will trigger NULL pointer dereference when a packet is hooked and handled by ip_vs_in where net->ipvs is dereferenced.
Another scene is ops_free_list call ops_free to free the net_generic directly while __ip_vs_cleanup finished, then calling ip_vs_in will triggers use-after-free.
This patch moves nf_unregister_net_hooks from __ip_vs_cleanup() to __ip_vs_dev_cleanup(), where rcu_barrier() is called by unregister_pernet_device -> unregister_pernet_operations, that will do the needed grace period.
--- net/netfilter/ipvs/ip_vs_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_core.c +1 -1
@@ -2268,7 +2268,6 @@ static void __net_exit __ip_vs_cleanup(struct net *net) {struct netns_ipvs *ipvs =net_ipvs (net); -nf_unregister_net_hooks (net, ip_vs_ops,ARRAY_SIZE (ip_vs_ops));ip_vs_service_net_cleanup (ipvs);/* ip_vs_flush() with locks */ ip_vs_conn_net_cleanup (ipvs);ip_vs_app_net_cleanup (ipvs);
@@ -2283,6 +2282,7 @@ static void __net_exit __ip_vs_dev_cleanup(struct net *net) {struct netns_ipvs *ipvs =net_ipvs (net);EnterFunction (2 ); +nf_unregister_net_hooks (net, ip_vs_ops,ARRAY_SIZE (ip_vs_ops)); ipvs->enable =0 ;/* Disable packet reception */ smp_wmb ();ip_vs_sync_net_cleanup (ipvs);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 14/45 selftests: netfilter: missing error check when setting up veth interface
In reply to Greg Kroah-Hartman[ Upstream commit 82ce6eb1dd13fd12e449b2ee2c2ec051e6f52c43 ]
A test for the basic NAT functionality uses ip command which needs veth device. There is a condition where the kernel support for veth is not compiled into the kernel and the test script breaks. This patch contains code for reasonable error display and correct code exit.
--- tools/testing/selftests/netfilter/nft_nat.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/netfilter/nft_nat.sh +5 -1
@@ -23,7 +23,11 @@ ip netns add ns0 ip netns add ns1 ip netns add ns2 -ip link add veth0 netns ns0 type veth peer name eth0 netns ns1 +ip link add veth0 netns ns0 type veth peer name eth0 netns ns1 > /dev/null 2>&1 +if [ $? -ne 0 ];then + echo "SKIP: No virtual ethernet pair device support in kernel" + exit $ksft_skip +fi ip link add veth1 netns ns0 type veth peer name eth0 netns ns2 ip -net ns0 link set lo up
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 15/45 clk: ti: clkctrl: Fix clkdm_clk handling
In reply to Greg Kroah-Hartman[ Upstream commit 1cc54078d104f5b4d7e9f8d55362efa5a8daffdb ]
We need to always call clkdm_clk_enable() and clkdm_clk_disable() even the clkctrl clock(s) enabled for the domain do not have any gate register bits. Otherwise clockdomains may never get enabled except when devices get probed with the legacy "ti,hwmods" devicetree property.
--- drivers/clk/ti/clkctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/ti/clkctrl.c +4 -4
@@ -124,9 +124,6 @@ static int _omap4_clkctrl_clk_enable(struct clk_hw *hw)int ret;union omap4_timeout timeout = {0 }; -if (!clk->enable_bit) -return 0 ; -if (clk->clkdm) { ret = ti_clk_ll_ops->clkdm_clk_enable (clk->clkdm, hw->clk);if (ret) {
@@ -138,6 +135,9 @@ static int _omap4_clkctrl_clk_enable(struct clk_hw *hw) } } +if (!clk->enable_bit) +return 0 ; + val = ti_clk_ll_ops->clk_readl (&clk->enable_reg); val &= ~OMAP4_MODULEMODE_MASK ;
@@ -166,7 +166,7 @@ static void _omap4_clkctrl_clk_disable(struct clk_hw *hw)union omap4_timeout timeout = {0 };if (!clk->enable_bit) -return ; + goto exit; val = ti_clk_ll_ops->clk_readl (&clk->enable_reg);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 16/45 powerpc/powernv: Return for invalid IMC domain
In reply to Greg Kroah-Hartman[ Upstream commit b59bd3527fe3c1939340df558d7f9d568fc9f882 ]
Currently init_imc_pmu() can fail either because we try to register an IMC unit with an invalid domain (i.e an IMC node not supported by the kernel) or something went wrong while registering a valid IMC unit. In both the cases kernel provides a 'Register failed' error message.
For example when trace-imc node is not supported by the kernel, but skiboot advertises a trace-imc node we print:
IMC Unknown Device type
IMC PMU (null) Register failed
To avoid confusion just print the unknown device type message, before attempting PMU registration, so the second message isn't printed.
--- arch/powerpc/platforms/powernv/opal-imc.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/platforms/powernv/opal-imc.c +4 -0
@@ -87,6 +87,10 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index, int domain)struct imc_pmu *pmu_ptr;u32 offset; +/* Return for unknown domain */ +if (domain <0 ) +return -EINVAL ; +/* memory for pmu */ pmu_ptr =kzalloc (sizeof (struct imc_pmu ),GFP_KERNEL );if (!pmu_ptr)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 17/45 mISDN: make sure device name is NUL terminated
In reply to Greg Kroah-Hartman[ Upstream commit ccfb62f27beb295103e9392462b20a6ed807d0ea ]
The user can change the device_name with the IMSETDEVNAME ioctl, but we need to ensure that the user's name is NUL terminated. Otherwise it could result in a buffer overflow when we copy the name back to the user with IMGETDEVINFO ioctl.
I also changed two strcpy() calls which handle the name to strscpy(). Hopefully, there aren't any other ways to create a too long name, but it's nice to do this as a kernel hardening measure.
--- drivers/isdn/mISDN/socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/isdn/mISDN/socket.c +3 -2
@@ -394,7 +394,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)memcpy (di.channelmap, dev->channelmap,sizeof (di.channelmap)); di.nrbchan = dev->nrbchan; -strcpy (di.name,dev_name (&dev->dev)); +strscpy (di.name,dev_name (&dev->dev),sizeof (di.name));if (copy_to_user ((void __user *)arg, &di,sizeof (di))) err = -EFAULT ; }else
@@ -678,7 +678,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)memcpy (di.channelmap, dev->channelmap,sizeof (di.channelmap)); di.nrbchan = dev->nrbchan; -strcpy (di.name,dev_name (&dev->dev)); +strscpy (di.name,dev_name (&dev->dev),sizeof (di.name));if (copy_to_user ((void __user *)arg, &di,sizeof (di))) err = -EFAULT ; }else
@@ -692,6 +692,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) err = -EFAULT ;break ; } + dn.name[sizeof (dn.name) -1 ] ='\0' ; dev =get_mdevice (dn.id);if (dev) err =device_rename (&dev->dev, dn.name);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 18/45 x86/CPU/AMD: Dont force the CPB cap when running under a hypervisor
In reply to Greg Kroah-Hartman[ Upstream commit 2ac44ab608705948564791ce1d15d43ba81a1e38 ]
For F17h AMD CPUs, the CPB capability ('Core Performance Boost') is forcibly set, because some versions of that chip incorrectly report that they do not have it.
However, a hypervisor may filter out the CPB capability, for good reasons. For example, KVM currently does not emulate setting the CPB bit in MSR_K7_HWCR, and unchecked MSR access errors will be thrown when trying to set it as a guest:
unchecked MSR access error: WRMSR to 0xc0010015 (tried to write 0x0000000001000011) at rIP: 0xffffffff890638f4 (native_write_msr+0x4/0x20) Call Trace: boost_set_msr+0x50/0x80 [acpi_cpufreq] cpuhp_invoke_callback+0x86/0x560 sort_range+0x20/0x20 cpuhp_thread_fun+0xb0/0x110 smpboot_thread_fn+0xef/0x160 kthread+0x113/0x130 kthread_create_worker_on_cpu+0x70/0x70 ret_from_fork+0x35/0x40
To avoid this issue, don't forcibly set the CPB capability for a CPU when running under a hypervisor.
--- arch/x86/kernel/cpu/amd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/amd.c +5 -2
@@ -792,8 +792,11 @@ static void init_amd_zn(struct cpuinfo_x86 *c) {set_cpu_cap (c,X86_FEATURE_ZEN ); -/* Fix erratum 1076: CPB feature bit not being set in CPUID. */ -if (!cpu_has (c,X86_FEATURE_CPB )) +/* +* Fix erratum 1076: CPB feature bit not being set in CPUID. +* Always set it, except when running under a hypervisor. +*/ +if (!cpu_has (c,X86_FEATURE_HYPERVISOR ) && !cpu_has (c,X86_FEATURE_CPB ))set_cpu_cap (c,X86_FEATURE_CPB ); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 19/45 perf/ring_buffer: Fix exposing a temporarily decreased data_head
In reply to Greg Kroah-Hartman[ Upstream commit 1b038c6e05ff70a1e66e3e571c2e6106bdb75f53 ]
In perf_output_put_handle(), an IRQ/NMI can happen in below location and write records to the same ring buffer:
... local_dec_and_test(&rb->nest) ... <-- an IRQ/NMI can happen here rb->user_page->data_head = head; ...
In this case, a value A is written to data_head in the IRQ, then a value B is written to data_head after the IRQ. And A > B. As a result, data_head is temporarily decreased from A to B. And a reader may see data_head < data_tail if it read the buffer frequently enough, which creates unexpected behaviors.
This can be fixed by moving dec(&rb->nest) to after updating data_head, which prevents the IRQ/NMI above from updating data_head.
[ Split up by peterz. ]
--- kernel/events/ring_buffer.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/events/ring_buffer.c +20 -4
@@ -52,11 +52,18 @@ static void perf_output_put_handle(struct perf_output_handle *handle) head =local_read (&rb->head);/* -* IRQ/NMI can happen here, which means we can miss a head update. +* IRQ/NMI can happen here and advance @rb->head, causing our +* load above to be stale. */ -if (!local_dec_and_test (&rb->nest)) +/* +* If this isn't the outermost nesting, we don't have to update +* @rb->user_page->data_head. +*/ +if (local_read (&rb->nest) >1 ) { +local_dec (&rb->nest); goto out; + }/* * Since the mmap() consumer (userspace) can run on a different CPU:
@@ -88,9 +95,18 @@ static void perf_output_put_handle(struct perf_output_handle *handle) rb->user_page->data_head = head;/* -* Now check if we missed an update -- rely on previous implied -* compiler barriers to force a re-read. +* We must publish the head before decrementing the nest count, +* otherwise an IRQ/NMI can publish a more recent head value and our +* write will (temporarily) publish a stale value. +*/ +barrier (); +local_set (&rb->nest,0 ); + +/* +* Ensure we decrement @rb->nest before we validate the @rb->head. +* Otherwise we cannot be sure we caught the 'last' nested update. */ +barrier ();if (unlikely (head !=local_read (&rb->head))) {local_inc (&rb->nest); goto again;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 20/45 perf/ring_buffer: Add ordering to rb->nest increment
In reply to Greg Kroah-Hartman[ Upstream commit 3f9fbe9bd86c534eba2faf5d840fd44c6049f50e ]
Similar to how decrementing rb->next too early can cause data_head to (temporarily) be observed to go backward, so too can this happen when we increment too late.
This barrier() ensures the rb->head load happens after the increment, both the one in the 'goto again' path, as the one from perf_output_get_handle() -- albeit very unlikely to matter for the latter.
--- kernel/events/ring_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/events/ring_buffer.c +9 -0
@@ -49,6 +49,15 @@ static void perf_output_put_handle(struct perf_output_handle *handle)unsigned long head; again: +/* +* In order to avoid publishing a head value that goes backwards, +* we must ensure the load of @rb->head happens after we've +* incremented @rb->nest. +* +* Otherwise we can observe a @rb->head value before one published +* by an IRQ/NMI happening between the load and the increment. +*/ +barrier (); head =local_read (&rb->head);/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 21/45 perf/ring-buffer: Always use {READ,WRITE}_ONCE() for rb->user_page data
In reply to Greg Kroah-Hartman[ Upstream commit 4d839dd9e4356bbacf3eb0ab13a549b83b008c21 ]
We must use {READ,WRITE}_ONCE() on rb->user_page data such that concurrent usage will see whole values. A few key sites were missing this.
--- kernel/events/ring_buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/ring_buffer.c +3 -3
@@ -101,7 +101,7 @@ static void perf_output_put_handle(struct perf_output_handle *handle)* See perf_output_begin(). */ smp_wmb ();/* B, matches C */ - rb->user_page->data_head = head; +WRITE_ONCE (rb->user_page->data_head, head);/* * We must publish the head before decrementing the nest count,
@@ -489,7 +489,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) handle->aux_flags); } - rb->user_page->aux_head = rb->aux_head; +WRITE_ONCE (rb->user_page->aux_head, rb->aux_head);if (rb_need_aux_wakeup (rb)) wakeup = true;
@@ -520,7 +520,7 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size) rb->aux_head += size; - rb->user_page->aux_head = rb->aux_head; +WRITE_ONCE (rb->user_page->aux_head, rb->aux_head);if (rb_need_aux_wakeup (rb)) {perf_output_wakeup (handle); handle->wakeup = rb->aux_wakeup + rb->aux_watermark;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 22/45 gpio: fix gpio-adp5588 build errors
In reply to Greg Kroah-Hartman[ Upstream commit e9646f0f5bb62b7d43f0968f39d536cfe7123b53 ]
The gpio-adp5588 driver uses interfaces that are provided by GPIOLIB_IRQCHIP, so select that symbol in its Kconfig entry.
Fixes these build errors:
../drivers/gpio/gpio-adp5588.c: In function ‘adp5588_irq_handler’:../drivers/gpio/gpio-adp5588.c:266:26: error: ‘struct gpio_chip’ has no member named ‘irq’
dev->gpio_chip.irq.domain, gpio));
^../drivers/gpio/gpio-adp5588.c: In function ‘adp5588_irq_setup’:../drivers/gpio/gpio-adp5588.c:298:2: error: implicit declaration of function ‘gpiochip_irqchip_add_nested’ [-Werror=implicit-function-declaration]
ret = gpiochip_irqchip_add_nested(&dev->gpio_chip,
^../drivers/gpio/gpio-adp5588.c:307:2: error: implicit declaration of function ‘gpiochip_set_nested_irqchip’ [-Werror=implicit-function-declaration]
gpiochip_set_nested_irqchip(&dev->gpio_chip,
^
--- drivers/gpio/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/Kconfig +1 -0
@@ -712,6 +712,7 @@ config GPIO_ADP5588 config GPIO_ADP5588_IRQ bool "Interrupt controller support for ADP5588" depends on GPIO_ADP5588=y + select GPIOLIB_IRQCHIP help Say yes here to enable the adp5588 to be used as an interrupt controller. It requires the driver to be built in the kernel.
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 23/45 net: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE()
In reply to Greg Kroah-Hartman[ Upstream commit 3e66b7cc50ef921121babc91487e1fb98af1ba6e ]
Building with Clang reports the redundant use of MODULE_DEVICE_TABLE():
drivers/net/ethernet/dec/tulip/de4x5.c:2110:1: error: redefinition of '__mod_eisa__de4x5_eisa_ids_device_table' MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
^./include/linux/module.h:229:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
extern typeof(name) __mod_##type##__##name##_device_table \
^<scratch space>:90:1: note: expanded from here __mod_eisa__de4x5_eisa_ids_device_table
^drivers/net/ethernet/dec/tulip/de4x5.c:2100:1: note: previous definition is here MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
^./include/linux/module.h:229:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
extern typeof(name) __mod_##type##__##name##_device_table \
^<scratch space>:85:1: note: expanded from here__mod_eisa__de4x5_eisa_ids_device_table
^
This drops the one further from the table definition to match the common use of MODULE_DEVICE_TABLE().
--- drivers/net/ethernet/dec/tulip/de4x5.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/dec/tulip/de4x5.c +0 -1
@@ -2108,7 +2108,6 @@ static struct eisa_driver de4x5_eisa_driver = { .remove = de4x5_eisa_remove, } }; -MODULE_DEVICE_TABLE (eisa, de4x5_eisa_ids);#endif #ifdef CONFIG_PCI
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 24/45 net: aquantia: fix LRO with FCS error
In reply to Greg Kroah-Hartman[ Upstream commit eaeb3b7494ba9159323814a8ce8af06a9277d99b ]
Driver stops producing skbs on ring if a packet with FCS error was coalesced into LRO session. Ring gets hang forever.
Thats a logical error in driver processing descriptors:
When rx_stat indicates MAC Error, next pointer and eop flags are not filled. This confuses driver so it waits for descriptor 0 to be filled by HW.
Solution is fill next pointer and eop flag even for packets with FCS error.
--- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +32 -29
@@ -683,38 +683,41 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self,if (is_err || rxd_wb->type &0x1000U ) {/* status error or DMA error */ buff->is_error =1U ; - }else { -if (self->aq_nic_cfg->is_rss) { -/* last 4 byte */ -u16 rss_type = rxd_wb->type &0xFU ; - -if (rss_type && rss_type <0x8U ) { - buff->is_hash_l4 = (rss_type ==0x4 || - rss_type ==0x5 ); - buff->rss_hash = rxd_wb->rss_hash; - } + } +if (self->aq_nic_cfg->is_rss) { +/* last 4 byte */ +u16 rss_type = rxd_wb->type &0xFU ; + +if (rss_type && rss_type <0x8U ) { + buff->is_hash_l4 = (rss_type ==0x4 || + rss_type ==0x5 ); + buff->rss_hash = rxd_wb->rss_hash; } + } -if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) { - buff->len = rxd_wb->pkt_len % -AQ_CFG_RX_FRAME_MAX ; - buff->len = buff->len ? - buff->len :AQ_CFG_RX_FRAME_MAX ; - buff->next =0U ; - buff->is_eop =1U ; +if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) { + buff->len = rxd_wb->pkt_len % +AQ_CFG_RX_FRAME_MAX ; + buff->len = buff->len ? + buff->len :AQ_CFG_RX_FRAME_MAX ; + buff->next =0U ; + buff->is_eop =1U ; + }else { + buff->len = + rxd_wb->pkt_len >AQ_CFG_RX_FRAME_MAX ? +AQ_CFG_RX_FRAME_MAX : rxd_wb->pkt_len; + +if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT & + rxd_wb->status) { +/* LRO */ + buff->next = rxd_wb->next_desc_ptr; + ++ring->stats.rx.lro_packets; }else { -if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT & - rxd_wb->status) { -/* LRO */ - buff->next = rxd_wb->next_desc_ptr; - ++ring->stats.rx.lro_packets; - }else { -/* jumbo */ - buff->next = -aq_ring_next_dx (ring, - ring->hw_head); - ++ring->stats.rx.jumbo_packets; - } +/* jumbo */ + buff->next = +aq_ring_next_dx (ring, + ring->hw_head); + ++ring->stats.rx.jumbo_packets; } } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 25/45 i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr
In reply to Greg Kroah-Hartman[ Upstream commit a0692f0eef91354b62c2b4c94954536536be5425 ]
If I2C_M_RECV_LEN check failed, msgs[i].buf allocated by memdup_user will not be freed. Pump index up so it will be freed.
--- drivers/i2c/i2c-dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/i2c-dev.c +1 -0
@@ -297,6 +297,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, rdwr_pa[i].buf[0] < 1 || rdwr_pa[i].len < rdwr_pa[i].buf[0] + I2C_SMBUS_BLOCK_MAX) { + i++; res = -EINVAL ;break ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 26/45 ALSA: hda - Force polling mode on CNL for fixing codec communication
In reply to Greg Kroah-Hartman[ Upstream commit fa763f1b2858752e6150ffff46886a1b7faffc82 ]
We observed the same issue as reported by commit a8d7bde23e7130686b7662 ("ALSA: hda - Force polling mode on CFL for fixing codec communication") We don't have a better solution. So apply the same workaround to CNL.
--- sound/pci/hda/hda_intel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/pci/hda/hda_intel.c +3 -2
@@ -376,6 +376,7 @@ enum {#define IS_BXT (pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)#define IS_CFL (pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348) +#define IS_CNL (pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8)static char *driver_short_names[] = { [AZX_DRIVER_ICH ] ="HDA Intel" ,
@@ -1751,8 +1752,8 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,else chip->bdl_pos_adj = bdl_pos_adj[dev]; -/* Workaround for a communication error on CFL (bko#199007) */ -if (IS_CFL (pci)) +/* Workaround for a communication error on CFL (bko#199007) and CNL */ +if (IS_CFL (pci) ||IS_CNL (pci)) chip->polling_mode =1 ; err =azx_bus_init (chip, model[dev], &pci_hda_io_ops);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 27/45 configfs: Fix use-after-free when accessing sd->s_dentry
In reply to Greg Kroah-Hartman[ Upstream commit f6122ed2a4f9c9c1c073ddf6308d1b2ac10e0781 ]
In the vfs_statx() context, during path lookup, the dentry gets added to sd->s_dentry via configfs_attach_attr(). In the end, vfs_statx() kills the dentry by calling path_put(), which invokes configfs_d_iput(). Ideally, this dentry must be removed from sd->s_dentry but it doesn't if the sd->s_count >= 3. As a result, sd->s_dentry is holding reference to a stale dentry pointer whose memory is already freed up. This results in use-after-free issue, when this stale sd->s_dentry is accessed later in configfs_readdir() path.
This issue can be easily reproduced, by running the LTP test case - sh fs_racer_file_list.sh /config
(https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/fs/racer/fs_racer_file_list.sh)
--- fs/configfs/dir.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/configfs/dir.c +6 -8
@@ -58,15 +58,13 @@ static void configfs_d_iput(struct dentry * dentry,if (sd) {/* Coordinate with configfs_readdir */ spin_lock (&configfs_dirent_lock); -/* Coordinate with configfs_attach_attr where will increase -* sd->s_count and update sd->s_dentry to new allocated one. -* Only set sd->dentry to null when this dentry is the only -* sd owner. -* If not do so, configfs_d_iput may run just after -* configfs_attach_attr and set sd->s_dentry to null -* even it's still in use. +/* +* Set sd->s_dentry to null only when this dentry is the one +* that is going to be killed. Otherwise configfs_d_iput may +* run just after configfs_attach_attr and set sd->s_dentry to +* NULL even it's still in use. */ -if (atomic_read (&sd->s_count) <=2 ) +if (sd->s_dentry == dentry) sd->s_dentry =NULL ;spin_unlock (&configfs_dirent_lock);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 28/45 perf data: Fix strncat may truncate build failure with recent gcc
In reply to Greg Kroah-Hartman[ Upstream commit 97acec7df172cd1e450f81f5e293c0aa145a2797 ]
This strncat() is safe because the buffer was allocated with zalloc(), however gcc doesn't know that. Since the string always has 4 non-null bytes, just use memcpy() here.
CC /home/shawn/linux/tools/perf/util/data-convert-bt.o
In file included from /usr/include/string.h:494,
from /home/shawn/linux/tools/lib/traceevent/event-parse.h:27,
from util/data-convert-bt.c:22:
In function ‘strncat’,
inlined from ‘string_set_value’ at util/data-convert-bt.c:274:4:
/usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation]
136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~LPU-Reference: [email protected]
--- tools/perf/util/data-convert-bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/data-convert-bt.c +1 -1
@@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string)if (i >0 )strncpy (buffer, string, i); } -strncat (buffer + p, numstr,4 ); +memcpy (buffer + p, numstr,4 ); p +=3 ; } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 29/45 perf record: Fix s390 missing module symbol and warning for non-root users
In reply to Greg Kroah-Hartman[ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ]
Command 'perf record' and 'perf report' on a system without kernel debuginfo packages uses /proc/kallsyms and /proc/modules to find addresses for kernel and module symbols. On x86 this works for root and non-root users.
On s390, when invoked as non-root user, many of the following warnings are shown and module symbols are missing:
proc/{kallsyms,modules} inconsistency while looking for
"[sha1_s390]" module!
Command 'perf record' creates a list of module start addresses by parsing the output of /proc/modules and creates a PERF_RECORD_MMAP record for the kernel and each module. The following function call sequence is executed:
machine__create_kernel_maps
machine__create_module
modules__parse
machine__create_module --> for each line in /proc/modules
arch__fix_module_text_startFunction arch__fix_module_text_start() is s390 specific. It opens file /sys/module/<name>/sections/.text to extract the module's .text section start address. On s390 the module loader prepends a header before the first section, whereas on x86 the module's text section address is identical the the module's load address.
However module section files are root readable only. For non-root the read operation fails and machine__create_module() returns an error. Command perf record does not generate any PERF_RECORD_MMAP record for loaded modules. Later command perf report complains about missing module maps.
To fix this function arch__fix_module_text_start() always returns success. For root users there is no change, for non-root users the module's load address is used as module's text start address (the prepended header then counts as part of the text section).
This enable non-root users to use module symbols and avoid the warning when perf report is executed.
Output before:
[tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
Output after:
[tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text 0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz 0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz 0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz
--- tools/perf/arch/s390/util/machine.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/arch/s390/util/machine.c +6 -3
@@ -5,16 +5,19 @@#include "util.h" #include "machine.h" #include "api/fs/fs.h" +#include "debug.h" int arch__fix_module_text_start (u64 *start,const char *name) { +u64 m_start = *start;char path[PATH_MAX ];snprintf (path,PATH_MAX ,"module/%.*s/sections/.text" , (int )strlen (name) -2 , name +1 ); - -if (sysfs__read_ull (path, (unsigned long long *)start) <0 ) -return -1 ; +if (sysfs__read_ull (path, (unsigned long long *)start) <0 ) { +pr_debug2 ("Using module %s start:%#lx\n" , path, m_start); + *start = m_start; + }return 0 ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 30/45 ia64: fix build errors by exporting paddr_to_nid()
In reply to Greg Kroah-Hartman[ Upstream commit 9a626c4a6326da4433a0d4d4a8a7d1571caf1ed3 ]
Fix build errors on ia64 when DISCONTIGMEM=y and NUMA=y by exporting paddr_to_nid().
Fixes these build errors:
ERROR: "paddr_to_nid" [sound/core/snd-pcm.ko] undefined!
ERROR: "paddr_to_nid" [net/sunrpc/sunrpc.ko] undefined!
ERROR: "paddr_to_nid" [fs/cifs/cifs.ko] undefined!
ERROR: "paddr_to_nid" [drivers/video/fbdev/core/fb.ko] undefined!
ERROR: "paddr_to_nid" [drivers/usb/mon/usbmon.ko] undefined!
ERROR: "paddr_to_nid" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/raid1.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-mod.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-crypt.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-bufio.ko] undefined!
ERROR: "paddr_to_nid" [drivers/ide/ide-core.ko] undefined!
ERROR: "paddr_to_nid" [drivers/ide/ide-cd_mod.ko] undefined!
ERROR: "paddr_to_nid" [drivers/gpu/drm/drm.ko] undefined!
ERROR: "paddr_to_nid" [drivers/char/agp/agpgart.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/nbd.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/loop.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/brd.ko] undefined!
ERROR: "paddr_to_nid" [crypto/ccm.ko] undefined!
--- arch/ia64/mm/numa.c | 1 + 1 file changed, 1 insertion(+)
arch/ia64/mm/numa.c +1 -0
@@ -49,6 +49,7 @@ paddr_to_nid(unsigned long paddr)return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ?-1 :0 ); } +EXPORT_SYMBOL (paddr_to_nid);#if defined(CONFIG_SPARSEMEM ) && defined(CONFIG_NUMA )/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 31/45 KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list
In reply to Greg Kroah-Hartman[ Upstream commit 1659e27d2bc1ef47b6d031abe01b467f18cb72d9 ]
Currently the Book 3S KVM code uses kvm->lock to synchronize access to the kvm->arch.rtas_tokens list. Because this list is scanned inside kvmppc_rtas_hcall(), which is called with the vcpu mutex held, taking kvm->lock cause a lock inversion problem, which could lead to a deadlock.
To fix this, we add a new mutex, kvm->arch.rtas_token_lock, which nests inside the vcpu mutexes, and use that instead of kvm->lock when accessing the rtas token list.
This removes the lockdep_assert_held() in kvmppc_rtas_tokens_free(). At this point we don't hold the new mutex, but that is OK because kvmppc_rtas_tokens_free() is only called when the whole VM is being destroyed, and at that point nothing can be looking up a token in the list.
--- arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kvm/book3s.c | 1 + arch/powerpc/kvm/book3s_rtas.c | 14 ++++++-------- 3 files changed, 8 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/kvm_host.h +1 -0
@@ -296,6 +296,7 @@ struct kvm_arch {#ifdef CONFIG_PPC_BOOK3S_64 struct list_head spapr_tce_tables;struct list_head rtas_tokens; +struct mutex rtas_token_lock;DECLARE_BITMAP (enabled_hcalls,MAX_HCALL_OPCODE /4 +1 );#endif #ifdef CONFIG_KVM_MPIC
arch/powerpc/kvm/book3s.c +1 -0
@@ -836,6 +836,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)#ifdef CONFIG_PPC64 INIT_LIST_HEAD_RCU (&kvm->arch.spapr_tce_tables);INIT_LIST_HEAD (&kvm->arch.rtas_tokens); +mutex_init (&kvm->arch.rtas_token_lock);#endif return kvm->arch.kvm_ops->init_vm (kvm);
arch/powerpc/kvm/book3s_rtas.c +6 -8
@@ -146,7 +146,7 @@ static int rtas_token_undefine(struct kvm *kvm, char *name) {struct rtas_token_definition *d, *tmp; -lockdep_assert_held (&kvm->lock); +lockdep_assert_held (&kvm->arch.rtas_token_lock);list_for_each_entry_safe (d, tmp, &kvm->arch.rtas_tokens, list) {if (rtas_name_matches (d->handler->name, name)) {
@@ -167,7 +167,7 @@ static int rtas_token_define(struct kvm *kvm, char *name, u64 token)bool found;int i; -lockdep_assert_held (&kvm->lock); +lockdep_assert_held (&kvm->arch.rtas_token_lock);list_for_each_entry (d, &kvm->arch.rtas_tokens, list) {if (d->token == token)
@@ -206,14 +206,14 @@ int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp)if (copy_from_user (&args, argp,sizeof (args)))return -EFAULT ; -mutex_lock (&kvm->lock); +mutex_lock (&kvm->arch.rtas_token_lock);if (args.token) rc =rtas_token_define (kvm, args.name, args.token);else rc =rtas_token_undefine (kvm, args.name); -mutex_unlock (&kvm->lock); +mutex_unlock (&kvm->arch.rtas_token_lock);return rc; }
@@ -245,7 +245,7 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) orig_rets = args.rets; args.rets = &args.args[be32_to_cpu (args.nargs)]; -mutex_lock (&vcpu->kvm->lock); +mutex_lock (&vcpu->kvm->arch.rtas_token_lock); rc = -ENOENT ;list_for_each_entry (d, &vcpu->kvm->arch.rtas_tokens, list) {
@@ -256,7 +256,7 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) } } -mutex_unlock (&vcpu->kvm->lock); +mutex_unlock (&vcpu->kvm->arch.rtas_token_lock);if (rc ==0 ) { args.rets = orig_rets;
@@ -282,8 +282,6 @@ void kvmppc_rtas_tokens_free(struct kvm *kvm) {struct rtas_token_definition *d, *tmp; -lockdep_assert_held (&kvm->lock); -list_for_each_entry_safe (d, tmp, &kvm->arch.rtas_tokens, list) {list_del (&d->list);kfree (d);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 32/45 KVM: PPC: Book3S HV: Dont take kvm->lock around kvm_for_each_vcpu
In reply to Greg Kroah-Hartman[ Upstream commit 5a3f49364c3ffa1107bd88f8292406e98c5d206c ]
Currently the HV KVM code takes the kvm->lock around calls to kvm_for_each_vcpu() and kvm_get_vcpu_by_id() (which can call kvm_for_each_vcpu() internally). However, that leads to a lock order inversion problem, because these are called in contexts where the vcpu mutex is held, but the vcpu mutexes nest within kvm->lock according to Documentation/virtual/kvm/locking.txt. Hence there is a possibility of deadlock.
To fix this, we simply don't take the kvm->lock mutex around these calls. This is safe because the implementations of kvm_for_each_vcpu() and kvm_get_vcpu_by_id() have been designed to be able to be called locklessly.
--- arch/powerpc/kvm/book3s_hv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
arch/powerpc/kvm/book3s_hv.c +1 -8
@@ -392,12 +392,7 @@ static void kvmppc_dump_regs(struct kvm_vcpu *vcpu)static struct kvm_vcpu *kvmppc_find_vcpu (struct kvm *kvm,int id) { -struct kvm_vcpu *ret; - -mutex_lock (&kvm->lock); - ret =kvm_get_vcpu_by_id (kvm, id); -mutex_unlock (&kvm->lock); -return ret; +return kvm_get_vcpu_by_id (kvm, id); }static void init_vpa (struct kvm_vcpu *vcpu,struct lppaca *vpa)
@@ -1258,7 +1253,6 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr,struct kvmppc_vcore *vc = vcpu->arch.vcore;u64 mask; -mutex_lock (&kvm->lock);spin_lock (&vc->lock);/* * If ILE (interrupt little-endian) has changed, update the
@@ -1298,7 +1292,6 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr, mask &=0xFFFFFFFF ; vc->lpcr = (vc->lpcr & ~mask) | (new_lpcr & mask);spin_unlock (&vc->lock); -mutex_unlock (&kvm->lock); } static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 33/45 net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs
In reply to Greg Kroah-Hartman[ Upstream commit 315ca92dd863fecbffc0bb52ae0ac11e0398726a ]
The sh_eth_close() resets the MAC and then calls phy_stop() so that mdio read access result is incorrect without any error according to kernel trace like below:
ifconfig-216 [003] .n.. 109.133124: mdio_access: ee700000.ethernet-ffffffff read phy:0x01 reg:0x00 val:0xffff
According to the hardware manual, the RMII mode should be set to 1 before operation the Ethernet MAC. However, the previous code was not set to 1 after the driver issued the soft_reset in sh_eth_dev_exit() so that the mdio read access result seemed incorrect. To fix the issue, this patch adds a condition and set the RMII mode register in sh_eth_dev_exit() for R-Car Gen2 and RZ/A1 SoCs.
Note that when I have tried to move the sh_eth_dev_exit() calling after phy_stop() on sh_eth_close(), but it gets worse (kernel panic happened and it seems that a register is accessed while the clock is off).
--- drivers/net/ethernet/renesas/sh_eth.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +4 -0
@@ -1458,6 +1458,10 @@ static void sh_eth_dev_exit(struct net_device *ndev)sh_eth_get_stats (ndev);sh_eth_reset (ndev); +/* Set the RMII mode again if required */ +if (mdp->cd->rmiimode) +sh_eth_write (ndev,0x1 ,RMIIMODE ); +/* Set MAC address again */ update_mac_address (ndev); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 34/45 net: phy: dp83867: Set up RGMII TX delay
In reply to Greg Kroah-Hartman[ Upstream commit 2b892649254fec01678c64f16427622b41fa27f4 ]
PHY_INTERFACE_MODE_RGMII_RXID is less then TXID
so code to set tx delay is never called.
--- drivers/net/phy/dp83867.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/phy/dp83867.c +1 -3
@@ -249,10 +249,8 @@ static int dp83867_config_init(struct phy_device *phydev) ret =phy_write (phydev,MII_DP83867_PHYCTRL , val);if (ret)return ret; - } -if ((phydev->interface >=PHY_INTERFACE_MODE_RGMII_ID ) && - (phydev->interface <=PHY_INTERFACE_MODE_RGMII_RXID )) { +/* Set up RGMII delays */ val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_RGMIICTL );if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID )
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 35/45 scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()
In reply to Greg Kroah-Hartman[ Upstream commit cc555759117e8349088e0c5d19f2f2a500bafdbd ]
ip_dev_find() can return NULL so add a check for NULL pointer.
--- drivers/scsi/cxgbi/libcxgbi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/cxgbi/libcxgbi.c +4 -0
@@ -640,6 +640,10 @@ cxgbi_check_route(struct sockaddr *dst_addr, int ifindex)if (ndev->flags &IFF_LOOPBACK ) { ndev =ip_dev_find (&init_net, daddr->sin_addr.s_addr); +if (!ndev) { + err = -ENETUNREACH ; + goto rel_neigh; + } mtu = ndev->mtu;pr_info ("rt dev %s, loopback -> %s, mtu %u.\n" , n->dev->name, ndev->name, mtu);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 36/45 scsi: smartpqi: properly set both the DMA mask and the coherent DMA mask
In reply to Greg Kroah-Hartman[ Upstream commit 1d94f06e7f5df4064ef336b7b710f50143b64a53 ]
When SME is enabled, the smartpqi driver won't work on the HP DL385 G10 machine, which causes the failure of kernel boot because it fails to allocate pqi error buffer. Please refer to the kernel log:
....
[ 9.431749] usbcore: registered new interface driver uas
[ 9.441524] Microsemi PQI Driver (v1.1.4-130)
[ 9.442956] i40e 0000:04:00.0: fw 6.70.48768 api 1.7 nvm 10.2.5
[ 9.447237] smartpqi 0000:23:00.0: Microsemi Smart Family Controller found
Starting dracut initqueue hook...[ OK ] Started Show Plymouth Boot Scre[ 9.471654] Broadcom NetXtreme-C/E driver bnxt_en v1.9.1
en.
[ OK ] Started Forward Password Requests to Plymouth Directory Watch.
[[0;[ 9.487108] smartpqi 0000:23:00.0: failed to allocate PQI error buffer
....
[ 139.050544] dracut-initqueue[949]: Warning: dracut-initqueue timeout - starting timeout scripts [ 139.589779] dracut-initqueue[949]: Warning: dracut-initqueue timeout - starting timeout scripts
Basically, the fact that the coherent DMA mask value wasn't set caused the driver to fall back to SWIOTLB when SME is active.
For correct operation, lets call the dma_set_mask_and_coherent() to properly set the mask for both streaming and coherent, in order to inform the kernel about the devices DMA addressing capabilities.
--- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
@@ -6392,7 +6392,7 @@ static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info)else mask =DMA_BIT_MASK (32 ); - rc =dma_set_mask (&ctrl_info->pci_dev->dev, mask); + rc =dma_set_mask_and_coherent (&ctrl_info->pci_dev->dev, mask);if (rc) {dev_err (&ctrl_info->pci_dev->dev,"failed to set DMA mask\n" ); goto disable_device;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 37/45 scsi: scsi_dh_alua: Fix possible null-ptr-deref
In reply to Greg Kroah-Hartman[ Upstream commit 12e750bc62044de096ab9a95201213fd912b9994 ]
If alloc_workqueue fails in alua_init, it should return -ENOMEM, otherwise it will trigger null-ptr-deref while unloading module which calls destroy_workqueue dereferencewq->lock like this:
BUG: KASAN: null-ptr-deref in __lock_acquire+0x6b4/0x1ee0 Read of size 8 at addr 0000000000000080 by task syz-executor.0/7045 CPU: 0 PID: 7045 Comm: syz-executor.0 Tainted: G C 5.1.0+ #28 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 Call Trace: dump_stack+0xa9/0x10e __kasan_report+0x171/0x18d ? __lock_acquire+0x6b4/0x1ee0 kasan_report+0xe/0x20 __lock_acquire+0x6b4/0x1ee0 lock_acquire+0xb4/0x1b0 __mutex_lock+0xd8/0xb90 drain_workqueue+0x25/0x290 destroy_workqueue+0x1f/0x3f0 __x64_sys_delete_module+0x244/0x330 do_syscall_64+0x72/0x2a0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/scsi/device_handler/scsi_dh_alua.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +2 -4
@@ -1151,10 +1151,8 @@ static int __init alua_init(void)int r; kaluad_wq =alloc_workqueue ("kaluad" ,WQ_MEM_RECLAIM ,0 ); -if (!kaluad_wq) { -/* Temporary failure, bypass */ -return SCSI_DH_DEV_TEMP_BUSY ; - } +if (!kaluad_wq) +return -ENOMEM ; r =scsi_register_device_handler (&alua_dh);if (r !=0 ) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 38/45 scsi: libsas: delete sas port if expander discover failed
In reply to Greg Kroah-Hartman[ Upstream commit 3b0541791453fbe7f42867e310e0c9eb6295364d ]
The sas_port(phy->port) allocated in sas_ex_discover_expander() will not be deleted when the expander failed to discover. This will cause resource leak and a further issue of kernel BUG like below:
[159785.843156] port-2:17:29: trying to add phy phy-2:17:29 fails: it's already part of another port [159785.852144] ------------[ cut here ]------------ [159785.856833] kernel BUG at drivers/scsi/scsi_transport_sas.c:1086! [159785.863000] Internal error: Oops - BUG: 0 [#1] SMP [159785.867866] CPU: 39 PID: 16993 Comm: kworker/u96:2 Tainted: G W OE 4.19.25-vhulk1901.1.0.h111.aarch64 #1 [159785.878458] Hardware name: Huawei Technologies Co., Ltd. Hi1620EVBCS/Hi1620EVBCS, BIOS Hi1620 CS B070 1P TA 03/21/2019 [159785.889231] Workqueue: 0000:74:02.0_disco_q sas_discover_domain [159785.895224] pstate: 40c00009 (nZcv daif +PAN +UAO) [159785.900094] pc : sas_port_add_phy+0x188/0x1b8 [159785.904524] lr : sas_port_add_phy+0x188/0x1b8 [159785.908952] sp : ffff0001120e3b80 [159785.912341] x29: ffff0001120e3b80 x28: 0000000000000000 [159785.917727] x27: ffff802ade8f5400 x26: ffff0000681b7560 [159785.923111] x25: ffff802adf11a800 x24: ffff0000680e8000 [159785.928496] x23: ffff802ade8f5728 x22: ffff802ade8f5708 [159785.933880] x21: ffff802adea2db40 x20: ffff802ade8f5400 [159785.939264] x19: ffff802adea2d800 x18: 0000000000000010 [159785.944649] x17: 00000000821bf734 x16: ffff00006714faa0 [159785.950033] x15: ffff0000e8ab4ecf x14: 7261702079646165 [159785.955417] x13: 726c612073277469 x12: ffff00006887b830 [159785.960802] x11: ffff00006773eaa0 x10: 7968702079687020 [159785.966186] x9 : 0000000000002453 x8 : 726f702072656874 [159785.971570] x7 : 6f6e6120666f2074 x6 : ffff802bcfb21290 [159785.976955] x5 : ffff802bcfb21290 x4 : 0000000000000000 [159785.982339] x3 : ffff802bcfb298c8 x2 : 337752b234c2ab00 [159785.987723] x1 : 337752b234c2ab00 x0 : 0000000000000000 [159785.993108] Process kworker/u96:2 (pid: 16993, stack limit = 0x0000000072dae094) [159786.000576] Call trace: [159786.003097] sas_port_add_phy+0x188/0x1b8 [159786.007179] sas_ex_get_linkrate.isra.5+0x134/0x140 [159786.012130] sas_ex_discover_expander+0x128/0x408 [159786.016906] sas_ex_discover_dev+0x218/0x4c8 [159786.021249] sas_ex_discover_devices+0x9c/0x1a8 [159786.025852] sas_discover_root_expander+0x134/0x160 [159786.030802] sas_discover_domain+0x1b8/0x1e8 [159786.035148] process_one_work+0x1b4/0x3f8 [159786.039230] worker_thread+0x54/0x470 [159786.042967] kthread+0x134/0x138 [159786.046269] ret_from_fork+0x10/0x18 [159786.049918] Code: 91322300 f0004402 91178042 97fe4c9b (d4210000) [159786.056083] Modules linked in: hns3_enet_ut(OE) hclge(OE) hnae3(OE) hisi_sas_test_hw(OE) hisi_sas_test_main(OE) serdes(OE) [159786.067202] ---[ end trace 03622b9e2d99e196 ]--- [159786.071893] Kernel panic - not syncing: Fatal exception [159786.077190] SMP: stopping secondary CPUs [159786.081192] Kernel Offset: disabled [159786.084753] CPU features: 0x2,a2a00a38
--- drivers/scsi/libsas/sas_expander.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/libsas/sas_expander.c +2 -0
@@ -989,6 +989,8 @@ static struct domain_device *sas_ex_discover_expander(list_del (&child->dev_list_node);spin_unlock_irq (&parent->port->dev_list_lock);sas_put_device (child); +sas_port_delete (phy->port); + phy->port =NULL ;return NULL ; }list_add_tail (&child->siblings, &parent->ex_dev.children);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 39/45 mlxsw: spectrum: Prevent force of 56G
In reply to Greg Kroah-Hartman[ Upstream commit 275e928f19117d22f6d26dee94548baf4041b773 ]
Force of 56G is not supported by hardware in Ethernet devices. This configuration fails with a bad parameter error from firmware.
Add check of this case. Instead of trying to set 56G with autoneg off, return a meaningful error.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4 -0
@@ -2505,6 +2505,10 @@ mlxsw_sp_port_set_link_ksettings(structmlxsw_reg_ptys_eth_unpack (ptys_pl, ð_proto_cap,NULL ,NULL ); autoneg = cmd->base.autoneg ==AUTONEG_ENABLE ; +if (!autoneg && cmd->base.speed ==SPEED_56000 ) { +netdev_err (dev,"56G not supported with autoneg off\n" ); +return -EINVAL ; + } eth_proto_new = autoneg ?mlxsw_sp_to_ptys_advert_link (cmd) :mlxsw_sp_to_ptys_speed (cmd->base.speed);
Greg Kroah-Hartman
maintainerPATCH 40/45 HID: wacom: Dont set tool type until were in range
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
commit 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 upstream.
The serial number and tool type information that is reported by the tablet while a pen is merely "in prox" instead of fully "in range" can be stale and cause us to report incorrect tool information. Serial number, tool type, and other information is only valid once the pen comes fully in range so we should be careful to not use this information until that point.
In particular, this issue may cause the driver to incorectly report BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.
--- drivers/hid/wacom_wac.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/hid/wacom_wac.c +16 -1
@@ -1225,13 +1225,13 @@ static void wacom_intuos_pro2_bt_pen(str/* Add back in missing bits of ID for non-USI pens */ wacom->id[0 ] |= (wacom->serial[0 ] >>32 ) &0xFFFFF ; } - wacom->tool[0 ] =wacom_intuos_get_tool_type (wacom_intuos_id_mangle (wacom->id[0 ]));for (i =0 ; i < pen_frames; i++) {unsigned char *frame = &data[i*pen_frame_len +1 ];bool valid = frame[0 ] &0x80 ;bool prox = frame[0 ] &0x40 ;bool range = frame[0 ] &0x20 ; +bool invert = frame[0 ] &0x10 ;if (!valid)continue ;
@@ -1240,8 +1240,13 @@ static void wacom_intuos_pro2_bt_pen(str wacom->shared->stylus_in_proximity = false;wacom_exit_report (wacom);input_sync (pen_input); + + wacom->tool[0 ] =0 ; + wacom->id[0 ] =0 ; + wacom->serial[0 ] =0 ;return ; } +if (range) {/* Fix rotation alignment: userspace expects zero at left */ int16_t rotation = (int16_t )get_unaligned_le16 (&frame[9 ]);
@@ -1249,6 +1254,16 @@ static void wacom_intuos_pro2_bt_pen(strif (rotation >899 ) rotation -=1800 ; +if (!wacom->tool[0 ]) {/* first in range */ +/* Going into range select tool */ +if (invert) + wacom->tool[0 ] =BTN_TOOL_RUBBER ; +else if (wacom->id[0 ]) + wacom->tool[0 ] =wacom_intuos_get_tool_type (wacom->id[0 ]); +else + wacom->tool[0 ] =BTN_TOOL_PEN ; + } +input_report_abs (pen_input,ABS_X ,get_unaligned_le16 (&frame[1 ]));input_report_abs (pen_input,ABS_Y ,get_unaligned_le16 (&frame[3 ]));input_report_abs (pen_input,ABS_TILT_X , (char )frame[7 ]);
Greg Kroah-Hartman
maintainerPATCH 41/45 HID: wacom: Dont report anything prior to the tool entering range
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
commit e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc upstream.
If the tool spends some time in prox before entering range, a series of events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace have any clue about the pen whose data is being reported. We need to hold off on reporting anything until the pen has entered range. Since we still want to report events that occur "in prox" after the pen has *left* range we use 'wacom-tool[0]' as the indicator that the pen did at one point enter range and provide us/userspace with tool type and serial number information.
--- drivers/hid/wacom_wac.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/hid/wacom_wac.c +11 -9
@@ -1271,17 +1271,19 @@ static void wacom_intuos_pro2_bt_pen(strinput_report_abs (pen_input,ABS_Z , rotation);input_report_abs (pen_input,ABS_WHEEL ,get_unaligned_le16 (&frame[11 ])); } -input_report_abs (pen_input,ABS_PRESSURE ,get_unaligned_le16 (&frame[5 ])); -input_report_abs (pen_input,ABS_DISTANCE , range ? frame[13 ] : wacom->features.distance_max); +if (wacom->tool[0 ]) { +input_report_abs (pen_input,ABS_PRESSURE ,get_unaligned_le16 (&frame[5 ])); +input_report_abs (pen_input,ABS_DISTANCE , range ? frame[13 ] : wacom->features.distance_max); -input_report_key (pen_input,BTN_TOUCH , frame[0 ] &0x01 ); -input_report_key (pen_input,BTN_STYLUS , frame[0 ] &0x02 ); -input_report_key (pen_input,BTN_STYLUS2 , frame[0 ] &0x04 ); +input_report_key (pen_input,BTN_TOUCH , frame[0 ] &0x01 ); +input_report_key (pen_input,BTN_STYLUS , frame[0 ] &0x02 ); +input_report_key (pen_input,BTN_STYLUS2 , frame[0 ] &0x04 ); -input_report_key (pen_input, wacom->tool[0 ], prox); -input_event (pen_input,EV_MSC ,MSC_SERIAL , wacom->serial[0 ]); -input_report_abs (pen_input,ABS_MISC , -wacom_intuos_id_mangle (wacom->id[0 ]));/* report tool id */ +input_report_key (pen_input, wacom->tool[0 ], prox); +input_event (pen_input,EV_MSC ,MSC_SERIAL , wacom->serial[0 ]); +input_report_abs (pen_input,ABS_MISC , +wacom_intuos_id_mangle (wacom->id[0 ]));/* report tool id */ + } wacom->shared->stylus_in_proximity = prox;
Greg Kroah-Hartman
maintainerPATCH 42/45 HID: wacom: Send BTN_TOUCH in response to INTUOSP2_BT eraser contact
In reply to Greg Kroah-HartmanFrom: Jason Gerecke <[email protected]>
commit fe7f8d73d1af19b678171170e4e5384deb57833d upstream.
The Bluetooth reports from the 2nd-gen Intuos Pro have separate bits for indicating if the tip or eraser is in contact with the tablet. At the moment, only the tip contact bit controls the state of the BTN_TOUCH event. This prevents the eraser from working as expected. This commit changes the driver to send BTN_TOUCH whenever either the tip or eraser contact bit is set.
--- drivers/hid/wacom_wac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/wacom_wac.c +1 -1
@@ -1275,7 +1275,7 @@ static void wacom_intuos_pro2_bt_pen(strinput_report_abs (pen_input,ABS_PRESSURE ,get_unaligned_le16 (&frame[5 ]));input_report_abs (pen_input,ABS_DISTANCE , range ? frame[13 ] : wacom->features.distance_max); -input_report_key (pen_input,BTN_TOUCH , frame[0 ] &0x01 ); +input_report_key (pen_input,BTN_TOUCH , frame[0 ] &0x09 );input_report_key (pen_input,BTN_STYLUS , frame[0 ] &0x02 );input_report_key (pen_input,BTN_STYLUS2 , frame[0 ] &0x04 );
Greg Kroah-Hartman
maintainerPATCH 43/45 coredump: fix race condition between collapse_huge_page() and core dumping
In reply to Greg Kroah-HartmanFrom: Andrea Arcangeli <[email protected]>
commit 59ea6d06cfa9247b586a695c21f94afa7183af74 upstream.
When fixing the race conditions between the coredump and the mmap_sem holders outside the context of the process, we focused on mmget_not_zero()/get_task_mm() callers in 04f5866e41fb70 ("coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping"), but those aren't the only cases where the mmap_sem can be taken outside of the context of the process as Michal Hocko noticed while backporting that commit to older -stable kernels.
If mmgrab() is called in the context of the process, but then the mm_count reference is transferred outside the context of the process, that can also be a problem if the mmap_sem has to be taken for writing through that mm_count reference.
khugepaged registration calls mmgrab() in the context of the process, but the mmap_sem for writing is taken later in the context of the khugepaged kernel thread.
collapse_huge_page() after taking the mmap_sem for writing doesn't modify any vma, so it's not obvious that it could cause a problem to the coredump, but it happens to modify the pmd in a way that breaks an invariant that pmd_trans_huge_lock() relies upon. collapse_huge_page() needs the mmap_sem for writing just to block concurrent page faults that call pmd_trans_huge_lock().
Specifically the invariant that "!pmd_trans_huge()" cannot become a "pmd_trans_huge()" doesn't hold while collapse_huge_page() runs.
The coredump will call __get_user_pages() without mmap_sem for reading, which eventually can invoke a lockless page fault which will need a functional pmd_trans_huge_lock().
So collapse_huge_page() needs to use mmget_still_valid() to check it's not running concurrently with the coredump... as long as the coredump can invoke page faults without holding the mmap_sem for reading.
This has "Fixes: khugepaged" to facilitate backporting, but in my view it's more a bug in the coredump code that will eventually have to be rewritten to stop invoking page faults without the mmap_sem for reading. So the long term plan is still to drop all mmget_still_valid().
--- include/linux/sched/mm.h | 4 ++++ mm/khugepaged.c | 3 +++ 2 files changed, 7 insertions(+)
include/linux/sched/mm.h +4 -0
@@ -62,6 +62,10 @@ static inline void mmdrop_async(struct m* followed by taking the mmap_sem for writing before modifying the * vmas or anything the coredump pretends not to change from under it. * +* It also has to be called when mmgrab() is used in the context of +* the process, but then the mm_count refcount is transferred outside +* the context of the process to run down_write() on that pinned mm. +* * NOTE: find_extend_vma() called from GUP context is the only place * that can modify the "mm" (notably the vm_start/end) under mmap_sem * for reading and outside the context of the process, so it is also
mm/khugepaged.c +3 -0
@@ -1006,6 +1006,9 @@ static void collapse_huge_page(struct mm* handled by the anon_vma lock + PG_lock. */ down_write (&mm->mmap_sem); + result =SCAN_ANY_PROCESS ; +if (!mmget_still_valid (mm)) + goto out; result =hugepage_vma_revalidate (mm, address, &vma);if (result) goto out;
Greg Kroah-Hartman
maintainerPATCH 44/45 infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
In reply to Greg Kroah-HartmanFrom: Ajay Kaher <[email protected]>
This patch is the extension of following upstream commit to fix the race condition between get_task_mm() and core dumping for IB->mlx4 and IB->mlx5 drivers:
commit 04f5866e41fb ("coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping")'
Thanks to Jason for pointing this.
--- drivers/infiniband/hw/mlx4/main.c | 4 +++- drivers/infiniband/hw/mlx5/main.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/main.c +3 -1
@@ -1197,6 +1197,8 @@ static void mlx4_ib_disassociate_ucontex* mlx4_ib_vma_close(). */ down_write (&owning_mm->mmap_sem); +if (!mmget_still_valid (owning_mm)) + goto skip_mm;for (i =0 ; i <HW_BAR_COUNT ; i++) { vma = context->hw_bar_info[i].vma;if (!vma)
@@ -1215,7 +1217,7 @@ static void mlx4_ib_disassociate_ucontex/* context going to be destroyed, should not access ops any more */ context->hw_bar_info[i].vma->vm_ops =NULL ; } - +skip_mm:up_write (&owning_mm->mmap_sem);mmput (owning_mm);put_task_struct (owning_process);
drivers/infiniband/hw/mlx5/main.c +3 -0
@@ -1646,6 +1646,8 @@ static void mlx5_ib_disassociate_ucontex* mlx5_ib_vma_close. */ down_write (&owning_mm->mmap_sem); +if (!mmget_still_valid (owning_mm)) + goto skip_mm;mutex_lock (&context->vma_private_list_mutex);list_for_each_entry_safe (vma_private, n, &context->vma_private_list, list) {
@@ -1662,6 +1664,7 @@ static void mlx5_ib_disassociate_ucontexkfree (vma_private); }mutex_unlock (&context->vma_private_list_mutex); +skip_mm:up_write (&owning_mm->mmap_sem);mmput (owning_mm);put_task_struct (owning_process);
Greg Kroah-Hartman
maintainerPATCH 45/45 Abort file_remove_privs() for non-reg. files
In reply to Greg Kroah-HartmanFrom: Alexander Lochmann <[email protected]>
commit f69e749a49353d96af1a293f56b5b56de59c668a upstream.
file_remove_privs() might be called for non-regular files, e.g. blkdev inode. There is no reason to do its job on things like blkdev inodes, pipes, or cdevs. Hence, abort if file does not refer to a regular inode.
AV: more to the point, for devices there might be any number of inodes refering to given device. Which one to strip the permissions from, even if that made any sense in the first place? All of them will be observed with contents modified, after all.
Found by LockDoc (Alexander Lochmann, Horst Schirmeier and Olaf Spinczyk)
--- fs/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/inode.c +7 -2
@@ -1817,8 +1817,13 @@ int file_remove_privs(struct file *file)int kill;int error =0 ; -/* Fast path for nothing security related */ -if (IS_NOSEC (inode)) +/* +* Fast path for nothing security related. +* As well for non-regular files, e.g. blkdev inodes. +* For example, blkdev_write_iter() might get here +* trying to remove privs which it is not allowed to. +*/ +if (IS_NOSEC (inode) || !S_ISREG (inode->i_mode))return 0 ; kill =dentry_needs_remove_privs (dentry);
stable-rc/linux-4.14.y boot: 118 boots: 1 failed, 112 passed with 4 offline, 1 untried/unknown (v4.14.128-46-g593d1fadd024)
stable-rc/linux-4.14.y boot: 118 boots: 1 failed, 112 passed with 4 offline, 1 untried/unknown (v4.14.128-46-g593d1fadd024)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.14.y/kernel/v4.14.128-46-g593d1fadd024/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.14.y/kernel/v4.14.128-46-g593d1fadd024/
Tree: stable-rc
Branch: linux-4.14.y
Git Describe: v4.14.128-46-g593d1fadd024
Git Commit: 593d1fadd0247d5932dd5e626b90fe30984c2ae5
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 65 unique boards, 23 SoC families, 14 builds out of 201
Boot Regressions Detected:
arm64:
defconfig:
gcc-8:
meson-gxl-s905x-nexbox-a95x:
lab-baylibre-seattle: new failure (last pass: v4.14.128)Boot Failure Detected:
arm64:
defconfig:
gcc-8:
meson-gxl-s905x-nexbox-a95x: 1 failed labOffline Platforms:
arm:
exynos_defconfig:
gcc-8
exynos5800-peach-pi: 1 offline lab
davinci_all_defconfig:
gcc-8
da850-evm: 1 offline lab
dm365evm,legacy: 1 offline lab
arm64:
defconfig:
gcc-8
apq8016-sbc: 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.129 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat 22 Jun 2019 05:42:15 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.129-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.129-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: 7741fd984e5da7edc8b42719cac2db8d8f56b9a3
git describe: v4.14.128-46-g7741fd984e5d
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.14-oe/build/v4.14.128-46-g7741fd984e5d
No regressions (compared to build v4.14.128)
No fixes (compared to build v4.14.128)
Ran 23866 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-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-timers-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* network-basic-tests
* ltp-open-posix-tests
* kvm-unit-tests
* 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.129 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat 22 Jun 2019 05:42:15 PM UTC. Anything received after that time might be too late.
Build results:
total: 172 pass: 172 fail: 0 Qemu test results: total: 346 pass: 346 fail: 0
Guenter