4.14.299-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 4.14.299-rc1 review
This is the start of the stable review cycle for the 4.14.299 release. There are 40 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 Thu, 10 Nov 2022 13:33:17 +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.14.299-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.299-rc1
Dokyung Song <[email protected]>
wifi: brcmfmac: Fix potential buffer overflow in brcmf_fweh_event_worker()
Masahiro Yamada <[email protected]>
linux/bits.h: make BIT(), GENMASK(), and friends available in assembly
Masahiro Yamada <[email protected]>
linux/const.h: move UL() macro to include/linux/const.h
Masahiro Yamada <[email protected]>
linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI
Maxim Levitsky <[email protected]>
KVM: x86: emulator: update the emulation mode after CR0 write
Maxim Levitsky <[email protected]>
KVM: x86: emulator: introduce emulator_recalc_and_set_mode
Maxim Levitsky <[email protected]>
KVM: x86: emulator: em_sysexit should update ctxt->mode
Jim Mattson <[email protected]>
KVM: x86: Mask off reserved bits in CPUID.80000008H
Ye Bin <[email protected]>
ext4: fix warning in 'ext4_da_release_space'
Helge Deller <[email protected]>
parisc: Export iosapic_serial_irq() symbol for serial port driver
Helge Deller <[email protected]>
parisc: Make 8250_gsc driver dependend on CONFIG_PARISC
Ard Biesheuvel <[email protected]>
efi: random: reduce seed size to 32 bytes
John Veness <[email protected]>
ALSA: usb-audio: Add quirks for MacroSilicon MS2100/MS2106 devices
Gaosheng Cui <[email protected]>
capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
Kuniyuki Iwashima <[email protected]>
tcp/udp: Make early_demux back namespacified.
David Sterba <[email protected]>
btrfs: fix type of parameter generation in btrfs_get_dentry
Yu Kuai <[email protected]>
block, bfq: protect 'bfqd->queued' by 'bfqd->lock'
Luiz Augusto von Dentz <[email protected]>
Bluetooth: L2CAP: Fix attempting to access uninitialized memory
Martin Tůma <[email protected]>
i2c: xiic: Add platform module alias
Hans Verkuil <[email protected]>
media: dvb-frontends/drxk: initialize err to 0
Hans Verkuil <[email protected]>
media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE
Chen Zhongjin <[email protected]>
net, neigh: Fix null-ptr-deref in neigh_table_clear()
Gaosheng Cui <[email protected]>
net: mdio: fix undefined behavior in bit shift for __mdiobus_register
Zhengchao Shao <[email protected]>
Bluetooth: L2CAP: fix use-after-free in l2cap_conn_del()
Maxim Mikityanskiy <[email protected]>
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_reassemble_sdu
Filipe Manana <[email protected]>
btrfs: fix ulist leaks in error paths of qgroup self tests
Filipe Manana <[email protected]>
btrfs: fix inode list leak during backref walking at resolve_indirect_refs()
Yang Yingliang <[email protected]>
isdn: mISDN: netjet: fix wrong check of device registration
Yang Yingliang <[email protected]>
mISDN: fix possible memory leak in mISDN_register_device()
Zhang Qilong <[email protected]>
rose: Fix NULL pointer dereference in rose_send_frame()
Jason A. Donenfeld <[email protected]>
ipvs: use explicitly signed chars
Dan Carpenter <[email protected]>
net: sched: Fix use after free in red_enqueue()
Sergey Shtylyov <[email protected]>
ata: pata_legacy: fix pdc20230_set_piomode()
Zhang Changzhong <[email protected]>
net: fec: fix improper use of NETDEV_TX_BUSY
Shang XiaoJing <[email protected]>
nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()
Shang XiaoJing <[email protected]>
nfc: s3fwrn5: Fix potential memory leak in s3fwrn5_nci_send()
Chen Zhongjin <[email protected]>
net: dsa: Fix possible memory leaks in dsa_loop_init()
Zhang Xiaoxu <[email protected]>
nfs4: Fix kmemleak when allocate slot failed
Trond Myklebust <[email protected]>
NFSv4.1: We must always send RECLAIM_COMPLETE after a reboot
Trond Myklebust <[email protected]>
NFSv4.1: Handle RECLAIM_COMPLETE trunking errors
-------------
Diffstat:
Makefile | 4 +- arch/arm/include/asm/memory.h | 6 -- arch/arm64/include/asm/memory.h | 6 -- arch/unicore32/include/asm/memory.h | 6 -- arch/x86/kvm/cpuid.c | 1 + arch/x86/kvm/emulate.c | 102 +++++++++++++++------ block/bfq-iosched.c | 4 +- drivers/ata/pata_legacy.c | 5 +- drivers/firmware/efi/efi.c | 2 +- drivers/i2c/busses/i2c-xiic.c | 1 + drivers/isdn/hardware/mISDN/netjet.c | 2 +- drivers/isdn/mISDN/core.c | 5 +- drivers/media/dvb-frontends/drxk_hard.c | 2 +- drivers/media/platform/s5p-cec/s5p_cec.c | 2 + drivers/net/dsa/dsa_loop.c | 25 +++-- drivers/net/ethernet/freescale/fec_main.c | 4 +- drivers/net/phy/mdio_bus.c | 2 +- .../wireless/broadcom/brcm80211/brcmfmac/fweh.c | 4 + drivers/nfc/nfcmrvl/i2c.c | 7 +- drivers/nfc/s3fwrn5/core.c | 8 +- drivers/parisc/iosapic.c | 1 + drivers/tty/serial/8250/Kconfig | 2 +- fs/btrfs/backref.c | 36 ++++---- fs/btrfs/export.c | 2 +- fs/btrfs/export.h | 2 +- fs/btrfs/tests/qgroup-tests.c | 20 +++- fs/ext4/migrate.c | 3 +- fs/nfs/nfs4client.c | 1 + fs/nfs/nfs4state.c | 2 + include/linux/bits.h | 17 ++-- include/linux/const.h | 9 ++ include/linux/efi.h | 2 +- include/net/protocol.h | 4 - include/net/tcp.h | 2 + include/net/udp.h | 1 + include/uapi/linux/const.h | 9 +- net/bluetooth/l2cap_core.c | 52 +++++++++-- net/core/neighbour.c | 2 +- net/ipv4/af_inet.c | 14 +-- net/ipv4/ip_input.c | 32 ++++--- net/ipv4/sysctl_net_ipv4.c | 59 +----------- net/ipv6/ip6_input.c | 23 +++-- net/ipv6/tcp_ipv6.c | 9 +- net/ipv6/udp.c | 9 +- net/netfilter/ipvs/ip_vs_conn.c | 4 +- net/rose/rose_link.c | 3 + net/sched/sch_red.c | 4 +- security/commoncap.c | 6 +- sound/usb/quirks-table.h | 58 ++++++++++++ sound/usb/quirks.c | 1 + 50 files changed, 358 insertions(+), 229 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/40 NFSv4.1: Handle RECLAIM_COMPLETE trunking errors
From: Trond Myklebust <[email protected]>
[ Upstream commit 5d917cba3201e5c25059df96c29252fd99c4f6a7 ]
If RECLAIM_COMPLETE sets the NFS4CLNT_BIND_CONN_TO_SESSION flag, then we need to loop back in order to handle it.
--- fs/nfs/nfs4state.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4state.c +1 -0
@@ -2507,6 +2507,7 @@ static void nfs4_state_manager(struct nfs_client *clp)if (status <0 ) goto out_error;nfs4_state_end_reclaim_reboot (clp); +continue ; }/* Detect expired delegations... */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 2/40 NFSv4.1: We must always send RECLAIM_COMPLETE after a reboot
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit e59679f2b7e522ecad99974e5636291ffd47c184 ]
Currently, we are only guaranteed to send RECLAIM_COMPLETE if we have open state to recover. Fix the client to always send RECLAIM_COMPLETE after setting up the lease.
--- fs/nfs/nfs4state.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4state.c +1 -0
@@ -1674,6 +1674,7 @@ static void nfs4_state_mark_reclaim_helper(struct nfs_client *clp,static void nfs4_state_start_reclaim_reboot (struct nfs_client *clp) { +set_bit (NFS4CLNT_RECLAIM_REBOOT , &clp->cl_state);/* Mark all delegations for reclaim */ nfs_delegation_mark_reclaim (clp);nfs4_state_mark_reclaim_helper (clp, nfs4_state_mark_reclaim_reboot);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 3/40 nfs4: Fix kmemleak when allocate slot failed
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit 7e8436728e22181c3f12a5dbabd35ed3a8b8c593 ]
If one of the slot allocate failed, should cleanup all the other allocated slots, otherwise, the allocated slots will leak:
unreferenced object 0xffff8881115aa100 (size 64):
comm ""mount.nfs"", pid 679, jiffies 4294744957 (age 115.037s)
hex dump (first 32 bytes):
00 cc 19 73 81 88 ff ff 00 a0 5a 11 81 88 ff ff ...s......Z.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<000000007a4c434a>] nfs4_find_or_create_slot+0x8e/0x130
[<000000005472a39c>] nfs4_realloc_slot_table+0x23f/0x270
[<00000000cd8ca0eb>] nfs40_init_client+0x4a/0x90
[<00000000128486db>] nfs4_init_client+0xce/0x270
[<000000008d2cacad>] nfs4_set_client+0x1a2/0x2b0
[<000000000e593b52>] nfs4_create_server+0x300/0x5f0
[<00000000e4425dd2>] nfs4_try_get_tree+0x65/0x110
[<00000000d3a6176f>] vfs_get_tree+0x41/0xf0
[<0000000016b5ad4c>] path_mount+0x9b3/0xdd0
[<00000000494cae71>] __x64_sys_mount+0x190/0x1d0
[<000000005d56bdec>] do_syscall_64+0x35/0x80
[<00000000687c9ae4>] entry_SYSCALL_64_after_hwframe+0x46/0xb0--- fs/nfs/nfs4client.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4client.c +1 -0
@@ -326,6 +326,7 @@ int nfs40_init_client(struct nfs_client *clp) ret =nfs4_setup_slot_table (tbl,NFS4_MAX_SLOT_TABLE ,"NFSv4.0 transport Slot table" );if (ret) { +nfs4_shutdown_slot_table (tbl);kfree (tbl);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 4/40 net: dsa: Fix possible memory leaks in dsa_loop_init()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 633efc8b3dc96f56f5a57f2a49764853a2fa3f50 ]
kmemleak reported memory leaks in dsa_loop_init():
kmemleak: 12 new suspected memory leaks
unreferenced object 0xffff8880138ce000 (size 2048):
comm "modprobe", pid 390, jiffies 4295040478 (age 238.976s) backtrace:
[<000000006a94f1d5>] kmalloc_trace+0x26/0x60
[<00000000a9c44622>] phy_device_create+0x5d/0x970
[<00000000d0ee2afc>] get_phy_device+0xf3/0x2b0
[<00000000dca0c71f>] __fixed_phy_register.part.0+0x92/0x4e0
[<000000008a834798>] fixed_phy_register+0x84/0xb0
[<0000000055223fcb>] dsa_loop_init+0xa9/0x116 [dsa_loop]
...There are two reasons for memleak in dsa_loop_init().
First, fixed_phy_register() create and register phy_device:
fixed_phy_register()
get_phy_device()
phy_device_create() # freed by phy_device_free()
phy_device_register() # freed by phy_device_remove()
But fixed_phy_unregister() only calls phy_device_remove(). So the memory allocated in phy_device_create() is leaked.
Second, when mdio_driver_register() fail in dsa_loop_init(), it just returns and there is no cleanup for phydevs.
Fix the problems by catching the error of mdio_driver_register() in dsa_loop_init(), then calling both fixed_phy_unregister() and phy_device_free() to release phydevs.
Also add a function for phydevs cleanup to avoid duplacate.
--- drivers/net/dsa/dsa_loop.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/dsa/dsa_loop.c +18 -7
@@ -330,6 +330,17 @@ static struct mdio_driver dsa_loop_drv = {#define NUM_FIXED_PHYS (DSA_LOOP_NUM_PORTS - 2) +static void dsa_loop_phydevs_unregister (void ) +{ +unsigned int i; + +for (i =0 ; i <NUM_FIXED_PHYS ; i++) +if (!IS_ERR (phydevs[i])) { +fixed_phy_unregister (phydevs[i]); +phy_device_free (phydevs[i]); + } +} +static int __init dsa_loop_init (void ) {struct fixed_phy_status status = {
@@ -337,23 +348,23 @@ static int __init dsa_loop_init(void) .speed = SPEED_100, .duplex = DUPLEX_FULL, }; -unsigned int i; +unsigned int i, ret;for (i =0 ; i <NUM_FIXED_PHYS ; i++) phydevs[i] =fixed_phy_register (PHY_POLL , &status,-1 ,NULL ); -return mdio_driver_register (&dsa_loop_drv); + ret =mdio_driver_register (&dsa_loop_drv); +if (ret) +dsa_loop_phydevs_unregister (); + +return ret; }module_init (dsa_loop_init); static void __exit dsa_loop_exit(void) { -unsigned int i; -mdio_driver_unregister (&dsa_loop_drv); -for (i =0 ; i <NUM_FIXED_PHYS ; i++) -if (!IS_ERR (phydevs[i])) -fixed_phy_unregister (phydevs[i]); +dsa_loop_phydevs_unregister (); }module_exit (dsa_loop_exit);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 5/40 nfc: s3fwrn5: Fix potential memory leak in s3fwrn5_nci_send()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 3a146b7e3099dc7cf3114f627d9b79291e2d2203 ]
s3fwrn5_nci_send() will call s3fwrn5_i2c_write() or s3fwrn82_uart_write(), and free the skb if write() failed. However, even if the write() run succeeds, the skb will not be freed in write(). As the result, the skb will memleak. s3fwrn5_nci_send() should also free the skb when write() succeeds.
--- drivers/nfc/s3fwrn5/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nfc/s3fwrn5/core.c +6 -2
@@ -108,11 +108,15 @@ static int s3fwrn5_nci_send(struct nci_dev *ndev, struct sk_buff *skb) } ret =s3fwrn5_write (info, skb); -if (ret <0 ) +if (ret <0 ) {kfree_skb (skb); +mutex_unlock (&info->mutex); +return ret; + } +consume_skb (skb);mutex_unlock (&info->mutex); -return ret; +return 0 ; }static int s3fwrn5_nci_post_setup (struct nci_dev *ndev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 6/40 nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 93d904a734a74c54d945a9884b4962977f1176cd ]
nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send() will only free skb when i2c_master_send() return >=0, which means skb will memleak when i2c_master_send() failed. Free skb no matter whether i2c_master_send() succeeds.
--- drivers/nfc/nfcmrvl/i2c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nfc/nfcmrvl/i2c.c +6 -1
@@ -151,10 +151,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv, ret = -EREMOTEIO ; }else ret =0 ; + } + +if (ret) {kfree_skb (skb); +return ret; } -return ret; +consume_skb (skb); +return 0 ; } static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 7/40 net: fec: fix improper use of NETDEV_TX_BUSY
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 06a4df5863f73af193a4ff7abf7cb04058584f06 ]
The ndo_start_xmit() method must not free skb when returning NETDEV_TX_BUSY, since caller is going to requeue freed skb.
Fix it by returning NETDEV_TX_OK in case of dma_map_single() fails.
--- drivers/net/ethernet/freescale/fec_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +2 -2
@@ -582,7 +582,7 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb,dev_kfree_skb_any (skb);if (net_ratelimit ())netdev_err (ndev,"Tx DMA memory map failed\n" ); -return NETDEV_TX_BUSY ; +return NETDEV_TX_OK ; } bdp->cbd_datlen =cpu_to_fec16 (size);
@@ -644,7 +644,7 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq,dev_kfree_skb_any (skb);if (net_ratelimit ())netdev_err (ndev,"Tx DMA memory map failed\n" ); -return NETDEV_TX_BUSY ; +return NETDEV_TX_OK ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 8/40 ata: pata_legacy: fix pdc20230_set_piomode()
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit 171a93182eccd6e6835d2c86b40787f9f832efaa ]
Clang gives a warning when compiling pata_legacy.c with 'make W=1' about the 'rt' local variable in pdc20230_set_piomode() being set but unused. Quite obviously, there is an outb() call missing to write back the updated variable. Moreover, checking the docs by Petr Soucek revealed that bitwise AND should have been done with a negated timing mask and the master/slave timing masks were swapped while updating...
--- drivers/ata/pata_legacy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_legacy.c +3 -2
@@ -292,9 +292,10 @@ static void pdc20230_set_piomode(struct ata_port *ap, struct ata_device *adev)outb (inb (0x1F4 ) &0x07 ,0x1F4 ); rt =inb (0x1F3 ); - rt &=0x07 << (3 * adev->devno); + rt &= ~(0x07 << (3 * !adev->devno));if (pio) - rt |= (1 +3 * pio) << (3 * adev->devno); + rt |= (1 +3 * pio) << (3 * !adev->devno); +outb (rt,0x1F3 );udelay (100 );outb (inb (0x1F2 ) |0x01 ,0x1F2 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 9/40 net: sched: Fix use after free in red_enqueue()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 8bdc2acd420c6f3dd1f1c78750ec989f02a1e2b9 ]
We can't use "skb" again after passing it to qdisc_enqueue(). This is basically identical to commit 2f09707d0c97 ("sch_sfb: Also store skb len before calling child enqueue").
--- net/sched/sch_red.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/sch_red.c +3 -1
@@ -61,6 +61,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch, {struct red_sched_data *q =qdisc_priv (sch);struct Qdisc *child = q->qdisc; +unsigned int len;int ret; q->vars.qavg = red_calc_qavg(&q->parms,
@@ -96,9 +97,10 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,break ; } + len =qdisc_pkt_len (skb); ret =qdisc_enqueue (skb, child, to_free);if (likely (ret ==NET_XMIT_SUCCESS )) { -qdisc_qstats_backlog_inc (sch, skb); + sch->qstats.backlog += len; sch->q.qlen++; }else if (net_xmit_drop_count (ret)) { q->stats.pdrop++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 10/40 ipvs: use explicitly signed chars
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
[ Upstream commit 5c26159c97b324dc5174a5713eafb8c855cf8106 ]
The char type with no explicit sign is sometimes signed and sometimes unsigned. This code will break on platforms such as arm, where char is unsigned. So mark it here as explicitly signed, so that the todrop_counter decrement and subsequent comparison is correct.
--- net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +2 -2
@@ -1240,8 +1240,8 @@ static inline int todrop_entry(struct ip_vs_conn *cp)* The drop rate array needs tuning for real environments. * Called from timer bh only => no locking */ -static const char todrop_rate[9 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 }; -static char todrop_counter[9 ] = {0 }; +static const signed char todrop_rate[9 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 }; +static signed char todrop_counter[9 ] = {0 };int i;/* if the conn entry hasn't lasted for 60 seconds, don't drop it.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 11/40 rose: Fix NULL pointer dereference in rose_send_frame()
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit e97c089d7a49f67027395ddf70bf327eeac2611e ]
The syzkaller reported an issue:
KASAN: null-ptr-deref in range [0x0000000000000380-0x0000000000000387] CPU: 0 PID: 4069 Comm: kworker/0:15 Not tainted 6.0.0-syzkaller-02734-g0326074ff465 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 Workqueue: rcu_gp srcu_invoke_callbacks RIP: 0010:rose_send_frame+0x1dd/0x2f0 net/rose/rose_link.c:101 Call Trace: <IRQ> rose_transmit_clear_request+0x1d5/0x290 net/rose/rose_link.c:255 rose_rx_call_request+0x4c0/0x1bc0 net/rose/af_rose.c:1009 rose_loopback_timer+0x19e/0x590 net/rose/rose_loopback.c:111 call_timer_fn+0x1a0/0x6b0 kernel/time/timer.c:1474 expire_timers kernel/time/timer.c:1519 [inline] __run_timers.part.0+0x674/0xa80 kernel/time/timer.c:1790 __run_timers kernel/time/timer.c:1768 [inline] run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1803 __do_softirq+0x1d0/0x9c8 kernel/softirq.c:571 [...] </IRQ>
It triggers NULL pointer dereference when 'neigh->dev->dev_addr' is called in the rose_send_frame(). It's the first occurrence of the neigh is in rose_loopback_timer() as `rose_loopback_neigh', and the 'dev' in 'rose_loopback_neigh' is initialized sa nullptr.
It had been fixed by commit 3b3fd068c56e3fbea30090859216a368398e39bf ("rose: Fix Null pointer dereference in rose_send_frame()") ever. But it's introduced by commit 3c53cd65dece47dd1f9d3a809f32e59d1d87b2b8 ("rose: check NULL rose_loopback_neigh->loopback") again.
We fix it by add NULL check in rose_transmit_clear_request(). When the 'dev' in 'neigh' is NULL, we don't reply the request and just clear it.
syzkaller don't provide repro, and I provide a syz repro like:
r0 = syz_init_net_socket$bt_sco(0x1f, 0x5, 0x2)
ioctl$sock_inet_SIOCSIFFLAGS(r0, 0x8914, &(0x7f0000000180)={'rose0\x00', 0x201})
r1 = syz_init_net_socket$rose(0xb, 0x5, 0x0)
bind$rose(r1, &(0x7f00000000c0)=@full={0xb, @dev, @null, 0x0, [@null, @null, @netrom, @netrom, @default, @null]}, 0x40)
connect$rose(r1, &(0x7f0000000240)=@short={0xb, @dev={0xbb, 0xbb, 0xbb, 0x1, 0x0}, @remote={0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x1}, 0x1, @netrom={0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0x0, 0x0}}, 0x1c)
--- net/rose/rose_link.c | 3 +++ 1 file changed, 3 insertions(+)
net/rose/rose_link.c +3 -0
@@ -239,6 +239,9 @@ void rose_transmit_clear_request(struct rose_neigh *neigh, unsigned int lci, unsunsigned char *dptr;int len; +if (!neigh->dev) +return ; + len =AX25_BPQ_HEADER_LEN +AX25_MAX_HEADER_LEN +ROSE_MIN_LEN +3 ;if ((skb =alloc_skb (len,GFP_ATOMIC )) ==NULL )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 12/40 mISDN: fix possible memory leak in mISDN_register_device()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e7d1d4d9ac0dfa40be4c2c8abd0731659869b297 ]
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, add put_device() to give up the reference, so that the name can be freed in kobject_cleanup() when the refcount is 0.
Set device class before put_device() to avoid null release() function WARN message in device_release().
--- drivers/isdn/mISDN/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/isdn/mISDN/core.c +3 -2
@@ -242,11 +242,12 @@ mISDN_register_device(struct mISDNdevice *dev,if (debug &DEBUG_CORE )printk (KERN_DEBUG "mISDN_register %s %d\n" ,dev_name (&dev->dev), dev->id); + dev->dev.class = &mISDN_class; + err =create_stack (dev);if (err) goto error1; - dev->dev.class = &mISDN_class; dev->dev.platform_data = dev; dev->dev.parent = parent;dev_set_drvdata (&dev->dev, dev);
@@ -258,8 +259,8 @@ mISDN_register_device(struct mISDNdevice *dev, error3:delete_stack (dev); -return err; error1: +put_device (&dev->dev);return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 13/40 isdn: mISDN: netjet: fix wrong check of device registration
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit bf00f5426074249058a106a6edbb89e4b25a4d79 ]
The class is set in mISDN_register_device(), but if device_add() returns error, it will lead to delete a device without added, fix this by using device_is_registered() to check if the device is registered.
--- drivers/isdn/hardware/mISDN/netjet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/isdn/hardware/mISDN/netjet.c +1 -1
@@ -970,7 +970,7 @@ nj_release(struct tiger_hw *card) }if (card->irq >0 )free_irq (card->irq, card); -if (card->isac.dch.dev.dev.class) +if (device_is_registered (&card->isac.dch.dev.dev))mISDN_unregister_device (&card->isac.dch.dev);for (i =0 ; i <2 ; i++) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 14/40 btrfs: fix inode list leak during backref walking at resolve_indirect_refs()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit 5614dc3a47e3310fbc77ea3b67eaadd1c6417bf1 ]
During backref walking, at resolve_indirect_refs(), if we get an error we jump to the 'out' label and call ulist_free() on the 'parents' ulist, which frees all the elements in the ulist - however that does not free any inode lists that may be attached to elements, through the 'aux' field of a ulist node, so we end up leaking lists if we have any attached to the unodes.
Fix this by calling free_leaf_list() instead of ulist_free() when we exit from resolve_indirect_refs(). The static function free_leaf_list() is moved up for this to be possible and it's slightly simplified by removing unnecessary code.
--- fs/btrfs/backref.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
fs/btrfs/backref.c +17 -19
@@ -597,6 +597,18 @@ unode_aux_to_inode_list(struct ulist_node *node)return (struct extent_inode_elem *)(uintptr_t )node->aux; } +static void free_leaf_list (struct ulist *ulist) +{ +struct ulist_node *node; +struct ulist_iterator uiter; + +ULIST_ITER_INIT (&uiter); +while ((node =ulist_next (ulist, &uiter))) +free_inode_elem_list (unode_aux_to_inode_list (node)); + +ulist_free (ulist); +} +/* * We maintain three seperate rbtrees: one for direct refs, one for * indirect refs which have a key, and one for indirect refs which do not
@@ -711,7 +723,11 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,cond_resched (); } out: -ulist_free (parents); +/* +* We may have inode lists attached to refs in the parents ulist, so we +* must free them before freeing the ulist and its refs. +*/ +free_leaf_list (parents);return ret; }
@@ -1361,24 +1377,6 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,return ret; } -static void free_leaf_list (struct ulist *blocks) -{ -struct ulist_node *node =NULL ; -struct extent_inode_elem *eie; -struct ulist_iterator uiter; - -ULIST_ITER_INIT (&uiter); -while ((node =ulist_next (blocks, &uiter))) { -if (!node->aux) -continue ; - eie =unode_aux_to_inode_list (node); -free_inode_elem_list (eie); - node->aux =0 ; - } - -ulist_free (blocks); -} -/* * Finds all leafs with a reference to the specified combination of bytenr and * offset. key_list_head will point to a list of corresponding keys (caller must
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 15/40 btrfs: fix ulist leaks in error paths of qgroup self tests
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit d37de92b38932d40e4a251e876cc388f9aee5f42 ]
In the test_no_shared_qgroup() and test_multiple_refs() qgroup self tests, if we fail to add the tree ref, remove the extent item or remove the extent ref, we are returning from the test function without freeing the "old_roots" ulist that was allocated by the previous calls to btrfs_find_all_roots(). Fix that by calling ulist_free() before returning.
--- fs/btrfs/tests/qgroup-tests.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
fs/btrfs/tests/qgroup-tests.c +15 -5
@@ -249,8 +249,10 @@ static int test_no_shared_qgroup(struct btrfs_root *root, ret =insert_normal_tree_ref (root, nodesize, nodesize,0 ,BTRFS_FS_TREE_OBJECTID ); -if (ret) +if (ret) { +ulist_free (old_roots);return ret; + } ret =btrfs_find_all_roots (&trans, fs_info, nodesize,0 , &new_roots);if (ret) {
@@ -283,8 +285,10 @@ static int test_no_shared_qgroup(struct btrfs_root *root, } ret =remove_extent_item (root, nodesize, nodesize); -if (ret) +if (ret) { +ulist_free (old_roots);return -EINVAL ; + } ret =btrfs_find_all_roots (&trans, fs_info, nodesize,0 , &new_roots);if (ret) {
@@ -346,8 +350,10 @@ static int test_multiple_refs(struct btrfs_root *root, ret =insert_normal_tree_ref (root, nodesize, nodesize,0 ,BTRFS_FS_TREE_OBJECTID ); -if (ret) +if (ret) { +ulist_free (old_roots);return ret; + } ret =btrfs_find_all_roots (&trans, fs_info, nodesize,0 , &new_roots);if (ret) {
@@ -379,8 +385,10 @@ static int test_multiple_refs(struct btrfs_root *root, ret =add_tree_ref (root, nodesize, nodesize,0 ,BTRFS_FIRST_FREE_OBJECTID ); -if (ret) +if (ret) { +ulist_free (old_roots);return ret; + } ret =btrfs_find_all_roots (&trans, fs_info, nodesize,0 , &new_roots);if (ret) {
@@ -418,8 +426,10 @@ static int test_multiple_refs(struct btrfs_root *root, ret =remove_extent_ref (root, nodesize, nodesize,0 ,BTRFS_FIRST_FREE_OBJECTID ); -if (ret) +if (ret) { +ulist_free (old_roots);return ret; + } ret =btrfs_find_all_roots (&trans, fs_info, nodesize,0 , &new_roots);if (ret) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 16/40 Bluetooth: L2CAP: Fix use-after-free caused by l2cap_reassemble_sdu
In reply to Greg Kroah-HartmanFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 3aff8aaca4e36dc8b17eaa011684881a80238966 ]
Fix the race condition between the following two flows that run in parallel:
1. l2cap_reassemble_sdu -> chan->ops->recv (l2cap_sock_recv_cb) -> __sock_queue_rcv_skb.
2. bt_sock_recvmsg -> skb_recv_datagram, skb_free_datagram.
An SKB can be queued by the first flow and immediately dequeued and freed by the second flow, therefore the callers of l2cap_reassemble_sdu can't use the SKB after that function returns. However, some places continue accessing struct l2cap_ctrl that resides in the SKB's CB for a short time after l2cap_reassemble_sdu returns, leading to a use-after-free condition (the stack trace is below, line numbers for kernel 5.19.8).
Fix it by keeping a local copy of struct l2cap_ctrl.
BUG: KASAN: use-after-free in l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth Read of size 1 at addr ffff88812025f2f0 by task kworker/u17:3/43169 Workqueue: hci0 hci_rx_work [bluetooth] Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4)) print_report.cold (mm/kasan/report.c:314 mm/kasan/report.c:429) ? l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth kasan_report (mm/kasan/report.c:162 mm/kasan/report.c:493) ? l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth l2cap_rx (net/bluetooth/l2cap_core.c:7236 net/bluetooth/l2cap_core.c:7271) bluetooth ret_from_fork (arch/x86/entry/entry_64.S:306) </TASK> Allocated by task 43169: kasan_save_stack (mm/kasan/common.c:39) __kasan_slab_alloc (mm/kasan/common.c:45 mm/kasan/common.c:436 mm/kasan/common.c:469) kmem_cache_alloc_node (mm/slab.h:750 mm/slub.c:3243 mm/slub.c:3293) __alloc_skb (net/core/skbuff.c:414) l2cap_recv_frag (./include/net/bluetooth/bluetooth.h:425 net/bluetooth/l2cap_core.c:8329) bluetooth l2cap_recv_acldata (net/bluetooth/l2cap_core.c:8442) bluetooth hci_rx_work (net/bluetooth/hci_core.c:3642 net/bluetooth/hci_core.c:3832) bluetooth process_one_work (kernel/workqueue.c:2289) worker_thread (./include/linux/list.h:292 kernel/workqueue.c:2437) kthread (kernel/kthread.c:376) ret_from_fork (arch/x86/entry/entry_64.S:306) Freed by task 27920: kasan_save_stack (mm/kasan/common.c:39) kasan_set_track (mm/kasan/common.c:45) kasan_set_free_info (mm/kasan/generic.c:372) ____kasan_slab_free (mm/kasan/common.c:368 mm/kasan/common.c:328) slab_free_freelist_hook (mm/slub.c:1780) kmem_cache_free (mm/slub.c:3536 mm/slub.c:3553) skb_free_datagram (./include/net/sock.h:1578 ./include/net/sock.h:1639 net/core/datagram.c:323) bt_sock_recvmsg (net/bluetooth/af_bluetooth.c:295) bluetooth l2cap_sock_recvmsg (net/bluetooth/l2cap_sock.c:1212) bluetooth sock_read_iter (net/socket.c:1087) new_sync_read (./include/linux/fs.h:2052 fs/read_write.c:401) vfs_read (fs/read_write.c:482) ksys_read (fs/read_write.c:620) do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
--- net/bluetooth/l2cap_core.c | 48 ++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-)
net/bluetooth/l2cap_core.c +41 -7
@@ -6255,6 +6255,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,struct l2cap_ctrl *control, struct sk_buff *skb, u8 event) { + struct l2cap_ctrl local_control;int err =0 ;bool skb_in_use = false;
@@ -6279,15 +6280,32 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan, chan->buffer_seq = chan->expected_tx_seq; skb_in_use = true; +/* l2cap_reassemble_sdu may free skb, hence invalidate +* control, so make a copy in advance to use it after +* l2cap_reassemble_sdu returns and to avoid the race +* condition, for example: +* +* The current thread calls: +* l2cap_reassemble_sdu +* chan->ops->recv == l2cap_sock_recv_cb +* __sock_queue_rcv_skb +* Another thread calls: +* bt_sock_recvmsg +* skb_recv_datagram +* skb_free_datagram +* Then the current thread tries to access control, but +* it was freed by skb_free_datagram. +*/ + local_control = *control; err =l2cap_reassemble_sdu (chan, skb, control);if (err)break ; -if (control->final) { +if (local_control.final) {if (!test_and_clear_bit (CONN_REJ_ACT , &chan->conn_state)) { - control->final =0 ; -l2cap_retransmit_all (chan, control); + local_control.final =0 ; +l2cap_retransmit_all (chan, &local_control);l2cap_ertm_send (chan); } }
@@ -6667,11 +6685,27 @@ static int l2cap_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,static int l2cap_stream_rx (struct l2cap_chan *chan,struct l2cap_ctrl *control,struct sk_buff *skb) { +/* l2cap_reassemble_sdu may free skb, hence invalidate control, so store +* the txseq field in advance to use it after l2cap_reassemble_sdu +* returns and to avoid the race condition, for example: +* +* The current thread calls: +* l2cap_reassemble_sdu +* chan->ops->recv == l2cap_sock_recv_cb +* __sock_queue_rcv_skb +* Another thread calls: +* bt_sock_recvmsg +* skb_recv_datagram +* skb_free_datagram +* Then the current thread tries to access control, but it was freed by +* skb_free_datagram. +*/ +u16 txseq = control->txseq; +BT_DBG ("chan %p, control %p, skb %p, state %d" , chan, control, skb, chan->rx_state); -if (l2cap_classify_txseq (chan, control->txseq) == -L2CAP_TXSEQ_EXPECTED ) { +if (l2cap_classify_txseq (chan, txseq) ==L2CAP_TXSEQ_EXPECTED ) {l2cap_pass_to_tx (chan, control); BT_DBG("buffer_seq %d->%d", chan->buffer_seq,
@@ -6694,8 +6728,8 @@ static int l2cap_stream_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control, } } - chan->last_acked_seq = control->txseq; - chan->expected_tx_seq =__next_seq (chan, control->txseq); + chan->last_acked_seq = txseq; + chan->expected_tx_seq =__next_seq (chan, txseq);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 17/40 Bluetooth: L2CAP: fix use-after-free in l2cap_conn_del()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 0d0e2d032811280b927650ff3c15fe5020e82533 ]
When l2cap_recv_frame() is invoked to receive data, and the cid is L2CAP_CID_A2MP, if the channel does not exist, it will create a channel. However, after a channel is created, the hold operation of the channel is not performed. In this case, the value of channel reference counting is 1. As a result, after hci_error_reset() is triggered, l2cap_conn_del() invokes the close hook function of A2MP to release the channel. Then
l2cap_chan_unlock(chan) will trigger UAF issue.
The process is as follows:
Receive data:l2cap_data_channel()
a2mp_channel_create() --->channel ref is 2
l2cap_chan_put() --->channel ref is 1Triger event:
hci_error_reset()
hci_dev_do_close()
...
l2cap_disconn_cfm()
l2cap_conn_del()
l2cap_chan_hold() --->channel ref is 2
l2cap_chan_del() --->channel ref is 1
a2mp_chan_close_cb() --->channel ref is 0, release channel
l2cap_chan_unlock() --->UAF of channelThe detailed Call Trace is as follows:
BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0xa6/0x5e0 Read of size 8 at addr ffff8880160664b8 by task kworker/u11:1/7593 Workqueue: hci0 hci_error_reset Call Trace: <TASK> dump_stack_lvl+0xcd/0x134 print_report.cold+0x2ba/0x719 kasan_report+0xb1/0x1e0 kasan_check_range+0x140/0x190 __mutex_unlock_slowpath+0xa6/0x5e0 l2cap_conn_del+0x404/0x7b0 l2cap_disconn_cfm+0x8c/0xc0 hci_conn_hash_flush+0x11f/0x260 hci_dev_close_sync+0x5f5/0x11f0 hci_dev_do_close+0x2d/0x70 hci_error_reset+0x9e/0x140 process_one_work+0x98a/0x1620 worker_thread+0x665/0x1080 kthread+0x2e4/0x3a0 ret_from_fork+0x1f/0x30 </TASK> Allocated by task 7593: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0xa9/0xd0 l2cap_chan_create+0x40/0x930 amp_mgr_create+0x96/0x990 a2mp_channel_create+0x7d/0x150 l2cap_recv_frame+0x51b8/0x9a70 l2cap_recv_acldata+0xaa3/0xc00 hci_rx_work+0x702/0x1220 process_one_work+0x98a/0x1620 worker_thread+0x665/0x1080 kthread+0x2e4/0x3a0 ret_from_fork+0x1f/0x30 Freed by task 7593: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 ____kasan_slab_free+0x167/0x1c0 slab_free_freelist_hook+0x89/0x1c0 kfree+0xe2/0x580 l2cap_chan_put+0x22a/0x2d0 l2cap_conn_del+0x3fc/0x7b0 l2cap_disconn_cfm+0x8c/0xc0 hci_conn_hash_flush+0x11f/0x260 hci_dev_close_sync+0x5f5/0x11f0 hci_dev_do_close+0x2d/0x70 hci_error_reset+0x9e/0x140 process_one_work+0x98a/0x1620 worker_thread+0x665/0x1080 kthread+0x2e4/0x3a0 ret_from_fork+0x1f/0x30 Last potentially related work creation: kasan_save_stack+0x1e/0x40 __kasan_record_aux_stack+0xbe/0xd0 call_rcu+0x99/0x740 netlink_release+0xe6a/0x1cf0 __sock_release+0xcd/0x280 sock_close+0x18/0x20 __fput+0x27c/0xa90 task_work_run+0xdd/0x1a0 exit_to_user_mode_prepare+0x23c/0x250 syscall_exit_to_user_mode+0x19/0x50 do_syscall_64+0x42/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x1e/0x40 __kasan_record_aux_stack+0xbe/0xd0 call_rcu+0x99/0x740 netlink_release+0xe6a/0x1cf0 __sock_release+0xcd/0x280 sock_close+0x18/0x20 __fput+0x27c/0xa90 task_work_run+0xdd/0x1a0 exit_to_user_mode_prepare+0x23c/0x250 syscall_exit_to_user_mode+0x19/0x50 do_syscall_64+0x42/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
--- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/l2cap_core.c +1 -0
@@ -6967,6 +6967,7 @@ static void l2cap_data_channel(struct l2cap_conn *conn, u16 cid,return ; } +l2cap_chan_hold (chan);l2cap_chan_lock (chan); }else {BT_DBG ("unknown cid 0x%4.4x" , cid);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 18/40 net: mdio: fix undefined behavior in bit shift for __mdiobus_register
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 40e4eb324c59e11fcb927aa46742d28aba6ecb8a ]
Shifting signed 32-bit value by 31 bits is undefined, so changing significant bit to unsigned. The UBSAN warning calltrace like below:
UBSAN: shift-out-of-bounds in drivers/net/phy/mdio_bus.c:586:27 left shift of 1 by 31 places cannot be represented in type 'int' Call Trace: <TASK> dump_stack_lvl+0x7d/0xa5 dump_stack+0x15/0x1b ubsan_epilogue+0xe/0x4e __ubsan_handle_shift_out_of_bounds+0x1e7/0x20c __mdiobus_register+0x49d/0x4e0 fixed_mdio_bus_init+0xd8/0x12d do_one_initcall+0x76/0x430 kernel_init_freeable+0x3b3/0x422 kernel_init+0x24/0x1e0 ret_from_fork+0x1f/0x30 </TASK>
--- drivers/net/phy/mdio_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio_bus.c +1 -1
@@ -378,7 +378,7 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) bus->reset (bus);for (i =0 ; i <PHY_MAX_ADDR ; i++) { -if ((bus->phy_mask & (1 << i)) ==0 ) { +if ((bus->phy_mask &BIT (i)) ==0 ) {struct phy_device *phydev; phydev =mdiobus_scan (bus, i);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 19/40 net, neigh: Fix null-ptr-deref in neigh_table_clear()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit f8017317cb0b279b8ab98b0f3901a2e0ac880dad ]
When IPv6 module gets initialized but hits an error in the middle, kenel panic with:
KASAN: null-ptr-deref in range [0x0000000000000598-0x000000000000059f] CPU: 1 PID: 361 Comm: insmod Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:__neigh_ifdown.isra.0+0x24b/0x370 RSP: 0018:ffff888012677908 EFLAGS: 00000202 ... Call Trace: <TASK> neigh_table_clear+0x94/0x2d0 ndisc_cleanup+0x27/0x40 [ipv6] inet6_init+0x21c/0x2cb [ipv6] do_one_initcall+0xd3/0x4d0 do_init_module+0x1ae/0x670 ... Kernel panic - not syncing: Fatal exception
When ipv6 initialization fails, it will try to cleanup and calls:
neigh_table_clear()
neigh_ifdown(tbl, NULL)
pneigh_queue_purge(&tbl->proxy_queue, dev_net(dev == NULL)) # dev_net(NULL) triggers null-ptr-deref.
Fix it by passing NULL to pneigh_queue_purge() in neigh_ifdown() if dev is NULL, to make kernel not panic immediately.
--- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/neighbour.c +1 -1
@@ -310,7 +310,7 @@ int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)write_lock_bh (&tbl->lock);neigh_flush_dev (tbl, dev);pneigh_ifdown_and_unlock (tbl, dev); -pneigh_queue_purge (&tbl->proxy_queue,dev_net (dev)); +pneigh_queue_purge (&tbl->proxy_queue, dev ?dev_net (dev) :NULL );if (skb_queue_empty_lockless (&tbl->proxy_queue))del_timer_sync (&tbl->proxy_timer);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 20/40 media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 93f65ce036863893c164ca410938e0968964b26c ]
I expect that the hardware will have limited this to 16, but just in case it hasn't, check for this corner case.
--- drivers/media/platform/s5p-cec/s5p_cec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/s5p-cec/s5p_cec.c +2 -0
@@ -116,6 +116,8 @@ static irqreturn_t s5p_cec_irq_handler(int irq, void *priv)dev_dbg (cec->dev,"Buffer overrun (worker did not process previous message)\n" ); cec->rx =STATE_BUSY ; cec->msg.len = status >>24 ; +if (cec->msg.len >CEC_MAX_MSG_SIZE ) + cec->msg.len =CEC_MAX_MSG_SIZE ; cec->msg.rx_status =CEC_RX_STATUS_OK ;s5p_cec_get_rx_buf (cec, cec->msg.len, cec->msg.msg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 21/40 media: dvb-frontends/drxk: initialize err to 0
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 20694e96ca089ce6693c2348f8f628ee621e4e74 ]
Fix a compiler warning:
drivers/media/dvb-frontends/drxk_hard.c: In function 'drxk_read_ucblocks':drivers/media/dvb-frontends/drxk_hard.c:6673:21: warning: 'err' may be used uninitialized [-Wmaybe-uninitialized]
6673 | *ucblocks = (u32) err;
| ^~~~~~~~~drivers/media/dvb-frontends/drxk_hard.c:6663:13: note: 'err' was declared here
6663 | u16 err;
| ^~~
--- drivers/media/dvb-frontends/drxk_hard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/drxk_hard.c +1 -1
@@ -6700,7 +6700,7 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr)static int drxk_read_ucblocks (struct dvb_frontend *fe,u32 *ucblocks) {struct drxk_state *state = fe->demodulator_priv; -u16 err; +u16 err =0 ;dprintk (1 ,"\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 22/40 i2c: xiic: Add platform module alias
In reply to Greg Kroah-HartmanFrom: Martin Tůma <[email protected]>
[ Upstream commit b8caf0a0e04583fb71e21495bef84509182227ea ]
The missing "platform" alias is required for the mgb4 v4l2 driver to load the i2c controller driver when probing the HW.
--- drivers/i2c/busses/i2c-xiic.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-xiic.c +1 -0
@@ -900,6 +900,7 @@ static struct platform_driver xiic_i2c_driver = {module_platform_driver (xiic_i2c_driver); +MODULE_ALIAS ("platform:" DRIVER_NAME );MODULE_AUTHOR ("[email protected]" );MODULE_DESCRIPTION ("Xilinx I2C bus driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 23/40 Bluetooth: L2CAP: Fix attempting to access uninitialized memory
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
commit b1a2cd50c0357f243b7435a732b4e62ba3157a2e upstream.
On l2cap_parse_conf_req the variable efs is only initialized if remote_efs has been set.
CVE: CVE-2022-42895
--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -3551,7 +3551,8 @@ done:l2cap_add_conf_opt (&ptr,L2CAP_CONF_RFC ,sizeof (rfc), (unsigned long ) &rfc, endptr - ptr); -if (test_bit (FLAG_EFS_ENABLE , &chan->flags)) { +if (remote_efs && +test_bit (FLAG_EFS_ENABLE , &chan->flags)) { chan->remote_id = efs.id; chan->remote_stype = efs.stype; chan->remote_msdu =le16_to_cpu (efs.msdu);
Greg Kroah-Hartman
maintainerPATCH 24/40 block, bfq: protect bfqd->queued by bfqd->lock
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
commit 181490d5321806e537dc5386db5ea640b826bf78 upstream.
If bfq_schedule_dispatch() is called from bfq_idle_slice_timer_body(), then 'bfqd->queued' is read without holding 'bfqd->lock'. This is wrong since it can be wrote concurrently.
Fix the problem by holding 'bfqd->lock' in such case.
--- block/bfq-iosched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/bfq-iosched.c +3 -1
@@ -298,6 +298,8 @@ static struct bfq_io_cq *bfq_bic_lookup(*/ void bfq_schedule_dispatch (struct bfq_data *bfqd) { +lockdep_assert_held (&bfqd->lock); +if (bfqd->queued !=0 ) {bfq_log (bfqd,"schedule dispatch" );blk_mq_run_hw_queues (bfqd->queue, true);
@@ -4584,8 +4586,8 @@ bfq_idle_slice_timer_body(struct bfq_datbfq_bfqq_expire (bfqd, bfqq, true, reason); schedule_dispatch: -spin_unlock_irqrestore (&bfqd->lock, flags);bfq_schedule_dispatch (bfqd); +spin_unlock_irqrestore (&bfqd->lock, flags); }/*
Greg Kroah-Hartman
maintainerPATCH 25/40 btrfs: fix type of parameter generation in btrfs_get_dentry
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit 2398091f9c2c8e0040f4f9928666787a3e8108a7 upstream.
The type of parameter generation has been u32 since the beginning, however all callers pass a u64 generation, so unify the types to prevent potential loss.
--- fs/btrfs/export.c | 2 +- fs/btrfs/export.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/export.c +1 -1
@@ -57,7 +57,7 @@ static int btrfs_encode_fh(struct inode }struct dentry *btrfs_get_dentry (struct super_block *sb,u64 objectid, -u64 root_objectid,u32 generation, +u64 root_objectid,u64 generation,int check_generation) {struct btrfs_fs_info *fs_info =btrfs_sb (sb);
fs/btrfs/export.h +1 -1
@@ -18,7 +18,7 @@ struct btrfs_fid { } __attribute__ ((packed));struct dentry *btrfs_get_dentry (struct super_block *sb,u64 objectid, -u64 root_objectid,u32 generation, +u64 root_objectid,u64 generation,int check_generation);struct dentry *btrfs_get_parent (struct dentry *child);
Greg Kroah-Hartman
maintainerPATCH 26/40 tcp/udp: Make early_demux back namespacified.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
commit 11052589cf5c0bab3b4884d423d5f60c38fcf25d upstream.
Commit e21145a9871a ("ipv4: namespacify ip_early_demux sysctl knob") made it possible to enable/disable early_demux on a per-netns basis. Then, we introduced two knobs, tcp_early_demux and udp_early_demux, to switch it for TCP/UDP in commit dddb64bcb346 ("net: Add sysctl to toggle early demux for tcp and udp"). However, the .proc_handler() was wrong and actually disabled us from changing the behaviour in each netns.
We can execute early_demux if net.ipv4.ip_early_demux is on and each proto .early_demux() handler is not NULL. When we toggle (tcp|udp)_early_demux, the change itself is saved in each netns variable, but the .early_demux() handler is a global variable, so the handler is switched based on the init_net's sysctl variable. Thus, netns (tcp|udp)_early_demux knobs have nothing to do with the logic. Whether we CAN execute proto .early_demux() is always decided by init_net's sysctl knob, and whether we DO it or not is by each netns ip_early_demux knob.
This patch namespacifies (tcp|udp)_early_demux again. For now, the users of the .early_demux() handler are TCP and UDP only, and they are called directly to avoid retpoline. So, we can remove the .early_demux() handler from inet6?_protos and need not dereference them in ip6?_rcv_finish_core(). If another proto needs .early_demux(), we can restore it at that time.
--- include/net/protocol.h | 4 --- include/net/tcp.h | 2 + include/net/udp.h | 1 net/ipv4/af_inet.c | 14 +--------- net/ipv4/ip_input.c | 32 ++++++++++++++++-------- net/ipv4/sysctl_net_ipv4.c | 59 +-------------------------------------------- net/ipv6/ip6_input.c | 23 +++++++++++------ net/ipv6/tcp_ipv6.c | 9 +----- net/ipv6/udp.c | 9 +----- 9 files changed, 47 insertions(+), 106 deletions(-)
include/net/protocol.h +0 -4
@@ -39,8 +39,6 @@/* This is used to register protocols. */ struct net_protocol { -int (*early_demux)(struct sk_buff *skb); -int (*early_demux_handler)(struct sk_buff *skb);int (*handler)(struct sk_buff *skb);void (*err_handler)(struct sk_buff *skb,u32 info); unsigned int no_policy:1,
@@ -54,8 +52,6 @@ struct net_protocol { #if IS_ENABLED(CONFIG_IPV6) struct inet6_protocol { - void (*early_demux)(struct sk_buff *skb); - void (*early_demux_handler)(struct sk_buff *skb); int (*handler)(struct sk_buff *skb); void (*err_handler)(struct sk_buff *skb,
include/net/tcp.h +2 -0
@@ -890,6 +890,8 @@ static inline int tcp_v6_sdif(const stru#endif return 0; } + +void tcp_v6_early_demux (struct sk_buff *skb);#endif static inline bool inet_exact_dif_match (struct net *net,struct sk_buff *skb)
include/net/udp.h +1 -0
@@ -173,6 +173,7 @@ typedef struct sock *(*udp_lookup_t)(strstruct sk_buff **udp_gro_receive (struct sk_buff **head,struct sk_buff *skb,struct udphdr *uh,udp_lookup_t lookup);int udp_gro_complete (struct sk_buff *skb,int nhoff,udp_lookup_t lookup); +void udp_v6_early_demux (struct sk_buff *skb);static inline struct udphdr *udp_gro_udphdr (struct sk_buff *skb) {
net/ipv4/af_inet.c +2 -12
@@ -1608,12 +1608,7 @@ static const struct net_protocol igmp_pr };#endif -/* thinking of making this const? Don't. -* early_demux can change based on sysctl. -*/ -static struct net_protocol tcp_protocol = { - .early_demux = tcp_v4_early_demux, - .early_demux_handler = tcp_v4_early_demux, +static const struct net_protocol tcp_protocol = { .handler = tcp_v4_rcv, .err_handler = tcp_v4_err, .no_policy =1 ,
@@ -1621,12 +1616,7 @@ static struct net_protocol tcp_protocol .icmp_strict_tag_validation = 1, }; -/* thinking of making this const? Don't. -* early_demux can change based on sysctl. -*/ -static struct net_protocol udp_protocol = { - .early_demux = udp_v4_early_demux, - .early_demux_handler = udp_v4_early_demux, +static const struct net_protocol udp_protocol = { .handler = udp_rcv, .err_handler = udp_err, .no_policy =1 ,
net/ipv4/ip_input.c +21 -11
@@ -307,10 +307,11 @@ drop:return true; } +int udp_v4_early_demux (struct sk_buff *); +int tcp_v4_early_demux (struct sk_buff *);static int ip_rcv_finish (struct net *net,struct sock *sk,struct sk_buff *skb) {const struct iphdr *iph =ip_hdr (skb); -int (*edemux)(struct sk_buff *skb);struct net_device *dev = skb->dev;struct rtable *rt;int err;
@@ -322,20 +323,29 @@ static int ip_rcv_finish(struct net *netif (!skb)return NET_RX_SUCCESS ; -if (net->ipv4.sysctl_ip_early_demux && +if (READ_ONCE (net->ipv4.sysctl_ip_early_demux) && !skb_dst (skb) && !skb->sk && !ip_is_fragment (iph)) { -const struct net_protocol *ipprot; -int protocol = iph->protocol; +switch (iph->protocol) { +case IPPROTO_TCP : +if (READ_ONCE (net->ipv4.sysctl_tcp_early_demux)) { +tcp_v4_early_demux (skb); - ipprot =rcu_dereference (inet_protos[protocol]); -if (ipprot && (edemux =READ_ONCE (ipprot->early_demux))) { - err =edemux (skb); -if (unlikely (err)) - goto drop_error; -/* must reload iph, skb->head might have changed */ - iph =ip_hdr (skb); +/* must reload iph, skb->head might have changed */ + iph =ip_hdr (skb); + } +break ; +case IPPROTO_UDP : +if (READ_ONCE (net->ipv4.sysctl_udp_early_demux)) { + err =udp_v4_early_demux (skb); +if (unlikely (err)) + goto drop_error; + +/* must reload iph, skb->head might have changed */ + iph =ip_hdr (skb); + } +break ; } }
net/ipv4/sysctl_net_ipv4.c +2 -57
77 lines not on this page · raw message
net/ipv6/ip6_input.c +15 -8
@@ -47,10 +47,10 @@#include <net/inet_ecn.h> #include <net/dst_metadata.h> +void udp_v6_early_demux (struct sk_buff *); +void tcp_v6_early_demux (struct sk_buff *);int ip6_rcv_finish (struct net *net,struct sock *sk,struct sk_buff *skb) { -void (*edemux)(struct sk_buff *skb); -/* if ingress device is enslaved to an L3 master device pass the * skb to its handler for processing */
@@ -58,13 +58,20 @@ int ip6_rcv_finish(struct net *net, struif (!skb)return NET_RX_SUCCESS ; -if (net->ipv4.sysctl_ip_early_demux && !skb_dst (skb) && skb->sk ==NULL ) { -const struct inet6_protocol *ipprot; - - ipprot =rcu_dereference (inet6_protos[ipv6_hdr (skb)->nexthdr]); -if (ipprot && (edemux =READ_ONCE (ipprot->early_demux))) -edemux (skb); +if (READ_ONCE (net->ipv4.sysctl_ip_early_demux) && + !skb_dst (skb) && !skb->sk) { +switch (ipv6_hdr (skb)->nexthdr) { +case IPPROTO_TCP : +if (READ_ONCE (net->ipv4.sysctl_tcp_early_demux)) +tcp_v6_early_demux (skb); +break ; +case IPPROTO_UDP : +if (READ_ONCE (net->ipv4.sysctl_udp_early_demux)) +udp_v6_early_demux (skb); +break ; + } } +if (!skb_valid_dst (skb))ip6_route_input (skb);
net/ipv6/tcp_ipv6.c +2 -7
@@ -1635,7 +1635,7 @@ do_time_wait: goto discard_it; } -static void tcp_v6_early_demux (struct sk_buff *skb) +void tcp_v6_early_demux (struct sk_buff *skb) {const struct ipv6hdr *hdr;const struct tcphdr *th;
@@ -1991,12 +1991,7 @@ struct proto tcpv6_prot = { .diag_destroy = tcp_abort, }; -/* thinking of making this const? Don't. -* early_demux can change based on sysctl. -*/ -static struct inet6_protocol tcpv6_protocol = { - .early_demux = tcp_v6_early_demux, - .early_demux_handler = tcp_v6_early_demux, +static const struct inet6_protocol tcpv6_protocol = { .handler = tcp_v6_rcv, .err_handler = tcp_v6_err, .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL ,
net/ipv6/udp.c +2 -7
@@ -932,7 +932,7 @@ static struct sock *__udp6_lib_demux_looreturn NULL ; } -static void udp_v6_early_demux (struct sk_buff *skb) +void udp_v6_early_demux (struct sk_buff *skb) {struct net *net =dev_net (skb->dev);const struct udphdr *uh;
@@ -1491,12 +1491,7 @@ int compat_udpv6_getsockopt(struct sock }#endif -/* thinking of making this const? Don't. -* early_demux can change based on sysctl. -*/ -static struct inet6_protocol udpv6_protocol = { - .early_demux = udp_v6_early_demux, - .early_demux_handler = udp_v6_early_demux, +static const struct inet6_protocol udpv6_protocol = { .handler = udpv6_rcv, .err_handler = udpv6_err, .flags =INET6_PROTO_NOPOLICY |INET6_PROTO_FINAL ,
Greg Kroah-Hartman
maintainerPATCH 27/40 capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
commit 8cf0a1bc12870d148ae830a4ba88cfdf0e879cee upstream.
In cap_inode_getsecurity(), we will use vfs_getxattr_alloc() to complete the memory allocation of tmpbuf, if we have completed the memory allocation of tmpbuf, but failed to call handler->get(...), there will be a memleak in below logic:
|-- ret = (int)vfs_getxattr_alloc(mnt_userns, ...)
| /* ^^^ alloc for tmpbuf */
|-- value = krealloc(*xattr_value, error + 1, flags)
| /* ^^^ alloc memory */
|-- error = handler->get(handler, ...)
| /* error! */
|-- *xattr_value = value
| /* xattr_value is &tmpbuf (memory leak!) */So we will try to free(tmpbuf) after vfs_getxattr_alloc() fails to fix it.
--- security/commoncap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/commoncap.c +4 -2
@@ -398,8 +398,10 @@ int cap_inode_getsecurity(struct inode * &tmpbuf, size, GFP_NOFS);dput (dentry); -if (ret <0 || !tmpbuf) -return ret; +if (ret <0 || !tmpbuf) { + size = ret; + goto out_free; + } fs_ns = inode->i_sb->s_user_ns; cap = (struct vfs_cap_data *) tmpbuf;
Greg Kroah-Hartman
maintainerPATCH 28/40 ALSA: usb-audio: Add quirks for MacroSilicon MS2100/MS2106 devices
In reply to Greg Kroah-HartmanFrom: John Veness <[email protected]>
commit 6e2c9105e0b743c92a157389d40f00b81bdd09fe upstream.
Treat the claimed 96kHz 1ch in the descriptors as 48kHz 2ch, so that the audio stream doesn't sound mono. Also fix initial stream alignment, so that left and right channels are in the correct order.
--- sound/usb/quirks-table.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/quirks.c | 1 2 files changed, 59 insertions(+)
sound/usb/quirks-table.h +58 -0
@@ -3334,6 +3334,64 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge },/* +* MacroSilicon MS2100/MS2106 based AV capture cards +* +* These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch. +* They also need QUIRK_AUDIO_ALIGN_TRANSFER, which makes one wonder if +* they pretend to be 96kHz mono as a workaround for stereo being broken +* by that... +* +* They also have an issue with initial stream alignment that causes the +* channels to be swapped and out of phase, which is dealt with in quirks.c. +*/ +{ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | +USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS, + .idVendor = 0x534d, + .idProduct = 0x0021, + .bInterfaceClass = USB_CLASS_AUDIO, + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + .driver_info = (unsigned long ) &(const struct snd_usb_audio_quirk ) { + .vendor_name ="MacroSilicon" , + .product_name ="MS210x" , + .ifnum =QUIRK_ANY_INTERFACE , + .type =QUIRK_COMPOSITE , + .data = &(const struct snd_usb_audio_quirk []) { + { + .ifnum =2 , + .type =QUIRK_AUDIO_ALIGN_TRANSFER , + }, + { + .ifnum =2 , + .type =QUIRK_AUDIO_STANDARD_MIXER , + }, + { + .ifnum =3 , + .type =QUIRK_AUDIO_FIXED_ENDPOINT , + .data = &(const struct audioformat ) { + .formats =SNDRV_PCM_FMTBIT_S16_LE , + .channels =2 , + .iface =3 , + .altsetting =1 , + .altset_idx =1 , + .attributes =0 , + .endpoint =0x82 , + .ep_attr =USB_ENDPOINT_XFER_ISOC | +USB_ENDPOINT_SYNC_ASYNC , + .rates =SNDRV_PCM_RATE_CONTINUOUS , + .rate_min =48000 , + .rate_max =48000 , + } + }, + { + .ifnum =-1 + } + } + } +}, + +/* * MacroSilicon MS2109 based HDMI capture cards * * These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch.
sound/usb/quirks.c +1 -0
@@ -1128,6 +1128,7 @@ void snd_usb_set_format_quirk(struct sndcase USB_ID (0x041e ,0x3f19 ):/* E-Mu 0204 USB */ set_format_emu_quirk (subs, fmt);break ; +case USB_ID (0x534d ,0x0021 ):/* MacroSilicon MS2100/MS2106 */ case USB_ID (0x534d ,0x2109 ):/* MacroSilicon MS2109 */ subs->stream_offset_adj =2 ;break ;
Greg Kroah-Hartman
maintainerPATCH 29/40 efi: random: reduce seed size to 32 bytes
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 161a438d730dade2ba2b1bf8785f0759aba4ca5f upstream.
We no longer need at least 64 bytes of random seed to permit the early crng init to complete. The RNG is now based on Blake2s, so reduce the EFI seed size to the Blake2s hash size, which is sufficient for our purposes.
While at it, drop the READ_ONCE(), which was supposed to prevent size from being evaluated after seed was unmapped. However, this cannot actually happen, so READ_ONCE() is unnecessary here.
--- drivers/firmware/efi/efi.c | 2 +- include/linux/efi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/efi.c +1 -1
@@ -532,7 +532,7 @@ int __init efi_config_parse_tables(void seed =early_memremap (efi.rng_seed,sizeof (*seed));if (seed !=NULL ) { - size = seed->size; + size =min (seed->size,EFI_RANDOM_SEED_SIZE );early_memunmap (seed,sizeof (*seed)); }else {pr_err ("Could not map UEFI random seed!\n" );
include/linux/efi.h +1 -1
@@ -1607,7 +1607,7 @@ efi_status_t efi_exit_boot_services(efi_void *priv, efi_exit_boot_map_processing priv_func); -#define EFI_RANDOM_SEED_SIZE 64U +#define EFI_RANDOM_SEED_SIZE 32U // BLAKE2S_HASH_SIZEstruct linux_efi_random_seed {u32 size;
Greg Kroah-Hartman
maintainerPATCH 30/40 parisc: Make 8250_gsc driver dependend on CONFIG_PARISC
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit e8a18e3f00f3ee8d07c17ab1ea3ad4df4a3b6fe0 upstream.
Although the name of the driver 8250_gsc.c suggests that it handles only serial ports on the GSC bus, it does handle serial ports listed in the parisc machine inventory as well, e.g. the serial ports in a C8000 PCI-only workstation.
Change the dependency to CONFIG_PARISC, so that the driver gets included in the kernel even if CONFIG_GSC isn't set.
--- drivers/tty/serial/8250/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/Kconfig +1 -1
@@ -105,7 +105,7 @@ config SERIAL_8250_CONSOLE config SERIAL_8250_GSC tristate - depends on SERIAL_8250 && GSC + depends on SERIAL_8250 && PARISC default SERIAL_8250 config SERIAL_8250_DMA
Greg Kroah-Hartman
maintainerPATCH 31/40 parisc: Export iosapic_serial_irq() symbol for serial port driver
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit a0c9f1f2e53b8eb2ae43987a30e547ba56b4fa18 upstream.
The parisc serial port driver needs this symbol when it's compiled as module.
--- drivers/parisc/iosapic.c | 1 + 1 file changed, 1 insertion(+)
drivers/parisc/iosapic.c +1 -0
@@ -889,6 +889,7 @@ int iosapic_serial_irq(struct parisc_dev return vi->txn_irq; } +EXPORT_SYMBOL (iosapic_serial_irq);#endif
Greg Kroah-Hartman
maintainerPATCH 32/40 ext4: fix warning in ext4_da_release_space
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
commit 1b8f787ef547230a3249bcf897221ef0cc78481b upstream.
Syzkaller report issue as follows:
EXT4-fs (loop0): Free/Dirty block details
EXT4-fs (loop0): free_blocks=0
EXT4-fs (loop0): dirty_blocks=0
EXT4-fs (loop0): Block reservation details
EXT4-fs (loop0): i_reserved_data_blocks=0
EXT4-fs warning (device loop0): ext4_da_release_space:1527: ext4_da_release_space: ino 18, to_free 1 with only 0 reserved data blocks
------------[ cut here ]------------ WARNING: CPU: 0 PID: 92 at fs/ext4/inode.c:1528 ext4_da_release_space+0x25e/0x370 fs/ext4/inode.c:1524 Modules linked in: CPU: 0 PID: 92 Comm: kworker/u4:4 Not tainted 6.0.0-syzkaller-09423-g493ffd6605b2 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 Workqueue: writeback wb_workfn (flush-7:0) RIP: 0010:ext4_da_release_space+0x25e/0x370 fs/ext4/inode.c:1528 RSP: 0018:ffffc900015f6c90 EFLAGS: 00010296 RAX: 42215896cd52ea00 RBX: 0000000000000000 RCX: 42215896cd52ea00 RDX: 0000000000000000 RSI: 0000000080000001 RDI: 0000000000000000 RBP: 1ffff1100e907d96 R08: ffffffff816aa79d R09: fffff520002bece5 R10: fffff520002bece5 R11: 1ffff920002bece4 R12: ffff888021fd2000 R13: ffff88807483ecb0 R14: 0000000000000001 R15: ffff88807483e740 FS: 0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005555569ba628 CR3: 000000000c88e000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ext4_es_remove_extent+0x1ab/0x260 fs/ext4/extents_status.c:1461 mpage_release_unused_pages+0x24d/0xef0 fs/ext4/inode.c:1589 ext4_writepages+0x12eb/0x3be0 fs/ext4/inode.c:2852 do_writepages+0x3c3/0x680 mm/page-writeback.c:2469 __writeback_single_inode+0xd1/0x670 fs/fs-writeback.c:1587 writeback_sb_inodes+0xb3b/0x18f0 fs/fs-writeback.c:1870 wb_writeback+0x41f/0x7b0 fs/fs-writeback.c:2044 wb_do_writeback fs/fs-writeback.c:2187 [inline] wb_workfn+0x3cb/0xef0 fs/fs-writeback.c:2227 process_one_work+0x877/0xdb0 kernel/workqueue.c:2289 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK>
Above issue may happens as follows:ext4_da_write_begin
ext4_create_inline_data
ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);
ext4_set_inode_flag(inode, EXT4_INODE_INLINE_DATA);__ext4_ioctl
ext4_ext_migrate -> will lead to eh->eh_entries not zero, and set extent flagext4_da_write_begin
ext4_da_convert_inline_data_to_extent
ext4_da_write_inline_data_begin
ext4_da_map_blocks
ext4_insert_delayed_block
if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk))
if (!ext4_es_scan_clu(inode, &ext4_es_is_mapped, lblk))
ext4_clu_mapped(inode, EXT4_B2C(sbi, lblk)); -> will return 1
allocated = true;
ext4_es_insert_delayed_block(inode, lblk, allocated);
ext4_writepages
mpage_map_and_submit_extent(handle, &mpd, &give_up_on_write); -> return -ENOSPC
mpage_release_unused_pages(&mpd, give_up_on_write); -> give_up_on_write == 1
ext4_es_remove_extent
ext4_da_release_space(inode, reserved);
if (unlikely(to_free > ei->i_reserved_data_blocks))
-> to_free == 1 but ei->i_reserved_data_blocks == 0
-> then trigger warning as aboveTo solve above issue, forbid inode do migrate which has inline data.
--- fs/ext4/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/migrate.c +2 -1
@@ -450,7 +450,8 @@ int ext4_ext_migrate(struct inode *inode* already is extent-based, error out. */ if (!ext4_has_feature_extents (inode->i_sb) || - (ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ))) +ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ) || +ext4_has_inline_data (inode))return -EINVAL ;if (S_ISLNK (inode->i_mode) && inode->i_blocks ==0 )
Greg Kroah-Hartman
maintainerPATCH 33/40 KVM: x86: Mask off reserved bits in CPUID.80000008H
In reply to Greg Kroah-HartmanFrom: Jim Mattson <[email protected]>
commit 7030d8530e533844e2f4b0e7476498afcd324634 upstream.
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM actually supports. The following ranges of CPUID.80000008H are reserved and should be masked off:
ECX[31:18]
ECX[11:8]In addition, the PerfTscSize field at ECX[17:16] should also be zero because KVM does not set the PERFTSC bit at CPUID.80000001H.ECX[27].
Message-Id: <[email protected]>
--- arch/x86/kvm/cpuid.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/cpuid.c +1 -0
@@ -663,6 +663,7 @@ static inline int __do_cpuid_ent(struct g_phys_as = phys_as; entry->eax = g_phys_as | (virt_as <<8 ); + entry->ecx &= ~(GENMASK (31 ,16 ) |GENMASK (11 ,8 )); entry->edx =0 ;/* * IBRS, IBPB and VIRT_SSBD aren't necessarily present in
Greg Kroah-Hartman
maintainerPATCH 34/40 KVM: x86: emulator: em_sysexit should update ctxt->mode
In reply to Greg Kroah-HartmanFrom: Maxim Levitsky <[email protected]>
commit 5015bb89b58225f97df6ac44383e7e8c8662c8c9 upstream.
SYSEXIT is one of the instructions that can change the processor mode, thus ctxt->mode should be updated after it.
Note that this is likely a benign bug, because the only problematic mode change is from 32 bit to 64 bit which can lead to truncation of RIP, and it is not possible to do with sysexit,
since sysexit running in 32 bit mode will be limited to 32 bit version.
Message-Id: <[email protected]>
--- arch/x86/kvm/emulate.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/emulate.c +1 -0
@@ -2889,6 +2889,7 @@ static int em_sysexit(struct x86_emulate ops->set_segment (ctxt, ss_sel, &ss,0 ,VCPU_SREG_SS ); ctxt->_eip = rdx; + ctxt->mode = usermode; *reg_write (ctxt,VCPU_REGS_RSP ) = rcx;return X86EMUL_CONTINUE ;
Greg Kroah-Hartman
maintainerPATCH 35/40 KVM: x86: emulator: introduce emulator_recalc_and_set_mode
In reply to Greg Kroah-HartmanFrom: Maxim Levitsky <[email protected]>
commit d087e0f79fa0dd336a9a6b2f79ec23120f5eff73 upstream.
Some instructions update the cpu execution mode, which needs to update the emulation mode.
Extract this code, and make assign_eip_far use it.
assign_eip_far now reads CS, instead of getting it via a parameter, which is ok, because callers always assign CS to the same value before calling this function.
No functional change is intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/emulate.c | 85 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 28 deletions(-)
arch/x86/kvm/emulate.c +57 -28
@@ -758,8 +758,7 @@ static int linearize(struct x86_emulate_ ctxt->mode, linear); } -static inline int assign_eip (struct x86_emulate_ctxt *ctxt,ulong dst, -enum x86emul_mode mode) +static inline int assign_eip (struct x86_emulate_ctxt *ctxt,ulong dst) {ulong linear;int rc;
@@ -769,41 +768,71 @@ static inline int assign_eip(struct x86_if (ctxt->op_bytes !=sizeof (unsigned long )) addr.ea = dst & ((1UL << (ctxt->op_bytes <<3 )) -1 ); - rc =__linearize (ctxt, addr, &max_size,1 , false, true, mode, &linear); + rc =__linearize (ctxt, addr, &max_size,1 , false, true, ctxt->mode, &linear);if (rc ==X86EMUL_CONTINUE ) ctxt->_eip = addr.ea;return rc; } +static inline int emulator_recalc_and_set_mode (struct x86_emulate_ctxt *ctxt) +{ +u64 efer; +struct desc_struct cs; +u16 selector; +u32 base3; + + ctxt->ops->get_msr (ctxt,MSR_EFER , &efer); + +if (!(ctxt->ops->get_cr (ctxt,0 ) &X86_CR0_PE )) { +/* Real mode. cpu must not have long mode active */ +if (efer &EFER_LMA ) +return X86EMUL_UNHANDLEABLE ; + ctxt->mode =X86EMUL_MODE_REAL ; +return X86EMUL_CONTINUE ; + } + +if (ctxt->eflags &X86_EFLAGS_VM ) { +/* Protected/VM86 mode. cpu must not have long mode active */ +if (efer &EFER_LMA ) +return X86EMUL_UNHANDLEABLE ; + ctxt->mode =X86EMUL_MODE_VM86 ; +return X86EMUL_CONTINUE ; + } + +if (!ctxt->ops->get_segment (ctxt, &selector, &cs, &base3,VCPU_SREG_CS )) +return X86EMUL_UNHANDLEABLE ; + +if (efer &EFER_LMA ) { +if (cs.l) { +/* Proper long mode */ + ctxt->mode =X86EMUL_MODE_PROT64 ; + }else if (cs.d) { +/* 32 bit compatibility mode*/ + ctxt->mode =X86EMUL_MODE_PROT32 ; + }else { + ctxt->mode =X86EMUL_MODE_PROT16 ; + } + }else { +/* Legacy 32 bit / 16 bit mode */ + ctxt->mode = cs.d ?X86EMUL_MODE_PROT32 :X86EMUL_MODE_PROT16 ; + } + +return X86EMUL_CONTINUE ; +} +static inline int assign_eip_near (struct x86_emulate_ctxt *ctxt,ulong dst) { -return assign_eip (ctxt, dst, ctxt->mode); +return assign_eip (ctxt, dst); } -static int assign_eip_far (struct x86_emulate_ctxt *ctxt,ulong dst, -const struct desc_struct *cs_desc) +static int assign_eip_far (struct x86_emulate_ctxt *ctxt,ulong dst) { -enum x86emul_mode mode = ctxt->mode; -int rc; +int rc =emulator_recalc_and_set_mode (ctxt); -#ifdef CONFIG_X86_64 -if (ctxt->mode >=X86EMUL_MODE_PROT16 ) { -if (cs_desc->l) { -u64 efer =0 ; +if (rc !=X86EMUL_CONTINUE ) +return rc; - ctxt->ops->get_msr (ctxt,MSR_EFER , &efer); -if (efer &EFER_LMA ) - mode =X86EMUL_MODE_PROT64 ; - }else - mode =X86EMUL_MODE_PROT32 ;/* temporary value */ - } -#endif -if (mode ==X86EMUL_MODE_PROT16 || mode ==X86EMUL_MODE_PROT32 ) - mode = cs_desc->d ?X86EMUL_MODE_PROT32 :X86EMUL_MODE_PROT16 ; - rc =assign_eip (ctxt, dst, mode); -if (rc ==X86EMUL_CONTINUE ) - ctxt->mode = mode; -return rc; +return assign_eip (ctxt, dst); }static inline int jmp_rel (struct x86_emulate_ctxt *ctxt,int rel)
@@ -2205,7 +2234,7 @@ static int em_jmp_far(struct x86_emulateif (rc !=X86EMUL_CONTINUE )return rc; - rc =assign_eip_far (ctxt, ctxt->src.val, &new_desc); + rc =assign_eip_far (ctxt, ctxt->src.val);/* Error handling is not implemented. */ if (rc !=X86EMUL_CONTINUE )return X86EMUL_UNHANDLEABLE ;
@@ -2286,7 +2315,7 @@ static int em_ret_far(struct x86_emulate &new_desc);if (rc !=X86EMUL_CONTINUE )return rc; - rc =assign_eip_far (ctxt, eip, &new_desc); + rc =assign_eip_far (ctxt, eip);/* Error handling is not implemented. */ if (rc !=X86EMUL_CONTINUE )return X86EMUL_UNHANDLEABLE ;
@@ -3475,7 +3504,7 @@ static int em_call_far(struct x86_emulatif (rc !=X86EMUL_CONTINUE )return rc; - rc =assign_eip_far (ctxt, ctxt->src.val, &new_desc); + rc =assign_eip_far (ctxt, ctxt->src.val);if (rc !=X86EMUL_CONTINUE ) goto fail;
Greg Kroah-Hartman
maintainerPATCH 36/40 KVM: x86: emulator: update the emulation mode after CR0 write
In reply to Greg Kroah-HartmanFrom: Maxim Levitsky <[email protected]>
commit ad8f9e69942c7db90758d9d774157e53bce94840 upstream.
Update the emulation mode when handling writes to CR0, because toggling CR0.PE switches between Real and Protected Mode, and toggling CR0.PG when EFER.LME=1 switches between Long and Protected Mode.
This is likely a benign bug because there is no writeback of state, other than the RIP increment, and when toggling CR0.PE, the CPU has to execute code from a very low memory address.
Message-Id: <[email protected]>
--- arch/x86/kvm/emulate.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
arch/x86/kvm/emulate.c +15 -1
@@ -3651,11 +3651,25 @@ static int em_movbe(struct x86_emulate_cstatic int em_cr_write (struct x86_emulate_ctxt *ctxt) { -if (ctxt->ops->set_cr (ctxt, ctxt->modrm_reg, ctxt->src.val)) +int cr_num = ctxt->modrm_reg; +int r; + +if (ctxt->ops->set_cr (ctxt, cr_num, ctxt->src.val))return emulate_gp (ctxt,0 );/* Disable writeback. */ ctxt->dst.type =OP_NONE ; + +if (cr_num ==0 ) { +/* +* CR0 write might have updated CR0.PE and/or CR0.PG +* which can affect the cpu's execution mode. +*/ + r =emulator_recalc_and_set_mode (ctxt); +if (r !=X86EMUL_CONTINUE ) +return r; + } +return X86EMUL_CONTINUE ; }
Greg Kroah-Hartman
maintainerPATCH 37/40 linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 2a6cc8a6c0cb44baf7df2f64e5090aaf726002c3 upstream.
Patch series "linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc", v3.
ARM, ARM64, UniCore32 define UL() as a shorthand of _AC(..., UL). More architectures may introduce it in the future.
UL() is arch-agnostic, and useful. So let's move it to include/linux/const.h
Currently, <asm/memory.h> must be included to use UL(). It pulls in more bloats just for defining some bit macros.
I posted V2 one year ago.
The previous posts are:
https://patchwork.kernel.org/patch/9498273/
https://patchwork.kernel.org/patch/9498275/
https://patchwork.kernel.org/patch/9498269/
https://patchwork.kernel.org/patch/9498271/
At that time, what blocked this series was a comment from David Howells:
You need to be very careful doing this. Some userspace stuff depends on the guard macro names on the kernel header files.
(https://patchwork.kernel.org/patch/9498275/)
Looking at the code closer, I noticed this is not a problem.
See the following line.
https://github.com/torvalds/linux/blob/v4.16-rc2/scripts/headers_install.sh#L40
scripts/headers_install.sh rips off _UAPI prefix from guard macro names.
I ran "make headers_install" and confirmed the result is what I expect.
So, we can prefix the include guard of include/uapi/linux/const.h, and add a new include/linux/const.h.
This patch (of 4):
I am going to add include/linux/const.h for the kernel space.
Add _UAPI to the include guard of include/uapi/linux/const.h to prepare for that.
Please notice the guard name of the exported one will be kept as-is. So, this commit has no impact to the userspace even if some userspace stuff depends on the guard macro names.
scripts/headers_install.sh processes exported headers by SED, and rips off "_UAPI" from guard macro names.
#ifndef _UAPI_LINUX_CONST_H #define _UAPI_LINUX_CONST_H
will be turned into
#ifndef _LINUX_CONST_H #define _LINUX_CONST_H
--- include/uapi/linux/const.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/const.h +3 -3
@@ -1,8 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* const.h: Macros for dealing with constants. */ -#ifndef _LINUX_CONST_H -#define _LINUX_CONST_H +#ifndef _UAPI_LINUX_CONST_H +#define _UAPI_LINUX_CONST_H/* Some constant macros are used in both assembler and * C code. Therefore we cannot annotate them always with
@@ -30,4 +30,4 @@#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) -#endif /* !(_LINUX_CONST_H) */ +#endif /* _UAPI_LINUX_CONST_H */
Greg Kroah-Hartman
maintainerPATCH 38/40 linux/const.h: move UL() macro to include/linux/const.h
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 2dd8a62c647691161a2346546834262597739872 upstream.
ARM, ARM64 and UniCore32 duplicate the definition of UL():
#define UL(x) _AC(x, UL)
This is not actually arch-specific, so it will be useful to move it to a common header. Currently, we only have the uapi variant for linux/const.h, so I am creating include/linux/const.h.
I also added _UL(), _ULL() and ULL() because _AC() is mostly used in the form either _AC(..., UL) or _AC(..., ULL). I expect they will be replaced in follow-up cleanups. The underscore-prefixed ones should be used for exported headers.
--- arch/arm/include/asm/memory.h | 6 ------ arch/arm64/include/asm/memory.h | 6 ------ arch/unicore32/include/asm/memory.h | 6 ------ include/linux/const.h | 9 +++++++++ include/uapi/linux/const.h | 3 +++ 5 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 include/linux/const.h
arch/arm/include/asm/memory.h +0 -6
@@ -22,12 +22,6 @@#include <mach/memory.h> #endif -/* -* Allow for constants defined here to be used from assembly code -* by prepending the UL suffix only with actual C code compilation. -*/ -#define UL (x) _AC(x, UL) -/* PAGE_OFFSET - the virtual address of the start of the kernel image */ #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
arch/arm64/include/asm/memory.h +0 -6
@@ -29,12 +29,6 @@#include <asm/sizes.h> /* -* Allow for constants defined here to be used from assembly code -* by prepending the UL suffix only with actual C code compilation. -*/ -#define UL (x) _AC(x, UL) - -/* * Size of the PCI I/O space. This must remain a power of two so that * IO_SPACE_LIMIT acts as a mask for the low bits of I/O addresses. */
arch/unicore32/include/asm/memory.h +0 -6
@@ -20,12 +20,6 @@#include <mach/memory.h> /* -* Allow for constants defined here to be used from assembly code -* by prepending the UL suffix only with actual C code compilation. -*/ -#define UL (x) _AC(x, UL) - -/* * PAGE_OFFSET - the virtual address of the start of the kernel image * TASK_SIZE - the maximum size of a user space task. * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
include/linux/const.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _LINUX_CONST_H +#define _LINUX_CONST_H + +#include <uapi/linux/const.h> + +#define UL (x) (_UL(x)) +#define ULL (x) (_ULL(x)) + +#endif /* _LINUX_CONST_H */
include/uapi/linux/const.h +3 -0
@@ -22,6 +22,9 @@#define _AT (T ,X ) ((T)(X))#endif +#define _UL (x) (_AC(x, UL)) +#define _ULL (x) (_AC(x, ULL)) +#define _BITUL (x) (_AC(1,UL) << (x))#define _BITULL (x) (_AC(1,ULL) << (x))
Greg Kroah-Hartman
maintainerPATCH 39/40 linux/bits.h: make BIT(), GENMASK(), and friends available in assembly
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 95b980d62d52c4c1768ee719e8db3efe27ef52b2 upstream.
BIT(), GENMASK(), etc. are useful to define register bits of hardware. However, low-level code is often written in assembly, where they are not available due to the hard-coded 1UL, 0UL.
In fact, in-kernel headers such as arch/arm64/include/asm/sysreg.h use _BITUL() instead of BIT() so that the register bit macros are available in assembly.
Using macros in include/uapi/linux/const.h have two reasons:
[1] For use in uapi headers
We should use underscore-prefixed variants for user-space.
[2] For use in assembly code
Since _BITUL() uses UL(1) instead of 1UL, it can be used as an alternative of BIT().
For [2], it is pretty easy to change BIT() etc. for use in assembly.
This allows to replace _BUTUL() in kernel-space headers with BIT().
--- include/linux/bits.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
include/linux/bits.h +10 -7
@@ -1,13 +1,15 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_BITS_H#define __LINUX_BITS_H + +#include <linux/const.h> #include <asm/bitsperlong.h> -#define BIT (nr) (1UL << (nr)) -#define BIT_ULL (nr) (1ULL << (nr)) -#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT (nr) (UL(1) << (nr)) +#define BIT_ULL (nr) (ULL(1) << (nr)) +#define BIT_MASK (nr) (UL(1) << ((nr) % BITS_PER_LONG))#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) -#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_MASK (nr) (ULL(1) << ((nr) % BITS_PER_LONG_LONG))#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG)#define BITS_PER_BYTE 8
@@ -17,10 +19,11 @@* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. */ #define GENMASK (h, l) \ - (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + (((~UL(0)) - (UL(1) << (l)) + 1) & \ + (~UL(0) >> (BITS_PER_LONG - 1 - (h))))#define GENMASK_ULL (h, l) \ - (((~0ULL) - (1ULL << (l)) + 1) & \ - (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + (((~ULL(0)) - (ULL(1) << (l)) + 1) & \ + (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))#endif /* __LINUX_BITS_H */
Greg Kroah-Hartman
maintainerPATCH 40/40 wifi: brcmfmac: Fix potential buffer overflow in brcmf_fweh_event_worker()
In reply to Greg Kroah-HartmanFrom: Dokyung Song <[email protected]>
commit 6788ba8aed4e28e90f72d68a9d794e34eac17295 upstream.
This patch fixes an intra-object buffer overflow in brcmfmac that occurs when the device provides a 'bsscfgidx' equal to or greater than the buffer size. The patch adds a check that leads to a safe failure if that is the case.
This fixes CVE-2022-3628.
UBSAN: array-index-out-of-bounds in drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c index 52 is out of range for type 'brcmf_if *[16]' CPU: 0 PID: 1898 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: events brcmf_fweh_event_worker Call Trace: dump_stack_lvl+0x57/0x7d ubsan_epilogue+0x5/0x40 __ubsan_handle_out_of_bounds+0x69/0x80 ? memcpy+0x39/0x60 brcmf_fweh_event_worker+0xae1/0xc00 ? brcmf_fweh_call_event_handler.isra.0+0x100/0x100 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 process_one_work+0x873/0x13e0 ? lock_release+0x640/0x640 ? pwq_dec_nr_in_flight+0x320/0x320 ? rwlock_bug.part.0+0x90/0x90 worker_thread+0x8b/0xd10 ? __kthread_parkme+0xd9/0x1d0 ? process_one_work+0x13e0/0x13e0 kthread+0x379/0x450 ? _raw_spin_unlock_irq+0x24/0x30 ? set_kthread_struct+0x100/0x100 ret_from_fork+0x1f/0x30 ================================================================================ general protection fault, probably for non-canonical address 0xe5601c0020023fff: 0000 [#1] SMP KASAN KASAN: maybe wild-memory-access in range [0x2b0100010011fff8-0x2b0100010011ffff] CPU: 0 PID: 1898 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Workqueue: events brcmf_fweh_event_worker RIP: 0010:brcmf_fweh_call_event_handler.isra.0+0x42/0x100 Code: 89 f5 53 48 89 fb 48 83 ec 08 e8 79 0b 38 fe 48 85 ed 74 7e e8 6f 0b 38 fe 48 89 ea 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 8b 00 00 00 4c 8b 7d 00 44 89 e0 48 ba 00 00 00 RSP: 0018:ffffc9000259fbd8 EFLAGS: 00010207 RAX: dffffc0000000000 RBX: ffff888115d8cd50 RCX: 0000000000000000 RDX: 0560200020023fff RSI: ffffffff8304bc91 RDI: ffff888115d8cd50 RBP: 2b0100010011ffff R08: ffff888112340050 R09: ffffed1023549809 R10: ffff88811aa4c047 R11: ffffed1023549808 R12: 0000000000000045 R13: ffffc9000259fca0 R14: ffff888112340050 R15: ffff888112340000 FS: 0000000000000000(0000) GS:ffff88811aa00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000004053ccc0 CR3: 0000000112740000 CR4: 0000000000750ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: brcmf_fweh_event_worker+0x117/0xc00 ? brcmf_fweh_call_event_handler.isra.0+0x100/0x100 ? rcu_read_lock_sched_held+0xa1/0xd0 ? rcu_read_lock_bh_held+0xb0/0xb0 ? lockdep_hardirqs_on_prepare+0x273/0x3e0 process_one_work+0x873/0x13e0 ? lock_release+0x640/0x640 ? pwq_dec_nr_in_flight+0x320/0x320 ? rwlock_bug.part.0+0x90/0x90 worker_thread+0x8b/0xd10 ? __kthread_parkme+0xd9/0x1d0 ? process_one_work+0x13e0/0x13e0 kthread+0x379/0x450 ? _raw_spin_unlock_irq+0x24/0x30 ? set_kthread_struct+0x100/0x100 ret_from_fork+0x1f/0x30 Modules linked in: 88XXau(O) 88x2bu(O) ---[ end trace 41d302138f3ff55a ]--- RIP: 0010:brcmf_fweh_call_event_handler.isra.0+0x42/0x100 Code: 89 f5 53 48 89 fb 48 83 ec 08 e8 79 0b 38 fe 48 85 ed 74 7e e8 6f 0b 38 fe 48 89 ea 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 8b 00 00 00 4c 8b 7d 00 44 89 e0 48 ba 00 00 00 RSP: 0018:ffffc9000259fbd8 EFLAGS: 00010207 RAX: dffffc0000000000 RBX: ffff888115d8cd50 RCX: 0000000000000000 RDX: 0560200020023fff RSI: ffffffff8304bc91 RDI: ffff888115d8cd50 RBP: 2b0100010011ffff R08: ffff888112340050 R09: ffffed1023549809 R10: ffff88811aa4c047 R11: ffffed1023549808 R12: 0000000000000045 R13: ffffc9000259fca0 R14: ffff888112340050 R15: ffff888112340000 FS: 0000000000000000(0000) GS:ffff88811aa00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000004053ccc0 CR3: 0000000112740000 CR4: 0000000000750ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Kernel panic - not syncing: Fatal exception
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +4 -0
@@ -237,6 +237,10 @@ static void brcmf_fweh_event_worker(strubrcmf_fweh_event_name (event->code), event->code, event->emsg.ifidx, event->emsg.bsscfgidx, event->emsg.addr); +if (event->emsg.bsscfgidx >=BRCMF_MAX_IFS ) { +brcmf_err ("invalid bsscfg index: %u\n" , event->emsg.bsscfgidx); + goto event_free; + }/* convert event message */ emsg_be = &event->emsg;
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.299 release. There are 40 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 Thu, 10 Nov 2022 13:33:17 +0000. Anything received after that time might be too late.
Build results:
total: 170 pass: 170 fail: 0 Qemu test results: total: 422 pass: 422 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.299 release. There are 40 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 Thu, 10 Nov 2022 13:33:17 +0000. 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.299-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
All tests passing for Tegra ...
Test results for stable-v4.14:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.14.299-rc1-g85bb1cff28dd
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Jon
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.299 release. There are 40 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 Thu, 10 Nov 2022 13:33:17 +0000. 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.299-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.
## Build
* kernel: 4.14.299-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.14.y
* git commit: 85bb1cff28dd862a007c7d7eaada3e4f669566e2
* git describe: v4.14.298-41-g85bb1cff28dd
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.298-41-g85bb1cff28dd
## Test Regressions (compared to v4.14.297)
## Metric Regressions (compared to v4.14.297)
## Test Fixes (compared to v4.14.297)
## Metric Fixes (compared to v4.14.297)
## Test result summary
total: 111619, pass: 93601, fail: 1960, skip: 15138, xfail: 920
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 313 total, 308 passed, 5 failed
* arm64: 53 total, 50 passed, 3 failed
* i386: 29 total, 28 passed, 1 failed
* mips: 41 total, 41 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 20 total, 19 passed, 1 failed
* s390: 15 total, 11 passed, 4 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x86_64: 51 total, 50 passed, 1 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-net
* kselftest-net-forwarding
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-vm
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* packetdrill
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org