4.19.211-rc1 review
Greg Kroah-Hartman
maintainerPATCH 2/28 USB: cdc-acm: fix racy tty buffer accesses
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 65a205e6113506e69a503b61d97efec43fc10fd7 upstream.
A recent change that started reporting break events to the line discipline caused the tty-buffer insertions to no longer be serialised by inserting events also from the completion handler for the interrupt endpoint.
Completion calls for distinct endpoints are not guaranteed to be serialised. For example, in case a host-controller driver uses bottom-half completion, the interrupt and bulk-in completion handlers can end up running in parallel on two CPUs (high-and low-prio tasklets, respectively) thereby breaking the tty layer's single producer assumption.
Fix this by holding the read lock also when inserting characters from the bulk endpoint.
--- drivers/usb/class/cdc-acm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/class/cdc-acm.c +5 -0
@@ -474,11 +474,16 @@ static int acm_submit_read_urbs(struct astatic void acm_process_read_urb (struct acm *acm,struct urb *urb) { +unsigned long flags; +if (!urb->actual_length)return ; +spin_lock_irqsave (&acm->read_lock, flags);tty_insert_flip_string (&acm->port, urb->transfer_buffer, urb->actual_length); +spin_unlock_irqrestore (&acm->read_lock, flags); +tty_flip_buffer_push (&acm->port); }
Greg Kroah-Hartman
maintainerPATCH 1/28 Partially revert "usb: Kconfig: using select for USB_COMMON dependency"
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
commit 4d1aa9112c8e6995ef2c8a76972c9671332ccfea upstream.
This reverts commit cb9c1cfc86926d0e86d19c8e34f6c23458cd3478 for USB_LED_TRIG. This config symbol has bool type and enables extra code in usb_common itself, not a separate driver. Enabling it should not force usb_common to be built-in!
--- drivers/usb/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/Kconfig +1 -2
@@ -175,8 +175,7 @@ source "drivers/usb/roles/Kconfig" config USB_LED_TRIG bool "USB LED Triggers" - depends on LEDS_CLASS && LEDS_TRIGGERS - select USB_COMMON + depends on LEDS_CLASS && USB_COMMON && LEDS_TRIGGERS help This option adds LED triggers for USB host and/or gadget activity.
Greg Kroah-Hartman
maintainerPATCH 3/28 USB: cdc-acm: fix break reporting
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 58fc1daa4d2e9789b9ffc880907c961ea7c062cc upstream.
A recent change that started reporting break events forgot to push the event to the line discipline, which meant that a detected break would not be reported until further characters had been receive (the port could even have been closed and reopened in between).
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -339,6 +339,9 @@ static void acm_process_notification(str acm->iocount.overrun++;spin_unlock_irqrestore (&acm->read_lock, flags); +if (newctrl &ACM_CTRL_BRK ) +tty_flip_buffer_push (&acm->port); +if (difference)wake_up_all (&acm->wioctl);
Greg Kroah-Hartman
maintainerPATCH 4/28 xen/privcmd: fix error handling in mmap-resource processing
In reply to Greg Kroah-HartmanFrom: Jan Beulich <[email protected]>
commit e11423d6721dd63b23fb41ade5e8d0b448b17780 upstream.
xen_pfn_t is the same size as int only on 32-bit builds (and not even on Arm32). Hence pfns[] can't be used directly to read individual error values returned from xen_remap_domain_mfn_array(); every other error indicator would be skipped/ignored on 64-bit.
--- drivers/xen/privcmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/xen/privcmd.c +4 -3
@@ -835,11 +835,12 @@ static long privcmd_ioctl_mmap_resource(unsigned int domid = (xdata.flags & XENMEM_rsrc_acq_caller_owned) ?DOMID_SELF : kdata.dom; -int num; +int num, *errs = (int *)pfns; +BUILD_BUG_ON (sizeof (*errs) >sizeof (*pfns)); num =xen_remap_domain_mfn_array (vma, kdata.addr &PAGE_MASK , - pfns, kdata.num, (int *)pfns, + pfns, kdata.num, errs, vma->vm_page_prot, domid, vma->vm_private_data);
@@ -849,7 +850,7 @@ static long privcmd_ioctl_mmap_resource(unsigned int i;for (i =0 ; i < num; i++) { - rc = pfns[i]; + rc = errs[i];if (rc <0 )break ; }
Greg Kroah-Hartman
maintainerPATCH 5/28 ovl: fix missing negative dentry check in ovl_rename()
In reply to Greg Kroah-HartmanFrom: Zheng Liang <[email protected]>
commit a295aef603e109a47af355477326bd41151765b6 upstream.
The following reproducer
mkdir lower upper work merge
touch lower/old
touch lower/new
mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge rm merge/new
mv merge/old merge/new & unlink upper/new
may result in this race:
PROCESS A:
rename("merge/old", "merge/new"); overwrite=true,ovl_lower_positive(old)=true, ovl_dentry_is_whiteout(new)=true -> flags |= RENAME_EXCHANGE
PROCESS B:
unlink("upper/new");
PROCESS A:
lookup newdentry in new_upperdir
call vfs_rename() with negative newdentry and RENAME_EXCHANGE
Fix by adding the missing check for negative newdentry.
--- fs/overlayfs/dir.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/overlayfs/dir.c +7 -3
@@ -1166,9 +1166,13 @@ static int ovl_rename(struct inode *oldd goto out_dput; } }else { -if (!d_is_negative (newdentry) && - (!new_opaque || !ovl_is_whiteout (newdentry))) - goto out_dput; +if (!d_is_negative (newdentry)) { +if (!new_opaque || !ovl_is_whiteout (newdentry)) + goto out_dput; + }else { +if (flags &RENAME_EXCHANGE ) + goto out_dput; + } }if (olddentry == trap)
Greg Kroah-Hartman
maintainerPATCH 6/28 nfsd4: Handle the NFSv4 READDIR dircount hint being zero
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit f2e717d655040d632c9015f19aa4275f8b16e7f2 upstream.
RFC3530 notes that the 'dircount' field may be zero, in which case the recommendation is to ignore it, and only enforce the 'maxcount' field. In RFC5661, this recommendation to ignore a zero valued field becomes a requirement.
--- fs/nfsd/nfs4xdr.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
fs/nfsd/nfs4xdr.c +11 -8
@@ -3124,15 +3124,18 @@ nfsd4_encode_dirent(void *ccdv, const ch goto fail; cd->rd_maxcount -= entry_bytes;/* -* RFC 3530 14.2.24 describes rd_dircount as only a "hint", so -* let's always let through the first entry, at least: +* RFC 3530 14.2.24 describes rd_dircount as only a "hint", and +* notes that it could be zero. If it is zero, then the server +* should enforce only the rd_maxcount value. */ -if (!cd->rd_dircount) - goto fail; - name_and_cookie =4 +4 *XDR_QUADLEN (namlen) +8 ; -if (name_and_cookie > cd->rd_dircount && cd->cookie_offset) - goto fail; - cd->rd_dircount -=min (cd->rd_dircount, name_and_cookie); +if (cd->rd_dircount) { + name_and_cookie =4 +4 *XDR_QUADLEN (namlen) +8 ; +if (name_and_cookie > cd->rd_dircount && cd->cookie_offset) + goto fail; + cd->rd_dircount -=min (cd->rd_dircount, name_and_cookie); +if (!cd->rd_dircount) + cd->rd_maxcount =0 ; + } cd->cookie_offset = cookie_offset; skip_entry:
Greg Kroah-Hartman
maintainerPATCH 9/28 ARM: dts: qcom: apq8064: use compatible which contains chipid
In reply to Greg Kroah-HartmanFrom: David Heidelberg <[email protected]>
commit f5c03f131dae3f06d08464e6157dd461200f78d9 upstream.
Also resolves these kernel warnings for APQ8064:
adreno 4300000.adreno-3xx: Using legacy qcom,chipid binding! adreno 4300000.adreno-3xx: Use compatible qcom,adreno-320.2 instead.
Tested on Nexus 7 2013, no functional changes.
--- arch/arm/boot/dts/qcom-apq8064.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/qcom-apq8064.dtsi +1 -2
@@ -1182,7 +1182,7 @@ }; gpu: adreno-3xx@4300000 { - compatible = "qcom,adreno-3xx"; + compatible = "qcom,adreno-320.2", "qcom,adreno"; reg = <0x04300000 0x20000>; reg-names = "kgsl_3d0_reg_memory"; interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
@@ -1197,7 +1197,6 @@ <&mmcc GFX3D_AHB_CLK>, <&mmcc GFX3D_AXI_CLK>, <&mmcc MMSS_IMEM_AHB_CLK>; - qcom,chipid = <0x03020002>; iommus = <&gfx3d 0 &gfx3d 1
Greg Kroah-Hartman
maintainerPATCH 8/28 ARM: dts: omap3430-sdp: Fix NAND device node
In reply to Greg Kroah-HartmanFrom: Roger Quadros <[email protected]>
commit 80d680fdccba214e8106dc1aa33de5207ad75394 upstream.
Nand is on CS1 so reg properties first field should be 1 not 0.
--- arch/arm/boot/dts/omap3430-sdp.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/omap3430-sdp.dts +1 -1
@@ -104,7 +104,7 @@ nand@1,0 { compatible = "ti,omap2-nand"; - reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ + reg = <1 0 4>; /* CS1, offset 0, IO size 4 */ interrupt-parent = <&gpmc>; interrupts = <0 IRQ_TYPE_NONE>, /* fifoevent */ <1 IRQ_TYPE_NONE>; /* termcount */
Greg Kroah-Hartman
maintainercover 4.19.211-rc1 review
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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 Wed, 13 Oct 2021 13:46:31 +0000. 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.19.211-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.19.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.19.211-rc1
Lukas Bulwahn <[email protected]>
x86/Kconfig: Correct reference to MWINCHIP3D
Naveen N. Rao <[email protected]>
powerpc/bpf: Fix BPF_MOD when imm == 1
Jamie Iles <[email protected]>
i2c: acpi: fix resource leak in reconfiguration device addition
Sylwester Dziedziuch <[email protected]>
i40e: Fix freeing of uninitialized misc IRQ vector
Jiri Benc <[email protected]>
i40e: fix endless loop under rtnl
Eric Dumazet <[email protected]>
rtnetlink: fix if_nlmsg_stats_size() under estimation
Yang Yingliang <[email protected]>
drm/nouveau/debugfs: fix file release memory leak
Eric Dumazet <[email protected]>
netlink: annotate data races around nlk->bound
Sean Anderson <[email protected]>
net: sfp: Fix typo in state machine debug string
Eric Dumazet <[email protected]>
net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size()
Oleksij Rempel <[email protected]>
ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence
Andy Shevchenko <[email protected]>
ptp_pch: Load module automatically if ID matches
Pali Rohár <[email protected]>
powerpc/fsl/dts: Fix phy-connection-type for fm1mac3
Eric Dumazet <[email protected]>
net_sched: fix NULL deref in fifo_set_limit()
Pavel Skripkin <[email protected]>
phy: mdio: fix memory leak
Tatsuhiko Yasumatsu <[email protected]>
bpf: Fix integer overflow in prealloc_elems_and_freelist()
Johan Almbladh <[email protected]>
bpf, arm: Fix register clobbering in div/mod implementation
Max Filippov <[email protected]>
xtensa: call irqchip_init only when CONFIG_USE_OF is selected
Piotr Krysiuk <[email protected]>
bpf, mips: Validate conditional branch offsets
David Heidelberg <[email protected]>
ARM: dts: qcom: apq8064: use compatible which contains chipid
Roger Quadros <[email protected]>
ARM: dts: omap3430-sdp: Fix NAND device node
Juergen Gross <[email protected]>
xen/balloon: fix cancelled balloon action
Trond Myklebust <[email protected]>
nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero
Zheng Liang <[email protected]>
ovl: fix missing negative dentry check in ovl_rename()
Jan Beulich <[email protected]>
xen/privcmd: fix error handling in mmap-resource processing
Johan Hovold <[email protected]>
USB: cdc-acm: fix break reporting
Johan Hovold <[email protected]>
USB: cdc-acm: fix racy tty buffer accesses
Ben Hutchings <[email protected]>
Partially revert "usb: Kconfig: using select for USB_COMMON dependency"
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/omap3430-sdp.dts | 2 +- arch/arm/boot/dts/qcom-apq8064.dtsi | 3 +- arch/arm/mach-imx/pm-imx6.c | 2 + arch/arm/net/bpf_jit_32.c | 19 ++++++++++ arch/mips/net/bpf_jit.c | 57 ++++++++++++++++++++++------- arch/powerpc/boot/dts/fsl/t1023rdb.dts | 2 +- arch/powerpc/net/bpf_jit_comp64.c | 10 ++++- arch/x86/Kconfig | 2 +- arch/xtensa/kernel/irq.c | 2 +- drivers/gpu/drm/nouveau/nouveau_debugfs.c | 1 + drivers/i2c/i2c-core-acpi.c | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 5 ++- drivers/net/phy/mdio_bus.c | 7 ++++ drivers/net/phy/sfp.c | 2 +- drivers/ptp/ptp_pch.c | 1 + drivers/usb/Kconfig | 3 +- drivers/usb/class/cdc-acm.c | 8 ++++ drivers/xen/balloon.c | 21 ++++++++--- drivers/xen/privcmd.c | 7 ++-- fs/nfsd/nfs4xdr.c | 19 ++++++---- fs/overlayfs/dir.c | 10 +++-- kernel/bpf/stackmap.c | 3 +- net/bridge/br_netlink.c | 2 +- net/core/rtnetlink.c | 2 +- net/netlink/af_netlink.c | 14 +++++-- net/sched/sch_fifo.c | 3 ++ 27 files changed, 156 insertions(+), 56 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 7/28 xen/balloon: fix cancelled balloon action
From: Juergen Gross <[email protected]>
commit 319933a80fd4f07122466a77f93e5019d71be74c upstream.
In case a ballooning action is cancelled the new kernel thread handling the ballooning might end up in a busy loop.
Fix that by handling the cancelled action gracefully.
While at it introduce a short wait for the BP_WAIT case.
--- drivers/xen/balloon.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/xen/balloon.c +15 -6
@@ -508,12 +508,12 @@ static enum bp_state decrease_reservatio }/* -* Stop waiting if either state is not BP_EAGAIN and ballooning action is -* needed, or if the credit has changed while state is BP_EAGAIN. +* Stop waiting if either state is BP_DONE and ballooning action is +* needed, or if the credit has changed while state is not BP_DONE. */ static bool balloon_thread_cond (enum bp_state state,long credit) { -if (state !=BP_EAGAIN ) +if (state ==BP_DONE ) credit =0 ;return current_credit () != credit ||kthread_should_stop ();
@@ -533,10 +533,19 @@ static int balloon_thread(void *unused)set_freezable ();for (;;) { -if (state ==BP_EAGAIN ) - timeout = balloon_stats.schedule_delay *HZ ; -else +switch (state) { +case BP_DONE : +case BP_ECANCELED : timeout =3600 *HZ ; +break ; +case BP_EAGAIN : + timeout = balloon_stats.schedule_delay *HZ ; +break ; +case BP_WAIT : + timeout =HZ ; +break ; + } + credit =current_credit (); wait_event_freezable_timeout(balloon_thread_wq,
Greg Kroah-Hartman
maintainerPATCH 20/28 net: sfp: Fix typo in state machine debug string
In reply to Greg Kroah-HartmanFrom: Sean Anderson <[email protected]>
[ Upstream commit 25a9da6641f1f66006e93ddbefee13a437efa8c0 ]
The string should be "tx_disable" to match the state enum.
--- drivers/net/phy/sfp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/sfp.c +1 -1
@@ -113,7 +113,7 @@ static const char * const sm_state_strings[] = { [SFP_S_LINK_UP] = "link_up", [SFP_S_TX_FAULT] = "tx_fault", [SFP_S_REINIT] = "reinit", - [SFP_S_TX_DISABLE] = "rx_disable", + [SFP_S_TX_DISABLE] = "tx_disable", };static const char *sm_state_to_str (unsigned short sm_state)
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 11/28 xtensa: call irqchip_init only when CONFIG_USE_OF is selected
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit 6489f8d0e1d93a3603d8dad8125797559e4cf2a2 ]
During boot time kernel configured with OF=y but USE_OF=n displays the following warnings and hangs shortly after starting userspace:
------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at kernel/irq/irqdomain.c:695 irq_create_mapping_affinity+0x29/0xc0 irq_create_mapping_affinity(, 6) called with NULL domain CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.0-rc3-00001-gd67ed2510d28 #30 Call Trace: __warn+0x69/0xc4 warn_slowpath_fmt+0x6c/0x94 irq_create_mapping_affinity+0x29/0xc0 local_timer_setup+0x40/0x88 time_init+0xb1/0xe8 start_kernel+0x31d/0x3f4 _startup+0x13b/0x13b ---[ end trace 1e6630e1c5eda35b ]--- ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at arch/xtensa/kernel/time.c:141 local_timer_setup+0x58/0x88 error: can't map timer irq CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.15.0-rc3-00001-gd67ed2510d28 #30 Call Trace: __warn+0x69/0xc4 warn_slowpath_fmt+0x6c/0x94 local_timer_setup+0x58/0x88 time_init+0xb1/0xe8 start_kernel+0x31d/0x3f4 _startup+0x13b/0x13b ---[ end trace 1e6630e1c5eda35c ]---
Failed to request irq 0 (timer)
Fix that by calling irqchip_init only when CONFIG_USE_OF is selected and calling legacy interrupt controller init otherwise.
--- arch/xtensa/kernel/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/kernel/irq.c +1 -1
@@ -145,7 +145,7 @@ unsigned xtensa_get_ext_irq_no(unsigned irq)void __init init_IRQ (void ) { -#ifdef CONFIG_OF +#ifdef CONFIG_USE_OF irqchip_init ();#else #ifdef CONFIG_HAVE_SMP
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 21/28 netlink: annotate data races around nlk->bound
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 7707a4d01a648e4c655101a469c956cb11273655 ]
While existing code is correct, KCSAN is reporting a data-race in netlink_insert / netlink_sendmsg [1]
It is correct to read nlk->bound without a lock, as netlink_autobind() will acquire all needed locks.
[1]
BUG: KCSAN: data-race in netlink_insert / netlink_sendmsg
write to 0xffff8881031c8b30 of 1 bytes by task 18752 on cpu 0:
netlink_insert+0x5cc/0x7f0 net/netlink/af_netlink.c:597 netlink_autobind+0xa9/0x150 net/netlink/af_netlink.c:842 netlink_sendmsg+0x479/0x7c0 net/netlink/af_netlink.c:1892 sock_sendmsg_nosec net/socket.c:703 [inline] sock_sendmsg net/socket.c:723 [inline] ____sys_sendmsg+0x360/0x4d0 net/socket.c:2392 ___sys_sendmsg net/socket.c:2446 [inline] __sys_sendmsg+0x1ed/0x270 net/socket.c:2475 __do_sys_sendmsg net/socket.c:2484 [inline] __se_sys_sendmsg net/socket.c:2482 [inline] __x64_sys_sendmsg+0x42/0x50 net/socket.c:2482 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
read to 0xffff8881031c8b30 of 1 bytes by task 18751 on cpu 1:
netlink_sendmsg+0x270/0x7c0 net/netlink/af_netlink.c:1891 sock_sendmsg_nosec net/socket.c:703 [inline] sock_sendmsg net/socket.c:723 [inline] __sys_sendto+0x2a8/0x370 net/socket.c:2019 __do_sys_sendto net/socket.c:2031 [inline] __se_sys_sendto net/socket.c:2027 [inline] __x64_sys_sendto+0x74/0x90 net/socket.c:2027 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
value changed: 0x00 -> 0x01
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 18751 Comm: syz-executor.0 Not tainted 5.14.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
--- net/netlink/af_netlink.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/netlink/af_netlink.c +10 -4
@@ -599,7 +599,10 @@ static int netlink_insert(struct sock *sk, u32 portid)/* We need to ensure that the socket is hashed and visible. */ smp_wmb (); -nlk_sk (sk)->bound = portid; +/* Paired with lockless reads from netlink_bind(), +* netlink_connect() and netlink_sendmsg(). +*/ +WRITE_ONCE (nlk_sk (sk)->bound, portid); err:release_sock (sk);
@@ -1018,7 +1021,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,else if (nlk->ngroups <8 *sizeof (groups)) groups &= (1UL << nlk->ngroups) -1 ; - bound = nlk->bound; +/* Paired with WRITE_ONCE() in netlink_insert() */ + bound =READ_ONCE (nlk->bound);if (bound) {/* Ensure nlk->portid is up-to-date. */ smp_rmb ();
@@ -1104,8 +1108,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,/* No need for barriers here as we return to user-space without * using any of the bound attributes. +* Paired with WRITE_ONCE() in netlink_insert(). */ -if (!nlk->bound) +if (!READ_ONCE (nlk->bound)) err =netlink_autobind (sock);if (err ==0 ) {
@@ -1870,7 +1875,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) dst_group = nlk->dst_group; } -if (!nlk->bound) { +/* Paired with WRITE_ONCE() in netlink_insert() */ +if (!READ_ONCE (nlk->bound)) { err =netlink_autobind (sock);if (err) goto out;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 22/28 drm/nouveau/debugfs: fix file release memory leak
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f5a8703a9c418c6fc54eb772712dfe7641e3991c ]
When using single_open() for opening, single_release() should be called, otherwise the 'op' allocated in single_open() will be leaked.
--- drivers/gpu/drm/nouveau/nouveau_debugfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +1 -0
@@ -185,6 +185,7 @@ static const struct file_operations nouveau_pstate_fops = { .open = nouveau_debugfs_pstate_open, .read = seq_read, .write = nouveau_debugfs_pstate_set, + .release = single_release, };static struct drm_info_list nouveau_debugfs_list[] = {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 23/28 rtnetlink: fix if_nlmsg_stats_size() under estimation
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit d34367991933d28bd7331f67a759be9a8c474014 ]
rtnl_fill_statsinfo() is filling skb with one mandatory if_stats_msg structure.
nlmsg_put(skb, pid, seq, type, sizeof(struct if_stats_msg), flags);
But if_nlmsg_stats_size() never considered the needed storage.
This bug did not show up because alloc_skb(X) allocates skb with extra tailroom, because of added alignments. This could very well be changed in the future to have deterministic behavior.
--- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnetlink.c +1 -1
@@ -4512,7 +4512,7 @@ nla_put_failure:static size_t if_nlmsg_stats_size (const struct net_device *dev,u32 filter_mask) { -size_t size =0 ; +size_t size =NLMSG_ALIGN (sizeof (struct if_stats_msg ));if (stats_attr_valid (filter_mask,IFLA_STATS_LINK_64 ,0 )) size +=nla_total_size_64bit (sizeof (struct rtnl_link_stats64 ));
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 24/28 i40e: fix endless loop under rtnl
In reply to Greg Kroah-HartmanFrom: Jiri Benc <[email protected]>
[ Upstream commit 857b6c6f665cca9828396d9743faf37fd09e9ac3 ]
The loop in i40e_get_capabilities can never end. The problem is that although i40e_aq_discover_capabilities returns with an error if there's a firmware problem, the returned error is not checked. There is a check for pf->hw.aq.asq_last_status but that value is set to I40E_AQ_RC_OK on most firmware problems.
When i40e_aq_discover_capabilities encounters a firmware problem, it will encounter the same problem on its next invocation. As the result, the loop becomes endless. We hit this with I40E_ERR_ADMIN_QUEUE_TIMEOUT but looking at the code, it can happen with a range of other firmware errors.
I don't know what the correct behavior should be: whether the firmware should be retried a few times, or whether pf->hw.aq.asq_last_status should be always set to the encountered firmware error (but then it would be pointless and can be just replaced by the i40e_aq_discover_capabilities return value). However, the current behavior with an endless loop under the rtnl mutex(!) is unacceptable and Intel has not submitted a fix, although we explained the bug to them 7 months ago.
This may not be the best possible fix but it's better than hanging the whole system on a firmware bug.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -9068,7 +9068,7 @@ static int i40e_get_capabilities(struct i40e_pf *pf,if (pf->hw.aq.asq_last_status ==I40E_AQ_RC_ENOMEM ) {/* retry with a larger buffer */ buf_len = data_size; - }else if (pf->hw.aq.asq_last_status !=I40E_AQ_RC_OK ) { + }else if (pf->hw.aq.asq_last_status !=I40E_AQ_RC_OK || err) { dev_info(&pf->pdev->dev, "capability discovery failed, err %s aq_err %s\n", i40e_stat_str(&pf->hw, err),
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 25/28 i40e: Fix freeing of uninitialized misc IRQ vector
In reply to Greg Kroah-HartmanFrom: Sylwester Dziedziuch <[email protected]>
[ Upstream commit 2e5a20573a926302b233b0c2e1077f5debc7ab2e ]
When VSI set up failed in i40e_probe() as part of PF switch set up driver was trying to free misc IRQ vectors in i40e_clear_interrupt_scheme and produced a kernel Oops:
Trying to free already-free IRQ 266
WARNING: CPU: 0 PID: 5 at kernel/irq/manage.c:1731 __free_irq+0x9a/0x300 Workqueue: events work_for_cpu_fn RIP: 0010:__free_irq+0x9a/0x300 Call Trace: ? synchronize_irq+0x3a/0xa0 free_irq+0x2e/0x60 i40e_clear_interrupt_scheme+0x53/0x190 [i40e] i40e_probe.part.108+0x134b/0x1a40 [i40e] ? kmem_cache_alloc+0x158/0x1c0 ? acpi_ut_update_ref_count.part.1+0x8e/0x345 ? acpi_ut_update_object_reference+0x15e/0x1e2 ? strstr+0x21/0x70 ? irq_get_irq_data+0xa/0x20 ? mp_check_pin_attr+0x13/0xc0 ? irq_get_irq_data+0xa/0x20 ? mp_map_pin_to_irq+0xd3/0x2f0 ? acpi_register_gsi_ioapic+0x93/0x170 ? pci_conf1_read+0xa4/0x100 ? pci_bus_read_config_word+0x49/0x70 ? do_pci_enable_device+0xcc/0x100 local_pci_probe+0x41/0x90 work_for_cpu_fn+0x16/0x20 process_one_work+0x1a7/0x360 worker_thread+0x1cf/0x390 ? create_worker+0x1a0/0x1a0 kthread+0x112/0x130 ? kthread_flush_work_fn+0x10/0x10 ret_from_fork+0x1f/0x40
The problem is that at that point misc IRQ vectors were not allocated yet and we get a call trace that driver is trying to free already free IRQ vectors.
Add a check in i40e_clear_interrupt_scheme for __I40E_MISC_IRQ_REQUESTED PF state before calling i40e_free_misc_vector. This state is set only if misc IRQ vectors were properly initialized.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -1
@@ -4724,7 +4724,8 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) {int i; -i40e_free_misc_vector (pf); +if (test_bit (__I40E_MISC_IRQ_REQUESTED, pf->state)) +i40e_free_misc_vector (pf);i40e_put_lump (pf->irq_pile, pf->iwarp_base_vector,I40E_IWARP_IRQ_PILE_ID );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 26/28 i2c: acpi: fix resource leak in reconfiguration device addition
In reply to Greg Kroah-HartmanFrom: Jamie Iles <[email protected]>
[ Upstream commit 6558b646ce1c2a872fe1c2c7cb116f05a2c1950f ]
acpi_i2c_find_adapter_by_handle() calls bus_find_device() which takes a reference on the adapter which is never released which will result in a reference count leak and render the adapter unremovable. Make sure to put the adapter after creating the client in the same manner that we do for OF.
--- drivers/i2c/i2c-core-acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/i2c-core-acpi.c +1 -0
@@ -395,6 +395,7 @@ static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value,break ;i2c_acpi_register_device (adapter, adev, &info); +put_device (&adapter->dev);break ;case ACPI_RECONFIG_DEVICE_REMOVE :if (!acpi_device_enumerated (adev))
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 27/28 powerpc/bpf: Fix BPF_MOD when imm == 1
In reply to Greg Kroah-HartmanFrom: Naveen N. Rao <[email protected]>
[ Upstream commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 ]
Only ignore the operation if dividing by 1.
--- arch/powerpc/net/bpf_jit_comp64.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/net/bpf_jit_comp64.c +8 -2
@@ -385,8 +385,14 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,case BPF_ALU64 |BPF_DIV |BPF_K :/* dst /= imm */ if (imm ==0 )return -EINVAL ; -else if (imm ==1 ) - goto bpf_alu32_trunc; +if (imm ==1 ) { +if (BPF_OP (code) ==BPF_DIV ) { + goto bpf_alu32_trunc; + }else { +EMIT (PPC_RAW_LI (dst_reg,0 )); +break ; + } + }PPC_LI32 (b2p[TMP_REG_1 ], imm);switch (BPF_CLASS (code)) {
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 13/28 bpf: Fix integer overflow in prealloc_elems_and_freelist()
In reply to Greg Kroah-HartmanFrom: Tatsuhiko Yasumatsu <[email protected]>
[ Upstream commit 30e29a9a2bc6a4888335a6ede968b75cd329657a ]
In prealloc_elems_and_freelist(), the multiplication to calculate the size passed to bpf_map_area_alloc() could lead to an integer overflow. As a result, out-of-bounds write could occur in pcpu_freelist_populate() as reported by KASAN:
[...]
[ 16.968613] BUG: KASAN: slab-out-of-bounds in pcpu_freelist_populate+0xd9/0x100 [ 16.969408] Write of size 8 at addr ffff888104fc6ea0 by task crash/78 [ 16.970038] [ 16.970195] CPU: 0 PID: 78 Comm: crash Not tainted 5.15.0-rc2+ #1 [ 16.970878] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 16.972026] Call Trace: [ 16.972306] dump_stack_lvl+0x34/0x44 [ 16.972687] print_address_description.constprop.0+0x21/0x140 [ 16.973297] ? pcpu_freelist_populate+0xd9/0x100 [ 16.973777] ? pcpu_freelist_populate+0xd9/0x100 [ 16.974257] kasan_report.cold+0x7f/0x11b [ 16.974681] ? pcpu_freelist_populate+0xd9/0x100 [ 16.975190] pcpu_freelist_populate+0xd9/0x100 [ 16.975669] stack_map_alloc+0x209/0x2a0 [ 16.976106] __sys_bpf+0xd83/0x2ce0
[...]
The possibility of this overflow was originally discussed in [0], but was overlooked.
Fix the integer overflow by changing elem_size to u64 from u32.
[0] https://lore.kernel.org/bpf/[email protected]/
--- kernel/bpf/stackmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/bpf/stackmap.c +2 -1
@@ -63,7 +63,8 @@ static inline int stack_map_data_size(struct bpf_map *map)static int prealloc_elems_and_freelist (struct bpf_stack_map *smap) { -u32 elem_size =sizeof (struct stack_map_bucket ) + smap->map.value_size; +u64 elem_size =sizeof (struct stack_map_bucket ) + + (u64 )smap->map.value_size;int err; smap->elems = bpf_map_area_alloc(elem_size * smap->map.max_entries,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 12/28 bpf, arm: Fix register clobbering in div/mod implementation
In reply to Greg Kroah-HartmanFrom: Johan Almbladh <[email protected]>
[ Upstream commit 79e3445b38e0cab94264a3894c0c3d57c930b97e ]
On ARM CPUs that lack div/mod instructions, ALU32 BPF_DIV and BPF_MOD are implemented using a call to a helper function. Before, the emitted code for those function calls failed to preserve caller-saved ARM registers. Since some of those registers happen to be mapped to BPF registers, it resulted in eBPF register values being overwritten.
This patch emits code to push and pop the remaining caller-saved ARM registers r2-r3 into the stack during the div/mod function call. ARM registers r0-r1 are used as arguments and return value, and those were already saved and restored correctly.
--- arch/arm/net/bpf_jit_32.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/net/bpf_jit_32.c +19 -0
@@ -39,6 +39,10 @@* +-----+ * |RSVD | JIT scratchpad * current ARM_SP => +-----+ <= (BPF_FP - STACK_SIZE + SCRATCH_SIZE) +* | ... | caller-saved registers +* +-----+ +* | ... | arguments passed on stack +* ARM_SP during call => +-----| * | | * | ... | Function call stack * | |
@@ -66,6 +70,12 @@* * When popping registers off the stack at the end of a BPF function, we * reference them via the current ARM_FP register. +* +* Some eBPF operations are implemented via a call to a helper function. +* Such calls are "invisible" in the eBPF code, so it is up to the calling +* program to preserve any caller-saved ARM registers during the call. The +* JIT emits code to push and pop those registers onto the stack, immediately +* above the callee stack frame. */ #define CALLEE_MASK (1 << ARM_R4 | 1 << ARM_R5 | 1 << ARM_R6 | \ 1 << ARM_R7 | 1 << ARM_R8 | 1 << ARM_R9 | \
@@ -73,6 +83,8 @@#define CALLEE_PUSH_MASK (CALLEE_MASK | 1 << ARM_LR)#define CALLEE_POP_MASK (CALLEE_MASK | 1 << ARM_PC) +#define CALLER_MASK (1 << ARM_R0 | 1 << ARM_R1 | 1 << ARM_R2 | 1 << ARM_R3) +enum {/* Stack layout - these are offsets from (top of stack - 4) */ BPF_R2_HI ,
@@ -467,6 +479,7 @@ static inline int epilogue_offset(const struct jit_ctx *ctx)static inline void emit_udivmod (u8 rd,u8 rm,u8 rn,struct jit_ctx *ctx,u8 op) { +const int exclude_mask =BIT (ARM_R0 ) |BIT (ARM_R1 );const s8 *tmp = bpf2a32[TMP_REG_1 ];#if __LINUX_ARM_ARCH__ ==7
@@ -498,11 +511,17 @@ static inline void emit_udivmod(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx, u8 op)emit (ARM_MOV_R (ARM_R0 , rm), ctx); } +/* Push caller-saved registers on stack */ +emit (ARM_PUSH (CALLER_MASK & ~exclude_mask), ctx); +/* Call appropriate function */ emit_mov_i (ARM_IP , op ==BPF_DIV ? (u32 )jit_udiv32 : (u32 )jit_mod32, ctx);emit_blx_r (ARM_IP , ctx); +/* Restore caller-saved registers from stack */ +emit (ARM_POP (CALLER_MASK & ~exclude_mask), ctx); +/* Save return value */ if (rd !=ARM_R0 )emit (ARM_MOV_R (rd,ARM_R0 ), ctx);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 28/28 x86/Kconfig: Correct reference to MWINCHIP3D
In reply to Greg Kroah-HartmanFrom: Lukas Bulwahn <[email protected]>
commit 225bac2dc5d192e55f2c50123ee539b1edf8a411 upstream.
Commit in Fixes intended to exclude the Winchip series and referred to CONFIG_WINCHIP3D, but the config symbol is called CONFIG_MWINCHIP3D.
Hence, scripts/checkkconfigsymbols.py warns:
WINCHIP3D
Referencing files: arch/x86/Kconfig
Correct the reference to the intended config symbol.
--- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Kconfig +1 -1
@@ -1387,7 +1387,7 @@ config HIGHMEM4G config HIGHMEM64G bool "64GB" - depends on !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !WINCHIP3D && !MK6 + depends on !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !MWINCHIP3D && !MK6 select X86_PAE ---help--- Select this if you have a 32-bit processor and more than 4
Greg Kroah-Hartman
maintainerPATCH 14/28 phy: mdio: fix memory leak
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit ca6e11c337daf7925ff8a2aac8e84490a8691905 ]
Syzbot reported memory leak in MDIO bus interface, the problem was in wrong state logic.
MDIOBUS_ALLOCATED indicates 2 states:
1. Bus is only allocated
2. Bus allocated and __mdiobus_register() fails, but device_register() was called
In case of device_register() has been called we should call put_device() to correctly free the memory allocated for this device, but mdiobus_free() calls just kfree(dev) in case of MDIOBUS_ALLOCATED state
To avoid this behaviour we need to set bus->state to MDIOBUS_UNREGISTERED _before_ calling device_register(), because put_device() should be called even in case of device_register() failure.
--- drivers/net/phy/mdio_bus.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/phy/mdio_bus.c +7 -0
@@ -378,6 +378,13 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) bus->dev.groups =NULL ;dev_set_name (&bus->dev,"%s" , bus->id); +/* We need to set state to MDIOBUS_UNREGISTERED to correctly release +* the device in mdiobus_free() +* +* State will be updated later in this function in case of success +*/ + bus->state =MDIOBUS_UNREGISTERED ; + err =device_register (&bus->dev);if (err) {pr_err ("mii_bus %s failed to register\n" , bus->id);
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 16/28 powerpc/fsl/dts: Fix phy-connection-type for fm1mac3
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit eed183abc0d3b8adb64fd1363b7cea7986cd58d6 ]
Property phy-connection-type contains invalid value "sgmii-2500" per scheme defined in file ethernet-controller.yaml.
Correct phy-connection-type value should be "2500base-x".
--- arch/powerpc/boot/dts/fsl/t1023rdb.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/dts/fsl/t1023rdb.dts +1 -1
@@ -154,7 +154,7 @@ fm1mac3: ethernet@e4000 { phy-handle = <&sgmii_aqr_phy3>; - phy-connection-type = "sgmii-2500"; + phy-connection-type = "2500base-x"; sleep = <&rcpm 0x20000000>; };
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 17/28 ptp_pch: Load module automatically if ID matches
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 7cd8b1542a7ba0720c5a0a85ed414a122015228b ]
The driver can't be loaded automatically because it misses module alias to be provided. Add corresponding MODULE_DEVICE_TABLE() call to the driver.
--- drivers/ptp/ptp_pch.c | 1 + 1 file changed, 1 insertion(+)
drivers/ptp/ptp_pch.c +1 -0
@@ -695,6 +695,7 @@ static const struct pci_device_id pch_ieee1588_pcidev_id[] = { }, {0} }; +MODULE_DEVICE_TABLE (pci, pch_ieee1588_pcidev_id);static struct pci_driver pch_driver = { .name =KBUILD_MODNAME ,
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 18/28 ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence
In reply to Greg Kroah-HartmanFrom: Oleksij Rempel <[email protected]>
[ Upstream commit 783f3db030563f7bcdfe2d26428af98ea1699a8e ]
Any pending interrupt can prevent entering standby based power off state. To avoid it, disable the GIC CPU interface.
--- arch/arm/mach-imx/pm-imx6.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-imx/pm-imx6.c +2 -0
@@ -15,6 +15,7 @@#include <linux/io.h> #include <linux/irq.h> #include <linux/genalloc.h> +#include <linux/irqchip/arm-gic.h> #include <linux/mfd/syscon.h> #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> #include <linux/of.h>
@@ -622,6 +623,7 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdatastatic void imx6_pm_stby_poweroff (void ) { +gic_cpu_if_down (0 );imx6_set_lpm (STOP_POWER_OFF );imx6q_suspend_finish (0 );
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 19/28 net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit dbe0b88064494b7bb6a9b2aa7e085b14a3112d44 ]
bridge_fill_linkxstats() is using nla_reserve_64bit().
We must use nla_total_size_64bit() instead of nla_total_size() for corresponding data structure.
--- net/bridge/br_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_netlink.c +1 -1
@@ -1511,7 +1511,7 @@ static size_t br_get_linkxstats_size(const struct net_device *dev, int attr) }return numvls *nla_total_size (sizeof (struct bridge_vlan_xstats )) + -nla_total_size (sizeof (struct br_mcast_stats )) + +nla_total_size_64bit (sizeof (struct br_mcast_stats )) +nla_total_size (0 ); }
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 15/28 net_sched: fix NULL deref in fifo_set_limit()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 560ee196fe9e5037e5015e2cdb14b3aecb1cd7dc ]
syzbot reported another NULL deref in fifo_set_limit() [1]
I could repro the issue with :
unshare -n
tc qd add dev lo root handle 1:0 tbf limit 200000 burst 70000 rate 100Mbit tc qd replace dev lo parent 1:0 pfifo_fast
tc qd change dev lo root handle 1:0 tbf limit 300000 burst 70000 rate 100Mbit
pfifo_fast does not have a change() operation.
Make fifo_set_limit() more robust about this.
[1]
BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 1cf99067 P4D 1cf99067 PUD 7ca49067 PMD 0 Oops: 0010 [#1] PREEMPT SMP KASAN CPU: 1 PID: 14443 Comm: syz-executor959 Not tainted 5.15.0-rc3-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:0x0 Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. RSP: 0018:ffffc9000e2f7310 EFLAGS: 00010246 RAX: dffffc0000000000 RBX: ffffffff8d6ecc00 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff888024c27910 RDI: ffff888071e34000 RBP: ffff888071e34000 R08: 0000000000000001 R09: ffffffff8fcfb947 R10: 0000000000000001 R11: 0000000000000000 R12: ffff888024c27910 R13: ffff888071e34018 R14: 0000000000000000 R15: ffff88801ef74800 FS: 00007f321d897700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 00000000722c3000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: fifo_set_limit net/sched/sch_fifo.c:242 [inline] fifo_set_limit+0x198/0x210 net/sched/sch_fifo.c:227 tbf_change+0x6ec/0x16d0 net/sched/sch_tbf.c:418 qdisc_change net/sched/sch_api.c:1332 [inline] tc_modify_qdisc+0xd9a/0x1a60 net/sched/sch_api.c:1634 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5572 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2504 netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1340 netlink_sendmsg+0x86d/0xdb0 net/netlink/af_netlink.c:1929 sock_sendmsg_nosec net/socket.c:704 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:724 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- net/sched/sch_fifo.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/sch_fifo.c +3 -0
@@ -152,6 +152,9 @@ int fifo_set_limit(struct Qdisc *q, unsigned int limit)if (strncmp (q->ops->id +1 ,"fifo" ,4 ) !=0 )return 0 ; +if (!q->ops->change) +return 0 ; + nla =kmalloc (nla_attr_size (sizeof (struct tc_fifo_qopt )),GFP_KERNEL );if (nla) { nla->nla_type =RTM_NEWQDISC ;
Signature · 1 line
2.33.0
Greg Kroah-Hartman
maintainerPATCH 10/28 bpf, mips: Validate conditional branch offsets
In reply to Greg Kroah-HartmanFrom: Piotr Krysiuk <[email protected]>
commit 37cb28ec7d3a36a5bace7063a3dba633ab110f8b upstream.
The conditional branch instructions on MIPS use 18-bit signed offsets allowing for a branch range of 128 KBytes (backward and forward). However, this limit is not observed by the cBPF JIT compiler, and so the JIT compiler emits out-of-range branches when translating certain cBPF programs. A specific example of such a cBPF program is included in the "BPF_MAXINSNS: exec all MSH" test from lib/test_bpf.c that executes anomalous machine code containing incorrect branch offsets under JIT.
Furthermore, this issue can be abused to craft undesirable machine code, where the control flow is hijacked to execute arbitrary Kernel code.
The following steps can be used to reproduce the issue:
# echo 1 > /proc/sys/net/core/bpf_jit_enable # modprobe test_bpf test_name="BPF_MAXINSNS: exec all MSH"
This should produce multiple warnings from build_bimm() similar to:
------------[ cut here ]------------
WARNING: CPU: 0 PID: 209 at arch/mips/mm/uasm-mips.c:210 build_insn+0x558/0x590
Micro-assembler field overflow
Modules linked in: test_bpf(+)
CPU: 0 PID: 209 Comm: modprobe Not tainted 5.14.3 #1
Stack : 00000000 807bb824 82b33c9c 801843c0 00000000 00000004 00000000 63c9b5ee
82b33af4 80999898 80910000 80900000 82fd6030 00000001 82b33a98 82087180
00000000 00000000 80873b28 00000000 000000fc 82b3394c 00000000 2e34312e
6d6d6f43 809a180f 809a1836 6f6d203a 80900000 00000001 82b33bac 80900000
00027f80 00000000 00000000 807bb824 00000000 804ed790 001cc317 00000001
[...]
Call Trace:
[<80108f44>] show_stack+0x38/0x118
[<807a7aac>] dump_stack_lvl+0x5c/0x7c
[<807a4b3c>] __warn+0xcc/0x140
[<807a4c3c>] warn_slowpath_fmt+0x8c/0xb8
[<8011e198>] build_insn+0x558/0x590
[<8011e358>] uasm_i_bne+0x20/0x2c
[<80127b48>] build_body+0xa58/0x2a94
[<80129c98>] bpf_jit_compile+0x114/0x1e4
[<80613fc4>] bpf_prepare_filter+0x2ec/0x4e4
[<8061423c>] bpf_prog_create+0x80/0xc4
[<c0a006e4>] test_bpf_init+0x300/0xba8 [test_bpf]
[<8010051c>] do_one_initcall+0x50/0x1d4
[<801c5e54>] do_init_module+0x60/0x220
[<801c8b20>] sys_finit_module+0xc4/0xfc
[<801144d0>] syscall_common+0x34/0x58
[...]
---[ end trace a287d9742503c645 ]---Then the anomalous machine code executes:
=> 0xc0a18000: addiu sp,sp,-16 0xc0a18004: sw s3,0(sp) 0xc0a18008: sw s4,4(sp) 0xc0a1800c: sw s5,8(sp) 0xc0a18010: sw ra,12(sp) 0xc0a18014: move s5,a0 0xc0a18018: move s4,zero 0xc0a1801c: move s3,zero
# __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0) 0xc0a18020: lui t6,0x8012 0xc0a18024: ori t4,t6,0x9e14 0xc0a18028: li a1,0 0xc0a1802c: jalr t4 0xc0a18030: move a0,s5 0xc0a18034: bnez v0,0xc0a1ffb8 # incorrect branch offset 0xc0a18038: move v0,zero 0xc0a1803c: andi s4,s3,0xf 0xc0a18040: b 0xc0a18048 0xc0a18044: sll s4,s4,0x2
[...]
# __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0) 0xc0a1ffa0: lui t6,0x8012 0xc0a1ffa4: ori t4,t6,0x9e14 0xc0a1ffa8: li a1,0 0xc0a1ffac: jalr t4 0xc0a1ffb0: move a0,s5 0xc0a1ffb4: bnez v0,0xc0a1ffb8 # incorrect branch offset 0xc0a1ffb8: move v0,zero 0xc0a1ffbc: andi s4,s3,0xf 0xc0a1ffc0: b 0xc0a1ffc8 0xc0a1ffc4: sll s4,s4,0x2
# __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0) 0xc0a1ffc8: lui t6,0x8012 0xc0a1ffcc: ori t4,t6,0x9e14 0xc0a1ffd0: li a1,0 0xc0a1ffd4: jalr t4 0xc0a1ffd8: move a0,s5 0xc0a1ffdc: bnez v0,0xc0a3ffb8 # correct branch offset 0xc0a1ffe0: move v0,zero 0xc0a1ffe4: andi s4,s3,0xf 0xc0a1ffe8: b 0xc0a1fff0 0xc0a1ffec: sll s4,s4,0x2
[...]
# epilogue 0xc0a3ffb8: lw s3,0(sp) 0xc0a3ffbc: lw s4,4(sp) 0xc0a3ffc0: lw s5,8(sp) 0xc0a3ffc4: lw ra,12(sp) 0xc0a3ffc8: addiu sp,sp,16 0xc0a3ffcc: jr ra 0xc0a3ffd0: nop
To mitigate this issue, we assert the branch ranges for each emit call that could generate an out-of-range branch.
--- arch/mips/net/bpf_jit.c | 57 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 14 deletions(-)
arch/mips/net/bpf_jit.c +43 -14
@@ -662,6 +662,11 @@ static void build_epilogue(struct jit_ct ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative : func) : \ func##_positive) +static bool is_bad_offset (int b_off) +{ +return b_off >0x1ffff || b_off <-0x20000 ; +} +static int build_body (struct jit_ctx *ctx) {const struct bpf_prog *prog = ctx->skf;
@@ -728,7 +733,10 @@ load_common:/* Load return register on DS for failures */ emit_reg_move (r_ret, r_zero, ctx);/* Return with error */ -emit_b (b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_b (b_off, ctx);emit_nop (ctx);break ;case BPF_LD |BPF_W |BPF_IND :
@@ -775,8 +783,10 @@ load_ind:emit_jalr (MIPS_R_RA , r_s0, ctx);emit_reg_move (MIPS_R_A0 , r_skb, ctx);/* delay slot */ /* Check the error value */ -emit_bcond (MIPS_COND_NE , r_ret,0 , -b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_bcond (MIPS_COND_NE , r_ret,0 , b_off, ctx);emit_reg_move (r_ret, r_zero, ctx);/* We are good */ /* X <- P[1:K] & 0xf */
@@ -855,8 +865,10 @@ load_ind:/* A /= X */ ctx->flags |=SEEN_X |SEEN_A ;/* Check if r_X is zero */ -emit_bcond (MIPS_COND_EQ , r_X, r_zero, -b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_bcond (MIPS_COND_EQ , r_X, r_zero, b_off, ctx);emit_load_imm (r_ret,0 , ctx);/* delay slot */ emit_div (r_A, r_X, ctx);break ;
@@ -864,8 +876,10 @@ load_ind:/* A %= X */ ctx->flags |=SEEN_X |SEEN_A ;/* Check if r_X is zero */ -emit_bcond (MIPS_COND_EQ , r_X, r_zero, -b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_bcond (MIPS_COND_EQ , r_X, r_zero, b_off, ctx);emit_load_imm (r_ret,0 , ctx);/* delay slot */ emit_mod (r_A, r_X, ctx);break ;
@@ -926,7 +940,10 @@ load_ind:break ;case BPF_JMP |BPF_JA :/* pc += K */ -emit_b (b_imm (i + k +1 , ctx), ctx); + b_off =b_imm (i + k +1 , ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_b (b_off, ctx);emit_nop (ctx);break ;case BPF_JMP |BPF_JEQ |BPF_K :
@@ -1056,12 +1073,16 @@ jmp_cmp:break ;case BPF_RET |BPF_A : ctx->flags |=SEEN_A ; -if (i != prog->len -1 ) +if (i != prog->len -1 ) {/* * If this is not the last instruction * then jump to the epilogue */ -emit_b (b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_b (b_off, ctx); + }emit_reg_move (r_ret, r_A, ctx);/* delay slot */ break ;case BPF_RET |BPF_K :
@@ -1075,7 +1096,10 @@ jmp_cmp:* If this is not the last instruction * then jump to the epilogue */ -emit_b (b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_b (b_off, ctx);emit_nop (ctx); }break ;
@@ -1133,8 +1157,10 @@ jmp_cmp:/* Load *dev pointer */ emit_load_ptr (r_s0, r_skb, off, ctx);/* error (0) in the delay slot */ -emit_bcond (MIPS_COND_EQ , r_s0, r_zero, -b_imm (prog->len, ctx), ctx); + b_off =b_imm (prog->len, ctx); +if (is_bad_offset (b_off)) +return -E2BIG ; +emit_bcond (MIPS_COND_EQ , r_s0, r_zero, b_off, ctx);emit_reg_move (r_ret, r_zero, ctx);if (code == (BPF_ANC |SKF_AD_IFINDEX )) { BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, ifindex) != 4);
@@ -1244,7 +1270,10 @@ void bpf_jit_compile(struct bpf_prog *fp/* Generate the actual JIT code */ build_prologue (&ctx); -build_body (&ctx); +if (build_body (&ctx)) { +module_memfree (ctx.target); + goto out; + }build_epilogue (&ctx);/* Update the icache */
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-4.19.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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 Wed, 13 Oct 2021 13:46:31 +0000. Anything received after that time might be too late.
arch/powerpc/net/bpf_jit_comp64.c: In function 'bpf_jit_build_body':arch/powerpc/net/bpf_jit_comp64.c:392:46: error: implicit declaration of function 'PPC_RAW_LI'; did you mean 'PPC_RLWIMI'?
This problem affects all release candidates from v4.9.y to v5.4.y.
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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 Wed, 13 Oct 2021 13:46:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.211-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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 Wed, 13 Oct 2021 13:46:31 +0000. Anything received after that time might be too late.
Build results:
total: 155 pass: 153 fail: 2
Failed builds:
powerpc:defconfig
powerpc:allmodconfig
Qemu test results:
total: 439 pass: 418 fail: 21
Failed tests:
All pseries, powernv
Failures as already reported.
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.211 release. There are 28 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 Wed, 13 Oct 2021 13:46:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.211-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Tested on arm64 and x86 for 4.19.211-rc1,
Kernel repo:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-4.19.y
Version: 4.19.211-rc1
Commit: dd0ad52a3bb0042c42f468e946d1cbda6e74dfe2
Compiler: gcc version 7.3.0 (GCC)
arm64:
--------------------------------------------------------------------
Testcase Result Summary:
total: 8859
passed: 8859
failed: 0
timeout: 0
--------------------------------------------------------------------
x86:
--------------------------------------------------------------------
Testcase Result Summary:
total: 8859
passed: 8859
failed: 0
timeout: 0
--------------------------------------------------------------------