Bluetooth: Fix debugfs entry leak in hci_register_dev()
Subsystems (12)
Sasha Levin
maintainerPATCH 1/29 Bluetooth: Fix debugfs entry leak in hci_register_dev()
From: Wei Yongjun <[email protected]>
[ Upstream commit 5a4bb6a8e981d3d0d492aa38412ee80b21033177 ]
Fault injection test report debugfs entry leak as follows:
debugfs: Directory 'hci0' with parent 'bluetooth' already present!
When register_pm_notifier() failed in hci_register_dev(), the debugfs create by debugfs_create_dir() do not removed in the error handing path.
Add the remove debugfs code to fix it.
--- net/bluetooth/hci_core.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/hci_core.c +1 -0
@@ -3459,6 +3459,7 @@ int hci_register_dev(struct hci_dev *hdev)return id; err_wqueue: +debugfs_remove_recursive (hdev->debugfs);destroy_workqueue (hdev->workqueue);destroy_workqueue (hdev->req_workqueue); err:
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 2/29 fs: dlm: filter user dlm messages for kernel locks
From: Alexander Aring <[email protected]>
[ Upstream commit 6c2e3bf68f3e5e5a647aa52be246d5f552d7496d ]
This patch fixes the following crash by receiving a invalid message:
[ 160.672220] ================================================================== [ 160.676206] BUG: KASAN: user-memory-access in dlm_user_add_ast+0xc3/0x370 [ 160.679659] Read of size 8 at addr 00000000deadbeef by task kworker/u32:13/319 [ 160.681447] [ 160.681824] CPU: 10 PID: 319 Comm: kworker/u32:13 Not tainted 5.14.0-rc2+ #399 [ 160.683472] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.14.0-1.module+el8.6.0+12648+6ede71a5 04/01/2014 [ 160.685574] Workqueue: dlm_recv process_recv_sockets [ 160.686721] Call Trace: [ 160.687310] dump_stack_lvl+0x56/0x6f [ 160.688169] ? dlm_user_add_ast+0xc3/0x370 [ 160.689116] kasan_report.cold.14+0x116/0x11b [ 160.690138] ? dlm_user_add_ast+0xc3/0x370 [ 160.690832] dlm_user_add_ast+0xc3/0x370 [ 160.691502] _receive_unlock_reply+0x103/0x170 [ 160.692241] _receive_message+0x11df/0x1ec0 [ 160.692926] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 160.693700] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 160.694427] ? lock_acquire+0x175/0x400 [ 160.695058] ? do_purge.isra.51+0x200/0x200 [ 160.695744] ? lock_acquired+0x360/0x5d0 [ 160.696400] ? lock_contended+0x6a0/0x6a0 [ 160.697055] ? lock_release+0x21d/0x5e0 [ 160.697686] ? lock_is_held_type+0xe0/0x110 [ 160.698352] ? lock_is_held_type+0xe0/0x110 [ 160.699026] ? ___might_sleep+0x1cc/0x1e0 [ 160.699698] ? dlm_wait_requestqueue+0x94/0x140 [ 160.700451] ? dlm_process_requestqueue+0x240/0x240 [ 160.701249] ? down_write_killable+0x2b0/0x2b0 [ 160.701988] ? do_raw_spin_unlock+0xa2/0x130 [ 160.702690] dlm_receive_buffer+0x1a5/0x210 [ 160.703385] dlm_process_incoming_buffer+0x726/0x9f0 [ 160.704210] receive_from_sock+0x1c0/0x3b0 [ 160.704886] ? dlm_tcp_shutdown+0x30/0x30 [ 160.705561] ? lock_acquire+0x175/0x400 [ 160.706197] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 160.706941] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 160.707681] process_recv_sockets+0x32/0x40 [ 160.708366] process_one_work+0x55e/0xad0 [ 160.709045] ? pwq_dec_nr_in_flight+0x110/0x110 [ 160.709820] worker_thread+0x65/0x5e0 [ 160.710423] ? process_one_work+0xad0/0xad0 [ 160.711087] kthread+0x1ed/0x220 [ 160.711628] ? set_kthread_struct+0x80/0x80 [ 160.712314] ret_from_fork+0x22/0x30
The issue is that we received a DLM message for a user lock but the destination lock is a kernel lock. Note that the address which is trying to derefence is 00000000deadbeef, which is in a kernel lock lkb->lkb_astparam, this field should never be derefenced by the DLM kernel stack. In case of a user lock lkb->lkb_astparam is lkb->lkb_ua (memory is shared by a union field). The struct lkb_ua will be handled by the DLM kernel stack but on a kernel lock it will contain invalid data and ends in most likely crashing the kernel.
It can be reproduced with two cluster nodes.
node 2:dlm_tool join test
echo "862 fooobaar 1 2 1" > /sys/kernel/debug/dlm/test_locks echo "862 3 1" > /sys/kernel/debug/dlm/test_waiters
node 1:dlm_tool join test
python:
foo = DLM(h_cmd=3, o_nextcmd=1, h_nodeid=1, h_lockspace=0x77222027, \
m_type=7, m_flags=0x1, m_remid=0x862, m_result=0xFFFEFFFE)newFile = open("/sys/kernel/debug/dlm/comms/2/rawmsg", "wb") newFile.write(bytes(foo))
--- fs/dlm/lock.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/dlm/lock.c +9 -0
@@ -3975,6 +3975,14 @@ static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms)int from = ms->m_header.h_nodeid;int error =0 ; +/* currently mixing of user/kernel locks are not supported */ +if (ms->m_flags &DLM_IFL_USER && ~lkb->lkb_flags &DLM_IFL_USER ) { +log_error (lkb->lkb_resource->res_ls, +"got user dlm message for a kernel lock" ); + error = -EINVAL ; + goto out; + } +switch (ms->m_type) {case DLM_MSG_CONVERT :case DLM_MSG_UNLOCK :
@@ -4003,6 +4011,7 @@ static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms) error = -EINVAL ; } +out:if (error) log_error(lkb->lkb_resource->res_ls, "ignore invalid message %d from %d %x %x %x %d",
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 3/29 ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START reply
In reply to Sasha LevinFrom: Zekun Shen <[email protected]>
[ Upstream commit ae80b6033834342601e99f74f6a62ff5092b1cee ]
Unexpected WDCMSG_TARGET_START replay can lead to null-ptr-deref when ar->tx_cmd->odata is NULL. The patch adds a null check to prevent such case.
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] ar5523_cmd+0x46a/0x581 [ar5523] ar5523_probe.cold+0x1b7/0x18da [ar5523] ? ar5523_cmd_rx_cb+0x7a0/0x7a0 [ar5523] ? __pm_runtime_set_status+0x54a/0x8f0 ? _raw_spin_trylock_bh+0x120/0x120 ? pm_runtime_barrier+0x220/0x220 ? __pm_runtime_resume+0xb1/0xf0 usb_probe_interface+0x25b/0x710 really_probe+0x209/0x5d0 driver_probe_device+0xc6/0x1b0 device_driver_attach+0xe2/0x120
I found the bug using a custome USBFuzz port. It's a research work to fuzz USB stack/drivers. I modified it to fuzz ath9k driver only, providing hand-crafted usb descriptors to QEMU.
After fixing the code (fourth byte in usb packet) to WDCMSG_TARGET_START, I got the null-ptr-deref bug. I believe the bug is triggerable whenever cmd->odata is NULL. After patching, I tested with the same input and no longer see the KASAN report.
This was NOT tested on a real device.
--- drivers/net/wireless/ath/ar5523/ar5523.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ar5523/ar5523.c +4 -0
@@ -153,6 +153,10 @@ static void ar5523_cmd_rx_cb(struct urb *urb)ar5523_err (ar,"Invalid reply to WDCMSG_TARGET_START" );return ; } +if (!cmd->odata) { +ar5523_err (ar,"Unexpected WDCMSG_TARGET_START reply" ); +return ; + }memcpy (cmd->odata, hdr +1 ,sizeof (u32)); cmd->olen =sizeof (u32); cmd->res =0 ;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 4/29 usb: gadget: f_fs: Use stream_open() for endpoint files
In reply to Sasha LevinFrom: Pavankumar Kondeti <[email protected]>
[ Upstream commit c76ef96fc00eb398c8fc836b0eb2f82bcc619dc7 ]
Function fs endpoint file operations are synchronized via an interruptible mutex wait. However we see threads that do ep file operations concurrently are getting blocked for the mutex lock in __fdget_pos(). This is an uninterruptible wait and we see hung task warnings and kernel panic if hung_task_panic systcl is enabled if host does not send/receive the data for long time.
The reason for threads getting blocked in __fdget_pos() is due to the file position protection introduced by the commit 9c225f2655e3 ("vfs: atomic f_pos accesses as per POSIX"). Since function fs endpoint files does not have the notion of the file position, switch to the stream mode. This will bypass the file position mutex and threads will be blocked in interruptible state for the function fs mutex.
It should not affects user space as we are only changing the task state changes the task state from UNINTERRUPTIBLE to INTERRUPTIBLE while waiting for the USB transfers to be finished. However there is a slight change to the O_NONBLOCK behavior. Earlier threads that are using O_NONBLOCK are also getting blocked inside fdget_pos(). Now they reach to function fs and error code is returned. The non blocking behavior is actually honoured now.
--- drivers/usb/gadget/function/f_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_fs.c +2 -2
@@ -541,7 +541,7 @@ static int ffs_ep0_open(struct inode *inode, struct file *file) file->private_data = ffs;ffs_data_opened (ffs); -return 0 ; +return stream_open (inode, file); }static int ffs_ep0_release (struct inode *inode,struct file *file)
@@ -882,7 +882,7 @@ ffs_epfile_open(struct inode *inode, struct file *file) file->private_data = epfile;ffs_data_opened (epfile->ffs); -return 0 ; +return stream_open (inode, file); }static int ffs_aio_cancel (struct kiocb *kiocb)
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 5/29 media: b2c2: Add missing check in flexcop_pci_isr:
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit b13203032e679674c7c518f52a7ec0801ca3a829 ]
A out-of-bounds bug can be triggered by an interrupt, the reason for this bug is the lack of checking of register values.
In flexcop_pci_isr, the driver reads value from a register and uses it as a dma address. Finally, this address will be passed to the count parameter of find_next_packet. If this value is larger than the size of dma, the index of buffer will be out-of-bounds.
Fix this by adding a check after reading the value of the register.
The following KASAN report reveals it:
BUG: KASAN: slab-out-of-bounds in find_next_packet drivers/media/dvb-core/dvb_demux.c:528 [inline] BUG: KASAN: slab-out-of-bounds in _dvb_dmx_swfilter drivers/media/dvb-core/dvb_demux.c:572 [inline] BUG: KASAN: slab-out-of-bounds in dvb_dmx_swfilter+0x3fa/0x420 drivers/media/dvb-core/dvb_demux.c:603 Read of size 1 at addr ffff8880608c00a0 by task swapper/2/0 CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.19.177-gdba4159c14ef #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xec/0x156 lib/dump_stack.c:118 print_address_description+0x78/0x290 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x25b/0x380 mm/kasan/report.c:412 __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:430 find_next_packet drivers/media/dvb-core/dvb_demux.c:528 [inline] _dvb_dmx_swfilter drivers/media/dvb-core/dvb_demux.c:572 [inline] dvb_dmx_swfilter+0x3fa/0x420 drivers/media/dvb-core/dvb_demux.c:603 flexcop_pass_dmx_data+0x2e/0x40 drivers/media/common/b2c2/flexcop.c:167 flexcop_pci_isr+0x3d1/0x5d0 drivers/media/pci/b2c2/flexcop-pci.c:212 __handle_irq_event_percpu+0xfb/0x770 kernel/irq/handle.c:149 handle_irq_event_percpu+0x79/0x150 kernel/irq/handle.c:189 handle_irq_event+0xac/0x140 kernel/irq/handle.c:206 handle_fasteoi_irq+0x232/0x5c0 kernel/irq/chip.c:725 generic_handle_irq_desc include/linux/irqdesc.h:155 [inline] handle_irq+0x230/0x3a0 arch/x86/kernel/irq_64.c:87 do_IRQ+0xa7/0x1e0 arch/x86/kernel/irq.c:247 common_interrupt+0xf/0xf arch/x86/entry/entry_64.S:670 </IRQ> RIP: 0010:native_safe_halt+0x28/0x30 arch/x86/include/asm/irqflags.h:61 Code: 00 00 55 be 04 00 00 00 48 c7 c7 00 62 2f 8c 48 89 e5 e8 fb 31
e8 f8 8b 05 75 4f 8e 03 85 c0 7e 07 0f 00 2d 8a 61 66 00 fb f4 <5d> c3 90 90 90 90 90 90 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 41
RSP: 0018:ffff88806b71fcc8 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffde
RAX: 0000000000000000 RBX: ffffffff8bde44c8 RCX: ffffffff88a11285
RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffff8c2f6200
RBP: ffff88806b71fcc8 R08: fffffbfff185ec40 R09: fffffbfff185ec40
R10: 0000000000000001 R11: fffffbfff185ec40 R12: 0000000000000002
R13: ffffffff8be9d6e0 R14: 0000000000000000 R15: 0000000000000000
arch_safe_halt arch/x86/include/asm/paravirt.h:94 [inline] default_idle+0x6f/0x360 arch/x86/kernel/process.c:557 arch_cpu_idle+0xf/0x20 arch/x86/kernel/process.c:548 default_idle_call+0x3b/0x60 kernel/sched/idle.c:93 cpuidle_idle_call kernel/sched/idle.c:153 [inline] do_idle+0x2ab/0x3c0 kernel/sched/idle.c:263 cpu_startup_entry+0xcb/0xe0 kernel/sched/idle.c:369 start_secondary+0x3b8/0x4e0 arch/x86/kernel/smpboot.c:271 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243 Allocated by task 1: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:553 kasan_slab_alloc+0x11/0x20 mm/kasan/kasan.c:490 slab_post_alloc_hook mm/slab.h:445 [inline] slab_alloc_node mm/slub.c:2741 [inline] slab_alloc mm/slub.c:2749 [inline] kmem_cache_alloc+0xeb/0x280 mm/slub.c:2754 kmem_cache_zalloc include/linux/slab.h:699 [inline] __kernfs_new_node+0xe2/0x6f0 fs/kernfs/dir.c:633 kernfs_new_node+0x9a/0x120 fs/kernfs/dir.c:693 __kernfs_create_file+0x5f/0x340 fs/kernfs/file.c:992 sysfs_add_file_mode_ns+0x22a/0x4e0 fs/sysfs/file.c:306 create_files fs/sysfs/group.c:63 [inline] internal_create_group+0x34e/0xc30 fs/sysfs/group.c:147 sysfs_create_group fs/sysfs/group.c:173 [inline] sysfs_create_groups+0x9c/0x140 fs/sysfs/group.c:200 driver_add_groups+0x3e/0x50 drivers/base/driver.c:129 bus_add_driver+0x3a5/0x790 drivers/base/bus.c:684 driver_register+0x1cd/0x410 drivers/base/driver.c:170 __pci_register_driver+0x197/0x200 drivers/pci/pci-driver.c:1411 cx88_audio_pci_driver_init+0x23/0x25 drivers/media/pci/cx88/cx88-alsa.c: 1017 do_one_initcall+0xe0/0x610 init/main.c:884 do_initcall_level init/main.c:952 [inline] do_initcalls init/main.c:960 [inline] do_basic_setup init/main.c:978 [inline] kernel_init_freeable+0x4d0/0x592 init/main.c:1145 kernel_init+0x18/0x190 init/main.c:1062 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415 Freed by task 0:
(stack is not available)
The buggy address belongs to the object at ffff8880608c0000
which belongs to the cache kernfs_node_cache of size 160
The buggy address is located 0 bytes to the right of
160-byte region [ffff8880608c0000, ffff8880608c00a0)
The buggy address belongs to the page:
page:ffffea0001823000 count:1 mapcount:0 mapping:ffff88806bed1e00
index:0x0 compound_mapcount: 0
flags: 0x100000000008100(slab|head)
raw: 0100000000008100 dead000000000100 dead000000000200 ffff88806bed1e00
raw: 0000000000000000 0000000000240024 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880608bff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8880608c0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880608c0080: 00 00 00 00 fc fc fc fc fc fc fc fc 00 00 00 00
^
ffff8880608c0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8880608c0180: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
==================================================================--- drivers/media/pci/b2c2/flexcop-pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/pci/b2c2/flexcop-pci.c +3 -0
@@ -184,6 +184,8 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id)dma_addr_t cur_addr = fc->read_ibi_reg (fc,dma1_008).dma_0x8.dma_cur_addr <<2 ;u32 cur_pos = cur_addr - fc_pci->dma[0 ].dma_addr0; +if (cur_pos > fc_pci->dma[0 ].size *2 ) + goto error; deb_irq("%u irq: %08x cur_addr: %llx: cur_pos: %08x, " "last_cur_pos: %08x ",
@@ -225,6 +227,7 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id) ret =IRQ_NONE ; } +error:spin_unlock_irqrestore (&fc_pci->irq_lock, flags);return ret; }
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 6/29 ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART
In reply to Sasha LevinFrom: Lukas Bulwahn <[email protected]>
[ Upstream commit b0100bce4ff82ec1ccd3c1f3d339fd2df6a81784 ]
Since commit 4b563a066611 ("ARM: imx: Remove imx21 support"), the config DEBUG_IMX21_IMX27_UART is really only debug support for IMX27.
So, rename this option to DEBUG_IMX27_UART and adjust dependencies in Kconfig and rename the definitions to IMX27 as further clean-up.
This issue was discovered with ./scripts/checkkconfigsymbols.py, which reported that DEBUG_IMX21_IMX27_UART depends on the non-existing config SOC_IMX21.
--- arch/arm/Kconfig.debug | 14 +++++++------- arch/arm/include/debug/imx-uart.h | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/Kconfig.debug +7 -7
@@ -339,12 +339,12 @@ choice Say Y here if you want kernel low-level debugging support on i.MX25. - config DEBUG_IMX21_IMX27_UART - bool "i.MX21 and i.MX27 Debug UART" - depends on SOC_IMX21 || SOC_IMX27 + config DEBUG_IMX27_UART + bool "i.MX27 Debug UART" + depends on SOC_IMX27 help Say Y here if you want kernel low-level debugging support - on i.MX21 or i.MX27. + on i.MX27. config DEBUG_IMX28_UART bool "i.MX28 Debug UART"
@@ -1263,7 +1263,7 @@ config DEBUG_IMX_UART_PORT int "i.MX Debug UART Port Selection" depends on DEBUG_IMX1_UART || \ DEBUG_IMX25_UART || \ - DEBUG_IMX21_IMX27_UART || \ + DEBUG_IMX27_UART || \ DEBUG_IMX31_UART || \ DEBUG_IMX35_UART || \ DEBUG_IMX50_UART || \
@@ -1314,12 +1314,12 @@ config DEBUG_LL_INCLUDE default "debug/icedcc.S" if DEBUG_ICEDCC default "debug/imx.S" if DEBUG_IMX1_UART || \ DEBUG_IMX25_UART || \ - DEBUG_IMX21_IMX27_UART || \ + DEBUG_IMX27_UART || \ DEBUG_IMX31_UART || \ DEBUG_IMX35_UART || \ DEBUG_IMX50_UART || \ DEBUG_IMX51_UART || \ - DEBUG_IMX53_UART ||\ + DEBUG_IMX53_UART || \ DEBUG_IMX6Q_UART || \ DEBUG_IMX6SL_UART || \ DEBUG_IMX6SX_UART || \
arch/arm/include/debug/imx-uart.h +9 -9
@@ -14,13 +14,6 @@#define IMX1_UART_BASE_ADDR (n) IMX1_UART##n##_BASE_ADDR#define IMX1_UART_BASE (n) IMX1_UART_BASE_ADDR(n) -#define IMX21_UART1_BASE_ADDR 0x1000a000 -#define IMX21_UART2_BASE_ADDR 0x1000b000 -#define IMX21_UART3_BASE_ADDR 0x1000c000 -#define IMX21_UART4_BASE_ADDR 0x1000d000 -#define IMX21_UART_BASE_ADDR (n) IMX21_UART##n##_BASE_ADDR -#define IMX21_UART_BASE (n) IMX21_UART_BASE_ADDR(n) -#define IMX25_UART1_BASE_ADDR 0x43f90000#define IMX25_UART2_BASE_ADDR 0x43f94000#define IMX25_UART3_BASE_ADDR 0x5000c000
@@ -29,6 +22,13 @@#define IMX25_UART_BASE_ADDR (n) IMX25_UART##n##_BASE_ADDR#define IMX25_UART_BASE (n) IMX25_UART_BASE_ADDR(n) +#define IMX27_UART1_BASE_ADDR 0x1000a000 +#define IMX27_UART2_BASE_ADDR 0x1000b000 +#define IMX27_UART3_BASE_ADDR 0x1000c000 +#define IMX27_UART4_BASE_ADDR 0x1000d000 +#define IMX27_UART_BASE_ADDR (n) IMX27_UART##n##_BASE_ADDR +#define IMX27_UART_BASE (n) IMX27_UART_BASE_ADDR(n) +#define IMX31_UART1_BASE_ADDR 0x43f90000#define IMX31_UART2_BASE_ADDR 0x43f94000#define IMX31_UART3_BASE_ADDR 0x5000c000
@@ -115,10 +115,10 @@#ifdef CONFIG_DEBUG_IMX1_UART #define UART_PADDR IMX_DEBUG_UART_BASE(IMX1) -#elif defined(CONFIG_DEBUG_IMX21_IMX27_UART ) -#define UART_PADDR IMX_DEBUG_UART_BASE(IMX21)#elif defined(CONFIG_DEBUG_IMX25_UART )#define UART_PADDR IMX_DEBUG_UART_BASE(IMX25) +#elif defined(CONFIG_DEBUG_IMX27_UART ) +#define UART_PADDR IMX_DEBUG_UART_BASE(IMX27)#elif defined(CONFIG_DEBUG_IMX31_UART )#define UART_PADDR IMX_DEBUG_UART_BASE(IMX31)#elif defined(CONFIG_DEBUG_IMX35_UART )
Signature · 1 line
2.34.1
Re: [PATCH AUTOSEL 4.4 06/29] ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART
Hi!
Quoted 6 lines
From: Lukas Bulwahn <[email protected]>
[ Upstream commit
b0100bce4ff82ec1ccd3c1f3d339fd2df6a81784]Since commit
4b563a066611("ARM: imx: Remove imx21 support"), the configDEBUG_IMX21_IMX27_UARTis really only debug support for IMX27.
This is unsuitable for 4.4 as imx21 is still supported there.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerRe: [PATCH AUTOSEL 4.4 06/29] ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART
Quoted 10 lines · Pavel Machek
Hi!
Quoted 6 lines
From: Lukas Bulwahn <[email protected]>
[ Upstream commit
b0100bce4ff82ec1ccd3c1f3d339fd2df6a81784]Since commit
4b563a066611("ARM: imx: Remove imx21 support"), the configDEBUG_IMX21_IMX27_UARTis really only debug support for IMX27.This is unsuitable for 4.4 as imx21 is still supported there.
I'll drop it, thanks!
Signature · 2 lines
Thanks, Sasha
Re: [PATCH AUTOSEL 4.4 06/29] ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART
Hi!
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
From: Lukas Bulwahn <[email protected]>
[ Upstream commit
b0100bce4ff82ec1ccd3c1f3d339fd2df6a81784]Since commit
4b563a066611("ARM: imx: Remove imx21 support"), the configDEBUG_IMX21_IMX27_UARTis really only debug support for IMX27.This is unsuitable for 4.4 as imx21 is still supported there.
I'll drop it, thanks!
Thank you.
I have not checked which is the newest kernel that supports imx21, other kernels may have same issue, too.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerPATCH 7/29 HSI: core: Fix return freed object in hsi_new_client
In reply to Sasha LevinFrom: Chengfeng Ye <[email protected]>
[ Upstream commit a1ee1c08fcd5af03187dcd41dcab12fd5b379555 ]
cl is freed on error of calling device_register, but this object is return later, which will cause uaf issue. Fix it by return NULL on error.
--- drivers/hsi/hsi.c | 1 + 1 file changed, 1 insertion(+)
drivers/hsi/hsi.c +1 -0
@@ -115,6 +115,7 @@ struct hsi_client *hsi_new_client(struct hsi_port *port,if (device_register (&cl->device) <0 ) {pr_err ("hsi: failed to register client: %s\n" , info->name);put_device (&cl->device); + goto err; }return cl;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 8/29 mwifiex: Fix skb_over_panic in mwifiex_usb_recv()
In reply to Sasha LevinFrom: Zekun Shen <[email protected]>
[ Upstream commit 04d80663f67ccef893061b49ec8a42ff7045ae84 ]
Currently, with an unknown recv_type, mwifiex_usb_recv just return -1 without restoring the skb. Next time mwifiex_usb_rx_complete is invoked with the same skb, calling skb_put causes skb_over_panic.
The bug is triggerable with a compromised/malfunctioning usb device. After applying the patch, skb_over_panic no longer shows up with the same input.
Attached is the panic report from fuzzing.
skbuff: skb_over_panic: text:000000003bf1b5fa
len:2048 put:4 head:00000000dd6a115b data:000000000a9445d8 tail:0x844 end:0x840 dev:<NULL>
kernel BUG at net/core/skbuff.c:109!
invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 PID: 198 Comm: in:imklog Not tainted 5.6.0 #60 RIP: 0010:skb_panic+0x15f/0x161 Call Trace: <IRQ> ? mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb] skb_put.cold+0x24/0x24 mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb] __usb_hcd_giveback_urb+0x1e4/0x380 usb_giveback_urb_bh+0x241/0x4f0 ? __hrtimer_run_queues+0x316/0x740 ? __usb_hcd_giveback_urb+0x380/0x380 tasklet_action_common.isra.0+0x135/0x330 __do_softirq+0x18c/0x634 irq_exit+0x114/0x140 smp_apic_timer_interrupt+0xde/0x380 apic_timer_interrupt+0xf/0x20 </IRQ>
--- drivers/net/wireless/mwifiex/usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mwifiex/usb.c +2 -1
@@ -132,7 +132,8 @@ static int mwifiex_usb_recv(struct mwifiex_adapter *adapter,default :mwifiex_dbg (adapter,ERROR ,"unknown recv_type %#x\n" , recv_type); -return -1 ; + ret =-1 ; + goto exit_restore_skb; }break ;case MWIFIEX_USB_EP_DATA :
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 9/29 floppy: Add max size check for user space request
In reply to Sasha LevinFrom: Xiongwei Song <[email protected]>
[ Upstream commit 545a32498c536ee152331cd2e7d2416aa0f20e01 ]
We need to check the max request size that is from user space before allocating pages. If the request size exceeds the limit, return -EINVAL. This check can avoid the warning below from page allocator.
WARNING: CPU: 3 PID: 16525 at mm/page_alloc.c:5344 current_gfp_context include/linux/sched/mm.h:195 [inline] WARNING: CPU: 3 PID: 16525 at mm/page_alloc.c:5344 __alloc_pages+0x45d/0x500 mm/page_alloc.c:5356 Modules linked in: CPU: 3 PID: 16525 Comm: syz-executor.3 Not tainted 5.15.0-syzkaller #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 RIP: 0010:__alloc_pages+0x45d/0x500 mm/page_alloc.c:5344 Code: be c9 00 00 00 48 c7 c7 20 4a 97 89 c6 05 62 32 a7 0b 01 e8 74 9a 42 07 e9 6a ff ff ff 0f 0b e9 a0 fd ff ff 40 80 e5 3f eb 88 <0f> 0b e9 18 ff ff ff 4c 89 ef 44 89 e6 45 31 ed e8 1e 76 ff ff e9 RSP: 0018:ffffc90023b87850 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 1ffff92004770f0b RCX: dffffc0000000000 RDX: 0000000000000000 RSI: 0000000000000033 RDI: 0000000000010cc1 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001 R10: ffffffff81bb4686 R11: 0000000000000001 R12: ffffffff902c1960 R13: 0000000000000033 R14: 0000000000000000 R15: ffff88804cf64a30 FS: 0000000000000000(0000) GS:ffff88802cd00000(0063) knlGS:00000000f44b4b40 CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 CR2: 000000002c921000 CR3: 000000004f507000 CR4: 0000000000150ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191 __get_free_pages+0x8/0x40 mm/page_alloc.c:5418 raw_cmd_copyin drivers/block/floppy.c:3113 [inline] raw_cmd_ioctl drivers/block/floppy.c:3160 [inline] fd_locked_ioctl+0x12e5/0x2820 drivers/block/floppy.c:3528 fd_ioctl drivers/block/floppy.c:3555 [inline] fd_compat_ioctl+0x891/0x1b60 drivers/block/floppy.c:3869 compat_blkdev_ioctl+0x3b8/0x810 block/ioctl.c:662 __do_compat_sys_ioctl+0x1c7/0x290 fs/ioctl.c:972 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
--- drivers/block/floppy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/floppy.c +3 -1
@@ -3116,6 +3116,8 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) } } +#define MAX_LEN (1UL << MAX_ORDER << PAGE_SHIFT) +static int raw_cmd_copyin (int cmd,void __user *param,struct floppy_raw_cmd **rcmd) {
@@ -3153,7 +3155,7 @@ static int raw_cmd_copyin(int cmd, void __user *param, ptr->resultcode =0 ;if (ptr->flags & (FD_RAW_READ |FD_RAW_WRITE )) { -if (ptr->length <=0 ) +if (ptr->length <=0 || ptr->length >=MAX_LEN )return -EINVAL ; ptr->kernel_data = (char *)fd_dma_mem_alloc (ptr->length);fallback_on_nodma_alloc (&ptr->kernel_data, ptr->length);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 10/29 media: saa7146: hexium_orion: Fix a NULL pointer dereference in hexium_attach()
In reply to Sasha LevinFrom: Zhou Qingyang <[email protected]>
[ Upstream commit 348df8035301dd212e3cc2860efe4c86cb0d3303 ]
In hexium_attach(dev, info), saa7146_vv_init() is called to allocate a new memory for dev->vv_data. In hexium_detach(), saa7146_vv_release() will be called and there is a dereference of dev->vv_data in saa7146_vv_release(), which could lead to a NULL pointer dereference on failure of saa7146_vv_init() according to the following logic.
Both hexium_attach() and hexium_detach() are callback functions of the variable 'extension', so there exists a possible call chain directly from hexium_attach() to hexium_detach():
hexium_attach(dev, info) -- fail to alloc memory to dev->vv_data
| in saa7146_vv_init(). | |
hexium_detach() -- a dereference of dev->vv_data in saa7146_vv_release()
Fix this bug by adding a check of saa7146_vv_init().
This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug.
Builds with CONFIG_VIDEO_HEXIUM_ORION=m show no new warnings, and our static analyzer no longer warns about this code.
--- drivers/media/pci/saa7146/hexium_orion.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/pci/saa7146/hexium_orion.c +7 -1
@@ -366,10 +366,16 @@ static struct saa7146_ext_vv vv_data;static int hexium_attach (struct saa7146_dev *dev,struct saa7146_pci_extension_data *info) {struct hexium *hexium = (struct hexium *) dev->ext_priv; +int ret;DEB_EE ("\n" ); -saa7146_vv_init (dev, &vv_data); + ret =saa7146_vv_init (dev, &vv_data); +if (ret) { +pr_err ("Error in saa7146_vv_init()\n" ); +return ret; + } + vv_data.vid_ops.vidioc_enum_input = vidioc_enum_input; vv_data.vid_ops.vidioc_g_input = vidioc_g_input; vv_data.vid_ops.vidioc_s_input = vidioc_s_input;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 11/29 media: m920x: don't use stack on USB reads
In reply to Sasha LevinFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit a2ab06d7c4d6bfd0b545a768247a70463e977e27 ]
Using stack-allocated pointers for USB message data don't work. This driver is almost OK with that, except for the I2C read logic.
Fix it by using a temporary read buffer, just like on all other calls to m920x_read().
--- drivers/media/usb/dvb-usb/m920x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb/m920x.c +11 -1
@@ -284,6 +284,13 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu/* Should check for ack here, if we knew how. */ }if (msg[i].flags &I2C_M_RD ) { +char *read =kmalloc (1 ,GFP_KERNEL ); +if (!read) { + ret = -ENOMEM ; +kfree (read); + goto unlock; + } +for (j =0 ; j < msg[i].len; j++) {/* Last byte of transaction? * Send STOP, otherwise send ACK. */
@@ -291,9 +298,12 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuif ((ret =m920x_read (d->udev,M9206_I2C ,0x0 ,0x20 | stop, - &msg[i].buf[j],1 )) !=0 ) + read,1 )) !=0 ) goto unlock; + msg[i].buf[j] = read[0 ]; } + +kfree (read); }else {for (j =0 ; j < msg[i].len; j++) {/* Last byte of transaction? Then send STOP. */
Signature · 1 line
2.34.1
Re: [PATCH AUTOSEL 4.4 11/29] media: m920x: don't use stack on USB reads
Hi!
Quoted 10 lines
From: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit
a2ab06d7c4d6bfd0b545a768247a70463e977e27]Using stack-allocated pointers for USB message data don't work. This driver is almost OK with that, except for the I2C read logic.
Fix it by using a temporary read buffer, just like on all other calls to
m920x_read().
This introduces memory leak... and I don't believe it really fixes the problem.
drivers/media/usb/dvb-usb/m920x.c static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu · line 292
Quoted 13 lines
index
eafc5c82467f4..5b806779e2106100644drivers/media/usb/dvb-usb/m920x.c +6
-0@@ -284,6 +284,13 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu/* Should check for ack here, if we knew how. */ }if (msg[i].flags &I2C_M_RD ) { +char *read =kmalloc (1 ,GFP_KERNEL ); +if (!read) { + ret = -ENOMEM ; +kfree (read); + goto unlock; + }
kfree(NULL);
drivers/media/usb/dvb-usb/m920x.c static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu · line 302
Quoted 10 lines
drivers/media/usb/dvb-usb/m920x.c +1
-1for (j =0 ; j < msg[i].len; j++) {/* Last byte of transaction? * Send STOP, otherwise send ACK. */ @@ -291,9 +298,12 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuif ((ret =m920x_read (d->udev,M9206_I2C ,0x0 ,0x20 | stop, - &msg[i].buf[j],1 )) !=0 ) + read,1 )) !=0 ) goto unlock;
Memory leak of read.
drivers/media/usb/dvb-usb/m920x.c static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu · line 309
Quoted 7 lines
drivers/media/usb/dvb-usb/m920x.c +3
-0+ msg[i].buf[j] = read[0 ]; } + +kfree (read); }else {for (j =0 ; j < msg[i].len; j++) {/* Last byte of transaction? Then send STOP. */
But more importantly, do we have exact copy of the read problem just below, during write?
Best regards,
Pavel
drivers/media/usb/dvb-usb/m920x.c +4 -3
@@ -250,7 +250,7 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu {struct dvb_usb_device *d =i2c_get_adapdata (adap);int i, j; -int ret =0 ; +int ret;if (mutex_lock_interruptible (&d->i2c_mutex) <0 )return -EAGAIN ;
@@ -277,7 +277,6 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuchar *read =kmalloc (1 ,GFP_KERNEL );if (!read) { ret = -ENOMEM ; -kfree (read); goto unlock; }
@@ -288,8 +287,10 @@ static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nuif ((ret =m920x_read (d->udev,M9206_I2C ,0x0 ,0x20 | stop, - read,1 )) !=0 ) + read,1 )) !=0 ) { +kfree (read); goto unlock; + } msg[i].buf[j] = read[0 ]; }
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerPATCH 12/29 iwlwifi: mvm: synchronize with FW after multicast commands
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit db66abeea3aefed481391ecc564fb7b7fb31d742 ]
If userspace installs a lot of multicast groups very quickly, then we may run out of command queue space as we send the updates in an asynchronous fashion (due to locking concerns), and the CPU can create them faster than the firmware can process them. This is true even when mac80211 has a work struct that gets scheduled.
Fix this by synchronizing with the firmware after sending all those commands - outside of the iteration we can send a synchronous echo command that just has the effect of the CPU waiting for the prior asynchronous commands to finish. This also will cause fewer of the commands to be sent to the firmware overall, because the work will only run once when rescheduled multiple times while it's running.
--- drivers/net/wireless/iwlwifi/mvm/mac80211.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/wireless/iwlwifi/mvm/mac80211.c +17 -0
@@ -1957,6 +1957,7 @@ static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)struct iwl_mvm_mc_iter_data iter_data = { .mvm = mvm, }; +int ret;lockdep_assert_held (&mvm->mutex);
@@ -1966,6 +1967,22 @@ static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)ieee80211_iterate_active_interfaces_atomic ( mvm->hw,IEEE80211_IFACE_ITER_NORMAL , iwl_mvm_mc_iface_iterator, &iter_data); + +/* +* Send a (synchronous) ech command so that we wait for the +* multiple asynchronous MCAST_FILTER_CMD commands sent by +* the interface iterator. Otherwise, we might get here over +* and over again (by userspace just sending a lot of these) +* and the CPU can send them faster than the firmware can +* process them. +* Note that the CPU is still faster - but with this we'll +* actually send fewer commands overall because the CPU will +* not schedule the work in mac80211 as frequently if it's +* still running when rescheduled (possibly multiple times). +*/ + ret =iwl_mvm_send_cmd_pdu (mvm,ECHO_CMD ,0 ,0 ,NULL ); +if (ret) +IWL_ERR (mvm,"Failed to synchronize multicast groups update\n" ); } static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw,
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 13/29 net: Enable neighbor sysctls that is save for userns root
In reply to Sasha LevinFrom: xu xin <[email protected]>
[ Upstream commit 8c8b7aa7fb0cf9e1cc9204e6bc6e1353b8393502 ]
Inside netns owned by non-init userns, sysctls about ARP/neighbor is currently not visible and configurable.
For the attributes these sysctls correspond to, any modifications make effects on the performance of networking(ARP, especilly) only in the scope of netns, which does not affect other netns.
Actually, some tools via netlink can modify these attribute. iproute2 is an example. see as follows:
$ unshare -ur -n
$ cat /proc/sys/net/ipv4/neigh/lo/retrans_time
cat: can't open '/proc/sys/net/ipv4/neigh/lo/retrans_time': No such file
or directory
$ ip ntable show dev lo
inet arp_cache
dev lo
refcnt 1 reachable 19494 base_reachable 30000 retrans 1000
gc_stale 60000 delay_probe 5000 queue 101
app_probes 0 ucast_probes 3 mcast_probes 3
anycast_delay 1000 proxy_delay 800 proxy_queue 64 locktime 1000inet6 ndisc_cache
dev lo
refcnt 1 reachable 42394 base_reachable 30000 retrans 1000 gc_stale 60000 delay_probe 5000 queue 101 app_probes 0 ucast_probes 3 mcast_probes 3 anycast_delay 1000 proxy_delay 800 proxy_queue 64 locktime 0
$ ip ntable change name arp_cache dev <if> retrans 2000
inet arp_cache
dev lo
refcnt 1 reachable 22917 base_reachable 30000 retrans 2000
gc_stale 60000 delay_probe 5000 queue 101
app_probes 0 ucast_probes 3 mcast_probes 3
anycast_delay 1000 proxy_delay 800 proxy_queue 64 locktime 1000inet6 ndisc_cache
dev lo
refcnt 1 reachable 35524 base_reachable 30000 retrans 1000 gc_stale 60000 delay_probe 5000 queue 101 app_probes 0 ucast_probes 3 mcast_probes 3 anycast_delay 1000 proxy_delay 800 proxy_queue 64 locktime 0
--- net/core/neighbour.c | 4 ---- 1 file changed, 4 deletions(-)
net/core/neighbour.c +0 -4
@@ -3210,10 +3210,6 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, neigh_proc_base_reachable_time; } -/* Don't export sysctls to unprivileged users */ -if (neigh_parms_net (p)->user_ns != &init_user_ns) - t->neigh_vars[0 ].procname =NULL ; -switch (neigh_parms_family (p)) {case AF_INET : p_name ="ipv4" ;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 14/29 net: bonding: debug: avoid printing debug logs when bond is not notifying peers
In reply to Sasha LevinFrom: Suresh Kumar <[email protected]>
[ Upstream commit fee32de284ac277ba434a2d59f8ce46528ff3946 ]
Currently "bond_should_notify_peers: slave ..." messages are printed whenever "bond_should_notify_peers" function is called.
+++
Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:26 node1 kernel: bond0: (slave enp0s25): Received LACPDU on port 1 Dec 12 12:33:26 node1 kernel: bond0: (slave enp0s25): Rx Machine: Port=1, Last State=6, Curr State=6 Dec 12 12:33:26 node1 kernel: bond0: (slave enp0s25): partner sync=1 Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:26 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 ... Dec 12 12:33:30 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:30 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:30 node1 kernel: bond0: (slave enp4s3): Received LACPDU on port 2 Dec 12 12:33:30 node1 kernel: bond0: (slave enp4s3): Rx Machine: Port=2, Last State=6, Curr State=6 Dec 12 12:33:30 node1 kernel: bond0: (slave enp4s3): partner sync=1 Dec 12 12:33:30 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:30 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25 Dec 12 12:33:30 node1 kernel: bond0: bond_should_notify_peers: slave enp0s25
+++
This is confusing and can also clutter up debug logs. Print logs only when the peer notification happens.
--- drivers/net/bonding/bond_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +3 -3
@@ -785,14 +785,14 @@ static bool bond_should_notify_peers(struct bonding *bond) slave =rcu_dereference (bond->curr_active_slave);rcu_read_unlock (); -netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , - slave ? slave->dev->name :"NULL" ); -if (!slave || !bond->send_peer_notif || !netif_carrier_ok (bond->dev) ||test_bit (__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))return false; +netdev_dbg (bond->dev,"bond_should_notify_peers: slave %s\n" , + slave ? slave->dev->name :"NULL" ); +return true; }
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 15/29 media: igorplugusb: receiver overflow should be reported
In reply to Sasha LevinFrom: Sean Young <[email protected]>
[ Upstream commit 8fede658e7ddb605bbd68ed38067ddb0af033db4 ]
Without this, some IR will be missing mid-stream and we might decode something which never really occurred.
--- drivers/media/rc/igorplugusb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/rc/igorplugusb.c +3 -1
@@ -73,9 +73,11 @@ static void igorplugusb_irdata(struct igorplugusb *ir, unsigned len)if (start >= len) {dev_err (ir->dev,"receive overflow invalid: %u" , overflow); }else { -if (overflow >0 ) +if (overflow >0 ) {dev_warn (ir->dev,"receive overflow, at least %u lost" , overflow); +ir_raw_event_reset (ir->rc); + } do { rawir.duration = ir->buf_in[i] * 85333;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 16/29 media: saa7146: hexium_gemini: Fix a NULL pointer dereference in hexium_attach()
In reply to Sasha LevinFrom: Zhou Qingyang <[email protected]>
[ Upstream commit 3af86b046933ba513d08399dba0d4d8b50d607d0 ]
In hexium_attach(dev, info), saa7146_vv_init() is called to allocate a new memory for dev->vv_data. saa7146_vv_release() will be called on failure of saa7146_register_device(). There is a dereference of dev->vv_data in saa7146_vv_release(), which could lead to a NULL pointer dereference on failure of saa7146_vv_init().
Fix this bug by adding a check of saa7146_vv_init().
This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug.
Builds with CONFIG_VIDEO_HEXIUM_GEMINI=m show no new warnings, and our static analyzer no longer warns about this code.
--- drivers/media/common/saa7146/saa7146_fops.c | 2 +- drivers/media/pci/saa7146/hexium_gemini.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/media/common/saa7146/saa7146_fops.c +1 -1
@@ -524,7 +524,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)ERR ("out of memory. aborting.\n" );kfree (vv);v4l2_ctrl_handler_free (hdl); -return -1 ; +return -ENOMEM ; } saa7146_video_uops.init (dev,vv);
drivers/media/pci/saa7146/hexium_gemini.c +6 -1
@@ -296,7 +296,12 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_dhexium_set_input (hexium,0 ); hexium->cur_input =0 ; -saa7146_vv_init (dev, &vv_data); + ret =saa7146_vv_init (dev, &vv_data); +if (ret) { +i2c_del_adapter (&hexium->i2c_adapter); +kfree (hexium); +return ret; + } vv_data.vid_ops.vidioc_enum_input = vidioc_enum_input; vv_data.vid_ops.vidioc_g_input = vidioc_g_input;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 17/29 usb: hub: Add delay for SuperSpeed hub resume to let links transit to U0
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 00558586382891540c59c9febc671062425a6e47 ]
When a new USB device gets plugged to nested hubs, the affected hub, which connects to usb 2-1.4-port2, doesn't report there's any change, hence the nested hubs go back to runtime suspend like nothing happened:
[ 281.032951] usb usb2: usb wakeup-resume [ 281.032959] usb usb2: usb auto-resume [ 281.032974] hub 2-0:1.0: hub_resume [ 281.033011] usb usb2-port1: status 0263 change 0000 [ 281.033077] hub 2-0:1.0: state 7 ports 4 chg 0000 evt 0000 [ 281.049797] usb 2-1: usb wakeup-resume [ 281.069800] usb 2-1: Waited 0ms for CONNECT [ 281.069810] usb 2-1: finish resume [ 281.070026] hub 2-1:1.0: hub_resume [ 281.070250] usb 2-1-port4: status 0203 change 0000 [ 281.070272] usb usb2-port1: resume, status 0 [ 281.070282] hub 2-1:1.0: state 7 ports 4 chg 0010 evt 0000 [ 281.089813] usb 2-1.4: usb wakeup-resume [ 281.109792] usb 2-1.4: Waited 0ms for CONNECT [ 281.109801] usb 2-1.4: finish resume [ 281.109991] hub 2-1.4:1.0: hub_resume [ 281.110147] usb 2-1.4-port2: status 0263 change 0000 [ 281.110234] usb 2-1-port4: resume, status 0 [ 281.110239] usb 2-1-port4: status 0203, change 0000, 10.0 Gb/s [ 281.110266] hub 2-1.4:1.0: state 7 ports 4 chg 0000 evt 0000 [ 281.110426] hub 2-1.4:1.0: hub_suspend [ 281.110565] usb 2-1.4: usb auto-suspend, wakeup 1 [ 281.130998] hub 2-1:1.0: hub_suspend [ 281.137788] usb 2-1: usb auto-suspend, wakeup 1 [ 281.142935] hub 2-0:1.0: state 7 ports 4 chg 0000 evt 0000 [ 281.177828] usb 2-1: usb wakeup-resume [ 281.197839] usb 2-1: Waited 0ms for CONNECT [ 281.197850] usb 2-1: finish resume [ 281.197984] hub 2-1:1.0: hub_resume [ 281.198203] usb 2-1-port4: status 0203 change 0000 [ 281.198228] usb usb2-port1: resume, status 0 [ 281.198237] hub 2-1:1.0: state 7 ports 4 chg 0010 evt 0000 [ 281.217835] usb 2-1.4: usb wakeup-resume [ 281.237834] usb 2-1.4: Waited 0ms for CONNECT [ 281.237845] usb 2-1.4: finish resume [ 281.237990] hub 2-1.4:1.0: hub_resume [ 281.238067] usb 2-1.4-port2: status 0263 change 0000 [ 281.238148] usb 2-1-port4: resume, status 0 [ 281.238152] usb 2-1-port4: status 0203, change 0000, 10.0 Gb/s [ 281.238166] hub 2-1.4:1.0: state 7 ports 4 chg 0000 evt 0000 [ 281.238385] hub 2-1.4:1.0: hub_suspend [ 281.238523] usb 2-1.4: usb auto-suspend, wakeup 1 [ 281.258076] hub 2-1:1.0: hub_suspend [ 281.265744] usb 2-1: usb auto-suspend, wakeup 1 [ 281.285976] hub 2-0:1.0: hub_suspend [ 281.285988] usb usb2: bus auto-suspend, wakeup 1
USB 3.2 spec, 9.2.5.4 "Changing Function Suspend State" says that "If the link is in a non-U0 state, then the device must transition the link to U0 prior to sending the remote wake message", but the hub only transits the link to U0 after signaling remote wakeup.
So be more forgiving and use a 20ms delay to let the link transit to U0 for remote wakeup.
--- drivers/usb/core/hub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +4 -1
@@ -1054,7 +1054,10 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) }else {hub_power_on (hub, true); } - } +/* Give some time on remote wakeup to let links to transit to U0 */ + }else if (hub_is_superspeed (hub->hdev)) +msleep (20 ); + init2:/*
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 18/29 ath9k: Fix out-of-bound memcpy in ath9k_hif_usb_rx_stream
In reply to Sasha LevinFrom: Zekun Shen <[email protected]>
[ Upstream commit 6ce708f54cc8d73beca213cec66ede5ce100a781 ]
Large pkt_len can lead to out-out-bound memcpy. Current ath9k_hif_usb_rx_stream allows combining the content of two urb inputs to one pkt. The first input can indicate the size of the pkt. Any remaining size is saved in hif_dev->rx_remain_len. While processing the next input, memcpy is used with rx_remain_len.
4-byte pkt_len can go up to 0xffff, while a single input is 0x4000 maximum in size (MAX_RX_BUF_SIZE). Thus, the patch adds a check for pkt_len which must not exceed 2 * MAX_RX_BUG_SIZE.
BUG: KASAN: slab-out-of-bounds in ath9k_hif_usb_rx_cb+0x490/0xed7 [ath9k_htc] Read of size 46393 at addr ffff888018798000 by task kworker/0:1/23 CPU: 0 PID: 23 Comm: kworker/0:1 Not tainted 5.6.0 #63 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.2-0-g5f4c7b1-prebuilt.qemu-project.org 04/01/2014 Workqueue: events request_firmware_work_func Call Trace: <IRQ> dump_stack+0x76/0xa0 print_address_description.constprop.0+0x16/0x200 ? ath9k_hif_usb_rx_cb+0x490/0xed7 [ath9k_htc] ? ath9k_hif_usb_rx_cb+0x490/0xed7 [ath9k_htc] __kasan_report.cold+0x37/0x7c ? ath9k_hif_usb_rx_cb+0x490/0xed7 [ath9k_htc] kasan_report+0xe/0x20 check_memory_region+0x15a/0x1d0 memcpy+0x20/0x50 ath9k_hif_usb_rx_cb+0x490/0xed7 [ath9k_htc] ? hif_usb_mgmt_cb+0x2d9/0x2d9 [ath9k_htc] ? _raw_spin_lock_irqsave+0x7b/0xd0 ? _raw_spin_trylock_bh+0x120/0x120 ? __usb_unanchor_urb+0x12f/0x210 __usb_hcd_giveback_urb+0x1e4/0x380 usb_giveback_urb_bh+0x241/0x4f0 ? __hrtimer_run_queues+0x316/0x740 ? __usb_hcd_giveback_urb+0x380/0x380 tasklet_action_common.isra.0+0x135/0x330 __do_softirq+0x18c/0x634 irq_exit+0x114/0x140 smp_apic_timer_interrupt+0xde/0x380 apic_timer_interrupt+0xf/0x20
I found the bug using a custome USBFuzz port. It's a research work to fuzz USB stack/drivers. I modified it to fuzz ath9k driver only, providing hand-crafted usb descriptors to QEMU.
After fixing the value of pkt_tag to ATH_USB_RX_STREAM_MODE_TAG in QEMU emulation, I found the KASAN report. The bug is triggerable whenever pkt_len is above two MAX_RX_BUG_SIZE. I used the same input that crashes to test the driver works when applying the patch.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +7 -0
@@ -586,6 +586,13 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,return ; } +if (pkt_len >2 *MAX_RX_BUF_SIZE ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: invalid pkt_len (%x)\n" , pkt_len); +RX_STAT_INC (skb_dropped); +return ; + } + pad_len =4 - (pkt_len &0x3 );if (pad_len ==4 ) pad_len =0 ;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 19/29 um: registers: Rename function names to avoid conflicts and build problems
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 077b7320942b64b0da182aefd83c374462a65535 ]
The function names init_registers() and restore_registers() are used in several net/ethernet/ and gpu/drm/ drivers for other purposes (not calls to UML functions), so rename them.
This fixes multiple build errors.
--- arch/um/include/shared/registers.h | 4 ++-- arch/um/os-Linux/registers.c | 4 ++-- arch/um/os-Linux/start_up.c | 2 +- arch/x86/um/syscalls_64.c | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-)
arch/um/include/shared/registers.h +2 -2
@@ -14,8 +14,8 @@ extern int restore_fp_registers(int pid, unsigned long *fp_regs);extern int save_fpx_registers (int pid,unsigned long *fp_regs);extern int restore_fpx_registers (int pid,unsigned long *fp_regs);extern int save_registers (int pid,struct uml_pt_regs *regs); -extern int restore_registers (int pid,struct uml_pt_regs *regs); -extern int init_registers (int pid); +extern int restore_pid_registers (int pid,struct uml_pt_regs *regs); +extern int init_pid_registers (int pid);extern void get_safe_registers (unsigned long *regs,unsigned long *fp_regs);extern unsigned long get_thread_reg (int reg,jmp_buf *buf);extern int get_fp_registers (int pid,unsigned long *regs);
arch/um/os-Linux/registers.c +2 -2
@@ -21,7 +21,7 @@ int save_registers(int pid, struct uml_pt_regs *regs)return 0 ; } -int restore_registers (int pid,struct uml_pt_regs *regs) +int restore_pid_registers (int pid,struct uml_pt_regs *regs) {int err;
@@ -36,7 +36,7 @@ int restore_registers(int pid, struct uml_pt_regs *regs)static unsigned long exec_regs[MAX_REG_NR ];static unsigned long exec_fp_regs[FP_SIZE ]; -int init_registers (int pid) +int init_pid_registers (int pid) {int err;
arch/um/os-Linux/start_up.c +1 -1
@@ -334,7 +334,7 @@ void __init os_early_checks(void)check_tmpexec (); pid =start_ptraced_child (); -if (init_registers (pid)) +if (init_pid_registers (pid))fatal ("Failed to initialize default registers" );stop_ptraced_child (pid,1 ,1 ); }
arch/x86/um/syscalls_64.c +2 -1
@@ -9,6 +9,7 @@#include <linux/uaccess.h> #include <asm/prctl.h> /* XXX This should get the constants from libc */ #include <os.h> +#include <registers.h> long arch_prctl (struct task_struct *task,int code,unsigned long __user *addr) {
@@ -32,7 +33,7 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)switch (code) {case ARCH_SET_FS :case ARCH_SET_GS : - ret =restore_registers (pid, ¤t->thread.regs.regs); + ret =restore_pid_registers (pid, ¤t->thread.regs.regs);if (ret)return ret;break ;
Signature · 7 lines
2.34.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Johannes Berg
maintainerRe: [PATCH AUTOSEL 4.4 19/29] um: registers: Rename function names to avoid conflicts and build problems
Quoted 9 lines · Sasha Levin
From: Randy Dunlap <[email protected]>
[ Upstream commit
077b7320942b64b0da182aefd83c374462a65535]The function names
init_registers()andrestore_registers()are used in severalnet/ethernet/and gpu/drm/ drivers for other purposes (not calls to UML functions), so rename them.This fixes multiple build errors.
FWIW, this is certainly fine to backport, but also almost certainly not
necessary: most likely all those drivers cannot be built before 5.14 (commit 68f5d3f3b654 ("um: add PCI over virtio emulation driver")) anyway.
johannes
Sasha Levin
maintainerPATCH 20/29 ACPICA: Utilities: Avoid deleting the same object twice in a row
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 1cdfe9e346b4c5509ffe19ccde880fd259d9f7a3 ]
ACPICA commit c11af67d8f7e3d381068ce7771322f2b5324d687
If original_count is 0 in acpi_ut_update_ref_count (), acpi_ut_delete_internal_obj () is invoked for the target object, which is incorrect, because that object has been deleted once already and the memory allocated to store it may have been reclaimed and allocated for a different purpose by the host OS. Moreover, a confusing debug message following the "Reference Count is already zero, cannot decrement" warning is printed in that case.
To fix this issue, make acpi_ut_update_ref_count () return after finding that original_count is 0 and printing the above warning.
--- drivers/acpi/acpica/utdelete.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/utdelete.c +1 -0
@@ -439,6 +439,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)ACPI_WARNING ((AE_INFO ,"Obj %p, Reference Count is already zero, cannot decrement\n" , object)); +return ; } ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 21/29 ACPICA: Executer: Fix the REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R()
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 24ea5f90ec9548044a6209685c5010edd66ffe8f ]
ACPICA commit d984f12041392fa4156b52e2f7e5c5e7bc38ad9e
If Operand[0] is a reference of the ACPI_REFCLASS_REFOF class, acpi_ex_opcode_1A_0T_1R () calls acpi_ns_get_attached_object () to obtain return_desc which may require additional resolution with the help of acpi_ex_read_data_from_field (). If the latter fails, the reference counter of the original return_desc is decremented which is incorrect, because acpi_ns_get_attached_object () does not increment the reference counter of the object returned by it.
This issue may lead to premature deletion of the attached object while it is still attached and a use-after-free and crash in the host OS. For example, this may happen when on evaluation of ref_of() a local region field where there is no registered handler for the given Operation Region.
Fix it by making acpi_ex_opcode_1A_0T_1R () return Status right away after a acpi_ex_read_data_from_field () failure.
--- drivers/acpi/acpica/exoparg1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/acpica/exoparg1.c +2 -1
@@ -1016,7 +1016,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) (walk_state, return_desc, &temp_desc);if (ACPI_FAILURE (status)) { - goto cleanup; +return_ACPI_STATUS + (status); } return_desc = temp_desc;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 22/29 btrfs: remove BUG_ON() in find_parent_nodes()
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit fcba0120edf88328524a4878d1d6f4ad39f2ec81 ]
We search for an extent entry with .offset = -1, which shouldn't be a thing, but corruption happens. Add an ASSERT() for the developers, return -EUCLEAN for mortals.
--- fs/btrfs/backref.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/backref.c +6 -1
@@ -975,7 +975,12 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ret =btrfs_search_slot (trans, fs_info->extent_root, &key, path,0 ,0 );if (ret <0 ) goto out; -BUG_ON (ret ==0 ); +if (ret ==0 ) { +/* This shouldn't happen, indicates a bug or fs corruption. */ +ASSERT (ret !=0 ); + ret = -EUCLEAN ; + goto out; + }#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS if (trans && likely(trans->type != __TRANS_DUMMY) &&
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 23/29 btrfs: remove BUG_ON(!eie) in find_parent_nodes
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit 9f05c09d6baef789726346397438cca4ec43c3ee ]
If we're looking for leafs that point to a data extent we want to record the extent items that point at our bytenr. At this point we have the reference and we know for a fact that this leaf should have a reference to our bytenr. However if there's some sort of corruption we may not find any references to our leaf, and thus could end up with eie == NULL. Replace this BUG_ON() with an ASSERT() and then return -EUCLEAN for the mortals.
--- fs/btrfs/backref.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/btrfs/backref.c +11 -3
@@ -1109,10 +1109,18 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, goto out;if (!ret && extent_item_pos) {/* -* we've recorded that parent, so we must extend -* its inode list here +* We've recorded that parent, so we must extend +* its inode list here. +* +* However if there was corruption we may not +* have found an eie, return an error in this +* case. */ -BUG_ON (!eie); +ASSERT (eie); +if (!eie) { + ret = -EUCLEAN ; + goto out; + }while (eie->next) eie = eie->next; eie->next = ref->inode_list;
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 24/29 net: mdio: Demote probed message to debug print
In reply to Sasha LevinFrom: Florian Fainelli <[email protected]>
[ Upstream commit 7590fc6f80ac2cbf23e6b42b668bbeded070850b ]
On systems with large numbers of MDIO bus/muxes the message indicating that a given MDIO bus has been successfully probed is repeated for as many buses we have, which can eat up substantial boot time for no reason, demote to a debug print.
--- drivers/net/phy/mdio_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio_bus.c +1 -1
@@ -295,7 +295,7 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) } bus->state =MDIOBUS_REGISTERED ; -pr_info ("%s: probed\n" , bus->name); +dev_dbg (&bus->dev,"probed\n" );return 0 ; error:
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 25/29 dm btree: add a defensive bounds check to insert_at()
In reply to Sasha LevinFrom: Joe Thornber <[email protected]>
[ Upstream commit 85bca3c05b6cca31625437eedf2060e846c4bbad ]
Corrupt metadata could trigger an out of bounds write.
--- drivers/md/persistent-data/dm-btree.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/persistent-data/dm-btree.c +5 -3
@@ -83,14 +83,16 @@ void inc_children(struct dm_transaction_manager *tm, struct btree_node *n, }static int insert_at (size_t value_size,struct btree_node *node,unsigned index, -uint64_t key,void *value) -__dm_written_to_disk (value) +uint64_t key,void *value) +__dm_written_to_disk (value) {uint32_t nr_entries =le32_to_cpu (node->header.nr_entries); +uint32_t max_entries =le32_to_cpu (node->header.max_entries);__le64 key_le =cpu_to_le64 (key);if (index > nr_entries || - index >=le32_to_cpu (node->header.max_entries)) { + index >= max_entries || + nr_entries >= max_entries) {DMERR ("too many entries in btree node for insert" );__dm_unbless_for_disk (value);return -ENOMEM ;
Signature · 7 lines
2.34.1 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Sasha Levin
maintainerPATCH 26/29 dm space map common: add bounds check to sm_ll_lookup_bitmap()
In reply to Sasha LevinFrom: Joe Thornber <[email protected]>
[ Upstream commit cba23ac158db7f3cd48a923d6861bee2eb7a2978 ]
Corrupted metadata could warrant returning error from sm_ll_lookup_bitmap().
--- drivers/md/persistent-data/dm-space-map-common.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/persistent-data/dm-space-map-common.c +5 -0
@@ -279,6 +279,11 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result)struct disk_index_entry ie_disk;struct dm_block *blk; +if (b >= ll->nr_blocks) { +DMERR_LIMIT ("metadata block out of bounds" ); +return -EINVAL ; + } + b =do_div (index, ll->entries_per_block); r = ll->load_ie (ll, index, &ie_disk);if (r <0 )
Signature · 7 lines
2.34.1 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Sasha Levin
maintainerPATCH 27/29 serial: pl010: Drop CR register reset on set_termios
In reply to Sasha LevinFrom: Lukas Wunner <[email protected]>
[ Upstream commit 08a0c6dff91c965e39905cf200d22db989203ccb ]
pl010_set_termios() briefly resets the CR register to zero.
Where does this register write come from?
The PL010 driver's IRQ handler ambauart_int() originally modified the CR register without holding the port spinlock. ambauart_set_termios() also modified that register. To prevent concurrent read-modify-writes by the IRQ handler and to prevent transmission while changing baudrate, ambauart_set_termios() had to disable interrupts. That is achieved by writing zero to the CR register.
However in 2004 the PL010 driver was amended to acquire the port spinlock in the IRQ handler, obviating the need to disable interrupts in ->set_termios():
https://git.kernel.org/history/history/c/157c0342e591
That rendered the CR register write obsolete. Drop it.
--- drivers/tty/serial/amba-pl010.c | 3 --- 1 file changed, 3 deletions(-)
drivers/tty/serial/amba-pl010.c +0 -3
@@ -465,14 +465,11 @@ pl010_set_termios(struct uart_port *port, struct ktermios *termios,if ((termios->c_cflag &CREAD ) ==0 ) uap->port.ignore_status_mask |=UART_DUMMY_RSR_RX ; -/* first, disable everything */ old_cr =readb (uap->port.membase +UART010_CR ) & ~UART010_CR_MSIE ;if (UART_ENABLE_MS (port, termios->c_cflag)) old_cr |=UART010_CR_MSIE ; -writel (0 , uap->port.membase +UART010_CR ); -/* Set baud rate */ quot -=1 ;writel ((quot &0xf00 ) >>8 , uap->port.membase +UART010_LCRM );
Signature · 1 line
2.34.1
Re: [PATCH AUTOSEL 4.4 27/29] serial: pl010: Drop CR register reset on set_termios
Quoted 15 lines · Sasha Levin
From: Lukas Wunner <[email protected]>
[ Upstream commit
08a0c6dff91c965e39905cf200d22db989203ccb]
pl010_set_termios()briefly resets the CR register to zero.Where does this register write come from?
The PL010 driver's IRQ handler
ambauart_int()originally modified the CR register without holding the port spinlock.ambauart_set_termios()also modified that register. To prevent concurrent read-modify-writes by the IRQ handler and to prevent transmission while changing baudrate,ambauart_set_termios()had to disable interrupts. That is achieved by writing zero to the CR register.
Quoted 6 lines
However in 2004 the PL010 driver was amended to acquire the port spinlock in the IRQ handler, obviating the need to disable interrupts in ->set_termios():
https://git.kernel.org/history/history/c/157c0342e591That rendered the CR register write obsolete. Drop it.
I'd recommend against backporting this particular patch for pl010 as it's merely a cleanup that eases future work on the driver, but doesn't actually fix anything.
You've also auto-selected a patch for the pl011 driver with the same subject. That other patch *does* actually fix an rs485 Transmit Enable glitch, so backporting it makes sense.
Thanks,
Lukas
Quoted 30 lines
Cc Russell King <[email protected]>Signed-off-by Lukas Wunner <[email protected]>Link https://lore.kernel.org/r/fcaff16e5b1abb4cc3da5a2879ac13f278b99ed0.1641128728.git.lukas@wunner.de open hereSigned-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/tty/serial/amba-pl010.c | 3 --- 1 file changed, 3 deletions(-)drivers/tty/serial/amba-pl010.c +0
-3@@ -465,14 +465,11 @@ pl010_set_termios(struct uart_port *port, struct ktermios *termios,if ((termios->c_cflag &CREAD ) ==0 ) uap->port.ignore_status_mask |=UART_DUMMY_RSR_RX ; -/* first, disable everything */ old_cr =readb (uap->port.membase +UART010_CR ) & ~UART010_CR_MSIE ;if (UART_ENABLE_MS (port, termios->c_cflag)) old_cr |=UART010_CR_MSIE ; -writel (0 , uap->port.membase +UART010_CR ); -/* Set baud rate */ quot -=1 ;writel ((quot &0xf00 ) >>8 , uap->port.membase +UART010_LCRM );Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 28/29 serial: core: Keep mctrl register state and cached copy in sync
In reply to Sasha LevinFrom: Lukas Wunner <[email protected]>
[ Upstream commit 93a770b7e16772530196674ffc79bb13fa927dc6 ]
struct uart_port contains a cached copy of the Modem Control signals. It is used to skip register writes in uart_update_mctrl() if the new signal state equals the old signal state. It also avoids a register read to obtain the current state of output signals.
When a uart_port is registered, uart_configure_port() changes signal state but neglects to keep the cached copy in sync. That may cause a subsequent register write to be incorrectly skipped. Fix it before it trips somebody up.
This behavior has been present ever since the serial core was introduced in 2002:
https://git.kernel.org/history/history/c/33c0d1b0c3eb
So far it was never an issue because the cached copy is initialized to 0 by kzalloc() and when uart_configure_port() is executed, at most DTR has been set by uart_set_options() or sunsu_console_setup(). Therefore, a stable designation seems unnecessary.
--- drivers/tty/serial/serial_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +2 -1
@@ -2247,7 +2247,8 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,* We probably don't need a spinlock around this, but */ spin_lock_irqsave (&port->lock, flags); - port->ops->set_mctrl (port, port->mctrl &TIOCM_DTR ); + port->mctrl &=TIOCM_DTR ; + port->ops->set_mctrl (port, port->mctrl);spin_unlock_irqrestore (&port->lock, flags);/*
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.4 28/29] serial: core: Keep mctrl register state and cached copy in sync
Quoted 14 lines · Sasha Levin
From: Lukas Wunner <[email protected]>
[ Upstream commit
93a770b7e16772530196674ffc79bb13fa927dc6]struct
uart_portcontains a cached copy of the Modem Control signals. It is used to skip register writes inuart_update_mctrl()if the new signal state equals the old signal state. It also avoids a register read to obtain the current state of output signals.When a
uart_portis registered,uart_configure_port()changes signal state but neglects to keep the cached copy in sync. That may cause a subsequent register write to be incorrectly skipped. Fix it before it trips somebody up.
Quoted 8 lines
This behavior has been present ever since the serial core was introduced in 2002:
https://git.kernel.org/history/history/c/33c0d1b0c3ebSo far it was never an issue because the cached copy is initialized to 0 by
kzalloc()and whenuart_configure_port()is executed, at most DTR has been set byuart_set_options()orsunsu_console_setup(). Therefore, a stable designation seems unnecessary.
As per the text here, this is not needed in any stable trees, so can you please drop it from all of your autosel queues now?
thanks,
greg k-h
Sasha Levin
maintainerPATCH 29/29 parisc: Avoid calling faulthandler_disabled() twice
In reply to Sasha LevinFrom: John David Anglin <[email protected]>
[ Upstream commit 9e9d4b460f23bab61672eae397417d03917d116c ]
In handle_interruption(), we call faulthandler_disabled() to check whether the fault handler is not disabled. If the fault handler is disabled, we immediately call do_page_fault(). It then calls faulthandler_disabled(). If disabled, do_page_fault() attempts to fixup the exception by jumping to no_context:
no_context:
if (!user_mode(regs) && fixup_exception(regs)) {
return;
}
parisc_terminate("Bad Address (null pointer deref?)", regs, code, address);Apart from the error messages, the two blocks of code perform the same function.
We can avoid two calls to faulthandler_disabled() by a simple revision to the code in handle_interruption().
Note: I didn't try to fix the formatting of this code block.
--- arch/parisc/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/traps.c +1 -1
@@ -796,7 +796,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)* unless pagefault_disable() was called before. */ -if (fault_space ==0 && !faulthandler_disabled ()) +if (faulthandler_disabled () || fault_space ==0 ) {/* Clean up and return if in exception table. */ if (fixup_exception (regs))
Signature · 1 line
2.34.1