5.15.212-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 806/843 hfs/hfsplus: prevent getting negative values of offset/length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
[ Upstream commit 00c14a09a70e10ae18eb3707d0059291425c04bd ]
The syzbot reported KASAN out-of-bounds issue inhfs_bnode_move():
[ 45.588165][ T9821] hfs: dst 14, src 65536, len -65536 [ 45.588895][ T9821] ================================================================== [ 45.590114][ T9821] BUG: KASAN: out-of-bounds in hfs_bnode_move+0xfd/0x140 [ 45.591127][ T9821] Read of size 18446744073709486080 at addr ffff888035935400 by task repro/9821 [ 45.592207][ T9821] [ 45.592420][ T9821] CPU: 0 UID: 0 PID: 9821 Comm: repro Not tainted 6.16.0-rc7-dirty #42 PREEMPT(full) [ 45.592428][ T9821] Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 45.592431][ T9821] Call Trace: [ 45.592434][ T9821] <TASK> [ 45.592437][ T9821] dump_stack_lvl+0x1c1/0x2a0 [ 45.592446][ T9821] ? __virt_addr_valid+0x1c8/0x5c0 [ 45.592454][ T9821] ? __pfx_dump_stack_lvl+0x10/0x10 [ 45.592461][ T9821] ? rcu_is_watching+0x15/0xb0 [ 45.592469][ T9821] ? lock_release+0x4b/0x3e0 [ 45.592476][ T9821] ? __virt_addr_valid+0x1c8/0x5c0 [ 45.592483][ T9821] ? __virt_addr_valid+0x4a5/0x5c0 [ 45.592491][ T9821] print_report+0x17e/0x7c0 [ 45.592497][ T9821] ? __virt_addr_valid+0x1c8/0x5c0 [ 45.592504][ T9821] ? __virt_addr_valid+0x4a5/0x5c0 [ 45.592511][ T9821] ? __phys_addr+0xd3/0x180 [ 45.592519][ T9821] ? hfs_bnode_move+0xfd/0x140 [ 45.592526][ T9821] kasan_report+0x147/0x180 [ 45.592531][ T9821] ? _printk+0xcf/0x120 [ 45.592537][ T9821] ? hfs_bnode_move+0xfd/0x140 [ 45.592544][ T9821] ? hfs_bnode_move+0xfd/0x140 [ 45.592552][ T9821] kasan_check_range+0x2b0/0x2c0 [ 45.592557][ T9821] ? hfs_bnode_move+0xfd/0x140 [ 45.592565][ T9821] __asan_memmove+0x29/0x70 [ 45.592572][ T9821] hfs_bnode_move+0xfd/0x140 [ 45.592580][ T9821] hfs_brec_remove+0x473/0x560 [ 45.592589][ T9821] hfs_cat_move+0x6fb/0x960 [ 45.592598][ T9821] ? __pfx_hfs_cat_move+0x10/0x10 [ 45.592607][ T9821] ? seqcount_lockdep_reader_access+0x122/0x1c0 [ 45.592614][ T9821] ? lockdep_hardirqs_on+0x9c/0x150 [ 45.592631][ T9821] ? __lock_acquire+0xaec/0xd80 [ 45.592641][ T9821] hfs_rename+0x1dc/0x2d0 [ 45.592649][ T9821] ? __pfx_hfs_rename+0x10/0x10 [ 45.592657][ T9821] vfs_rename+0xac6/0xed0 [ 45.592664][ T9821] ? __pfx_vfs_rename+0x10/0x10 [ 45.592670][ T9821] ? d_alloc+0x144/0x190 [ 45.592677][ T9821] ? bpf_lsm_path_rename+0x9/0x20 [ 45.592683][ T9821] ? security_path_rename+0x17d/0x490 [ 45.592691][ T9821] do_renameat2+0x890/0xc50 [ 45.592699][ T9821] ? __pfx_do_renameat2+0x10/0x10 [ 45.592707][ T9821] ? getname_flags+0x1e5/0x540 [ 45.592714][ T9821] __x64_sys_rename+0x82/0x90 [ 45.592720][ T9821] ? entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 45.592725][ T9821] do_syscall_64+0xf3/0x3a0 [ 45.592741][ T9821] ? exc_page_fault+0x9f/0xf0 [ 45.592748][ T9821] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 45.592754][ T9821] RIP: 0033:0x7f7f73fe3fc9 [ 45.592760][ T9821] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 48 [ 45.592765][ T9821] RSP: 002b:00007ffc7e116cf8 EFLAGS: 00000283 ORIG_RAX: 0000000000000052 [ 45.592772][ T9821] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f7f73fe3fc9 [ 45.592776][ T9821] RDX: 0000200000000871 RSI: 0000200000000780 RDI: 00002000000003c0 [ 45.592781][ T9821] RBP: 00007ffc7e116d00 R08: 0000000000000000 R09: 00007ffc7e116d30 [ 45.592784][ T9821] R10: fffffffffffffff0 R11: 0000000000000283 R12: 00005557e81f8250 [ 45.592788][ T9821] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 45.592795][ T9821] </TASK> [ 45.592797][ T9821] [ 45.619721][ T9821] The buggy address belongs to the physical page: [ 45.620300][ T9821] page: refcount:1 mapcount:1 mapping:0000000000000000 index:0x559a88174 pfn:0x35935 [ 45.621150][ T9821] memcg:ffff88810a1d5b00 [ 45.621531][ T9821] anon flags: 0xfff60000020838(uptodate|dirty|lru|owner_2|swapbacked|node=0|zone=1|lastcpupid=0x7ff) [ 45.622496][ T9821] raw: 00fff60000020838 ffffea0000d64d88 ffff888021753e10 ffff888029da0771 [ 45.623260][ T9821] raw: 0000000559a88174 0000000000000000 0000000100000000 ffff88810a1d5b00 [ 45.624030][ T9821] page dumped because: kasan: bad access detected [ 45.624602][ T9821] page_owner tracks the page as allocated [ 45.625115][ T9821] page last allocated via order 0, migratetype Movable, gfp_mask 0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO0 [ 45.626685][ T9821] post_alloc_hook+0x240/0x2a0 [ 45.627127][ T9821] get_page_from_freelist+0x2101/0x21e0 [ 45.627628][ T9821] __alloc_frozen_pages_noprof+0x274/0x380 [ 45.628154][ T9821] alloc_pages_mpol+0x241/0x4b0 [ 45.628593][ T9821] vma_alloc_folio_noprof+0xe4/0x210 [ 45.629066][ T9821] folio_prealloc+0x30/0x180 [ 45.629487][ T9821] __handle_mm_fault+0x34bd/0x5640 [ 45.629957][ T9821] handle_mm_fault+0x40e/0x8e0 [ 45.630392][ T9821] do_user_addr_fault+0xa81/0x1390 [ 45.630862][ T9821] exc_page_fault+0x76/0xf0 [ 45.631273][ T9821] asm_exc_page_fault+0x26/0x30 [ 45.631712][ T9821] page last free pid 5269 tgid 5269 stack trace: [ 45.632281][ T9821] free_unref_folios+0xc73/0x14c0 [ 45.632740][ T9821] folios_put_refs+0x55b/0x640 [ 45.633177][ T9821] free_pages_and_swap_cache+0x26d/0x510 [ 45.633685][ T9821] tlb_flush_mmu+0x3a0/0x680 [ 45.634105][ T9821] tlb_finish_mmu+0xd4/0x200 [ 45.634525][ T9821] exit_mmap+0x44c/0xb70 [ 45.634914][ T9821] __mmput+0x118/0x420 [ 45.635286][ T9821] exit_mm+0x1da/0x2c0 [ 45.635659][ T9821] do_exit+0x652/0x2330 [ 45.636039][ T9821] do_group_exit+0x21c/0x2d0 [ 45.636457][ T9821] __x64_sys_exit_group+0x3f/0x40 [ 45.636915][ T9821] x64_sys_call+0x21ba/0x21c0 [ 45.637342][ T9821] do_syscall_64+0xf3/0x3a0 [ 45.637756][ T9821] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 45.638290][ T9821] page has been migrated, last migrate reason: numa_misplaced [ 45.638956][ T9821] [ 45.639173][ T9821] Memory state around the buggy address: [ 45.639677][ T9821] ffff888035935300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 45.640397][ T9821] ffff888035935380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 45.641117][ T9821] >ffff888035935400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 45.641837][ T9821] ^ [ 45.642207][ T9821] ffff888035935480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 45.642929][ T9821] ffff888035935500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 45.643650][ T9821] ==================================================================
This commit [1] fixes the issue if an offset inside of b-tree node or length of the request is bigger than b-tree node. However, this fix is still not ready for negative values
of the offset or length. Moreover, negative values of the offset or length doesn't make sense for b-tree's operations. Because we could try to access the memory address outside of the beginning of memory page's addresses range. Also, using of negative values make logic very complicated, unpredictable, and we could access the wrong item(s)
in the b-tree node.
This patch changes b-tree interface by means of converting signed integer arguments of offset and length on u32 type. Such conversion has goal to prevent of using negative values unintentionally or by mistake in b-tree operations.
[1] 'commit a431930c9bac ("hfs: fix slab-out-of-bounds in hfs_bnode_read()")'
Stable-dep-of: 966cb76fb285 ("hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length")
--- fs/hfs/bfind.c | 2 - fs/hfs/bnode.c | 52 ++++++++++++++--------------- fs/hfs/brec.c | 2 - fs/hfs/btree.c | 2 - fs/hfs/btree.h | 71 ++++++++++++++++++++-------------------- fs/hfs/hfs_fs.h | 85 ++++++++++++++++++++++++++++-------------------- fs/hfs/inode.c | 2 - fs/hfsplus/bfind.c | 2 - fs/hfsplus/bnode.c | 60 ++++++++++++++++----------------- fs/hfsplus/brec.c | 2 - fs/hfsplus/btree.c | 2 - fs/hfsplus/hfsplus_fs.h | 38 ++++++++++----------- 12 files changed, 168 insertions(+), 152 deletions(-)
fs/hfs/bfind.c +1 -1
@@ -164,7 +164,7 @@ release:return res; } -int hfs_brec_read (struct hfs_find_data *fd,void *rec,int rec_len) +int hfs_brec_read (struct hfs_find_data *fd,void *rec,u32 rec_len) {int res;
fs/hfs/bnode.c +26 -26
172 lines not on this page · raw message
fs/hfs/brec.c +1 -1
@@ -62,7 +62,7 @@ u16 hfs_brec_keylen(struct hfs_bnode *noreturn retval; } -int hfs_brec_insert (struct hfs_find_data *fd,void *entry,int entry_len) +int hfs_brec_insert (struct hfs_find_data *fd,void *entry,u32 entry_len) {struct hfs_btree *tree;struct hfs_bnode *node, *new_node;
fs/hfs/btree.c +1 -1
@@ -221,7 +221,7 @@ static struct hfs_bnode *hfs_bmap_new_bm }/* Make sure @tree has enough space for the @rsvd_nodes */ -int hfs_bmap_reserve (struct hfs_btree *tree,int rsvd_nodes) +int hfs_bmap_reserve (struct hfs_btree *tree,u32 rsvd_nodes) {struct inode *inode = tree->inode;u32 count;
fs/hfs/btree.h +36 -35
84 lines not on this page · raw message
fs/hfs/hfs_fs.h +50 -35
121 lines not on this page · raw message
fs/hfs/inode.c +1 -1
@@ -50,7 +50,7 @@ static void hfs_write_failed(struct addr }static int hfs_write_begin (struct file *file,struct address_space *mapping, -loff_t pos,unsigned len,unsigned flags, +loff_t pos,unsigned int len,unsigned flags,struct page **pagep,void **fsdata) {int ret;
fs/hfsplus/bfind.c +1 -1
@@ -210,7 +210,7 @@ release:return res; } -int hfs_brec_read (struct hfs_find_data *fd,void *rec,int rec_len) +int hfs_brec_read (struct hfs_find_data *fd,void *rec,u32 rec_len) {int res;
fs/hfsplus/bnode.c +30 -30
207 lines not on this page · raw message
fs/hfsplus/brec.c +1 -1
@@ -60,7 +60,7 @@ u16 hfs_brec_keylen(struct hfs_bnode *noreturn retval; } -int hfs_brec_insert (struct hfs_find_data *fd,void *entry,int entry_len) +int hfs_brec_insert (struct hfs_find_data *fd,void *entry,u32 entry_len) {struct hfs_btree *tree;struct hfs_bnode *node, *new_node;
fs/hfsplus/btree.c +1 -1
@@ -343,7 +343,7 @@ static struct hfs_bnode *hfs_bmap_new_bm }/* Make sure @tree has enough space for the @rsvd_nodes */ -int hfs_bmap_reserve (struct hfs_btree *tree,int rsvd_nodes) +int hfs_bmap_reserve (struct hfs_btree *tree,u32 rsvd_nodes) {struct inode *inode = tree->inode;struct hfsplus_inode_info *hip =HFSPLUS_I (inode);
fs/hfsplus/hfsplus_fs.h +19 -19
@@ -388,21 +388,21 @@ u32 hfsplus_calc_btree_clump_size(u32 blstruct hfs_btree *hfs_btree_open (struct super_block *sb,u32 id);void hfs_btree_close (struct hfs_btree *tree);int hfs_btree_write (struct hfs_btree *tree); -int hfs_bmap_reserve (struct hfs_btree *tree,int rsvd_nodes); +int hfs_bmap_reserve (struct hfs_btree *tree,u32 rsvd_nodes);struct hfs_bnode *hfs_bmap_alloc (struct hfs_btree *tree);void hfs_bmap_free (struct hfs_bnode *node);/* bnode.c */ -void hfs_bnode_read (struct hfs_bnode *node,void *buf,int off,int len); -u16 hfs_bnode_read_u16 (struct hfs_bnode *node,int off); -u8 hfs_bnode_read_u8 (struct hfs_bnode *node,int off); -void hfs_bnode_read_key (struct hfs_bnode *node,void *key,int off); -void hfs_bnode_write (struct hfs_bnode *node,void *buf,int off,int len); -void hfs_bnode_write_u16 (struct hfs_bnode *node,int off,u16 data); -void hfs_bnode_clear (struct hfs_bnode *node,int off,int len); -void hfs_bnode_copy (struct hfs_bnode *dst_node,int dst, -struct hfs_bnode *src_node,int src,int len); -void hfs_bnode_move (struct hfs_bnode *node,int dst,int src,int len); +void hfs_bnode_read (struct hfs_bnode *node,void *buf,u32 off,u32 len); +u16 hfs_bnode_read_u16 (struct hfs_bnode *node,u32 off); +u8 hfs_bnode_read_u8 (struct hfs_bnode *node,u32 off); +void hfs_bnode_read_key (struct hfs_bnode *node,void *key,u32 off); +void hfs_bnode_write (struct hfs_bnode *node,void *buf,u32 off,u32 len); +void hfs_bnode_write_u16 (struct hfs_bnode *node,u32 off,u16 data); +void hfs_bnode_clear (struct hfs_bnode *node,u32 off,u32 len); +void hfs_bnode_copy (struct hfs_bnode *dst_node,u32 dst, +struct hfs_bnode *src_node,u32 src,u32 len); +void hfs_bnode_move (struct hfs_bnode *node,u32 dst,u32 src,u32 len);void hfs_bnode_dump (struct hfs_bnode *node);void hfs_bnode_unlink (struct hfs_bnode *node);struct hfs_bnode *hfs_bnode_findhash (struct hfs_btree *tree,u32 cnid);
@@ -417,7 +417,7 @@ bool hfs_bnode_need_zeroout(struct hfs_b/* brec.c */ u16 hfs_brec_lenoff (struct hfs_bnode *node,u16 rec,u16 *off);u16 hfs_brec_keylen (struct hfs_bnode *node,u16 rec); -int hfs_brec_insert (struct hfs_find_data *fd,void *entry,int entry_len); +int hfs_brec_insert (struct hfs_find_data *fd,void *entry,u32 entry_len);int hfs_brec_remove (struct hfs_find_data *fd);/* bfind.c */
@@ -430,7 +430,7 @@ int hfs_find_rec_by_key(struct hfs_bnodeint __hfs_brec_find (struct hfs_bnode *bnode,struct hfs_find_data *fd,search_strategy_t rec_found);int hfs_brec_find (struct hfs_find_data *fd,search_strategy_t do_key_compare); -int hfs_brec_read (struct hfs_find_data *fd,void *rec,int rec_len); +int hfs_brec_read (struct hfs_find_data *fd,void *rec,u32 rec_len);int hfs_brec_goto (struct hfs_find_data *fd,int cnt);/* catalog.c */
@@ -586,14 +586,14 @@ hfsplus_btree_lock_class(struct hfs_btre }static inline -bool is_bnode_offset_valid (struct hfs_bnode *node,int off) +bool is_bnode_offset_valid (struct hfs_bnode *node,u32 off) {bool is_valid = off < node->tree->node_size;if (!is_valid) {pr_err ("requested invalid offset: " "NODE: id %u, type %#x, height %u, " -"node_size %u, offset %d\n" , +"node_size %u, offset %u\n" , node->this, node->type, node->height, node->tree->node_size, off); }
@@ -602,7 +602,7 @@ bool is_bnode_offset_valid(struct hfs_bn }static inline -int check_and_correct_requested_length (struct hfs_bnode *node,int off,int len) +u32 check_and_correct_requested_length (struct hfs_bnode *node,u32 off,u32 len) {unsigned int node_size;
@@ -612,12 +612,12 @@ int check_and_correct_requested_length(s node_size = node->tree->node_size;if ((off + len) > node_size) { -int new_len = (int )node_size - off; +u32 new_len = node_size - off;pr_err ("requested length has been corrected: " "NODE: id %u, type %#x, height %u, " -"node_size %u, offset %d, " -"requested_len %d, corrected_len %d\n" , +"node_size %u, offset %u, " +"requested_len %u, corrected_len %u\n" , node->this, node->type, node->height, node->tree->node_size, off, len, new_len);
Greg Kroah-Hartman
maintainerPATCH 807/843 hfs/hfsplus: fix u32 overflow in check_and_correct_requested_length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit 966cb76fb2857a4242cab6ea2ea17acf818a3da7 ]
check_and_correct_requested_length() compares (off + len) against node_size using u32 arithmetic. When the caller passes a large len value (e.g. from an underflowed subtraction in hfs_brec_remove()), off + len can wrap past 2^32 and produce a small result, causing the bounds check to pass when it should fail.
For example, with off=14 and len=0xFFFFFFF2 (underflowed from data_off - keyoffset - size in hfs_brec_remove), off + len wraps to 6, which is less than a typical node_size of 512, so the check passes and the subsequent memmove reads ~4GB past the node buffer.
Fix this by widening the addition to u64 before comparing against node_size. This prevents the u32 wrap while keeping the logic straightforward.
--- fs/hfs/bnode.c | 2 +- fs/hfsplus/hfsplus_fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/hfs/bnode.c +1 -1
@@ -41,7 +41,7 @@ u32 check_and_correct_requested_length(s node_size = node->tree->node_size; -if ((off + len) > node_size) { +if ((u64 )off + len > node_size) {u32 new_len = node_size - off; pr_err("requested length has been corrected: "
fs/hfsplus/hfsplus_fs.h +1 -1
@@ -611,7 +611,7 @@ u32 check_and_correct_requested_length(s node_size = node->tree->node_size; -if ((off + len) > node_size) { +if ((u64 )off + len > node_size) {u32 new_len = node_size - off; pr_err("requested length has been corrected: "
Greg Kroah-Hartman
maintainerPATCH 808/843 xdp: introduce flags field in xdp_buff/xdp_frame
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 2e88d4ff03013937028f5397268b21e10cf68713 ]
Introduce flags field in xdp_frame and xdp_buffer data structures to define additional buffer features. At the moment the only supported buffer feature is frags bit (XDP_FLAGS_HAS_FRAGS). frags bit is used to specify if this is a linear buffer (XDP_FLAGS_HAS_FRAGS not set) or a frags frame (XDP_FLAGS_HAS_FRAGS set). In the latter case the driver is expected to initialize the skb_shared_info structure at the end of the first buffer to link together subsequent buffers belonging to the same frame.
Stable-dep-of: aa496720618f ("bpf: Reject fragmented frames in devmap")
--- include/net/xdp.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
include/net/xdp.h +29 -0
@@ -66,6 +66,10 @@ struct xdp_txq_info {struct net_device *dev; }; +enum xdp_buff_flags { +XDP_FLAGS_HAS_FRAGS =BIT (0 ),/* non-linear xdp buff */ +}; +struct xdp_buff {void *data;void *data_end;
@@ -74,13 +78,30 @@ struct xdp_buff {struct xdp_rxq_info *rxq;struct xdp_txq_info *txq;u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ +u32 flags;/* supported values defined in xdp_buff_flags */ }; +static __always_inline bool xdp_buff_has_frags(struct xdp_buff *xdp) +{ +return !!(xdp->flags &XDP_FLAGS_HAS_FRAGS ); +} + +static __always_inline void xdp_buff_set_frags_flag(struct xdp_buff *xdp) +{ + xdp->flags |=XDP_FLAGS_HAS_FRAGS ; +} + +static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp) +{ + xdp->flags &= ~XDP_FLAGS_HAS_FRAGS ; +} + static __always_inline voidxdp_init_buff (struct xdp_buff *xdp,u32 frame_sz,struct xdp_rxq_info *rxq) { xdp->frame_sz = frame_sz; xdp->rxq = rxq; + xdp->flags =0 ; }static __always_inline void
@@ -122,8 +143,14 @@ struct xdp_frame {*/ struct xdp_mem_info mem;struct net_device *dev_rx;/* used by cpumap */ +u32 flags;/* supported values defined in xdp_buff_flags */ }; +static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame) +{ +return !!(frame->flags &XDP_FLAGS_HAS_FRAGS ); +} +#define XDP_BULK_QUEUE_SIZE 16struct xdp_frame_bulk {int count;
@@ -180,6 +207,7 @@ void xdp_convert_frame_to_buff(struct xd xdp->data_end = frame->data + frame->len; xdp->data_meta = frame->data - frame->metasize; xdp->frame_sz = frame->frame_sz; + xdp->flags = frame->flags; } static inline
@@ -206,6 +234,7 @@ int xdp_update_frame_from_buff(struct xd xdp_frame->headroom = headroom -sizeof (*xdp_frame); xdp_frame->metasize = metasize; xdp_frame->frame_sz = xdp->frame_sz; + xdp_frame->flags = xdp->flags;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 809/843 bpf: Reject fragmented frames in devmap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Zhang <[email protected]>
[ Upstream commit aa496720618f1a6054f1c870bf10b4f6c99bf656 ]
Devmap broadcast redirects clone the packet for all but the last destination.
For native XDP, that clone path copies only the linear xdp_frame data, while fragmented frames keep skb_shared_info in tailroom outside the linear area. Cloning such a frame leaves XDP_FLAGS_HAS_FRAGS set but without valid frag metadata, and the later free path can interpret uninitialized tail data as skb_shared_info, leading to an out-of-bounds access during frame return.
Reject fragmented native XDP frames in dev_map_enqueue_clone().
Add the same restriction to the generic XDP clone path in dev_map_redirect_clone(). Generic XDP represents fragmented packets as nonlinear skbs, and rejecting them here keeps clone-based broadcast support aligned between native and generic XDP.
--- kernel/bpf/devmap.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/bpf/devmap.c +7 -0
@@ -551,6 +551,10 @@ static int dev_map_enqueue_clone(struct {struct xdp_frame *nxdpf; +/* Frags live outside the linear frame and cannot be cloned safely. */ +if (unlikely (xdp_frame_has_frags (xdpf))) +return -EOPNOTSUPP ; + nxdpf =xdpf_clone (xdpf);if (!nxdpf)return -ENOMEM ;
@@ -708,6 +712,9 @@ static int dev_map_redirect_clone(structstruct sk_buff *nskb;int err; +if (unlikely (skb_is_nonlinear (skb))) +return -EOPNOTSUPP ; + nskb =skb_clone (skb,GFP_ATOMIC );if (!nskb)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 810/843 bpf: Convert lpm_trie.c to rqspinlock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 47979314c0fe245ed54306e2f91b3f819c7c0f9f ]
Convert all LPM trie usage of raw_spinlock to rqspinlock.
Note that rcu_dereference_protected in trie_delete_elem is switched over to plain rcu_dereference, the RCU read lock should be held from BPF program side or eBPF syscall path, and the trie->lock is just acquired before the dereference. It is not clear the reason the protected variant was used from the commit history, but the above reasoning makes sense so switch over.
Stable-dep-of: 2f884d371faf ("bpf: Allow LPM map access from sleepable BPF programs")
--- kernel/bpf/lpm_trie.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/bpf/lpm_trie.c +2 -4
@@ -349,8 +349,7 @@ static int trie_update_elem(struct bpf_m*/ slot = &trie->root; -while ((node =rcu_dereference_protected (*slot, -lockdep_is_held (&trie->lock)))) { +while ((node =rcu_dereference (*slot))) { matchlen =longest_prefix_match (trie, node, key); if (node->prefixlen != matchlen ||
@@ -475,8 +474,7 @@ static int trie_delete_elem(struct bpf_m trim = &trie->root; trim2 = trim; parent =NULL ; -while ((node =rcu_dereference_protected ( - *trim,lockdep_is_held (&trie->lock)))) { +while ((node =rcu_dereference (*trim))) { matchlen =longest_prefix_match (trie, node, key); if (node->prefixlen != matchlen ||
Greg Kroah-Hartman
maintainerPATCH 811/843 bpf: Consistently use bpf_rcu_lock_held() everywhere
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 48a97ffc6c826640907d13b199e29008f4fe2c15 ]
We have many places which open-code what's now is bpf_rcu_lock_held() macro, so replace all those places with a clean and short macro invocation. For that, move bpf_rcu_lock_held() macro into include/linux/bpf.h.
Stable-dep-of: 2f884d371faf ("bpf: Allow LPM map access from sleepable BPF programs")
--- include/linux/bpf.h | 4 ++++ kernel/bpf/hashtab.c | 21 +++++++-------------- kernel/bpf/helpers.c | 9 +++------ 3 files changed, 14 insertions(+), 20 deletions(-)
include/linux/bpf.h +4 -0
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/percpu-refcount.h> #include <linux/bpfptr.h> +#include <linux/rcupdate_trace.h> struct bpf_verifier_env ;struct bpf_verifier_log ;
@@ -1482,6 +1483,9 @@ out: _ret; \ }) +#define bpf_rcu_lock_held () \ + (rcu_read_lock_held() || rcu_read_lock_trace_held() || rcu_read_lock_bh_held()) +#ifdef CONFIG_BPF_SYSCALL DECLARE_PER_CPU (int, bpf_prog_active);extern struct mutex bpf_stats_enabled_mutex;
kernel/bpf/hashtab.c +7 -14
@@ -642,8 +642,7 @@ static void *__htab_map_lookup_elem(strustruct htab_elem *l;u32 hash, key_size; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1047,8 +1046,7 @@ static int htab_map_update_elem(struct b/* unknown flags */ return -EINVAL ; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1149,8 +1147,7 @@ static int htab_lru_map_update_elem(stru/* unknown flags */ return -EINVAL ; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1218,8 +1215,7 @@ static int __htab_percpu_map_update_elem/* unknown flags */ return -EINVAL ; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1273,8 +1269,7 @@ static int __htab_lru_percpu_map_update_/* unknown flags */ return -EINVAL ; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1349,8 +1344,7 @@ static int htab_map_delete_elem(struct bu32 hash, key_size;int ret; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
@@ -1385,8 +1379,7 @@ static int htab_lru_map_delete_elem(struu32 hash, key_size;int ret; -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ()); key_size = map->key_size;
kernel/bpf/helpers.c +3 -6
@@ -30,8 +30,7 @@*/ BPF_CALL_2(bpf_map_lookup_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ());return (unsigned long ) map->ops->map_lookup_elem (map, key); }
@@ -47,8 +46,7 @@ const struct bpf_func_proto bpf_map_look BPF_CALL_4(bpf_map_update_elem, struct bpf_map *, map, void *, key, void *, value, u64, flags) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ());return map->ops->map_update_elem (map, key, value, flags); }
@@ -65,8 +63,7 @@ const struct bpf_func_proto bpf_map_upda BPF_CALL_2(bpf_map_delete_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () && - !rcu_read_lock_bh_held ()); +WARN_ON_ONCE (!bpf_rcu_lock_held ());return map->ops->map_delete_elem (map, key); }
Greg Kroah-Hartman
maintainerPATCH 812/843 bpf: Allow LPM map access from sleepable BPF programs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Poenaru <[email protected]>
[ Upstream commit 2f884d371fafea137afea504d49ee4a7c8d7985b ]
trie_lookup_elem() annotates its rcu_dereference_check() walks with only rcu_read_lock_bh_held(). Because rcu_dereference_check(p, c) resolves to "c || rcu_read_lock_held()", this passes for XDP/NAPI and classic RCU readers but fails for sleepable BPF programs, which enter via __bpf_prog_enter_sleepable() and hold only rcu_read_lock_trace().
trie_update_elem() and trie_delete_elem() have the same problem in a different form: they walk the trie with plain rcu_dereference(), which asserts rcu_read_lock_held() unconditionally. Both are reachable from sleepable BPF programs via the bpf_map_update_elem / bpf_map_delete_elem helpers, and from the syscall path under classic rcu_read_lock(). In the writer paths the trie is actually protected by trie->lock (an rqspinlock taken across the walk); we never relied on the RCU read-side lock to keep nodes alive there.
A sleepable LSM hook that ends up touching an LPM trie therefore triggers lockdep on debug kernels:
=============================
WARNING: suspicious RCU usage
7.1.0-... Tainted: G E
-----------------------------
kernel/bpf/lpm_trie.c:249 suspicious rcu_dereference_check() usage! 1 lock held by net_tests/540:
#0: (rcu_tasks_trace_srcu_struct){....}-{0:0},
at: __bpf_prog_enter_sleepable+0x26/0x280 Call Trace: dump_stack_lvl lockdep_rcu_suspicious trie_lookup_elem bpf_prog_..._enforce_security_socket_connect bpf_trampoline_... security_socket_connect __sys_connect do_syscall_64
This is lockdep-only -- no UAF, since Tasks Trace RCU does serialize against the trie's reclaim path -- but it spams the console once per distinct callsite on every debug kernel running a sleepable BPF LSM that touches an LPM trie, which is increasingly common.
For the lookup path, switch the rcu_dereference_check() annotation from rcu_read_lock_bh_held() to bpf_rcu_lock_held(), which accepts all three contexts (classic, BH, Tasks Trace). Other map types already follow this convention.
For trie_update_elem() and trie_delete_elem(), annotate the walks as rcu_dereference_protected(*p, 1) -- matching trie_free() in the same file -- since trie->lock is held across the walk. rqspinlock has no lockdep_map, so the predicate degenerates to '1' rather than lockdep_is_held(&trie->lock); the protection is real but not machine-verifiable. trie_get_next_key() also uses bare rcu_dereference() but is reachable only from the BPF syscall, which holds classic rcu_read_lock() before dispatching, so it is left untouched.
--- kernel/bpf/lpm_trie.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/bpf/lpm_trie.c +4 -4
@@ -235,7 +235,7 @@ static void *trie_lookup_elem(struct bpf/* Start walking the trie from the root node ... */ -for (node =rcu_dereference_check (trie->root,rcu_read_lock_bh_held ()); +for (node =rcu_dereference_check (trie->root,bpf_rcu_lock_held ()); node;) {unsigned int next_bit;size_t matchlen;
@@ -269,7 +269,7 @@ static void *trie_lookup_elem(struct bpf*/ next_bit =extract_bit (key->data, node->prefixlen); node =rcu_dereference_check (node->child[next_bit], -rcu_read_lock_bh_held ()); +bpf_rcu_lock_held ()); }if (!found)
@@ -349,7 +349,7 @@ static int trie_update_elem(struct bpf_m*/ slot = &trie->root; -while ((node =rcu_dereference (*slot))) { +while ((node =rcu_dereference_protected (*slot,1 ))) { matchlen =longest_prefix_match (trie, node, key); if (node->prefixlen != matchlen ||
@@ -474,7 +474,7 @@ static int trie_delete_elem(struct bpf_m trim = &trie->root; trim2 = trim; parent =NULL ; -while ((node =rcu_dereference (*trim))) { +while ((node =rcu_dereference_protected (*trim,1 ))) { matchlen =longest_prefix_match (trie, node, key); if (node->prefixlen != matchlen ||
Greg Kroah-Hartman
maintainerPATCH 813/843 usb: iowarrior: remove inherent race with minor number
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 56dd29088c9d9510c48a8ebad2465248fde36551 ]
The driver saves the minor number it gets upon registration in its descriptor for debugging purposes. However, there is inevitably a window between registration and saving the correct minor in a descriptor. During this window the debugging output will be wrong.
As wrong debug output is worse than no debug output, just remove it.
Stable-dep-of: c602254ba4c1 ("USB: iowarrior: fix use-after-free on disconnect race")
--- drivers/usb/misc/iowarrior.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/usb/misc/iowarrior.c +3 -14
@@ -74,7 +74,6 @@ struct iowarrior {struct mutex mutex;/* locks this structure */ struct usb_device *udev;/* save off the usb device pointer */ struct usb_interface *interface;/* the interface for this device */ -unsigned char minor;/* the starting minor number for this device */ struct usb_endpoint_descriptor *int_out_endpoint;/* endpoint for reading (needed for IOW56 only) */ struct usb_endpoint_descriptor *int_in_endpoint;/* endpoint for reading */ struct urb *int_in_urb;/* the urb for reading data */
@@ -246,7 +245,6 @@ static void iowarrior_write_callback(str*/ static inline void iowarrior_delete (struct iowarrior *dev) { -dev_dbg (&dev->interface->dev,"minor %d\n" , dev->minor);kfree (dev->int_in_buffer);usb_free_urb (dev->int_in_urb);kfree (dev->read_queue);
@@ -297,9 +295,6 @@ static ssize_t iowarrior_read(struct fil goto exit; } -dev_dbg (&dev->interface->dev,"minor %d, count = %zd\n" , - dev->minor, count); -/* read count must be packet size (+ time stamp) */ if ((count != dev->report_size) && (count != (dev->report_size +1 ))) {
@@ -379,8 +374,6 @@ static ssize_t iowarrior_write(struct fi retval = -ENODEV ; goto exit; } -dev_dbg (&dev->interface->dev,"minor %d, count = %zd\n" , - dev->minor, count);/* if count is 0 we're already done */ if (count ==0 ) { retval =0 ;
@@ -523,9 +516,6 @@ static long iowarrior_ioctl(struct file goto error_out; } -dev_dbg (&dev->interface->dev,"minor %d, cmd 0x%.4x, arg %ld\n" , - dev->minor, cmd, arg); - retval =0 ; io_res =0 ;switch (cmd) {
@@ -672,8 +662,6 @@ static int iowarrior_release(struct inodif (!dev)return -ENODEV ; -dev_dbg (&dev->interface->dev,"minor %d\n" , dev->minor); -/* lock our device */ mutex_lock (&dev->mutex);
@@ -776,6 +764,7 @@ static int iowarrior_probe(struct usb_instruct usb_host_interface *iface_desc;int retval = -ENOMEM ;int res; +int minor;/* allocate memory for our device state and initialize it */ dev =kzalloc (sizeof (struct iowarrior ),GFP_KERNEL );
@@ -891,12 +880,12 @@ static int iowarrior_probe(struct usb_in goto error; } - dev->minor = interface->minor; + minor = interface->minor;/* let the user know what node this device is now attached to */ dev_info (&interface->dev,"IOWarrior product=0x%x, serial=%s interface=%d " "now attached to iowarrior%d\n" , dev->product_id, dev->chip_serial, - iface_desc->desc.bInterfaceNumber, dev->minor -IOWARRIOR_MINOR_BASE ); + iface_desc->desc.bInterfaceNumber, minor -IOWARRIOR_MINOR_BASE );return retval; error:
Greg Kroah-Hartman
maintainerPATCH 814/843 drm/i2c/sil164: Drop no-op remove function
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit eb09882d64807c24228ed1d005dbbae70860ca3f ]
A remove callback that just returns 0 is equivalent to no callback at all as can be seen in i2c_device_remove(). So simplify accordingly.
Stable-dep-of: 1f0bdc2884b6 ("usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove")
--- drivers/gpu/drm/i2c/sil164_drv.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/i2c/sil164_drv.c +0 -7
@@ -370,12 +370,6 @@ sil164_probe(struct i2c_client *client,return 0 ; } -static int -sil164_remove (struct i2c_client *client) -{ -return 0 ; -} -static struct i2c_client *sil164_detect_slave (struct i2c_client *client) {
@@ -427,7 +421,6 @@ MODULE_DEVICE_TABLE(i2c, sil164_ids);static struct drm_i2c_encoder_driver sil164_driver = { .i2c_driver = { .probe = sil164_probe, - .remove = sil164_remove, .driver = { .name ="sil164" , },
Greg Kroah-Hartman
maintainerPATCH 815/843 leds: lm3697: Remove duplicated error reporting in .remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit af89fa11fae1cee4e07453f780e6e5573ef0f477 ]
Returning an error value from an i2c remove callback results in an error message being emitted by the i2c core, but otherwise it doesn't make a difference. The device goes away anyhow and the devm cleanups are called.
As lm3697_remove() already emits an error message on failure and the additional error message by the i2c core doesn't add any useful information, don't pass the error value up the stack. Instead continue to clean up and return 0.
This patch is a preparation for making i2c remove callbacks return void.
Stable-dep-of: 1f0bdc2884b6 ("usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove")
--- drivers/leds/leds-lm3697.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/leds/leds-lm3697.c +1 -3
@@ -345,10 +345,8 @@ static int lm3697_remove(struct i2c_clie ret =regmap_update_bits (led->regmap,LM3697_CTRL_ENABLE ,LM3697_CTRL_A_B_EN ,0 ); -if (ret) { +if (ret)dev_err (dev,"Failed to disable the device\n" ); -return ret; - }if (led->enable_gpio)gpiod_direction_output (led->enable_gpio,0 );
Greg Kroah-Hartman
maintainerPATCH 816/843 leds: lm3601x: Improve error reporting for problems during .remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 22a23436891886a66d21af3619f4a4e8809f0e0a ]
Returning an error value in an i2c remove callback results in a generic error message being emitted by the i2c core, but otherwise it doesn't make a difference. The device goes away anyhow and the devm cleanups are called.
So instead of triggering the generic i2c error message, emit a more helpful message if a problem occurs and return 0 to suppress the generic message.
This patch is a preparation for making i2c remove callbacks return void.
Stable-dep-of: 1f0bdc2884b6 ("usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove")
--- drivers/leds/flash/leds-lm3601x.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/leds/flash/leds-lm3601x.c +8 -3
@@ -443,10 +443,15 @@ static int lm3601x_probe(struct i2c_cliestatic int lm3601x_remove (struct i2c_client *client) {struct lm3601x_led *led =i2c_get_clientdata (client); +int ret; -return regmap_update_bits (led->regmap,LM3601X_ENABLE_REG , -LM3601X_ENABLE_MASK , -LM3601X_MODE_STANDBY ); + ret =regmap_update_bits (led->regmap,LM3601X_ENABLE_REG , +LM3601X_ENABLE_MASK ,LM3601X_MODE_STANDBY ); +if (ret) +dev_warn (&client->dev, +"Failed to put into standby (%pe)\n" ,ERR_PTR (ret)); + +return 0 ; }static const struct i2c_device_id lm3601x_id[] = {
Greg Kroah-Hartman
maintainerPATCH 817/843 gpio: pca953x: Make platform teardown callback return void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 6a8f359c3132e4f51bdb263ad74ec632c65e55fd ]
All platforms that provide a teardown callback return 0. New users are supposed to not make use of platform support, so there is no functionality lost.
This patch is a preparation for making i2c remove callbacks return void.
Stable-dep-of: 1f0bdc2884b6 ("usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove")
--- arch/arm/mach-davinci/board-da850-evm.c | 12 ++++-------- drivers/gpio/gpio-pca953x.c | 11 +++-------- include/linux/platform_data/pca953x.h | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +4 -8
@@ -517,8 +517,8 @@ exp_setup_sela_fail:return ret; } -static int da850_evm_ui_expander_teardown (struct i2c_client *client, -unsigned gpio,unsigned ngpio,void *c) +static void da850_evm_ui_expander_teardown (struct i2c_client *client, +unsigned gpio,unsigned ngpio,void *c) {platform_device_unregister (&da850_evm_ui_keys_device);
@@ -530,8 +530,6 @@ static int da850_evm_ui_expander_teardowgpio_free (gpio +DA850_EVM_UI_EXP_SEL_C );gpio_free (gpio +DA850_EVM_UI_EXP_SEL_B );gpio_free (gpio +DA850_EVM_UI_EXP_SEL_A ); - -return 0 ; }/* assign the baseboard expander's GPIOs after the UI board's */
@@ -698,13 +696,11 @@ io_exp_setup_sw_fail:return ret; } -static int da850_evm_bb_expander_teardown (struct i2c_client *client, -unsigned gpio,unsigned ngpio,void *c) +static void da850_evm_bb_expander_teardown (struct i2c_client *client, +unsigned gpio,unsigned ngpio,void *c) {platform_device_unregister (&da850_evm_bb_leds_device);platform_device_unregister (&da850_evm_bb_keys_device); - -return 0 ; }static struct pca953x_platform_data da850_evm_ui_expander_info = {
drivers/gpio/gpio-pca953x.c +3 -8
@@ -1074,20 +1074,15 @@ static int pca953x_remove(struct i2c_cli {struct pca953x_platform_data *pdata =dev_get_platdata (&client->dev);struct pca953x_chip *chip =i2c_get_clientdata (client); -int ret;if (pdata && pdata->teardown) { - ret = pdata->teardown (client, chip->gpio_chip.base, - chip->gpio_chip.ngpio, pdata->context); -if (ret <0 ) -dev_err (&client->dev,"teardown failed, %d\n" , ret); - }else { - ret =0 ; + pdata->teardown (client, chip->gpio_chip.base, + chip->gpio_chip.ngpio, pdata->context); }regulator_disable (chip->regulator); -return ret; +return 0 ; }#ifdef CONFIG_PM_SLEEP
include/linux/platform_data/pca953x.h +1 -1
@@ -22,7 +22,7 @@ struct pca953x_platform_data {int (*setup)(struct i2c_client *client,unsigned gpio,unsigned ngpio,void *context); -int (*teardown)(struct i2c_client *client, +void (*teardown)(struct i2c_client *client,unsigned gpio,unsigned ngpio,void *context);const char *const *names;
Greg Kroah-Hartman
maintainerPATCH 818/843 usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 1f0bdc2884b67de337215079bba166df0cdf4ac5 ]
The threaded IRQ handler ccg_irq_handler() calls ucsi_notify_common(), which on a connector-change event calls ucsi_connector_change() and schedules connector work. In ucsi_ccg_remove(), ucsi_destroy() frees uc->ucsi (kfree) before free_irq() is called, so a handler invocation already in flight may access the freed object after ucsi_destroy().
CPU 0 (remove) | CPU 1 (threaded IRQ)
ucsi_destroy(uc->ucsi) | ccg_irq_handler()
kfree(ucsi) // FREE | ucsi_notify_common(uc->ucsi) // USEMove free_irq() before ucsi_destroy() in the remove path. It is kept after ucsi_unregister(): ucsi_unregister() cancels connector work whose handler issues GET_CONNECTOR_STATUS through ucsi_send_command_common(), which waits for a completion that is signalled from the IRQ handler, so the IRQ must stay active until that work has been cancelled.
The probe error path already orders free_irq() before ucsi_destroy().
This bug was found by static analysis.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -1
@@ -1418,8 +1418,8 @@ static int ucsi_ccg_remove(struct i2c_clcancel_work_sync (&uc->work);pm_runtime_disable (uc->dev);ucsi_unregister (uc->ucsi); -ucsi_destroy (uc->ucsi);free_irq (uc->irq, uc); +ucsi_destroy (uc->ucsi);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 819/843 usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf ]
ueagle-atm uses the asynchronous request_firmware_nowait() in .probe(), but does not wait for its completion, not even in .disconnect(); so, if the device is unplugged meanwhile, its teardown runs concurrently with that.
Even though this inconsistency is worth addressing on its own, it has also triggered several bug reports in syzbot over the years (some auto-closed) where the firmware sysfs fallback mechanism (CONFIG_FW_LOADER_USER_HELPER) creates a firmware subdirectory in the device directory during its removal, which might hit unexpected conditions in kernfs, apparently, depending at which point the add and remove operations raced. (See links.)
The pattern is:
usb ?-?: Direct firmware load for ueagle-atm/eagle?.fw failed with error -2 usb ?-?: Falling back to sysfs fallback for: ueagle-atm/eagle?.fw <ERROR>
Call trace: ... kernfs_create_dir_ns sysfs_create_dir_ns create_dir kobject_add_internal kobject_add_varg kobject_add class_dir_create_and_add get_device_parent device_add fw_load_sysfs_fallback fw_load_from_user_helper firmware_fallback_sysfs _request_firmware request_firmware_work_func ...
(Some variations are observed, after fw_load_sysfs_fallback(), e.g., [1].)
While the kernfs side is being looked at, the ueagle-atm side can be fixed by waiting for the pre-firmware load in the .disconnect() handler.
This change has a similar approach to previous work by Andrey Tsygunka [2] (wait_for_completion() in .disconnect()), but it is relatively different in design/implementation; using the Originally-by tag for credit assignment.
This has been tested with:
- synthetic reproducer to check the error path;
- USB gadget (virtual device) to check the firmware upload path;
- QEMU device emulator to check the device ID re-enumeration path; (The latter two were written by Claude; no other code/text in this commit.)
Links (year first reported):
2025 https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
2025 https://syzbot.org/bug?extid=9af8471255ac36e34fd4
2024 https://syzbot.org/bug?extid=306212936b13e520679d
2023 https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
2022 https://syzbot.org/bug?extid=782984d6f1701b526edb
2021 https://syzbot.org/bug?id=f3f221579f4ef7e9691281f3c6f56c05f83e8490
2021 https://syzbot.org/bug?id=84d86f0d71394829df6fc53daf6642c045983881
2021 https://syzbot.org/bug?id=3302dc1c0e2b9c94f2e8edb404eabc9267bc6f90
[1] https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
[2] https://lore.kernel.org/lkml/[email protected]/
--- drivers/usb/atm/ueagle-atm.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/usb/atm/ueagle-atm.c +31 -5
@@ -599,7 +599,9 @@ static int uea_send_modem_cmd(struct usbstatic void uea_upload_pre_firmware (const struct firmware *fw_entry,void *context) { -struct usb_device *usb = context; +struct usb_interface *intf = context; +struct usb_device *usb =interface_to_usbdev (intf); +struct completion *fw_done =usb_get_intfdata (intf);const u8 *pfw;u8 value;u32 crc =0 ;
@@ -670,15 +672,17 @@ err_fw_corrupted: err:release_firmware (fw_entry);uea_leaves (usb); +complete (fw_done); }/* * uea_load_firmware - Load usb firmware for pre-firmware devices. */ -static int uea_load_firmware (struct usb_device *usb,unsigned int ver) +static int uea_load_firmware (struct usb_interface *intf,unsigned int ver) {int ret;char *fw_name =EAGLE_FIRMWARE ; +struct usb_device *usb =interface_to_usbdev (intf);uea_enters (usb);uea_info (usb,"pre-firmware device, uploading firmware\n" );
@@ -702,7 +706,7 @@ static int uea_load_firmware(struct usb_ } ret =request_firmware_nowait (THIS_MODULE ,1 , fw_name, &usb->dev, -GFP_KERNEL , usb, +GFP_KERNEL , intf, uea_upload_pre_firmware);if (ret)uea_err (usb,"firmware %s is not available\n" , fw_name);
@@ -2598,8 +2602,23 @@ static int uea_probe(struct usb_interfacusb_reset_device (usb); -if (UEA_IS_PREFIRM (id)) -return uea_load_firmware (usb,UEA_CHIP_VERSION (id)); +if (UEA_IS_PREFIRM (id)) { +struct completion *fw_done; + +/* Wait for the firmware load to be done, in .disconnect() */ + fw_done =kzalloc (sizeof (*fw_done),GFP_KERNEL ); +if (!fw_done) +return -ENOMEM ; + +init_completion (fw_done); +usb_set_intfdata (intf, fw_done); + + ret =uea_load_firmware (intf,UEA_CHIP_VERSION (id)); +if (ret) +kfree (fw_done); + +return ret; + } ret =usbatm_usb_probe (intf, id, &uea_usbatm_driver);if (ret ==0 ) {
@@ -2630,6 +2649,13 @@ static void uea_disconnect(struct usb_inusbatm_usb_disconnect (intf);mutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); + }else if (usb->config->desc.bNumInterfaces ==1 ) { +struct completion *fw_done =usb_get_intfdata (intf); + +uea_dbg (usb,"pre-firmware device, waiting firmware upload\n" ); +wait_for_completion (fw_done); +uea_dbg (usb,"pre-firmware device, finished waiting\n" ); +kfree (fw_done); }uea_leaves (usb);
Greg Kroah-Hartman
maintainerPATCH 820/843 usb: typec: tcpm: Fix VDM type for Enter Mode commands
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Yan <[email protected]>
[ Upstream commit 9cff680e47632b7723cb19f9c5e63669063c3417 ]
VDO() second parameter is VDM type (bit 15): 1 for SVDM, 0 for UVDM. Using 'vdo ? 2 : 1' corrupts SVID low bit when vdo is non-NULL (2 << 15 = BIT(16)). Enter Mode is always SVDM, hardcode to 1.
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -2223,7 +2223,7 @@ static int tcpm_altmode_enter(struct typif (svdm_version <0 )return svdm_version; - header =VDO (altmode->svid, vdo ?2 :1 , svdm_version,CMD_ENTER_MODE ); + header =VDO (altmode->svid,1 , svdm_version,CMD_ENTER_MODE ); header |=VDO_OPOS (altmode->mode);tcpm_queue_vdm_unlocked (port, header, vdo, vdo ?1 :0 );
Greg Kroah-Hartman
maintainerPATCH 821/843 usb: gadget: f_fs: initialize reset_work at allocation time
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyler Baker <[email protected]>
[ Upstream commit 3137b243c93982fe3460335e12f9247739766e10 ]
ffs_fs_kill_sb() unconditionally calls cancel_work_sync() on ffs->reset_work when a functionfs instance is unmounted:
ffs_data_reset(ffs); cancel_work_sync(&ffs->reset_work);
However ffs->reset_work is only ever initialized via INIT_WORK() in ffs_func_set_alt() and ffs_func_disable(), and only on the FFS_DEACTIVATED path. That state is reached solely by ffs_data_closed() when the instance is mounted with the "no_disconnect" option, so for the common case (no "no_disconnect", or mounted and unmounted without ever being deactivated) reset_work is never initialized.
ffs_data_new() allocates the ffs_data with kzalloc_obj() and does not initialize reset_work, and ffs_data_reset()/ffs_data_clear() do not touch it either, so reset_work.func is left NULL. cancel_work_sync() on such a work then trips the WARN_ON(!work->func) guard in __flush_work():
WARNING: kernel/workqueue.c:4301 at __flush_work+0x330/0x360, CPU#3: umount Call trace: __flush_work cancel_work_sync ffs_fs_kill_sb [usb_f_fs] deactivate_locked_super deactivate_super cleanup_mnt __cleanup_mnt task_work_run exit_to_user_mode_loop el0_svc
On older kernels cancel_work_sync() on a zero-initialized work struct was a silent no-op, which hid the missing initialization.
Initialize reset_work once in ffs_data_new() so it is always valid for the lifetime of the ffs_data, and drop the now-redundant INIT_WORK() calls from the two deactivation paths.
--- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +2 -1
@@ -255,6 +255,7 @@ static int ffs_acquire_dev(const char *dstatic void ffs_release_dev (struct ffs_dev *ffs_dev);static int ffs_ready (struct ffs_data *ffs);static void ffs_closed (struct ffs_data *ffs); +static void ffs_reset_work (struct work_struct *work);/* Misc helper functions ****************************************************/
@@ -1786,6 +1787,7 @@ static struct ffs_data *ffs_data_new(coninit_waitqueue_head (&ffs->ev.waitq);init_waitqueue_head (&ffs->wait);init_completion (&ffs->ep0req_completion); +INIT_WORK (&ffs->reset_work, ffs_reset_work);/* XXX REVISIT need to update it in some places, or do we? */ ffs->ev.can_stall =1 ;
@@ -3342,7 +3344,6 @@ static int ffs_func_set_alt(struct usb_fif (ffs->state ==FFS_DEACTIVATED ) { ffs->state =FFS_CLOSING ; -INIT_WORK (&ffs->reset_work, ffs_reset_work);schedule_work (&ffs->reset_work);return -ENODEV ; }
Greg Kroah-Hartman
maintainerPATCH 822/843 crypto: atmel-sha204a - Mark OF related data as maybe unused
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 75f3d950054389e2556277e42170e37dd97cd872 ]
The driver can be compile tested with !CONFIG_OF making certain data unused:
drivers/crypto/atmel-sha204a.c:129:34: error: ‘atmel_sha204a_dt_ids’ defined but not used [-Werror=unused-const-variable=]
Stable-dep-of: ea5e57cc9718 ("crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A")
--- drivers/crypto/atmel-sha204a.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/atmel-sha204a.c +4 -2
@@ -136,14 +136,16 @@ static int atmel_sha204a_remove(struct ireturn 0 ; } -static const struct of_device_id atmel_sha204a_dt_ids[] = { +static const struct of_device_id atmel_sha204a_dt_ids[]__maybe_unused = { + { .compatible ="atmel,atsha204" , }, { .compatible ="atmel,atsha204a" , }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, atmel_sha204a_dt_ids);static const struct i2c_device_id atmel_sha204a_id[] = { - {"atsha204a" ,0 }, + {"atsha204" }, + {"atsha204a" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (i2c, atmel_sha204a_id);
Greg Kroah-Hartman
maintainerPATCH 823/843 crypto: atmel - Drop explicit initialization of struct i2c_device_id::driver_data to 0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit d86ad3911a5d4549297ed810ee450e5772fd665f ]
These drivers don't use the driver_data member of struct i2c_device_id, so don't explicitly initialize this member.
This prepares putting driver_data in an anonymous union which requires either no initialization or named designators. But it's also a nice cleanup on its own.
Stable-dep-of: ea5e57cc9718 ("crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A")
--- drivers/crypto/atmel-ecc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-ecc.c +1 -1
@@ -375,7 +375,7 @@ MODULE_DEVICE_TABLE(of, atmel_ecc_dt_ids#endif static const struct i2c_device_id atmel_ecc_id[] = { - {"atecc508a" ,0 }, + {"atecc508a" }, { } };MODULE_DEVICE_TABLE (i2c, atmel_ecc_id);
Greg Kroah-Hartman
maintainerPATCH 824/843 crypto: atmel-sha204a - drop hwrng quality reduction for ATSHA204A
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit ea5e57cc97185329dcc5ebdcaae7e1500bf0ad0b ]
Commit 8006aff15516 ("crypto: atmel-sha204a - Set hwrng quality to lowest possible") reduced the hwrng quality to 1 based on a review by Bill Cox [1]. However, despite its title, the review only tested the ATSHA204, not the ATSHA204A.
In the same thread, Atmel engineer Landon Cox wrote "this behavior has been eliminated entirely"[2] in the ATSHA204A and "this problem does not affect the ATECC108 or the ATECC108A (or the ATSHA204A)"[3].
According to the official ATSHA204A datasheet [4], the device contains a high-quality hardware RNG that combines its output with an internal seed value stored in EEPROM or SRAM to generate random numbers. The device also implements all security functions using SHA-256, and the driver uses the chip's Random command in seed-update mode.
Keep 'quality = 1' for ATSHA204, but drop the explicit hwrng quality reduction for ATSHA204A and fall back to the hwrng core default.
[1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html
[2] https://www.metzdowd.com/pipermail/cryptography/2014-December/023852.html
[3] https://www.metzdowd.com/pipermail/cryptography/2014-December/023886.html
[4] https://ww1.microchip.com/downloads/en/DeviceDoc/ATSHA204A-Data-Sheet-40002025A.pdf
--- drivers/crypto/atmel-sha204a.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/crypto/atmel-sha204a.c +12 -7
@@ -18,6 +18,12 @@#include <linux/workqueue.h> #include "atmel-i2c.h" +/* +* According to review by Bill Cox [1], the ATSHA204 has very low entropy. +* [1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html +*/ +static const unsigned short atsha204_quality =1 ; +static void atmel_sha204a_rng_done (struct atmel_i2c_work_data *work_data,void *areq,int status) {
@@ -95,6 +101,7 @@ static int atmel_sha204a_probe(struct i2 const struct i2c_device_id *id) {struct atmel_i2c_client_priv *i2c_priv; +const unsigned short *quality;int ret; ret =atmel_i2c_probe (client, id);
@@ -108,11 +115,9 @@ static int atmel_sha204a_probe(struct i2 i2c_priv->hwrng.name =dev_name (&client->dev); i2c_priv->hwrng.read = atmel_sha204a_rng_read; -/* -* According to review by Bill Cox [1], this HWRNG has very low entropy. -* [1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html -*/ - i2c_priv->hwrng.quality =1 ; + quality =i2c_get_match_data (client); +if (quality) + i2c_priv->hwrng.quality = *quality; ret =devm_hwrng_register (&client->dev, &i2c_priv->hwrng);if (ret)
@@ -137,14 +142,14 @@ static int atmel_sha204a_remove(struct i }static const struct of_device_id atmel_sha204a_dt_ids[]__maybe_unused = { - { .compatible ="atmel,atsha204" , }, + { .compatible ="atmel,atsha204" , .data = &atsha204_quality }, { .compatible ="atmel,atsha204a" , }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, atmel_sha204a_dt_ids);static const struct i2c_device_id atmel_sha204a_id[] = { - {"atsha204" }, + {"atsha204" , (kernel_ulong_t)&atsha204_quality }, {"atsha204a" }, {/* sentinel */ } };
Greg Kroah-Hartman
maintainerPATCH 825/843 usb: gadget: f_fs: Tie read_buffer lifetime to ffs_epfile
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neill Kapron <[email protected]>
[ Upstream commit 8bdcf96eb135aebacac319667f87db034fb38406 ]
Currently, ffs_epfile_release unconditionally frees the endpoint's read_buffer when a file descriptor is closed. If userspace explicitly opens the endpoint multiple times and closes one, the read_buffer is destroyed. This can lead to silent data loss if other file descriptors are still actively reading from the endpoint.
By tying the lifetime of the read_buffer to the ffs_epfile structure itself (which is destroyed when the functionfs instance is torn down in ffs_epfiles_destroy), we eliminate the brittle dependency on open/release calls while correctly matching the conceptual lifetime of unread data on the hardware endpoint.
--- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +1 -1
@@ -1292,7 +1292,6 @@ ffs_epfile_release(struct inode *inode,ENTER (); -__ffs_epfile_read_buffer_free (epfile);ffs_data_closed (epfile->ffs);return 0 ;
@@ -1957,6 +1956,7 @@ static void ffs_epfiles_destroy(struct ffor (; count; --count, ++epfile) {BUG_ON (mutex_is_locked (&epfile->mutex)); +__ffs_epfile_read_buffer_free (epfile);if (epfile->dentry) {d_delete (epfile->dentry);dput (epfile->dentry);
Greg Kroah-Hartman
maintainerPATCH 826/843 btrfs: do not trim a device which is not writeable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 1b1937eb08f51319bf71575484cde2b8c517aedc ]
[BUG]
There is a bug report that btrfs/242 can randomly fail with the following NULL pointer dereference:
run fstests btrfs/242 at 2026-06-01 10:25:08
BTRFS: device fsid d4d7f234-487c-4787-88e4-47a8b68c9874 devid 1 transid 9 /dev/sdc (8:32) scanned by mount (122609) BTRFS info (device sdc): first mount of filesystem d4d7f234-487c-4787-88e4-47a8b68c9874
BTRFS info (device sdc): using crc32c checksum algorithm
BTRFS warning (device sdc): devid 2 uuid fbe72d72-3272-482d-80fb-ab88ed398192 is missing
BTRFS warning (device sdc): devid 2 uuid fbe72d72-3272-482d-80fb-ab88ed398192 is missing
BTRFS info (device sdc): allowing degraded mounts
BTRFS info (device sdc): turning on async discard
BTRFS info (device sdc): enabling free space tree
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000018 user pgtable: 4k pages, 48-bit VAs, pgdp=000000013fd6b000 CPU: 4 UID: 0 PID: 122625 Comm: fstrim Not tainted 7.0.10-2-default #1 PREEMPT(full) openSUSE Tumbleweed e9a5f6b24978fba3bf015a992f865837fdfff3dd Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20250812-19.fc42 08/12/2025 pstate: 01400005 (nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) pc : btrfs_trim_fs+0x34c/0xa00 [btrfs] lr : btrfs_trim_fs+0x1f0/0xa00 [btrfs] Call trace: btrfs_trim_fs+0x34c/0xa00 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] (P) btrfs_ioctl_fitrim+0xe8/0x178 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] btrfs_ioctl+0xdd4/0x2bd8 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] __arm64_sys_ioctl+0xac/0x108 invoke_syscall.constprop.0+0x5c/0xd0 el0_svc_common.constprop.0+0x40/0xf0 do_el0_svc+0x24/0x40 el0_svc+0x40/0x1d0 el0t_64_sync_handler+0xa0/0xe8 el0t_64_sync+0x1b0/0x1b8 Code: 17ffff83 f94017e0 f9002be0 f9402ea0 (f9400c00) ---[ end trace 0000000000000000 ]---
Also the reporter is very kind to test the following ASSERT() added to btrfs_trim_free_extents_throttle():
ASSERT(device->bdev, "devid=%llu path=%s dev_state=0x%lx\n", device->devid, btrfs_dev_name(device), device->dev_state);
And it shows the following output:
assertion failed: device->bdev, in extent-tree.c:6630 (devid=2 path=/dev/sdd dev_state=0x82)
Which means the device->bdev is NULL, and the dev_state is BTRFS_DEV_STATE_IN_FS_METADATA | BTRFS_DEV_STATE_ITEM_FOUND, without BTRFS_DEV_STATE_WRITEABLE flag set.
[CAUSE]
The pc points to the following call chain:
btrfs_trim_fs()
|- btrfs_trim_free_extents()
|- btrfs_trim_free_extents_throttle()
|- bdev_max_discard_sectors(device->bdev)So the NULL pointer dereference is caused by device->bdev being NULL.
This looks impossible by a quick glance, as just before calling btrfs_trim_free_extents_throttle(), we have skipped any device that has BTRFS_DEV_STATE_MISSING flag set.
However in this particular case, there is a window where the missing device is later re-scanned, causing btrfs to remove the BTRFS_DEV_STATE_MISSING flag:
btrfs_control_ioctl()
|- btrfs_scan_one_device()
|- device_list_add()
|- rcu_assign_pointer(device->name, name);
| This updates the missing device's path to the new good path.
|
|- clear_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)
This removes the BTRFS_DEV_STATE_MISSING flag.This allows the missing device to re-appear and clear the BTRFS_DEV_STATE_MISSING flag. However the device still does not have the BTRFS_DEV_STATE_WRITEABLE flag set, nor is its bdev pointer updated.
The bdev pointer remains NULL, triggering the crash later.
[FIX]
This is a big de-synchronization between BTRFS_DEV_STATE_MISSING and device->bdev pointer, and shows a gap in btrfs's re-appearing-device handling.
The proper handling of re-appearing device will need quite some extra work, which is out of the context of this small fix.
Thankfully the regular bbio submission path has already handled it well by checking if the device->bdev is NULL before submitting.
So here we just fix the crash by checking if the device is writeable and has a bdev pointer before calling bdev_max_discard_sectors().
--- fs/btrfs/extent-tree.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/btrfs/extent-tree.c +8 -4
@@ -5994,12 +5994,16 @@ static int btrfs_trim_free_extents(struc *trimmed =0 ; -/* Discard not supported = nothing to do. */ -if (!blk_queue_discard (bdev_get_queue (device->bdev))) +/* +* The caller only filters out MISSING devices, but a device that was +* missing at mount and later rescanned has MISSING cleared while bdev +* is still NULL and WRITEABLE is still unset. Skip those here. +*/ +if (!test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state) || !device->bdev)return 0 ; -/* Not writable = nothing to do. */ -if (!test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state)) +/* Discard not supported = nothing to do. */ +if (!blk_queue_discard (bdev_get_queue (device->bdev)))return 0 ;/* No free space = nothing to do. */
Greg Kroah-Hartman
maintainerPATCH 827/843 crypto: qat - fix restarting state leak on allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 7d3ed20f7e46b3e991936fedd7a28f3ff4aec8d2 ]
In adf_dev_aer_schedule_reset(), ADF_STATUS_RESTARTING is set before allocating reset_data. If the allocation fails, the function returns -ENOMEM without queuing reset work, so nothing ever clears the bit. This leaves the device permanently stuck in the restarting state, causing all subsequent reset attempts to be silently skipped.
Fix this by using test_and_set_bit() to atomically claim the RESTARTING state, preventing duplicate reset scheduling races under concurrent fatal error reporting. If the subsequent allocation fails, clear the bit to restore clean state so future reset attempts can proceed.
--- drivers/crypto/qat/qat_common/adf_aer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_aer.c +4 -3
@@ -116,13 +116,14 @@ static int adf_dev_aer_schedule_reset(ststruct adf_reset_dev_data *reset_data;if (!adf_dev_started (accel_dev) || -test_bit (ADF_STATUS_RESTARTING , &accel_dev->status)) +test_and_set_bit (ADF_STATUS_RESTARTING , &accel_dev->status))return 0 ; -set_bit (ADF_STATUS_RESTARTING , &accel_dev->status); reset_data =kzalloc (sizeof (*reset_data),GFP_KERNEL ); -if (!reset_data) +if (!reset_data) { +clear_bit (ADF_STATUS_RESTARTING , &accel_dev->status);return -ENOMEM ; + } reset_data->accel_dev = accel_dev;init_completion (&reset_data->compl); reset_data->mode = mode;
Greg Kroah-Hartman
maintainerPATCH 828/843 btrfs: fix false IO failure after falling back to buffered write
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 66ff4d366e7eb4d31813d2acabf3af512ce03aa5 ]
[BUG]
The test case generic/362 will fail with "nodatasum" mount option (*):
MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch
# generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # --- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930 # +++ /home/adam/xfstests/results//generic/362.out.bad 2026-05-27 10:21:17.574771567 +0930 # @@ -1,2 +1,3 @@ # QA output created by 362 # +First write failed: Input/output error # Silence is golden # ...
*: If the test case has been executed before with default data checksum, the failure will not reproduce. Need the following fix to make it reliably reproducible:
https://lore.kernel.org/linux-btrfs/[email protected]/
[CAUSE]
Inside __iomap_dio_rw(), the -EFAULT/-ENOTBLK error is not directly returned. Thus we never got an error pointer from __iomap_dio_rw().
The call chain looks like this:
btrfs_direct_write()
|- btrfs_dio_write()
|- __iomap_dio_rw()
| |- iomap_iter()
| | |- btrfs_dio_iomap_begin()
| | Now an ordered extent is allocated for the 4K write.
| |
| |- iomi.status = iomap_dio_iter()
| | Where iomap_dio_iter() returned -EFAULT.
| |
| |- ret = iomap_iter()
| | |- btrfs_dio_iomap_end()
| | | |- btrfs_finish_ordered_extent(uptodate = false)
| | | | |- can_finish_ordered_extent()
| | | | |- btrfs_mark_ordered_extent_error()
| | | | |- mapping_set_error()
| | | | Now the address space is marked error.
| | | | return -ENOTBLK
| | |- return -ENOTBLK
| |- if (ret == -ENOTBLK) { ret = 0; }
| Now the return value is reset to 0.
| Thus no error pointer will be returned.
|
|- ret = iomap_dio_complete()
| Since no byte is submitted, @ret is 0.
|
|- Fallback to buffered IO
| And the buffered write finished without error
|
|- filemap_fdatawait_range() |- filemap_check_errors()
The previous error is recorded, thus an error is returned
However the buffered write is properly submitted and finished, the error is from the btrfs_finish_ordered_extent() call with @uptodate = false.
[FIX]
When a short dio write happened, any range that is submitted will have btrfs_extract_ordered_extent() to be called, thus the submitted range will always have an OE just covering the submitted range.
The remaining OE range is never submitted, thus they should be treated as truncated, not an error. So that we can properly reclaim and not insert an unnecessary file extent item, without marking the mapping as error.
Extract a helper, btrfs_mark_ordered_extent_truncated(), and utilize that helper to mark the direct IO ordered extent as truncated, so it won't cause failure for the later buffered fallback.
[REASON FOR NO FIXES TAG]
The bug itself is pretty old, at commit f85781fb505e ("btrfs: switch to iomap for direct IO") we're already passing @uptodate=false finishing the OE.
But at that time OE with IOERR won't call mapping_set_error(), so it's not exposed.
Later commit d61bec08b904 ("btrfs: mark ordered extent and inode with error if we fail to finish") finally exposed the bug, but that commit is doing a correct job, not the root cause.
Anyway the bug is very old, dating back to 5.1x days, thus only CC to stable.
--- fs/btrfs/inode.c | 34 ++++++++++++++++++++++++++-------- fs/btrfs/ordered-data.c | 13 +++++++++++++ fs/btrfs/ordered-data.h | 2 ++ 3 files changed, 41 insertions(+), 8 deletions(-)
fs/btrfs/inode.c +26 -8
@@ -8207,12 +8207,34 @@ static int btrfs_dio_iomap_end(struct inif (submitted < length) { pos += submitted; length -= submitted; -if (write) +if (write) { +struct btrfs_ordered_extent *ordered; + +/* +* We have a short write. Any range that was properly +* submitted will be finished through the bio +* completion path with an uptodate status matching +* the bio status. +* +* The remaining range was never submitted, so mark +* it as truncated and finish it without an error, so +* the extent is reclaimed without inserting a file +* extent item for it and without marking the mapping +* as failed, which would make a later buffered write +* fallback fail with a false -EIO. +*/ + ordered =btrfs_lookup_ordered_extent (BTRFS_I (inode), + pos); +ASSERT (ordered); +btrfs_mark_ordered_extent_truncated (ordered, + pos - ordered->file_offset); +btrfs_put_ordered_extent (ordered);__endio_write_update_ordered (BTRFS_I (inode), pos, - length, false); -else + length, true); + }else {unlock_extent (&BTRFS_I (inode)->io_tree, pos, pos + length -1 ); + } ret = -ENOTBLK ; }
@@ -8839,11 +8861,7 @@ static void btrfs_invalidatepage(structEXTENT_LOCKED |EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 1, 0, &cached_state); -spin_lock_irq (&inode->ordered_tree.lock); -set_bit (BTRFS_ORDERED_TRUNCATED , &ordered->flags); - ordered->truncated_len =min (ordered->truncated_len, - cur - ordered->file_offset); -spin_unlock_irq (&inode->ordered_tree.lock); +btrfs_mark_ordered_extent_truncated (ordered, cur - ordered->file_offset);if (btrfs_dec_test_ordered_pending (inode, &ordered, cur, range_end +1 - cur)) {
fs/btrfs/ordered-data.c +13 -0
@@ -298,6 +298,19 @@ void btrfs_add_ordered_sum(struct btrfs_spin_unlock_irq (&tree->lock); } +void btrfs_mark_ordered_extent_truncated (struct btrfs_ordered_extent *ordered, +u64 truncate_len) +{ +struct btrfs_ordered_inode_tree *tree; + + tree = &BTRFS_I (ordered->inode)->ordered_tree; +ASSERT (truncate_len <= ordered->num_bytes); +spin_lock_irq (&tree->lock); +set_bit (BTRFS_ORDERED_TRUNCATED , &ordered->flags); + ordered->truncated_len =min (ordered->truncated_len, truncate_len); +spin_unlock_irq (&tree->lock); +} +/* * Mark all ordered extents io inside the specified range finished. *
fs/btrfs/ordered-data.h +2 -0
@@ -212,6 +212,8 @@ void btrfs_lock_and_flush_ordered_range( struct extent_state **cached_state);int btrfs_split_ordered_extent (struct btrfs_ordered_extent *ordered,u64 pre,u64 post); +void btrfs_mark_ordered_extent_truncated (struct btrfs_ordered_extent *ordered, +u64 truncate_len);int __init ordered_data_init (void );void __cold ordered_data_exit (void );
Greg Kroah-Hartman
maintainerPATCH 829/843 crypto: qat - validate RSA CRT component lengths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giovanni Cabiddu <[email protected]>
[ Upstream commit b3ac78756588059729b9195fcc9f4b37d54057a5 ]
The generic RSA key parser (rsa_helper.c) bounds each CRT component (p, q, dp, dq, qinv) by the modulus size n_sz, but qat_rsa_setkey_crt() allocates half-size DMA buffers (key_sz / 2) and right-aligns each component with:
memcpy(dst + half_key_sz - len, src, len)
When a CRT component is larger than half_key_sz the subtraction underflows and memcpy writes past the DMA buffer, causing memory corruption.
Add a len > half_key_sz check next to the existing !len check for each of the five CRT components so the driver falls back to the non-CRT path instead of writing out of bounds.
--- drivers/crypto/qat/qat_common/qat_asym_algs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/qat_asym_algs.c +5 -5
@@ -1032,7 +1032,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->p; len = rsa_key->p_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto err; ctx->p =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_p,GFP_KERNEL );if (!ctx->p)
@@ -1043,7 +1043,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->q; len = rsa_key->q_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_p; ctx->q =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_q,GFP_KERNEL );if (!ctx->q)
@@ -1054,7 +1054,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->dp; len = rsa_key->dp_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_q; ctx->dp =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_dp,GFP_KERNEL );
@@ -1066,7 +1066,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->dq; len = rsa_key->dq_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_dp; ctx->dq =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_dq,GFP_KERNEL );
@@ -1078,7 +1078,7 @@ static void qat_rsa_setkey_crt(struct qa ptr = rsa_key->qinv; len = rsa_key->qinv_sz;qat_rsa_drop_leading_zeros (&ptr, &len); -if (!len) +if (!len || len > half_key_sz) goto free_dq; ctx->qinv =dma_alloc_coherent (dev, half_key_sz, &ctx->dma_qinv,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 830/843 btrfs: fix incorrect buffered IO fallback for append direct writes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit ff66fe6662330226b3f486014c375538d91c44aa ]
[BUG]
With the previous bug of short direct writes fixed, test case generic/362 (*) still fails with the following error with nodatasum mount option:
# generic/362 0s ... - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # - output mismatch (see /home/adam/xfstests/results//generic/362.out.bad) # --- tests/generic/362.out 2024-08-24 15:31:37.200000000 +0930 # +++ /home/adam/xfstests/results//generic/362.out.bad 2026-05-27 10:13:09.072485767 +0930 # @@ -1,2 +1,3 @@ # QA output created by 362 # +Wrong file size after first write, got 8192 expected 4096 # Silence is golden # ...
*: If the test case has been executed before with default data checksum, the failure will not reproduce. Need the following fix to make it reliably reproducible:
https://lore.kernel.org/linux-btrfs/[email protected]/
[CAUSE]
Inside btrfs_dio_iomap_begin() for a direct write, we increase the isize if it's beyond the current isize.
But if the direct io finished short, we do not revert the isize to the previous value nor to the short write end.
Then if we need to fall back to buffered writes, and the write has IOCB_APPEND flag, then the buffered write will be positioned at the incorrect isize.
The call chain looks like this:
btrfs_direct_write(pos=0, length=4K)
|- __iomap_dio_rw()
| |- iomap_iter()
| | |- btrfs_dio_iomap_begin()
| | |- btrfs_get_blocks_direct_write()
| | |- i_size_write()
| | Which updates the isize to the write end (4K).
| |
| |- iomap_dio_iter()
| | Failed with -EFAULT on the first page.
| |
| |- iomap_iter()
| | |- btrfs_dio_iomap_end()
| | Detects a short write, return -ENOTBLK
| |- if (ret == -ENOTBLK) { ret = 0;}
| Which resets the return value.
|
|- ret = iomap_dio_complet()
| Which returns 0.
|
|- btrfs_buffered_write(iocb, from); |- generic_write_checks()
|- iocb->ki_pos = i_size_read()
Which is still the new size (4K), other than the original isize 0.
[FIX]
Introduce the following btrfs_dio_data members:
- old_isize
- updated_isize
If the direct write has enlarged the isize.
Then if we got a short write, and btrfs_dio_data::updated_isize is set, revert to the correct isize based on old_isize and current file position.
And here we call i_size_write() without holding an extent lock, which is a very special case that we're safe to do:
- Only a single writer can be enlarging isize Enlarging isize will take the exclusive inode lock.
- Buffered readers need to wait for the OE we're holding Buffered readers will lock extent and wait for OE of the folio range. Sometimes we can skip the OE wait, but since all page cache is invalidated, the OE wait can not be skipped.
But I do not think this is the most elegant solution, nor covers all cases. E.g. if the bio is submitted but IO failed, we are unable to do the revert.
I believe the more elegant one would be extend the EXTENT_DIO_LOCKED lifespan for direct writes, so that we can update the isize when a write beyond EOF finished successfully.
However that change is too huge for a small bug fix. So only implement the minimal partial fix for now.
[REASON FOR NO FIXES TAG]
The bug is again very old, before commit f85781fb505e ("btrfs: switch to iomap for direct IO") we are already increasing isize without a proper rollback for short writes.
Thus only a CC to stable.
--- fs/btrfs/inode.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +42 -1
@@ -61,7 +61,9 @@ struct btrfs_iget_args {struct btrfs_dio_data {ssize_t submitted; +loff_t old_isize;struct extent_changeset *data_reserved; +bool updated_isize; };static const struct inode_operations btrfs_dir_inode_operations;
@@ -7904,6 +7906,7 @@ static int btrfs_get_blocks_direct_writebool can_nocow = false;bool space_reserved = false;u64 prev_len; +loff_t old_isize;int ret =0 ;/*
@@ -7997,8 +8000,14 @@ static int btrfs_get_blocks_direct_write* Need to update the i_size under the extent lock so buffered * readers will get the updated i_size when we unlock. */ -if (start + len >i_size_read (inode)) + old_isize =i_size_read (inode); +if (start + len > old_isize) { +if (!dio_data->updated_isize) { + dio_data->old_isize = old_isize; + dio_data->updated_isize = true; + }i_size_write (inode, start + len); + } out:if (ret && space_reserved) {btrfs_delalloc_release_extents (BTRFS_I (inode), len);
@@ -8211,6 +8220,38 @@ static int btrfs_dio_iomap_end(struct instruct btrfs_ordered_extent *ordered;/* +* Got a short write and have updated the isize, need to +* revert the isize change. +* +* Normally we need to update isize with extent lock hold, +* but we're safe due to the following factors: +* +* - Only a single writer can be enlarging isize +* Enlarging isize will take the exclusive inode lock. +* +* - Buffered readers need to wait for the OE we're holding +* Buffered readers will lock extent and wait for OE +* of the folio range, and since page cache is invalidated +* the OE wait can not be skipped. +* +* So here we are safe to revert the isize before +* finishing the OE, and no reader of the remaining range +* can see the enlarged size. +* +* TODO: Extend the DIO_LOCKED lifespan for direct writes, +* and only enlarge isize after a successful write. +*/ +if (dio_data->updated_isize) { +u64 new_isize; + +if (submitted ==0 ) + new_isize = dio_data->old_isize; +else + new_isize =max (dio_data->old_isize, pos); +i_size_write (inode, new_isize); + dio_data->updated_isize = false; + } +/* * We have a short write. Any range that was properly * submitted will be finished through the bio * completion path with an uptodate status matching
Greg Kroah-Hartman
maintainerPATCH 831/843 audit: add audit_log_nf_skb helper function
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Robaina <[email protected]>
[ Upstream commit f19590b07cb620be1fcd5474c49515e21a05d406 ]
Netfilter code (net/netfilter/nft_log.c and net/netfilter/xt_AUDIT.c) have to be kept in sync. Both source files had duplicated versions of audit_ip4() and audit_ip6() functions, which can result in lack of consistency and/or duplicated work.
This patch adds a helper function in audit.c that can be called by netfilter code commonly, aiming to improve maintainability and consistency.
Stable-dep-of: 65dfde57d1e2 ("audit: fix potential integer overflow in audit_log_n_hex()")
--- include/linux/audit.h | 8 +++++ kernel/audit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ net/netfilter/nft_log.c | 58 ------------------------------------------ net/netfilter/xt_AUDIT.c | 58 ------------------------------------------ 4 files changed, 74 insertions(+), 114 deletions(-)
include/linux/audit.h +8 -0
@@ -186,6 +186,8 @@ extern void audit_log_lost(const chextern int audit_log_task_context (struct audit_buffer *ab);extern void audit_log_task_info (struct audit_buffer *ab); +extern int audit_log_nf_skb (struct audit_buffer *ab, +const struct sk_buff *skb,u8 nfproto);extern int audit_update_lsm_rules (void );
@@ -251,6 +253,12 @@ static inline int audit_log_task_contextstatic inline void audit_log_task_info (struct audit_buffer *ab) { } +static inline int audit_log_nf_skb (struct audit_buffer *ab, +const struct sk_buff *skb,u8 nfproto) +{ +return 0 ; +} +static inline kuid_t audit_get_loginuid (struct task_struct *tsk) {return INVALID_UID ;
kernel/audit.c +64 -0
76 lines not on this page · raw message
net/netfilter/nft_log.c +1 -57
74 lines not on this page · raw message
net/netfilter/xt_AUDIT.c +1 -57
74 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 832/843 audit: fix potential integer overflow in audit_log_n_hex()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Robaina <[email protected]>
[ Upstream commit 65dfde57d1e29ce2b76fc23dd565eccd5c0bc0f0 ]
The function calculates new_len as len << 1 for hex encoding. This has two overflow risks: the shift itself can overflow when len is large, and the result can be truncated when assigned to new_len (declared as int) from the size_t calculation.
Fix by using check_shl_overflow() to catch shift overflow and changing new_len and loop counter i to size_t to prevent truncation.
--- kernel/audit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/audit.c +9 -2
@@ -61,6 +61,7 @@#include <net/netns/generic.h> #include <net/ip.h> #include <net/ipv6.h> +#include <linux/overflow.h> #include "audit.h"
@@ -2037,7 +2038,8 @@ void audit_log_format(struct audit_buffevoid audit_log_n_hex (struct audit_buffer *ab,const unsigned char *buf,size_t len) { -int i, avail, new_len; +int avail; +size_t i, new_len;unsigned char *ptr;struct sk_buff *skb;
@@ -2047,7 +2049,12 @@ void audit_log_n_hex(struct audit_bufferBUG_ON (!ab->skb); skb = ab->skb; avail =skb_tailroom (skb); - new_len = len<<1 ; + +if (check_shl_overflow (len,1 , &new_len)) { +audit_log_format (ab,"?" ); +return ; + } +if (new_len >= avail) {/* Round the buffer request up to the next multiple */ new_len =AUDIT_BUFSIZ *(((new_len-avail)/AUDIT_BUFSIZ ) +1 );
Greg Kroah-Hartman
maintainerPATCH 833/843 regulator: scmi: fix of_node refcount leak in scmi_regulator_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit fa11039d6cdff84584a3ef8cc1f5e1b56e045da2 ]
scmi_regulator_probe() calls of_find_node_by_name() which takes a reference on the returned device node. On the error path where process_scmi_regulator_of_node() fails, the function returns without calling of_node_put() on the child node, leaking the reference.
Add of_node_put(np) on the error path to properly release the reference.
--- drivers/regulator/scmi-regulator.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/scmi-regulator.c +1 -0
@@ -350,6 +350,7 @@ static int scmi_regulator_probe(struct s/* abort on any mem issue */ if (ret == -ENOMEM ) {of_node_put (child); +of_node_put (np);return ret; } }
Greg Kroah-Hartman
maintainerPATCH 834/843 posix-cpu-timers: Use u64 multiplication in update_rlimit_cpu()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <[email protected]>
commit 26aff38fefb1d6cd87e22525f41cc8f1aa61b24f upstream.
update_rlimit_cpu() converts the RLIMIT_CPU value to nanoseconds with
u64 nsecs = rlim_new * NSEC_PER_SEC;
On 32-bit kernels both rlim_new (unsigned long) and NSEC_PER_SEC (1000000000L) are 32-bit, so the multiplication is performed in unsigned long and truncated for rlim_new > 4 seconds before being widened to u64.
The same file already casts to u64 for the matching computation in check_process_timers():
u64 softns = (u64)soft * NSEC_PER_SEC;
As a result, the truncated value is installed into the CPUCLOCK_PROF expiry cache (nextevt), causing the process CPU timer to be programmed to fire prematurely for any RLIMIT_CPU soft limit >= 5 seconds. The actual SIGXCPU/SIGKILL decision in check_process_timers() already casts to u64 and is therefore correct, so limit enforcement is not broken; only the expiry-cache programming is wrong. Apply the same cast here so both paths convert rlim_cur identically.
64-bit kernels are unaffected.
--- kernel/time/posix-cpu-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/posix-cpu-timers.c +1 -1
@@ -37,7 +37,7 @@ void posix_cputimers_group_init(struct p*/ void update_rlimit_cpu (struct task_struct *task,unsigned long rlim_new) { -u64 nsecs = rlim_new *NSEC_PER_SEC ; +u64 nsecs = (u64 )rlim_new *NSEC_PER_SEC ;spin_lock_irq (&task->sighand->siglock);set_process_cpu_timer (task,CPUCLOCK_PROF , &nsecs,NULL );
Greg Kroah-Hartman
maintainerPATCH 835/843 KVM: Move kvm_io_bus_get_dev() locking responsibilities to callers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 3a07249981629ace483ebbef81ef6b34c2d2afec upstream.
kvm_io_bus_get_dev() returns a device that is only matched by the address, and nothing else. This can cause a lifetime issue if the matched device is not the expected type, as by the time the caller can introspect the object, it might be gone (the srcu lock having been dropped).
Given that there is only a single user of this helper, the simplest option is to move the locking responsibility to the caller, which can keep the srcu lock held for as long as it wants.
Note that this aligns with other kvm_io_bus*() helpers, which already require the srcu lock to be held by the callers.
--- arch/arm64/kvm/vgic/vgic-its.c | 2 ++ virt/kvm/kvm_main.c | 16 +++++----------- 2 files changed, 7 insertions(+), 11 deletions(-)
arch/arm64/kvm/vgic/vgic-its.c +2 -0
@@ -713,6 +713,8 @@ struct vgic_its *vgic_msi_to_its(struct address = (u64 )msi->address_hi <<32 | msi->address_lo; +guard (srcu)(&kvm->srcu); + kvm_io_dev =kvm_io_bus_get_dev (kvm,KVM_MMIO_BUS , address);if (!kvm_io_dev)return ERR_PTR (-EINVAL );
virt/kvm/kvm_main.c +5 -11
@@ -5222,25 +5222,19 @@ struct kvm_io_device *kvm_io_bus_get_dev gpa_t addr) {struct kvm_io_bus *bus; -int dev_idx, srcu_idx; -struct kvm_io_device *iodev =NULL ; +int dev_idx; - srcu_idx =srcu_read_lock (&kvm->srcu); +lockdep_assert_held (&kvm->srcu); bus =srcu_dereference (kvm->buses[bus_idx], &kvm->srcu);if (!bus) - goto out_unlock; +return NULL ; dev_idx =kvm_io_bus_get_first_dev (bus, addr,1 );if (dev_idx <0 ) - goto out_unlock; +return NULL ; - iodev = bus->range[dev_idx].dev; - -out_unlock: -srcu_read_unlock (&kvm->srcu, srcu_idx); - -return iodev; +return bus->range[dev_idx].dev; }EXPORT_SYMBOL_GPL (kvm_io_bus_get_dev);
Greg Kroah-Hartman
maintainerPATCH 836/843 Bluetooth: L2CAP: Fix regressions caused by reusing ident
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 761fb8ec8778f0caf2bba5a41e3cff1ea86974f3 upstream.
This attempt to fix regressions caused by reusing ident which apparently is not handled well on certain stacks causing the stack to not respond to requests, so instead of simple returning the first unallocated id this stores the last used tx_ident and then attempt to use the next until all available ids are exausted and then cycle starting over to 1.
--- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
include/net/bluetooth/l2cap.h +1 -0
@@ -692,6 +692,7 @@ struct l2cap_conn {struct sk_buff *rx_skb;__u32 rx_len;struct ida tx_ida; +__u8 tx_ident;struct sk_buff_head pending_rx;struct work_struct pending_rx_work;
net/bluetooth/l2cap_core.c +26 -3
@@ -939,16 +939,39 @@ int l2cap_chan_check_security(struct l2cstatic int l2cap_get_ident (struct l2cap_conn *conn) { +u8 max; +int ident; +/* LE link does not support tools like l2ping so use the full range */ if (conn->hcon->type ==LE_LINK ) -return ida_alloc_range (&conn->tx_ida,1 ,255 ,GFP_ATOMIC ); - + max =255 ;/* Get next available identificator. * 1 - 128 are used by kernel. * 129 - 199 are reserved. * 200 - 254 are used by utilities like l2ping, etc. */ -return ida_alloc_range (&conn->tx_ida,1 ,128 ,GFP_ATOMIC ); +else + max =128 ; + +/* Allocate ident using min as last used + 1 (cyclic) */ + ident =ida_alloc_range (&conn->tx_ida,READ_ONCE (conn->tx_ident) +1 , + max,GFP_ATOMIC ); +/* Force min 1 to start over */ +if (ident <=0 ) { + ident =ida_alloc_range (&conn->tx_ida,1 , max,GFP_ATOMIC ); +if (ident <=0 ) { +/* If all idents are in use, log an error, this is +* extremely unlikely to happen and would indicate a bug +* in the code that idents are not being freed properly. +*/ +BT_ERR ("Unable to allocate ident: %d" , ident); +return 0 ; + } + } + +WRITE_ONCE (conn->tx_ident, ident); + +return ident; } static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
Greg Kroah-Hartman
maintainerPATCH 837/843 ALSA: seq: Avoid confusion of aligned read size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8c15a18331191b67bdce54d21af068baec044baf upstream.
Currently the read event packet size in snd_seq_read() is defined by client->midi_version value that is guaranteed to be zero if UMP isn't enabled. But the static analyzer doesn't know of the fact, and it still suspects as if it were leading to a potential overflow.
Add the more explicit check of CONFIG_SND_SEQ_UMP to determine the aligned_size value for avoiding the confusion.
--- sound/core/seq/seq_clientmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_clientmgr.c +1 -1
@@ -441,7 +441,7 @@ static ssize_t snd_seq_read(struct file err =0 ;snd_seq_fifo_lock (fifo); -if (client->midi_version >0 ) +if (IS_ENABLED (CONFIG_SND_SEQ_UMP ) && client->midi_version >0 ) aligned_size =sizeof (struct snd_seq_ump_event );else aligned_size =sizeof (struct snd_seq_event );
Greg Kroah-Hartman
maintainerPATCH 838/843 iio: imu: inv_mpu6050: fix frequency setting when chip is off
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit daec424cc57b33a28f8621eb7ac85f8bd327bd6b upstream.
Track correctly FIFO state and apply ODR change before starting the chip. Without the fix, you cannot change ODR more than 1 time when data buffering is off. This restriction on a single pending ODR change should only apply when the FIFO is on.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +5 -0
@@ -111,6 +111,7 @@ int inv_mpu6050_prepare_fifo(struct inv_if (enable) {/* reset timestamping */ inv_sensors_timestamp_reset (&st->timestamp); +inv_sensors_timestamp_apply_odr (&st->timestamp,0 ,0 ,0 );/* reset FIFO */ d = st->chip_config.user_ctrl |INV_MPU6050_BIT_FIFO_RST ; ret =regmap_write (st->map, st->reg->user_ctrl, d);
@@ -184,6 +185,10 @@ static int inv_mpu6050_set_enable(structif (result) goto error_power_off; }else { + st->chip_config.gyro_fifo_enable =0 ; + st->chip_config.accl_fifo_enable =0 ; + st->chip_config.temp_fifo_enable =0 ; + st->chip_config.magn_fifo_enable =0 ; result =inv_mpu6050_prepare_fifo (st, false);if (result) goto error_power_off;
Greg Kroah-Hartman
maintainerPATCH 839/843 iio: invensense: fix odr switching to same value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 95444b9eeb8c5c0330563931d70c61ca3b101548 upstream.
ODR switching happens in 2 steps, update to store the new value and then apply when the ODR change flag is received in the data. When switching to the same ODR value, the ODR change flag is never happening, and frequency switching is blocked waiting for the never coming apply.
Fix the issue by preventing update to happen when switching to same ODR value.
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +5 -1
@@ -60,11 +60,15 @@ EXPORT_SYMBOL_NS_GPL(inv_sensors_timestaint inv_sensors_timestamp_update_odr (struct inv_sensors_timestamp *ts,uint32_t period,bool fifo) { +uint32_t mult; +/* when FIFO is on, prevent odr change if one is already pending */ if (fifo && ts->new_mult !=0 )return -EAGAIN ; - ts->new_mult = period / ts->chip.clock_period; + mult = period / ts->chip.clock_period; +if (mult != ts->mult) + ts->new_mult = mult;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 840/843 ALSA: seq: Skip event type filtering for UMP events
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 32108c22ac619c32dd6db594319e259b63bfb387 upstream.
UMP events don't use the event type field, hence it's invalid to apply the filter, which may drop the events unexpectedly.
Skip the event filtering for UMP events, instead.
--- sound/core/seq/seq_clientmgr.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/seq/seq_clientmgr.c +3 -0
@@ -528,6 +528,9 @@ static struct snd_seq_client *get_event_return NULL ;if (! dest->accept_input) goto __not_avail; +if (snd_seq_ev_is_ump (event)) +return dest;/* ok - no filter checks */ +if ((dest->filter &SNDRV_SEQ_FILTER_USE_EVENT ) && !test_bit (event->type, dest->event_filter)) goto __not_avail;
Greg Kroah-Hartman
maintainerPATCH 841/843 ALSA: seq: Check UMP support for midi_version change
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8765429279e7d3d68d39ace5f84af2815174bb1e upstream.
When the kernel is built without UMP support but a user-space app requires the midi_version > 0, the kernel should return an error. Otherwise user-space assumes as if it were possible to deal, eventually hitting serious errors later.
--- sound/core/seq/seq_clientmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/core/seq/seq_clientmgr.c +10 -4
@@ -1330,10 +1330,16 @@ static int snd_seq_ioctl_set_client_infoif (client->type != client_info->type)return -EINVAL ; -/* check validity of midi_version field */ -if (client->user_pversion >=SNDRV_PROTOCOL_VERSION (1 ,0 ,3 ) && - client_info->midi_version >SNDRV_SEQ_CLIENT_UMP_MIDI_2_0 ) -return -EINVAL ; +if (client->user_pversion >=SNDRV_PROTOCOL_VERSION (1 ,0 ,3 )) { +/* check validity of midi_version field */ +if (client_info->midi_version >SNDRV_SEQ_CLIENT_UMP_MIDI_2_0 ) +return -EINVAL ; + +/* check if UMP is supported in kernel */ +if (!IS_ENABLED (CONFIG_SND_SEQ_UMP ) && + client_info->midi_version >0 ) +return -EINVAL ; + }/* fill the info fields */ if (client_info->name[0 ])
Greg Kroah-Hartman
maintainerPATCH 842/843 iio: imu: inv_icm42600: fix timestamp clock period by using lower value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 8b0b864c11a2e2ada470f9d5010e1c2bf1eceef2 upstream.
Clock period value is used for computing periods of sampling. There is no need for it to be higher than the maximum odr, otherwise we are losing precision in the computation for nothing.
Switch clock period value to maximum odr period (8kHz).
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 4 ++-- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +2 -2
@@ -720,10 +720,10 @@ struct iio_dev *inv_icm42600_accel_init(return ERR_PTR (-ENOMEM );/* -* clock period is 32kHz (31250ns) +* clock period is 8kHz (125000ns) * jitter is +/- 2% (20 per mille) */ - ts_chip.clock_period =31250 ; + ts_chip.clock_period =125000 ; ts_chip.jitter =20 ; ts_chip.init_period =inv_icm42600_odr_to_period (st->conf.accel.odr); ts =iio_priv (indio_dev);
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +2 -2
@@ -731,10 +731,10 @@ struct iio_dev *inv_icm42600_gyro_init(sreturn ERR_PTR (-ENOMEM );/* -* clock period is 32kHz (31250ns) +* clock period is 8kHz (125000ns) * jitter is +/- 2% (20 per mille) */ - ts_chip.clock_period =31250 ; + ts_chip.clock_period =125000 ; ts_chip.jitter =20 ; ts_chip.init_period =inv_icm42600_odr_to_period (st->conf.accel.odr); ts =iio_priv (indio_dev);
Greg Kroah-Hartman
maintainerPATCH 843/843 ALSA: seq: Fix uninitialised heap leak in snd_seq_event_dup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
commit 435990e25bf1f4af3e6df12a6fbfd1f7ba4a97d4 upstream.
snd_seq_event_dup() copies an incoming event into a pool cell and, in the UMP-enabled build, clears the trailing cell->ump.raw.extra word that the memcpy() did not cover. The guard deciding whether to clear it compares the copied size against sizeof(cell->event):
memcpy(&cell->ump, event, size); if (size < sizeof(cell->event)) cell->ump.raw.extra = 0;
For a legacy (non-UMP) event, size == sizeof(struct snd_seq_event) == sizeof(cell->event), so the condition is false and the extra word keeps stale data. The cell pool is allocated with kvmalloc() (not zeroed) and cells are reused via a free list, so that word holds uninitialised heap or leftover event data.
When such a cell is delivered to a UMP client (client->midi_version > 0) that set SNDRV_SEQ_FILTER_NO_CONVERT -- so the legacy event reaches it unconverted -- snd_seq_read() reads it out as the larger struct snd_seq_ump_event and copies the stale word to user space, a 4-byte kernel heap infoleak to an unprivileged /dev/snd/seq client.
Compare against sizeof(cell->ump) instead, so the trailing word is zeroed for every event shorter than the UMP cell.
--- sound/core/seq/seq_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_memory.c +1 -1
@@ -309,7 +309,7 @@ int snd_seq_event_dup(struct snd_seq_poo size =snd_seq_event_packet_size (event);memcpy (&cell->ump, event, size);#if IS_ENABLED (CONFIG_SND_SEQ_UMP ) -if (size <sizeof (cell->event)) +if (size <sizeof (cell->ump)) cell->ump.raw.extra =0 ;#endif
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.212 release. There are 843 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, 23 Jul 2026 15:23:00 +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/v5.x/stable-review/patch-5.15.212-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.212 release. There are 843 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, 23 Jul 2026 15:23:00 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.212-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 5.15.212 release. There are 843 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.15.y
Best regards,
Pavel