6.1.120-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 265/772 f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qi Han <[email protected]>
[ Upstream commit 26413ce18e85de3dda2cd3d72c3c3e8ab8f4f996 ]
After release a file and subsequently reserve it, the FSCK flag is set when the file is deleted, as shown in the following backtrace:
F2FS-fs (dm-48): Inconsistent i_blocks, ino:401231, iblocks:1448, sectors:1472
fs_rec_info_write_type+0x58/0x274 f2fs_rec_info_write+0x1c/0x2c set_sbi_flag+0x74/0x98 dec_valid_block_count+0x150/0x190 f2fs_truncate_data_blocks_range+0x2d4/0x3cc f2fs_do_truncate_blocks+0x2fc/0x5f0 f2fs_truncate_blocks+0x68/0x100 f2fs_truncate+0x80/0x128 f2fs_evict_inode+0x1a4/0x794 evict+0xd4/0x280 iput+0x238/0x284 do_unlinkat+0x1ac/0x298 __arm64_sys_unlinkat+0x48/0x68 invoke_syscall+0x58/0x11c
For clusters of the following type, i_blocks are decremented by 1 and i_compr_blocks are incremented by 7 in release_compress_blocks, while updates to i_blocks and i_compr_blocks are skipped in reserve_compress_blocks.
raw node:
D D D D D D D D
after compress:
C D D D D D D D
after reserve:
C D D D D D D D
Let's update i_blocks and i_compr_blocks properly in reserve_compress_blocks.
--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
@@ -3703,7 +3703,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count, to_reserved = cluster_size - compr_blocks - reserved;/* for the case all blocks in cluster were reserved */ -if (to_reserved ==1 ) { +if (reserved && to_reserved ==1 ) { dn->ofs_in_node += cluster_size; goto next; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/772 f2fs: fix to account dirty data in __get_secs_required()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 1acd73edbbfef2c3c5b43cba4006a7797eca7050 ]
It will trigger system panic w/ testcase in [1]:
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:2752! RIP: 0010:new_curseg+0xc81/0x2110 Call Trace: f2fs_allocate_data_block+0x1c91/0x4540 do_write_page+0x163/0xdf0 f2fs_outplace_write_data+0x1aa/0x340 f2fs_do_write_data_page+0x797/0x2280 f2fs_write_single_data_page+0x16cd/0x2190 f2fs_write_cache_pages+0x994/0x1c80 f2fs_write_data_pages+0x9cc/0xea0 do_writepages+0x194/0x7a0 filemap_fdatawrite_wbc+0x12b/0x1a0 __filemap_fdatawrite_range+0xbb/0xf0 file_write_and_wait_range+0xa1/0x110 f2fs_do_sync_file+0x26f/0x1c50 f2fs_sync_file+0x12b/0x1d0 vfs_fsync_range+0xfa/0x230 do_fsync+0x3d/0x80 __x64_sys_fsync+0x37/0x50 x64_sys_call+0x1e88/0x20d0 do_syscall_64+0x4b/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e
The root cause is if checkpoint_disabling and lfs_mode are both on, it will trigger OPU for all overwritten data, it may cost more free segment than expected, so f2fs must account those data correctly to calculate cosumed free segments later, and return ENOSPC earlier to avoid run out of free segment during block allocation.
[1] https://lore.kernel.org/fstests/[email protected]/
--- fs/f2fs/segment.h | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
fs/f2fs/segment.h +25 -10
@@ -584,18 +584,21 @@ static inline int reserved_sections(struct f2fs_sb_info *sbi) }static inline bool has_curseg_enough_space (struct f2fs_sb_info *sbi, -unsigned int node_blocks,unsigned int dent_blocks) +unsigned int node_blocks,unsigned int data_blocks, +unsigned int dent_blocks) { -unsigned segno, left_blocks; +unsigned int segno, left_blocks, blocks;int i; -/* check current node sections in the worst case. */ -for (i =CURSEG_HOT_NODE ; i <=CURSEG_COLD_NODE ; i++) { +/* check current data/node sections in the worst case. */ +for (i =CURSEG_HOT_DATA ; i <NR_PERSISTENT_LOG ; i++) { segno =CURSEG_I (sbi, i)->segno; left_blocks =CAP_BLKS_PER_SEC (sbi) -get_ckpt_valid_blocks (sbi, segno, true); -if (node_blocks > left_blocks) + + blocks = i <=CURSEG_COLD_DATA ? data_blocks : node_blocks; +if (blocks > left_blocks)return false; }
@@ -609,8 +612,9 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi, }/* -* calculate needed sections for dirty node/dentry -* and call has_curseg_enough_space +* calculate needed sections for dirty node/dentry and call +* has_curseg_enough_space, please note that, it needs to account +* dirty data as well in lfs mode when checkpoint is disabled. */ static inline void __get_secs_required (struct f2fs_sb_info *sbi,unsigned int *lower_p,unsigned int *upper_p,bool *curseg_p)
@@ -619,19 +623,30 @@ static inline void __get_secs_required(struct f2fs_sb_info *sbi,get_pages (sbi,F2FS_DIRTY_DENTS ) +get_pages (sbi,F2FS_DIRTY_IMETA );unsigned int total_dent_blocks =get_pages (sbi,F2FS_DIRTY_DENTS ); +unsigned int total_data_blocks =0 ;unsigned int node_secs = total_node_blocks /CAP_BLKS_PER_SEC (sbi);unsigned int dent_secs = total_dent_blocks /CAP_BLKS_PER_SEC (sbi); +unsigned int data_secs =0 ;unsigned int node_blocks = total_node_blocks %CAP_BLKS_PER_SEC (sbi);unsigned int dent_blocks = total_dent_blocks %CAP_BLKS_PER_SEC (sbi); +unsigned int data_blocks =0 ; + +if (f2fs_lfs_mode (sbi) && +unlikely (is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) { + total_data_blocks =get_pages (sbi,F2FS_DIRTY_DATA ); + data_secs = total_data_blocks /CAP_BLKS_PER_SEC (sbi); + data_blocks = total_data_blocks %CAP_BLKS_PER_SEC (sbi); + }if (lower_p) - *lower_p = node_secs + dent_secs; + *lower_p = node_secs + dent_secs + data_secs;if (upper_p) *upper_p = node_secs + dent_secs + - (node_blocks ?1 :0 ) + (dent_blocks ?1 :0 ); + (node_blocks ?1 :0 ) + (dent_blocks ?1 :0 ) + + (data_blocks ?1 :0 );if (curseg_p) *curseg_p =has_curseg_enough_space (sbi, - node_blocks, dent_blocks); + node_blocks, data_blocks, dent_blocks); } static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/772 perf probe: Fix libdw memory leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 4585038b8e186252141ef86e9f0d8e97f11dce8d ]
Add missing dwarf_cfi_end to free memory associated with probe_finder cfi_eh which is allocated and owned via a call to dwarf_getcfi_elf. Confusingly cfi_dbg shouldn't be freed as its memory is owned by the passed in debuginfo struct. Add comments to highlight this.
This addresses leak sanitizer issues seen in:tools/perf/tests/shell/test_uprobe_from_different_cu.sh
--- tools/perf/util/probe-finder.c | 4 ++++ tools/perf/util/probe-finder.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +4 -0
@@ -1490,6 +1490,10 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,if (ret >=0 && tf.pf.skip_empty_arg) ret =fill_empty_trace_arg (pev, tf.tevs, tf.ntevs); +#if _ELFUTILS_PREREQ (0 ,142 ) +dwarf_cfi_end (tf.pf.cfi_eh); +#endif +if (ret <0 || tf.ntevs ==0 ) {for (i =0 ; i < tf.ntevs; i++)clear_probe_trace_event (&tf.tevs[i]);
tools/perf/util/probe-finder.h +2 -2
@@ -81,9 +81,9 @@ struct probe_finder {/* For variable searching */ #if _ELFUTILS_PREREQ (0 ,142 ) -/* Call Frame Information from .eh_frame */ +/* Call Frame Information from .eh_frame. Owned by this struct. */ Dwarf_CFI *cfi_eh; -/* Call Frame Information from .debug_frame */ +/* Call Frame Information from .debug_frame. Not owned. */ Dwarf_CFI *cfi_dbg;#endif Dwarf_Op *fb_ops;/* Frame base attribute */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/772 perf probe: Correct demangled symbols in C++ program
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 314909f13cc12d47c468602c37dace512d225eeb ]
An issue can be observed when probe C++ demangled symbol with steps:
# nm test_cpp_mangle | grep print_data
0000000000000c94 t _GLOBAL__sub_I__Z10print_datai
0000000000000afc T _Z10print_datai
0000000000000b38 T _Z10print_dataR5Point # perf probe -x /home/niayan01/test_cpp_mangle -F --demangle
...
print_data(Point&)
print_data(int)
... # perf --debug verbose=3 probe -x test_cpp_mangle --add "test=print_data(int)"
probe-definition(0): test=print_data(int)
symbol:print_data(int) file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /home/niayan01/test_cpp_mangle
Try to find probe point from debuginfo.
Symbol print_data(int) address found : afc
Matched function: print_data [2ccf]
Probe point found: print_data+0
Found 1 probe_trace_events.
Opening /sys/kernel/tracing//uprobe_events write=1
Opening /sys/kernel/tracing//README write=0
Writing event: p:probe_test_cpp_mangle/test /home/niayan01/test_cpp_mangle:0xb38
...When tried to probe symbol "print_data(int)", the log shows:
Symbol print_data(int) address found : afc
The found address is 0xafc - which is right with verifying the output result from nm. Afterwards when write event, the command uses offset 0xb38 in the last log, which is a wrong address.
The dwarf_diename() gets a common function name, in above case, it returns string "print_data". As a result, the tool parses the offset based on the common name. This leads to probe at the wrong symbol "print_data(Point&)".
To fix the issue, use the die_get_linkage_name() function to retrieve the distinct linkage name - this is the mangled name for the C++ case. Based on this unique name, the tool can get a correct offset for probing. Based on DWARF doc, it is possible the linkage name is missed in the DIE, it rolls back to use dwarf_diename().
After:
# perf --debug verbose=3 probe -x test_cpp_mangle --add "test=print_data(int)"
probe-definition(0): test=print_data(int)
symbol:print_data(int) file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /home/niayan01/test_cpp_mangle
Try to find probe point from debuginfo.
Symbol print_data(int) address found : afc
Matched function: print_data [2d06]
Probe point found: print_data+0
Found 1 probe_trace_events.
Opening /sys/kernel/tracing//uprobe_events write=1
Opening /sys/kernel/tracing//README write=0
Writing event: p:probe_test_cpp_mangle/test /home/niayan01/test_cpp_mangle:0xafc
Added new event:
probe_test_cpp_mangle:test (on print_data(int) in /home/niayan01/test_cpp_mangle)You can now use it in all perf tools, such as:
perf record -e probe_test_cpp_mangle:test -aR sleep 1
# perf --debug verbose=3 probe -x test_cpp_mangle --add "test2=print_data(Point&)"
probe-definition(0): test2=print_data(Point&)
symbol:print_data(Point&) file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /home/niayan01/test_cpp_mangle
Try to find probe point from debuginfo.
Symbol print_data(Point&) address found : b38
Matched function: print_data [2ccf]
Probe point found: print_data+0
Found 1 probe_trace_events.
Opening /sys/kernel/tracing//uprobe_events write=1
Parsing probe_events: p:probe_test_cpp_mangle/test /home/niayan01/test_cpp_mangle:0x0000000000000afc
Group:probe_test_cpp_mangle Event:test probe:p
Opening /sys/kernel/tracing//README write=0
Writing event: p:probe_test_cpp_mangle/test2 /home/niayan01/test_cpp_mangle:0xb38
Added new event:
probe_test_cpp_mangle:test2 (on print_data(Point&) in /home/niayan01/test_cpp_mangle)You can now use it in all perf tools, such as:
perf record -e probe_test_cpp_mangle:test2 -aR sleep 1
--- tools/perf/util/probe-finder.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +15 -2
@@ -1736,8 +1736,21 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, u64 addr,/* Find a corresponding function (name, baseline and baseaddr) */ if (die_find_realfunc (&cudie, (Dwarf_Addr )addr, &spdie)) { -/* Get function entry information */ - func = basefunc =dwarf_diename (&spdie); +/* +* Get function entry information. +* +* As described in the document DWARF Debugging Information +* Format Version 5, section 2.22 Linkage Names, "mangled names, +* are used in various ways, ... to distinguish multiple +* entities that have the same name". +* +* Firstly try to get distinct linkage name, if fail then +* rollback to get associated name in DIE. +*/ + func = basefunc =die_get_linkage_name (&spdie); +if (!func) + func = basefunc =dwarf_diename (&spdie); +if (!func ||die_entrypc (&spdie, &baseaddr) !=0 ||dwarf_decl_line (&spdie, &baseline) !=0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/772 PCI: cpqphp: Use PCI_POSSIBLE_ERROR() to check config reads
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: weiyufeng <[email protected]>
[ Upstream commit 87d5403378cccc557af9e02a8a2c8587ad8b7e9a ]
Use PCI_POSSIBLE_ERROR() to check the response we get when we read data from hardware. This unifies PCI error response checking and makes error checks consistent and easier to find.
Stable-dep-of: e2226dbc4a49 ("PCI: cpqphp: Fix PCIBIOS_* return value confusion")
--- drivers/pci/hotplug/cpqphp_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +2 -2
@@ -138,7 +138,7 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 oif (pci_bus_read_config_dword (bus, devfn,PCI_VENDOR_ID , &vendID) ==-1 )return -1 ; -if (vendID ==0xffffffff ) +if (PCI_POSSIBLE_ERROR (vendID))return -1 ;return pci_bus_read_config_dword (bus, devfn, offset, value); }
@@ -253,7 +253,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num *dev_num = tdevice; ctrl->pci_bus->number = tbus;pci_bus_read_config_dword (ctrl->pci_bus, *dev_num,PCI_VENDOR_ID , &work); -if (!nobridge || (work ==0xffffffff )) +if (!nobridge ||PCI_POSSIBLE_ERROR (work))return 0 ;dbg ("bus_num %d devfn %d\n" , *bus_num, *dev_num);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/772 PCI: cpqphp: Fix PCIBIOS_* return value confusion
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit e2226dbc4a4919d9c8bd9293299b532090bdf020 ]
Code in and related to PCI_RefinedAccessConfig() has three types of return type confusion:
- PCI_RefinedAccessConfig() tests pci_bus_read_config_dword() return value against -1.
- PCI_RefinedAccessConfig() returns both -1 and PCIBIOS_* return codes.
- Callers of PCI_RefinedAccessConfig() only test for -1.
Make PCI_RefinedAccessConfig() return PCIBIOS_* codes consistently and adapt callers accordingly.
--- drivers/pci/hotplug/cpqphp_pci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +10 -5
@@ -135,11 +135,13 @@ int cpqhp_unconfigure_device(struct pci_func *func)static int PCI_RefinedAccessConfig (struct pci_bus *bus,unsigned int devfn,u8 offset,u32 *value) {u32 vendID =0 ; +int ret; -if (pci_bus_read_config_dword (bus, devfn,PCI_VENDOR_ID , &vendID) ==-1 ) -return -1 ; + ret =pci_bus_read_config_dword (bus, devfn,PCI_VENDOR_ID , &vendID); +if (ret !=PCIBIOS_SUCCESSFUL ) +return PCIBIOS_DEVICE_NOT_FOUND ;if (PCI_POSSIBLE_ERROR (vendID)) -return -1 ; +return PCIBIOS_DEVICE_NOT_FOUND ;return pci_bus_read_config_dword (bus, devfn, offset, value); }
@@ -202,13 +204,15 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_ {u16 tdevice;u32 work; +int ret;u8 tbus; ctrl->pci_bus->number = bus_num;for (tdevice =0 ; tdevice <0xFF ; tdevice++) {/* Scan for access first */ -if (PCI_RefinedAccessConfig (ctrl->pci_bus, tdevice,0x08 , &work) ==-1 ) + ret =PCI_RefinedAccessConfig (ctrl->pci_bus, tdevice,0x08 , &work); +if (ret)continue ;dbg ("Looking for nonbridge bus_num %d dev_num %d\n" , bus_num, tdevice);/* Yep we got one. Not a bridge ? */
@@ -220,7 +224,8 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_ }for (tdevice =0 ; tdevice <0xFF ; tdevice++) {/* Scan for access first */ -if (PCI_RefinedAccessConfig (ctrl->pci_bus, tdevice,0x08 , &work) ==-1 ) + ret =PCI_RefinedAccessConfig (ctrl->pci_bus, tdevice,0x08 , &work); +if (ret)continue ;dbg ("Looking for bridge bus_num %d dev_num %d\n" , bus_num, tdevice);/* Yep we got one. bridge ? */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/772 perf ftrace latency: Fix unit on histogram first entry when using --use-nsec
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 064d569e20e82c065b1dec9d20c29c7087bb1a00 ]
The use_nsec arg wasn't being taken into account when printing the first histogram entry, fix it:
root@number:~# perf ftrace latency --use-nsec -T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 1 us | 0 | |
1 - 2 ns | 0 | |
2 - 4 ns | 0 | |
4 - 8 ns | 0 | |
8 - 16 ns | 0 | |
16 - 32 ns | 0 | |
32 - 64 ns | 125 | |
64 - 128 ns | 335 | |
128 - 256 ns | 2155 | #### |
256 - 512 ns | 9996 | ################### |
512 - 1024 ns | 4958 | ######### |
1 - 2 us | 4636 | ######### |
2 - 4 us | 1053 | ## |
4 - 8 us | 15 | |
8 - 16 us | 1 | |
16 - 32 us | 0 | |
32 - 64 us | 0 | |
64 - 128 us | 0 | |
128 - 256 us | 0 | |
256 - 512 us | 0 | |
512 - 1024 us | 0 | |
1 - ... ms | 0 | |
root@number:~#After:
root@number:~# perf ftrace latency --use-nsec -T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 1 ns | 0 | |
1 - 2 ns | 0 | |
2 - 4 ns | 0 | |
4 - 8 ns | 0 | |
8 - 16 ns | 0 | |
16 - 32 ns | 0 | |
32 - 64 ns | 19 | |
64 - 128 ns | 94 | |
128 - 256 ns | 2191 | #### |
256 - 512 ns | 9719 | #################### |
512 - 1024 ns | 5330 | ########### |
1 - 2 us | 4104 | ######## |
2 - 4 us | 807 | # |
4 - 8 us | 9 | |
8 - 16 us | 0 | |
16 - 32 us | 0 | |
32 - 64 us | 0 | |
64 - 128 us | 0 | |
128 - 256 us | 0 | |
256 - 512 us | 0 | |
512 - 1024 us | 0 | |
1 - ... ms | 0 | |
root@number:~#--- tools/perf/builtin-ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-ftrace.c +1 -1
@@ -769,7 +769,7 @@ static void display_histogram(int buckets[], bool use_nsec) bar_len = buckets[0 ] * bar_total / total;printf (" %4d - %-4d %s | %10d | %.*s%*s |\n" , -0 ,1 ,"us" , buckets[0 ], bar_len, bar, bar_total - bar_len,"" ); +0 ,1 , use_nsec ?"ns" :"us" , buckets[0 ], bar_len, bar, bar_total - bar_len,"" );for (i =1 ; i <NUM_BUCKET -1 ; i++) {int start = (1 << (i -1 ));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/772 f2fs: fix the wrong f2fs_bug_on condition in f2fs_do_replace_block
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: LongPing Wei <[email protected]>
[ Upstream commit c3af1f13476ec23fd99c98d060a89be28c1e8871 ]
This f2fs_bug_on was introduced by commit 2c1905042c8c ("f2fs: check segment type in __f2fs_replace_block") when there were only 6 curseg types. After commit d0b9e42ab615 ("f2fs: introduce inmem curseg") was introduced, the condition should be changed to checking curseg->seg_type.
--- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
@@ -3543,8 +3543,8 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, } } -f2fs_bug_on (sbi, !IS_DATASEG (type)); curseg =CURSEG_I (sbi, type); +f2fs_bug_on (sbi, !IS_DATASEG (curseg->seg_type));mutex_lock (&curseg->curseg_mutex);down_write (&sit_i->sentry_lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 273/772 f2fs: remove struct segment_allocation default_salloc_ops
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 1c8a8ec0a0e9a1176022a35c4daf04fe1594d270 ]
There is only single instance of these ops, so remove the indirection and call allocate_segment_by_default directly.
Stable-dep-of: 43563069e1c1 ("f2fs: check curseg->inited before write_sum_page in change_curseg")
--- fs/f2fs/segment.c | 11 ++--------- fs/f2fs/segment.h | 6 ------ 2 files changed, 2 insertions(+), 15 deletions(-)
fs/f2fs/segment.c +2 -9
@@ -2936,7 +2936,7 @@ static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type,return ; alloc: old_segno = curseg->segno; -SIT_I (sbi)->s_ops->allocate_segment (sbi, type, true); +allocate_segment_by_default (sbi, type, true);locate_dirty_segment (sbi, old_segno); }
@@ -2967,10 +2967,6 @@ void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)f2fs_up_read (&SM_I (sbi)->curseg_lock); } -static const struct segment_allocation default_salloc_ops = { - .allocate_segment = allocate_segment_by_default, -}; -bool f2fs_exist_trim_candidates (struct f2fs_sb_info *sbi,struct cp_control *cpc) {
@@ -3295,7 +3291,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,get_atssr_segment (sbi, type, se->type,AT_SSR , se->mtime); else - sit_i->s_ops->allocate_segment(sbi, type, false); +allocate_segment_by_default (sbi ,type ,false ); }/* * segment dirty status should be updated after segment allocation,
@@ -4281,9 +4277,6 @@ static int build_sit_info(struct f2fs_sb_info *sbi)return -ENOMEM ;#endif -/* init SIT information */ - sit_i->s_ops = &default_salloc_ops; - sit_i->sit_base_addr =le32_to_cpu (raw_super->sit_blkaddr); sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; sit_i->written_valid_blocks =0 ;
fs/f2fs/segment.h +0 -6
@@ -225,10 +225,6 @@ struct sec_entry {unsigned int valid_blocks;/* # of valid blocks in a section */ }; -struct segment_allocation { -void (*allocate_segment)(struct f2fs_sb_info *,int ,bool ); -}; -#define MAX_SKIP_GC_COUNT 16struct revoke_entry {
@@ -238,8 +234,6 @@ struct revoke_entry { };struct sit_info { -const struct segment_allocation *s_ops; -block_t sit_base_addr;/* start block address of SIT area */ block_t sit_blocks;/* # of blocks used by SIT area */ block_t written_valid_blocks;/* # of valid blocks in main area */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/772 f2fs: open code allocate_segment_by_default
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 8442d94b8ac8d5d8300725a9ffa9def526b71170 ]
allocate_segment_by_default has just two callers, which use very different code pathes inside it based on the force paramter. Just open code the logic in the two callers using a new helper to decided if a new segment should be allocated.
Stable-dep-of: 43563069e1c1 ("f2fs: check curseg->inited before write_sum_page in change_curseg")
--- fs/f2fs/segment.c | 50 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 26 deletions(-)
fs/f2fs/segment.c +24 -26
@@ -2859,31 +2859,20 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type,return 0 ; } -/* -* flush out current segment and replace it with new segment -* This function should be returned with success, otherwise BUG -*/ -static void allocate_segment_by_default (struct f2fs_sb_info *sbi, -int type,bool force) +static bool need_new_seg (struct f2fs_sb_info *sbi,int type) {struct curseg_info *curseg =CURSEG_I (sbi, type); -if (force) -new_curseg (sbi, type, true); -else if (!is_set_ckpt_flags (sbi,CP_CRC_RECOVERY_FLAG ) && - curseg->seg_type ==CURSEG_WARM_NODE ) -new_curseg (sbi, type, false); -else if (curseg->alloc_type ==LFS && -is_next_segment_free (sbi, curseg, type) && -likely (!is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) -new_curseg (sbi, type, false); -else if (f2fs_need_SSR (sbi) && -get_ssr_segment (sbi, type,SSR ,0 )) -change_curseg (sbi, type, true); -else -new_curseg (sbi, type, false); - -stat_inc_seg_type (sbi, curseg); +if (!is_set_ckpt_flags (sbi,CP_CRC_RECOVERY_FLAG ) && + curseg->seg_type ==CURSEG_WARM_NODE ) +return true; +if (curseg->alloc_type ==LFS && +is_next_segment_free (sbi, curseg, type) && +likely (!is_sbi_flag_set (sbi,SBI_CP_DISABLED ))) +return true; +if (!f2fs_need_SSR (sbi) || !get_ssr_segment (sbi, type,SSR ,0 )) +return true; +return false; } void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type,
@@ -2936,7 +2925,8 @@ static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type,return ; alloc: old_segno = curseg->segno; -allocate_segment_by_default (sbi, type, true); +new_curseg (sbi, type, true); +stat_inc_seg_type (sbi, curseg);locate_dirty_segment (sbi, old_segno); }
@@ -3287,11 +3277,19 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,update_sit_entry (sbi, old_blkaddr,-1 );if (!__has_curseg_space (sbi, curseg)) { -if (from_gc) +/* +* Flush out current segment and replace it with new segment. +*/ +if (from_gc) {get_atssr_segment (sbi, type, se->type,AT_SSR , se->mtime); -else -allocate_segment_by_default (sbi, type, false); + }else { +if (need_new_seg (sbi, type)) +new_curseg (sbi, type, false); +else +change_curseg (sbi, type, true); +stat_inc_seg_type (sbi, curseg); + } }/* * segment dirty status should be updated after segment allocation,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 275/772 f2fs: remove the unused flush argument to change_curseg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 5bcd655fffaec24e849bda1207446f5cc821713e ]
Stable-dep-of: 43563069e1c1 ("f2fs: check curseg->inited before write_sum_page in change_curseg")
--- fs/f2fs/segment.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
fs/f2fs/segment.c +7 -9
@@ -2666,7 +2666,7 @@ bool f2fs_segment_has_free_slot(struct f2fs_sb_info *sbi, int segno)* This function always allocates a used segment(from dirty seglist) by SSR * manner, so it should recover the existing segment information of valid blocks */ -static void change_curseg (struct f2fs_sb_info *sbi,int type,bool flush) +static void change_curseg (struct f2fs_sb_info *sbi,int type) {struct dirty_seglist_info *dirty_i =DIRTY_I (sbi);struct curseg_info *curseg =CURSEG_I (sbi, type);
@@ -2674,9 +2674,7 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type, bool flush)struct f2fs_summary_block *sum_node;struct page *sum_page; -if (flush) -write_sum_page (sbi, curseg->sum_blk, -GET_SUM_BLOCK (sbi, curseg->segno)); +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, curseg->segno));__set_test_and_inuse (sbi, new_segno);
@@ -2715,7 +2713,7 @@ static void get_atssr_segment(struct f2fs_sb_info *sbi, int type,struct seg_entry *se =get_seg_entry (sbi, curseg->next_segno); curseg->seg_type = se->type; -change_curseg (sbi, type, true); +change_curseg (sbi, type); }else {/* allocate cold segment by default */ curseg->seg_type =CURSEG_COLD_DATA ;
@@ -2890,7 +2888,7 @@ void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type, goto unlock;if (f2fs_need_SSR (sbi) &&get_ssr_segment (sbi, type,SSR ,0 )) -change_curseg (sbi, type, true); +change_curseg (sbi, type);else new_curseg (sbi, type, true);
@@ -3287,7 +3285,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,if (need_new_seg (sbi, type))new_curseg (sbi, type, false);else -change_curseg (sbi, type, true); +change_curseg (sbi, type);stat_inc_seg_type (sbi, curseg); } }
@@ -3550,7 +3548,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,/* change the current segment */ if (segno != curseg->segno) { curseg->next_segno = segno; -change_curseg (sbi, type, true); +change_curseg (sbi, type); } curseg->next_blkoff =GET_BLKOFF_FROM_SEG0 (sbi, new_blkaddr);
@@ -3578,7 +3576,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,if (recover_curseg) {if (old_cursegno != curseg->segno) { curseg->next_segno = old_cursegno; -change_curseg (sbi, type, true); +change_curseg (sbi, type); } curseg->next_blkoff = old_blkoff; curseg->alloc_type = old_alloc_type;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 276/772 f2fs: check curseg->inited before write_sum_page in change_curseg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongpeng Yang <[email protected]>
[ Upstream commit 43563069e1c1df417d2eed6eca8a22fc6b04691d ]
In the __f2fs_init_atgc_curseg->get_atssr_segment calling, curseg->segno is NULL_SEGNO, indicating that there is no summary block that needs to be written.
--- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
@@ -2674,7 +2674,8 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)struct f2fs_summary_block *sum_node;struct page *sum_page; -write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, curseg->segno)); +if (curseg->inited) +write_sum_page (sbi, curseg->sum_blk,GET_SUM_BLOCK (sbi, curseg->segno));__set_test_and_inuse (sbi, new_segno);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 277/772 f2fs: fix to avoid use GC_AT when setting gc_mode as GC_URGENT_LOW or GC_URGENT_MID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit 296b8cb34e65fa93382cf919be5a056f719c9a26 ]
If gc_mode is set to GC_URGENT_LOW or GC_URGENT_MID, cost benefit GC approach should be used, but if ATGC is enabled at the same time, Age-threshold approach will be selected, which can only do amount of GC and it is much less than the numbers of CB approach.
some traces:
f2fs_gc-254:48-396 [007] ..... 2311600.684028: f2fs_gc_begin: dev = (254,48), gc_type = Background GC, no_background_GC = 0, nr_free_secs = 0, nodes = 1053, dents = 2, imeta = 18, free_sec:44898, free_seg:44898, rsv_seg:239, prefree_seg:0 f2fs_gc-254:48-396 [007] ..... 2311600.684527: f2fs_get_victim: dev = (254,48), type = No TYPE, policy = (Background GC, LFS-mode, Age-threshold), victim = 10, cost = 4294364975, ofs_unit = 1, pre_victim_secno = -1, prefree = 0, free = 44898 f2fs_gc-254:48-396 [007] ..... 2311600.714835: f2fs_gc_end: dev = (254,48), ret = 0, seg_freed = 0, sec_freed = 0, nodes = 1562, dents = 2, imeta = 18, free_sec:44898, free_seg:44898, rsv_seg:239, prefree_seg:0 f2fs_gc-254:48-396 [007] ..... 2311600.714843: f2fs_background_gc: dev = (254,48), wait_ms = 50, prefree = 0, free = 44898 f2fs_gc-254:48-396 [007] ..... 2311600.771785: f2fs_gc_begin: dev = (254,48), gc_type = Background GC, no_background_GC = 0, nr_free_secs = 0, nodes = 1562, dents = 2, imeta = 18, free_sec:44898, free_seg:44898, rsv_seg:239, prefree_seg: f2fs_gc-254:48-396 [007] ..... 2311600.772275: f2fs_gc_end: dev = (254,48), ret = -61, seg_freed = 0, sec_freed = 0, nodes = 1562, dents = 2, imeta = 18, free_sec:44898, free_seg:44898, rsv_seg:239, prefree_seg:0
--- Documentation/ABI/testing/sysfs-fs-f2fs | 7 +++++-- fs/f2fs/gc.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +5 -2
@@ -303,10 +303,13 @@ Description: Do background GC aggressively when set. Set to 0 by default. GC approach and turns SSR mode on. gc urgent low(2): lowers the bar of checking I/O idling in order to process outstanding discard commands and GC a - little bit aggressively. uses cost benefit GC approach. + little bit aggressively. always uses cost benefit GC approach, + and will override age-threshold GC approach if ATGC is enabled + at the same time. gc urgent mid(3): does GC forcibly in a period of given gc_urgent_sleep_time and executes a mid level of I/O idling check. - uses cost benefit GC approach. + always uses cost benefit GC approach, and will override + age-threshold GC approach if ATGC is enabled at the same time. What: /sys/fs/f2fs/<disk>/gc_urgent_sleep_time Date: August 2017
fs/f2fs/gc.c +2 -0
@@ -227,6 +227,8 @@ static int select_gc_type(struct f2fs_sb_info *sbi, int gc_type)switch (sbi->gc_mode) {case GC_IDLE_CB : +case GC_URGENT_LOW : +case GC_URGENT_MID : gc_mode =GC_CB ;break ;case GC_IDLE_GREEDY :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 278/772 f2fs: fix to avoid forcing direct write to use buffered IO on inline_data inode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 26e6f59d0bbaac76fa3413462d780bd2b5f9f653 ]
Jinsu Lee reported a performance regression issue, after commit 5c8764f8679e ("f2fs: fix to force buffered IO on inline_data inode"), we forced direct write to use buffered IO on inline_data inode, it will cause performace regression due to memory copy and data flush.
It's fine to not force direct write to use buffered IO, as it can convert inline inode before committing direct write IO.
--- fs/f2fs/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/file.c +5 -1
@@ -855,7 +855,11 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw)return true;if (f2fs_compressed_file (inode))return true; -if (f2fs_has_inline_data (inode)) +/* +* only force direct read to use buffered IO, for direct write, +* it expects inline data conversion before committing IO. +*/ +if (f2fs_has_inline_data (inode) && rw ==READ )return true;/* disallow direct IO if any of devices has unaligned blksize */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 279/772 perf trace: avoid garbage when not printing a trace events arguments
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 5fb8e56542a3cf469fdf25d77f50e21cbff3ae7e ]
trace__fprintf_tp_fields may not print any tracepoint arguments. E.g., if the argument values are all zero. Previously, this would result in a totally uninitialized buffer being passed to fprintf, which could lead to garbage on the console. Fix the problem by passing the number of initialized bytes fprintf.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -2770,7 +2770,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, printed +=syscall_arg_fmt__scnprintf_val (arg, bf + printed, size - printed, &syscall_arg, val); } -return printed +fprintf (trace->output,"%s" , bf); +return printed +fprintf (trace->output,"%.*s" , (int )printed, bf); } static int trace__event_handler(struct trace *trace, struct evsel *evsel,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 280/772 m68k: mcfgpio: Fix incorrect register offset for CONFIG_M5441x
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Michel Hautbois <[email protected]>
[ Upstream commit f212140962c93cd5da43283a18e31681540fc23d ]
Fix a typo in the CONFIG_M5441x preprocessor condition, where the GPIO register offset was incorrectly set to 8 instead of 0. This prevented proper GPIO configuration for m5441x targets.
--- arch/m68k/include/asm/mcfgpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/include/asm/mcfgpio.h +1 -1
@@ -144,7 +144,7 @@ static inline void gpio_free(unsigned gpio)* read-modify-write as well as those controlled by the EPORT and GPIO modules. */ #define MCFGPIO_SCR_START 40 -#elif defined(CONFIGM5441x) +#elif defined(CONFIG_M5441x)/* The m5441x EPORT doesn't have its own GPIO port, uses PORT C */ #define MCFGPIO_SCR_START 0#else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 281/772 m68k: coldfire/device.c: only build FEC when HW macros are defined
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Quartulli <[email protected]>
[ Upstream commit 63a24cf8cc330e5a68ebd2e20ae200096974c475 ]
When CONFIG_FEC is set (due to COMPILE_TEST) along with CONFIG_M54xx, coldfire/device.c has compile errors due to missing MCFEC_* and MCF_IRQ_FEC_* symbols.
Make the whole FEC blocks dependent on having the HW macros defined, rather than on CONFIG_FEC itself.
This fix is very similar to commit e6e1e7b19fa1 ("m68k: coldfire/device.c: only build for MCF_EDMA when h/w macros are defined")
To: Greg Ungerer <[email protected]>
To: Geert Uytterhoeven <[email protected]>
--- arch/m68k/coldfire/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/m68k/coldfire/device.c +4 -4
@@ -93,7 +93,7 @@ static struct platform_device mcf_uart = { .dev.platform_data = mcf_uart_platform_data, }; -#if IS_ENABLED (CONFIG_FEC ) +#ifdef MCFFEC_BASE0 #ifdef CONFIG_M5441x#define FEC_NAME "enet-fec"
@@ -145,6 +145,7 @@ static struct platform_device mcf_fec0 = { .platform_data = FEC_PDATA, } }; +#endif /* MCFFEC_BASE0 */ #ifdef MCFFEC_BASE1 static struct resource mcf_fec1_resources[] = {
@@ -182,7 +183,6 @@ static struct platform_device mcf_fec1 = { } };#endif /* MCFFEC_BASE1 */ -#endif /* CONFIG_FEC */ #if IS_ENABLED (CONFIG_SPI_COLDFIRE_QSPI )/*
@@ -624,12 +624,12 @@ static struct platform_device mcf_flexcan0 = {static struct platform_device *mcf_devices[]__initdata = { &mcf_uart, -#if IS_ENABLED(CONFIG_FEC) +#ifdef MCFFEC_BASE0 &mcf_fec0, +#endif #ifdef MCFFEC_BASE1 &mcf_fec1, #endif -#endif #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) &mcf_qspi, #endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 282/772 svcrdma: Address an integer overflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 3c63d8946e578663b868cb9912dac616ea68bfd0 ]
Dan Carpenter reports:
Quoted 20 lines
Commit
78147ca8b4a9("svcrdma: Add a "parsed chunk list" data structure") from Jun 22, 2020 (linux-next), leads to the following Smatch static checker warning:
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c:498xdr_check_write_chunk()
warn: potential user controlled sizeof overflow 'segcount * 4 * 4'
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c488 static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt) 489 { 490 u32 segcount; 491 __be32 *p; 492 493 if (xdr_stream_decode_u32(&rctxt->rc_stream, &segcount)) ^^^^^^^^ 494 return false; 495 496 /* A bogus segcount causes this buffer overflow check to fail. */ 497 p = xdr_inline_decode(&rctxt->rc_stream,
Quoted 6 lines
--> 498 segcount *
rpcrdma_segment_maxsz*sizeof(*p));segcount is an untrusted u32. On 32bit systems anything >=
SIZE_MAX/ 16 will have an integer overflow and some those values will be accepted byxdr_inline_decode().
--- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +7 -1
@@ -482,7 +482,13 @@ static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt)if (xdr_stream_decode_u32 (&rctxt->rc_stream, &segcount))return false; -/* A bogus segcount causes this buffer overflow check to fail. */ +/* Before trusting the segcount value enough to use it in +* a computation, perform a simple range check. This is an +* arbitrary but sensible limit (ie, not architectural). +*/ +if (unlikely (segcount >RPCSVC_MAXPAGES )) +return false; + p =xdr_inline_decode (&rctxt->rc_stream, segcount * rpcrdma_segment_maxsz *sizeof (*p));return p !=NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 283/772 perf trace: Do not lose last events in a race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 3fd7c36973a250e17a4ee305a31545a9426021f4 ]
If a perf trace event selector specifies a maximum number of events to output (i.e., "/nr=N/" syntax), the event printing handler, trace__event_handler, disables the event selector after the maximum number events are printed.
Furthermore, trace__event_handler checked if the event selector was disabled before doing any work. This avoided exceeding the maximum number of events to print if more events were in the buffer before the selector was disabled.
However, the event selector can be disabled for reasons other than exceeding the maximum number of events. In particular, when the traced subprocess exits, the main loop disables all event selectors. This meant the last events of a traced subprocess might be lost to the printing handler's short-circuiting logic.
This nondeterministic problem could be seen by running the following many times:
$ perf trace -e syscalls:sys_enter_exit_group true
trace__event_handler should simply check for exceeding the maximum number of events to print rather than the state of the event selector.
--- tools/perf/builtin-trace.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
tools/perf/builtin-trace.c +2 -7
@@ -2779,13 +2779,8 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel, {struct thread *thread;int callchain_ret =0 ; -/* -* Check if we called perf_evsel__disable(evsel) due to, for instance, -* this event's max_events having been hit and this is an entry coming -* from the ring buffer that we should discard, since the max events -* have already been considered/printed. -*/ -if (evsel->disabled) + +if (evsel->nr_events_printed >= evsel->max_events)return 0 ; thread =machine__findnew_thread (trace->host, sample->pid, sample->tid);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 284/772 perf trace: Avoid garbage when not printing a syscalls arguments
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Peterson <[email protected]>
[ Upstream commit 1302e352b26f34991b619b5d0b621b76d20a3883 ]
syscall__scnprintf_args may not place anything in the output buffer (e.g., because the arguments are all zero). If that happened in trace__fprintf_sys_enter, its fprintf would receive an unitialized buffer leading to garbage output.
Fix the problem by passing the (possibly zero) bounds of the argument buffer to the output fprintf.
--- tools/perf/builtin-trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +3 -2
@@ -2385,6 +2385,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,char msg[1024 ];void *args, *augmented_args =NULL ;int augmented_args_size; +size_t printed =0 ;if (sc ==NULL )return -1 ;
@@ -2400,8 +2401,8 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel, args =perf_evsel__sc_tp_ptr (evsel, args, sample); augmented_args =syscall__augmented_args (sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size); -syscall__scnprintf_args (sc, msg,sizeof (msg), args, augmented_args, augmented_args_size, trace, thread); -fprintf (trace->output,"%s" , msg); + printed +=syscall__scnprintf_args (sc, msg,sizeof (msg), args, augmented_args, augmented_args_size, trace, thread); +fprintf (trace->output,"%.*s" , (int )printed, msg); err =0 ; out_put:thread__put (thread);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 285/772 remoteproc: qcom: q6v5: Use _clk_get_optional for aggre2_clk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 6d967a5a49e8d08d8e4430aadba8d3c903b794a5 ]
Only msm8996 and msm8998 SLPIs need the RPM_SMD_AGGR2_NOC_CLK (as aggre2 clock). None of the other platforms do. Back when the support for the mentioned platforms was added to the q6v5 pass driver, the devm_clk_get_optional was not available, so the has_aggre2_clk was necessary in order to differentiate between plaforms that need this clock and those which do not. Now that devm_clk_get_optional is available, we can drop the has_aggre2_clk. This makes the adsp_data more cleaner and removes the check within adsp_init_clocks.
Stable-dep-of: e8983156d54f ("remoteproc: qcom: pas: add minidump_id to SM8350 resources")
--- drivers/remoteproc/qcom_q6v5_pas.c | 42 +++++------------------------- 1 file changed, 7 insertions(+), 35 deletions(-)
drivers/remoteproc/qcom_q6v5_pas.c +7 -35
@@ -37,7 +37,6 @@ struct adsp_data {const char *firmware_name;int pas_id;unsigned int minidump_id; -bool has_aggre2_clk;bool auto_boot;bool decrypt_shutdown;
@@ -68,7 +67,6 @@ struct qcom_adsp {int pas_id;unsigned int minidump_id;int crash_reason_smem; -bool has_aggre2_clk;bool decrypt_shutdown;const char *info_name;
@@ -345,15 +343,13 @@ static int adsp_init_clock(struct qcom_adsp *adsp)return ret; } -if (adsp->has_aggre2_clk) { - adsp->aggre2_clk =devm_clk_get (adsp->dev,"aggre2" ); -if (IS_ERR (adsp->aggre2_clk)) { - ret =PTR_ERR (adsp->aggre2_clk); -if (ret != -EPROBE_DEFER ) -dev_err (adsp->dev, -"failed to get aggre2 clock" ); -return ret; - } + adsp->aggre2_clk =devm_clk_get_optional (adsp->dev,"aggre2" ); +if (IS_ERR (adsp->aggre2_clk)) { + ret =PTR_ERR (adsp->aggre2_clk); +if (ret != -EPROBE_DEFER ) +dev_err (adsp->dev, +"failed to get aggre2 clock" ); +return ret; }return 0 ;
@@ -505,7 +501,6 @@ static int adsp_probe(struct platform_device *pdev) adsp->rproc = rproc; adsp->minidump_id = desc->minidump_id; adsp->pas_id = desc->pas_id; - adsp->has_aggre2_clk = desc->has_aggre2_clk; adsp->info_name = desc->sysmon_name; adsp->decrypt_shutdown = desc->decrypt_shutdown;platform_set_drvdata (pdev, adsp);
@@ -585,7 +580,6 @@ static const struct adsp_data adsp_resource_init = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .ssr_name = "lpass", .sysmon_name = "adsp",
@@ -596,7 +590,6 @@ static const struct adsp_data sdm845_adsp_resource_init = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .load_state = "adsp", .ssr_name = "lpass",
@@ -608,7 +601,6 @@ static const struct adsp_data sm6350_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -625,7 +617,6 @@ static const struct adsp_data sm8150_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -641,7 +632,6 @@ static const struct adsp_data sm8250_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -658,7 +648,6 @@ static const struct adsp_data sm8350_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -675,7 +664,6 @@ static const struct adsp_data msm8996_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -690,7 +678,6 @@ static const struct adsp_data cdsp_resource_init = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .ssr_name = "cdsp", .sysmon_name = "cdsp",
@@ -701,7 +688,6 @@ static const struct adsp_data sdm845_cdsp_resource_init = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .load_state = "cdsp", .ssr_name = "cdsp",
@@ -713,7 +699,6 @@ static const struct adsp_data sm6350_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -730,7 +715,6 @@ static const struct adsp_data sm8150_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -746,7 +730,6 @@ static const struct adsp_data sm8250_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -762,7 +745,6 @@ static const struct adsp_data sc8280xp_nsp0_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"nsp" ,
@@ -777,7 +759,6 @@ static const struct adsp_data sc8280xp_nsp1_resource = { .crash_reason_smem = 633, .firmware_name = "cdsp.mdt", .pas_id = 30, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"nsp" ,
@@ -792,7 +773,6 @@ static const struct adsp_data sm8350_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -810,7 +790,6 @@ static const struct adsp_data mpss_resource_init = { .firmware_name = "modem.mdt", .pas_id = 4, .minidump_id = 3, - .has_aggre2_clk = false, .auto_boot = false, .proxy_pd_names = (char *[]){"cx" ,
@@ -827,7 +806,6 @@ static const struct adsp_data sc8180x_mpss_resource = { .crash_reason_smem = 421, .firmware_name = "modem.mdt", .pas_id = 4, - .has_aggre2_clk = false, .auto_boot = false, .proxy_pd_names = (char *[]){"cx" ,
@@ -843,7 +821,6 @@ static const struct adsp_data slpi_resource_init = { .crash_reason_smem = 424, .firmware_name = "slpi.mdt", .pas_id = 12, - .has_aggre2_clk = true, .auto_boot = true, .proxy_pd_names = (char *[]){"ssc_cx" ,
@@ -858,7 +835,6 @@ static const struct adsp_data sm8150_slpi_resource = { .crash_reason_smem = 424, .firmware_name = "slpi.mdt", .pas_id = 12, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -875,7 +851,6 @@ static const struct adsp_data sm8250_slpi_resource = { .crash_reason_smem = 424, .firmware_name = "slpi.mdt", .pas_id = 12, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -892,7 +867,6 @@ static const struct adsp_data sm8350_slpi_resource = { .crash_reason_smem = 424, .firmware_name = "slpi.mdt", .pas_id = 12, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -919,7 +893,6 @@ static const struct adsp_data sdx55_mpss_resource = { .crash_reason_smem = 421, .firmware_name = "modem.mdt", .pas_id = 4, - .has_aggre2_clk = false, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
@@ -936,7 +909,6 @@ static const struct adsp_data sm8450_mpss_resource = { .firmware_name = "modem.mdt", .pas_id = 4, .minidump_id = 3, - .has_aggre2_clk = false, .auto_boot = false, .decrypt_shutdown = true, .proxy_pd_names = (char *[]){
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 286/772 remoteproc: qcom: pas: add minidump_id to SM8350 resources
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e8983156d54f59f57e648ecd44f01c16572da842 ]
Specify minidump_id for the SM8350 DSPs. It was omitted for in the original commit e8b4e9a21af7 ("remoteproc: qcom: pas: Add SM8350 PAS remoteprocs").
--- drivers/remoteproc/qcom_q6v5_pas.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/qcom_q6v5_pas.c +2 -0
@@ -632,6 +632,7 @@ static const struct adsp_data sm8250_adsp_resource = { .crash_reason_smem = 423, .firmware_name = "adsp.mdt", .pas_id = 1, + .minidump_id = 5, .auto_boot = true, .proxy_pd_names = (char *[]){"lcx" ,
@@ -773,6 +774,7 @@ static const struct adsp_data sm8350_cdsp_resource = { .crash_reason_smem = 601, .firmware_name = "cdsp.mdt", .pas_id = 18, + .minidump_id = 7, .auto_boot = true, .proxy_pd_names = (char *[]){"cx" ,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 287/772 rpmsg: glink: Fix GLINK command prefix
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 4e816d0318fdfe8932da80dbf04ba318b13e4b3a ]
The upstream GLINK driver was first introduced to communicate with the RPM on MSM8996, presumably as an artifact from that era the command defines was prefixed RPM_CMD, while they actually are GLINK_CMDs.
Let's rename these, to keep things tidy. No functional change.
Stable-dep-of: 06c59d97f63c ("rpmsg: glink: use only lower 16-bits of param2 for CMD_OPEN name length")
--- drivers/rpmsg/qcom_glink_native.c | 98 +++++++++++++++---------------- 1 file changed, 49 insertions(+), 49 deletions(-)
drivers/rpmsg/qcom_glink_native.c +49 -49
@@ -189,20 +189,20 @@ struct glink_channel {static const struct rpmsg_endpoint_ops glink_endpoint_ops; -#define RPM_CMD_VERSION 0 -#define RPM_CMD_VERSION_ACK 1 -#define RPM_CMD_OPEN 2 -#define RPM_CMD_CLOSE 3 -#define RPM_CMD_OPEN_ACK 4 -#define RPM_CMD_INTENT 5 -#define RPM_CMD_RX_DONE 6 -#define RPM_CMD_RX_INTENT_REQ 7 -#define RPM_CMD_RX_INTENT_REQ_ACK 8 -#define RPM_CMD_TX_DATA 9 -#define RPM_CMD_CLOSE_ACK 11 -#define RPM_CMD_TX_DATA_CONT 12 -#define RPM_CMD_READ_NOTIF 13 -#define RPM_CMD_RX_DONE_W_REUSE 14 +#define GLINK_CMD_VERSION 0 +#define GLINK_CMD_VERSION_ACK 1 +#define GLINK_CMD_OPEN 2 +#define GLINK_CMD_CLOSE 3 +#define GLINK_CMD_OPEN_ACK 4 +#define GLINK_CMD_INTENT 5 +#define GLINK_CMD_RX_DONE 6 +#define GLINK_CMD_RX_INTENT_REQ 7 +#define GLINK_CMD_RX_INTENT_REQ_ACK 8 +#define GLINK_CMD_TX_DATA 9 +#define GLINK_CMD_CLOSE_ACK 11 +#define GLINK_CMD_TX_DATA_CONT 12 +#define GLINK_CMD_READ_NOTIF 13 +#define GLINK_CMD_RX_DONE_W_REUSE 14#define GLINK_FEATURE_INTENTLESS BIT(1)
@@ -311,7 +311,7 @@ static void qcom_glink_send_read_notify(struct qcom_glink *glink) {struct glink_msg msg; - msg.cmd =cpu_to_le16 (RPM_CMD_READ_NOTIF ); + msg.cmd =cpu_to_le16 (GLINK_CMD_READ_NOTIF ); msg.param1 =0 ; msg.param2 =0 ;
@@ -373,7 +373,7 @@ static int qcom_glink_send_version(struct qcom_glink *glink) {struct glink_msg msg; - msg.cmd =cpu_to_le16 (RPM_CMD_VERSION ); + msg.cmd =cpu_to_le16 (GLINK_CMD_VERSION ); msg.param1 =cpu_to_le16 (GLINK_VERSION_1 ); msg.param2 =cpu_to_le32 (glink->features);
@@ -384,7 +384,7 @@ static void qcom_glink_send_version_ack(struct qcom_glink *glink) {struct glink_msg msg; - msg.cmd =cpu_to_le16 (RPM_CMD_VERSION_ACK ); + msg.cmd =cpu_to_le16 (GLINK_CMD_VERSION_ACK ); msg.param1 =cpu_to_le16 (GLINK_VERSION_1 ); msg.param2 =cpu_to_le32 (glink->features);
@@ -396,7 +396,7 @@ static void qcom_glink_send_open_ack(struct qcom_glink *glink, {struct glink_msg msg; - msg.cmd =cpu_to_le16 (RPM_CMD_OPEN_ACK ); + msg.cmd =cpu_to_le16 (GLINK_CMD_OPEN_ACK ); msg.param1 =cpu_to_le16 (channel->rcid); msg.param2 =cpu_to_le32 (0 );
@@ -422,11 +422,11 @@ static void qcom_glink_handle_intent_req_ack(struct qcom_glink *glink, }/** -* qcom_glink_send_open_req() - send a RPM_CMD_OPEN request to the remote +* qcom_glink_send_open_req() - send a GLINK_CMD_OPEN request to the remote * @glink: Ptr to the glink edge * @channel: Ptr to the channel that the open req is sent * -* Allocates a local channel id and sends a RPM_CMD_OPEN message to the remote. +* Allocates a local channel id and sends a GLINK_CMD_OPEN message to the remote. * Will return with refcount held, regardless of outcome. * * Return: 0 on success, negative errno otherwise.
@@ -455,7 +455,7 @@ static int qcom_glink_send_open_req(struct qcom_glink *glink, channel->lcid = ret; - req.msg.cmd =cpu_to_le16 (RPM_CMD_OPEN ); + req.msg.cmd =cpu_to_le16 (GLINK_CMD_OPEN ); req.msg.param1 =cpu_to_le16 (channel->lcid); req.msg.param2 =cpu_to_le32 (name_len);strcpy (req.name, channel->name);
@@ -480,7 +480,7 @@ static void qcom_glink_send_close_req(struct qcom_glink *glink, {struct glink_msg req; - req.cmd =cpu_to_le16 (RPM_CMD_CLOSE ); + req.cmd =cpu_to_le16 (GLINK_CMD_CLOSE ); req.param1 =cpu_to_le16 (channel->lcid); req.param2 =0 ;
@@ -492,7 +492,7 @@ static void qcom_glink_send_close_ack(struct qcom_glink *glink, {struct glink_msg req; - req.cmd =cpu_to_le16 (RPM_CMD_CLOSE_ACK ); + req.cmd =cpu_to_le16 (GLINK_CMD_CLOSE_ACK ); req.param1 =cpu_to_le16 (rcid); req.param2 =0 ;
@@ -523,7 +523,7 @@ static void qcom_glink_rx_done_work(struct work_struct *work) iid = intent->id; reuse = intent->reuse; - cmd.id = reuse ?RPM_CMD_RX_DONE_W_REUSE :RPM_CMD_RX_DONE ; + cmd.id = reuse ?GLINK_CMD_RX_DONE_W_REUSE :GLINK_CMD_RX_DONE ; cmd.lcid = cid; cmd.liid = iid;
@@ -635,7 +635,7 @@ static int qcom_glink_send_intent_req_ack(struct qcom_glink *glink, {struct glink_msg msg; - msg.cmd =cpu_to_le16 (RPM_CMD_RX_INTENT_REQ_ACK ); + msg.cmd =cpu_to_le16 (GLINK_CMD_RX_INTENT_REQ_ACK ); msg.param1 =cpu_to_le16 (channel->lcid); msg.param2 =cpu_to_le32 (granted);
@@ -666,7 +666,7 @@ static int qcom_glink_advertise_intent(struct qcom_glink *glink, } __packed;struct command cmd; - cmd.id =cpu_to_le16 (RPM_CMD_INTENT ); + cmd.id =cpu_to_le16 (GLINK_CMD_INTENT ); cmd.lcid =cpu_to_le16 (channel->lcid); cmd.count =cpu_to_le32 (1 ); cmd.size =cpu_to_le32 (intent->size);
@@ -1031,42 +1031,42 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) param2 =le32_to_cpu (msg.param2);switch (cmd) { -case RPM_CMD_VERSION : -case RPM_CMD_VERSION_ACK : -case RPM_CMD_CLOSE : -case RPM_CMD_CLOSE_ACK : -case RPM_CMD_RX_INTENT_REQ : +case GLINK_CMD_VERSION : +case GLINK_CMD_VERSION_ACK : +case GLINK_CMD_CLOSE : +case GLINK_CMD_CLOSE_ACK : +case GLINK_CMD_RX_INTENT_REQ : ret =qcom_glink_rx_defer (glink,0 );break ; -case RPM_CMD_OPEN_ACK : +case GLINK_CMD_OPEN_ACK : ret =qcom_glink_rx_open_ack (glink, param1);qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ; -case RPM_CMD_OPEN : +case GLINK_CMD_OPEN : ret =qcom_glink_rx_defer (glink, param2);break ; -case RPM_CMD_TX_DATA : -case RPM_CMD_TX_DATA_CONT : +case GLINK_CMD_TX_DATA : +case GLINK_CMD_TX_DATA_CONT : ret =qcom_glink_rx_data (glink, avail);break ; -case RPM_CMD_READ_NOTIF : +case GLINK_CMD_READ_NOTIF :qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));mbox_send_message (glink->mbox_chan,NULL );mbox_client_txdone (glink->mbox_chan,0 );break ; -case RPM_CMD_INTENT : +case GLINK_CMD_INTENT :qcom_glink_handle_intent (glink, param1, param2, avail);break ; -case RPM_CMD_RX_DONE : +case GLINK_CMD_RX_DONE :qcom_glink_handle_rx_done (glink, param1, param2, false);qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ; -case RPM_CMD_RX_DONE_W_REUSE : +case GLINK_CMD_RX_DONE_W_REUSE :qcom_glink_handle_rx_done (glink, param1, param2, true);qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ; -case RPM_CMD_RX_INTENT_REQ_ACK : +case GLINK_CMD_RX_INTENT_REQ_ACK :qcom_glink_handle_intent_req_ack (glink, param1, param2);qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ;
@@ -1269,7 +1269,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,reinit_completion (&channel->intent_req_comp); - cmd.id =RPM_CMD_RX_INTENT_REQ ; + cmd.id =GLINK_CMD_RX_INTENT_REQ ; cmd.cid = channel->lcid; cmd.size = size;
@@ -1343,7 +1343,7 @@ static int __qcom_glink_send(struct glink_channel *channel, chunk_size =SZ_8K ; left_size = len - chunk_size; } - req.msg.cmd =cpu_to_le16 (RPM_CMD_TX_DATA ); + req.msg.cmd =cpu_to_le16 (GLINK_CMD_TX_DATA ); req.msg.param1 =cpu_to_le16 (channel->lcid); req.msg.param2 =cpu_to_le32 (iid); req.chunk_size =cpu_to_le32 (chunk_size);
@@ -1365,7 +1365,7 @@ static int __qcom_glink_send(struct glink_channel *channel, chunk_size =SZ_8K ; left_size -= chunk_size; - req.msg.cmd =cpu_to_le16 (RPM_CMD_TX_DATA_CONT ); + req.msg.cmd =cpu_to_le16 (GLINK_CMD_TX_DATA_CONT ); req.msg.param1 =cpu_to_le16 (channel->lcid); req.msg.param2 =cpu_to_le32 (iid); req.chunk_size =cpu_to_le32 (chunk_size);
@@ -1631,22 +1631,22 @@ static void qcom_glink_work(struct work_struct *work) param2 =le32_to_cpu (msg->param2);switch (cmd) { -case RPM_CMD_VERSION : +case GLINK_CMD_VERSION :qcom_glink_receive_version (glink, param1, param2);break ; -case RPM_CMD_VERSION_ACK : +case GLINK_CMD_VERSION_ACK :qcom_glink_receive_version_ack (glink, param1, param2);break ; -case RPM_CMD_OPEN : +case GLINK_CMD_OPEN :qcom_glink_rx_open (glink, param1, msg->data);break ; -case RPM_CMD_CLOSE : +case GLINK_CMD_CLOSE :qcom_glink_rx_close (glink, param1);break ; -case RPM_CMD_CLOSE_ACK : +case GLINK_CMD_CLOSE_ACK :qcom_glink_rx_close_ack (glink, param1);break ; -case RPM_CMD_RX_INTENT_REQ : +case GLINK_CMD_RX_INTENT_REQ :qcom_glink_handle_intent_req (glink, param1, param2);break ;default :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 288/772 rpmsg: glink: use only lower 16-bits of param2 for CMD_OPEN name length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Marek <[email protected]>
[ Upstream commit 06c59d97f63c1b8af521fa5aef8a716fb988b285 ]
The name len field of the CMD_OPEN packet is only 16-bits and the upper 16-bits of "param2" are a different "prio" field, which can be nonzero in certain situations, and CMD_OPEN packets can be unexpectedly dropped because of this.
Fix this by masking out the upper 16 bits of param2.
--- drivers/rpmsg/qcom_glink_native.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rpmsg/qcom_glink_native.c +2 -1
@@ -1043,7 +1043,8 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data)qcom_glink_rx_advance (glink,ALIGN (sizeof (msg),8 ));break ;case GLINK_CMD_OPEN : - ret =qcom_glink_rx_defer (glink, param2); +/* upper 16 bits of param2 are the "prio" field */ + ret =qcom_glink_rx_defer (glink, param2 &0xffff );break ;case GLINK_CMD_TX_DATA :case GLINK_CMD_TX_DATA_CONT :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 289/772 remoteproc: qcom_q6v5_mss: Re-order writes to the IMEM region
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sibi Sankar <[email protected]>
[ Upstream commit 7b22b7719fc17d5979a991c918c868ab041be5c8 ]
Any write access to the IMEM region when the Q6 is setting up XPU protection on it will result in a XPU violation. Fix this by ensuring IMEM writes related to the MBA post-mortem logs happen before the Q6 is brought out of reset.
--- drivers/remoteproc/qcom_q6v5_mss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +3 -3
@@ -1118,6 +1118,9 @@ static int q6v5_mba_load(struct q6v5 *qproc) goto disable_active_clks; } +if (qproc->has_mba_logs) +qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE ); +writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG );if (qproc->dp_size) {writel (qproc->mba_phys +SZ_1M , qproc->rmb_base +RMB_PMI_CODE_START_REG );
@@ -1128,9 +1131,6 @@ static int q6v5_mba_load(struct q6v5 *qproc)if (ret) goto reclaim_mba; -if (qproc->has_mba_logs) -qcom_pil_info_store ("mba" , qproc->mba_phys,MBA_LOG_SIZE ); - ret =q6v5_rmb_mba_wait (qproc,0 ,5000 );if (ret == -ETIMEDOUT ) {dev_err (qproc->dev,"MBA boot timed out\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 290/772 NFSD: Prevent NULL dereference in nfsd4_process_cb_update()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 1e02c641c3a43c88cecc08402000418e15578d38 ]
@ses is initialized to NULL. If __nfsd4_find_backchannel() finds no available backchannel session, setup_callback_client() will try to dereference @ses and segfault.
--- fs/nfsd/nfs4callback.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfsd/nfs4callback.c +2 -0
@@ -1379,6 +1379,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ses = c->cn_session; }spin_unlock (&clp->cl_lock); +if (!c) +return ; err =setup_callback_client (clp, &conn, ses);if (err) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 291/772 NFSD: Cap the number of bytes copied by nfs4_reset_recoverydir()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit f64ea4af43161bb86ffc77e6aeb5bcf5c3229df0 ]
It's only current caller already length-checks the string, but let's be safe.
--- fs/nfsd/nfs4recover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4recover.c +2 -1
@@ -658,7 +658,8 @@ nfs4_reset_recoverydir(char *recdir)return status; status = -ENOTDIR ;if (d_is_dir (path.dentry)) { -strcpy (user_recovery_dirname, recdir); +strscpy (user_recovery_dirname, recdir, +sizeof (user_recovery_dirname)); status =0 ; }path_put (&path);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 292/772 sunrpc: simplify two-level sysctl registration for svcrdma_parm_table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Chamberlain <[email protected]>
[ Upstream commit 376bcd9b37632cf191711a68aa25ab42f0048c2e ]
There is no need to declare two tables to just create directories, this can be easily be done with a prefix path with register_sysctl().
Simplify this registration.
Stable-dep-of: ce89e742a4c1 ("svcrdma: fix miss destroy percpu_counter in svc_rdma_proc_init()")
--- net/sunrpc/xprtrdma/svc_rdma.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
net/sunrpc/xprtrdma/svc_rdma.c +2 -19
@@ -212,24 +212,6 @@ static struct ctl_table svcrdma_parm_table[] = { { }, }; -static struct ctl_table svcrdma_table[] = { - { - .procname ="svc_rdma" , - .mode =0555 , - .child = svcrdma_parm_table - }, - { }, -}; - -static struct ctl_table svcrdma_root_table[] = { - { - .procname ="sunrpc" , - .mode =0555 , - .child = svcrdma_table - }, - { }, -}; -static void svc_rdma_proc_cleanup (void ) {if (!svcrdma_table_header)
@@ -263,7 +245,8 @@ static int svc_rdma_proc_init(void)if (rc) goto out_err; - svcrdma_table_header =register_sysctl_table (svcrdma_root_table); + svcrdma_table_header =register_sysctl ("sunrpc/svc_rdma" , + svcrdma_parm_table);return 0 ; out_err:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 293/772 svcrdma: fix miss destroy percpu_counter in svc_rdma_proc_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit ce89e742a4c12b20f09a43fec1b21db33f2166cd ]
There's issue as follows:
RPC: Registered rdma transport module.
RPC: Registered rdma backchannel transport module.
RPC: Unregistered rdma transport module.
RPC: Unregistered rdma backchannel transport module.
BUG: unable to handle page fault for address: fffffbfff80c609a PGD 123fee067 P4D 123fee067 PUD 123fea067 PMD 10c624067 PTE 0 Oops: Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI RIP: 0010:percpu_counter_destroy_many+0xf7/0x2a0 Call Trace: <TASK> __die+0x1f/0x70 page_fault_oops+0x2cd/0x860 spurious_kernel_fault+0x36/0x450 do_kern_addr_fault+0xca/0x100 exc_page_fault+0x128/0x150 asm_exc_page_fault+0x26/0x30 percpu_counter_destroy_many+0xf7/0x2a0 mmdrop+0x209/0x350 finish_task_switch.isra.0+0x481/0x840 schedule_tail+0xe/0xd0 ret_from_fork+0x23/0x80 ret_from_fork_asm+0x1a/0x30 </TASK>
If register_sysctl() return NULL, then svc_rdma_proc_cleanup() will not destroy the percpu counters which init in svc_rdma_proc_init(). If CONFIG_HOTPLUG_CPU is enabled, residual nodes may be in the 'percpu_counters' list. The above issue may occur once the module is removed. If the CONFIG_HOTPLUG_CPU configuration is not enabled, memory leakage occurs.
To solve above issue just destroy all percpu counters when register_sysctl() return NULL.
--- net/sunrpc/xprtrdma/svc_rdma.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
net/sunrpc/xprtrdma/svc_rdma.c +14 -5
@@ -234,25 +234,34 @@ static int svc_rdma_proc_init(void) rc =percpu_counter_init (&svcrdma_stat_read,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err; rc =percpu_counter_init (&svcrdma_stat_recv,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_read; rc =percpu_counter_init (&svcrdma_stat_sq_starve,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_recv; rc =percpu_counter_init (&svcrdma_stat_write,0 ,GFP_KERNEL );if (rc) - goto out_err; + goto err_sq; svcrdma_table_header =register_sysctl ("sunrpc/svc_rdma" , svcrdma_parm_table); +if (!svcrdma_table_header) + goto err_write; +return 0 ; -out_err: +err_write: + rc = -ENOMEM ; +percpu_counter_destroy (&svcrdma_stat_write); +err_sq:percpu_counter_destroy (&svcrdma_stat_sq_starve); +err_recv:percpu_counter_destroy (&svcrdma_stat_recv); +err_read:percpu_counter_destroy (&svcrdma_stat_read); +err:return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 294/772 NFSD: Fix nfsd4_shutdown_copy()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 62a8642ba00aa8ceb0a02ade942f5ec52e877c95 ]
nfsd4_shutdown_copy() is just this:
while ((copy = nfsd4_get_copy(clp)) != NULL) nfsd4_stop_copy(copy);
nfsd4_get_copy() bumps @copy's reference count, preventing nfsd4_stop_copy() from releasing @copy.
A while loop like this usually works by removing the first element of the list, but neither nfsd4_get_copy() nor nfsd4_stop_copy() alters the async_copies list.
Best I can tell, then, is that nfsd4_shutdown_copy() continues to loop until other threads manage to remove all the items from this list. The spinning loop blocks shutdown until these items are gone.
Possibly the reason we haven't seen this issue in the field is because client_has_state() prevents __destroy_client() from calling nfsd4_shutdown_copy() if there are any items on this list. In a subsequent patch I plan to remove that restriction.
--- fs/nfsd/nfs4proc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +5 -2
@@ -1255,7 +1255,7 @@ static void nfsd4_stop_copy(struct nfsd4_copy *copy)nfs4_put_copy (copy); } -static struct nfsd4_copy *nfsd4_get_copy (struct nfs4_client *clp) +static struct nfsd4_copy *nfsd4_unhash_copy (struct nfs4_client *clp) {struct nfsd4_copy *copy =NULL ;
@@ -1264,6 +1264,9 @@ static struct nfsd4_copy *nfsd4_get_copy(struct nfs4_client *clp) copy = list_first_entry(&clp->async_copies, struct nfsd4_copy, copies);refcount_inc (©->refcount); + copy->cp_clp =NULL ; +if (!list_empty (©->copies)) +list_del_init (©->copies); }spin_unlock (&clp->async_lock);return copy;
@@ -1273,7 +1276,7 @@ void nfsd4_shutdown_copy(struct nfs4_client *clp) {struct nfsd4_copy *copy; -while ((copy =nfsd4_get_copy (clp)) !=NULL ) +while ((copy =nfsd4_unhash_copy (clp)) !=NULL )nfsd4_stop_copy (copy); }#ifdef CONFIG_NFSD_V4_2_INTER_SSC
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 295/772 hwmon: (tps23861) Fix reporting of negative temperatures
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit de2bf507fabba9c0c678cf5ed54beb546f5ca29a ]
Negative temperatures are reported as large positive temperatures due to missing sign extension from unsigned int to long. Cast unsigned raw register values to signed before performing the calculations to fix the problem.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Message-ID: <[email protected]>
--- drivers/hwmon/tps23861.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tps23861.c +1 -1
@@ -132,7 +132,7 @@ static int tps23861_read_temp(struct tps23861_data *data, long *val)if (err <0 )return err; - *val = (regval *TEMPERATURE_LSB ) -20000 ; + *val = ((long )regval *TEMPERATURE_LSB ) -20000 ;return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 296/772 vdpa/mlx5: Fix suboptimal range on iotlb iteration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Si-Wei Liu <[email protected]>
[ Upstream commit 35025963326e44d8bced3eecd42d2f040f4f0024 ]
The starting iova address to iterate iotlb map entry within a range was set to an irrelevant value when passing to the itree_next() iterator, although luckily it doesn't affect the outcome of finding out the granule of the smallest iotlb map size. Fix the code to make it consistent with the following for-loop.
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/core/mr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/vdpa/mlx5/core/mr.c +1 -3
@@ -227,7 +227,6 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mrunsigned long lgcd =0 ;int log_entity_size;unsigned long size; -u64 start =0 ;int err;struct page *pg;unsigned int nsg;
@@ -238,10 +237,9 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mrstruct device *dma = mvdev->vdev.dma_dev;for (map =vhost_iotlb_itree_first (iotlb, mr->start, mr->end -1 ); - map; map =vhost_iotlb_itree_next (map, start, mr->end -1 )) { + map; map =vhost_iotlb_itree_next (map, mr->start, mr->end -1 )) { size =maplen (map, mr); lgcd =gcd (lgcd, size); - start += size; } log_entity_size =ilog2 (lgcd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 297/772 selftests/mount_setattr: Fix failures on 64K PAGE_SIZE kernels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit f13242a46438e690067a4bf47068fde4d5719947 ]
Currently the mount_setattr_test fails on machines with a 64K PAGE_SIZE, with errors such as:
# RUN mount_setattr_idmapped.invalid_fd_negative ...
mkfs.ext4: No space left on device while writing out and closing file system
# mount_setattr_test.c:1055:invalid_fd_negative:Expected system("mkfs.ext4 -q /mnt/C/ext4.img") (256) == 0 (0) # invalid_fd_negative: Test terminated by assertion
# FAIL mount_setattr_idmapped.invalid_fd_negative
not ok 12 mount_setattr_idmapped.invalid_fd_negative
The code creates a 100,000 byte tmpfs:
ASSERT_EQ(mount("testing", "/mnt", "tmpfs", MS_NOATIME | MS_NODEV,
"size=100000,mode=700"), 0);And then a little later creates a 2MB ext4 filesystem in that tmpfs:
ASSERT_EQ(ftruncate(img_fd, 1024 * 2048), 0);
ASSERT_EQ(system("mkfs.ext4 -q /mnt/C/ext4.img"), 0);At first glance it seems like that should never work, after all 2MB is larger than 100,000 bytes. However the filesystem image doesn't actually occupy 2MB on "disk" (actually RAM, due to tmpfs). On 4K kernels the ext4.img uses ~84KB of actual space (according to du), which just fits.
However on 64K PAGE_SIZE kernels the ext4.img takes at least 256KB, which is too large to fit in the tmpfs, hence the errors.
It seems fraught to rely on the ext4.img taking less space on disk than the allocated size, so instead create the tmpfs with a size of 2MB. With that all 21 tests pass on 64K PAGE_SIZE kernels.
--- tools/testing/selftests/mount_setattr/mount_setattr_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mount_setattr/mount_setattr_test.c +1 -1
@@ -1026,7 +1026,7 @@ FIXTURE_SETUP(mount_setattr_idmapped) "size=100000,mode=700"), 0);ASSERT_EQ (mount ("testing" ,"/mnt" ,"tmpfs" ,MS_NOATIME |MS_NODEV , -"size=100000,mode=700" ),0 ); +"size=2m,mode=700" ),0 );ASSERT_EQ (mkdir ("/mnt/A" ,0777 ),0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 298/772 vfio/pci: Properly hide first-in-list PCIe extended capability
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avihai Horon <[email protected]>
[ Upstream commit fe4bf8d0b6716a423b16495d55b35d3fe515905d ]
There are cases where a PCIe extended capability should be hidden from the user. For example, an unknown capability (i.e., capability with ID greater than PCI_EXT_CAP_ID_MAX) or a capability that is intentionally chosen to be hidden from the user.
Hiding a capability is done by virtualizing and modifying the 'Next Capability Offset' field of the previous capability so it points to the capability after the one that should be hidden.
The special case where the first capability in the list should be hidden is handled differently because there is no previous capability that can be modified. In this case, the capability ID and version are zeroed while leaving the next pointer intact. This hides the capability and leaves an anchor for the rest of the capability list.
However, today, hiding the first capability in the list is not done properly if the capability is unknown, as struct vfio_pci_core_device->pci_config_map is set to the capability ID during initialization but the capability ID is not properly checked later when used in vfio_config_do_rw(). This leads to the following warning [1] and to an out-of-bounds access to ecap_perms array.
Fix it by checking cap_id in vfio_config_do_rw(), and if it is greater than PCI_EXT_CAP_ID_MAX, use an alternative struct perm_bits for direct read only access instead of the ecap_perms array.
Note that this is safe since the above is the only case where cap_id can exceed PCI_EXT_CAP_ID_MAX (except for the special capabilities, which are already checked before).
[1]
WARNING: CPU: 118 PID: 5329 at drivers/vfio/pci/vfio_pci_config.c:1900 vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] CPU: 118 UID: 0 PID: 5329 Comm: simx-qemu-syste Not tainted 6.12.0+ #1 (snip) Call Trace: <TASK> ? show_regs+0x69/0x80 ? __warn+0x8d/0x140 ? vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] ? report_bug+0x18f/0x1a0 ? handle_bug+0x63/0xa0 ? exc_invalid_op+0x19/0x70 ? asm_exc_invalid_op+0x1b/0x20 ? vfio_pci_config_rw+0x395/0x430 [vfio_pci_core] ? vfio_pci_config_rw+0x244/0x430 [vfio_pci_core] vfio_pci_rw+0x101/0x1b0 [vfio_pci_core] vfio_pci_core_read+0x1d/0x30 [vfio_pci_core] vfio_device_fops_read+0x27/0x40 [vfio] vfs_read+0xbd/0x340 ? vfio_device_fops_unl_ioctl+0xbb/0x740 [vfio] ? __rseq_handle_notify_resume+0xa4/0x4b0 __x64_sys_pread64+0x96/0xc0 x64_sys_call+0x1c3d/0x20d0 do_syscall_64+0x4d/0x120 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- drivers/vfio/pci/vfio_pci_config.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci_config.c +14 -2
@@ -312,6 +312,10 @@ static int vfio_virt_config_read(struct vfio_pci_core_device *vdev, int pos,return count; } +static struct perm_bits direct_ro_perms = { + .readfn = vfio_direct_config_read, +}; +/* Default capability regions to read-only, no-virtualization */ static struct perm_bits cap_perms[PCI_CAP_ID_MAX +1 ] = { [0 ...PCI_CAP_ID_MAX ] = { .readfn = vfio_direct_config_read }
@@ -1890,9 +1894,17 @@ static ssize_t vfio_config_do_rw(struct vfio_pci_core_device *vdev, char __user cap_start = *ppos; }else {if (*ppos >=PCI_CFG_SPACE_SIZE ) { -WARN_ON (cap_id >PCI_EXT_CAP_ID_MAX ); +/* +* We can get a cap_id that exceeds PCI_EXT_CAP_ID_MAX +* if we're hiding an unknown capability at the start +* of the extended capability list. Use default, ro +* access, which will virtualize the id and next values. +*/ +if (cap_id >PCI_EXT_CAP_ID_MAX ) + perm = &direct_ro_perms; +else + perm = &ecap_perms[cap_id]; - perm = &ecap_perms[cap_id]; cap_start =vfio_find_cap_start (vdev, *ppos); }else {WARN_ON (cap_id >PCI_CAP_ID_MAX );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 299/772 fs_parser: update mount_api doc to match function signature
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit c66f759832a83cb273ba5a55c66dcc99384efa74 ]
Add the missing 'name' parameter to the mount_api documentation for fs_validate_description().
--- Documentation/filesystems/mount_api.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/filesystems/mount_api.rst +2 -1
@@ -778,7 +778,8 @@ process the parameters it is given. * :: - bool fs_validate_description(const struct fs_parameter_description *desc); + bool fs_validate_description(const char *name, + const struct fs_parameter_description *desc); This performs some validation checks on a parameter description. It returns true if the description is good and false if it is not. It will
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 300/772 LoongArch: Tweak CFLAGS for Clang compatibility
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: WANG Xuerui <[email protected]>
[ Upstream commit 38b10b269d04540aee05c34a059dcf304cfce0a8 ]
Now the arch code is mostly ready for LLVM/Clang consumption, it is time to re-organize the CFLAGS a little to actually enable the LLVM build. Namely, all -G0 switches from CFLAGS are removed, and -mexplicit-relocs and -mdirect-extern-access are now wrapped with cc-option (with the related asm/percpu.h definition guarded against toolchain combos that are known to not work).
A build with !RELOCATABLE && !MODULE is confirmed working within a QEMU environment; support for the two features are currently blocked on LLVM/Clang, and will come later.
Why -G0 can be removed:
In GCC, -G stands for "small data threshold", that instructs the compiler to put data smaller than the specified threshold in a dedicated "small data" section (called .sdata on LoongArch and several other arches).
However, benefiting from this would require ABI cooperation, which is not the case for LoongArch; and current GCC behave the same whether -G0 (equal to disabling this optimization) is given or not. So, remove -G0 from CFLAGS altogether for one less thing to care about. This also benefits LLVM/Clang compatibility where the -G switch is not supported.
Why -mexplicit-relocs can now be conditionally applied without regressions:
Originally -mexplicit-relocs is unconditionally added to CFLAGS in case of CONFIG_AS_HAS_EXPLICIT_RELOCS, because not having it (i.e. old GCC + new binutils) would not work: modules will have R_LARCH_ABS_* relocs inside, but given the rarity of such toolchain combo in the wild, it may not be worthwhile to support it, so support for such relocs in modules were not added back when explicit relocs support was upstreamed, and -mexplicit-relocs is unconditionally added to fail the build early.
Now that Clang compatibility is desired, given Clang is behaving like -mexplicit-relocs from day one but without support for the CLI flag, we must ensure the flag is not passed in case of Clang. However, explicit compiler flavor checks can be more brittle than feature detection: in this case what actually matters is support for __attribute__((model)) when building modules. Given neither older GCC nor current Clang support this attribute, probing for the attribute support and #error'ing out would allow proper UX without checking for Clang, and also automatically work when Clang support for the attribute is to be added in the future.
Why -mdirect-extern-access is now conditionally applied:
This is actually a nice-to-have optimization that can reduce GOT accesses, but not having it is harmless either. Because Clang does not support the option currently, but might do so in the future, conditional application via cc-option ensures compatibility with both current and future Clang versions.
Stable-dep-of: 947d5d036c78 ("LoongArch: Fix build failure with GCC 15 (-std=gnu23)")
--- arch/loongarch/Makefile | 21 +++++++++++++-------- arch/loongarch/include/asm/percpu.h | 6 +++++- arch/loongarch/vdso/Makefile | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-)
arch/loongarch/Makefile +13 -8
@@ -41,8 +41,8 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -G0 -pipe -msoft-float -LDFLAGS_vmlinux += -G0 -static -n -nostdlib +cflags-y += -pipe -msoft-float +LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. # GCC may have -mexplicit-relocs off by default if it was built with an old
@@ -51,13 +51,18 @@ LDFLAGS_vmlinux += -G0 -static -n -nostdlib # When the assembler does not supports explicit relocation hint, we can't use # it. Disable it if the compiler supports it. # -# If you've seen "unknown reloc hint" message building the kernel and you are -# now wondering why "-mexplicit-relocs" is not wrapped with cc-option: the -# combination of a "new" assembler and "old" compiler is not supported. Either -# upgrade the compiler or downgrade the assembler. +# The combination of a "new" assembler and "old" GCC is not supported, given +# the rarity of this combo and the extra complexity needed to make it work. +# Either upgrade the compiler or downgrade the assembler; the build will error +# out if it is the case (by probing for the model attribute; all supported +# compilers in this case would have support). +# +# Also, -mdirect-extern-access is useful in case of building with explicit +# relocs, for avoiding unnecessary GOT accesses. It is harmless to not have +# support though. ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS -cflags-y += -mexplicit-relocs -KBUILD_CFLAGS_KERNEL += -mdirect-extern-access +cflags-y += $(call cc-option,-mexplicit-relocs) +KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access) else cflags-y += $(call cc-option,-mno-explicit-relocs) KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
arch/loongarch/include/asm/percpu.h +5 -1
@@ -14,7 +14,11 @@* loaded. Tell the compiler this fact when using explicit relocs. */ #if defined(MODULE ) && defined(CONFIG_AS_HAS_EXPLICIT_RELOCS ) -#define PER_CPU_ATTRIBUTES __attribute__((model("extreme"))) +# if __has_attribute (model) +# define PER_CPU_ATTRIBUTES __attribute__((model("extreme"))) +# else +# error compiler support for the model attribute is necessary when a recent assembler is used +# endif #endif /* Use r21 for fast access */
arch/loongarch/vdso/Makefile +1 -1
@@ -23,7 +23,7 @@ endif cflags-vdso := $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=include) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -O2 -g -fno-strict-aliasing -fno-common -fno-builtin -G0 \ + -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 301/772 LoongArch: Fix build failure with GCC 15 (-std=gnu23)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 947d5d036c788156f09e83e7f16322ffe8124384 ]
Whenever I try to build the kernel with upcoming GCC 15 which defaults to -std=gnu23 I get a build failure:
CC arch/loongarch/vdso/vgetcpu.o
In file included from ./include/uapi/linux/posix_types.h:5,
from ./include/uapi/linux/types.h:14,
from ./include/linux/types.h:6,
from ./include/linux/kasan-checks.h:5,
from ./include/asm-generic/rwonce.h:26,
from ./arch/loongarch/include/generated/asm/rwonce.h:1,
from ./include/linux/compiler.h:317,
from ./include/asm-generic/bug.h:5,
from ./arch/loongarch/include/asm/bug.h:60,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from ./include/linux/mm.h:6,
from ./arch/loongarch/include/asm/vdso.h:10,
from arch/loongarch/vdso/vgetcpu.c:6:
./include/linux/stddef.h:11:9: error: expected identifier before 'false'
11 | false = 0,
| ^~~~~
./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
35 | typedef _Bool bool;
| ^~~~
./include/linux/types.h:35:1: warning: useless type name in empty declaration
35 | typedef _Bool bool;
| ^~~~~~~The kernel builds explicitly with -std=gnu11 in top Makefile, but arch/loongarch/vdso does not use KBUILD_CFLAGS from the rest of the kernel, just add -std=gnu11 flag to arch/loongarch/vdso/Makefile.
By the way, commit e8c07082a810 ("Kbuild: move to -std=gnu11") did a similar change for arch/arm64/kernel/vdso32/Makefile.
--- arch/loongarch/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/vdso/Makefile +1 -1
@@ -23,7 +23,7 @@ endif cflags-vdso := $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=include) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ + -std=gnu11 -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 302/772 LoongArch: BPF: Sign-extend return values
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 73c359d1d356cf10236ccd358bd55edab33e9424 ]
(1) Description of Problem:
When testing BPF JIT with the latest compiler toolchains on LoongArch, there exist some strange failed test cases, dmesg shows something like this:
# dmesg -t | grep FAIL | head -1 ... ret -3 != -3 (0xfffffffd != 0xfffffffd)FAIL ...
(2) Steps to Reproduce:
# echo 1 > /proc/sys/net/core/bpf_jit_enable # modprobe test_bpf
(3) Additional Info:
There are no failed test cases compiled with the lower version of GCC such as 13.3.0, while the problems only appear with higher version of GCC such as 14.2.0.
This is because the problems were hidden by the lower version of GCC due to redundant sign extension instructions generated by compiler, but with optimization of higher version of GCC, the sign extension instructions have been removed.
(4) Root Cause Analysis:
The LoongArch architecture does not expose sub-registers, and hold all 32-bit values in a sign-extended format. While BPF, on the other hand, exposes sub-registers, and use zero-extension (similar to arm64/x86).
This has led to some subtle bugs, where a BPF JITted program has not sign-extended the a0 register (return value in LoongArch land), passed the return value up the kernel, for example:
| int from_bpf(void);
|
| long foo(void)
| {
| return from_bpf();
| }Here, a0 would be 0xffffffff instead of the expected 0xffffffffffffffff.
Internally, the LoongArch JIT uses a5 as a dedicated register for BPF return values. That is to say, the LoongArch BPF uses a5 for BPF return values, which are zero-extended, whereas the LoongArch ABI uses a0 which is sign-extended.
(5) Final Solution:
Keep a5 zero-extended, but explicitly sign-extend a0 (which is used outside BPF land). Because libbpf currently defines the return value of an ebpf program as a 32-bit unsigned integer, just use addi.w to extend bit 31 into bits 63 through 32 of a5 to a0. This is similar to commit 2f1b0d3d7331 ("riscv, bpf: Sign-extend return values").
--- arch/loongarch/net/bpf_jit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/net/bpf_jit.c +1 -1
@@ -179,7 +179,7 @@ static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)if (!is_tail_call) {/* Set return value */ -move_reg (ctx,LOONGARCH_GPR_A0 , regmap[BPF_REG_0 ]); +emit_insn (ctx, addiw,LOONGARCH_GPR_A0 , regmap[BPF_REG_0 ],0 );/* Return to the caller */ emit_insn (ctx, jirl,LOONGARCH_GPR_RA ,LOONGARCH_GPR_ZERO ,0 ); }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 303/772 power: supply: core: Remove might_sleep() from power_supply_put()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit f6da4553ff24a5d1c959c9627c965323adc3d307 ]
The put_device() call in power_supply_put() may call power_supply_dev_release(). The latter function does not sleep so power_supply_put() doesn't sleep either. Hence, remove the might_sleep() call from power_supply_put(). This patch suppresses false positive complaints about calling a sleeping function from atomic context if power_supply_put() is called from atomic context.
--- drivers/power/supply/power_supply_core.c | 2 -- 1 file changed, 2 deletions(-)
drivers/power/supply/power_supply_core.c +0 -2
@@ -480,8 +480,6 @@ EXPORT_SYMBOL_GPL(power_supply_get_by_name);*/ void power_supply_put (struct power_supply *psy) { -might_sleep (); -atomic_dec (&psy->use_cnt);put_device (&psy->dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 304/772 power: supply: bq27xxx: Fix registers of bq27426
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Barnabás Czémán <[email protected]>
[ Upstream commit 34f99d3b706a519e556841f405c224ca708b1f54 ]
Correct bq27426 registers, according to technical reference manual it does not have Design Capacity register so it is not register compatible with bq27421.
--- drivers/power/supply/bq27xxx_battery.c | 37 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
drivers/power/supply/bq27xxx_battery.c +35 -2
@@ -449,9 +449,29 @@ static u8 [BQ27XXX_REG_AP ] =0x18 ,BQ27XXX_DM_REG_ROWS , }, + bq27426_regs[BQ27XXX_REG_MAX ] = { + [BQ27XXX_REG_CTRL ] =0x00 , + [BQ27XXX_REG_TEMP ] =0x02 , + [BQ27XXX_REG_INT_TEMP ] =0x1e , + [BQ27XXX_REG_VOLT ] =0x04 , + [BQ27XXX_REG_AI ] =0x10 , + [BQ27XXX_REG_FLAGS ] =0x06 , + [BQ27XXX_REG_TTE ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTF ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTES ] =INVALID_REG_ADDR , + [BQ27XXX_REG_TTECP ] =INVALID_REG_ADDR , + [BQ27XXX_REG_NAC ] =0x08 , + [BQ27XXX_REG_RC ] =0x0c , + [BQ27XXX_REG_FCC ] =0x0e , + [BQ27XXX_REG_CYCT ] =INVALID_REG_ADDR , + [BQ27XXX_REG_AE ] =INVALID_REG_ADDR , + [BQ27XXX_REG_SOC ] =0x1c , + [BQ27XXX_REG_DCAP ] =INVALID_REG_ADDR , + [BQ27XXX_REG_AP ] =0x18 , +BQ27XXX_DM_REG_ROWS , + }, #define bq27411_regs bq27421_regs #define bq27425_regs bq27421_regs -#define bq27426_regs bq27421_regs #define bq27441_regs bq27421_regs #define bq27621_regs bq27421_regs bq27z561_regs[BQ27XXX_REG_MAX ] = {
@@ -769,10 +789,23 @@ static enum power_supply_property bq27421_props[] = { };#define bq27411_props bq27421_props#define bq27425_props bq27421_props -#define bq27426_props bq27421_props#define bq27441_props bq27421_props#define bq27621_props bq27421_props +static enum power_supply_property bq27426_props[] = { +POWER_SUPPLY_PROP_STATUS , +POWER_SUPPLY_PROP_PRESENT , +POWER_SUPPLY_PROP_VOLTAGE_NOW , +POWER_SUPPLY_PROP_CURRENT_NOW , +POWER_SUPPLY_PROP_CAPACITY , +POWER_SUPPLY_PROP_CAPACITY_LEVEL , +POWER_SUPPLY_PROP_TEMP , +POWER_SUPPLY_PROP_TECHNOLOGY , +POWER_SUPPLY_PROP_CHARGE_FULL , +POWER_SUPPLY_PROP_CHARGE_NOW , +POWER_SUPPLY_PROP_MANUFACTURER , +}; +static enum power_supply_property bq27z561_props[] = {POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_PRESENT ,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 305/772 net: usb: lan78xx: Fix double free issue with interrupt buffer allocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit 03819abbeb11117dcbba40bfe322b88c0c88a6b6 ]
In lan78xx_probe(), the buffer buf was being freed twice: once implicitly through usb_free_urb(dev->urb_intr) with the URB_FREE_BUFFER flag and again explicitly by kfree(buf). This caused a double free issue.
To resolve this, reordered kmalloc() and usb_alloc_urb() calls to simplify the initialization sequence and removed the redundant kfree(buf). Now, buf is allocated after usb_alloc_urb(), ensuring it is correctly managed by usb_fill_int_urb() and freed by usb_free_urb() as intended.
--- drivers/net/usb/lan78xx.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/net/usb/lan78xx.c +14 -15
@@ -4417,29 +4417,30 @@ static int lan78xx_probe(struct usb_interface *intf, period = ep_intr->desc.bInterval; maxp =usb_maxpacket (dev->udev, dev->pipe_intr); - buf =kmalloc (maxp,GFP_KERNEL ); -if (!buf) { + + dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!dev->urb_intr) { ret = -ENOMEM ; goto out5; } - dev->urb_intr =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!dev->urb_intr) { + buf =kmalloc (maxp,GFP_KERNEL ); +if (!buf) { ret = -ENOMEM ; - goto out6; - }else { -usb_fill_int_urb (dev->urb_intr, dev->udev, - dev->pipe_intr, buf, maxp, - intr_complete, dev, period); - dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + goto free_urbs; } +usb_fill_int_urb (dev->urb_intr, dev->udev, + dev->pipe_intr, buf, maxp, + intr_complete, dev, period); + dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) { ret = -ENODEV ; - goto out6; + goto free_urbs; }/* driver requires remote-wakeup capability during autosuspend. */
@@ -4447,7 +4448,7 @@ static int lan78xx_probe(struct usb_interface *intf, ret =lan78xx_phy_init (dev);if (ret <0 ) - goto out7; + goto free_urbs; ret =register_netdev (netdev);if (ret !=0 ) {
@@ -4469,10 +4470,8 @@ static int lan78xx_probe(struct usb_interface *intf, out8:phy_disconnect (netdev->phydev); -out7: +free_urbs:usb_free_urb (dev->urb_intr); -out6: -kfree (buf); out5:lan78xx_unbind (dev, intf); out4:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 306/772 net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit ae7370e61c5d8f5bcefc2d4fca724bd4e9bbf789 ]
Add calls to phy_device_free after fixed_phy_unregister to fix a memory leak that occurs when the device is unplugged. This ensures proper cleanup of pseudo fixed-link PHYs.
--- drivers/net/usb/lan78xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +4 -1
@@ -2387,6 +2387,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)if (dev->chipid ==ID_REV_CHIP_ID_7801_ ) {if (phy_is_pseudo_fixed_link (phydev)) {fixed_phy_unregister (phydev); +phy_device_free (phydev); }else {phy_unregister_fixup_for_uid (PHY_KSZ9031RNX ,0xfffffff0 );
@@ -4246,8 +4247,10 @@ static void lan78xx_disconnect(struct usb_interface *intf)phy_disconnect (net->phydev); -if (phy_is_pseudo_fixed_link (phydev)) +if (phy_is_pseudo_fixed_link (phydev)) {fixed_phy_unregister (phydev); +phy_device_free (phydev); + }usb_scuttle_anchored_urbs (&dev->deferred);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 307/772 tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Chebbi <[email protected]>
[ Upstream commit 614f4d166eeeb9bd709b0ad29552f691c0f45776 ]
The hardware on Broadcom 1G chipsets have a known limitation where they cannot handle DMA addresses that cross over 4GB. When such an address is encountered, the hardware sets the address overflow error bit in the DMA status register and triggers a reset.
However, BCM57766 hardware is setting the overflow bit and triggering a reset in some cases when there is no actual underlying address overflow. The hardware team analyzed the issue and concluded that it is happening when the status block update has an address with higher (b16 to b31) bits as 0xffff following a previous update that had lowest bits as 0xffff.
To work around this bug in the BCM57766 hardware, set the coherent dma mask from the current 64b to 31b. This will ensure that upper bits of the status block DMA address are always at most 0x7fff, thus avoiding the improper overflow check described above. This work around is intended for only status block and ring memories and has no effect on TX and RX buffers as they do not require coherent memory.
--- drivers/net/ethernet/broadcom/tg3.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +3 -0
@@ -17736,6 +17736,9 @@ static int tg3_init_one(struct pci_dev *pdev, }else persist_dma_mask = dma_mask =DMA_BIT_MASK (64 ); +if (tg3_asic_rev (tp) ==ASIC_REV_57766 ) + persist_dma_mask =DMA_BIT_MASK (31 ); +/* Configure DMA attributes. */ if (dma_mask >DMA_BIT_MASK (32 )) { err =dma_set_mask (&pdev->dev, dma_mask);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 308/772 net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit e863ff806f72098bccaf8fa89c80d9ad6187c3b0 ]
Validate Wake-on-LAN (WoL) options in lan78xx_set_wol before calling usb_autopm_get_interface. This prevents USB autopm refcounting issues and ensures the adapter can properly enter autosuspend when invalid WoL options are provided.
--- drivers/net/usb/lan78xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/lan78xx.c +3 -3
@@ -1657,13 +1657,13 @@ static int lan78xx_set_wol(struct net_device *netdev,struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0 ]);int ret; +if (wol->wolopts & ~WAKE_ALL ) +return -EINVAL ; + ret =usb_autopm_get_interface (dev->intf);if (ret <0 )return ret; -if (wol->wolopts & ~WAKE_ALL ) -return -EINVAL ; - pdata->wol = wol->wolopts;device_set_wakeup_enable (&dev->udev->dev, (bool )wol->wolopts);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 309/772 s390/iucv: MSG_PEEK causes memory leak in iucv_sock_destruct()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sidraya Jayagond <[email protected]>
[ Upstream commit ebaf81317e42aa990ad20b113cfe3a7b20d4e937 ]
Passing MSG_PEEK flag to skb_recv_datagram() increments skb refcount (skb->users) and iucv_sock_recvmsg() does not decrement skb refcount at exit.
This results in skb memory leak in skb_queue_purge() and WARN_ON in iucv_sock_destruct() during socket close. To fix this decrease skb refcount by one if MSG_PEEK is set in order to prevent memory leak and WARN_ON.
WARNING: CPU: 2 PID: 6292 at net/iucv/af_iucv.c:286 iucv_sock_destruct+0x144/0x1a0 [af_iucv]
CPU: 2 PID: 6292 Comm: afiucv_test_msg Kdump: loaded Tainted: G W 6.10.0-rc7 #1
Hardware name: IBM 3931 A01 704 (z/VM 7.3.0)
Call Trace:
[<001587c682c4aa98>] iucv_sock_destruct+0x148/0x1a0 [af_iucv]
[<001587c682c4a9d0>] iucv_sock_destruct+0x80/0x1a0 [af_iucv]
[<001587c704117a32>] __sk_destruct+0x52/0x550
[<001587c704104a54>] __sock_release+0xa4/0x230
[<001587c704104c0c>] sock_close+0x2c/0x40
[<001587c702c5f5a8>] __fput+0x2e8/0x970
[<001587c7024148c4>] task_work_run+0x1c4/0x2c0
[<001587c7023b0716>] do_exit+0x996/0x1050
[<001587c7023b13aa>] do_group_exit+0x13a/0x360
[<001587c7023b1626>] __s390x_sys_exit_group+0x56/0x60
[<001587c7022bccca>] do_syscall+0x27a/0x380
[<001587c7049a6a0c>] __do_syscall+0x9c/0x160
[<001587c7049ce8a8>] system_call+0x70/0x98
Last Breaking-Event-Address:
[<001587c682c4a9d4>] iucv_sock_destruct+0x84/0x1a0 [af_iucv]--- net/iucv/af_iucv.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
net/iucv/af_iucv.c +17 -9
@@ -1238,7 +1238,9 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,return -EOPNOTSUPP ;/* receive/dequeue next skb: -* the function understands MSG_PEEK and, thus, does not dequeue skb */ +* the function understands MSG_PEEK and, thus, does not dequeue skb +* only refcount is increased. +*/ skb =skb_recv_datagram (sk, flags, &err);if (!skb) {if (sk->sk_shutdown &RCV_SHUTDOWN )
@@ -1254,9 +1256,8 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg, cskb = skb;if (skb_copy_datagram_msg (cskb, offset, msg, copied)) { -if (!(flags &MSG_PEEK )) -skb_queue_head (&sk->sk_receive_queue, skb); -return -EFAULT ; + err = -EFAULT ; + goto err_out; }/* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */
@@ -1273,11 +1274,8 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg, err =put_cmsg (msg,SOL_IUCV ,SCM_IUCV_TRGCLS ,sizeof (IUCV_SKB_CB (skb)->class), (void *)&IUCV_SKB_CB (skb)->class); -if (err) { -if (!(flags &MSG_PEEK )) -skb_queue_head (&sk->sk_receive_queue, skb); -return err; - } +if (err) + goto err_out;/* Mark read part of skb as used */ if (!(flags &MSG_PEEK )) {
@@ -1333,8 +1331,18 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,/* SOCK_SEQPACKET: return real length if MSG_TRUNC is set */ if (sk->sk_type ==SOCK_SEQPACKET && (flags &MSG_TRUNC )) copied = rlen; +if (flags &MSG_PEEK ) +skb_unref (skb);return copied; + +err_out: +if (!(flags &MSG_PEEK )) +skb_queue_head (&sk->sk_receive_queue, skb); +else +skb_unref (skb); + +return err; }static inline __poll_t iucv_accept_poll (struct sock *parent)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 310/772 net/ipv6: delete temporary address if mngtmpaddr is removed or unmanaged
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 00b5b7aab9e422d00d5a9d03d7e0760a76b5d57f ]
RFC8981 section 3.4 says that existing temporary addresses must have their lifetimes adjusted so that no temporary addresses should ever remain "valid" or "preferred" longer than the incoming SLAAC Prefix Information. This would strongly imply in Linux's case that if the "mngtmpaddr" address is deleted or un-flagged as such, its corresponding temporary addresses must be cleared out right away.
But now the temporary address is renewed even after ‘mngtmpaddr’ is removed or becomes unmanaged as manage_tempaddrs() set temporary addresses prefered/valid time to 0, and later in addrconf_verify_rtnl() all checkings failed to remove the addresses. Fix this by deleting the temporary address directly for these situations.
--- net/ipv6/addrconf.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
net/ipv6/addrconf.c +29 -12
@@ -2527,6 +2527,24 @@ static struct inet6_dev *addrconf_add_dev(struct net_device *dev)return idev; } +static void delete_tempaddrs (struct inet6_dev *idev, +struct inet6_ifaddr *ifp) +{ +struct inet6_ifaddr *ift, *tmp; + +write_lock_bh (&idev->lock); +list_for_each_entry_safe (ift, tmp, &idev->tempaddr_list, tmp_list) { +if (ift->ifpub != ifp) +continue ; + +in6_ifa_hold (ift); +write_unlock_bh (&idev->lock); +ipv6_del_addr (ift); +write_lock_bh (&idev->lock); + } +write_unlock_bh (&idev->lock); +} + static void manage_tempaddrs(struct inet6_dev *idev, struct inet6_ifaddr *ifp, __u32 valid_lft, __u32 prefered_lft,
@@ -3051,11 +3069,12 @@ static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,in6_ifa_hold (ifp);read_unlock_bh (&idev->lock); -if (!(ifp->flags &IFA_F_TEMPORARY ) && - (ifa_flags &IFA_F_MANAGETEMPADDR )) -manage_tempaddrs (idev, ifp,0 ,0 , false, - jiffies);ipv6_del_addr (ifp); + +if (!(ifp->flags &IFA_F_TEMPORARY ) && + (ifp->flags &IFA_F_MANAGETEMPADDR )) +delete_tempaddrs (idev, ifp); +addrconf_verify_rtnl (net);if (ipv6_addr_is_multicast (pfx)) { ipv6_mc_config(net->ipv6.mc_autojoin_sk,
@@ -4863,14 +4882,12 @@ static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp, }if (was_managetempaddr || ifp->flags &IFA_F_MANAGETEMPADDR ) { -if (was_managetempaddr && - !(ifp->flags &IFA_F_MANAGETEMPADDR )) { - cfg->valid_lft =0 ; - cfg->preferred_lft =0 ; - } -manage_tempaddrs (ifp->idev, ifp, cfg->valid_lft, - cfg->preferred_lft, !was_managetempaddr, - jiffies); +if (was_managetempaddr && !(ifp->flags &IFA_F_MANAGETEMPADDR )) +delete_tempaddrs (ifp->idev, ifp); +else +manage_tempaddrs (ifp->idev, ifp, cfg->valid_lft, + cfg->preferred_lft, !was_managetempaddr, + jiffies); }addrconf_verify_rtnl (net);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 311/772 net: mdio-ipq4019: add missing error check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 9cc8d0ecdd2aad42e377e971e3bb114339df609e ]
If an optional resource is found but fails to remap, return on failure. Avoids any potential problems when using the iomapped resource as the assumption is that it's available.
--- drivers/net/mdio/mdio-ipq4019.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/mdio/mdio-ipq4019.c +4 -1
@@ -231,8 +231,11 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)/* The platform resource is provided on the chipset IPQ5018 */ /* This resource is optional */ res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (res) +if (res) { priv->eth_ldo_rdy =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (priv->eth_ldo_rdy)) +return PTR_ERR (priv->eth_ldo_rdy); + } bus->name ="ipq4019_mdio" ; bus->read = ipq4019_mdio_read;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 312/772 marvell: pxa168_eth: fix call balance of pep->clk handling routines
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitalii Mordan <[email protected]>
[ Upstream commit b032ae57d4fe2b2445e3bc190db6fcaa8c102f68 ]
If the clock pep->clk was not enabled in pxa168_eth_probe, it should not be disabled in any path.
Conversely, if it was enabled in pxa168_eth_probe, it must be disabled in all error paths to ensure proper cleanup.
Use the devm_clk_get_enabled helper function to ensure proper call balance for pep->clk.
Found by Linux Verification Center (linuxtesting.org) with Klever.
--- drivers/net/ethernet/marvell/pxa168_eth.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/marvell/pxa168_eth.c +4 -10
@@ -1394,18 +1394,15 @@ static int pxa168_eth_probe(struct platform_device *pdev)printk (KERN_NOTICE "PXA168 10/100 Ethernet Driver\n" ); - clk =devm_clk_get (&pdev->dev,NULL ); + clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (clk)) { -dev_err (&pdev->dev,"Fast Ethernet failed to get clock\n" ); +dev_err (&pdev->dev,"Fast Ethernet failed to get and enable clock\n" );return -ENODEV ; } -clk_prepare_enable (clk); dev =alloc_etherdev (sizeof (struct pxa168_eth_private )); -if (!dev) { - err = -ENOMEM ; - goto err_clk; - } +if (!dev) +return -ENOMEM ;platform_set_drvdata (pdev, dev); pep =netdev_priv (dev);
@@ -1523,8 +1520,6 @@ static int pxa168_eth_probe(struct platform_device *pdev)mdiobus_free (pep->smi_bus); err_netdev:free_netdev (dev); -err_clk: -clk_disable_unprepare (clk);return err; }
@@ -1542,7 +1537,6 @@ static int pxa168_eth_remove(struct platform_device *pdev)if (dev->phydev)phy_disconnect (dev->phydev); -clk_disable_unprepare (pep->clk);mdiobus_unregister (pep->smi_bus);mdiobus_free (pep->smi_bus);unregister_netdev (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 313/772 net: stmmac: dwmac-socfpga: Set RX watchdog interrupt as broken
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit 407618d66dba55e7db1278872e8be106808bbe91 ]
On DWMAC3 and later, there's a RX Watchdog interrupt that's used for interrupt coalescing. It's known to be buggy on some platforms, and dwmac-socfpga appears to be one of them. Changing the interrupt coalescing from ethtool doesn't appear to have any effect here.
Without disabling RIWT (Received Interrupt Watchdog Timer, I believe...), we observe latencies while receiving traffic that amount to around ~0.4ms. This was discovered with NTP but can be easily reproduced with a simple ping. Without this patch :
64 bytes from 192.168.5.2: icmp_seq=1 ttl=64 time=0.657 ms
With this patch :
64 bytes from 192.168.5.2: icmp_seq=1 ttl=64 time=0.254 ms
--- drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +2 -0
@@ -426,6 +426,8 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) plat_dat->bsp_priv = dwmac; plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; + plat_dat->riwt_off =1 ; + ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) goto err_remove_config_dt;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 314/772 octeontx2-af: RPM: Fix mismatch in lmac type
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit 7ebbbb23ea5b6d051509cb11399afac5042c9266 ]
Due to a bug in the previous patch, there is a mismatch between the lmac type reported by the driver and the actual hardware configuration.
--- drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +1 -1
@@ -350,7 +350,7 @@ u8 rpm_get_lmac_type(void *rpmd, int lmac_id)int err; req =FIELD_SET (CMDREG_ID ,CGX_CMD_GET_LINK_STS , req); - err =cgx_fwi_cmd_generic (req, &resp, rpm,0 ); + err =cgx_fwi_cmd_generic (req, &resp, rpm, lmac_id);if (!err)return FIELD_GET (RESP_LINKSTAT_LMAC_TYPE , resp);return err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 315/772 spi: atmel-quadspi: Fix register name in verbose logging function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Csókás, Bence <[email protected]>
[ Upstream commit 2ac40e6d0ccdd93031f8b1af61b0fe5cdd704923 ]
atmel_qspi_reg_name() is used for pretty-printing register offsets for verbose logging of register accesses. However, due to a typo (likely a copy-paste error), QSPI_RD's offset prints as "MR", the name of the previous register. Fix this typo.
--- drivers/spi/atmel-quadspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/atmel-quadspi.c +1 -1
@@ -183,7 +183,7 @@ static const char *atmel_qspi_reg_name(u32 offset, char *tmp, size_t sz)case QSPI_MR :return "MR" ;case QSPI_RD : -return "MR" ; +return "RD" ;case QSPI_TD :return "TD" ;case QSPI_SR :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 316/772 net: hsr: fix hsr_init_sk() vs network/transport headers.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9cfb5e7f0ded2bfaabc270ceb5f91d13f0e805b9 ]
Following sequence in hsr_init_sk() is invalid :
skb_reset_mac_header(skb);
skb_reset_mac_len(skb);
skb_reset_network_header(skb);
skb_reset_transport_header(skb);It is invalid because skb_reset_mac_len() needs the correct network header, which should be after the mac header.
This patch moves the skb_reset_network_header() and skb_reset_transport_header() before
the call to dev_hard_header().
As a result skb->mac_len is no longer set to a value close to 65535.
--- net/hsr/hsr_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/hsr/hsr_device.c +2 -2
@@ -253,6 +253,8 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master) skb->dev = master->dev; skb->priority =TC_PRIO_CONTROL ; +skb_reset_network_header (skb); +skb_reset_transport_header (skb);if (dev_hard_header (skb, skb->dev,ETH_P_PRP , hsr->sup_multicast_addr, skb->dev->dev_addr, skb->len) <=0 )
@@ -260,8 +262,6 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master)skb_reset_mac_header (skb);skb_reset_mac_len (skb); -skb_reset_network_header (skb); -skb_reset_transport_header (skb);return skb; out:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 317/772 bnxt_en: Reserve rings after PCIe AER recovery if NIC interface is down
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravanan Vajravel <[email protected]>
[ Upstream commit 5311598f7f3293683cdc761df71ae3469327332c ]
After successful PCIe AER recovery, FW will reset all resource reservations. If it is IF_UP, the driver will call bnxt_open() and all resources will be reserved again. It it is IF_DOWN, we should call bnxt_reserve_rings() so that we can reserve resources including RoCE resources to allow RoCE to resume after AER. Without this patch, RoCE fails to resume in this IF_DOWN scenario.
Later, if it becomes IF_UP, bnxt_open() will see that resources have been reserved and will not reserve again.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -14113,8 +14113,12 @@ static void bnxt_io_resume(struct pci_dev *pdev)rtnl_lock (); err =bnxt_hwrm_func_qcaps (bp); -if (!err &&netif_running (netdev)) - err =bnxt_open (netdev); +if (!err) { +if (netif_running (netdev)) + err =bnxt_open (netdev); +else + err =bnxt_reserve_rings (bp, true); + }bnxt_ulp_start (bp, err);if (!err) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 318/772 Bluetooth: MGMT: Fix slab-use-after-free Read in set_powered_sync
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0b882940665ca2849386ee459d4331aa2f8c4e7d ]
This fixes the following crash:
==================================================================
BUG: KASAN: slab-use-after-free in set_powered_sync+0x3a/0xc0 net/bluetooth/mgmt.c:1353 Read of size 8 at addr ffff888029b4dd18 by task kworker/u9:0/54 CPU: 1 UID: 0 PID: 54 Comm: kworker/u9:0 Not tainted 6.11.0-rc6-syzkaller-01155-gf723224742fc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Workqueue: hci0 hci_cmd_sync_work Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 q kasan_report+0x143/0x180 mm/kasan/report.c:601 set_powered_sync+0x3a/0xc0 net/bluetooth/mgmt.c:1353 hci_cmd_sync_work+0x22b/0x400 net/bluetooth/hci_sync.c:328 process_one_work kernel/workqueue.c:3231 [inline] process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312 worker_thread+0x86d/0xd10 kernel/workqueue.c:3389 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> Allocated by task 5247: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4193 kmalloc_noprof include/linux/slab.h:681 [inline] kzalloc_noprof include/linux/slab.h:807 [inline] mgmt_pending_new+0x65/0x250 net/bluetooth/mgmt_util.c:269 mgmt_pending_add+0x36/0x120 net/bluetooth/mgmt_util.c:296 set_powered+0x3cd/0x5e0 net/bluetooth/mgmt.c:1394 hci_mgmt_cmd+0xc47/0x11d0 net/bluetooth/hci_sock.c:1712 hci_sock_sendmsg+0x7b8/0x11c0 net/bluetooth/hci_sock.c:1832 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 sock_write_iter+0x2dd/0x400 net/socket.c:1160 new_sync_write fs/read_write.c:497 [inline] vfs_write+0xa72/0xc90 fs/read_write.c:590 ksys_write+0x1a0/0x2c0 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5246: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2256 [inline] slab_free mm/slub.c:4477 [inline] kfree+0x149/0x360 mm/slub.c:4598 settings_rsp+0x2bc/0x390 net/bluetooth/mgmt.c:1443 mgmt_pending_foreach+0xd1/0x130 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x112/0x420 net/bluetooth/mgmt.c:9455 hci_dev_close_sync+0x665/0x11a0 net/bluetooth/hci_sync.c:5191 hci_dev_do_close net/bluetooth/hci_core.c:483 [inline] hci_dev_close+0x112/0x210 net/bluetooth/hci_core.c:508 sock_do_ioctl+0x158/0x460 net/socket.c:1222 sock_ioctl+0x629/0x8e0 net/socket.c:1341 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83gv entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- net/bluetooth/mgmt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +9 -2
@@ -1329,7 +1329,8 @@ static void mgmt_set_powered_complete(struct hci_dev *hdev, void *data, int err)struct mgmt_mode *cp;/* Make sure cmd still outstanding. */ -if (cmd !=pending_find (MGMT_OP_SET_POWERED , hdev)) +if (err == -ECANCELED || + cmd !=pending_find (MGMT_OP_SET_POWERED , hdev))return ; cp = cmd->param;
@@ -1362,7 +1363,13 @@ static void mgmt_set_powered_complete(struct hci_dev *hdev, void *data, int err)static int set_powered_sync (struct hci_dev *hdev,void *data) {struct mgmt_pending_cmd *cmd = data; -struct mgmt_mode *cp = cmd->param; +struct mgmt_mode *cp; + +/* Make sure cmd still outstanding. */ +if (cmd !=pending_find (MGMT_OP_SET_POWERED , hdev)) +return -ECANCELED ; + + cp = cmd->param;BT_DBG ("%s" , hdev->name);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 319/772 crypto: api - Add crypto_tfm_get
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit ae131f4970f0778f35ed06aeb15bde2fbc1d9619 ]
Add a crypto_tfm_get interface to allow tfm objects to be shared. They can still be freed in the usual way.
This should only be done with tfm objects with no keys. You must also not modify the tfm flags in any way once it becomes shared.
Stable-dep-of: 1465036b10be ("llc: Improve setsockopt() handling of malformed user input")
--- crypto/api.c | 4 ++++ crypto/internal.h | 6 ++++++ include/linux/crypto.h | 1 + 3 files changed, 11 insertions(+)
crypto/api.c +4 -0
@@ -409,6 +409,7 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, goto out_err; tfm->__crt_alg = alg; +refcount_set (&tfm->refcnt,1 ); err =crypto_init_ops (tfm, type, mask);if (err)
@@ -508,6 +509,7 @@ void *crypto_create_tfm_node(struct crypto_alg *alg, tfm = (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg = alg; tfm->node = node; +refcount_set (&tfm->refcnt,1 ); err = frontend->init_tfm (tfm);if (err)
@@ -620,6 +622,8 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)if (IS_ERR_OR_NULL (mem))return ; +if (!refcount_dec_and_test (&tfm->refcnt)) +return ; alg = tfm->__crt_alg;if (!tfm->exit && alg->cra_exit)
crypto/internal.h +6 -0
@@ -10,6 +10,7 @@#include <crypto/algapi.h> #include <linux/completion.h> +#include <linux/err.h> #include <linux/jump_label.h> #include <linux/list.h> #include <linux/module.h>
@@ -166,5 +167,10 @@ static inline int crypto_is_test_larval(struct crypto_larval *larval) return larval->alg.cra_driver_name[0]; } +static inline struct crypto_tfm *crypto_tfm_get (struct crypto_tfm *tfm) +{ +return refcount_inc_not_zero (&tfm->refcnt) ? tfm :ERR_PTR (-EOVERFLOW ); +} +#endif /* _CRYPTO_INTERNAL_H */
include/linux/crypto.h +1 -0
@@ -642,6 +642,7 @@ int crypto_has_alg(const char *name, u32 type, u32 mask);*/ struct crypto_tfm { +refcount_t refcnt;u32 crt_flags;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 320/772 crypto: api - Add crypto_clone_tfm
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 3c3a24cb0ae46c9c45e4ce2272f84f0504831f59 ]
This patch adds the helper crypto_clone_tfm. The purpose is to allocate a tfm object with GFP_ATOMIC. As we cannot sleep, the object has to be cloned from an existing tfm object.
This allows code paths that cannot otherwise allocate a crypto_tfm object to do so. Once a new tfm has been obtained its key could then be changed without impacting other users.
Stable-dep-of: 1465036b10be ("llc: Improve setsockopt() handling of malformed user input")
--- crypto/api.c | 59 +++++++++++++++++++++++++++++++++++++++-------- crypto/internal.h | 2 ++ 2 files changed, 52 insertions(+), 9 deletions(-)
crypto/api.c +50 -9
@@ -489,28 +489,44 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask) }EXPORT_SYMBOL_GPL (crypto_alloc_base); -void *crypto_create_tfm_node (struct crypto_alg *alg, -const struct crypto_type *frontend, -int node) +static void *crypto_alloc_tfmmem (struct crypto_alg *alg, +const struct crypto_type *frontend,int node, +gfp_t gfp) { -char *mem; -struct crypto_tfm *tfm =NULL ; +struct crypto_tfm *tfm;unsigned int tfmsize;unsigned int total; -int err = -ENOMEM ; +char *mem; tfmsize = frontend->tfmsize; total = tfmsize +sizeof (*tfm) + frontend->extsize (alg); - mem =kzalloc_node (total,GFP_KERNEL , node); + mem =kzalloc_node (total, gfp, node);if (mem ==NULL ) - goto out_err; +return ERR_PTR (-ENOMEM ); tfm = (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg = alg; tfm->node = node;refcount_set (&tfm->refcnt,1 ); +return mem; +} + +void *crypto_create_tfm_node (struct crypto_alg *alg, +const struct crypto_type *frontend, +int node) +{ +struct crypto_tfm *tfm; +char *mem; +int err; + + mem =crypto_alloc_tfmmem (alg, frontend, node,GFP_KERNEL ); +if (IS_ERR (mem)) + goto out; + + tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); + err = frontend->init_tfm (tfm);if (err) goto out_free_tfm;
@@ -526,13 +542,38 @@ void *crypto_create_tfm_node(struct crypto_alg *alg,if (err == -EAGAIN )crypto_shoot_alg (alg);kfree (mem); -out_err: mem =ERR_PTR (err); out:return mem; }EXPORT_SYMBOL_GPL (crypto_create_tfm_node); +void *crypto_clone_tfm (const struct crypto_type *frontend, +struct crypto_tfm *otfm) +{ +struct crypto_alg *alg = otfm->__crt_alg; +struct crypto_tfm *tfm; +char *mem; + + mem =ERR_PTR (-ESTALE ); +if (unlikely (!crypto_mod_get (alg))) + goto out; + + mem =crypto_alloc_tfmmem (alg, frontend, otfm->node,GFP_ATOMIC ); +if (IS_ERR (mem)) { +crypto_mod_put (alg); + goto out; + } + + tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); + tfm->crt_flags = otfm->crt_flags; + tfm->exit = otfm->exit; + +out: +return mem; +} +EXPORT_SYMBOL_GPL (crypto_clone_tfm); +struct crypto_alg *crypto_find_alg (const char *alg_name,const struct crypto_type *frontend,u32 type,u32 mask)
crypto/internal.h +2 -0
@@ -86,6 +86,8 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, u32 mask);void *crypto_create_tfm_node (struct crypto_alg *alg,const struct crypto_type *frontend,int node); +void *crypto_clone_tfm (const struct crypto_type *frontend, +struct crypto_tfm *otfm);static inline void *crypto_create_tfm (struct crypto_alg *alg,const struct crypto_type *frontend)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 321/772 llc: Improve setsockopt() handling of malformed user input
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 1465036b10be4b8b00eb31c879e86de633ad74c1 ]
copy_from_sockptr() is used incorrectly: return value is the number of bytes that could not be copied. Since it's deprecated, switch to copy_safe_from_sockptr().
Note: Keeping the optlen != sizeof(int) check as copy_safe_from_sockptr() by itself would also accept optlen > sizeof(int). Which would allow a more lenient handling of inputs.
--- net/llc/af_llc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/llc/af_llc.c +1 -1
@@ -1099,7 +1099,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,lock_sock (sk);if (unlikely (level !=SOL_LLC || optlen !=sizeof (int ))) goto out; - rc =copy_from_sockptr (&opt, optval,sizeof (opt)); + rc =copy_safe_from_sockptr (&opt,sizeof (opt), optval, optlen);if (rc) goto out; rc = -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 322/772 rxrpc: Improve setsockopt() handling of malformed user input
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 02020056647017e70509bb58c3096448117099e1 ]
copy_from_sockptr() does not return negative value on error; instead, it reports the number of bytes that failed to copy. Since it's deprecated, switch to copy_safe_from_sockptr().
Note: Keeping the optlen != sizeof(unsigned int) check as copy_safe_from_sockptr() by itself would also accept
optlen > sizeof(unsigned int). Which would allow a more lenient handling of inputs.
--- net/rxrpc/af_rxrpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/rxrpc/af_rxrpc.c +4 -3
@@ -641,9 +641,10 @@ static int rxrpc_setsockopt(struct socket *sock, int level, int optname, ret = -EISCONN ;if (rx->sk.sk_state !=RXRPC_UNBOUND ) goto error; - ret =copy_from_sockptr (&min_sec_level, optval, -sizeof (unsigned int )); -if (ret <0 ) + ret =copy_safe_from_sockptr (&min_sec_level, +sizeof (min_sec_level), + optval, optlen); +if (ret) goto error; ret = -EINVAL ;if (min_sec_level >RXRPC_SECURITY_MAX )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 323/772 tcp: Fix use-after-free of nreq in reqsk_timer_handler().
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit c31e72d021db2714df03df6c42855a1db592716c ]
The cited commit replaced inet_csk_reqsk_queue_drop_and_put() with __inet_csk_reqsk_queue_drop() and reqsk_put() in reqsk_timer_handler().
Then, oreq should be passed to reqsk_put() instead of req; otherwise use-after-free of nreq could happen when reqsk is migrated but the retry attempt failed (e.g. due to timeout).
Let's pass oreq to reqsk_put().
--- net/ipv4/inet_connection_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_connection_sock.c +1 -1
@@ -1121,7 +1121,7 @@ static void reqsk_timer_handler(struct timer_list *t) drop:__inet_csk_reqsk_queue_drop (sk_listener, oreq, true); -reqsk_put (req); +reqsk_put (oreq); } static bool reqsk_queue_hash_req(struct request_sock *req,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 324/772 ip6mr: fix tables suspicious RCU usage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit f1553c9894b4dbeb10a2ab15ab1aa113b3b4047c ]
Several places call ip6mr_get_table() with no RCU nor RTNL lock. Add RCU protection inside such helper and provide a lockless variant for the few callers that already acquired the relevant lock.
Note that some users additionally reference the table outside the RCU lock. That is actually safe as the table deletion can happen only after all table accesses are completed.
--- net/ipv6/ip6mr.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-)
net/ipv6/ip6mr.c +27 -11
@@ -125,7 +125,7 @@ static struct mr_table *ip6mr_mr_table_iter(struct net *net,return ret; } -static struct mr_table *ip6mr_get_table (struct net *net,u32 id) +static struct mr_table *__ip6mr_get_table (struct net *net,u32 id) {struct mr_table *mrt;
@@ -136,6 +136,16 @@ static struct mr_table *ip6mr_get_table(struct net *net, u32 id)return NULL ; } +static struct mr_table *ip6mr_get_table (struct net *net,u32 id) +{ +struct mr_table *mrt; + +rcu_read_lock (); + mrt =__ip6mr_get_table (net, id); +rcu_read_unlock (); +return mrt; +} +static int ip6mr_fib_lookup (struct net *net,struct flowi6 *flp6,struct mr_table **mrt) {
@@ -177,7 +187,7 @@ static int ip6mr_rule_action(struct fib_rule *rule, struct flowi *flp, arg->table =fib_rule_get_table (rule, arg); - mrt =ip6mr_get_table (rule->fr_net, arg->table); + mrt =__ip6mr_get_table (rule->fr_net, arg->table);if (!mrt)return -EAGAIN ; res->mrt = mrt;
@@ -304,6 +314,8 @@ static struct mr_table *ip6mr_get_table(struct net *net, u32 id)return net->ipv6.mrt6; } +#define __ip6mr_get_table ip6mr_get_table +static int ip6mr_fib_lookup (struct net *net,struct flowi6 *flp6,struct mr_table **mrt) {
@@ -382,7 +394,7 @@ static struct mr_table *ip6mr_new_table(struct net *net, u32 id) {struct mr_table *mrt; - mrt =ip6mr_get_table (net, id); + mrt =__ip6mr_get_table (net, id);if (mrt)return mrt;
@@ -411,13 +423,15 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)struct net *net =seq_file_net (seq);struct mr_table *mrt; - mrt =ip6mr_get_table (net,RT6_TABLE_DFLT ); -if (!mrt) +rcu_read_lock (); + mrt =__ip6mr_get_table (net,RT6_TABLE_DFLT ); +if (!mrt) { +rcu_read_unlock ();return ERR_PTR (-ENOENT ); + } iter->mrt = mrt; -rcu_read_lock ();return mr_vif_seq_start (seq, pos); }
@@ -2288,11 +2302,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,struct mfc6_cache *cache;struct rt6_info *rt = (struct rt6_info *)skb_dst (skb); - mrt =ip6mr_get_table (net,RT6_TABLE_DFLT ); -if (!mrt) +rcu_read_lock (); + mrt =__ip6mr_get_table (net,RT6_TABLE_DFLT ); +if (!mrt) { +rcu_read_unlock ();return -ENOENT ; + } -rcu_read_lock (); cache =ip6mr_cache_find (mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr);if (!cache && skb->dev) {int vif =ip6mr_find_vif (mrt, skb->dev);
@@ -2573,7 +2589,7 @@ static int ip6mr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp =nla_get_in6_addr (tb[RTA_DST ]); tableid = tb[RTA_TABLE ] ?nla_get_u32 (tb[RTA_TABLE ]) :0 ; - mrt =ip6mr_get_table (net, tableid ?:RT_TABLE_DEFAULT ); + mrt =__ip6mr_get_table (net, tableid ?:RT_TABLE_DEFAULT );if (!mrt) {NL_SET_ERR_MSG_MOD (extack,"MR table does not exist" );return -ENOENT ;
@@ -2618,7 +2634,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)if (filter.table_id) {struct mr_table *mrt; - mrt =ip6mr_get_table (sock_net (skb->sk), filter.table_id); + mrt =__ip6mr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) {if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IP6MR )return skb->len;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 325/772 ipmr: fix tables suspicious RCU usage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit fc9c273d6daaa9866f349bbe8cae25c67764c456 ]
Similar to the previous patch, plumb the RCU lock inside the ipmr_get_table(), provided a lockless variant and apply the latter in the few spots were the lock is already held.
--- net/ipv4/ipmr.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-)
net/ipv4/ipmr.c +29 -13
@@ -136,7 +136,7 @@ static struct mr_table *ipmr_mr_table_iter(struct net *net,return ret; } -static struct mr_table *ipmr_get_table (struct net *net,u32 id) +static struct mr_table *__ipmr_get_table (struct net *net,u32 id) {struct mr_table *mrt;
@@ -147,6 +147,16 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)return NULL ; } +static struct mr_table *ipmr_get_table (struct net *net,u32 id) +{ +struct mr_table *mrt; + +rcu_read_lock (); + mrt =__ipmr_get_table (net, id); +rcu_read_unlock (); +return mrt; +} +static int ipmr_fib_lookup (struct net *net,struct flowi4 *flp4,struct mr_table **mrt) {
@@ -188,7 +198,7 @@ static int ipmr_rule_action(struct fib_rule *rule, struct flowi *flp, arg->table =fib_rule_get_table (rule, arg); - mrt =ipmr_get_table (rule->fr_net, arg->table); + mrt =__ipmr_get_table (rule->fr_net, arg->table);if (!mrt)return -EAGAIN ; res->mrt = mrt;
@@ -314,6 +324,8 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)return net->ipv4.mrt; } +#define __ipmr_get_table ipmr_get_table +static int ipmr_fib_lookup (struct net *net,struct flowi4 *flp4,struct mr_table **mrt) {
@@ -402,7 +414,7 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id)if (id !=RT_TABLE_DEFAULT && id >=1000000000 )return ERR_PTR (-EINVAL ); - mrt =ipmr_get_table (net, id); + mrt =__ipmr_get_table (net, id);if (mrt)return mrt;
@@ -1373,7 +1385,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, goto out_unlock; } - mrt =ipmr_get_table (net,raw_sk (sk)->ipmr_table ? :RT_TABLE_DEFAULT ); + mrt =__ipmr_get_table (net,raw_sk (sk)->ipmr_table ? :RT_TABLE_DEFAULT );if (!mrt) { ret = -ENOENT ; goto out_unlock;
@@ -2247,11 +2259,13 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,struct mr_table *mrt;int err; - mrt =ipmr_get_table (net,RT_TABLE_DEFAULT ); -if (!mrt) +rcu_read_lock (); + mrt =__ipmr_get_table (net,RT_TABLE_DEFAULT ); +if (!mrt) { +rcu_read_unlock ();return -ENOENT ; + } -rcu_read_lock (); cache =ipmr_cache_find (mrt, saddr, daddr);if (!cache && skb->dev) {int vif =ipmr_find_vif (mrt, skb->dev);
@@ -2536,7 +2550,7 @@ static int ipmr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp = tb[RTA_DST ] ?nla_get_in_addr (tb[RTA_DST ]) :0 ; tableid = tb[RTA_TABLE ] ?nla_get_u32 (tb[RTA_TABLE ]) :0 ; - mrt =ipmr_get_table (net, tableid ? tableid :RT_TABLE_DEFAULT ); + mrt =__ipmr_get_table (net, tableid ? tableid :RT_TABLE_DEFAULT );if (!mrt) { err = -ENOENT ; goto errout_free;
@@ -2588,7 +2602,7 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)if (filter.table_id) {struct mr_table *mrt; - mrt =ipmr_get_table (sock_net (skb->sk), filter.table_id); + mrt =__ipmr_get_table (sock_net (skb->sk), filter.table_id);if (!mrt) {if (rtnl_msg_family (cb->nlh) !=RTNL_FAMILY_IPMR )return skb->len;
@@ -2696,7 +2710,7 @@ static int rtm_to_ipmr_mfcc(struct net *net, struct nlmsghdr *nlh,break ; } } - mrt =ipmr_get_table (net, tblid); + mrt =__ipmr_get_table (net, tblid);if (!mrt) { ret = -ENOENT ; goto out;
@@ -2904,13 +2918,15 @@ static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)struct net *net =seq_file_net (seq);struct mr_table *mrt; - mrt =ipmr_get_table (net,RT_TABLE_DEFAULT ); -if (!mrt) +rcu_read_lock (); + mrt =__ipmr_get_table (net,RT_TABLE_DEFAULT ); +if (!mrt) { +rcu_read_unlock ();return ERR_PTR (-ENOENT ); + } iter->mrt = mrt; -rcu_read_lock ();return mr_vif_seq_start (seq, pos); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 326/772 iio: light: al3010: Fix an error handling path in al3010_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit a4b7064d34186cf4970fe0333c3b27346cf8f819 ]
If i2c_smbus_write_byte_data() fails in al3010_init(), al3010_set_pwr(false) is not called.
In order to avoid such a situation, move the devm_add_action_or_reset() witch calls al3010_set_pwr(false) right after a successful al3010_set_pwr(true).
--- drivers/iio/light/al3010.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/light/al3010.c +5 -6
@@ -87,7 +87,12 @@ static int al3010_init(struct al3010_data *data)int ret; ret =al3010_set_pwr (data->client, true); +if (ret <0 ) +return ret; + ret =devm_add_action_or_reset (&data->client->dev, + al3010_set_pwr_off, + data);if (ret <0 )return ret;
@@ -191,12 +196,6 @@ static int al3010_probe(struct i2c_client *client,return ret; } - ret =devm_add_action_or_reset (&client->dev, - al3010_set_pwr_off, - data); -if (ret <0 ) -return ret; -return devm_iio_device_register (&client->dev, indio_dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 327/772 usb: using mutex lock and supporting O_NONBLOCK flag in iowarrior_read()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
[ Upstream commit 44feafbaa66ec86232b123bb8437a6a262442025 ]
iowarrior_read() uses the iowarrior dev structure, but does not use any lock on the structure. This can cause various bugs including data-races, so it is more appropriate to use a mutex lock to safely protect the iowarrior dev structure. When using a mutex lock, you should split the branch to prevent blocking when the O_NONBLOCK flag is set.
In addition, it is unnecessary to check for NULL on the iowarrior dev structure obtained by reading file->private_data. Therefore, it is better to remove the check.
--- drivers/usb/misc/iowarrior.c | 46 ++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 10 deletions(-)
drivers/usb/misc/iowarrior.c +36 -10
@@ -277,28 +277,45 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,struct iowarrior *dev;int read_idx;int offset; +int retval; dev = file->private_data; +if (file->f_flags &O_NONBLOCK ) { + retval =mutex_trylock (&dev->mutex); +if (!retval) +return -EAGAIN ; + }else { + retval =mutex_lock_interruptible (&dev->mutex); +if (retval) +return -ERESTARTSYS ; + } +/* verify that the device wasn't unplugged */ -if (!dev || !dev->present) -return -ENODEV ; +if (!dev->present) { + retval = -ENODEV ; + 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 ))) -return -EINVAL ; + && (count != (dev->report_size +1 ))) { + retval = -EINVAL ; + goto exit; + }/* repeat until no buffer overrun in callback handler occur */ do { atomic_set(&dev->overflow_flag, 0); if ((read_idx = read_index(dev)) == -1) { /* queue empty */ - if (file->f_flags & O_NONBLOCK) - return -EAGAIN; + if (file->f_flags & O_NONBLOCK) { + retval = -EAGAIN; + goto exit; + } else { //next line will return when there is either new data, or the device is unplugged int r = wait_event_interruptible(dev->read_wait,
@@ -309,28 +326,37 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer, -1));if (r) {//we were interrupted by a signal -return -ERESTART ; + retval = -ERESTART ; + goto exit; }if (!dev->present) {//The device was unplugged -return -ENODEV ; + retval = -ENODEV ; + goto exit; }if (read_idx ==-1 ) {// Can this happen ??? -return 0 ; + retval =0 ; + goto exit; } } } offset = read_idx * (dev->report_size +1 );if (copy_to_user (buffer, dev->read_queue + offset, count)) { -return -EFAULT ; + retval = -EFAULT ; + goto exit; } }while (atomic_read (&dev->overflow_flag)); read_idx = ++read_idx ==MAX_INTERRUPT_BUFFER ?0 : read_idx;atomic_set (&dev->read_idx, read_idx); +mutex_unlock (&dev->mutex);return count; + +exit: +mutex_unlock (&dev->mutex); +return retval; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 328/772 usb: yurex: make waiting on yurex_write interruptible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit e0aa9614ab0fd35b404e4b16ebe879f9fc152591 ]
The IO yurex_write() needs to wait for in order to have a device ready for writing again can take a long time time. Consequently the sleep is done in an interruptible state. Therefore others waiting for yurex_write() itself to finish should use mutex_lock_interruptible.
Rule: add
--- drivers/usb/misc/iowarrior.c | 4 ---- drivers/usb/misc/yurex.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/usb/misc/iowarrior.c +0 -4
@@ -912,7 +912,6 @@ static int iowarrior_probe(struct usb_interface *interface,static void iowarrior_disconnect (struct usb_interface *interface) {struct iowarrior *dev =usb_get_intfdata (interface); -int minor = dev->minor;usb_deregister_dev (interface, &iowarrior_class);
@@ -936,9 +935,6 @@ static void iowarrior_disconnect(struct usb_interface *interface)mutex_unlock (&dev->mutex);iowarrior_delete (dev); } - -dev_info (&interface->dev,"I/O-Warror #%d now disconnected\n" , - minor -IOWARRIOR_MINOR_BASE ); }/* usb specific object needed to register this driver with the usb subsystem */
drivers/usb/misc/yurex.c +4 -1
@@ -441,7 +441,10 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,if (count ==0 ) goto error; -mutex_lock (&dev->io_mutex); + retval =mutex_lock_interruptible (&dev->io_mutex); +if (retval <0 ) +return -EINTR ; +if (dev->disconnected) {/* already disconnected */ mutex_unlock (&dev->io_mutex); retval = -ENODEV ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 329/772 USB: chaoskey: fail open after removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 422dc0a4d12d0b80dd3aab3fe5943f665ba8f041 ]
chaoskey_open() takes the lock only to increase the counter of openings. That means that the mutual exclusion with chaoskey_disconnect() cannot prevent an increase of the counter and chaoskey_open() returning a success.
If that race is hit, chaoskey_disconnect() will happily free all resources associated with the device after it has dropped the lock, as it has read the counter as zero.
To prevent this race chaoskey_open() has to check the presence of the device under the lock. However, the current per device lock cannot be used, because it is a part of the data structure to be freed. Hence an additional global mutex is needed. The issue is as old as the driver.
Rule: add
--- drivers/usb/misc/chaoskey.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/usb/misc/chaoskey.c +24 -11
@@ -27,6 +27,8 @@ static struct usb_class_driver chaoskey_class;static int chaoskey_rng_read (struct hwrng *rng,void *data,size_t max,bool wait); +static DEFINE_MUTEX (chaoskey_list_lock); + #define usb_dbg(usb_if, format, arg...) \ dev_dbg(&(usb_if)->dev, format, ## arg)
@@ -231,6 +233,7 @@ static void chaoskey_disconnect(struct usb_interface *interface)if (dev->hwrng_registered)hwrng_unregister (&dev->hwrng); +mutex_lock (&chaoskey_list_lock);usb_deregister_dev (interface, &chaoskey_class);usb_set_intfdata (interface,NULL );
@@ -245,6 +248,7 @@ static void chaoskey_disconnect(struct usb_interface *interface) }else mutex_unlock (&dev->lock); +mutex_unlock (&chaoskey_list_lock);usb_dbg (interface,"disconnect done" ); }
@@ -252,6 +256,7 @@ static int chaoskey_open(struct inode *inode, struct file *file) {struct chaoskey *dev;struct usb_interface *interface; +int rv =0 ;/* get the interface from minor number and driver information */ interface =usb_find_interface (&chaoskey_driver,iminor (inode));
@@ -267,18 +272,23 @@ static int chaoskey_open(struct inode *inode, struct file *file) } file->private_data = dev; +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock); - ++dev->open; +if (dev->present) + ++dev->open; +else + rv = -ENODEV ;mutex_unlock (&dev->lock); +mutex_unlock (&chaoskey_list_lock); -usb_dbg (interface,"open success" ); -return 0 ; +return rv; }static int chaoskey_release (struct inode *inode,struct file *file) {struct chaoskey *dev = file->private_data;struct usb_interface *interface; +int rv =0 ;if (dev ==NULL )return -ENODEV ;
@@ -287,14 +297,15 @@ static int chaoskey_release(struct inode *inode, struct file *file)usb_dbg (interface,"release" ); +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock);usb_dbg (interface,"open count at release is %d" , dev->open);if (dev->open <=0 ) {usb_dbg (interface,"invalid open count (%d)" , dev->open); -mutex_unlock (&dev->lock); -return -ENODEV ; + rv = -ENODEV ; + goto bail; } --dev->open;
@@ -303,13 +314,15 @@ static int chaoskey_release(struct inode *inode, struct file *file)if (dev->open ==0 ) {mutex_unlock (&dev->lock);chaoskey_free (dev); - }else -mutex_unlock (&dev->lock); - }else -mutex_unlock (&dev->lock); - + goto destruction; + } + } +bail: +mutex_unlock (&dev->lock); +destruction: +mutex_lock (&chaoskey_list_lock);usb_dbg (interface,"release success" ); -return 0 ; +return rv; }static void chaos_read_callback (struct urb *urb)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 330/772 USB: chaoskey: Fix possible deadlock chaoskey_list_lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit d73dc7b182be4238b75278bfae16afb4c5564a58 ]
[Syzbot reported two possible deadlocks]
The first possible deadlock is:
WARNING: possible recursive locking detected
6.12.0-rc1-syzkaller-00027-g4a9fe2a8ac53 #0 Not tainted
--------------------------------------------
syz-executor363/2651 is trying to acquire lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_release+0x15d/0x2c0 drivers/usb/misc/chaoskey.c:322
but task is already holding lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_release+0x7f/0x2c0 drivers/usb/misc/chaoskey.c:299
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(chaoskey_list_lock);
lock(chaoskey_list_lock);
*** DEADLOCK ***
The second possible deadlock is:
WARNING: possible circular locking dependency detected 6.12.0-rc1-syzkaller-00027-g4a9fe2a8ac53 #0 Not tainted
------------------------------------------------------
kworker/0:2/804 is trying to acquire lock:ffffffff899dadb0 (minor_rwsem){++++}-{3:3}, at: usb_deregister_dev+0x7c/0x1e0 drivers/usb/core/file.c:186
but task is already holding lock:ffffffff89b120e8 (chaoskey_list_lock){+.+.}-{3:3}, at: chaoskey_disconnect+0xa8/0x2a0 drivers/usb/misc/chaoskey.c:235
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (chaoskey_list_lock){+.+.}-{3:3}:
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x175/0x9c0 kernel/locking/mutex.c:752
chaoskey_open+0xdd/0x220 drivers/usb/misc/chaoskey.c:274
usb_open+0x186/0x220 drivers/usb/core/file.c:47
chrdev_open+0x237/0x6a0 fs/char_dev.c:414
do_dentry_open+0x6cb/0x1390 fs/open.c:958
vfs_open+0x82/0x3f0 fs/open.c:1088
do_open fs/namei.c:3774 [inline]
path_openat+0x1e6a/0x2d60 fs/namei.c:3933
do_filp_open+0x1dc/0x430 fs/namei.c:3960
do_sys_openat2+0x17a/0x1e0 fs/open.c:1415
do_sys_open fs/open.c:1430 [inline]
__do_sys_openat fs/open.c:1446 [inline]
__se_sys_openat fs/open.c:1441 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1441
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f-> #0 (minor_rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3161 [inline]
check_prevs_add kernel/locking/lockdep.c:3280 [inline]
validate_chain kernel/locking/lockdep.c:3904 [inline]
__lock_acquire+0x250b/0x3ce0 kernel/locking/lockdep.c:5202
lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825
down_write+0x93/0x200 kernel/locking/rwsem.c:1577
usb_deregister_dev+0x7c/0x1e0 drivers/usb/core/file.c:186
chaoskey_disconnect+0xb7/0x2a0 drivers/usb/misc/chaoskey.c:236
usb_unbind_interface+0x1e8/0x970 drivers/usb/core/driver.c:461
device_remove drivers/base/dd.c:569 [inline]
device_remove+0x122/0x170 drivers/base/dd.c:561
__device_release_driver drivers/base/dd.c:1273 [inline]
device_release_driver_internal+0x44a/0x610 drivers/base/dd.c:1296
bus_remove_device+0x22f/0x420 drivers/base/bus.c:576
device_del+0x396/0x9f0 drivers/base/core.c:3864
usb_disable_device+0x36c/0x7f0 drivers/usb/core/message.c:1418
usb_disconnect+0x2e1/0x920 drivers/usb/core/hub.c:2304
hub_port_connect drivers/usb/core/hub.c:5361 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5661 [inline]
port_event drivers/usb/core/hub.c:5821 [inline]
hub_event+0x1bed/0x4f40 drivers/usb/core/hub.c:5903
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3229
process_scheduled_works kernel/workqueue.c:3310 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391
kthread+0x2c1/0x3a0 kernel/kthread.c:389
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(chaoskey_list_lock);
lock(minor_rwsem);
lock(chaoskey_list_lock); lock(minor_rwsem);
*** DEADLOCK ***
[Analysis]
The first is AA lock, it because wrong logic, it need a unlock. The second is AB lock, it needs to rearrange the order of lock usage.
--- drivers/usb/misc/chaoskey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/misc/chaoskey.c +2 -2
@@ -233,10 +233,10 @@ static void chaoskey_disconnect(struct usb_interface *interface)if (dev->hwrng_registered)hwrng_unregister (&dev->hwrng); -mutex_lock (&chaoskey_list_lock);usb_deregister_dev (interface, &chaoskey_class);usb_set_intfdata (interface,NULL ); +mutex_lock (&chaoskey_list_lock);mutex_lock (&dev->lock); dev->present = false;
@@ -320,7 +320,7 @@ static int chaoskey_release(struct inode *inode, struct file *file) bail:mutex_unlock (&dev->lock); destruction: -mutex_lock (&chaoskey_list_lock); +mutex_unlock (&chaoskey_list_lock);usb_dbg (interface,"release success" );return rv; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 331/772 misc: apds990x: Fix missing pm_runtime_disable()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit 3c5d8b819d27012264edd17e6ae7fffda382fe44 ]
The pm_runtime_disable() is missing in probe error path, so add it to fix it.
--- drivers/misc/apds990x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/misc/apds990x.c +7 -5
@@ -1148,7 +1148,7 @@ static int apds990x_probe(struct i2c_client *client, err = chip->pdata->setup_resources ();if (err) { err = -EINVAL ; - goto fail3; + goto fail4; } }
@@ -1156,7 +1156,7 @@ static int apds990x_probe(struct i2c_client *client, apds990x_attribute_group);if (err <0 ) {dev_err (&chip->client->dev,"Sysfs registration failed\n" ); - goto fail4; + goto fail5; } err = request_threaded_irq(client->irq, NULL,
@@ -1167,15 +1167,17 @@ static int apds990x_probe(struct i2c_client *client,if (err) {dev_err (&client->dev,"could not get IRQ %d\n" , client->irq); - goto fail5; + goto fail6; }return err; -fail5: +fail6:sysfs_remove_group (&chip->client->dev.kobj, &apds990x_attribute_group[0 ]); -fail4: +fail5:if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources (); +fail4: +pm_runtime_disable (&client->dev); fail3:regulator_bulk_disable (ARRAY_SIZE (chip->regs), chip->regs); fail2:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 332/772 counter: stm32-timer-cnt: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 842c3755a6bfbfcafa4a1438078d2485a9eb1d87 ]
Add check for the return value of clk_enable() in order to catch the potential exception.
--- drivers/counter/stm32-timer-cnt.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/counter/stm32-timer-cnt.c +13 -3
@@ -195,11 +195,17 @@ static int stm32_count_enable_write(struct counter_device *counter, {struct stm32_timer_cnt *const priv =counter_priv (counter);u32 cr1; +int ret;if (enable) {regmap_read (priv->regmap,TIM_CR1 , &cr1); -if (!(cr1 &TIM_CR1_CEN )) -clk_enable (priv->clk); +if (!(cr1 &TIM_CR1_CEN )) { + ret =clk_enable (priv->clk); +if (ret) { +dev_err (counter->parent,"Cannot enable clock %d\n" , ret); +return ret; + } + }regmap_update_bits (priv->regmap,TIM_CR1 ,TIM_CR1_CEN ,TIM_CR1_CEN );
@@ -380,7 +386,11 @@ static int __maybe_unused stm32_timer_cnt_resume(struct device *dev)return ret;if (priv->enabled) { -clk_enable (priv->clk); + ret =clk_enable (priv->clk); +if (ret) { +dev_err (dev,"Cannot enable clock %d\n" , ret); +return ret; + }/* Restore registers that may have been lost */ regmap_write (priv->regmap,TIM_SMCR , priv->bak.smcr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 333/772 counter: ti-ecap-capture: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 1437d9f1c56fce9c24e566508bce1d218dd5497a ]
Add check for the return value of clk_enable() in order to catch the potential exception.
--- drivers/counter/ti-ecap-capture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/counter/ti-ecap-capture.c +6 -1
@@ -576,8 +576,13 @@ static int ecap_cnt_resume(struct device *dev) {struct counter_device *counter_dev =dev_get_drvdata (dev);struct ecap_cnt_dev *ecap_dev =counter_priv (counter_dev); +int ret; -clk_enable (ecap_dev->clk); + ret =clk_enable (ecap_dev->clk); +if (ret) { +dev_err (dev,"Cannot enable clock %d\n" , ret); +return ret; + }ecap_cnt_capture_set_evmode (counter_dev, ecap_dev->pm_ctx.ev_mode);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 334/772 ALSA: hda/realtek: Update ALC256 depop procedure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
[ Upstream commit cc3d0b5dd989d3238d456f9fd385946379a9c13d ]
Old procedure has a chance to meet Headphone no output.
--- sound/pci/hda/patch_realtek.c | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
sound/pci/hda/patch_realtek.c +19 -23
@@ -3599,25 +3599,22 @@ static void alc256_init(struct hda_codec *codec) hp_pin_sense =snd_hda_jack_detect (codec, hp_pin); -if (hp_pin_sense) +if (hp_pin_sense) {msleep (2 ); +alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ -alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ - -snd_hda_codec_write (codec, hp_pin,0 , -AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_MUTE ); - -if (hp_pin_sense || spec->ultra_low_power) -msleep (85 ); - -snd_hda_codec_write (codec, hp_pin,0 , +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,PIN_OUT ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (100 ); +msleep (75 ); + +snd_hda_codec_write (codec, hp_pin,0 , +AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_UNMUTE ); +msleep (75 ); +alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x4 );/* Hight power */ + }alc_update_coef_idx (codec,0x46 ,3 <<12 ,0 ); -alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x4 );/* Hight power */ alc_update_coefex_idx (codec,0x53 ,0x02 ,0x8000 ,1 <<15 );/* Clear bit */ alc_update_coefex_idx (codec,0x53 ,0x02 ,0x8000 ,0 <<15 );/*
@@ -3641,29 +3638,28 @@ static void alc256_shutup(struct hda_codec *codec)alc_update_coefex_idx (codec,0x57 ,0x04 ,0x0007 ,0x1 );/* Low power */ hp_pin_sense =snd_hda_jack_detect (codec, hp_pin); -if (hp_pin_sense) +if (hp_pin_sense) {msleep (2 ); -snd_hda_codec_write (codec, hp_pin,0 , +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_AMP_GAIN_MUTE ,AMP_OUT_MUTE ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (85 ); +msleep (75 );/* 3k pull low control for Headset jack. */ /* NOTE: call this before clearing the pin, otherwise codec stalls */ /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly * when booting with headset plugged. So skip setting it for the codec alc257 */ -if (spec->en_3kpull_low) -alc_update_coef_idx (codec,0x46 ,0 ,3 <<12 ); +if (spec->en_3kpull_low) +alc_update_coef_idx (codec,0x46 ,0 ,3 <<12 ); -if (!spec->no_shutup_pins) -snd_hda_codec_write (codec, hp_pin,0 , +if (!spec->no_shutup_pins) +snd_hda_codec_write (codec, hp_pin,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x0 ); -if (hp_pin_sense || spec->ultra_low_power) -msleep (100 ); +msleep (75 ); + }alc_auto_setup_eapd (codec, false);alc_shutup_pins (codec);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 335/772 apparmor: fix Do simple duplicate message elimination
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: chao liu <[email protected]>
[ Upstream commit 9b897132424fe76bf6c61f22f9cf12af7f1d1e6a ]
Multiple profiles shared 'ent->caps', so some logs missed.
--- security/apparmor/capability.c | 2 ++ 1 file changed, 2 insertions(+)
security/apparmor/capability.c +2 -0
@@ -94,6 +94,8 @@ static int audit_caps(struct common_audit_data *sa, struct aa_profile *profile,return error; }else {aa_put_profile (ent->profile); +if (profile != ent->profile) +cap_clear (ent->caps); ent->profile =aa_get_profile (profile);cap_raise (ent->caps, cap); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 336/772 ASoC: amd: yc: Fix for enabling DMIC on acp6x via _DSD entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Venkata Prasad Potturu <[email protected]>
[ Upstream commit 4095cf872084ecfdfdb0e681f3e9ff9745acfa75 ]
Add condition check to register ACP PDM sound card by reading _WOV acpi entry.
--- sound/soc/amd/yc/acp6x-mach.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
sound/soc/amd/yc/acp6x-mach.c +17 -1
@@ -439,8 +439,14 @@ static int acp6x_probe(struct platform_device *pdev)struct acp6x_pdm *machine =NULL ;struct snd_soc_card *card;struct acpi_device *adev; +acpi_handle handle; +acpi_integer dmic_status;int ret; +bool is_dmic_enable, wov_en; +/* IF WOV entry not found, enable dmic based on AcpDmicConnected entry*/ + is_dmic_enable = false; + wov_en = true;/* check the parent device's firmware node has _DSD or not */ adev =ACPI_COMPANION (pdev->dev.parent);if (adev) {
@@ -448,9 +454,19 @@ static int acp6x_probe(struct platform_device *pdev)if (!acpi_dev_get_property (adev,"AcpDmicConnected" ,ACPI_TYPE_INTEGER , &obj) && obj->integer.value ==1 ) -platform_set_drvdata (pdev, &acp6x_card); + is_dmic_enable = true; } + handle =ACPI_HANDLE (pdev->dev.parent); + ret =acpi_evaluate_integer (handle,"_WOV" ,NULL , &dmic_status); +if (!ACPI_FAILURE (ret)) + wov_en = dmic_status; + +if (is_dmic_enable && wov_en) +platform_set_drvdata (pdev, &acp6x_card); +else +return 0 ; +/* check for any DMI overrides */ dmi_id =dmi_first_match (yc_acp_quirk_table);if (dmi_id)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 337/772 mailbox: mtk-cmdq: Move devm_mbox_controller_register() after devm_pm_runtime_enable()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason-JH.Lin <[email protected]>
commit a8bd68e4329f9a0ad1b878733e0f80be6a971649 upstream.
When mtk-cmdq unbinds, a WARN_ON message with condition pm_runtime_get_sync() < 0 occurs.
According to the call tracei below:
cmdq_mbox_shutdown
mbox_free_channel
mbox_controller_unregister
__devm_mbox_controller_unregister
...
The root cause can be deduced to be calling pm_runtime_get_sync() after calling pm_runtime_disable() as observed below:
1. CMDQ driver uses devm_mbox_controller_register() in cmdq_probe() to bind the cmdq device to the mbox_controller, so devm_mbox_controller_unregister() will automatically unregister the device bound to the mailbox controller when the device-managed resource is removed. That means devm_mbox_controller_unregister() and cmdq_mbox_shoutdown() will be called after cmdq_remove().
2. CMDQ driver also uses devm_pm_runtime_enable() in cmdq_probe() after devm_mbox_controller_register(), so that devm_pm_runtime_disable() will be called after cmdq_remove(), but before devm_mbox_controller_unregister().
To fix this problem, cmdq_probe() needs to move devm_mbox_controller_register() after devm_pm_runtime_enable() to make devm_pm_runtime_disable() be called after devm_mbox_controller_unregister().
--- drivers/mailbox/mtk-cmdq-mailbox.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +6 -6
@@ -605,18 +605,18 @@ static int cmdq_probe(struct platform_de cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i]; } - err =devm_mbox_controller_register (dev, &cmdq->mbox); -if (err <0 ) { -dev_err (dev,"failed to register mailbox: %d\n" , err); -return err; - } -platform_set_drvdata (pdev, cmdq);WARN_ON (clk_bulk_prepare (cmdq->gce_num, cmdq->clocks));cmdq_init (cmdq); + err =devm_mbox_controller_register (dev, &cmdq->mbox); +if (err <0 ) { +dev_err (dev,"failed to register mailbox: %d\n" , err); +return err; + } +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 338/772 fs/ntfs3: Fixed overflow check in mi_enum_attr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
commit 652cfeb43d6b9aba5c7c4902bed7a7340df131fb upstream.
--- fs/ntfs3/record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/record.c +1 -1
@@ -273,7 +273,7 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (t16 > asize)return NULL ; -if (t16 +le32_to_cpu (attr->res.data_size) > asize) +if (le32_to_cpu (attr->res.data_size) > asize - t16)return NULL ; if (attr->name_len &&
Greg Kroah-Hartman
maintainerPATCH 339/772 ntfs3: Add bounds checking to mi_enum_attr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: lei lu <[email protected]>
commit 556bdf27c2dd5c74a9caacbe524b943a6cd42d99 upstream.
Added bounds checking to make sure that every attr don't stray beyond valid memory region.
--- fs/ntfs3/record.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
fs/ntfs3/record.c +10 -13
@@ -217,28 +217,19 @@ struct ATTRIB *mi_enum_attr(struct mft_i prev_type =0 ; attr =Add2Ptr (rec, off); }else { -/* Check if input attr inside record. */ +/* +* We don't need to check previous attr here. There is +* a bounds checking in the previous round. +*/ off =PtrOffset (rec, attr); -if (off >= used) -return NULL ; asize =le32_to_cpu (attr->size); -if (asize <SIZEOF_RESIDENT ) { -/* Impossible 'cause we should not return such attribute. */ -return NULL ; - } - -/* Overflow check. */ -if (off + asize < off) -return NULL ; prev_type =le32_to_cpu (attr->type); attr =Add2Ptr (attr, asize); off += asize; } - asize =le32_to_cpu (attr->size); -/* Can we use the first field (attr->type). */ if (off +8 > used) {static_assert (ALIGN (sizeof (enum ATTR_TYPE ),8 ) ==8 );
@@ -259,6 +250,12 @@ struct ATTRIB *mi_enum_attr(struct mft_iif (t32 < prev_type)return NULL ; + asize =le32_to_cpu (attr->size); +if (asize <SIZEOF_RESIDENT ) { +/* Impossible 'cause we should not return such attribute. */ +return NULL ; + } +/* Check overflow and boundary. */ if (off + asize < off || off + asize > used)return NULL ;
Greg Kroah-Hartman
maintainerPATCH 340/772 scsi: lpfc: Validate hdwq pointers before dereferencing in reset/errata paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
commit 2be1d4f11944cd6283cb97268b3e17c4424945ca upstream.
When the HBA is undergoing a reset or is handling an errata event, NULL ptr dereference crashes may occur in routines such as lpfc_sli_flush_io_rings(), lpfc_dev_loss_tmo_callbk(), or lpfc_abort_handler().
Add NULL ptr checks before dereferencing hdwq pointers that may have been freed due to operations colliding with a reset or errata event handler.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 3 ++- drivers/scsi/lpfc/lpfc_scsi.c | 13 +++++++++++-- drivers/scsi/lpfc/lpfc_sli.c | 11 +++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -1
@@ -177,7 +177,8 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport/* Don't schedule a worker thread event if the vport is going down. * The teardown process cleans up the node via lpfc_drop_node. */ -if (vport->load_flag &FC_UNLOADING ) { +if ((vport->load_flag &FC_UNLOADING ) || + !(phba->hba_flag &HBA_SETUP )) { ((struct lpfc_rport_data *)rport->dd_data)->pnode =NULL ; ndlp->rport =NULL ;
drivers/scsi/lpfc/lpfc_scsi.c +11 -2
@@ -5554,11 +5554,20 @@ lpfc_abort_handler(struct scsi_cmnd *cmn iocb = &lpfc_cmd->cur_iocbq;if (phba->sli_rev ==LPFC_SLI_REV4 ) { - pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring; -if (!pring_s4) { +/* if the io_wq & pring are gone, the port was reset. */ +if (!phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq || + !phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring) { +lpfc_printf_vlog (vport,KERN_WARNING ,LOG_FCP , +"2877 SCSI Layer I/O Abort Request " +"IO CMPL Status x%x ID %d LUN %llu " +"HBA_SETUP %d\n" ,FAILED , + cmnd->device->id, + (u64 )cmnd->device->lun, + (HBA_SETUP & phba->hba_flag)); ret =FAILED ; goto out_unlock_hba; } + pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;spin_lock (&pring_s4->ring_lock); }/* the command is in process of being cancelled */
drivers/scsi/lpfc/lpfc_sli.c +11 -0
@@ -4668,6 +4668,17 @@ lpfc_sli_flush_io_rings(struct lpfc_hba/* Look on all the FCP Rings for the iotag */ if (phba->sli_rev >=LPFC_SLI_REV4 ) {for (i =0 ; i < phba->cfg_hdw_queue; i++) { +if (!phba->sli4_hba.hdwq || + !phba->sli4_hba.hdwq[i].io_wq) { +lpfc_printf_log (phba,KERN_ERR ,LOG_SLI , +"7777 hdwq's deleted %lx " +"%lx %x %x\n" , + (unsigned long )phba->pport->load_flag, + (unsigned long )phba->hba_flag, + phba->link_state, + phba->sli.sli_flag); +return ; + } pring = phba->sli4_hba.hdwq[i].io_wq->pring;spin_lock_irq (&pring->ring_lock);
Greg Kroah-Hartman
maintainerPATCH 341/772 xfs: add bounds checking to xlog_recover_process_data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: lei lu <[email protected]>
commit fb63435b7c7dc112b1ae1baea5486e0a6e27b196 upstream.
There is a lack of verification of the space occupied by fixed members of xlog_op_header in the xlog_recover_process_data.
We can create a crafted image to trigger an out of bounds read by following these steps:
1) Mount an image of xfs, and do some file operations to leave records
2) Before umounting, copy the image for subsequent steps to simulate abnormal exit. Because umount will ensure that tail_blk and head_blk are the same, which will result in the inability to enter xlog_recover_process_data
3) Write a tool to parse and modify the copied image in step 2
4) Make the end of the xlog_op_header entries only 1 byte away from xlog_rec_header->h_size
5) xlog_rec_header->h_num_logops++
6) Modify xlog_rec_header->h_crc
Fix:
Add a check to make sure there is sufficient space to access fixed members of xlog_op_header.
--- fs/xfs/xfs_log_recover.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/xfs_log_recover.c +4 -1
@@ -2439,7 +2439,10 @@ xlog_recover_process_data( ohead = (struct xlog_op_header *)dp; dp +=sizeof (*ohead); -ASSERT (dp <= end); +if (dp > end) { +xfs_warn (log->l_mp,"%s: op header overrun" , __func__); +return -EFSCORRUPTED ; + }/* errors will abort recovery */ error = xlog_recover_process_ophdr(log, rhash, rhead, ohead,
Greg Kroah-Hartman
maintainerPATCH 342/772 xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiu-ji Chen <[email protected]>
commit afc545da381ba0c651b2658966ac737032676f01 upstream.
This patch fixes an issue in the function xenbus_dev_probe(). In the xenbus_dev_probe() function, within the if (err) branch at line 313, the program incorrectly returns err directly without releasing the resources allocated by err = drv->probe(dev, id). As the return value is non-zero, the upper layers assume the processing logic has failed. However, the probe operation was performed earlier without a corresponding remove operation. Since the probe actually allocates resources, failing to perform the remove operation could lead to problems.
To fix this issue, we followed the resource release logic of the xenbus_dev_remove() function by adding a new block fail_remove before the fail_put block. After entering the branch if (err) at line 313, the function will use a goto statement to jump to the fail_remove block, ensuring that the previously acquired resources are correctly released, thus preventing the reference count leak.
This bug was identified by an experimental static analysis tool developed by our team. The tool specializes in analyzing reference count operations and detecting potential issues where resources are not properly managed. In this case, the tool flagged the missing release operation as a potential problem, which led to the development of this patch.
Message-ID: <[email protected]>
--- drivers/xen/xenbus/xenbus_probe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/xen/xenbus/xenbus_probe.c +7 -1
@@ -313,7 +313,7 @@ int xenbus_dev_probe(struct device *_devif (err) {dev_warn (&dev->dev,"watch_otherend on %s failed.\n" , dev->nodename); -return err; + goto fail_remove; } dev->spurious_threshold =1 ;
@@ -322,6 +322,12 @@ int xenbus_dev_probe(struct device *_dev dev->nodename);return 0 ; +fail_remove: +if (drv->remove) { +down (&dev->reclaim_sem); + drv->remove (dev); +up (&dev->reclaim_sem); + } fail_put:module_put (drv->driver.owner); fail:
Greg Kroah-Hartman
maintainerPATCH 343/772 ALSA: usb-audio: Fix out of bounds reads when finding clock sources
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit a3dd4d63eeb452cfb064a13862fb376ab108f6a6 upstream.
The current USB-audio driver code doesn't check bLength of each descriptor at traversing for clock descriptors. That is, when a device provides a bogus descriptor with a shorter bLength, the driver might hit out-of-bounds reads.
For addressing it, this patch adds sanity checks to the validator functions for the clock descriptor traversal. When the descriptor length is shorter than expected, it's skipped in the loop.
For the clock source and clock multiplier descriptors, we can just check bLength against the sizeof() of each descriptor type. OTOH, the clock selector descriptor of UAC2 and UAC3 has an array of bNrInPins elements and two more fields at its tail, hence those have to be checked in addition to the sizeof() check.
--- sound/usb/clock.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
sound/usb/clock.c +23 -1
@@ -36,6 +36,12 @@ union uac23_clock_multiplier_desc {struct uac_clock_multiplier_descriptor v3; }; +/* check whether the descriptor bLength has the minimal length */ +#define DESC_LENGTH_CHECK (p, proto) \ + ((proto) == UAC_VERSION_3 ? \ + ((p)->v3.bLength >= sizeof((p)->v3)) : \ + ((p)->v2.bLength >= sizeof((p)->v2))) +#define GET_VAL (p, proto, field) \ ((proto) == UAC_VERSION_3 ? (p)->v3.field : (p)->v2.field)
@@ -58,6 +64,8 @@ static bool validate_clock_source(void * {union uac23_clock_source_desc *cs = p; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false;return GET_VAL (cs, proto, bClockID) == id; }
@@ -65,13 +73,27 @@ static bool validate_clock_selector(void {union uac23_clock_selector_desc *cs = p; -return GET_VAL (cs, proto, bClockID) == id; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false; +if (GET_VAL (cs, proto, bClockID) != id) +return false; +/* additional length check for baCSourceID array (in bNrInPins size) +* and two more fields (which sizes depend on the protocol) +*/ +if (proto ==UAC_VERSION_3 ) +return cs->v3.bLength >=sizeof (cs->v3) + cs->v3.bNrInPins + +4 /* bmControls */ +2 /* wCSelectorDescrStr */ ; +else +return cs->v2.bLength >=sizeof (cs->v2) + cs->v2.bNrInPins + +1 /* bmControls */ +1 /* iClockSelector */ ; }static bool validate_clock_multiplier (void *p,int id,int proto) {union uac23_clock_multiplier_desc *cs = p; +if (!DESC_LENGTH_CHECK (cs, proto)) +return false;return GET_VAL (cs, proto, bClockID) == id; }
Greg Kroah-Hartman
maintainerPATCH 344/772 usb: ehci-spear: fix call balance of sehci clk handling routines
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitalii Mordan <[email protected]>
commit 40c974826734836402abfd44efbf04f63a2cc1c1 upstream.
If the clock sehci->clk was not enabled in spear_ehci_hcd_drv_probe, it should not be disabled in any path.
Conversely, if it was enabled in spear_ehci_hcd_drv_probe, it must be disabled in all error paths to ensure proper cleanup.
Found by Linux Verification Center (linuxtesting.org) with Klever.
--- drivers/usb/host/ehci-spear.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/host/ehci-spear.c +4 -3
@@ -106,7 +106,9 @@ static int spear_ehci_hcd_drv_probe(stru/* registers start at offset 0x0 */ hcd_to_ehci (hcd)->caps = hcd->regs; -clk_prepare_enable (sehci->clk); + retval =clk_prepare_enable (sehci->clk); +if (retval) + goto err_put_hcd; retval =usb_add_hcd (hcd, irq,IRQF_SHARED );if (retval) goto err_stop_ehci;
@@ -131,8 +133,7 @@ static int spear_ehci_hcd_drv_remove(strusb_remove_hcd (hcd); -if (sehci->clk) -clk_disable_unprepare (sehci->clk); +clk_disable_unprepare (sehci->clk);usb_put_hcd (hcd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 345/772 media: aspeed: Fix memory overwrite if timing is 1600x900
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jammy Huang <[email protected]>
commit c281355068bc258fd619c5aefd978595bede7bfe upstream.
When capturing 1600x900, system could crash when system memory usage is tight.
The way to reproduce this issue:
1. Use 1600x900 to display on host
2. Mount ISO through 'Virtual media' on OpenBMC's web
3. Run script as below on host to do sha continuously #!/bin/bash
while [ [1] ];
do
find /media -type f -printf '"%h/%f"\n' | xargs sha256sum
done
4. Open KVM on OpenBMC's web
The size of macro block captured is 8x8. Therefore, we should make sure the height of src-buf is 8 aligned to fix this issue.
--- drivers/media/platform/aspeed/aspeed-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/aspeed/aspeed-video.c +2 -2
@@ -1047,7 +1047,7 @@ static void aspeed_video_get_resolution(static void aspeed_video_set_resolution (struct aspeed_video *video) {struct v4l2_bt_timings *act = &video->active_timings; -unsigned int size = act->width * act->height; +unsigned int size = act->width *ALIGN (act->height,8 );/* Set capture/compression frame sizes */ aspeed_video_calc_compressed_size (video, size);
@@ -1064,7 +1064,7 @@ static void aspeed_video_set_resolution(u32 width =ALIGN (act->width,64 );aspeed_video_write (video,VE_CAP_WINDOW , width <<16 | act->height); - size = width * act->height; + size = width *ALIGN (act->height,8 ); }else {aspeed_video_write (video,VE_CAP_WINDOW , act->width <<16 | act->height);
Greg Kroah-Hartman
maintainerPATCH 346/772 wifi: iwlwifi: mvm: avoid NULL pointer dereference
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miri Korenblit <[email protected]>
commit 557a6cd847645e667f3b362560bd7e7c09aac284 upstream.
iwl_mvm_tx_skb_sta() and iwl_mvm_tx_mpdu() verify that the mvmvsta pointer is not NULL.
It retrieves this pointer using iwl_mvm_sta_from_mac80211, which is dereferencing the ieee80211_sta pointer.
If sta is NULL, iwl_mvm_sta_from_mac80211 will dereference a NULL pointer.
Fix this by checking the sta pointer before retrieving the mvmsta from it. If sta is not NULL, then mvmsta isn't either.
--- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +7 -5
@@ -1105,6 +1105,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvbool is_ampdu = false;int hdrlen; +if (WARN_ON_ONCE (!sta)) +return -1 ; + mvmsta =iwl_mvm_sta_from_mac80211 (sta); fc = hdr->frame_control; hdrlen =ieee80211_hdrlen (fc);
@@ -1112,9 +1115,6 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvif (IWL_MVM_NON_TRANSMITTING_AP &&ieee80211_is_probe_resp (fc))return -1 ; -if (WARN_ON_ONCE (!mvmsta)) -return -1 ; -if (WARN_ON_ONCE (mvmsta->sta_id ==IWL_MVM_INVALID_STA ))return -1 ;
@@ -1242,16 +1242,18 @@ drop:int iwl_mvm_tx_skb_sta (struct iwl_mvm *mvm,struct sk_buff *skb,struct ieee80211_sta *sta) { -struct iwl_mvm_sta *mvmsta =iwl_mvm_sta_from_mac80211 (sta); +struct iwl_mvm_sta *mvmsta;struct ieee80211_tx_info info;struct sk_buff_head mpdus_skbs;unsigned int payload_len;int ret;struct sk_buff *orig_skb = skb; -if (WARN_ON_ONCE (!mvmsta)) +if (WARN_ON_ONCE (!sta))return -1 ; + mvmsta =iwl_mvm_sta_from_mac80211 (sta); +if (WARN_ON_ONCE (mvmsta->sta_id ==IWL_MVM_INVALID_STA ))return -1 ;
Greg Kroah-Hartman
maintainerPATCH 347/772 drm/amd/display: Add NULL check for clk_mgr and clk_mgr->funcs in dcn30_init_hw
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit cba7fec864172dadd953daefdd26e01742b71a6a upstream.
This commit addresses a potential null pointer dereference issue in the dcn30_init_hw function. The issue could occur when dc->clk_mgr or dc->clk_mgr->funcs is null.
The fix adds a check to ensure dc->clk_mgr and dc->clk_mgr->funcs is not null before accessing its functions. This prevents a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:789 dcn30_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 628)
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +4 -3
@@ -448,7 +448,7 @@ void dcn30_init_hw(struct dc *dc)int edp_num;uint32_t backlight =MAX_BACKLIGHT_LEVEL ; -if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);// Initialize the dccg
@@ -631,11 +631,12 @@ void dcn30_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr);//if softmax is enabled then hardmax will be set by a different call -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->set_hard_max_memclk && + !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
Greg Kroah-Hartman
maintainerPATCH 348/772 drm/amd/display: Add NULL check for clk_mgr in dcn32_init_hw
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit c395fd47d1565bd67671f45cca281b3acc2c31ef upstream.
This commit addresses a potential null pointer dereference issue in the dcn32_init_hw function. The issue could occur when dc->clk_mgr is null.
The fix adds a check to ensure dc->clk_mgr is not null before accessing its functions. This prevents a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn32/dcn32_hwseq.c:961 dcn32_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 782)
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c +4 -3
@@ -811,7 +811,7 @@ void dcn32_init_hw(struct dc *dc)int edp_num;uint32_t backlight =MAX_BACKLIGHT_LEVEL ; -if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);// Initialize the dccg
@@ -970,10 +970,11 @@ void dcn32_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr); -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->set_hard_max_memclk && + !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
Greg Kroah-Hartman
maintainerPATCH 349/772 drm/amd/display: Add NULL check for function pointer in dcn20_set_output_transfer_func
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
commit 62ed6f0f198da04e884062264df308277628004f upstream.
This commit adds a null check for the set_output_gamma function pointer in the dcn20_set_output_transfer_func function. Previously, set_output_gamma was being checked for null at line 1030, but then it was being dereferenced without any null check at line 1048. This could potentially lead to a null pointer dereference error if set_output_gamma is null.
To fix this, we now ensure that set_output_gamma is not null before dereferencing it. We do this by adding a null check for set_output_gamma before the call to set_output_gamma at line 1048.
--- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +2 -1
@@ -856,7 +856,8 @@ bool dcn20_set_output_transfer_func(stru/* * if above if is not executed then 'params' equal to 0 and set in bypass */ - mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +if (mpc->funcs->set_output_gamma) + mpc->funcs->set_output_gamma (mpc, mpcc_id, params);return true; }
Greg Kroah-Hartman
maintainerPATCH 350/772 drm/amd/display: Check phantom_stream before it is used
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Hung <[email protected]>
commit 3718a619a8c0a53152e76bb6769b6c414e1e83f4 upstream.
dcn32_enable_phantom_stream can return null, so returned value must be checked before used.
This fixes 1 NULL_RETURNS issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c +3 -0
@@ -1796,6 +1796,9 @@ void dcn32_add_phantom_pipes(struct dc *// be a valid candidate for SubVP (i.e. has a plane, stream, doesn't // already have phantom pipe assigned, etc.) by previous checks. phantom_stream =dcn32_enable_phantom_stream (dc, context, pipes, pipe_cnt, index); +if (!phantom_stream) +return ; +dcn32_enable_phantom_plane (dc, context, phantom_stream, index);for (i =0 ; i < dc->res_pool->pipe_count; i++) {
Greg Kroah-Hartman
maintainerPATCH 351/772 rcu-tasks: Fix access non-existent percpu rtpcp variable in rcu_tasks_need_gpcb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zqiang <[email protected]>
commit fd70e9f1d85f5323096ad313ba73f5fe3d15ea41 upstream.
For kernels built with CONFIG_FORCE_NR_CPUS=y, the nr_cpu_ids is defined as NR_CPUS instead of the number of possible cpus, this will cause the following system panic:
smpboot: Allowing 4 CPUs, 0 hotplug CPUs
...setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:512 nr_node_ids:1
...
BUG: unable to handle page fault for address: ffffffff9911c8c8 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 15 Comm: rcu_tasks_trace Tainted: G W 6.6.21 #1 5dc7acf91a5e8e9ac9dcfc35bee0245691283ea6 RIP: 0010:rcu_tasks_need_gpcb+0x25d/0x2c0 RSP: 0018:ffffa371c00a3e60 EFLAGS: 00010082 CR2: ffffffff9911c8c8 CR3: 000000040fa20005 CR4: 00000000001706f0 Call Trace: <TASK> ? __die+0x23/0x80 ? page_fault_oops+0xa4/0x180 ? exc_page_fault+0x152/0x180 ? asm_exc_page_fault+0x26/0x40 ? rcu_tasks_need_gpcb+0x25d/0x2c0 ? __pfx_rcu_tasks_kthread+0x40/0x40 rcu_tasks_one_gp+0x69/0x180 rcu_tasks_kthread+0x94/0xc0 kthread+0xe8/0x140 ? __pfx_kthread+0x40/0x40 ret_from_fork+0x34/0x80 ? __pfx_kthread+0x40/0x40 ret_from_fork_asm+0x1b/0x80 </TASK>
Considering that there may be holes in the CPU numbers, use the maximum possible cpu number, instead of nr_cpu_ids, for configuring enqueue and dequeue limits.
[ neeraj.upadhyay: Fix htmldocs build error reported by Stephen Rothwell ]
--- kernel/rcu/tasks.h | 82 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 28 deletions(-)
kernel/rcu/tasks.h +54 -28
@@ -31,6 +31,7 @@ typedef void (*postgp_func_t)(struct rcu* @barrier_q_head: RCU callback for barrier operation. * @rtp_blkd_tasks: List of tasks blocked as readers. * @cpu: CPU number corresponding to this entry. +* @index: Index of this CPU in rtpcp_array of the rcu_tasks structure. * @rtpp: Pointer to the rcu_tasks structure. */ struct rcu_tasks_percpu {
@@ -43,6 +44,7 @@ struct rcu_tasks_percpu {struct rcu_head barrier_q_head;struct list_head rtp_blkd_tasks;int cpu; +int index;struct rcu_tasks *rtpp; };
@@ -68,6 +70,7 @@ struct rcu_tasks_percpu {* @postgp_func: This flavor's post-grace-period function (optional). * @call_func: This flavor's call_rcu()-equivalent function. * @rtpcpu: This flavor's rcu_tasks_percpu structure. +* @rtpcp_array: Array of pointers to rcu_tasks_percpu structure of CPUs in cpu_possible_mask. * @percpu_enqueue_shift: Shift down CPU ID this much when enqueuing callbacks. * @percpu_enqueue_lim: Number of per-CPU callback queues in use for enqueuing. * @percpu_dequeue_lim: Number of per-CPU callback queues in use for dequeuing.
@@ -100,6 +103,7 @@ struct rcu_tasks {postgp_func_t postgp_func;call_rcu_func_t call_func;struct rcu_tasks_percpu __percpu *rtpcpu; +struct rcu_tasks_percpu **rtpcp_array;int percpu_enqueue_shift;int percpu_enqueue_lim;int percpu_dequeue_lim;
@@ -164,6 +168,8 @@ module_param(rcu_task_contend_lim, int,static int rcu_task_collapse_lim__read_mostly =10 ;module_param (rcu_task_collapse_lim, int,0444 ); +static int rcu_task_cpu_ids; +/* RCU tasks grace-period state for debugging. */ #define RTGS_INIT 0#define RTGS_WAIT_WAIT_CBS 1
@@ -228,6 +234,8 @@ static void cblist_init_generic(struct runsigned long flags;int lim;int shift; +int maxcpu; +int index =0 ;raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags);if (rcu_task_enqueue_lim <0 ) {
@@ -238,14 +246,9 @@ static void cblist_init_generic(struct r } lim = rcu_task_enqueue_lim; -if (lim > nr_cpu_ids) - lim = nr_cpu_ids; - shift =ilog2 (nr_cpu_ids / lim); -if (((nr_cpu_ids -1 ) >> shift) >= lim) - shift++; -WRITE_ONCE (rtp->percpu_enqueue_shift, shift); -WRITE_ONCE (rtp->percpu_dequeue_lim, lim); -smp_store_release (&rtp->percpu_enqueue_lim, lim); + rtp->rtpcp_array =kcalloc (num_possible_cpus (),sizeof (struct rcu_tasks_percpu *),GFP_KERNEL ); +BUG_ON (!rtp->rtpcp_array); +for_each_possible_cpu (cpu) {struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);
@@ -258,16 +261,33 @@ static void cblist_init_generic(struct rINIT_WORK (&rtpcp->rtp_work, rcu_tasks_invoke_cbs_wq); rtpcp->cpu = cpu; rtpcp->rtpp = rtp; + rtpcp->index = index; + rtp->rtpcp_array[index] = rtpcp; + index++;if (!rtpcp->rtp_blkd_tasks.next)INIT_LIST_HEAD (&rtpcp->rtp_blkd_tasks);raw_spin_unlock_rcu_node (rtpcp);// irqs remain disabled. + maxcpu = cpu; }raw_spin_unlock_irqrestore (&rtp->cbs_gbl_lock, flags);if (rcu_task_cb_adjust)pr_info ("%s: Setting adjustable number of callback queues.\n" , __func__); -pr_info ("%s: Setting shift to %d and lim to %d.\n" , __func__,data_race (rtp->percpu_enqueue_shift),data_race (rtp->percpu_enqueue_lim)); + rcu_task_cpu_ids = maxcpu +1 ; +if (lim > rcu_task_cpu_ids) + lim = rcu_task_cpu_ids; + shift =ilog2 (rcu_task_cpu_ids / lim); +if (((rcu_task_cpu_ids -1 ) >> shift) >= lim) + shift++; +WRITE_ONCE (rtp->percpu_enqueue_shift, shift); +WRITE_ONCE (rtp->percpu_dequeue_lim, lim); +smp_store_release (&rtp->percpu_enqueue_lim, lim); + +pr_info ("%s: Setting shift to %d and lim to %d rcu_task_cb_adjust=%d rcu_task_cpu_ids=%d.\n" , + rtp->name,data_race (rtp->percpu_enqueue_shift),data_race (rtp->percpu_enqueue_lim), + rcu_task_cb_adjust, rcu_task_cpu_ids); + }// IRQ-work handler that does deferred wakeup for call_rcu_tasks_generic().
@@ -307,7 +327,7 @@ static void call_rcu_tasks_generic(struc rtpcp->rtp_n_lock_retries =0 ; }if (rcu_task_cb_adjust && ++rtpcp->rtp_n_lock_retries > rcu_task_contend_lim && -READ_ONCE (rtp->percpu_enqueue_lim) != nr_cpu_ids) +READ_ONCE (rtp->percpu_enqueue_lim) != rcu_task_cpu_ids) needadjust = true;// Defer adjustment to avoid deadlock. }if (!rcu_segcblist_is_enabled (&rtpcp->cblist)) {
@@ -320,10 +340,10 @@ static void call_rcu_tasks_generic(strucraw_spin_unlock_irqrestore_rcu_node (rtpcp, flags);if (unlikely (needadjust)) {raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags); -if (rtp->percpu_enqueue_lim != nr_cpu_ids) { +if (rtp->percpu_enqueue_lim != rcu_task_cpu_ids) {WRITE_ONCE (rtp->percpu_enqueue_shift,0 ); -WRITE_ONCE (rtp->percpu_dequeue_lim, nr_cpu_ids); -smp_store_release (&rtp->percpu_enqueue_lim, nr_cpu_ids); +WRITE_ONCE (rtp->percpu_dequeue_lim, rcu_task_cpu_ids); +smp_store_release (&rtp->percpu_enqueue_lim, rcu_task_cpu_ids);pr_info ("Switching %s to per-CPU callback queuing.\n" , rtp->name); }raw_spin_unlock_irqrestore (&rtp->cbs_gbl_lock, flags);
@@ -394,6 +414,8 @@ static int rcu_tasks_need_gpcb(struct rcint needgpcb =0 ;for (cpu =0 ; cpu <smp_load_acquire (&rtp->percpu_dequeue_lim); cpu++) { +if (!cpu_possible (cpu)) +continue ;struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);/* Advance and accelerate any new callbacks. */
@@ -426,7 +448,7 @@ static int rcu_tasks_need_gpcb(struct rcif (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) {raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags);if (rtp->percpu_enqueue_lim >1 ) { -WRITE_ONCE (rtp->percpu_enqueue_shift,order_base_2 (nr_cpu_ids)); +WRITE_ONCE (rtp->percpu_enqueue_shift,order_base_2 (rcu_task_cpu_ids));smp_store_release (&rtp->percpu_enqueue_lim,1 ); rtp->percpu_dequeue_gpseq =get_state_synchronize_rcu (); gpdone = false;
@@ -441,7 +463,9 @@ static int rcu_tasks_need_gpcb(struct rcpr_info ("Completing switch %s to CPU-0 callback queuing.\n" , rtp->name); }if (rtp->percpu_dequeue_lim ==1 ) { -for (cpu = rtp->percpu_dequeue_lim; cpu < nr_cpu_ids; cpu++) { +for (cpu = rtp->percpu_dequeue_lim; cpu < rcu_task_cpu_ids; cpu++) { +if (!cpu_possible (cpu)) +continue ;struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);WARN_ON_ONCE (rcu_segcblist_n_cbs (&rtpcp->cblist));
@@ -456,30 +480,32 @@ static int rcu_tasks_need_gpcb(struct rc// Advance callbacks and invoke any that are ready. static void rcu_tasks_invoke_cbs (struct rcu_tasks *rtp,struct rcu_tasks_percpu *rtpcp) { -int cpu; -int cpunext;int cpuwq;unsigned long flags;int len; +int index;struct rcu_head *rhp;struct rcu_cblist rcl =RCU_CBLIST_INITIALIZER (rcl);struct rcu_tasks_percpu *rtpcp_next; - cpu = rtpcp->cpu; - cpunext = cpu *2 +1 ; -if (cpunext <smp_load_acquire (&rtp->percpu_dequeue_lim)) { - rtpcp_next =per_cpu_ptr (rtp->rtpcpu, cpunext); - cpuwq =rcu_cpu_beenfullyonline (cpunext) ? cpunext :WORK_CPU_UNBOUND ; -queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); - cpunext++; -if (cpunext <smp_load_acquire (&rtp->percpu_dequeue_lim)) { - rtpcp_next =per_cpu_ptr (rtp->rtpcpu, cpunext); - cpuwq =rcu_cpu_beenfullyonline (cpunext) ? cpunext :WORK_CPU_UNBOUND ; + index = rtpcp->index *2 +1 ; +if (index <num_possible_cpus ()) { + rtpcp_next = rtp->rtpcp_array[index]; +if (rtpcp_next->cpu <smp_load_acquire (&rtp->percpu_dequeue_lim)) { + cpuwq =rcu_cpu_beenfullyonline (rtpcp_next->cpu) ? rtpcp_next->cpu :WORK_CPU_UNBOUND ;queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); + index++; +if (index <num_possible_cpus ()) { + rtpcp_next = rtp->rtpcp_array[index]; +if (rtpcp_next->cpu <smp_load_acquire (&rtp->percpu_dequeue_lim)) { + cpuwq =rcu_cpu_beenfullyonline (rtpcp_next->cpu) ? rtpcp_next->cpu :WORK_CPU_UNBOUND ; +queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); + } + } } } -if (rcu_segcblist_empty (&rtpcp->cblist) || !cpu_possible (cpu)) +if (rcu_segcblist_empty (&rtpcp->cblist))return ;raw_spin_lock_irqsave_rcu_node (rtpcp, flags);rcu_segcblist_advance (&rtpcp->cblist,rcu_seq_current (&rtp->tasks_gp_seq));
Greg Kroah-Hartman
maintainerPATCH 352/772 btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume operations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
commit 74e97958121aa1f5854da6effba70143f051b0cd upstream.
Create subvolume, create snapshot and delete subvolume all use btrfs_subvolume_reserve_metadata() to reserve metadata for the changes done to the parent subvolume's fs tree, which cannot be mediated in the normal way via start_transaction. When quota groups (squota or qgroups) are enabled, this reserves qgroup metadata of type PREALLOC. Once the operation is associated to a transaction, we convert PREALLOC to PERTRANS, which gets cleared in bulk at the end of the transaction.
However, the error paths of these three operations were not implementing this lifecycle correctly. They unconditionally converted the PREALLOC to PERTRANS in a generic cleanup step regardless of errors or whether the operation was fully associated to a transaction or not. This resulted in error paths occasionally converting this rsv to PERTRANS without calling record_root_in_trans successfully, which meant that unless that root got recorded in the transaction by some other thread, the end of the transaction would not free that root's PERTRANS, leaking it. Ultimately, this resulted in hitting a WARN in CONFIG_BTRFS_DEBUG builds at unmount for the leaked reservation.
The fix is to ensure that every qgroup PREALLOC reservation observes the following properties:
1. any failure before record_root_in_trans is called successfully results in freeing the PREALLOC reservation.
2. after record_root_in_trans, we convert to PERTRANS, and now the transaction owns freeing the reservation.
This patch enforces those properties on the three operations. Without it, generic/269 with squotas enabled at mkfs time would fail in ~5-10 runs on my system. With this patch, it ran successfully 1000 times in a row.
[Xiangyu: BP to fix CVE-2024-35956, due to 6.1 btrfs_subvolume_release_metadata() defined in ctree.h, modified the header file name from root-tree.h to ctree.h]
--- fs/btrfs/ctree.h | 2 -- fs/btrfs/inode.c | 13 ++++++++++++- fs/btrfs/ioctl.c | 36 ++++++++++++++++++++++++++++-------- fs/btrfs/root-tree.c | 10 ---------- 4 files changed, 40 insertions(+), 21 deletions(-)
fs/btrfs/ctree.h +0 -2
@@ -2987,8 +2987,6 @@ enum btrfs_flush_state {int btrfs_subvolume_reserve_metadata (struct btrfs_root *root,struct btrfs_block_rsv *rsv,int nitems,bool use_global_rsv); -void btrfs_subvolume_release_metadata (struct btrfs_root *root, -struct btrfs_block_rsv *rsv);void btrfs_delalloc_release_extents (struct btrfs_inode *inode,u64 num_bytes); int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes,
fs/btrfs/inode.c +12 -1
@@ -4707,6 +4707,7 @@ int btrfs_delete_subvolume(struct inodestruct btrfs_trans_handle *trans;struct btrfs_block_rsv block_rsv;u64 root_flags; +u64 qgroup_reserved =0 ;int ret;down_write (&fs_info->subvol_sem);
@@ -4751,12 +4752,20 @@ int btrfs_delete_subvolume(struct inode ret =btrfs_subvolume_reserve_metadata (root, &block_rsv,5 , true);if (ret) goto out_undead; + qgroup_reserved = block_rsv.qgroup_rsv_reserved; trans =btrfs_start_transaction (root,0 );if (IS_ERR (trans)) { ret =PTR_ERR (trans); goto out_release; } + ret =btrfs_record_root_in_trans (trans, root); +if (ret) { +btrfs_abort_transaction (trans, ret); + goto out_end_trans; + } +btrfs_qgroup_convert_reserved_meta (root, qgroup_reserved); + qgroup_reserved =0 ; trans->block_rsv = &block_rsv; trans->bytes_reserved = block_rsv.size;
@@ -4815,7 +4824,9 @@ out_end_trans: ret =btrfs_end_transaction (trans); inode->i_flags |=S_DEAD ; out_release: -btrfs_subvolume_release_metadata (root, &block_rsv); +btrfs_block_rsv_release (fs_info, &block_rsv, (u64)-1 ,NULL ); +if (qgroup_reserved) +btrfs_qgroup_free_meta_prealloc (root, qgroup_reserved); out_undead:if (ret) {spin_lock (&dest->root_item_lock);
fs/btrfs/ioctl.c +28 -8
@@ -592,6 +592,7 @@ static noinline int create_subvol(structint ret;dev_t anon_dev;u64 objectid; +u64 qgroup_reserved =0 ; root_item =kzalloc (sizeof (*root_item),GFP_KERNEL );if (!root_item)
@@ -629,13 +630,18 @@ static noinline int create_subvol(struct trans_num_items, false);if (ret) goto out_new_inode_args; + qgroup_reserved = block_rsv.qgroup_rsv_reserved; trans =btrfs_start_transaction (root,0 );if (IS_ERR (trans)) { ret =PTR_ERR (trans); -btrfs_subvolume_release_metadata (root, &block_rsv); - goto out_new_inode_args; + goto out_release_rsv; } + ret =btrfs_record_root_in_trans (trans,BTRFS_I (dir)->root); +if (ret) + goto out; +btrfs_qgroup_convert_reserved_meta (root, qgroup_reserved); + qgroup_reserved =0 ; trans->block_rsv = &block_rsv; trans->bytes_reserved = block_rsv.size;
@@ -744,12 +750,15 @@ static noinline int create_subvol(struct out: trans->block_rsv =NULL ; trans->bytes_reserved =0 ; -btrfs_subvolume_release_metadata (root, &block_rsv);if (ret)btrfs_end_transaction (trans);else ret =btrfs_commit_transaction (trans); +out_release_rsv: +btrfs_block_rsv_release (fs_info, &block_rsv, (u64)-1 ,NULL ); +if (qgroup_reserved) +btrfs_qgroup_free_meta_prealloc (root, qgroup_reserved); out_new_inode_args:btrfs_new_inode_args_destroy (&new_inode_args); out_inode:
@@ -771,6 +780,8 @@ static int create_snapshot(struct btrfs_struct btrfs_pending_snapshot *pending_snapshot;unsigned int trans_num_items;struct btrfs_trans_handle *trans; +struct btrfs_block_rsv *block_rsv; +u64 qgroup_reserved =0 ;int ret;/* We do not support snapshotting right now. */
@@ -807,19 +818,19 @@ static int create_snapshot(struct btrfs_ goto free_pending; } -btrfs_init_block_rsv (&pending_snapshot->block_rsv, -BTRFS_BLOCK_RSV_TEMP ); + block_rsv = &pending_snapshot->block_rsv; +btrfs_init_block_rsv (block_rsv,BTRFS_BLOCK_RSV_TEMP );/* * 1 to add dir item * 1 to add dir index * 1 to update parent inode item */ trans_num_items =create_subvol_num_items (inherit) +3 ; - ret =btrfs_subvolume_reserve_metadata (BTRFS_I (dir)->root, - &pending_snapshot->block_rsv, + ret =btrfs_subvolume_reserve_metadata (BTRFS_I (dir)->root, block_rsv, trans_num_items, false);if (ret) goto free_pending; + qgroup_reserved = block_rsv->qgroup_rsv_reserved; pending_snapshot->dentry = dentry; pending_snapshot->root = root;
@@ -832,6 +843,13 @@ static int create_snapshot(struct btrfs_ ret =PTR_ERR (trans); goto fail; } + ret =btrfs_record_root_in_trans (trans,BTRFS_I (dir)->root); +if (ret) { +btrfs_end_transaction (trans); + goto fail; + } +btrfs_qgroup_convert_reserved_meta (root, qgroup_reserved); + qgroup_reserved =0 ; trans->pending_snapshot = pending_snapshot;
@@ -861,7 +879,9 @@ fail:if (ret && pending_snapshot->snap) pending_snapshot->snap->anon_dev =0 ;btrfs_put_root (pending_snapshot->snap); -btrfs_subvolume_release_metadata (root, &pending_snapshot->block_rsv); +btrfs_block_rsv_release (fs_info, block_rsv, (u64)-1 ,NULL ); +if (qgroup_reserved) +btrfs_qgroup_free_meta_prealloc (root, qgroup_reserved); free_pending:if (pending_snapshot->anon_dev)free_anon_bdev (pending_snapshot->anon_dev);
fs/btrfs/root-tree.c +0 -10
@@ -532,13 +532,3 @@ int btrfs_subvolume_reserve_metadata(str }return ret; } - -void btrfs_subvolume_release_metadata (struct btrfs_root *root, -struct btrfs_block_rsv *rsv) -{ -struct btrfs_fs_info *fs_info = root->fs_info; -u64 qgroup_to_release; - -btrfs_block_rsv_release (fs_info, rsv, (u64)-1 , &qgroup_to_release); -btrfs_qgroup_convert_reserved_meta (root, qgroup_to_release); -}
Greg Kroah-Hartman
maintainerPATCH 353/772 perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 556a7c039a52c21da33eaae9269984a1ef59189b upstream.
The below error is observed on Ice Lake VM.
$ perf stat Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (slots). /bin/dmesg | grep -i perf may provide additional information.
In a virtualization env, the Topdown metrics and the slots event haven't been supported yet. The guest CPUID doesn't enumerate them. However, the current kernel unconditionally exposes the slots event and the Topdown metrics events to sysfs, which misleads the perf tool and triggers the error.
Hide the perf-metrics topdown events and the slots event if the perf-metrics feature is not enumerated.
The big core of a hybrid platform can also supports the perf-metrics feature. Fix the hybrid platform as well.
--- arch/x86/events/intel/core.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
arch/x86/events/intel/core.c +33 -1
@@ -5409,8 +5409,22 @@ default_is_visible(struct kobject *kobj,return attr->mode; } +static umode_t +td_is_visible (struct kobject *kobj,struct attribute *attr,int i) +{ +/* +* Hide the perf metrics topdown events +* if the feature is not enumerated. +*/ +if (x86_pmu.num_topdown_events) +return x86_pmu.intel_cap.perf_metrics ? attr->mode :0 ; + +return attr->mode; +} +static struct attribute_group group_events_td = { .name ="events" , + .is_visible = td_is_visible, };static struct attribute_group group_events_mem = {
@@ -5587,9 +5601,27 @@ static umode_t hybrid_format_is_visible(return (cpu >=0 ) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode :0 ; } +static umode_t hybrid_td_is_visible (struct kobject *kobj, +struct attribute *attr,int i) +{ +struct device *dev =kobj_to_dev (kobj); +struct x86_hybrid_pmu *pmu = + container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu); + +if (!is_attr_for_this_pmu (kobj, attr)) +return 0 ; + + +/* Only the big core supports perf metrics */ +if (pmu->cpu_type == hybrid_big) +return pmu->intel_cap.perf_metrics ? attr->mode :0 ; + +return attr->mode; +} +static struct attribute_group hybrid_group_events_td = { .name ="events" , - .is_visible = hybrid_events_is_visible, + .is_visible = hybrid_td_is_visible, };static struct attribute_group hybrid_group_events_mem = {
Greg Kroah-Hartman
maintainerPATCH 354/772 mlxsw: spectrum_acl_tcam: Fix NULL pointer dereference in error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
commit efeb7dfea8ee10cdec11b6b6ba4e405edbe75809 upstream.
When calling mlxsw_sp_acl_tcam_region_destroy() from an error path after failing to attach the region to an ACL group, we hit a NULL pointer dereference upon 'region->group->tcam' [1].
Fix by retrieving the 'tcam' pointer using mlxsw_sp_acl_to_tcam().
[1]
BUG: kernel NULL pointer dereference, address: 0000000000000000 [...] RIP: 0010:mlxsw_sp_acl_tcam_region_destroy+0xa0/0xd0 [...] Call Trace: mlxsw_sp_acl_tcam_vchunk_get+0x88b/0xa20 mlxsw_sp_acl_tcam_ventry_add+0x25/0xe0 mlxsw_sp_acl_rule_add+0x47/0x240 mlxsw_sp_flower_replace+0x1a9/0x1d0 tc_setup_cb_add+0xdc/0x1c0 fl_hw_replace_filter+0x146/0x1f0 fl_change+0xc17/0x1360 tc_new_tfilter+0x472/0xb90 rtnetlink_rcv_msg+0x313/0x3b0 netlink_rcv_skb+0x58/0x100 netlink_unicast+0x244/0x390 netlink_sendmsg+0x1e4/0x440 ____sys_sendmsg+0x164/0x260 ___sys_sendmsg+0x9a/0xe0 __sys_sendmsg+0x7a/0xc0 do_syscall_64+0x40/0xe0 entry_SYSCALL_64_after_hwframe+0x63/0x6b
[ For the function mlxsw_sp_acl_to_tcam() is not exist in 6.1.y, pick mlxsw_sp_acl_to_tcam() from commit 74cbc3c03c828ccf265a72f9bcb5aee906978744 ]
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 5 +++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +1 -0
@@ -970,6 +970,7 @@ enum mlxsw_sp_acl_profile { };struct mlxsw_afk *mlxsw_sp_acl_afk (struct mlxsw_sp_acl *acl); +struct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam (struct mlxsw_sp_acl *acl); int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_flow_block *block,
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +5 -0
@@ -40,6 +40,11 @@ struct mlxsw_afk *mlxsw_sp_acl_afk(strucreturn acl->afk; } +struct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam (struct mlxsw_sp_acl *acl) +{ +return &acl->tcam; +} +struct mlxsw_sp_acl_ruleset_ht_key {struct mlxsw_sp_flow_block *block;u32 chain_index;
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +2 -2
@@ -747,13 +747,13 @@ static void mlxsw_sp_acl_tcam_region_destroy(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region) { + struct mlxsw_sp_acl_tcam *tcam = mlxsw_sp_acl_to_tcam(mlxsw_sp->acl);const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops; ops->region_fini (mlxsw_sp, region->priv);mlxsw_sp_acl_tcam_region_disable (mlxsw_sp, region);mlxsw_sp_acl_tcam_region_free (mlxsw_sp, region); -mlxsw_sp_acl_tcam_region_id_put (region->group->tcam, - region->id); +mlxsw_sp_acl_tcam_region_id_put (tcam, region->id);kfree (region); }
Greg Kroah-Hartman
maintainerPATCH 355/772 ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Sevens <[email protected]>
commit b909df18ce2a998afef81d58bbd1a05dc0788c40 upstream.
A bogus device can provide a bNumConfigurations value that exceeds the initial value used in usb_get_configuration for allocating dev->config.
This can lead to out-of-bounds accesses later, e.g. in usb_destroy_configuration.
--- sound/usb/quirks.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
sound/usb/quirks.c +21 -6
@@ -553,6 +553,7 @@ int snd_usb_create_quirk(struct snd_usb_static int snd_usb_extigy_boot_quirk (struct usb_device *dev,struct usb_interface *intf) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err; if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
@@ -564,10 +565,14 @@ static int snd_usb_extigy_boot_quirk(strif (err <0 )dev_dbg (&dev->dev,"error sending boot message: %d\n" , err); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )dev_dbg (&dev->dev,"error usb_reset_configuration: %d\n" , err);
@@ -899,6 +904,7 @@ static void mbox2_setup_48_24_magic(strustatic int snd_usb_mbox2_boot_quirk (struct usb_device *dev) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err;u8 bootresponse[0x12 ];int fwsize;
@@ -934,10 +940,14 @@ static int snd_usb_mbox2_boot_quirk(strudev_dbg (&dev->dev,"device initialised!\n" ); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )
@@ -1251,6 +1261,7 @@ static void mbox3_setup_48_24_magic(strustatic int snd_usb_mbox3_boot_quirk (struct usb_device *dev) {struct usb_host_config *config = dev->actconfig; +struct usb_device_descriptor new_device_descriptor;int err;int descriptor_size;
@@ -1264,10 +1275,14 @@ static int snd_usb_mbox3_boot_quirk(strudev_dbg (&dev->dev,"device initialised!\n" ); err =usb_get_descriptor (dev,USB_DT_DEVICE ,0 , - &dev->descriptor,sizeof (dev->descriptor)); - config = dev->actconfig; + &new_device_descriptor,sizeof (new_device_descriptor));if (err <0 )dev_dbg (&dev->dev,"error usb_get_descriptor: %d\n" , err); +if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations) +dev_dbg (&dev->dev,"error too large bNumConfigurations: %d\n" , + new_device_descriptor.bNumConfigurations); +else +memcpy (&dev->descriptor, &new_device_descriptor,sizeof (dev->descriptor)); err =usb_reset_configuration (dev);if (err <0 )
Greg Kroah-Hartman
maintainerPATCH 356/772 Revert "arm64: dts: mediatek: mt8195-cherry: Mark USB 3.0 on xhci1 as disabled"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
This reverts commit edca00ad79aa1dfd1b88ace1df1e9dfa21a3026f.
The hunk was applied to the wrong device node when the commit was backported to the 6.1 stable branch.
Revert it to re-do the backport correctly.
--- arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +0 -1
@@ -922,7 +922,6 @@ usb2-lpm-disable; vusb33-supply = <&mt6359_vusb_ldo_reg>; vbus-supply = <&usb_vbus>; - mediatek,u3p-dis-msk = <1>; }; #include <arm/cros-ec-keyboard.dtsi>
Greg Kroah-Hartman
maintainerPATCH 357/772 arm64: dts: mediatek: mt8195-cherry: Mark USB 3.0 on xhci1 as disabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 09d385679487c58f0859c1ad4f404ba3df2f8830 ]
USB 3.0 on xhci1 is not used, as the controller shares the same PHY as pcie1. The latter is enabled to support the M.2 PCIe WLAN card on this design.
Mark USB 3.0 as disabled on this controller using the "mediatek,u3p-dis-msk" property.
--- arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +1 -0
@@ -906,6 +906,7 @@ vusb33-supply = <&mt6359_vusb_ldo_reg>; vbus-supply = <&usb_vbus>; + mediatek,u3p-dis-msk = <1>; }; &xhci2 {
Greg Kroah-Hartman
maintainerPATCH 358/772 mm/slab: decouple ARCH_KMALLOC_MINALIGN from ARCH_DMA_MINALIGN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 4ab5f8ec7d71aea5fe13a48248242130f84ac6bb upstream.
Patch series "mm, dma, arm64: Reduce ARCH_KMALLOC_MINALIGN to 8", v7.
A series reducing the kmalloc() minimum alignment on arm64 to 8 (from 128).
This patch (of 17):
In preparation for supporting a kmalloc() minimum alignment smaller than the arch DMA alignment, decouple the two definitions. This requires that either the kmalloc() caches are aligned to a (run-time) cache-line size or the DMA API bounces unaligned kmalloc() allocations. Subsequent patches will implement both options.
After this patch, ARCH_DMA_MINALIGN is expected to be used in static alignment annotations and defined by an architecture to be the maximum alignment for all supported configurations/SoCs in a single Image. Architectures opting in to a smaller ARCH_KMALLOC_MINALIGN will need to define its value in the arch headers.
Since ARCH_DMA_MINALIGN is now always defined, adjust the #ifdef in dma_get_cache_alignment() so that there is no change for architectures not requiring a minimum DMA alignment.
--- include/linux/cache.h | 6 ++++++ include/linux/dma-mapping.h | 3 ++- include/linux/slab.h | 14 ++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-)
include/linux/cache.h +6 -0
@@ -98,4 +98,10 @@ struct cacheline_padding {#define CACHELINE_PADDING (name)#endif +#ifdef ARCH_DMA_MINALIGN +#define ARCH_HAS_DMA_MINALIGN +#else +#define ARCH_DMA_MINALIGN __alignof__(unsigned long long) +#endif +#endif /* __LINUX_CACHE_H */
include/linux/dma-mapping.h +2 -1
@@ -2,6 +2,7 @@#ifndef _LINUX_DMA_MAPPING_H#define _LINUX_DMA_MAPPING_H +#include <linux/cache.h> #include <linux/sizes.h> #include <linux/string.h> #include <linux/device.h>
@@ -545,7 +546,7 @@ static inline int dma_set_min_align_maskstatic inline int dma_get_cache_alignment (void ) { -#ifdef ARCH_DMA_MINALIGN +#ifdef ARCH_HAS_DMA_MINALIGN return ARCH_DMA_MINALIGN ;#endif return 1 ;
include/linux/slab.h +10 -4
@@ -12,6 +12,7 @@#ifndef _LINUX_SLAB_H#define _LINUX_SLAB_H +#include <linux/cache.h> #include <linux/gfp.h> #include <linux/overflow.h> #include <linux/types.h>
@@ -225,12 +226,17 @@ static inline bool kmem_dump_obj(void *o* alignment larger than the alignment of a 64-bit integer. * Setting ARCH_DMA_MINALIGN in arch headers allows that. */ -#if defined(ARCH_DMA_MINALIGN ) &&ARCH_DMA_MINALIGN >8 +#ifdef ARCH_HAS_DMA_MINALIGN +#if ARCH_DMA_MINALIGN >8 && !defined(ARCH_KMALLOC_MINALIGN )#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN -#define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN -#define KMALLOC_SHIFT_LOW ilog2(ARCH_DMA_MINALIGN) -#else +#endif +#endif + +#ifndef ARCH_KMALLOC_MINALIGN #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long) +#elif ARCH_KMALLOC_MINALIGN >8 +#define KMALLOC_MIN_SIZE ARCH_KMALLOC_MINALIGN +#define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE)#endif /*
Greg Kroah-Hartman
maintainerPATCH 359/772 dma: allow dma_get_cache_alignment() to be overridden by the arch code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 8c57da28dc3df4e091474a004b5596c9b88a3be0 upstream.
On arm64, ARCH_DMA_MINALIGN is larger than most cache line size configurations deployed. Allow an architecture to override dma_get_cache_alignment() in order to return a run-time probed value (e.g. cache_line_size()).
--- include/linux/dma-mapping.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/dma-mapping.h +2 -0
@@ -544,6 +544,7 @@ static inline int dma_set_min_align_maskreturn 0 ; } +#ifndef dma_get_cache_alignmentstatic inline int dma_get_cache_alignment (void ) {#ifdef ARCH_HAS_DMA_MINALIGN
@@ -551,6 +552,7 @@ static inline int dma_get_cache_alignmen#endif return 1; } +#endif static inline void *dmam_alloc_coherent (struct device *dev,size_t size,dma_addr_t *dma_handle,gfp_t gfp)
Greg Kroah-Hartman
maintainerPATCH 360/772 ASoC: Intel: sst: Fix used of uninitialized ctx to log an error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit c1895ba181e560144601fafe46aeedbafdf4dbc4 upstream.
Fix the new "LPE0F28" code path using the uninitialized ctx variable to log an error.
--- sound/soc/intel/atom/sst/sst_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/atom/sst/sst_acpi.c +1 -1
@@ -309,7 +309,7 @@ static int sst_acpi_probe(struct platfor rsrc =platform_get_resource (pdev,IORESOURCE_MEM , pdata->res_info->acpi_lpe_res_index);if (!rsrc) { -dev_err (ctx->dev,"Invalid SHIM base\n" ); +dev_err (dev,"Invalid SHIM base\n" );return -EIO ; } rsrc->start -= pdata->res_info->shim_offset;
Greg Kroah-Hartman
maintainerPATCH 361/772 soc: qcom: socinfo: fix revision check in qcom_socinfo_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manikanta Mylavarapu <[email protected]>
commit 128fdbf36cddc2a901c4889ba1c89fa9f2643f2c upstream.
In success case, the revision holds a non-null pointer. The current logic incorrectly returns an error for a non-null pointer, whereas it should return an error for a null pointer.
The socinfo driver for IPQ9574 and IPQ5332 is currently broken, resulting in the following error message
qcom-socinfo qcom-socinfo: probe with driver qcom-socinfo failed with error -12
Add a null check for the revision to ensure it returns an error only in failure case (null pointer).
--- drivers/soc/qcom/socinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/socinfo.c +1 -1
@@ -649,7 +649,7 @@ static int qcom_socinfo_probe(struct pla qs->attr.revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%u.%u" ,SOCINFO_MAJOR (le32_to_cpu (info->ver)),SOCINFO_MINOR (le32_to_cpu (info->ver))); -if (!qs->attr.soc_id || qs->attr.revision) +if (!qs->attr.soc_id || !qs->attr.revision)return -ENOMEM ;if (offsetof(struct socinfo , serial_num) <= item_size) {
Greg Kroah-Hartman
maintainerPATCH 362/772 ext4: supress data-race warnings in ext4_free_inodes_{count,set}()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 902cc179c931a033cd7f4242353aa2733bf8524c upstream.
find_group_other() and find_group_orlov() read *_lo, *_hi with ext4_free_inodes_count without additional locking. This can cause data-race warning, but since the lock is held for most writes and free inodes value is generally not a problem even if it is incorrect, it is more appropriate to use READ_ONCE()/WRITE_ONCE() than to add locking.
==================================================================
BUG: KCSAN: data-race in ext4_free_inodes_count / ext4_free_inodes_set
write to 0xffff88810404300e of 2 bytes by task 6254 on cpu 1:
ext4_free_inodes_set+0x1f/0x80 fs/ext4/super.c:405 __ext4_new_inode+0x15ca/0x2200 fs/ext4/ialloc.c:1216 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4615 do_symlinkat+0xe3/0x340 fs/namei.c:4641 __do_sys_symlinkat fs/namei.c:4657 [inline] __se_sys_symlinkat fs/namei.c:4654 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4654 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
read to 0xffff88810404300e of 2 bytes by task 6257 on cpu 0:
ext4_free_inodes_count+0x1c/0x80 fs/ext4/super.c:349 find_group_other fs/ext4/ialloc.c:594 [inline] __ext4_new_inode+0x6ec/0x2200 fs/ext4/ialloc.c:1017 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4615 do_symlinkat+0xe3/0x340 fs/namei.c:4641 __do_sys_symlinkat fs/namei.c:4657 [inline] __se_sys_symlinkat fs/namei.c:4654 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4654 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- fs/ext4/super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ext4/super.c +4 -4
@@ -338,9 +338,9 @@ __u32 ext4_free_group_clusters(struct su__u32 ext4_free_inodes_count (struct super_block *sb,struct ext4_group_desc *bg) { -return le16_to_cpu (bg->bg_free_inodes_count_lo) | +return le16_to_cpu (READ_ONCE (bg->bg_free_inodes_count_lo)) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (__u32 )le16_to_cpu (bg->bg_free_inodes_count_hi) <<16 :0 ); + (__u32 )le16_to_cpu (READ_ONCE (bg->bg_free_inodes_count_hi)) <<16 :0 ); } __u32 ext4_used_dirs_count(struct super_block *sb,
@@ -394,9 +394,9 @@ void ext4_free_group_clusters_set(structvoid ext4_free_inodes_set (struct super_block *sb,struct ext4_group_desc *bg,__u32 count) { - bg->bg_free_inodes_count_lo =cpu_to_le16 ((__u16 )count); +WRITE_ONCE (bg->bg_free_inodes_count_lo,cpu_to_le16 ((__u16 )count));if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) - bg->bg_free_inodes_count_hi =cpu_to_le16 (count >>16 ); +WRITE_ONCE (bg->bg_free_inodes_count_hi,cpu_to_le16 (count >>16 )); } void ext4_used_dirs_set(struct super_block *sb,
Greg Kroah-Hartman
maintainerPATCH 363/772 ext4: fix FS_IOC_GETFSMAP handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 4a622e4d477bb12ad5ed4abbc7ad1365de1fa347 upstream.
The original implementation ext4's FS_IOC_GETFSMAP handling only worked when the range of queried blocks included at least one free (unallocated) block range. This is because how the metadata blocks were emitted was as a side effect of ext4_mballoc_query_range() calling ext4_getfsmap_datadev_helper(), and that function was only called when a free block range was identified. As a result, this caused generic/365 to fail.
Fix this by creating a new function ext4_getfsmap_meta_helper() which gets called so that blocks before the first free block range in a block group can get properly reported.
--- fs/ext4/fsmap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- fs/ext4/mballoc.c | 18 ++++++++++++++---- fs/ext4/mballoc.h | 1 + 3 files changed, 68 insertions(+), 5 deletions(-)
fs/ext4/fsmap.c +53 -1
@@ -185,6 +185,56 @@ static inline ext4_fsblk_t ext4_fsmap_nereturn fmr->fmr_physical + fmr->fmr_length; } +static int ext4_getfsmap_meta_helper (struct super_block *sb, +ext4_group_t agno,ext4_grpblk_t start, +ext4_grpblk_t len,void *priv) +{ +struct ext4_getfsmap_info *info = priv; +struct ext4_fsmap *p; +struct ext4_fsmap *tmp; +struct ext4_sb_info *sbi =EXT4_SB (sb); +ext4_fsblk_t fsb, fs_start, fs_end; +int error; + + fs_start = fsb = (EXT4_C2B (sbi, start) + +ext4_group_first_block_no (sb, agno)); + fs_end = fs_start +EXT4_C2B (sbi, len); + +/* Return relevant extents from the meta_list */ +list_for_each_entry_safe (p, tmp, &info->gfi_meta_list, fmr_list) { +if (p->fmr_physical < info->gfi_next_fsblk) { +list_del (&p->fmr_list); +kfree (p); +continue ; + } +if (p->fmr_physical <= fs_start || + p->fmr_physical + p->fmr_length <= fs_end) { +/* Emit the retained free extent record if present */ +if (info->gfi_lastfree.fmr_owner) { + error =ext4_getfsmap_helper (sb, info, + &info->gfi_lastfree); +if (error) +return error; + info->gfi_lastfree.fmr_owner =0 ; + } + error =ext4_getfsmap_helper (sb, info, p); +if (error) +return error; + fsb = p->fmr_physical + p->fmr_length; +if (info->gfi_next_fsblk < fsb) + info->gfi_next_fsblk = fsb; +list_del (&p->fmr_list); +kfree (p); +continue ; + } + } +if (info->gfi_next_fsblk < fsb) + info->gfi_next_fsblk = fsb; + +return 0 ; +} + +/* Transform a blockgroup's free record into a fsmap */ static int ext4_getfsmap_datadev_helper(struct super_block *sb, ext4_group_t agno, ext4_grpblk_t start,
@@ -539,6 +589,7 @@ static int ext4_getfsmap_datadev(struct error =ext4_mballoc_query_range (sb, info->gfi_agno,EXT4_B2C (sbi, info->gfi_low.fmr_physical),EXT4_B2C (sbi, info->gfi_high.fmr_physical), + ext4_getfsmap_meta_helper, ext4_getfsmap_datadev_helper, info);if (error) goto err;
@@ -560,7 +611,8 @@ static int ext4_getfsmap_datadev(struct/* Report any gaps at the end of the bg */ info->gfi_last = true; - error =ext4_getfsmap_datadev_helper (sb, end_ag, last_cluster,0 , info); + error =ext4_getfsmap_datadev_helper (sb, end_ag, last_cluster +1 , +0 , info);if (error) goto err;
fs/ext4/mballoc.c +14 -4
@@ -6685,13 +6685,14 @@ intext4_mballoc_query_range ( struct super_block *sb, ext4_group_t group, - ext4_grpblk_t start, + ext4_grpblk_t first, ext4_grpblk_t end, + ext4_mballoc_query_range_fn meta_formatter, ext4_mballoc_query_range_fn formatter, void *priv) { void *bitmap; -ext4_grpblk_t next; +ext4_grpblk_t start, next;struct ext4_buddy e4b;int error;
@@ -6702,10 +6703,19 @@ ext4_mballoc_query_range(ext4_lock_group (sb, group); - start =max (e4b.bd_info->bb_first_free, start); + start =max (e4b.bd_info->bb_first_free, first);if (end >=EXT4_CLUSTERS_PER_GROUP (sb)) end =EXT4_CLUSTERS_PER_GROUP (sb) -1 ; - +if (meta_formatter && start != first) { +if (start > end) + start = end; +ext4_unlock_group (sb, group); + error =meta_formatter (sb, group, first, start - first, + priv); +if (error) + goto out_unload; +ext4_lock_group (sb, group); + }while (start <= end) { start =mb_find_next_zero_bit (bitmap, end +1 , start);if (start > end)
fs/ext4/mballoc.h +1 -0
@@ -245,6 +245,7 @@ ext4_mballoc_query_range(ext4_group_t agno, ext4_grpblk_t start, ext4_grpblk_t end, + ext4_mballoc_query_range_fn meta_formatter, ext4_mballoc_query_range_fn formatter, void *priv);
Greg Kroah-Hartman
maintainerPATCH 364/772 jfs: xattr: check invalid xattr size more strictly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Sadovnikov <[email protected]>
commit d9f9d96136cba8fedd647d2c024342ce090133c2 upstream.
Commit 7c55b78818cf ("jfs: xattr: fix buffer overflow for invalid xattr") also addresses this issue but it only fixes it for positive values, while ea_size is an integer type and can take negative values, e.g. in case of a corrupted filesystem. This still breaks validation and would overflow because of implicit conversion from int to size_t in print_hex_dump().
Fix this issue by clamping the ea_size value instead.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- fs/jfs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/xattr.c +1 -1
@@ -559,7 +559,7 @@ static int ea_get(struct inode *inode, s size_check:if (EALIST_SIZE (ea_buf->xattr) != ea_size) { -int size =min_t (int,EALIST_SIZE (ea_buf->xattr), ea_size); +int size =clamp_t (int, ea_size,0 ,EALIST_SIZE (ea_buf->xattr));printk (KERN_ERR "ea_get: invalid extended attribute\n" ); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,
Greg Kroah-Hartman
maintainerPATCH 365/772 ASoC: amd: yc: Add a quirk for microfone on Lenovo ThinkPad P14s Gen 5 21MES00B00
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Zverev <[email protected]>
commit b682aa788e5f9f1ddacdfbb453e49fd3f4e83721 upstream.
New ThinkPads need new quirk entries. Ilya has tested this one. Laptop product id is 21MES00B00, though the shorthand 21ME works.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -245,6 +245,13 @@ static const struct dmi_system_id yc_acp .driver_data = &acp6x_card, .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "21ME"), + } + }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), DMI_MATCH(DMI_PRODUCT_NAME, "82TL"), } },
Greg Kroah-Hartman
maintainerPATCH 366/772 ASoC: codecs: Fix atomicity violation in snd_soc_component_get_drvdata()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiu-ji Chen <[email protected]>
commit 1157733344651ca505e259d6554591ff156922fa upstream.
An atomicity violation occurs when the validity of the variables da7219->clk_src and da7219->mclk_rate is being assessed. Since the entire assessment is not protected by a lock, the da7219 variable might still be in flux during the assessment, rendering this check invalid.
To fix this issue, we recommend adding a lock before the block if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) so that the legitimacy check for da7219->clk_src and da7219->mclk_rate is protected by the lock, ensuring the validity of the check.
This possible bug is found by an experimental static analysis tool developed by our team. This tool analyzes the locking APIs to extract function pairs that can be concurrently executed, and then analyzes the instructions in the paired functions to identify possible concurrency bugs including data races and atomicity violations.
--- sound/soc/codecs/da7219.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/codecs/da7219.c +6 -3
@@ -1167,17 +1167,20 @@ static int da7219_set_dai_sysclk(structstruct da7219_priv *da7219 =snd_soc_component_get_drvdata (component);int ret =0 ; -if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) +mutex_lock (&da7219->pll_lock); + +if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) { +mutex_unlock (&da7219->pll_lock);return 0 ; + }if ((freq <2000000 ) || (freq >54000000 )) { +mutex_unlock (&da7219->pll_lock);dev_err (codec_dai->dev,"Unsupported MCLK value %d\n" , freq);return -EINVAL ; } -mutex_lock (&da7219->pll_lock); -switch (clk_id) {case DA7219_CLKSRC_MCLK_SQR : snd_soc_component_update_bits(component, DA7219_PLL_CTRL,
Greg Kroah-Hartman
maintainerPATCH 367/772 perf/x86/intel/pt: Fix buffer full but size is 0 case
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit 5b590160d2cf776b304eb054afafea2bd55e3620 upstream.
If the trace data buffer becomes full, a truncated flag [T] is reported in PERF_RECORD_AUX. In some cases, the size reported is 0, even though data must have been added to make the buffer full.
That happens when the buffer fills up from empty to full before the Intel PT driver has updated the buffer position. Then the driver calculates the new buffer position before calculating the data size. If the old and new positions are the same, the data size is reported as 0, even though it is really the whole buffer size.
Fix by detecting when the buffer position is wrapped, and adjust the data size calculation accordingly.
Example
Use a very small buffer size (8K) and observe the size of truncated [T] data. Before the fix, it is possible to see records of 0 size.
Before:
$ perf record -m,8K -e intel_pt// uname
Linux
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.105 MB perf.data ]
$ perf script -D --no-itrace | grep AUX | grep -F '[T]'
Warning:
AUX data lost 2 times out of 3! 5 19462712368111 0x19710 [0x40]: PERF_RECORD_AUX offset: 0 size: 0 flags: 0x1 [T]
5 19462712700046 0x19ba8 [0x40]: PERF_RECORD_AUX offset: 0x170 size: 0xe90 flags: 0x1 [T]After:
$ perf record -m,8K -e intel_pt// uname
Linux
[ perf record: Woken up 3 times to write data ]
[ perf record: Captured and wrote 0.040 MB perf.data ]
$ perf script -D --no-itrace | grep AUX | grep -F '[T]'
Warning:
AUX data lost 2 times out of 3! 1 113720802995 0x4948 [0x40]: PERF_RECORD_AUX offset: 0 size: 0x2000 flags: 0x1 [T]
1 113720979812 0x6b10 [0x40]: PERF_RECORD_AUX offset: 0x2000 size: 0x2000 flags: 0x1 [T]--- arch/x86/events/intel/pt.c | 11 ++++++++--- arch/x86/events/intel/pt.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-)
arch/x86/events/intel/pt.c +8 -3
@@ -827,11 +827,13 @@ static void pt_buffer_advance(struct pt_ buf->cur_idx++;if (buf->cur_idx == buf->cur->last) { -if (buf->cur == buf->last) +if (buf->cur == buf->last) { buf->cur = buf->first; -else + buf->wrapped = true; + }else { buf->cur = list_entry(buf->cur->list.next, struct topa, list); + } buf->cur_idx =0 ; } }
@@ -845,8 +847,11 @@ static void pt_buffer_advance(struct pt_static void pt_update_head (struct pt *pt) {struct pt_buffer *buf =perf_get_aux (&pt->handle); +bool wrapped = buf->wrapped;u64 topa_idx, base, old; + buf->wrapped = false; +if (buf->single) {local_set (&buf->data_size, buf->output_off);return ;
@@ -864,7 +869,7 @@ static void pt_update_head(struct pt *pt }else { old = (local64_xchg (&buf->head, base) & ((buf->nr_pages <<PAGE_SHIFT ) -1 )); -if (base < old) +if (base < old || (base == old && wrapped)) base += buf->nr_pages <<PAGE_SHIFT ;local_add (base - old, &buf->data_size);
arch/x86/events/intel/pt.h +2 -0
@@ -65,6 +65,7 @@ struct pt_pmu {* @head: logical write offset inside the buffer * @snapshot: if this is for a snapshot/overwrite counter * @single: use Single Range Output instead of ToPA +* @wrapped: buffer advance wrapped back to the first topa table * @stop_pos: STOP topa entry index * @intr_pos: INT topa entry index * @stop_te: STOP topa entry pointer
@@ -82,6 +83,7 @@ struct pt_buffer {local64_t head;bool snapshot;bool single; +bool wrapped;long stop_pos, intr_pos;struct topa_entry *stop_te, *intr_te;void **data_pages;
Greg Kroah-Hartman
maintainerPATCH 368/772 crypto: x86/aegis128 - access 32-bit arguments as 32-bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 3b2f2d22fb424e9bebda4dbf6676cbfc7f9f62cd upstream.
Fix the AEGIS assembly code to access 'unsigned int' arguments as 32-bit values instead of 64-bit, since the upper bits of the corresponding 64-bit registers are not guaranteed to be zero.
Note: there haven't been any reports of this bug actually causing incorrect behavior. Neither gcc nor clang guarantee zero-extension to 64 bits, but zero-extension is likely to happen in practice because most instructions that operate on 32-bit registers zero-extend to 64 bits.
--- arch/x86/crypto/aegis128-aesni-asm.S | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
arch/x86/crypto/aegis128-aesni-asm.S +15 -14
@@ -21,7 +21,7 @@ #define T1 %xmm7 #define STATEP %rdi -#define LEN %rsi +#define LEN %esi #define SRC %rdx #define DST %rcx
@@ -76,32 +76,32 @@ SYM_FUNC_START_LOCAL(__load_partial) xor %r9d, %r9d pxor MSG, MSG - mov LEN, %r8 + mov LEN, %r8d and $0x1, %r8 jz .Lld_partial_1 - mov LEN, %r8 + mov LEN, %r8d and $0x1E, %r8 add SRC, %r8 mov (%r8), %r9b .Lld_partial_1: - mov LEN, %r8 + mov LEN, %r8d and $0x2, %r8 jz .Lld_partial_2 - mov LEN, %r8 + mov LEN, %r8d and $0x1C, %r8 add SRC, %r8 shl $0x10, %r9 mov (%r8), %r9w .Lld_partial_2: - mov LEN, %r8 + mov LEN, %r8d and $0x4, %r8 jz .Lld_partial_4 - mov LEN, %r8 + mov LEN, %r8d and $0x18, %r8 add SRC, %r8 shl $32, %r9
@@ -111,11 +111,11 @@ SYM_FUNC_START_LOCAL(__load_partial) .Lld_partial_4: movq %r9, MSG - mov LEN, %r8 + mov LEN, %r8d and $0x8, %r8 jz .Lld_partial_8 - mov LEN, %r8 + mov LEN, %r8d and $0x10, %r8 add SRC, %r8 pslldq $8, MSG
@@ -139,7 +139,7 @@ SYM_FUNC_END(__load_partial) * %r10 */ SYM_FUNC_START_LOCAL(__store_partial) - mov LEN, %r8 + mov LEN, %r8d mov DST, %r9 movq T0, %r10
@@ -677,7 +677,7 @@ SYM_TYPED_FUNC_START(crypto_aegis128_aes call __store_partial /* mask with byte count: */ - movq LEN, T0 + movd LEN, T0 punpcklbw T0, T0 punpcklbw T0, T0 punpcklbw T0, T0
@@ -702,7 +702,8 @@ SYM_FUNC_END(crypto_aegis128_aesni_dec_t /* * void crypto_aegis128_aesni_final(void *state, void *tag_xor, - * u64 assoclen, u64 cryptlen); + * unsigned int assoclen, + * unsigned int cryptlen); */ SYM_FUNC_START(crypto_aegis128_aesni_final) FRAME_BEGIN
@@ -715,8 +716,8 @@ SYM_FUNC_START(crypto_aegis128_aesni_fin movdqu 0x40(STATEP), STATE4 /* prepare length block: */ - movq %rdx, MSG - movq %rcx, T0 + movd %edx, MSG + movd %ecx, T0 pslldq $8, T0 pxor T0, MSG psllq $3, MSG /* multiply by 8 (to get bit count) */
Greg Kroah-Hartman
maintainerPATCH 369/772 KVM: x86/mmu: Skip the "try unsync" path iff the old SPTE was a leaf SPTE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 2867eb782cf7f64c2ac427596133b6f9c3f64b7a upstream.
Apply make_spte()'s optimization to skip trying to unsync shadow pages if and only if the old SPTE was a leaf SPTE, as non-leaf SPTEs in direct MMUs are always writable, i.e. could trigger a false positive and incorrectly lead to KVM creating a SPTE without write-protecting or marking shadow pages unsync.
This bug only affects the TDP MMU, as the shadow MMU only overwrites a shadow-present SPTE when synchronizing SPTEs (and only 4KiB SPTEs can be unsync). Specifically, mmu_set_spte() drops any non-leaf SPTEs *before* calling make_spte(), whereas the TDP MMU can do a direct replacement of a page table with the leaf SPTE.
Opportunistically update the comment to explain why skipping the unsync stuff is safe, as opposed to simply saying "it's someone else's problem".
Message-ID: <[email protected]>
--- arch/x86/kvm/mmu/spte.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu/spte.c +13 -5
@@ -194,12 +194,20 @@ bool make_spte(struct kvm_vcpu *vcpu, st spte |=PT_WRITABLE_MASK | shadow_mmu_writable_mask;/* -* Optimization: for pte sync, if spte was writable the hash -* lookup is unnecessary (and expensive). Write protection -* is responsibility of kvm_mmu_get_page / kvm_mmu_sync_roots. -* Same reasoning can be applied to dirty page accounting. +* When overwriting an existing leaf SPTE, and the old SPTE was +* writable, skip trying to unsync shadow pages as any relevant +* shadow pages must already be unsync, i.e. the hash lookup is +* unnecessary (and expensive). +* +* The same reasoning applies to dirty page/folio accounting; +* KVM will mark the folio dirty using the old SPTE, thus +* there's no need to immediately mark the new SPTE as dirty. +* +* Note, both cases rely on KVM not changing PFNs without first +* zapping the old SPTE, which is guaranteed by both the shadow +* MMU and the TDP MMU. */ -if (is_writable_pte (old_spte)) +if (is_last_spte (old_spte, level) &&is_writable_pte (old_spte)) goto out;/*
Greg Kroah-Hartman
maintainerPATCH 370/772 powerpc/pseries: Fix KVM guest detection for disabling hardlockup detector
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <[email protected]>
commit 44e5d21e6d3fd2a1fed7f0327cf72e99397e2eaf upstream.
As per the kernel documentation[1], hardlockup detector should be disabled in KVM guests as it may give false positives. On PPC, hardlockup detector is enabled inside KVM guests because disable_hardlockup_detector() is marked as early_initcall and it relies on kvm_guest static key (is_kvm_guest()) which is initialized later during boot by check_kvm_guest(), which is a core_initcall. check_kvm_guest() is also called in pSeries_smp_probe(), which is called before initcalls, but it is skipped if KVM guest does not have doorbell support or if the guest is launched with SMT=1.
Call check_kvm_guest() in disable_hardlockup_detector() so that is_kvm_guest() check goes through fine and hardlockup detector can be disabled inside the KVM guest.
[1]: Documentation/admin-guide/sysctl/kernel.rst
--- arch/powerpc/kernel/setup_64.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/setup_64.c +1 -0
@@ -924,6 +924,7 @@ static int __init disable_hardlockup_dethardlockup_detector_disable ();#else if (firmware_has_feature (FW_FEATURE_LPAR )) { +check_kvm_guest ();if (is_kvm_guest ())hardlockup_detector_disable (); }
Greg Kroah-Hartman
maintainerPATCH 371/772 KVM: arm64: vgic-v3: Sanitise guest writes to GICR_INVLPIR
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit d561491ba927cb5634094ff311795e9d618e9b86 upstream.
Make sure we filter out non-LPI invalidation when handling writes to GICR_INVLPIR.
--- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic-mmio-v3.c +6 -1
@@ -555,6 +555,7 @@ static void vgic_mmio_write_invlpi(struc unsigned long val) {struct vgic_irq *irq; +u32 intid;/* * If the guest wrote only to the upper 32bit part of the
@@ -566,9 +567,13 @@ static void vgic_mmio_write_invlpi(strucif ((addr &4 ) || !vgic_lpis_enabled (vcpu))return ; + intid =lower_32_bits (val); +if (intid <VGIC_MIN_LPI ) +return ; +vgic_set_rdist_busy (vcpu, true); - irq =vgic_get_irq (vcpu->kvm,NULL ,lower_32_bits (val)); + irq =vgic_get_irq (vcpu->kvm,NULL , intid);if (irq) {vgic_its_inv_lpi (vcpu->kvm, irq);vgic_put_irq (vcpu->kvm, irq);
Greg Kroah-Hartman
maintainerPATCH 372/772 KVM: arm64: Ignore PMCNTENSET_EL0 while checking for overflow status
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raghavendra Rao Ananta <[email protected]>
commit 54bbee190d42166209185d89070c58a343bf514b upstream.
DDI0487K.a D13.3.1 describes the PMU overflow condition, which evaluates to true if any counter's global enable (PMCR_EL0.E), overflow flag (PMOVSSET_EL0[n]), and interrupt enable (PMINTENSET_EL1[n]) are all 1. Of note, this does not require a counter to be enabled
(i.e. PMCNTENSET_EL0[n] = 1) to generate an overflow.
Align kvm_pmu_overflow_status() with the reality of the architecture and stop using PMCNTENSET_EL0 as part of the overflow condition. The bug was discovered while running an SBSA PMU test [*], which only sets PMCR.E, PMOVSSET<0>, PMINTENSET<0>, and expects an overflow interrupt.
--- arch/arm64/kvm/pmu-emul.c | 1 - 1 file changed, 1 deletion(-)
arch/arm64/kvm/pmu-emul.c +0 -1
@@ -294,7 +294,6 @@ static u64 kvm_pmu_overflow_status(strucif ((__vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) { reg =__vcpu_sys_reg (vcpu,PMOVSSET_EL0 ); - reg &=__vcpu_sys_reg (vcpu,PMCNTENSET_EL0 ); reg &=__vcpu_sys_reg (vcpu,PMINTENSET_EL1 ); }
Greg Kroah-Hartman
maintainerPATCH 373/772 PCI: Fix use-after-free of slot->bus on hot remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit c7acef99642b763ba585f4a43af999fcdbcc3dc4 upstream.
Dennis reports a boot crash on recent Lenovo laptops with a USB4 dock.
Since commit 0fc70886569c ("thunderbolt: Reset USB4 v2 host router") and commit 59a54c5f3dbd ("thunderbolt: Reset topology created by the boot firmware"), USB4 v2 and v1 Host Routers are reset on probe of the thunderbolt driver.
The reset clears the Presence Detect State and Data Link Layer Link Active bits at the USB4 Host Router's Root Port and thus causes hot removal of the dock.
The crash occurs when pciehp is unbound from one of the dock's Downstream
Ports: pciehp creates a pci_slot on bind and destroys it on unbind. The pci_slot contains a pointer to the pci_bus below the Downstream Port, but a reference on that pci_bus is never acquired. The pci_bus is destroyed before the pci_slot, so a use-after-free ensues when pci_slot_release() accesses slot->bus.
In principle this should not happen because pci_stop_bus_device() unbinds pciehp (and therefore destroys the pci_slot) before the pci_bus is destroyed by pci_remove_bus_device().
However the stacktrace provided by Dennis shows that pciehp is unbound from pci_remove_bus_device() instead of pci_stop_bus_device(). To understand the significance of this, one needs to know that the PCI core uses a two step process to remove a portion of the hierarchy: It first unbinds all drivers in the sub-hierarchy in pci_stop_bus_device() and then actually removes the devices in pci_remove_bus_device(). There is no precaution to prevent driver binding in-between pci_stop_bus_device() and pci_remove_bus_device().
In Dennis' case, it seems removal of the hierarchy by pciehp races with driver binding by pci_bus_add_devices(). pciehp is bound to the Downstream Port after pci_stop_bus_device() has run, so it is unbound by pci_remove_bus_device() instead of pci_stop_bus_device(). Because the pci_bus has already been destroyed at that point, accesses to it result in a use-after-free.
One might conclude that driver binding needs to be prevented after pci_stop_bus_device() has run. However it seems risky that pci_slot points to pci_bus without holding a reference. Solely relying on correct ordering of driver unbind versus pci_bus destruction is certainly not defensive programming.
If pci_slot has a need to access data in pci_bus, it ought to acquire a reference. Amend pci_create_slot() accordingly. Dennis reports that the crash is not reproducible with this change.
Abridged stacktrace:
pcieport 0000:00:07.0: PME: Signaling with IRQ 156
pcieport 0000:00:07.0: pciehp: Slot #12 AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise+ Interlock- NoCompl+ IbPresDis- LLActRep+ pci_bus 0000:20: dev 00, created physical slot 12
pcieport 0000:00:07.0: pciehp: Slot(12): Card not present
...
pcieport 0000:21:02.0: pciehp: pcie_disable_notification: SLOTCTRL d8 write cmd 0
Oops: general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b6b: 0000 [#1] PREEMPT SMP NOPTI CPU: 13 UID: 0 PID: 134 Comm: irq/156-pciehp Not tainted 6.11.0-devel+ #1 RIP: 0010:dev_driver_string+0x12/0x40 pci_destroy_slot pciehp_remove pcie_port_remove_service device_release_driver_internal bus_remove_device device_del device_unregister remove_iter device_for_each_child pcie_portdrv_remove pci_device_remove device_release_driver_internal bus_remove_device device_del pci_remove_bus_device (recursive invocation) pci_remove_bus_device pciehp_unconfigure_device pciehp_disable_slot pciehp_handle_presence_or_link_change pciehp_ist
--- drivers/pci/slot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/slot.c +3 -1
@@ -79,6 +79,7 @@ static void pci_slot_release(struct kobjup_read (&pci_bus_sem);list_del (&slot->list); +pci_bus_put (slot->bus);kfree (slot); }
@@ -261,7 +262,7 @@ placeholder: goto err; } - slot->bus = parent; + slot->bus =pci_bus_get (parent); slot->number = slot_nr; slot->kobj.kset = pci_slots_kset;
@@ -269,6 +270,7 @@ placeholder: slot_name =make_slot_name (name);if (!slot_name) { err = -ENOMEM ; +pci_bus_put (slot->bus);kfree (slot); goto err; }
Greg Kroah-Hartman
maintainerPATCH 374/772 fsnotify: fix sending inotify event with unexpected filename
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit aa52c54da40d9eee3ba87c05cdcb0cd07c04fa13 upstream.
We got a report that adding a fanotify filsystem watch prevents tail -f from receiving events.
Reproducer:
1. Create 3 windows / login sessions. Become root in each session.
2. Choose a mounted filesystem that is pretty quiet; I picked /boot.
3. In the first window, run: fsnotifywait -S -m /boot
4. In the second window, run: echo data >> /boot/foo
5. In the third window, run: tail -f /boot/foo
6. Go back to the second window and run: echo more data >> /boot/foo
7. Observe that the tail command doesn't show the new data.
8. In the first window, hit control-C to interrupt fsnotifywait.
9. In the second window, run: echo still more data >> /boot/foo
10. Observe that the tail command in the third window has now printed the missing data.
When stracing tail, we observed that when fanotify filesystem mark is set, tail does get the inotify event, but the event is receieved with the filename:
read(4, "\1\0\0\0\2\0\0\0\0\0\0\0\20\0\0\0foo\0\0\0\0\0\0\0\0\0\0\0\0\0",
50) = 32
This is unexpected, because tail is watching the file itself and not its parent and is inconsistent with the inotify event received by tail when fanotify filesystem mark is not set:
read(4, "\1\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0", 50) = 16
The inteference between different fsnotify groups was caused by the fact that the mark on the sb requires the filename, so the filename is passed to fsnotify(). Later on, fsnotify_handle_event() tries to take care of not passing the filename to groups (such as inotify) that are interested in the filename only when the parent is watching.
But the logic was incorrect for the case that no group is watching the parent, some groups are watching the sb and some watching the inode.
--- fs/notify/fsnotify.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
fs/notify/fsnotify.c +13 -10
@@ -310,16 +310,19 @@ static int fsnotify_handle_event(structif (!inode_mark)return 0 ; -if (mask &FS_EVENT_ON_CHILD ) { -/* -* Some events can be sent on both parent dir and child marks -* (e.g. FS_ATTRIB). If both parent dir and child are -* watching, report the event once to parent dir with name (if -* interested) and once to child without name (if interested). -* The child watcher is expecting an event without a file name -* and without the FS_EVENT_ON_CHILD flag. -*/ - mask &= ~FS_EVENT_ON_CHILD ; +/* +* Some events can be sent on both parent dir and child marks (e.g. +* FS_ATTRIB). If both parent dir and child are watching, report the +* event once to parent dir with name (if interested) and once to child +* without name (if interested). +* +* In any case regardless whether the parent is watching or not, the +* child watcher is expecting an event without the FS_EVENT_ON_CHILD +* flag. The file name is expected if and only if this is a directory +* event. +*/ + mask &= ~FS_EVENT_ON_CHILD ; +if (!(mask &ALL_FSNOTIFY_DIRENT_EVENTS )) { dir =NULL ; name =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 375/772 comedi: Flush partial mappings in error case
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit ce8f9fb651fac95dd41f69afe54d935420b945bd upstream.
If some remap_pfn_range() calls succeeded before one failed, we still have buffer pages mapped into the userspace page tables when we drop the buffer reference with comedi_buf_map_put(bm). The userspace mappings are only cleaned up later in the mmap error path.
Fix it by explicitly flushing all mappings in our VMA on the error path.
See commit 79a61cc3fc04 ("mm: avoid leaving partial pfn mappings around in error case").
--- drivers/comedi/comedi_fops.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/comedi/comedi_fops.c +12 -0
@@ -2402,6 +2402,18 @@ static int comedi_mmap(struct file *file start +=PAGE_SIZE ; } + +#ifdef CONFIG_MMU +/* +* Leaving behind a partial mapping of a buffer we're about to +* drop is unsafe, see remap_pfn_range_notrack(). +* We need to zap the range here ourselves instead of relying +* on the automatic zapping in remap_pfn_range() because we call +* remap_pfn_range() in a loop. +*/ +if (retval) +zap_vma_ptes (vma, vma->vm_start, size); +#endif }if (retval ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 376/772 apparmor: test: Fix memory leak for aa_unpack_strdup()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 7290f59231910ccba427d441a6e8b8c6f6112448 upstream.
The string allocated by kmemdup() in aa_unpack_strdup() is not freed and cause following memory leaks, free them to fix it.
unreferenced object 0xffffff80c6af8a50 (size 8): comm "kunit_try_catch", pid 225, jiffies 4294894407 hex dump (first 8 bytes): 74 65 73 74 69 6e 67 00 testing. backtrace (crc 5eab668b): [<0000000001e3714d>] kmemleak_alloc+0x34/0x40 [<000000006e6c7776>] __kmalloc_node_track_caller_noprof+0x300/0x3e0 [<000000006870467c>] kmemdup_noprof+0x34/0x60 [<000000001176bb03>] aa_unpack_strdup+0xd0/0x18c [<000000008ecde918>] policy_unpack_test_unpack_strdup_with_null_name+0xf8/0x3ec [<0000000032ef8f77>] kunit_try_run_case+0x13c/0x3ac [<00000000f3edea23>] kunit_generic_run_threadfn_adapter+0x80/0xec [<00000000adf936cf>] kthread+0x2e8/0x374 [<0000000041bb1628>] ret_from_fork+0x10/0x20 unreferenced object 0xffffff80c2a29090 (size 8): comm "kunit_try_catch", pid 227, jiffies 4294894409 hex dump (first 8 bytes): 74 65 73 74 69 6e 67 00 testing. backtrace (crc 5eab668b): [<0000000001e3714d>] kmemleak_alloc+0x34/0x40 [<000000006e6c7776>] __kmalloc_node_track_caller_noprof+0x300/0x3e0 [<000000006870467c>] kmemdup_noprof+0x34/0x60 [<000000001176bb03>] aa_unpack_strdup+0xd0/0x18c [<0000000046a45c1a>] policy_unpack_test_unpack_strdup_with_name+0xd0/0x3c4 [<0000000032ef8f77>] kunit_try_run_case+0x13c/0x3ac [<00000000f3edea23>] kunit_generic_run_threadfn_adapter+0x80/0xec [<00000000adf936cf>] kthread+0x2e8/0x374 [<0000000041bb1628>] ret_from_fork+0x10/0x20
--- security/apparmor/policy_unpack_test.c | 6 ++++++ 1 file changed, 6 insertions(+)
security/apparmor/policy_unpack_test.c +6 -0
@@ -286,6 +286,8 @@ static void policy_unpack_test_unpack_st ((uintptr_t )puf->e->start <= (uintptr_t )string) && ((uintptr_t)string <= (uintptr_t)puf->e->end));KUNIT_EXPECT_STREQ (test, string,TEST_STRING_DATA ); + +kfree (string); }static void policy_unpack_test_unpack_strdup_with_name (struct kunit *test)
@@ -301,6 +303,8 @@ static void policy_unpack_test_unpack_st ((uintptr_t )puf->e->start <= (uintptr_t )string) && ((uintptr_t)string <= (uintptr_t)puf->e->end));KUNIT_EXPECT_STREQ (test, string,TEST_STRING_DATA ); + +kfree (string); }static void policy_unpack_test_unpack_strdup_out_of_bounds (struct kunit *test)
@@ -318,6 +322,8 @@ static void policy_unpack_test_unpack_stKUNIT_EXPECT_EQ (test, size,0 );KUNIT_EXPECT_NULL (test, string);KUNIT_EXPECT_PTR_EQ (test, puf->e->pos, start); + +kfree (string); }static void policy_unpack_test_unpack_nameX_with_null_name (struct kunit *test)
Greg Kroah-Hartman
maintainerPATCH 377/772 tty: ldsic: fix tty_ldisc_autoload sysctls proc_handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Bouchinet <[email protected]>
commit 635a9fca54f4f4148be1ae1c7c6bd37af80f5773 upstream.
Commit 7c0cca7c847e ("tty: ldisc: add sysctl to prevent autoloading of ldiscs") introduces the tty_ldisc_autoload sysctl with the wrong proc_handler. .extra1 and .extra2 parameters are set to avoid other values thant SYSCTL_ZERO or SYSCTL_ONE to be set but proc_dointvec do not uses them.
This commit fixes this by using proc_dointvec_minmax instead of proc_dointvec.
--- drivers/tty/tty_ldisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_ldisc.c +1 -1
@@ -830,7 +830,7 @@ static struct ctl_table tty_table[] = { .data = &tty_ldisc_autoload, .maxlen = sizeof(tty_ldisc_autoload), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, },
Greg Kroah-Hartman
maintainerPATCH 378/772 locking/lockdep: Avoid creating new name string literals in lockdep_set_subclass()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Ehab <[email protected]>
commit d7fe143cb115076fed0126ad8cf5ba6c3e575e43 upstream.
Syzbot reports a problem that a warning will be triggered while searching a lock class in look_up_lock_class().
The cause of the issue is that a new name is created and used by lockdep_set_subclass() instead of using the existing one. This results in a lock instance has a different name pointer than previous registered one stored in lock class, and WARN_ONCE() is triggered because of that in look_up_lock_class().
To fix this, change lockdep_set_subclass() to use the existing name instead of a new one. Hence, no new name will be created by lockdep_set_subclass(). Hence, the warning is avoided.
[boqun: Reword the commit log to state the correct issue]
--- include/linux/lockdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lockdep.h +1 -1
@@ -229,7 +229,7 @@ static inline void lockdep_init_map(stru (lock)->dep_map.lock_type)#define lockdep_set_subclass (lock, sub) \ - lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\ + lockdep_init_map_type(&(lock)->dep_map, (lock)->dep_map.name, (lock)->dep_map.key, sub,\ (lock)->dep_map.wait_type_inner, \ (lock)->dep_map.wait_type_outer, \ (lock)->dep_map.lock_type)
Greg Kroah-Hartman
maintainerPATCH 379/772 pinctrl: qcom: spmi: fix debugfs drive strength
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6bc0ebfb1d920f13c522545f114cdabb49e9408a upstream.
Commit 723e8462a4fe ("pinctrl: qcom: spmi-gpio: Fix the GPIO strength mapping") fixed a long-standing issue in the Qualcomm SPMI PMIC gpio driver which had the 'low' and 'high' drive strength settings switched but failed to update the debugfs interface which still gets this wrong.
Fix the debugfs code so that the exported values match the hardware settings.
Note that this probably means that most devicetrees that try to describe the firmware settings got this wrong if the settings were derived from debugfs. Before the above mentioned commit the settings would have actually matched the firmware settings even if they were described incorrectly, but now they are inverted.
--- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +1 -1
@@ -665,7 +665,7 @@ static void pmic_gpio_config_dbg_show(st "push-pull", "open-drain", "open-source" };static const char *const strengths[] = { -"no" ,"high" ,"medium" ,"low" +"no" ,"low" ,"medium" ,"high" }; pad = pctldev->desc->pins[pin].drv_data;
Greg Kroah-Hartman
maintainerPATCH 380/772 dt-bindings: iio: dac: ad3552r: fix maximum spi speed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Angelo Dureghello <[email protected]>
commit d1d1c117f39b2057d1e978f26a8bd9631ddb193b upstream.
Fix maximum SPI clock speed, as per datasheet (Rev. B, page 6).
--- Documentation/devicetree/bindings/iio/dac/adi,ad3552r.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/iio/dac/adi,ad3552r.yaml +1 -1
@@ -26,7 +26,7 @@ properties: maxItems: 1 spi-max-frequency: - maximum: 30000000 + maximum: 66000000 reset-gpios: maxItems: 1
Greg Kroah-Hartman
maintainerPATCH 381/772 exfat: fix uninit-value in __exfat_get_dentry_set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 02dffe9ab092fc4c8800aee68cb7eafd37a980c4 upstream.
There is no check if stream size and start_clu are invalid. If start_clu is EOF cluster and stream size is 4096, It will cause uninit value access. because ei->hint_femp.eidx could be 128(if cluster size is 4K) and wrong hint will allocate next cluster. and this cluster will be same with the cluster that is allocated by exfat_extend_valid_size(). The previous patch will check invalid start_clu, but for clarity, initialize hint_femp.eidx to zero.
--- fs/exfat/namei.c | 1 + 1 file changed, 1 insertion(+)
fs/exfat/namei.c +1 -0
@@ -364,6 +364,7 @@ static int exfat_find_empty_entry(structif (ei->start_clu ==EXFAT_EOF_CLUSTER ) { ei->start_clu = clu.dir; p_dir->dir = clu.dir; + hint_femp.eidx =0 ; }/* append to the FAT chain */
Greg Kroah-Hartman
maintainerPATCH 382/772 Bluetooth: Fix type of len in rfcomm_sock_getsockopt{,_old}()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrej Shadura <[email protected]>
commit 5fe6caa62b07fd39cd6a28acc8f92ba2955e11a6 upstream.
Commit 9bf4e919ccad worked around an issue introduced after an innocuous optimisation change in LLVM main:
Quoted 11 lines
len is defined as an 'int' because it is assigned from '
__userint *optlen'. However, it is clamped against the result ofsizeof(), which has a type of 'size_t' ('unsigned long' for 64-bit platforms). This is done withmin_t()becausemin()requires compatible types, which results in both len and the result ofsizeof()being casted to 'unsigned int', meaning len changes signs and the result ofsizeof()is truncated. From there, len is passed tocopy_to_user(), which has a third parameter type of 'unsigned long', so it is widened and changes signs again. This excessive casting in combination with the KCSAN instrumentation causes LLVM to fail to eliminate the__bad_copy_from()call, failing the build.
The same issue occurs in rfcomm in functions rfcomm_sock_getsockopt and rfcomm_sock_getsockopt_old.
Change the type of len to size_t in both rfcomm_sock_getsockopt and rfcomm_sock_getsockopt_old and replace min_t() with min().
Improves: 9bf4e919ccad ("Bluetooth: Fix type of len in {l2cap,sco}_sock_getsockopt_old()")
--- net/bluetooth/rfcomm/sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/bluetooth/rfcomm/sock.c +6 -4
@@ -729,7 +729,8 @@ static int rfcomm_sock_getsockopt_old(ststruct sock *l2cap_sk;struct l2cap_conn *conn;struct rfcomm_conninfo cinfo; -int len, err =0 ; +int err =0 ; +size_t len;u32 opt;BT_DBG ("sk %p" , sk);
@@ -783,7 +784,7 @@ static int rfcomm_sock_getsockopt_old(st cinfo.hci_handle = conn->hcon->handle;memcpy (cinfo.dev_class, conn->hcon->dev_class,3 ); - len = min_t(unsigned int, len, sizeof(cinfo)); + len =min (len,sizeof (cinfo));if (copy_to_user (optval, (char *) &cinfo, len)) err = -EFAULT ;
@@ -802,7 +803,8 @@ static int rfcomm_sock_getsockopt(struct {struct sock *sk = sock->sk;struct bt_security sec; -int len, err =0 ; +int err =0 ; +size_t len;BT_DBG ("sk %p" , sk);
@@ -827,7 +829,7 @@ static int rfcomm_sock_getsockopt(struct sec.level =rfcomm_pi (sk)->sec_level; sec.key_size =0 ; - len = min_t(unsigned int, len, sizeof(sec)); + len =min (len,sizeof (sec));if (copy_to_user (optval, (char *) &sec, len)) err = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 383/772 usb: xhci: Fix TD invalidation under pending Set TR Dequeue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
commit 484c3bab2d5dfa13ff659a51a06e9a393141eefc upstream.
xhci_invalidate_cancelled_tds() may not work correctly if the hardware is modifying endpoint or stream contexts at the same time by executing a Set TR Dequeue command. And even if it worked, it would be unable to queue Set TR Dequeue for the next stream, failing to clear xHC cache.
On stream endpoints, a chain of Set TR Dequeue commands may take some time to execute and we may want to cancel more TDs during this time. Currently this leads to Stop Endpoint completion handler calling this function without testing for SET_DEQ_PENDING, which will trigger the aforementioned problems when it happens.
On all endpoints, a halt condition causes Reset Endpoint to be queued and an error status given to the class driver, which may unlink more URBs in response. Stop Endpoint is queued and its handler may execute concurrently with Set TR Dequeue queued by Reset Endpoint handler.
(Reset Endpoint handler calls this function too, but there seems to be no possibility of it running concurrently with Set TR Dequeue).
Fix xhci_invalidate_cancelled_tds() to work correctly under a pending Set TR Dequeue. Bail out of the function when SET_DEQ_PENDING is set, then make the completion handler call the function again and also call xhci_giveback_invalidated_tds(), which needs to be called next.
This seems to fix another potential bug, where the handler would call xhci_invalidate_cancelled_tds(), which may clear some deferred TDs if a sanity check fails, and the TDs wouldn't be given back promptly.
Said sanity check seems to be wrong and prone to false positives when the endpoint halts, but fixing it is beyond the scope of this change, besides ensuring that cleared TDs are given back properly.
--- drivers/usb/host/xhci-ring.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-ring.c +13 -5
@@ -954,6 +954,13 @@ static int xhci_invalidate_cancelled_tdsunsigned int slot_id = ep->vdev->slot_id;int err; +/* +* This is not going to work if the hardware is changing its dequeue +* pointers as we look at them. Completion handler will call us later. +*/ +if (ep->ep_state &SET_DEQ_PENDING ) +return 0 ; + xhci = ep->xhci;list_for_each_entry_safe (td, tmp_td, &ep->cancelled_td_list, cancelled_td_list) {
@@ -1324,7 +1331,6 @@ static void xhci_handle_cmd_set_deq(strustruct xhci_ep_ctx *ep_ctx;struct xhci_slot_ctx *slot_ctx;struct xhci_td *td, *tmp_td; -bool deferred = false; ep_index =TRB_TO_EP_INDEX (le32_to_cpu (trb->generic.field[3 ])); stream_id =TRB_TO_STREAM_ID (le32_to_cpu (trb->generic.field[2 ]));
@@ -1425,8 +1431,6 @@ static void xhci_handle_cmd_set_deq(struxhci_dbg (ep->xhci,"%s: Giveback cancelled URB %p TD\n" , __func__, td->urb);xhci_td_cleanup (ep->xhci, td, ep_ring, td->status); - }else if (td->cancel_status ==TD_CLEARING_CACHE_DEFERRED ) { - deferred = true; }else {xhci_dbg (ep->xhci,"%s: Keep cancelled URB %p TD as cancel_status is %d\n" , __func__, td->urb, td->cancel_status);
@@ -1437,11 +1441,15 @@ cleanup: ep->queued_deq_seg =NULL ; ep->queued_deq_ptr =NULL ; -if (deferred) { -/* We have more streams to clear */ +/* Check for deferred or newly cancelled TDs */ +if (!list_empty (&ep->cancelled_td_list)) {xhci_dbg (ep->xhci,"%s: Pending TDs to clear, continuing with invalidation\n" , __func__);xhci_invalidate_cancelled_tds (ep); +/* Try to restart the endpoint if all is done */ +ring_doorbell_for_active_rings (xhci, slot_id, ep_index); +/* Start giving back any TDs invalidated above */ +xhci_giveback_invalidated_tds (ep); }else {/* Restart any rings with pending URBs */ xhci_dbg (ep->xhci,"%s: All TDs cleared, ring doorbell\n" , __func__);
Greg Kroah-Hartman
maintainerPATCH 384/772 driver core: bus: Fix double free in driver API bus_register()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
commit bfa54a793ba77ef696755b66f3ac4ed00c7d1248 upstream.
For bus_register(), any error which happens after kset_register() will cause that @priv are freed twice, fixed by setting @priv with NULL after the first free.
--- drivers/base/bus.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/bus.c +2 -0
@@ -853,6 +853,8 @@ bus_devices_fail:bus_remove_file (bus, &bus_attr_uevent); bus_uevent_fail:kset_unregister (&bus->p->subsys); +/* Above kset_unregister() will kfree @bus->p */ + bus->p =NULL ; out:kfree (bus->p); bus->p =NULL ;
Greg Kroah-Hartman
maintainerPATCH 385/772 wifi: rtlwifi: Drastically reduce the attempts to read efuse in case of failures
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
commit 5c1b544563005a00591a3aa86ecff62ed4d11be3 upstream.
Syzkaller reported a hung task with uevent_show() on stack trace. That specific issue was addressed by another commit [0], but even with that fix applied (for example, running v6.12-rc5) we face another type of hung task that comes from the same reproducer [1]. By investigating that, we could narrow it to the following path:
(a) Syzkaller emulates a Realtek USB WiFi adapter using raw-gadget and dummy_hcd infrastructure.
(b) During the probe of rtl8192cu, the driver ends-up performing an efuse read procedure (which is related to EEPROM load IIUC), and here lies the
issue: the function read_efuse() calls read_efuse_byte() many times, as loop iterations depending on the efuse size (in our example, 512 in total).
This procedure for reading efuse bytes relies in a loop that performs an I/O read up to *10k* times in case of failures. We measured the time of the loop inside read_efuse_byte() alone, and in this reproducer (which involves the dummy_hcd emulation layer), it takes 15 seconds each. As a consequence, we have the driver stuck in its probe routine for big time, exposing a stack trace like below if we attempt to reboot the system, for example:
task:kworker/0:3 state:D stack:0 pid:662 tgid:662 ppid:2 flags:0x00004000
Workqueue: usb_hub_wq hub_event Call Trace: __schedule+0xe22/0xeb6 schedule_timeout+0xe7/0x132 __wait_for_common+0xb5/0x12e usb_start_wait_urb+0xc5/0x1ef ? usb_alloc_urb+0x95/0xa4 usb_control_msg+0xff/0x184 _usbctrl_vendorreq_sync+0xa0/0x161 _usb_read_sync+0xb3/0xc5 read_efuse_byte+0x13c/0x146 read_efuse+0x351/0x5f0 efuse_read_all_map+0x42/0x52 rtl_efuse_shadow_map_update+0x60/0xef rtl_get_hwinfo+0x5d/0x1c2 rtl92cu_read_eeprom_info+0x10a/0x8d5 ? rtl92c_read_chip_version+0x14f/0x17e rtl_usb_probe+0x323/0x851 usb_probe_interface+0x278/0x34b really_probe+0x202/0x4a4 __driver_probe_device+0x166/0x1b2 driver_probe_device+0x2f/0xd8 [...]
We propose hereby to drastically reduce the attempts of doing the I/O reads in case of failures, restricted to USB devices (given that they're inherently slower than PCIe ones). By retrying up to 10 times (instead of 10000), we got reponsiveness in the reproducer, while seems reasonable to believe that there's no sane USB device implementation in the field requiring this amount of retries at every I/O read in order to properly work. Based on that assumption, it'd be good to have it backported to stable but maybe not since driver implementation (the 10k number comes from day 0), perhaps up to 6.x series makes sense.
[0] Commit 15fffc6a5624 ("driver core: Fix uevent_show() vs driver detach race")
[1] A note about that: this syzkaller report presents multiple reproducers that differs by the type of emulated USB device. For this specific case, check the entry from 2024/08/08 06:23 in the list of crashes; the C repro is available at https://syzkaller.appspot.com/text?tag=ReproC&x=1521fc83980000.
--- drivers/net/wireless/realtek/rtlwifi/efuse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/efuse.c +10 -1
@@ -162,10 +162,19 @@ void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value)void read_efuse_byte (struct ieee80211_hw *hw,u16 _offset,u8 *pbuf) {struct rtl_priv *rtlpriv =rtl_priv (hw); +u16 max_attempts =10000 ;u32 value32;u8 readbyte;u16 retry; +/* +* In case of USB devices, transfer speeds are limited, hence +* efuse I/O reads could be (way) slower. So, decrease (a lot) +* the read attempts in case of failures. +*/ +if (rtlpriv->rtlhal.interface ==INTF_USB ) + max_attempts =10 ; +rtl_write_byte (rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL ] +1 , (_offset &0xff )); readbyte =rtl_read_byte (rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL ] +2 );
@@ -178,7 +187,7 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) retry =0 ; value32 =rtl_read_dword (rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL ]); -while (!(((value32 >>24 ) &0xff ) &0x80 ) && (retry <10000 )) { +while (!(((value32 >>24 ) &0xff ) &0x80 ) && (retry < max_attempts)) { value32 =rtl_read_dword (rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL ]); retry++;
Signature · 1 line
2.47.1
Greg Kroah-Hartman
maintainerPATCH 386/772 wifi: brcmfmac: release root node in all execution paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit 2e19a3b590ebf2e351fc9d0e7c323430e65b6b6d upstream.
The fixed patch introduced an additional condition to enter the scope where the 'root' device_node is released (!settings->board_type, currently 'err'), which avoid decrementing the refcount with a call to of_node_put() if that second condition is not satisfied.
Move the call to of_node_put() to the point where 'root' is no longer required to avoid leaking the resource if err is not zero.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +1 -2
@@ -102,9 +102,8 @@ void brcmf_of_probe(struct device *dev, }strreplace (board_type,'/' ,'-' ); settings->board_type = board_type; - -of_node_put (root); } +of_node_put (root);if (!np || !of_device_is_compatible (np,"brcm,bcm4329-fmac" ))return ;
Greg Kroah-Hartman
maintainerPATCH 387/772 Revert "usb: gadget: composite: fix OS descriptors w_value logic"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Vrastil <[email protected]>
commit 51cdd69d6a857f527d6d0697a2e1f0fa8bca1005 upstream.
This reverts commit ec6ce7075ef879b91a8710829016005dc8170f17.
Fix installation of WinUSB driver using OS descriptors. Without the fix the drivers are not installed correctly and the property 'DeviceInterfaceGUID' is missing on host side.
The original change was based on the assumption that the interface number is in the high byte of wValue but it is in the low byte, instead. Unfortunately, the fix is based on MS documentation which is also wrong.
The actual USB request for OS descriptors (using USB analyzer) looks like:
Offset 0 1 2 3 4 5 6 7 0x000 C1 A1 02 00 05 00 0A 00
C1: bmRequestType (device to host, vendor, interface)
A1: nas magic number
0002: wValue (2: nas interface)
0005: wIndex (5: get extended property i.e. nas interface GUID) 008E: wLength (142)
The fix was tested on Windows 10 and Windows 11.
--- drivers/usb/gadget/composite.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/usb/gadget/composite.c +15 -3
@@ -2032,8 +2032,20 @@ unknown:memset (buf,0 , w_length); buf[5 ] =0x01 ;switch (ctrl->bRequestType &USB_RECIP_MASK ) { +/* +* The Microsoft CompatID OS Descriptor Spec(w_index = 0x4) and +* Extended Prop OS Desc Spec(w_index = 0x5) state that the +* HighByte of wValue is the InterfaceNumber and the LowByte is +* the PageNumber. This high/low byte ordering is incorrectly +* documented in the Spec. USB analyzer output on the below +* request packets show the high/low byte inverted i.e LowByte +* is the InterfaceNumber and the HighByte is the PageNumber. +* Since we dont support >64KB CompatID/ExtendedProp descriptors, +* PageNumber is set to 0. Hence verify that the HighByte is 0 +* for below two cases. +*/ case USB_RECIP_DEVICE : -if (w_index !=0x4 || (w_value &0xff )) +if (w_index !=0x4 || (w_value >>8 ))break ; buf[6 ] = w_index;/* Number of ext compat interfaces */
@@ -2049,9 +2061,9 @@ unknown: }break ;case USB_RECIP_INTERFACE : -if (w_index !=0x5 || (w_value &0xff )) +if (w_index !=0x5 || (w_value >>8 ))break ; - interface = w_value >>8 ; + interface = w_value &0xFF ;if (interface >=MAX_CONFIG_INTERFACES || !os_desc_cfg->interface[interface])break ;
Greg Kroah-Hartman
maintainerPATCH 388/772 serial: sh-sci: Clean sci_ports[0] after at earlycon exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
commit 3791ea69a4858b81e0277f695ca40f5aae40f312 upstream.
The early_console_setup() function initializes the sci_ports[0].port with an object of type struct uart_port obtained from the object of type struct earlycon_device received as argument by the early_console_setup().
It may happen that later, when the rest of the serial ports are probed, the serial port that was used as earlycon (e.g., port A) to be mapped to a different position in sci_ports[] and the slot 0 to be used by a different serial port (e.g., port B), as follows:
sci_ports[0] = port A
sci_ports[X] = port B
In this case, the new port mapped at index zero will have associated data that was used for earlycon.
In case this happens, after Linux boot, any access to the serial port that maps on sci_ports[0] (port A) will block the serial port that was used as earlycon (port B).
To fix this, add early_console_exit() that clean the sci_ports[0] at earlycon exit time.
--- drivers/tty/serial/sh-sci.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/tty/serial/sh-sci.c +28 -0
@@ -3432,6 +3432,32 @@ sh_early_platform_init_buffer("earlyprin#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON static struct plat_sci_port port_cfg__initdata ; +static int early_console_exit (struct console *co) +{ +struct sci_port *sci_port = &sci_ports[0 ]; +struct uart_port *port = &sci_port->port; +unsigned long flags; +int locked =1 ; + +if (port->sysrq) + locked =0 ; +else if (oops_in_progress) + locked =uart_port_trylock_irqsave (port, &flags); +else +uart_port_lock_irqsave (port, &flags); + +/* +* Clean the slot used by earlycon. A new SCI device might +* map to this slot. +*/ +memset (sci_ports,0 ,sizeof (*sci_port)); + +if (locked) +uart_port_unlock_irqrestore (port, flags); + +return 0 ; +} +static int __init early_console_setup (struct earlycon_device *device,int type) {
@@ -3450,6 +3476,8 @@ static int __init early_console_setup(st SCSCR_RE | SCSCR_TE | port_cfg.scscr); device->con->write = serial_console_write; + device->con->exit = early_console_exit; +return 0 ; } static int __init sci_early_console_setup(struct earlycon_device *device,
Greg Kroah-Hartman
maintainerPATCH 389/772 Revert "serial: sh-sci: Clean sci_ports[0] after at earlycon exit"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 718632467d88e98816fa01ab12681ef1c2aa56f8 upstream.
This reverts commit 3791ea69a4858b81e0277f695ca40f5aae40f312.
It was reported to cause boot-time issues, so revert it for now.
--- drivers/tty/serial/sh-sci.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
drivers/tty/serial/sh-sci.c +0 -28
@@ -3432,32 +3432,6 @@ sh_early_platform_init_buffer("earlyprin#ifdef CONFIG_SERIAL_SH_SCI_EARLYCON static struct plat_sci_port port_cfg__initdata ; -static int early_console_exit (struct console *co) -{ -struct sci_port *sci_port = &sci_ports[0 ]; -struct uart_port *port = &sci_port->port; -unsigned long flags; -int locked =1 ; - -if (port->sysrq) - locked =0 ; -else if (oops_in_progress) - locked =uart_port_trylock_irqsave (port, &flags); -else -uart_port_lock_irqsave (port, &flags); - -/* -* Clean the slot used by earlycon. A new SCI device might -* map to this slot. -*/ -memset (sci_ports,0 ,sizeof (*sci_port)); - -if (locked) -uart_port_unlock_irqrestore (port, flags); - -return 0 ; -} -static int __init early_console_setup (struct earlycon_device *device,int type) {
@@ -3476,8 +3450,6 @@ static int __init early_console_setup(st SCSCR_RE | SCSCR_TE | port_cfg.scscr); device->con->write = serial_console_write; - device->con->exit = early_console_exit; -return 0 ; } static int __init sci_early_console_setup(struct earlycon_device *device,
Greg Kroah-Hartman
maintainerPATCH 390/772 gpio: exar: set value when external pull-up or pull-down is present
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Kumar Cholleti <[email protected]>
commit 72cef64180de04a7b055b4773c138d78f4ebdb77 upstream.
Setting GPIO direction = high, sometimes results in GPIO value = 0.
If a GPIO is pulled high, the following construction results in the value being 0 when the desired value is 1:
$ echo "high" > /sys/class/gpio/gpio336/direction $ cat /sys/class/gpio/gpio336/value 0
Before the GPIO direction is changed from an input to an output, exar_set_value() is called with value = 1, but since the GPIO is an input when exar_set_value() is called, _regmap_update_bits() reads a 1 due to an external pull-up. regmap_set_bits() sets force_write = false, so the value (1) is not written. When the direction is then changed, the GPIO becomes an output with the value of 0 (the hardware default).
regmap_write_bits() sets force_write = true, so the value is always written by exar_set_value() and an external pull-up doesn't affect the outcome of setting direction = high.
The same can happen when a GPIO is pulled low, but the scenario is a little more complicated.
$ echo high > /sys/class/gpio/gpio351/direction $ cat /sys/class/gpio/gpio351/value 1
$ echo in > /sys/class/gpio/gpio351/direction $ cat /sys/class/gpio/gpio351/value 0
$ echo low > /sys/class/gpio/gpio351/direction $ cat /sys/class/gpio/gpio351/value 1
--- drivers/gpio/gpio-exar.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpio/gpio-exar.c +6 -4
@@ -99,11 +99,13 @@ static void exar_set_value(struct gpio_cstruct exar_gpio_chip *exar_gpio =gpiochip_get_data (chip);unsigned int addr =exar_offset_to_lvl_addr (exar_gpio, offset);unsigned int bit =exar_offset_to_bit (exar_gpio, offset); +unsigned int bit_value = value ?BIT (bit) :0 ; -if (value) -regmap_set_bits (exar_gpio->regmap, addr,BIT (bit)); -else -regmap_clear_bits (exar_gpio->regmap, addr,BIT (bit)); +/* +* regmap_write_bits() forces value to be written when an external +* pull up/down might otherwise indicate value was already set. +*/ +regmap_write_bits (exar_gpio->regmap, addr,BIT (bit), bit_value); } static int exar_direction_output(struct gpio_chip *chip, unsigned int offset,
Greg Kroah-Hartman
maintainerPATCH 391/772 netfilter: ipset: add missing range check in bitmap_ip_uadt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit 35f56c554eb1b56b77b3cf197a6b00922d49033d upstream.
When tb[IPSET_ATTR_IP_TO] is not present but tb[IPSET_ATTR_CIDR] exists, the values of ip and ip_to are slightly swapped. Therefore, the range check for ip should be done later, but this part is missing and it seems that the vulnerability occurs.
So we should add missing range checks and remove unnecessary range checks.
--- net/netfilter/ipset/ip_set_bitmap_ip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/netfilter/ipset/ip_set_bitmap_ip.c +2 -5
@@ -163,11 +163,8 @@ bitmap_ip_uadt(struct ip_set *set, struc ret =ip_set_get_hostipaddr4 (tb[IPSET_ATTR_IP_TO ], &ip_to);if (ret)return ret; -if (ip > ip_to) { +if (ip > ip_to)swap (ip, ip_to); -if (ip < map->first_ip) -return -IPSET_ERR_BITMAP_RANGE ; - } }else if (tb[IPSET_ATTR_CIDR ]) {u8 cidr =nla_get_u8 (tb[IPSET_ATTR_CIDR ]);
@@ -178,7 +175,7 @@ bitmap_ip_uadt(struct ip_set *set, struc ip_to = ip; } -if (ip_to > map->last_ip) +if (ip < map->first_ip || ip_to > map->last_ip)return -IPSET_ERR_BITMAP_RANGE ;for (; !before (ip_to, ip); ip += map->hosts) {
Greg Kroah-Hartman
maintainerPATCH 392/772 spi: Fix acpi deferred irq probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
commit d24cfee7f63d6b44d45a67c5662bd1cc48e8b3ca upstream.
When probing spi device take care of deferred probe of ACPI irq gpio similar like for OF/DT case.
Quoted 1 line
From practical standpoint this fixes issue with vsc-tp driver on
Dell XP 9340 laptop, which try to request interrupt with spi->irq equal to -EPROBE_DEFER and fail to probe with the following error:
vsc-tp spi-INTC10D0:00: probe with driver vsc-tp failed with error -22
--- drivers/spi/spi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/spi/spi.c +10 -3
@@ -425,6 +425,16 @@ static int spi_probe(struct device *dev) spi->irq =0 ; } +if (has_acpi_companion (dev) && spi->irq <0 ) { +struct acpi_device *adev =to_acpi_device_node (dev->fwnode); + + spi->irq =acpi_dev_gpio_irq_get (adev,0 ); +if (spi->irq == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +if (spi->irq <0 ) + spi->irq =0 ; + } + ret =dev_pm_domain_attach (dev, true);if (ret)return ret;
@@ -2697,9 +2707,6 @@ static acpi_status acpi_register_spi_devacpi_set_modalias (adev,acpi_device_hid (adev), spi->modalias,sizeof (spi->modalias)); -if (spi->irq <0 ) - spi->irq =acpi_dev_gpio_irq_get (adev,0 ); -acpi_device_set_enumerated (adev); adev->power.flags.ignore_parent = true;
Greg Kroah-Hartman
maintainerPATCH 393/772 mtd: spi-nor: core: replace dummy buswidth from addr to data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Ming Lin <[email protected]>
commit 98d1fb94ce75f39febd456d6d3cbbe58b6678795 upstream.
The default dummy cycle for Macronix SPI NOR flash in Octal Output Read Mode(1-1-8) is 20.
Currently, the dummy buswidth is set according to the address bus width. In the 1-1-8 mode, this means the dummy buswidth is 1. When converting dummy cycles to bytes, this results in 20 x 1 / 8 = 2 bytes, causing the host to read data 4 cycles too early.
Since the protocol data buswidth is always greater than or equal to the address buswidth. Setting the dummy buswidth to match the data buswidth increases the likelihood that the dummy cycle-to-byte conversion will be divisible, preventing the host from reading data prematurely.
--- drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +1 -1
@@ -90,7 +90,7 @@ void spi_nor_spimem_setup_op(const struc op->addr.buswidth =spi_nor_get_protocol_addr_nbits (proto);if (op->dummy.nbytes) - op->dummy.buswidth =spi_nor_get_protocol_addr_nbits (proto); + op->dummy.buswidth =spi_nor_get_protocol_data_nbits (proto);if (op->data.nbytes) op->data.buswidth =spi_nor_get_protocol_data_nbits (proto);
Greg Kroah-Hartman
maintainerPATCH 394/772 cpufreq: mediatek-hw: Fix wrong return value in mtk_cpufreq_get_cpu_power()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 172bf5ed04cb6c9e66d58de003938ed5c8756570 upstream.
mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in em_create_perf_table(), the later zero check for power is not invalid as power is uninitialized. As Lukasz suggested, it must return -EINVAL when the 'policy' is not found. So return -EINVAL to fix it.
--- drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/mediatek-cpufreq-hw.c +1 -1
@@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device policy =cpufreq_cpu_get_raw (cpu_dev->id);if (!policy) -return 0 ; +return -EINVAL ; data = policy->driver_data;
Greg Kroah-Hartman
maintainerPATCH 395/772 parisc/ftrace: Fix function graph tracing disablement
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit a5f05a138a8cac035bf9da9b6ed0e532bc7942c8 upstream.
Due to an apparent copy-paste bug, the parisc implementation of ftrace_disable_ftrace_graph_caller() doesn't actually do anything. It enables the (already-enabled) static key rather than disabling it.
The result is that after function graph tracing has been "disabled", any subsequent (non-graph) function tracing will inadvertently also enable the slow fgraph return address hijacking.
--- arch/parisc/kernel/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/ftrace.c +1 -1
@@ -87,7 +87,7 @@ int ftrace_enable_ftrace_graph_caller(voint ftrace_disable_ftrace_graph_caller (void ) { -static_key_enable (&ftrace_graph_enable.key); +static_key_disable (&ftrace_graph_enable.key);return 0 ; }#endif
Greg Kroah-Hartman
maintainerPATCH 396/772 platform/chrome: cros_ec_typec: fix missing fwnode reference decrement
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit 9c41f371457bd9a24874e3c7934d9745e87fbc58 upstream.
The device_for_each_child_node() macro requires explicit calls to fwnode_handle_put() upon early exits (return, break, goto) to decrement the fwnode's refcount, and avoid levaing a node reference behind.
Add the missing fwnode_handle_put() after the common label for all error paths.
--- drivers/platform/chrome/cros_ec_typec.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_ec_typec.c +1 -0
@@ -446,6 +446,7 @@ static int cros_typec_init_ports(structreturn 0 ; unregister_ports: +fwnode_handle_put (fwnode);cros_unregister_ports (typec);return ret; }
Greg Kroah-Hartman
maintainerPATCH 397/772 ubi: wl: Put source PEB into correct list if trying locking LEB failed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
commit d610020f030bec819f42de327c2bd5437d2766b3 upstream.
During wear-leveing work, the source PEB will be moved into scrub list when source LEB cannot be locked in ubi_eba_copy_leb(), which is wrong for non-scrub type source PEB. The problem could bring extra and ineffective wear-leveing jobs, which makes more or less negative effects for the life time of flash. Specifically, the process is divided 2 steps:
1. wear_leveling_worker // generate false scrub type PEB ubi_eba_copy_leb // MOVE_RETRY is returned leb_write_trylock // trylock failed
scrubbing = 1;
e1 is put into ubi->scrub
2. wear_leveling_worker // schedule false scrub type PEB for wl scrubbing = 1
e1 = rb_entry(rb_first(&ubi->scrub))
The problem can be reproduced easily by running fsstress on a small UBIFS partition(<64M, simulated by nandsim) for 5~10mins (CONFIG_MTD_UBI_FASTMAP=y,CONFIG_MTD_UBI_WL_THRESHOLD=50). Following message is shown:
ubi0: scrubbed PEB 66 (LEB 0:10), data moved to PEB 165
Since scrub type source PEB has set variable scrubbing as '1', and variable scrubbing is checked before variable keep, so the problem can be fixed by setting keep variable as 1 directly if the source LEB cannot be locked.
--- drivers/mtd/ubi/wl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mtd/ubi/wl.c +8 -1
@@ -834,7 +834,14 @@ static int wear_leveling_worker(struct u goto out_not_moved; }if (err ==MOVE_RETRY ) { - scrubbing =1 ; +/* +* For source PEB: +* 1. The scrubbing is set for scrub type PEB, it will +* be put back into ubi->scrub list. +* 2. Non-scrub type PEB will be put back into ubi->used +* list. +*/ + keep =1 ; dst_leb_clean =1 ; goto out_not_moved; }
Greg Kroah-Hartman
maintainerPATCH 398/772 um: ubd: Do not use drvdata in release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
commit 5bee35e5389f450a7eea7318deb9073e9414d3b1 upstream.
The drvdata is not available in release. Let's just use container_of() to get the ubd instance. Otherwise, removing a ubd device will result in a crash:
RIP: 0033:blk_mq_free_tag_set+0x1f/0xba RSP: 00000000e2083bf0 EFLAGS: 00010246 RAX: 000000006021463a RBX: 0000000000000348 RCX: 0000000062604d00 RDX: 0000000004208060 RSI: 00000000605241a0 RDI: 0000000000000348 RBP: 00000000e2083c10 R08: 0000000062414010 R09: 00000000601603f7 R10: 000000000000133a R11: 000000006038c4bd R12: 0000000000000000 R13: 0000000060213a5c R14: 0000000062405d20 R15: 00000000604f7aa0 Kernel panic - not syncing: Segfault with no mm CPU: 0 PID: 17 Comm: kworker/0:1 Not tainted 6.8.0-rc3-00107-gba3f67c11638 #1 Workqueue: events mc_work_proc Stack: 00000000 604f7ef0 62c5d000 62405d20 e2083c30 6002c776 6002c755 600e47ff e2083c60 6025ffe3 04208060 603d36e0 Call Trace: [<6002c776>] ubd_device_release+0x21/0x55 [<6002c755>] ? ubd_device_release+0x0/0x55 [<600e47ff>] ? kfree+0x0/0x100 [<6025ffe3>] device_release+0x70/0xba [<60381d6a>] kobject_put+0xb5/0xe2 [<6026027b>] put_device+0x19/0x1c [<6026a036>] platform_device_put+0x26/0x29 [<6026ac5a>] platform_device_unregister+0x2c/0x2e [<6002c52e>] ubd_remove+0xb8/0xd6 [<6002bb74>] ? mconsole_reply+0x0/0x50 [<6002b926>] mconsole_remove+0x160/0x1cc [<6002bbbc>] ? mconsole_reply+0x48/0x50 [<6003379c>] ? um_set_signals+0x3b/0x43 [<60061c55>] ? update_min_vruntime+0x14/0x70 [<6006251f>] ? dequeue_task_fair+0x164/0x235 [<600620aa>] ? update_cfs_group+0x0/0x40 [<603a0e77>] ? __schedule+0x0/0x3ed [<60033761>] ? um_set_signals+0x0/0x43 [<6002af6a>] mc_work_proc+0x77/0x91 [<600520b4>] process_scheduled_works+0x1af/0x2c3 [<6004ede3>] ? assign_work+0x0/0x58 [<600527a1>] worker_thread+0x2f7/0x37a [<6004ee3b>] ? set_pf_worker+0x0/0x64 [<6005765d>] ? arch_local_irq_save+0x0/0x2d [<60058e07>] ? kthread_exit+0x0/0x3a [<600524aa>] ? worker_thread+0x0/0x37a [<60058f9f>] kthread+0x130/0x135 [<6002068e>] new_thread_handler+0x85/0xb6
--- arch/um/drivers/ubd_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/ubd_kern.c +1 -1
@@ -799,7 +799,7 @@ static int ubd_open_dev(struct ubd *ubd_static void ubd_device_release (struct device *dev) { -struct ubd *ubd_dev =dev_get_drvdata (dev); + struct ubd *ubd_dev = container_of(dev, struct ubd, pdev.dev);blk_mq_free_tag_set (&ubd_dev->tag_set); *ubd_dev = ((struct ubd )DEFAULT_UBD );
Greg Kroah-Hartman
maintainerPATCH 399/772 um: net: Do not use drvdata in release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
commit d1db692a9be3b4bd3473b64fcae996afaffe8438 upstream.
The drvdata is not available in release. Let's just use container_of() to get the uml_net instance. Otherwise, removing a network device will result in a crash:
RIP: 0033:net_device_release+0x10/0x6f RSP: 00000000e20c7c40 EFLAGS: 00010206 RAX: 000000006002e4e7 RBX: 00000000600f1baf RCX: 00000000624074e0 RDX: 0000000062778000 RSI: 0000000060551c80 RDI: 00000000627af028 RBP: 00000000e20c7c50 R08: 00000000603ad594 R09: 00000000e20c7b70 R10: 000000000000135a R11: 00000000603ad422 R12: 0000000000000000 R13: 0000000062c7af00 R14: 0000000062406d60 R15: 00000000627700b6 Kernel panic - not syncing: Segfault with no mm CPU: 0 UID: 0 PID: 29 Comm: kworker/0:2 Not tainted 6.12.0-rc6-g59b723cd2adb #1 Workqueue: events mc_work_proc Stack: 627af028 62c7af00 e20c7c80 60276fcd 62778000 603f5820 627af028 00000000 e20c7cb0 603a2bcd 627af000 62770010 Call Trace: [<60276fcd>] device_release+0x70/0xba [<603a2bcd>] kobject_put+0xba/0xe7 [<60277265>] put_device+0x19/0x1c [<60281266>] platform_device_put+0x26/0x29 [<60281e5f>] platform_device_unregister+0x2c/0x2e [<6002ec9c>] net_remove+0x63/0x69 [<60031316>] ? mconsole_reply+0x0/0x50 [<600310c8>] mconsole_remove+0x160/0x1cc [<60087d40>] ? __remove_hrtimer+0x38/0x74 [<60087ff8>] ? hrtimer_try_to_cancel+0x8c/0x98 [<6006b3cf>] ? dl_server_stop+0x3f/0x48 [<6006b390>] ? dl_server_stop+0x0/0x48 [<600672e8>] ? dequeue_entities+0x327/0x390 [<60038fa6>] ? um_set_signals+0x0/0x43 [<6003070c>] mc_work_proc+0x77/0x91 [<60057664>] process_scheduled_works+0x1b3/0x2dd [<60055f32>] ? assign_work+0x0/0x58 [<60057f0a>] worker_thread+0x1e9/0x293 [<6005406f>] ? set_pf_worker+0x0/0x64 [<6005d65d>] ? arch_local_irq_save+0x0/0x2d [<6005d748>] ? kthread_exit+0x0/0x3a [<60057d21>] ? worker_thread+0x0/0x293 [<6005dbf1>] kthread+0x126/0x12b [<600219c5>] new_thread_handler+0x85/0xb6
--- arch/um/drivers/net_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/net_kern.c +1 -1
@@ -336,7 +336,7 @@ static struct platform_driver uml_net_drstatic void net_device_release (struct device *dev) { -struct uml_net *device =dev_get_drvdata (dev); + struct uml_net *device = container_of(dev, struct uml_net, pdev.dev);struct net_device *netdev = device->dev;struct uml_net_private *lp =netdev_priv (netdev);
Greg Kroah-Hartman
maintainerPATCH 400/772 dt-bindings: serial: rs485: Fix rs485-rts-delay property
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Simek <[email protected]>
commit 12b3642b6c242061d3ba84e6e3050c3141ded14c upstream.
Code expects array only with 2 items which should be checked. But also item checking is not working as it should likely because of incorrect items description.
--- Documentation/devicetree/bindings/serial/rs485.yaml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/serial/rs485.yaml +9 -10
@@ -18,16 +18,15 @@ properties: description: prop-encoded-array <a b> $ref: /schemas/types.yaml#/definitions/uint32-array items: - items: - - description: Delay between rts signal and beginning of data sent in - milliseconds. It corresponds to the delay before sending data. - default: 0 - maximum: 100 - - description: Delay between end of data sent and rts signal in milliseconds. - It corresponds to the delay after sending data and actual release - of the line. - default: 0 - maximum: 100 + - description: Delay between rts signal and beginning of data sent in + milliseconds. It corresponds to the delay before sending data. + default: 0 + maximum: 100 + - description: Delay between end of data sent and rts signal in milliseconds. + It corresponds to the delay after sending data and actual release + of the line. + default: 0 + maximum: 100 rs485-rts-active-low: description: drive RTS low when sending (default is high).
Greg Kroah-Hartman
maintainerPATCH 401/772 serial: 8250_fintek: Add support for F81216E
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filip Brozovic <[email protected]>
commit 166105c9030a30ba08574a9998afc7b60bc72dd7 upstream.
The F81216E is a LPC/eSPI to 4 UART Super I/O and is mostly compatible with the F81216H, but does not support RS-485 auto-direction delays on any port.
--- drivers/tty/serial/8250/8250_fintek.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_fintek.c +13 -1
@@ -21,6 +21,7 @@#define CHIP_ID_F81866 0x1010#define CHIP_ID_F81966 0x0215#define CHIP_ID_F81216AD 0x1602 +#define CHIP_ID_F81216E 0x1617#define CHIP_ID_F81216H 0x0501#define CHIP_ID_F81216 0x0802#define VENDOR_ID1 0x23
@@ -158,6 +159,7 @@ static int fintek_8250_check_id(struct fcase CHIP_ID_F81866 :case CHIP_ID_F81966 :case CHIP_ID_F81216AD : +case CHIP_ID_F81216E :case CHIP_ID_F81216H :case CHIP_ID_F81216 :break ;
@@ -181,6 +183,7 @@ static int fintek_8250_get_ldn_range(strreturn 0 ;case CHIP_ID_F81216AD : +case CHIP_ID_F81216E :case CHIP_ID_F81216H :case CHIP_ID_F81216 : *min =F81216_LDN_LOW ;
@@ -250,6 +253,7 @@ static void fintek_8250_set_irq_mode(strbreak ;case CHIP_ID_F81216AD : +case CHIP_ID_F81216E :case CHIP_ID_F81216H :case CHIP_ID_F81216 : sio_write_mask_reg(pdata, FINTEK_IRQ_MODE, IRQ_SHARE,
@@ -263,7 +267,8 @@ static void fintek_8250_set_irq_mode(strstatic void fintek_8250_set_max_fifo (struct fintek_8250 *pdata) {switch (pdata->pid) { -case CHIP_ID_F81216H :/* 128Bytes FIFO */ +case CHIP_ID_F81216E :/* 128Bytes FIFO */ +case CHIP_ID_F81216H :case CHIP_ID_F81966 :case CHIP_ID_F81866 : sio_write_mask_reg(pdata, FIFO_CTRL,
@@ -297,6 +302,7 @@ static void fintek_8250_set_termios(stru goto exit;switch (pdata->pid) { +case CHIP_ID_F81216E :case CHIP_ID_F81216H : reg =RS485 ;break ;
@@ -346,6 +352,7 @@ static void fintek_8250_set_termios_handstruct fintek_8250 *pdata = uart->port.private_data;switch (pdata->pid) { +case CHIP_ID_F81216E :case CHIP_ID_F81216H :case CHIP_ID_F81966 :case CHIP_ID_F81866 :
@@ -438,6 +445,11 @@ static void fintek_8250_set_rs485_handle uart->port.rs485_supported = fintek_8250_rs485_supported;break ; +case CHIP_ID_F81216E :/* F81216E does not support RS485 delays */ + uart->port.rs485_config = fintek_8250_rs485_config; + uart->port.rs485_supported = fintek_8250_rs485_supported; +break ; +default :/* No RS485 Auto direction functional */ break ; }
Greg Kroah-Hartman
maintainerPATCH 402/772 serial: 8250: omap: Move pm_runtime_get_sync
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit bcc7ba668818dcadd2f1db66b39ed860a63ecf97 upstream.
Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.
--- drivers/tty/serial/8250/8250_omap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +2 -2
@@ -749,12 +749,12 @@ static void omap_8250_shutdown(struct uastruct uart_8250_port *up =up_to_u8250p (port);struct omap8250_priv *priv = port->private_data; +pm_runtime_get_sync (port->dev); +flush_work (&priv->qos_work);if (up->dma)omap_8250_rx_dma_flush (up); -pm_runtime_get_sync (port->dev); -serial_out (up,UART_OMAP_WER ,0 );if (priv->habit &UART_HAS_EFR2 )serial_out (up,UART_OMAP_EFR2 ,0x0 );
Greg Kroah-Hartman
maintainerPATCH 403/772 um: vector: Do not use drvdata in release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiwei Bie <[email protected]>
commit 51b39d741970742a5c41136241a9c48ac607cf82 upstream.
The drvdata is not available in release. Let's just use container_of() to get the vector_device instance. Otherwise, removing a vector device will result in a crash:
RIP: 0033:vector_device_release+0xf/0x50 RSP: 00000000e187bc40 EFLAGS: 00010202 RAX: 0000000060028f61 RBX: 00000000600f1baf RCX: 00000000620074e0 RDX: 000000006220b9c0 RSI: 0000000060551c80 RDI: 0000000000000000 RBP: 00000000e187bc50 R08: 00000000603ad594 R09: 00000000e187bb70 R10: 000000000000135a R11: 00000000603ad422 R12: 00000000623ae028 R13: 000000006287a200 R14: 0000000062006d30 R15: 00000000623700b6 Kernel panic - not syncing: Segfault with no mm CPU: 0 UID: 0 PID: 16 Comm: kworker/0:1 Not tainted 6.12.0-rc6-g59b723cd2adb #1 Workqueue: events mc_work_proc Stack: 60028f61 623ae028 e187bc80 60276fcd 6220b9c0 603f5820 623ae028 00000000 e187bcb0 603a2bcd 623ae000 62370010 Call Trace: [<60028f61>] ? vector_device_release+0x0/0x50 [<60276fcd>] device_release+0x70/0xba [<603a2bcd>] kobject_put+0xba/0xe7 [<60277265>] put_device+0x19/0x1c [<60281266>] platform_device_put+0x26/0x29 [<60281e5f>] platform_device_unregister+0x2c/0x2e [<60029422>] vector_remove+0x52/0x58 [<60031316>] ? mconsole_reply+0x0/0x50 [<600310c8>] mconsole_remove+0x160/0x1cc [<603b19f4>] ? strlen+0x0/0x15 [<60066611>] ? __dequeue_entity+0x1a9/0x206 [<600666a7>] ? set_next_entity+0x39/0x63 [<6006666e>] ? set_next_entity+0x0/0x63 [<60038fa6>] ? um_set_signals+0x0/0x43 [<6003070c>] mc_work_proc+0x77/0x91 [<60057664>] process_scheduled_works+0x1b3/0x2dd [<60055f32>] ? assign_work+0x0/0x58 [<60057f0a>] worker_thread+0x1e9/0x293 [<6005406f>] ? set_pf_worker+0x0/0x64 [<6005d65d>] ? arch_local_irq_save+0x0/0x2d [<6005d748>] ? kthread_exit+0x0/0x3a [<60057d21>] ? worker_thread+0x0/0x293 [<6005dbf1>] kthread+0x126/0x12b [<600219c5>] new_thread_handler+0x85/0xb6
--- arch/um/drivers/vector_kern.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/um/drivers/vector_kern.c +2 -1
@@ -823,7 +823,8 @@ static struct platform_driver uml_net_drstatic void vector_device_release (struct device *dev) { -struct vector_device *device =dev_get_drvdata (dev); +struct vector_device *device = + container_of(dev, struct vector_device, pdev.dev);struct net_device *netdev = device->dev;list_del (&device->list);
Greg Kroah-Hartman
maintainerPATCH 404/772 sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 3c891f7c6a4e90bb1199497552f24b26e46383bc upstream.
When CONFIG_CPUMASK_OFFSTACK and CONFIG_DEBUG_PER_CPU_MAPS are selected, cpu_max_bits_warn() generates a runtime warning similar as below when showing /proc/cpuinfo. Fix this by using nr_cpu_ids (the runtime limit) instead of NR_CPUS to iterate CPUs.
[ 3.052463] ------------[ cut here ]------------ [ 3.059679] WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:108 show_cpuinfo+0x5e8/0x5f0 [ 3.070072] Modules linked in: efivarfs autofs4 [ 3.076257] CPU: 0 PID: 1 Comm: systemd Not tainted 5.19-rc5+ #1052 [ 3.099465] Stack : 9000000100157b08 9000000000f18530 9000000000cf846c 9000000100154000 [ 3.109127] 9000000100157a50 0000000000000000 9000000100157a58 9000000000ef7430 [ 3.118774] 90000001001578e8 0000000000000040 0000000000000020 ffffffffffffffff [ 3.128412] 0000000000aaaaaa 1ab25f00eec96a37 900000010021de80 900000000101c890 [ 3.138056] 0000000000000000 0000000000000000 0000000000000000 0000000000aaaaaa [ 3.147711] ffff8000339dc220 0000000000000001 0000000006ab4000 0000000000000000 [ 3.157364] 900000000101c998 0000000000000004 9000000000ef7430 0000000000000000 [ 3.167012] 0000000000000009 000000000000006c 0000000000000000 0000000000000000 [ 3.176641] 9000000000d3de08 9000000001639390 90000000002086d8 00007ffff0080286 [ 3.186260] 00000000000000b0 0000000000000004 0000000000000000 0000000000071c1c [ 3.195868] ... [ 3.199917] Call Trace: [ 3.203941] [<90000000002086d8>] show_stack+0x38/0x14c [ 3.210666] [<9000000000cf846c>] dump_stack_lvl+0x60/0x88 [ 3.217625] [<900000000023d268>] __warn+0xd0/0x100 [ 3.223958] [<9000000000cf3c90>] warn_slowpath_fmt+0x7c/0xcc [ 3.231150] [<9000000000210220>] show_cpuinfo+0x5e8/0x5f0 [ 3.238080] [<90000000004f578c>] seq_read_iter+0x354/0x4b4 [ 3.245098] [<90000000004c2e90>] new_sync_read+0x17c/0x1c4 [ 3.252114] [<90000000004c5174>] vfs_read+0x138/0x1d0 [ 3.258694] [<90000000004c55f8>] ksys_read+0x70/0x100 [ 3.265265] [<9000000000cfde9c>] do_syscall+0x7c/0x94 [ 3.271820] [<9000000000202fe4>] handle_syscall+0xc4/0x160 [ 3.281824] ---[ end trace 8b484262b4b8c24c ]---
--- arch/sh/kernel/cpu/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/cpu/proc.c +1 -1
@@ -132,7 +132,7 @@ static int show_cpuinfo(struct seq_filestatic void *c_start (struct seq_file *m,loff_t *pos) { -return *pos <NR_CPUS ? cpu_data + *pos :NULL ; +return *pos < nr_cpu_ids ? cpu_data + *pos :NULL ; }static void *c_next (struct seq_file *m,void *v,loff_t *pos) {
Greg Kroah-Hartman
maintainerPATCH 405/772 ublk: fix ublk_ch_mmap() for 64K page size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit d369735e02ef122d19d4c3d093028da0eb400636 upstream.
In ublk_ch_mmap(), queue id is calculated in the following way:
(vma->vm_pgoff << PAGE_SHIFT) / `max_cmd_buf_size`
'max_cmd_buf_size' is equal to
UBLK_MAX_QUEUE_DEPTH * sizeof(struct ublksrv_io_desc)
and UBLK_MAX_QUEUE_DEPTH is 4096 and part of UAPI, so 'max_cmd_buf_size' is always page aligned in 4K page size kernel. However, it isn't true in 64K page size kernel.
Fixes the issue by always rounding up 'max_cmd_buf_size' with PAGE_SIZE.
--- drivers/block/ublk_drv.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/block/ublk_drv.c +12 -3
@@ -325,12 +325,21 @@ static inline char *ublk_queue_cmd_buf(sreturn ublk_get_queue (ub, q_id)->io_cmd_buf; } +static inline int __ublk_queue_cmd_buf_size (int depth) +{ +return round_up (depth *sizeof (struct ublksrv_io_desc ),PAGE_SIZE ); +} +static inline int ublk_queue_cmd_buf_size (struct ublk_device *ub,int q_id) {struct ublk_queue *ubq =ublk_get_queue (ub, q_id); -return round_up (ubq->q_depth *sizeof (struct ublksrv_io_desc ), -PAGE_SIZE ); +return __ublk_queue_cmd_buf_size (ubq->q_depth); +} + +static int ublk_max_cmd_buf_size (void ) +{ +return __ublk_queue_cmd_buf_size (UBLK_MAX_QUEUE_DEPTH ); } static inline bool ublk_queue_can_use_recovery_reissue(
@@ -930,7 +939,7 @@ static int ublk_ch_mmap(struct file *fil {struct ublk_device *ub = filp->private_data;size_t sz = vma->vm_end - vma->vm_start; -unsigned max_sz =UBLK_MAX_QUEUE_DEPTH *sizeof (struct ublksrv_io_desc ); +unsigned max_sz =ublk_max_cmd_buf_size ();unsigned long pfn, end, phys_off = vma->vm_pgoff <<PAGE_SHIFT ;int q_id, ret =0 ;