6.6.163-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 1360/3318 xfs: bound da-node entry count against the correct geometry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit 3df5e5aaa3bc0913236c48ab29b7df3a785aa29f ]
xfs_da3_node_verify() bounds the node entry count against the larger of the directory and attribute geometries because, as a buffer verifier, it cannot tell whether the block belongs to the directory or the attribute tree. When the directory block size exceeds the fs block size (e.g. mkfs.xfs -n size=64k -b size=4k), an attribute node buffer is a single fs block that holds only m_attr_geo->node_ents entries, yet a crafted attr node may claim a count up to m_dir_geo->node_ents and still pass the verifier.
xfs_da3_node_lookup_int() then indexes btree[] up to that count during its binary search -- an out-of-bounds read via getxattr/listxattr on a mounted crafted image.
The buffer verifier is the wrong place to tighten this: it has no fork context, and the transaction-less read path used by getxattr does not run xfs_da3_node_set_type() either. xfs_da3_node_lookup_int(), on the other hand, always runs on that path and holds args->geo, the geometry of the fork actually being searched. Bound the entry count against args->geo->node_ents there, before walking the entries.
--- fs/xfs/libxfs/xfs_da_btree.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/xfs/libxfs/xfs_da_btree.c +13 -0
@@ -1671,6 +1671,19 @@ xfs_da3_node_lookup_int( }else expected_level--; +/* +* The node verifier cannot tell whether this block belongs to +* the directory or the attribute tree, so it only bounds the +* entry count against the larger of the two geometries. Here +* args->geo is the geometry of the fork we are actually +* searching, so reject a count that would walk btree[] off the +* end of this node buffer. +*/ +if (nodehdr.count > args->geo->node_ents) { +xfs_buf_mark_corrupt (blk->bp); +return -EFSCORRUPTED ; + } + max = nodehdr.count; blk->hashval =be32_to_cpu (btree[max -1 ].hashval);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1361/3318 smb: client: reject FIND data areas that run past the received response
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Oliva <[email protected]>
[ Upstream commit 29bd6773187cb5c1bbbdf90d677c6add7d58af26 ]
CIFSFindFirst() and CIFSFindNext() take the directory entries of a TRANS2_FIND_FIRST2 or TRANS2_FIND_NEXT2 response from DataOffset for DataCount bytes. validate_t2() bounds DataOffset at 1024 and ParameterCount + DataCount by the byte count, and nothing compares DataOffset + DataCount with the number of bytes SendReceive() copied into the buffer.
smb_init() places the request and the response in the same cifs_request allocation and cifs_buf_get() clears only the start of it, so a short response whose data area extends past its end has srch_entries_start point at bytes of the request that was just sent, or at whatever the allocation held before, and those bytes are parsed as directory entries. cifs_readdir() and find_cifs_entry() walk the entries with nxt_dir_entry(), which checks every entry but the first of a response against the end of the SMB; cifs_query_path_info() and cifs_backup_query_path_info() read the first entry with no check at all. Those reads stay inside the allocation, but what they return is not part of the response. The last entry, which LastNameOffset locates relative to the data area, is bounded against the received response by an earlier patch of this series, as is every entry that cifs_fill_dirent() parses; the walk itself and the two query functions are not.
SMB1 is not negotiated by default; reaching this code requires an explicit vers=1.0 mount.
Reject a response whose data area extends past the received length, with the -EINVAL that validate_t2() returns for the other malformed transaction responses. cifs_query_path_info() and cifs_backup_query_path_info() still read a whole entry from a data area that may be smaller than one; that is not changed here.
A conforming server is not affected. The data block of a transaction response is part of the SMB, so DataOffset + DataCount cannot exceed the smbCalcSize() bytes that SendReceive() copies; coalesce_t2() appends each secondary response to the data area and adds its length to both DataCount and the byte count, which keeps that relation.
--- fs/smb/client/cifssmb.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
fs/smb/client/cifssmb.c +25 -6
@@ -3969,8 +3969,9 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,/* level 257 SMB_ */ TRANSACTION2_FFIRST_REQ *pSMB =NULL ;TRANSACTION2_FFIRST_RSP *pSMBr =NULL ; -T2_FFIRST_RSP_PARMS *parms; +unsigned int data_off, data_count;struct nls_table *nls_codepage; +T2_FFIRST_RSP_PARMS *parms;unsigned int lnoff;__u16 params, byte_count;int bytes_returned =0 ;
@@ -4089,11 +4090,19 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,return rc; } + data_off =le16_to_cpu (pSMBr->t2.DataOffset); + data_count =le16_to_cpu (pSMBr->t2.DataCount); +if (data_off + data_count > (unsigned int )bytes_returned) { +cifs_dbg (VFS ,"%s: data area offset %u count %u past response length %d\n" , + __func__, data_off, data_count, bytes_returned); +cifs_buf_release (pSMB); +return -EINVAL ; + } + psrch_inf->unicode = !!(pSMBr->hdr.Flags2 &SMBFLG2_UNICODE ); psrch_inf->ntwrk_buf_start = (char *)pSMBr; psrch_inf->smallBuf = false; - psrch_inf->srch_entries_start = (char *)&pSMBr->hdr.Protocol + -le16_to_cpu (pSMBr->t2.DataOffset); + psrch_inf->srch_entries_start = (char *)&pSMBr->hdr.Protocol + data_off; parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +le16_to_cpu (pSMBr->t2.ParameterOffset));
@@ -4126,8 +4135,9 @@ int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon, {TRANSACTION2_FNEXT_REQ *pSMB =NULL ;TRANSACTION2_FNEXT_RSP *pSMBr =NULL ; -T2_FNEXT_RSP_PARMS *parms; +unsigned int data_off, data_count;unsigned int name_len; +T2_FNEXT_RSP_PARMS *parms;unsigned int lnoff;__u16 params, byte_count;char *response_data;
@@ -4210,13 +4220,22 @@ int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,cifs_buf_release (pSMB);return rc; } + + data_off =le16_to_cpu (pSMBr->t2.DataOffset); + data_count =le16_to_cpu (pSMBr->t2.DataCount); +if (data_off + data_count > (unsigned int )bytes_returned) { +cifs_dbg (VFS ,"%s: data area offset %u count %u past response length %d\n" , + __func__, data_off, data_count, bytes_returned); +cifs_buf_release (pSMB); +return -EINVAL ; + } +/* BB fixme add lock for file (srch_info) struct here */ psrch_inf->unicode = !!(pSMBr->hdr.Flags2 &SMBFLG2_UNICODE ); response_data = (char *)&pSMBr->hdr.Protocol +le16_to_cpu (pSMBr->t2.ParameterOffset); parms = (T2_FNEXT_RSP_PARMS *)response_data; - response_data = (char *)&pSMBr->hdr.Protocol + -le16_to_cpu (pSMBr->t2.DataOffset); + response_data = (char *)&pSMBr->hdr.Protocol + data_off;if (psrch_inf->smallBuf)cifs_small_buf_release (psrch_inf->ntwrk_buf_start);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1362/3318 raid6: add missing vzeroupper to AVX2 code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 24f1241cdb056fd630e6710a916e0f7c8c910a70 upstream.
Since the AVX2 optimized RAID6 code uses YMM registers, execute vzeroupper before returning from it. This is needed to avoid degrading the performance of any later SSE code that may happen to be executed.
--- lib/raid6/avx2.c | 6 ++++++ lib/raid6/recov_avx2.c | 2 ++ 2 files changed, 8 insertions(+)
lib/raid6/avx2.c +6 -0
@@ -76,6 +76,7 @@ static void raid6_avx21_gen_syndrome(int disks, size_t bytes, void **ptrs) } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -124,6 +125,7 @@ static void raid6_avx21_xor_syndrome(int disks, int start, int stop, } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -186,6 +188,7 @@ static void raid6_avx22_gen_syndrome(int disks, size_t bytes, void **ptrs) } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -254,6 +257,7 @@ static void raid6_avx22_xor_syndrome(int disks, int start, int stop, } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -347,6 +351,7 @@ static void raid6_avx24_gen_syndrome(int disks, size_t bytes, void **ptrs) } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -457,6 +462,7 @@ static void raid6_avx24_xor_syndrome(int disks, int start, int stop, asmvolatile ("vmovntdq %%ymm14,%0" :"=m" (q[d+96 ])); } asmvolatile ("sfence" : : :"memory" ); + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
lib/raid6/recov_avx2.c +2 -0
@@ -180,6 +180,7 @@ static void raid6_2data_recov_avx2(int disks, size_t bytes, int faila,#endif } + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
@@ -297,6 +298,7 @@ static void raid6_datap_recov_avx2(int disks, size_t bytes, int faila,#endif } + asmvolatile ("vzeroupper" );kernel_fpu_end (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1363/3318 mm/damon/core: skip applying scheme if region split for quota fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <[email protected]>
[ Upstream commit 90c2fa6adfed7abe0935506a43cdff3a05c1fff0 ]
Patch series "mm/damon: fix DAMOS bugs in core, paddr and vaddr".
Fix misc bugs of DAMOS. Patch 1 makes DAMOS less stress memory allocator under extreme situation. Patches 2 and 3 fix wrong folios walking in DAMON_PADDR. Patches 4 and 5 fix wrong folios walking in DAMON_VADDR. Patches 6-8 handle extreme and unlikely memory situations that can cause divide by zero and underflow.
All bugs are discovered by Sashiko.
This patch (of 8):
damos_apply_scheme() splits a region and apply the action to the subregion if it is needed for not violating the quota. The split operation (damon_split_region_at()) could fail for allocation failure. In the case, the quota could be violated. From the user's perspective, DAMOS becomes more aggressive than expected under the extreme situation. Handle the failure.
The user impact is not critical. The failure of damon_split_region_at() is unlikely since it is arguably too small to fail. Also DAMOS being aggressive is limited to the single region. Users can set min_nr_regions to set the maximum size of each region. If it is reasonably set, the transient overhead shouldn't be critical.
The issue was discovered [1] by Sashiko.
6.6.y porting notes. Modify damon_split_region_at() to return failures. It is a part of commit c60874860762 ("mm/damon/core: handle region split failure in apply_min_nr_regions()"). Without it, build fails.
--- mm/damon/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/damon/core.c +8 -4
@@ -828,7 +828,7 @@ static void kdamond_reset_aggregated(struct damon_ctx *c) } } -static void damon_split_region_at (struct damon_target *t, +static int damon_split_region_at (struct damon_target *t,struct damon_region *r,unsigned long sz_r);static bool __damos_valid_target (struct damon_region *r,struct damos *s)
@@ -1004,7 +1004,8 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, DAMON_MIN_REGION);if (!sz) goto update_stat; -damon_split_region_at (t, r, sz); +if (damon_split_region_at (t, r, sz)) + goto update_stat; }if (damos_filter_out (c, t, r, s))return ;
@@ -1267,15 +1268,17 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,* * r the region to be split * sz_r size of the first sub-region that will be made +* +* Return: 0 on success, negative error code otherwise. */ -static void damon_split_region_at (struct damon_target *t, +static int damon_split_region_at (struct damon_target *t,struct damon_region *r,unsigned long sz_r) {struct damon_region *new; new =damon_new_region (r->ar.start + sz_r, r->ar.end);if (!new) -return ; +return -ENOMEM ; r->ar.end = new->ar.start;
@@ -1284,6 +1287,7 @@ static void damon_split_region_at(struct damon_target *t, new->nr_accesses = r->nr_accesses;damon_insert_region (new, r,damon_next_region (r), t); +return 0 ; }/* Split every region in the given target into 'nr_subs' regions */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1364/3318 mm/damon/core: filter out damos address filter-split failed region
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <[email protected]>
[ Upstream commit bbeec2d8324d7aac438bb12dd2d22b184e0a8d43 ]
When an address type DAMOS filter is configured, DAMOS tries to split the region for the filter range, and apply DAMOS action to the filter-in region. The split operation (damon_split_region_at()) could fail from allocation failure under extreme memory pressure. In the case, DAMOS action could be applied more or less than expected, ignoring the address filter.
The issue only rarely happens under extreme memory pressure. No crash or leak happens. Occasionally not applying the action to a few regions shouldn't be a real problem. But applying the action to a region that the user has excluded via address filter could be a surprise depending on the use case. It is only theoretical. No such real case is found yet.
Filter out the entire region if the split is failed. Update damos_filter_match() signature to receive the error from split. Also update kunit tests for the updated signature.
The issue was discovered [1] by sashiko.
--- mm/damon/core-test.h | 11 ++++++----- mm/damon/core.c | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-)
mm/damon/core-test.h +6 -5
@@ -461,6 +461,7 @@ static void damos_test_filter_out(struct kunit *test)struct damon_target *t;struct damon_region *r, *r2;struct damos_filter *f; +int err; f =damos_new_filter (DAMOS_FILTER_TYPE_ADDR , true);if (!f)
@@ -482,25 +483,25 @@ static void damos_test_filter_out(struct kunit *test)damon_add_region (r, t);/* region in the range */ -KUNIT_EXPECT_TRUE (test,__damos_filter_out (NULL , t, r, f)); +KUNIT_EXPECT_TRUE (test,__damos_filter_out (NULL , t, r, f, &err));KUNIT_EXPECT_EQ (test,damon_nr_regions (t),1 );/* region before the range */ r->ar.start =DAMON_MIN_REGION *1 ; r->ar.end =DAMON_MIN_REGION *2 ; -KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f)); +KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f, &err));KUNIT_EXPECT_EQ (test,damon_nr_regions (t),1 );/* region after the range */ r->ar.start =DAMON_MIN_REGION *6 ; r->ar.end =DAMON_MIN_REGION *8 ; -KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f)); +KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f, &err));KUNIT_EXPECT_EQ (test,damon_nr_regions (t),1 );/* region started before the range */ r->ar.start =DAMON_MIN_REGION *1 ; r->ar.end =DAMON_MIN_REGION *4 ; -KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f)); +KUNIT_EXPECT_FALSE (test,__damos_filter_out (NULL , t, r, f, &err));/* filter should have split the region */ KUNIT_EXPECT_EQ (test, r->ar.start,DAMON_MIN_REGION *1 );KUNIT_EXPECT_EQ (test, r->ar.end,DAMON_MIN_REGION *2 );
@@ -515,7 +516,7 @@ static void damos_test_filter_out(struct kunit *test)/* region started in the range */ r->ar.start =DAMON_MIN_REGION *2 ; r->ar.end =DAMON_MIN_REGION *8 ; -KUNIT_EXPECT_TRUE (test,__damos_filter_out (NULL , t, r, f)); +KUNIT_EXPECT_TRUE (test,__damos_filter_out (NULL , t, r, f, &err));/* filter should have split the region */ KUNIT_EXPECT_EQ (test, r->ar.start,DAMON_MIN_REGION *2 );KUNIT_EXPECT_EQ (test, r->ar.end,DAMON_MIN_REGION *6 );
mm/damon/core.c +9 -4
@@ -930,13 +930,14 @@ static void damos_update_stat(struct damos *s, }static bool __damos_filter_out (struct damon_ctx *ctx,struct damon_target *t, -struct damon_region *r,struct damos_filter *filter) +struct damon_region *r,struct damos_filter *filter,int *err) {bool matched = false;struct damon_target *ti;int target_idx =0 ;unsigned long start, end; + *err =0 ;switch (filter->type) {case DAMOS_FILTER_TYPE_TARGET :damon_for_each_target (ti, ctx) {
@@ -962,12 +963,13 @@ static bool __damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, }/* start before the range and overlap */ if (r->ar.start < start) { -damon_split_region_at (t, r, start - r->ar.start); + *err =damon_split_region_at (t, r, + start - r->ar.start); matched = false;break ; }/* start inside the range */ -damon_split_region_at (t, r, end - r->ar.start); + *err =damon_split_region_at (t, r, end - r->ar.start); matched = true;break ;default :
@@ -981,9 +983,12 @@ static bool damos_filter_out(struct damon_ctx *ctx, struct damon_target *t, struct damon_region *r, struct damos *s) { struct damos_filter *filter; +bool matching; +int err;damos_for_each_filter (filter, s) { -if (__damos_filter_out (ctx, t, r, filter)) + matching =__damos_filter_out (ctx, t, r, filter, &err); +if (matching || err)return true; }return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1365/3318 mm/damon/core: remove unreachable damos charge_{target,addr}_from
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <[email protected]>
[ Upstream commit 5695abc4e742b947f586bfb6a080a80ad9957e5d ]
damos_quota->charge_{target,addr}_from saves the target and region the scheme's quota limit is reached. damos_skip_charged_region() skips the target and regions before the point. The target that was assigned to charge_target_from could be dynamically removed from the context by the runtime parameters update (aka commit) feature. In this case, damos_skip_charged_region() cannot find if the point is passed or not, so the scheme is effectively disabled.
Similarly, the user could also remove all the regions of the target using the runtime parameters update feature. It would be uncommon to do that, but it is a supported feature. Because the skip pointer detection logic (damos_skip_charged_region()) works for each region of targets, this result in the logic is entirely skipped and the scheme is effectively disabled again.
The user impact is that the DAMOS scheme could suddenly stop working under certain uses of the runtime parameters update feature. It could surprise users. No crash or leak happens though. Users could also simply work around by re-installing the scheme.
Catch the corner cases in damos_adjust_quota() and reset the pointers.
--- mm/damon/core.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
mm/damon/core.c +23 -0
@@ -1089,6 +1089,27 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->esz = esz; } + +static void damos_fix_stale_charge_pointers (struct damon_ctx *c, +struct damos *s) +{ +struct damos_quota *quota; +struct damon_target *t; + + quota = &s->quota; +if (!quota->charge_target_from) +return ; +damon_for_each_target (t, c) { +if (t == quota->charge_target_from) { +if (damon_nr_regions (t) >0 ) +return ; +break ; + } + } + quota->charge_target_from =NULL ; + quota->charge_addr_from =0 ; +} +static void damos_adjust_quota (struct damon_ctx *c,struct damos *s) {struct damos_quota *quota = &s->quota;
@@ -1116,6 +1137,8 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)damos_set_effective_quota (quota); } +damos_fix_stale_charge_pointers (c, s); +if (!c->ops.get_scheme_score)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1366/3318 xfs: always report scrub errors in tracepoints
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 1ccc8f553d885d49c1bfe141ea1f331511940b3a ]
LOLLM complains that the error processing functions in scrub will sometimes zero out *error before recording a tracepoint. This makes diagnosing problems harder, so let's fix that.
--- fs/xfs/scrub/btree.c | 8 +++++++- fs/xfs/scrub/common.c | 7 +++++-- fs/xfs/scrub/dabtree.c | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-)
fs/xfs/scrub/btree.c +7 -1
@@ -46,8 +46,14 @@ __xchk_btree_process_error(case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; +if (cur->bc_flags &XFS_BTREE_ROOT_IN_INODE ) +trace_xchk_ifork_btree_op_error (sc, cur, level, + *error, ret_ip); +else +trace_xchk_btree_op_error (sc, cur, level, + *error, ret_ip); *error =0 ; - fallthrough; +break ;default :if (cur->bc_flags &XFS_BTREE_ROOT_IN_INODE ) trace_xchk_ifork_btree_op_error(sc, cur, level,
fs/xfs/scrub/common.c +5 -2
@@ -87,8 +87,9 @@ __xchk_process_error(case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; +trace_xchk_op_error (sc, agno, bno, *error, ret_ip); *error =0 ; - fallthrough; +break ;default :trace_xchk_op_error (sc, agno, bno, *error, ret_ip);
@@ -143,8 +144,10 @@ __xchk_fblock_process_error(case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; +trace_xchk_file_op_error (sc, whichfork, offset, *error, + ret_ip); *error =0 ; - fallthrough; +break ;default :trace_xchk_file_op_error (sc, whichfork, offset, *error, ret_ip);
fs/xfs/scrub/dabtree.c +5 -1
@@ -49,8 +49,12 @@ xchk_da_process_error(case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; +trace_xchk_file_op_error (sc, ds->dargs.whichfork, +xfs_dir2_da_to_db (ds->dargs.geo, + ds->state->path.blk[level].blkno), + *error, __return_address); *error =0 ; - fallthrough; +break ;default : trace_xchk_file_op_error(sc, ds->dargs.whichfork, xfs_dir2_da_to_db(ds->dargs.geo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1367/3318 mtd: rawnand: ndfc: use ioread32be/iowrite32be and allow COMPILE_TEST
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 4f2692a5383e4bdd43ae940cda012360f7217a2d ]
Replace ppc4xx-specific in_be32/out_be32 with generic ioread32be/ iowrite32be to make the driver portable. Add COMPILE_TEST dependency to get build coverage on non-ppc4xx architectures.
While at it, replace 4xx with 44x. The latter was removed a while ago and is only kept for compatibility.
--- drivers/mtd/nand/raw/Kconfig | 2 +- drivers/mtd/nand/raw/ndfc.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/mtd/nand/raw/Kconfig +1 -1
@@ -71,7 +71,7 @@ config MTD_NAND_AU1550 config MTD_NAND_NDFC tristate "IBM/MCC 4xx NAND controller" - depends on 4xx + depends on 44x || COMPILE_TEST select MTD_NAND_ECC_SW_HAMMING select MTD_NAND_ECC_SW_HAMMING_SMC help
drivers/mtd/nand/raw/ndfc.c +10 -10
@@ -44,13 +44,13 @@ static void ndfc_select_chip(struct nand_chip *nchip, int chip)uint32_t ccr;struct ndfc_controller *ndfc =nand_get_controller_data (nchip); - ccr =in_be32 (ndfc->ndfcbase +NDFC_CCR ); + ccr =ioread32be (ndfc->ndfcbase +NDFC_CCR );if (chip >=0 ) { ccr &= ~NDFC_CCR_BS_MASK ; ccr |=NDFC_CCR_BS (chip + ndfc->chip_select); }else ccr |=NDFC_CCR_RESET_CE ; -out_be32 (ndfc->ndfcbase +NDFC_CCR , ccr); +iowrite32be (ccr, ndfc->ndfcbase +NDFC_CCR ); }static void ndfc_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl)
@@ -70,7 +70,7 @@ static int ndfc_ready(struct nand_chip *chip) {struct ndfc_controller *ndfc =nand_get_controller_data (chip); -return in_be32 (ndfc->ndfcbase +NDFC_STAT ) &NDFC_STAT_IS_READY ; +return ioread32be (ndfc->ndfcbase +NDFC_STAT ) &NDFC_STAT_IS_READY ; }static void ndfc_enable_hwecc (struct nand_chip *chip,int mode)
@@ -78,9 +78,9 @@ static void ndfc_enable_hwecc(struct nand_chip *chip, int mode)uint32_t ccr;struct ndfc_controller *ndfc =nand_get_controller_data (chip); - ccr =in_be32 (ndfc->ndfcbase +NDFC_CCR ); + ccr =ioread32be (ndfc->ndfcbase +NDFC_CCR ); ccr |=NDFC_CCR_RESET_ECC ; -out_be32 (ndfc->ndfcbase +NDFC_CCR , ccr); +iowrite32be (ccr, ndfc->ndfcbase +NDFC_CCR );wmb (); }
@@ -92,7 +92,7 @@ static int ndfc_calculate_ecc(struct nand_chip *chip,uint8_t *p = (uint8_t *)&ecc;wmb (); - ecc =in_be32 (ndfc->ndfcbase +NDFC_ECC ); + ecc =ioread32be (ndfc->ndfcbase +NDFC_ECC );/* The NDFC uses Smart Media (SMC) bytes order */ ecc_code[0 ] = p[1 ]; ecc_code[1 ] = p[2 ];
@@ -114,7 +114,7 @@ static void ndfc_read_buf(struct nand_chip *chip, uint8_t *buf, int len)uint32_t *p = (uint32_t *) buf;for (;len >0 ; len -=4 ) - *p++ =in_be32 (ndfc->ndfcbase +NDFC_DATA ); + *p++ =ioread32be (ndfc->ndfcbase +NDFC_DATA ); }static void ndfc_write_buf (struct nand_chip *chip,const uint8_t *buf,int len)
@@ -123,7 +123,7 @@ static void ndfc_write_buf(struct nand_chip *chip, const uint8_t *buf, int len)uint32_t *p = (uint32_t *) buf;for (;len >0 ; len -=4 ) -out_be32 (ndfc->ndfcbase +NDFC_DATA , *p++); +iowrite32be (*p++, ndfc->ndfcbase +NDFC_DATA ); }/*
@@ -223,13 +223,13 @@ static int ndfc_probe(struct platform_device *ofdev)if (reg) ccr |=be32_to_cpup (reg); -out_be32 (ndfc->ndfcbase +NDFC_CCR , ccr); +iowrite32be (ccr, ndfc->ndfcbase +NDFC_CCR );/* Set the bank settings if given */ reg =of_get_property (ofdev->dev.of_node,"bank-settings" ,NULL );if (reg) {int offset =NDFC_BCFG0 + (ndfc->chip_select <<2 ); -out_be32 (ndfc->ndfcbase + offset,be32_to_cpup (reg)); +iowrite32be (be32_to_cpup (reg), ndfc->ndfcbase + offset); } err =ndfc_chip_init (ndfc, ofdev->dev.of_node);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1368/3318 mtd: rawnand: ndfc: add CONFIG_OF dependency
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 97f9e509d839f7e5b9a32105ae322e5223c86786 ]
When compile-testing on x86 without CONFIG_OF, the ndfc driver produces a harmless warning:
drivers/mtd/nand/raw/ndfc.c: In function 'ndfc_probe':include/linux/dev_printk.h:154:31: error: 'len' is used uninitialized [-Werror=uninitialized]
154 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^drivers/mtd/nand/raw/ndfc.c:196:17: note: in expansion of macro 'dev_err'
196 | dev_err(&ofdev->dev, "unable read reg property (%d)\n", len);
Limit compile-testing to configurations with CONFIG_OF to trivially avoid this. The driver will still be built in allmodconfig and many randconfig builds.
--- drivers/mtd/nand/raw/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/Kconfig +1 -0
@@ -72,6 +72,7 @@ config MTD_NAND_AU1550 config MTD_NAND_NDFC tristate "IBM/MCC 4xx NAND controller" depends on 44x || COMPILE_TEST + depends on OF select MTD_NAND_ECC_SW_HAMMING select MTD_NAND_ECC_SW_HAMMING_SMC help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1369/3318 mtd: rawnand: ndfc: fix gcc uninitialized var
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit cceca8cb776b03e83985578f84bd730c30d57f70 ]
Now that this can be built with COMPILE_TEST, an unassigned variable was found. Set to 0 to fix the W=1 error under GCC.
--- drivers/mtd/nand/raw/ndfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/ndfc.c +1 -1
@@ -188,7 +188,7 @@ static int ndfc_probe(struct platform_device *ofdev)const __be32 *reg;u32 ccr;u32 cs; -int err, len; +int err, len =0 ;/* Read the reg property to get the chip select */ reg =of_get_property (ofdev->dev.of_node,"reg" , &len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1370/3318 mtd: rawnand: ndfc: use devm_platform_ioremap_resource()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 0d66f9895f286d2fab396a71e6efeb95c4a7e5a6 ]
Replace the open-coded of_iomap()/iounmap() with the managed devm_platform_ioremap_resource() helper. This fixes a mapping leak on driver remove (the old code never called iounmap()) and simplifies the error path by dropping the manual cleanup in ndfc_probe().
There is no overlapping memory-region concern introduced by this
change: each supported board DT describes a single ndfc node with a unique 0x2000 register region, and the EBC parent uses dcr-reg rather than a MEM reg resource, so the newly added request_mem_region() cannot conflict with an existing reservation. Distinct chip selects map to distinct 64-bit physical addresses, so CS instances do not overlap.
--- drivers/mtd/nand/raw/ndfc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/ndfc.c +8 -13
@@ -185,10 +185,15 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,static int ndfc_probe (struct platform_device *ofdev) {struct ndfc_controller *ndfc; +void __iomem *ndfcbase;const __be32 *reg;u32 ccr;u32 cs; -int err, len =0 ; +int len =0 ; + + ndfcbase =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (ndfcbase)) +return PTR_ERR (ndfcbase);/* Read the reg property to get the chip select */ reg =of_get_property (ofdev->dev.of_node,"reg" , &len);
@@ -210,11 +215,7 @@ static int ndfc_probe(struct platform_device *ofdev) ndfc->ofdev = ofdev;dev_set_drvdata (&ofdev->dev, ndfc); - ndfc->ndfcbase =of_iomap (ofdev->dev.of_node,0 ); -if (!ndfc->ndfcbase) { -dev_err (&ofdev->dev,"failed to get memory\n" ); -return -EIO ; - } + ndfc->ndfcbase = ndfcbase; ccr =NDFC_CCR_BS (ndfc->chip_select);
@@ -232,13 +233,7 @@ static int ndfc_probe(struct platform_device *ofdev)iowrite32be (be32_to_cpup (reg), ndfc->ndfcbase + offset); } - err =ndfc_chip_init (ndfc, ofdev->dev.of_node); -if (err) { -iounmap (ndfc->ndfcbase); -return err; - } - -return 0 ; +return ndfc_chip_init (ndfc, ofdev->dev.of_node); }static void ndfc_remove (struct platform_device *ofdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1371/3318 net: bgmac: enable interrupts only after NAPI is ready
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit ac1f6e58cb77bb66b8811f7d98703e0f076a8f65 ]
bgmac_open() calls bgmac_chip_init(), which unmasks the interrupts and enables the MAC receiver, before request_irq() and napi_enable(). bgmac_enet_resume() also enables NAPI only after bgmac_chip_init().
When frames arrive in that window, the first RX interrupt masks all interrupts in bgmac_interrupt() and calls napi_schedule() on a NAPI instance that is still disabled, so nothing is scheduled. Nothing unmasks the interrupts again, the RX ring fills up and the interface stays deaf until it is brought down and up without traffic.
On an Asus RT-N16 (BCM4716) a single "ip link set eth0 down/up" while a host sends UDP to the router left INT_MASK at 0, INT_STATUS with RX pending and the RX DMA idle on a full ring, with the RX packet and interrupt counters no longer moving. With this change, 10 of 10 such cycles recovered on their own.
Request the IRQ and enable NAPI before the chip is initialized.
--- drivers/net/ethernet/broadcom/bgmac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +5 -5
@@ -1183,9 +1183,6 @@ static int bgmac_open(struct net_device *net_dev)if (err)return err; -/* Specs say about reclaiming rings here, but we do that in DMA init */ -bgmac_chip_init (bgmac); - err =request_irq (bgmac->irq, bgmac_interrupt,IRQF_SHARED , net_dev->name, net_dev);if (err <0 ) {
@@ -1195,6 +1192,9 @@ static int bgmac_open(struct net_device *net_dev) }napi_enable (&bgmac->napi); +/* Specs say about reclaiming rings here, but we do that in DMA init */ +bgmac_chip_init (bgmac); +phy_start (net_dev->phydev);netif_start_queue (net_dev);
@@ -1609,10 +1609,10 @@ int bgmac_enet_resume(struct bgmac *bgmac)if (rc)return rc; -bgmac_chip_init (bgmac); -napi_enable (&bgmac->napi); +bgmac_chip_init (bgmac); +netif_tx_lock (bgmac->net_dev);netif_device_attach (bgmac->net_dev);netif_tx_unlock (bgmac->net_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1372/3318 nfsd: fix NULL dereference in nfsd4_free_layout_stateid()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
Commit d12af460df27 ("nfsd: fix BUG_ON in nfsd4_alloc_layout_stateid on racing delegation revoke") replaced BUG_ON(!ls->ls_file) with a bail-out that calls nfs4_put_stid() on the partially initialized layout stateid.
nfs4_alloc_stid() leaves sc_count at 1 and nothing takes another reference before that bail-out, so the put runs sc_free, which is nfsd4_free_layout_stateid(). That function uses ls->ls_file unconditionally, both for vfs_setlease() and for nfsd_file_put(), and nfsd_file_put() does not accept NULL either. The new error path thus turns the race it was meant to handle gracefully into a NULL pointer dereference. The nfsd4_layout_setlease() failure path that already called nfs4_put_stid() was safe only because the BUG_ON guaranteed ls_file was non-NULL.
Upstream does not have this problem because its destructor goes through nfsd4_close_layout(), which tests the pointer before using it. That helper came in with the admin-revoke series, which is not in 6.6, so just add the NULL test here.
--- fs/nfsd/nfs4layouts.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/nfsd/nfs4layouts.c +7 -3
@@ -169,9 +169,13 @@ nfsd4_free_layout_stateid(struct nfs4_stid *stid)list_del_init (&ls->ls_perfile);spin_unlock (&fp->fi_lock); -if (!nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls) -vfs_setlease (ls->ls_file->nf_file,F_UNLCK ,NULL , (void **)&ls); -nfsd_file_put (ls->ls_file); +/* ls_file is NULL if nfsd4_alloc_layout_stateid() bailed out early */ +if (ls->ls_file) { +if (!nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls) +vfs_setlease (ls->ls_file->nf_file,F_UNLCK ,NULL , + (void **)&ls); +nfsd_file_put (ls->ls_file); + }if (ls->ls_recalled)atomic_dec (&ls->ls_stid.sc_file->fi_lo_recalls);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1373/3318 s390/vmcp: Initialize full session info to zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
[ Upstream commit f63eb4ee4a30fc5d8de07a229d92310e3c8d560c ]
The cma_alloc bit as well as the response can contain old data. cma_release will not free the kmalloced memory in that case and the response code might leak kernel stack data to CAP_SYS_ADMIN users.
--- drivers/s390/char/vmcp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/s390/char/vmcp.c +1 -3
@@ -105,13 +105,11 @@ static int vmcp_open(struct inode *inode, struct file *file)if (!capable (CAP_SYS_ADMIN ))return -EPERM ; - session =kmalloc (sizeof (*session),GFP_KERNEL ); + session =kzalloc (sizeof (*session),GFP_KERNEL );if (!session)return -ENOMEM ; session->bufsize =PAGE_SIZE ; - session->response =NULL ; - session->resp_size =0 ;mutex_init (&session->mutex); file->private_data = session;return nonseekable_open (inode, file);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1374/3318 wifi: mt76: mt792x: fix negative errno truncation in offload capability
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Cong <[email protected]>
[ Upstream commit d0115096429ca090a592770c7645f9553a839954 ]
Returning a negative errno as u8 turned -ENOENT into 0xfe, wrongly enabling CNM and NAN caps. Return int and default to no caps on error.
--- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +9 -2
@@ -591,7 +591,7 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw) }EXPORT_SYMBOL_GPL (mt792x_init_wiphy); -static u8 +static int mt792x_get_offload_capability (struct device *dev,const char *fw_wm) {const struct mt76_connac2_fw_trailer *hdr;
@@ -653,13 +653,20 @@ mt792x_get_mac80211_ops(struct device *dev, void *drv_data, u8 *fw_features) { struct ieee80211_ops *ops; +int ret; ops =devm_kmemdup (dev, mac80211_ops,sizeof (struct ieee80211_ops ),GFP_KERNEL );if (!ops)return NULL ; - *fw_features =mt792x_get_offload_capability (dev, drv_data); + ret =mt792x_get_offload_capability (dev, drv_data); +if (ret <0 ) { +dev_warn (dev,"failed to read firmware offload caps: %d\n" , ret); + *fw_features =0 ; + }else { + *fw_features = ret; + }if (!(*fw_features & MT792x_FW_CAP_CNM)) { ops->remain_on_channel =NULL ; ops->cancel_remain_on_channel =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1375/3318 jbd2: dont advance j_fc_off before the buffer is recorded
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daejun Park <[email protected]>
commit 9f359c031885bb50add7d23c7a5a0e9755b134c9 upstream.
jbd2_fc_get_buf() increments journal->j_fc_off before jbd2_journal_bmap() and __getblk() have had a chance to fail. When either does, the slot j_fc_wbuf[fc_off] is never assigned, but j_fc_off already counts it.
ext4 then fails the fast commit and falls back, and the fallback path reaches jbd2_fc_release_bufs() via ext4_fc_commit -> jbd2_fc_end_commit_fallback -> __jbd2_fc_end_commit -> ext4_fc_cleanup. That walks down from j_fc_off - 1 and put_bh()es every slot until it sees NULL, so it also touches the slot that was never written. j_fc_wbuf comes from a plain kmalloc() and is never zeroed, so a slot used for the first time holds uninitialised heap data.
Advance j_fc_off only after the buffer head has been stored. That restores the invariant that j_fc_off covers exactly the filled slots, which is what jbd2_fc_release_bufs() relies on: the live buffers of the current fast commit sit above the NULLs the previous one released, so stopping at the first NULL is correct.
Reproduced on a KASAN kernel with an ext4 fast_commit filesystem on a loop device, truncating the backing file under the live mount so that only the journal's fast-commit region falls past the end of the device. __getblk() then fails for the first fast-commit block while the rest of the journal is still addressable, so the journal is not aborted and the fast commit reaches the fallback path. j_fc_wbuf was poisoned to make the read of the never-written slot visible:
BUG: KASAN: wild-memory-access in jbd2_fc_release_bufs+0x6b/0xd0 Write of size 4 at addr 5a5a5a5a5a5a5ab2 by task sync/961 jbd2_fc_release_bufs+0x6b/0xd0 ext4_fc_cleanup+0x97/0x830 __jbd2_fc_end_commit+0x37/0xc0 ext4_fc_commit+0x524/0x560 ext4_sync_file+0x3c4/0x4b0 __x64_sys_fsync+0x20/0x30
With this patch the same run leaves j_fc_off at 0 across repeated __getblk() failures and completes cleanly.
[ Context: in 6.6.y, jbd2_fc_get_buf() still advances j_fc_off inside
the if/else bounds check, so the increment is removed from there. The change is otherwise the same as upstream. ]
--- fs/jbd2/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/journal.c +1 -1
@@ -869,7 +869,6 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)if (journal->j_fc_off + journal->j_fc_first < journal->j_fc_last) { fc_off = journal->j_fc_off; blocknr = journal->j_fc_first + fc_off; - journal->j_fc_off++; }else { ret = -EINVAL ; }
@@ -887,6 +886,7 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out) journal->j_fc_wbuf[fc_off] = bh; + journal->j_fc_off++; *bh_out = bh;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1376/3318 spi: bcm-qspi: reject oversized dummy bytes in mspi exec_mem_op
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weibin Liu <[email protected]>
[ Upstream commit 9e44f0df3fff215d9033089e85980048c3ac132a ]
bcm_qspi_mspi_exec_mem_op() builds a local command buffer cmd[6] holding one opcode byte, up to four address bytes and one spare byte, and sets t[0].len = op->addr.nbytes + op->dummy.nbytes + 1. bcm_qspi_exec_mem_op() only validates op->addr.nbytes <= 4 and never bounds op->dummy.nbytes, which spi_mem_check_op() also leaves unrestricted. With addr.nbytes = 4 and dummy.nbytes >= 2 the length becomes 7 or more, so write_to_hw() reads past cmd[] on the kernel stack and pushes the leaked bytes into the hardware TXRAM.
Reject operations whose dummy phase does not fit the remaining byte of cmd[] by requiring op->dummy.nbytes <= 1, so such transfers fall back to the generic SPI path instead of overrunning the buffer.
--- drivers/spi/spi-bcm-qspi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm-qspi.c +2 -1
@@ -1197,8 +1197,9 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem,u32 addr =0 , len;u_char *buf; +/* cmd[] holds 1 opcode + 4 address + 1 dummy byte at most */ if (!op->data.nbytes || !op->addr.nbytes || op->addr.nbytes >4 || - op->data.dir !=SPI_MEM_DATA_IN ) + op->dummy.nbytes >1 || op->data.dir !=SPI_MEM_DATA_IN )return -ENOTSUPP ; buf = op->data.buf.in;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1377/3318 pwm: tiehrpwm: Clear period on disable to allow reconfiguration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit e74b9a7ee50071aad25d3989bf985292f90b0c6e ]
Both channels share one period register, so ehrpwm_pwm_config() rejects a period differing from the sibling's period_cycles[]. That value was cleared only in .free(), not in .disable(), so a stopped channel kept blocking the sibling from switching to a new frequency. Clear it in .disable() too.
Testcase:
cd /sys/class/pwm/pwmchip0; echo 0 > export; echo 1 > export for p in pwm0 pwm1; do
echo 1000000 > $p/period; echo 500000 > $p/duty_cycle
echo 1 > $p/enable; echo 0 > $p/enable; echo 2000000 > $p/period done
echo 1 > pwm0/enable # before: -EINVAL, after: succeeds
--- drivers/pwm/pwm-tiehrpwm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pwm/pwm-tiehrpwm.c +3 -0
@@ -386,6 +386,9 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)/* Disable clock on PWM disable */ pm_runtime_put_sync (chip->dev); + +/* A disabled channel must not constrain the sibling's period */ + pc->period_cycles[pwm->hwpwm] =0 ; }static void ehrpwm_pwm_free (struct pwm_chip *chip,struct pwm_device *pwm)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1378/3318 media: uvcvideo: Add autosuspend quirk for AVerMedia Live Gamer HD 2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit b79251c881bb39f70c6f6fb30ad5d454b78c9f4a ]
A user has reported that this device gets stuck in a loop where every few seconds it will turn off and turn back on, causing audio devices to disappear and reappear, its LED to flash, spamming dmesg, etc. This only happens when not in use; everything is fine when the video device is actually being used.
They also reported that using the AUTOSUSPEND quirk via module parameters fixes the issue.
Add the device to the quirk list.
ID 07ca:1570 AVerMedia Technologies, Inc. AVerMedia USB Device Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1570 AVerMedia USB Device
bcdDevice 1.00
iManufacturer 6 AVerMedia iProduct 7 AVerMedia USB Device iSerial 3 53106326013650 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x01d6
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 150mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 8 AVerMedia Live Gamer HD 2
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 0
iInterface 8 AVerMedia Live Gamer HD 2
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.00
wTotalLength 0x004d
dwClockFrequency 120.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
Warning: Descriptor too short
bUnitID 3
bSourceID 1
wMaxMultiplier 0
bControlSize 2
bmControls 0x0000000f
Brightness
Contrast
Hue
Saturation
iProcessing 0
bmVideoStandards 0x09
None
SECAM - 625/50
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 4
guidExtensionCode {c66d125b-0480-0844-8c26-b8363a84de63}
bNumControls 17
bNrInPins 1
baSourceID( 0) 3
bControlSize 3
bmControls( 0) 0x07
bmControls( 1) 0xfe
bmControls( 2) 0x01
iExtension 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 8 AVerMedia Live Gamer HD 2
VideoStreaming Interface Descriptor:
bLength 14
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 1
wTotalLength 0x00bd
bEndpointAddress 0x89 EP 9 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 0
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 0
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 1
bNumFrameDescriptors 5
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 0
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x00
Still image unsupported
wWidth 640
wHeight 480
dwMinBitRate 294617088
dwMaxBitRate 294912000
dwMaxVideoFrameBufferSize 614400
dwDefaultFrameInterval 166833
bFrameIntervalType 2
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 2
bmCapabilities 0x00
Still image unsupported
wWidth 720
wHeight 480
dwMinBitRate 331444224
dwMaxBitRate 331776000
dwMaxVideoFrameBufferSize 691200
dwDefaultFrameInterval 166833
bFrameIntervalType 2
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 3
bmCapabilities 0x00
Still image unsupported
wWidth 720
wHeight 576
dwMinBitRate 331776000
dwMaxBitRate 331776000
dwMaxVideoFrameBufferSize 829440
dwDefaultFrameInterval 200000
bFrameIntervalType 1
dwFrameInterval( 0) 200000
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 4
bmCapabilities 0x00
Still image unsupported
wWidth 1280
wHeight 720
dwMinBitRate 737280000
dwMaxBitRate 884736000
dwMaxVideoFrameBufferSize 1843200
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 46
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 5
bmCapabilities 0x00
Still image unsupported
wWidth 1920
wHeight 1080
dwMinBitRate 994332672
dwMaxBitRate 1990656000
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 5
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
dwFrameInterval( 3) 333333
dwFrameInterval( 4) 333667
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 1 (BT.709,sRGB)
bTransferCharacteristics 1 (BT.709)
bMatrixCoefficients 4 (SMPTE 170M (BT.601))
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 8 AVerMedia Live Gamer HD 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x89 EP 9 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x1400 3x 1024 bytes
bInterval 1
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 9 AVerMedia Live Gamer HD 2
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 9 AVerMedia Live Gamer HD 2
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x003a
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 1
wChannelConfig 0x0000
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 5
wTerminalType 0x0603 Line Connector
bAssocTerminal 0
bNrChannels 1
wChannelConfig 0x0000
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 4
bControlSize 1
bmaControls(0) 0x01
Mute Control
iFeature 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 5 (SELECTOR_UNIT)
bUnitID 4
bNrInPins 2
baSourceID(0) 1
baSourceID(1) 5
iSelector 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 9 AVerMedia Live Gamer HD 2
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 9 AVerMedia Live Gamer HD 2
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x8a EP 10 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c0 1x 192 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0016
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000006
BESL Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps) Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 4 micro seconds
bU2DevExitLat 4 micro seconds
Device Status: 0x0000
(Bus Powered)
--- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +9 -0
@@ -2896,6 +2896,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth }, +/* AVerMedia Live Gamer HD 2 capture card */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x07ca, + .idProduct = 0x1570, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_DISABLE_AUTOSUSPEND) }, /* ViMicro Vega */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1379/3318 media: uvcvideo: Force UVC version for Avermedia GC515
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit 65444446f0c595c0e250368cde88735b59ccc446 ]
The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.
The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.
Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10
iManufacturer 1 AVerMedia iProduct 2 X'tra Go GC515 iSerial 3 5313180000221 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000
--- drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
@@ -2896,6 +2896,17 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth }, +/* Avermedia GC515 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x07ca, + .idProduct = 0x1515, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = UVC_PC_PROTOCOL_15, + .driver_info = (kernel_ulong_t)&(const struct uvc_device_info ){ + .uvc_version =0x0110 , + } }, /* AVerMedia Live Gamer HD 2 capture card */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1380/3318 efi/libstub: arm64: Dont use the platform register x18
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 4c86b5f3fa78347fa9cbc9e8ec06615b2f80e397 upstream
The UEFI specification designates x18, the platform register, as "do not use" on AArch64, so that UEFI code is compatible both with an OS that assigns a fixed role to x18, and with one that uses it as a temporary register.
The arm64 EFI stub and the EFI zboot decompressor only avoid x18 if the kernel is built with shadow call stacks, as that is the only case where -ffixed-x18 is added to KBUILD_CFLAGS, which the stub inherits. Otherwise, the compiler is free to use x18 as a temporary register, and it does so.
So pass -ffixed-x18 unconditionally when building the stub for arm64, so that the image can be run by loaders that rely on x18 being left alone, such as a kernel that uses it for its shadow call stack.
--- drivers/firmware/efi/libstub/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/Makefile +1 -1
@@ -22,7 +22,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -std=gnu11 \ # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin -cflags-$(CONFIG_ARM64) += -fpie $(DISABLE_STACKLEAK_PLUGIN) \ +cflags-$(CONFIG_ARM64) += -fpie $(DISABLE_STACKLEAK_PLUGIN) -ffixed-x18 \ -fno-unwind-tables -fno-asynchronous-unwind-tables cflags-$(CONFIG_ARM) += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \ -DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1381/3318 media: require two-byte Cypress type 04 records
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e22872703386c3885d8c6bd595124587bc4e5081 ]
Both Cypress Intel HEX parsers read two address bytes from type 04 records. Generic record framing permits any record length, so a short record can make the parser consume the checksum or bytes beyond the firmware record. A longer record also violates the Intel HEX type 04 layout.
Require the type 04 payload length to be exactly two bytes in both implementations.
--- drivers/media/common/cypress_firmware.c | 2 ++ drivers/media/usb/dvb-usb/dvb-usb-firmware.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/media/common/cypress_firmware.c +2 -0
@@ -59,6 +59,8 @@ static int cypress_get_hexline(const struct firmware *fw,if (hx->type ==0x04 ) {/* b[4] and b[5] are the Extended linear address record data * field */ +if (hx->len !=2 ) +return -EINVAL ; hx->addr |= (b[4 ] <<24 ) | (b[5 ] <<16 ); }
drivers/media/usb/dvb-usb/dvb-usb-firmware.c +2 -0
@@ -141,6 +141,8 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,if (hx->type ==0x04 ) {/* b[4] and b[5] are the Extended linear address record data field */ +if (hx->len !=2 ) +return -EINVAL ; hx->addr |= (b[4 ] <<24 ) | (b[5 ] <<16 );/* hx->len -= 2; data_offs += 2; */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1382/3318 media: adv748x: Fix endpoint reference leaks on probe failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 359db09cf055497075a668b192f4578a0ed00955 ]
adv748x_parse_dt() takes an extra reference for every endpoint saved in state->endpoints. If parsing later fails, adv748x_probe() skips adv748x_dt_cleanup(), so the saved references remain held. A CSI-2 lane parsing error also returns from for_each_endpoint_of_node() without dropping the iterator's reference.
Save the endpoint reference only after lane parsing succeeds. Drop the iterator reference before returning a lane parsing error and route all parse failures through the endpoint cleanup path to release any saved references. This retains the endpoints only for a successful probe.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/media/i2c/adv748x/adv748x-core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/media/i2c/adv748x/adv748x-core.c +7 -6
@@ -675,9 +675,6 @@ static int adv748x_parse_dt(struct adv748x_state *state)continue ; } -of_node_get (ep_np); - state->endpoints[ep.port] = ep_np; -/* * At least one input endpoint and one output endpoint shall * be defined.
@@ -689,8 +686,13 @@ static int adv748x_parse_dt(struct adv748x_state *state)/* Store number of CSI-2 lanes used for TXA and TXB. */ ret =adv748x_parse_csi2_lanes (state, ep.port, ep_np); -if (ret) +if (ret) { +of_node_put (ep_np);return ret; + } + +of_node_get (ep_np); + state->endpoints[ep.port] = ep_np; }return in_found && out_found ?0 : -ENODEV ;
@@ -739,7 +741,7 @@ static int adv748x_probe(struct i2c_client *client) ret =adv748x_parse_dt (state);if (ret) {adv_err (state,"Failed to parse device tree" ); - goto err_free_mutex; + goto err_cleanup_dt; }/* Configure IO Regmap region */
@@ -809,7 +811,6 @@ static int adv748x_probe(struct i2c_client *client)adv748x_unregister_clients (state); err_cleanup_dt:adv748x_dt_cleanup (state); -err_free_mutex:mutex_destroy (&state->mutex);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1383/3318 hwmon: (lm70) Fix rounding of negative temperatures
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
[ Upstream commit eddb0aaacce4baa9d8176eb2f4bd9e99e867f8fc ]
temp1_input_show() drops the low bits of the temperature register by dividing the raw value (raw / 32 on the LM70). These bits are not part of the temperature: the LM70, LM71, LM74 and TMP122/TMP124 always return some of them as 1, and the TMP125 fills them with copies of the temperature LSB. Division rounds toward zero, so a negative temperature with any of these bits set is reported one LSB too high.
For example, the TMP122 returns 0xffff for -0.0625 degrees C, which the driver reports as 0. The LM70 returns 0xf39f for -25 degrees C, which the driver reports as -24750.
Use an arithmetic right shift instead, which drops the low bits and rounds down.
--- drivers/hwmon/lm70.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/lm70.c +4 -4
@@ -97,21 +97,21 @@ static ssize_t temp1_input_show(struct device *dev,*/ switch (p_lm70->chip) {case LM70_CHIP_LM70 : - val = ((int )raw /32 ) *250 ; + val = ((int )raw >>5 ) *250 ;break ;case LM70_CHIP_TMP121 :case LM70_CHIP_TMP122 :case LM70_CHIP_LM74 : - val = ((int )raw /8 ) *625 /10 ; + val = ((int )raw >>3 ) *625 /10 ;break ;case LM70_CHIP_LM71 : - val = ((int )raw /4 ) *3125 /100 ; + val = ((int )raw >>2 ) *3125 /100 ;break ;case LM70_CHIP_TMP125 : - val = (sign_extend32 (raw,14 ) /32 ) *250 ; + val = (sign_extend32 (raw,14 ) >>5 ) *250 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1384/3318 iio: pressure: dps310: fix CFG_REG bit definitions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rupesh Majhi <[email protected]>
[ Upstream commit 4334dc4092c271e6cd010c2ee70b7f4415c4c199 ]
Driver defines them as BIT(4), BIT(5) and BIT(6). Per datasheet P_SHIFT is bit 2, FIFO_EN is bit 1 and SPI_MODE is bit 0.
Only P_SHIFT has a user. dps310_set_pres_precision() sets it at oversampling 16 or above, so with wrong bit the result register is never shifted and stops matching the scale factor compensation divides by. in_pressure_input returns -ERANGE at oversampling 16, 32 and 64.
FIFO_EN needed by FIFO support later in this series.
--- drivers/iio/pressure/dps310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/pressure/dps310.c +3 -3
@@ -50,9 +50,9 @@#define DPS310_CFG_REG 0x09#define DPS310_INT_HL BIT(7)#define DPS310_TMP_SHIFT_EN BIT(3) -#define DPS310_PRS_SHIFT_EN BIT(4) -#define DPS310_FIFO_EN BIT(5) -#define DPS310_SPI_EN BIT(6) +#define DPS310_PRS_SHIFT_EN BIT(2) +#define DPS310_FIFO_EN BIT(1) +#define DPS310_SPI_EN BIT(0)#define DPS310_RESET 0x0c#define DPS310_RESET_MAGIC 0x09#define DPS310_COEF_BASE 0x10
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1385/3318 media: mediatek: jpeg: Avoid context access after job finish
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kazuki Hanai <[email protected]>
[ Upstream commit 7c7f31405b76acd95a628c834ee8a2d6da439782 ]
v4l2_m2m_job_finish() publishes job completion and wakes waiters before it returns. A concurrent file release can therefore finish v4l2_m2m_ctx_release() and free the context while the single-core IRQ handler continues with its tail.
Both handlers only need the device for the matching runtime PM put. Use the IRQ-owned jpeg pointer instead of dereferencing ctx after completion has been published. This preserves the get/put pairing and removes the post-completion context access.
--- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +2 -2
@@ -1585,7 +1585,7 @@ static irqreturn_t mtk_jpeg_enc_done(struct mtk_jpeg_dev *jpeg)v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state);v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); -pm_runtime_put (ctx->jpeg->dev); +pm_runtime_put (jpeg->dev);return IRQ_HANDLED ; }
@@ -1872,7 +1872,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state);v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); -pm_runtime_put (ctx->jpeg->dev); +pm_runtime_put (jpeg->dev);return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1386/3318 NFSv4/pnfs: Free the netid when draining a data-server address list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit a7c8e96d1b9fa327cbdea514d047c8295b28d49a ]
nfs4_pnfs_ds_addr_free() releases all three of an address entry's allocations, but the four sites that drain a decoded list before it reaches a data server open-code the loop and free only da_remotestr and the entry, leaking da_netid. Both layout drivers drain that list when nfs4_pnfs_ds_add() returned a data server already in the cache, and again on their error exits.
Lift the drain into nfs4_pnfs_ds_addr_list_free() so an address list has one owner. A striping mount reaches the cached case on nearly every GETDEVICEINFO, since many deviceIDs name the same data servers.
--- fs/nfs/filelayout/filelayoutdev.c | 17 ++--------------- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 17 ++--------------- fs/nfs/pnfs.h | 1 + fs/nfs/pnfs_nfs.c | 21 +++++++++++++-------- 4 files changed, 18 insertions(+), 38 deletions(-)
fs/nfs/filelayout/filelayoutdev.c +2 -15
@@ -175,27 +175,14 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_drain_dsaddrs;/* If DS was already in cache, free ds addrs */ -while (!list_empty (&dsaddrs)) { - da =list_first_entry (&dsaddrs, - struct nfs4_pnfs_ds_addr, - da_node); -list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); - } +nfs4_pnfs_ds_addr_list_free (&dsaddrs); }__free_page (scratch);return dsaddr; out_err_drain_dsaddrs: -while (!list_empty (&dsaddrs)) { - da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr, - da_node); -list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); - } +nfs4_pnfs_ds_addr_list_free (&dsaddrs); out_err_free_deviceid:nfs4_fl_free_deviceid (dsaddr);/* stripe_indicies was part of dsaddr */
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -15
@@ -155,26 +155,13 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err_drain_dsaddrs;/* If DS was already in cache, free ds addrs */ -while (!list_empty (&dsaddrs)) { - da =list_first_entry (&dsaddrs, - struct nfs4_pnfs_ds_addr, - da_node); -list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); - } +nfs4_pnfs_ds_addr_list_free (&dsaddrs);__free_page (scratch);return new_ds; out_err_drain_dsaddrs: -while (!list_empty (&dsaddrs)) { - da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr, - da_node); -list_del_init (&da->da_node); -kfree (da->da_remotestr); -kfree (da); - } +nfs4_pnfs_ds_addr_list_free (&dsaddrs);kfree (ds_versions); out_scratch:
fs/nfs/pnfs.h +1 -0
@@ -416,6 +416,7 @@ int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds,struct nfs4_pnfs_ds_addr *nfs4_decode_mp_ds_addr (struct net *net,struct xdr_stream *xdr,gfp_t gfp_flags); +void nfs4_pnfs_ds_addr_list_free (struct list_head *dsaddrs); void pnfs_layout_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, struct nfs_commit_info *cinfo,
fs/nfs/pnfs_nfs.c +13 -8
@@ -679,23 +679,28 @@ static void nfs4_pnfs_ds_addr_free(struct nfs4_pnfs_ds_addr *da)kfree (da); } -static void destroy_ds (struct nfs4_pnfs_ds *ds) +void nfs4_pnfs_ds_addr_list_free (struct list_head *dsaddrs) {struct nfs4_pnfs_ds_addr *da; +while (!list_empty (dsaddrs)) { + da = list_first_entry(dsaddrs, struct nfs4_pnfs_ds_addr, + da_node); +list_del_init (&da->da_node); +nfs4_pnfs_ds_addr_free (da); + } +} +EXPORT_SYMBOL_GPL (nfs4_pnfs_ds_addr_list_free); + +static void destroy_ds (struct nfs4_pnfs_ds *ds) +{dprintk ("--> %s\n" , __func__);ifdebug (FACILITY)print_ds (ds);nfs_put_client (ds->ds_clp); -while (!list_empty (&ds->ds_addrs)) { - da =list_first_entry (&ds->ds_addrs, - struct nfs4_pnfs_ds_addr, - da_node); -list_del_init (&da->da_node); -nfs4_pnfs_ds_addr_free (da); - } +nfs4_pnfs_ds_addr_list_free (&ds->ds_addrs);kfree (ds->ds_remotestr);kfree (ds);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1387/3318 mm/memcontrol: fix data-race on reading jiffies_64
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit c20cf1c3c8cdd98618d6fcc794003a0e003ae858 ]
KCSAN reported a data-race between tick_do_update_jiffies64() updating jiffies_64 and mem_cgroup_flush_stats_ratelimited() reading it directly.
Unlike jiffies, jiffies_64 is not volatile, so raw reads are plain accesses and can even be torn on 32-bit. Use get_jiffies_64() instead, and fix the same pattern in mem_cgroup_flush_foreign().
--- mm/memcontrol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/memcontrol.c +3 -3
@@ -737,7 +737,7 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val)static void do_flush_stats (struct mem_cgroup *memcg) {if (mem_cgroup_is_root (memcg)) -WRITE_ONCE (flush_last_time, jiffies_64); +WRITE_ONCE (flush_last_time,get_jiffies_64 ());cgroup_rstat_flush (memcg->css.cgroup); }
@@ -766,7 +766,7 @@ void mem_cgroup_flush_stats(struct mem_cgroup *memcg)void mem_cgroup_flush_stats_ratelimited (struct mem_cgroup *memcg) {/* Only flush if the periodic flusher is one full cycle late */ -if (time_after64 (jiffies_64,READ_ONCE (flush_last_time) +2 *FLUSH_TIME )) +if (time_after64 (get_jiffies_64 (),READ_ONCE (flush_last_time) +2 *FLUSH_TIME ))mem_cgroup_flush_stats (memcg); }
@@ -4780,7 +4780,7 @@ void mem_cgroup_flush_foreign(struct bdi_writeback *wb) {struct mem_cgroup *memcg =mem_cgroup_from_css (wb->memcg_css);unsigned long intv =msecs_to_jiffies (dirty_expire_interval *10 ); -u64 now = jiffies_64; +u64 now =get_jiffies_64 ();int i;for (i =0 ; i <MEMCG_CGWB_FRN_CNT ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1388/3318 smb: client: fix OOB read in the SMB_FIND_FILE_UNIX name scan
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Oliva <[email protected]>
[ Upstream commit fa0c2f082946917c3f07d2475c8ce73a8c96d0e2 ]
cifs_fill_dirent_unix() finds the length of an SMB_FIND_FILE_UNIX entry name by scanning for its terminating NUL, over up to PATH_MAX + 1 UTF-16 units in cifs_unicode_bytelen() or PATH_MAX bytes in strnlen(). Neither scan knows where the response ends. cifs_fill_dirent() only requires the fixed part of the entry to fit, so the name can start exactly at the end of the received data, and a name that holds no terminator is then scanned for 8194 bytes, or 4096 bytes without unicode, past the end of the received data. SendReceive() copies at most 16468 bytes into the 16588-byte cifs_request allocation, so for a response of that length up to 8074 of the bytes scanned lie past the end of the allocation. Before the preceding patches bounded where the entry starts, the entry itself could start up to 820 bytes past the end of the allocation at the default CIFSMaxBufSize, and its name 928 bytes past it, so all 8194 scanned bytes would lie outside. cifs_fill_dirent() rejects the name afterwards because it extends past the end of the response, so nothing of what was read is used, but the out-of-bounds read itself remains.
SMB_FIND_FILE_UNIX is only used with SMB1 servers that offer the Unix extensions; SMB1 is not negotiated by default and requires an explicit vers=1.0 mount.
Before the preceding patches, an entry placed past the buffer left the scan out of bounds from its first read. They bound where the entry starts, but nothing bounds the scan, so a name that holds no terminator still runs off the end of the allocation. Reproduced on the unpatched tree with KASAN enabled, for an entry that starts inside the response, which is the case the preceding patches leave open:
==================================================================
BUG: KASAN: slab-out-of-bounds in cifs_save_resume_key.isra.0+0x75c/0x7f0 Read of size 2 at addr ffff88807ee640cc by task ls/84 CPU: 0 UID: 0 PID: 84 Comm: ls Not tainted 7.3.0-rc4-00457-gf14572c203d5 #69 PREEMPT(lazy) Call Trace: <TASK> kasan_report+0xdf/0x1a0 cifs_save_resume_key.isra.0+0x75c/0x7f0 cifs_readdir+0x1ed6/0x29c0 iterate_dir+0x1c0/0x570 __x64_sys_getdents64+0x133/0x270 do_syscall_64+0x109/0x5d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Allocated by task 84 on cpu 1 at 15.751078s: cifs_buf_get+0x36/0x90 smb_init+0x4f/0x110 CIFSFindNext+0xf7/0x14c0 cifs_readdir+0xf51/0x29c0 The buggy address belongs to the object at ffff88807ee60000 which belongs to the cache cifs_request of size 16588 The buggy address is located 0 bytes to the right of allocated 16588-byte region [ffff88807ee60000, ffff88807ee640cc) ==================================================================
The two bytes read there are one UTF-16 unit of the scan, at the first byte past the end of the object. The scan carries on from there, reported again 2, 4 and 6 bytes to the right.
Pass the number of bytes that follow the fixed part of the entry to cifs_fill_dirent_unix() and stop both scans there. A scan that reaches the end of the response without finding a terminator now fails: it returns a name that ends exactly at the end of the response and would otherwise pass the bound, so cifs_fill_dirent() requires the position of the terminator of an SMB_FIND_FILE_UNIX name to lie inside the response as well. Accepting such a name truncated at the end of the response would turn a malformed entry into a directory entry, or a resume name, that no server sent. A name longer than the PATH_MAX cap of the scans is still truncated there, as before, when the response extends past the cap. The message cifs_unicode_bytelen() logs when it finds no terminator now covers both limits.
This patch depends on "smb: client: fix OOB read of the resume name sent in TRANS2_FIND_NEXT2", which adds the end argument of cifs_fill_dirent() and the length it derives from it; the backport note in that patch applies to this one as well.
--- fs/smb/client/readdir.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
fs/smb/client/readdir.c +18 -11
@@ -454,17 +454,20 @@ initiate_cifs_search(const unsigned int xid, struct file *file, }/* return length of unicode string in bytes */ -static int cifs_unicode_bytelen (const char *str) +static size_t cifs_unicode_bytelen (const char *str,size_t maxlen) { -int len;const __le16 *ustr = (const __le16 *)str; +size_t len; -for (len =0 ; len <=PATH_MAX ; len++) { + maxlen =umin (PATH_MAX +1 , maxlen /sizeof (__le16)); +for (len =0 ; len < maxlen; len++) {if (ustr[len] ==0 ) -return len <<1 ; +return len *sizeof (__le16); } -cifs_dbg (FYI ,"Unicode string longer than PATH_MAX found\n" ); -return len <<1 ; + len *=sizeof (__le16); +cifs_dbg (FYI ,"%s: Unicode string not terminated within %zu bytes\n" , + __func__, len); +return len; }static char *nxt_dir_entry (char *old_entry,char *end_of_smb,int level)
@@ -530,13 +533,13 @@ static void cifs_fill_dirent_posix(struct cifs_dirent *de, }static void cifs_fill_dirent_unix (struct cifs_dirent *de, -const FILE_UNIX_INFO *info,bool is_unicode) +const FILE_UNIX_INFO *info,bool is_unicode,size_t maxlen) { de->name = &info->FileName[0 ];if (is_unicode) - de->namelen =cifs_unicode_bytelen (de->name); + de->namelen =cifs_unicode_bytelen (de->name, maxlen);else - de->namelen =strnlen (de->name,PATH_MAX ); + de->namelen =strnlen (de->name,min_t (size_t, maxlen,PATH_MAX )); de->resume_key = info->ResumeKey; de->ino =le64_to_cpu (info->basic.UniqueId); }
@@ -587,6 +590,7 @@ static int cifs_fill_dirent(struct cifs_dirent *de, const void *info, const char *end, u16 level, bool is_unicode) { size_t len = end > (const char *)info ? end - (const char *)info : 0; +size_t nul_len =0 ;memset (de,0 ,sizeof (*de));
@@ -599,7 +603,9 @@ static int cifs_fill_dirent(struct cifs_dirent *de, const void *info,case SMB_FIND_FILE_UNIX :if (len < offsetof(FILE_UNIX_INFO , FileName)) goto too_short; -cifs_fill_dirent_unix (de, info, is_unicode); +cifs_fill_dirent_unix (de, info, is_unicode, + len - offsetof(FILE_UNIX_INFO , FileName)); + nul_len = is_unicode ?sizeof (__le16) :sizeof (__u8);break ;case SMB_FIND_FILE_DIRECTORY_INFO :if (len < offsetof(FILE_DIRECTORY_INFO , FileName))
@@ -632,7 +638,8 @@ static int cifs_fill_dirent(struct cifs_dirent *de, const void *info, }if (de->name && - (end < de->name || (size_t )(end - de->name) < de->namelen)) { + (end < de->name || + (size_t )(end - de->name) < de->namelen + nul_len)) {cifs_dbg (VFS ,"%s: search entry name extends past end of SMB\n" , __func__);return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1389/3318 mfd: ab8500: Fix child device leaks on probe failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 5bf2ae8b131d4ae9c0ed5f7aa02532645f512022 ]
ab8500_probe() registers MFD child devices before completing the remaining device initialization. If a later MFD registration or sysfs group creation fails, previously registered child devices are not removed.
Use devm_mfd_add_devices() so registered MFD child devices are removed when probe fails.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
--- drivers/mfd/ab8500-core.c | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/mfd/ab8500-core.c +23 -21
@@ -1195,39 +1195,41 @@ static int ab8500_probe(struct platform_device *pdev)return ret;if (is_ab9540 (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab9540_devs, -ARRAY_SIZE (ab9540_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab9540_devs, +ARRAY_SIZE (ab9540_devs),NULL , +0 , ab8500->domain);else if (is_ab8540 (ab8500)) { - ret =mfd_add_devices (ab8500->dev,0 , ab8540_devs, -ARRAY_SIZE (ab8540_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8540_devs, +ARRAY_SIZE (ab8540_devs),NULL , +0 , ab8500->domain);if (ret)return ret;if (is_ab8540_1p2_or_earlier (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab8540_cut1_devs, -ARRAY_SIZE (ab8540_cut1_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , + ab8540_cut1_devs, +ARRAY_SIZE (ab8540_cut1_devs), +NULL ,0 , ab8500->domain);else /* ab8540 >= cut2 */ - ret =mfd_add_devices (ab8500->dev,0 , ab8540_cut2_devs, -ARRAY_SIZE (ab8540_cut2_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , + ab8540_cut2_devs, +ARRAY_SIZE (ab8540_cut2_devs), +NULL ,0 , ab8500->domain); }else if (is_ab8505 (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab8505_devs, -ARRAY_SIZE (ab8505_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8505_devs, +ARRAY_SIZE (ab8505_devs),NULL , +0 , ab8500->domain);else - ret =mfd_add_devices (ab8500->dev,0 , ab8500_devs, -ARRAY_SIZE (ab8500_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8500_devs, +ARRAY_SIZE (ab8500_devs),NULL , +0 , ab8500->domain);if (ret)return ret;/* Add battery management devices */ - ret =mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, -ARRAY_SIZE (ab8500_bm_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, +ARRAY_SIZE (ab8500_bm_devs),NULL , +0 , ab8500->domain);if (ret)dev_err (ab8500->dev,"error adding bm devices\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1390/3318 Bluetooth: selftest: Pin module for selftest debugfs file operations
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Viet Dung <[email protected]>
[ Upstream commit 64aabf94ecccb1120a63b4ee5a6761871a181a41 ]
An open debugfs file retains its file_operations pointer in the debugfs proxy state. However, test_smp_fops in net/bluetooth/smp.c and test_ecdh_fops in net/bluetooth/selftest.c have no .owner set to THIS_MODULE.
As a result, full_proxy_open_regular() calls fops_get() which succeeds without taking a reference to the bluetooth module. When CONFIG_BT=m and selftests are enabled, a userspace process can open either /sys/kernel/debug/bluetooth/selftest_smp or /sys/kernel/debug/bluetooth/selftest_ecdh and keep the file descriptor open while the module is unloaded (rmmod bluetooth).
When the userspace process subsequently closes the descriptor, full_proxy_release() accesses the already unmapped file_operations structure, triggering a kernel oops in full_proxy_release():
BUG: unable to handle page fault for address: fffffbfff8056f03 #PF: supervisor read access in kernel mode Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:full_proxy_release+0x8e/0x140 Call Trace: <TASK> __fput+0x39f/0xa60 fput_close_sync+0xff/0x200 __x64_sys_close+0x8c/0xf0 do_syscall_64+0x115/0x6a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
The issue was discovered via manual code audit of net/bluetooth/smp.c and net/bluetooth/selftest.c.
Set .owner = THIS_MODULE on test_smp_fops and test_ecdh_fops so that debugfs keeps the module pinned until the file descriptors are closed.
--- net/bluetooth/selftest.c | 1 + net/bluetooth/smp.c | 1 + 2 files changed, 2 insertions(+)
net/bluetooth/selftest.c +1 -0
@@ -191,6 +191,7 @@ static ssize_t test_ecdh_read(struct file *file, char __user *user_buf, }static const struct file_operations test_ecdh_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = test_ecdh_read, .llseek = default_llseek,
net/bluetooth/smp.c +1 -0
@@ -3736,6 +3736,7 @@ static ssize_t test_smp_read(struct file *file, char __user *user_buf, }static const struct file_operations test_smp_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = test_smp_read, .llseek = default_llseek,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1391/3318 tracing: Add the bucket size to expr_field_str()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
[ Upstream commit c027ed03bc03a0e82fc368eaad657584a4480c7a ]
expr_field_str() renders a HIST_FIELD_FL_BUCKET field as "pid.buckets", dropping the count, and parse_field() rejects that spelling.
get_hist_field_flags() returns the bare string "buckets" and keeps the count in hist_field->buckets. hist_field_print() appends it, expr_field_str() never did. Nothing reaches it today, since .buckets is refused on a value and no expression can carry one, but the next patch renders histogram keys with expr_field_str(), where a .buckets key is legal.
Append the count, as hist_field_print() does.
--- kernel/trace/trace_events_hist.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/trace_events_hist.c +3 -0
@@ -1747,6 +1747,9 @@ static bool expr_field_str(struct hist_field *field, struct seq_buf *s)seq_buf_printf (s,".%s" , flags_str); } +if (field->buckets) +seq_buf_printf (s,"=%lu" , field->buckets); +return !seq_buf_has_overflowed (s); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1392/3318 rds: fix out-of-bounds conn_path walks via handshake exthdrs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 50f2103fce43922b6e562937b2d2fc62089ff7ec ]
Both the lane and the connection-generation negotiation are driven by extension headers in handshake packets, and both are processed unconditionally, even on transports that are not multipath capable. A non-MP connection (t_mp_capable unset) owns exactly one rds_conn_path slot, so a peer claiming up to RDS_MPATH_WORKERS lanes makes every subsequent fan-out walk conn->c_path[0..7] at 504-byte strides past the single allocated slot (KASAN: "Read of size 8 in rds_conn_path_connect_if_down"); the generation negotiation opens a similar out-of-bounds walk on the same array.
Only process handshake extension headers when the connection's transport is multipath capable, so a peer can never make us walk lanes that do not exist. Both call sites in rds_recv_incoming() are gated.
This is a port of the Oracle UEK fix for the same issue, picked up where Paula's series of the same change left off.
This issue was discovered by Tencent CodeBuddy Security.
--- net/rds/recv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/rds/recv.c +4 -2
@@ -343,7 +343,8 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,rds_stats_inc (s_recv_ping);rds_send_pong (cp, inc->i_hdr.h_sport);/* if this is a handshake ping, start multipath if necessary */ -if (RDS_HS_PROBE (be16_to_cpu (inc->i_hdr.h_sport), +if (conn->c_trans->t_mp_capable && +RDS_HS_PROBE (be16_to_cpu (inc->i_hdr.h_sport),be16_to_cpu (inc->i_hdr.h_dport))) {rds_recv_hs_exthdrs (&inc->i_hdr, cp->cp_conn);rds_start_mprds (cp->cp_conn);
@@ -351,7 +352,8 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr, goto out; } -if (be16_to_cpu (inc->i_hdr.h_dport) ==RDS_FLAG_PROBE_PORT && +if (conn->c_trans->t_mp_capable && +be16_to_cpu (inc->i_hdr.h_dport) ==RDS_FLAG_PROBE_PORT && inc->i_hdr.h_sport ==0 ) {rds_recv_hs_exthdrs (&inc->i_hdr, cp->cp_conn);/* if this is a handshake pong, start multipath if necessary */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1393/3318 gpio: pca953x: Preserve wakeup accounting on parent IRQ failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sahaj Chaudhari <[email protected]>
[ Upstream commit a38bf551726a21c9bcc001b02164f30378b64b64 ]
pca953x_irq_set_wake() updates wakeup_path before asking the parent IRQ controller to change its wake state. If irq_set_irq_wake() fails, the IRQ core rolls back its wake state but the driver's counter remains changed.
A failed enable can therefore leave the expander marked as part of the wakeup path when no child IRQ has successfully enabled wakeup. A failed disable can make the driver stop retaining power even though wakeup is still enabled. The suspend and resume paths use this counter to decide whether to disable or enable the regulator.
Update wakeup_path only after the parent operation succeeds, leaving it unchanged on error.
--- drivers/gpio/gpio-pca953x.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpio/gpio-pca953x.c +6 -1
@@ -736,13 +736,18 @@ static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct pca953x_chip *chip =gpiochip_get_data (gc); +int ret; + + ret =irq_set_irq_wake (chip->client->irq, on); +if (ret) +return ret;if (on)atomic_inc (&chip->wakeup_path);else atomic_dec (&chip->wakeup_path); -return irq_set_irq_wake (chip->client->irq, on); +return 0 ; }static void pca953x_irq_bus_lock (struct irq_data *d)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1394/3318 f2fs: dont use truncate_inode_pages_final() on live inodes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 74bbd6ada01f91fcad60608e0417bf45a9fa99e6 ]
truncate_inode_pages_final() is meant to be called from ->evict_inode. It sets AS_EXITING on the mapping, and nothing ever clears it, to tell the VM that the inode is going away.
f2fs calls it in two places where the inode stays live:
- F2FS_IOC_START_ATOMIC_REPLACE uses it to drop the page cache of the original inode before setting i_size to 0. The atomic write then goes on through this inode.
- f2fs_abort_atomic_write() uses it to drop the uncommitted data. It is called on eviction, but also on the last writer's close in f2fs_release_file(), from f2fs_file_flush() when the atomic writer exits, from F2FS_IOC_ABORT_ATOMIC_WRITE and when F2FS_IOC_COMMIT_ATOMIC_WRITE fails.
Other processes may still have the file open or mapped in all of these cases. The mapping then stays marked as exiting for as long as the inode is in memory. This stops reclaim from storing workingset shadow entries for it and breaks any code that assumes an exiting mapping has no users left.
All we need in both places is to drop the page cache, so use truncate_inode_pages(mapping, 0) instead. The eviction path is not affected, because f2fs_pre_evict_inode() still calls truncate_inode_pages_final() after f2fs_abort_atomic_write().
--- fs/f2fs/file.c | 2 +- fs/f2fs/segment.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/file.c +1 -1
@@ -2335,7 +2335,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) fi->original_i_size = isize;if (truncate) {set_inode_flag (inode,FI_ATOMIC_REPLACE ); -truncate_inode_pages_final (inode->i_mapping); +truncate_inode_pages (inode->i_mapping,0 );f2fs_i_size_write (inode,0 ); isize =0 ; }
fs/f2fs/segment.c +1 -1
@@ -193,7 +193,7 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean)return ;if (clean) -truncate_inode_pages_final (inode->i_mapping); +truncate_inode_pages (inode->i_mapping,0 );release_atomic_write_cnt (inode);clear_inode_flag (inode,FI_ATOMIC_COMMITTED );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1395/3318 scsi: ufs: bsg: Validate request_len before accessing request
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
[ Upstream commit 42aa443718104d10dbdb6f258810b425eb2451f8 ]
ufs_bsg_request() and ufs_bsg_exec_advanced_rpmb_req() read the request buffer without checking job->request_len, which userspace controls. A short request causes an out-of-bounds read. Found by syzkaller.
Reject requests shorter than the structure each path reads.
--- drivers/ufs/core/ufs_bsg.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/ufs/core/ufs_bsg.c +9 -0
@@ -79,6 +79,9 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *jif (hba->ufs_version <ufshci_version (4 ,0 ) || !hba->dev_info.b_advanced_rpmb_en)return -EINVAL ; +if (job->request_len <sizeof (*rpmb_request)) +return -EINVAL ; +if (rpmb_request->ehs_req.length !=2 || rpmb_request->ehs_req.ehs_type !=1 )return -EINVAL ;
@@ -144,6 +147,11 @@ static int ufs_bsg_request(struct bsg_job *job)memset (job->reply,0 , job->reply_len); +if (job->request_len <sizeof (*bsg_request)) { + ret = -EINVAL ; + goto out_complete; + } +ufshcd_rpm_get_sync (hba); msgcode = bsg_request->msgcode;
@@ -193,6 +201,7 @@ static int ufs_bsg_request(struct bsg_job *job) out:ufshcd_rpm_put_sync (hba);kfree (buff); +out_complete: bsg_reply->result = ret;if (ret ==0 ) job->reply_len = rpmb ? sizeof(struct ufs_rpmb_reply) :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1396/3318 scsi: ufs: bsg: Reject UIC commands with a non-zero result byte
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
[ Upstream commit 1ae42513205a38b811afedb6797f9f9c4de37b90 ]
ufs_bsg_request() passes the user-supplied UIC argument2 unchanged, including the result byte (bits 7:0) that only the host controller writes. A non-zero value triggers the WARN_ON_ONCE() in ufshcd_dispatch_uic_cmd() and corrupts the reported result. Found by syzkaller.
Reject UIC commands that have the result byte set with -EINVAL.
--- drivers/ufs/core/ufs_bsg.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ufs/core/ufs_bsg.c +4 -0
@@ -178,6 +178,10 @@ static int ufs_bsg_request(struct bsg_job *job)break ;case UPIU_TRANSACTION_UIC_CMD :memcpy (&uc, &bsg_request->upiu_req.uc,UIC_CMD_SIZE ); +if (uc.argument2 &MASK_UIC_COMMAND_RESULT ) { + ret = -EINVAL ; +break ; + } ret =ufshcd_send_bsg_uic_cmd (hba, &uc);if (ret)dev_err (hba->dev,"send uic cmd: error code %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1397/3318 scsi: handle out-of-range SG_SET_TIMEOUT values
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingjie Wang <[email protected]>
[ Upstream commit 9a6cb1da4f3bc4633bf6669faed25a361834b1b9 ]
SG_SET_TIMEOUT accepts a signed int in USER_HZ units. The sg character device rejects negative values and limits positive values so the converted timeout fits its destination field. The block SCSI and BSG paths instead pass the value to clock_t_to_jiffies(), which accepts an unsigned long, and store the result in an unsigned int.
Negative values are converted into large unsigned timeouts. On 64-bit systems, large positive values can also exceed UINT_MAX after conversion and are truncated on assignment. With HZ=1000 and USER_HZ=100, for example, 429496730 clock ticks become 4294967300 jiffies and are stored as 4 jiffies. On 32-bit systems, an overflowing conversion becomes ULONG_MAX, which is an unsafe relative interval for the block timer comparisons.
Reject negative values with -EIO, matching drivers/scsi/sg.c. Saturate the converted value at the smaller of the destination field limit and MAX_JIFFY_OFFSET. This preserves successful ioctl behavior while avoiding both narrowing wraparound and an unsafe 32-bit timer interval.
The block SCSI behavior predates Git history. BSG has exposed the same behavior since it was introduced.
--- block/bsg.c | 5 ++++- drivers/scsi/scsi_ioctl.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-)
block/bsg.c +4 -1
@@ -130,7 +130,10 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case SG_SET_TIMEOUT :if (get_user (val, intp))return -EFAULT ; - bd->timeout =clock_t_to_jiffies (val); +if (val <0 ) +return -EIO ; + bd->timeout =min (clock_t_to_jiffies (val), +min (UINT_MAX ,MAX_JIFFY_OFFSET ));return 0 ;case SG_GET_TIMEOUT :return jiffies_to_clock_t (bd->timeout);
drivers/scsi/scsi_ioctl.c +8 -3
@@ -9,6 +9,7 @@#include <linux/blkdev.h> #include <linux/interrupt.h> #include <linux/errno.h> +#include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -180,10 +181,14 @@ static int sg_set_timeout(struct scsi_device *sdev, int __user *p) {int timeout, err =get_user (timeout, p); -if (!err) - sdev->sg_timeout =clock_t_to_jiffies (timeout); +if (err) +return err; +if (timeout <0 ) +return -EIO ; -return err; + sdev->sg_timeout =min (clock_t_to_jiffies (timeout), +min (UINT_MAX ,MAX_JIFFY_OFFSET )); +return 0 ; }static int sg_get_reserved_size (struct scsi_device *sdev,int __user *p)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1398/3318 posix-timers: Accept NULL clock_getres() output in stubs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 5b819071e4346256c4edbae5cc2095dff25694fc ]
With CONFIG_POSIX_TIMERS disabled, clock_getres() returns -EFAULT for a supported clock when the result pointer is NULL. POSIX permits a NULL result pointer to suppress returning the clock resolution.
Only copy the result when a destination is provided, in both the native and time32 stubs. This matches the full POSIX timer implementation and preserves clock ID validation.
--- kernel/time/posix-stubs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/time/posix-stubs.c +2 -2
@@ -83,7 +83,7 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timecase CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_timespec64 (&rtn_tp, tp)) +if (tp &&put_timespec64 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :
@@ -166,7 +166,7 @@ SYSCALL_DEFINE2(clock_getres_time32, clockid_t, which_clock,case CLOCK_REALTIME :case CLOCK_MONOTONIC :case CLOCK_BOOTTIME : -if (put_old_timespec32 (&rtn_tp, tp)) +if (tp &&put_old_timespec32 (&rtn_tp, tp))return -EFAULT ;return 0 ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1399/3318 ipmr: drop packets with unknown ingress VIF
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 09280680f2ea060514be2a39ea84209fb6d721d4 ]
A packet can race with VIF publication and make ipmr_find_vif() return -1 even though the VIF device pointer is already visible. The parent VIF device check can then pass with an invalid ingress VIF. For (*,G) entries, this can also let the packet be forwarded back out its ingress VIF.
Drop packets whose ingress VIF lookup fails in both IPv4 and IPv6 forwarding, before checking the MFC parent device. This prevents forwarding with an unknown ingress VIF and avoids the (*,G) hairpin.
Without the early check, the negative index can reach the IPv4 offload lookup only for an skb marked for L3 forwarding offload, currently done by mlxsw. The race is rare; the supplied PoC reports only the UBSAN negative-index diagnostic.
--- net/ipv4/ipmr.c | 3 ++- net/ipv6/ip6mr.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/ipv4/ipmr.c +2 -1
@@ -1990,7 +1990,8 @@ static void ip_mr_forward(struct net *net, struct mr_table *mrt, }/* Wrong interface: drop packet and (maybe) send PIM assert. */ -if (rcu_access_pointer (mrt->vif_table[vif].dev) != dev) { +if (true_vifi <0 || +rcu_access_pointer (mrt->vif_table[vif].dev) != dev) {if (rt_is_output_route (skb_rtable (skb))) {/* It is our own packet, looped back. * Very complicated situation...
net/ipv6/ip6mr.c +2 -1
@@ -2149,7 +2149,8 @@ static void ip6_mr_forward(struct net *net, struct mr_table *mrt,/* * Wrong interface: drop packet and (maybe) send PIM assert. */ -if (rcu_access_pointer (mrt->vif_table[vif].dev) != dev) { +if (true_vifi <0 || +rcu_access_pointer (mrt->vif_table[vif].dev) != dev) {atomic_long_inc (&c->_c.mfc_un.res.wrong_if); if (true_vifi >= 0 && mrt->mroute_do_assert &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1400/3318 tg3: Invert restart quirk logic to restrict SNP power-down bypass
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Noam D. Eliyahu <[email protected]>
[ Upstream commit d7314b51341c037973ce022f12c6009fd07b021e ]
Commit 9fc3bc764334 ("tg3: power down device only on SYSTEM_POWER_OFF") bypassed tg3_power_down() on system restarts to prevent reboot hangs and NMIs on servers where NICs were initialized via SNP (such as Dell PowerEdge R650 and R750).
However, skipping the power-down flow globally causes the ACPI _PTS method to trigger fatal PCIe AER events and hangs on other models. Commit e0efe83ed325 ("tg3: Disable tg3 PCIe AER on system reboot") attempted to mitigate this by adding an AER-disable DMI quirk table. Maintaining a growing list of models for a secondary symptom misses the root cause, leaving systems like the PowerEdge T440 (sharing the BCM5720 NIC) exposed.
Fix this by inverting the quirk logic:
1. Restrict SNP power-down avoidance strictly to tg3_restart_snp_quirk_table for the specific systems requiring it (Dell PowerEdge R650 and R750).
2. Restore standard power-down behavior for all other systems, eliminating the separate AER-disable quirk table.
For systems affected by the original SNP restart issue, their shutdown flow remains completely untouched.
--- drivers/net/ethernet/broadcom/tg3.c | 42 ++++++++--------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +11 -31
@@ -18122,41 +18122,17 @@ static int tg3_resume(struct device *device) static SIMPLE_DEV_PM_OPS(tg3_pm_ops, tg3_suspend, tg3_resume); -/* Systems where ACPI _PTS (Prepare To Sleep) S5 will result in a fatal -* PCIe AER event on the tg3 device if the tg3 device is not, or cannot -* be, powered down. +/* Systems where powering down a tg3 device on restarts triggers +* NMIs and fatal hangs during reboot if the network adapters were +* initialized under SNP. */ -static const struct dmi_system_id tg3_restart_aer_quirk_table[] = { - { - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), -DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R440" ), - }, - }, - { - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), -DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R540" ), - }, - }, - { - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), -DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R640" ), - }, - }, +static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { { .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ),DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R650" ), }, }, - { - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), -DMI_MATCH (DMI_PRODUCT_NAME ,"PowerEdge R740" ), - }, - }, { .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ),
@@ -18180,14 +18156,18 @@ static void tg3_shutdown(struct pci_dev *pdev)if (netif_running (dev))dev_close (dev); -if (system_state ==SYSTEM_POWER_OFF ) +if (!dmi_first_match (tg3_restart_snp_quirk_table) || + system_state ==SYSTEM_POWER_OFF ) {tg3_power_down (tp); -else if (system_state ==SYSTEM_RESTART && -dmi_first_match (tg3_restart_aer_quirk_table) && + }else if (system_state ==SYSTEM_RESTART && pdev->current_state != PCI_D3cold && pdev->current_state !=PCI_UNKNOWN ) {/* Disable PCIe AER on the tg3 to avoid a fatal * error during this system restart. +* Needed since on restarts for systems in +* tg3_restart_snp_quirk_table skipping on powering down the +* tg3 device causes a fatal AER error during ACPI _PTS +* (Prepare To Sleep). */ pcie_capability_clear_word(pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_CERE |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1401/3318 xfrm: retry inexact policy lookup after node reinsertion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
[ Upstream commit 868f63c8bfafa9b827168c9126f85264c39c02ec ]
An inexact policy lookup first records pointers to candidate hlist heads and then traverses the lists. A concurrent policy insertion can merge inexact tree nodes between those operations:
lookup policy insertion
------ ----------------
find inexact candidates
save obsolete hlist head
write_seqcount_begin(&bin->count)
merge inexact tree nodes
hlist_del_rcu(&policy->bydst)
reinsert policy->bydst in survivor
write_seqcount_end(&bin->count) evaluate saved candidate list
miss the moved policy
The merge immediately reinserts the same hlist node into the surviving tree node. RCU keeps the policy alive, but it does not provide a consistent view while its list node is moved. A lookup that selected the obsolete list can observe it empty. A lookup already traversing a moved policy can instead follow the next pointer rewritten by the reinsertion. Either case can return an incorrect IPsec policy result.
The per-bin sequence counter already brackets calls to xfrm_policy_inexact_insert_node(), including node merges. The read side, however, currently validates the counter only while searching an individual rb-tree. A successful search returns without validation, and the later candidate-list traversal is outside that read-side section.
Snapshot the per-bin sequence before discovering candidate heads and
validate it after evaluating all candidate lists. Retry the lookup if
the inexact policy tree changes while it is being searched.
--- net/xfrm/xfrm_policy.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +9 -2
@@ -2182,6 +2182,7 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type,struct xfrm_pol_inexact_bin *bin;struct xfrm_policy *pol, *ret;struct hlist_head *chain; +unsigned int inexact_sequence;unsigned int sequence;int err;
@@ -2216,12 +2217,18 @@ static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, goto skip_inexact; bin =xfrm_policy_inexact_lookup_rcu (net, type, family, dir, if_id); -if (!bin || !xfrm_policy_find_inexact_candidates (&cand, bin, saddr, - daddr)) +if (!bin) + goto skip_inexact; + + inexact_sequence =read_seqcount_begin (&bin->count); +if (!xfrm_policy_find_inexact_candidates (&cand, bin, saddr, daddr)) goto skip_inexact; pol =xfrm_policy_eval_candidates (&cand, ret, fl, type, family, if_id); +if (read_seqcount_retry (&bin->count, inexact_sequence)) + goto retry; +if (pol) { ret = pol;if (IS_ERR (pol))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1402/3318 9p/trans_virtio: reject mount tags longer than NAME_MAX at probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 5bfef2b6dafe83fe2d8d210d54093a8f48cfc97e ]
p9_virtio_probe() reads a 16-bit mount tag length (tag_len) from the device config and kzalloc()s tag_len + 1 bytes for chan->tag with no upper bound. A malicious or compromised host can present a tag of up to 65535 bytes; that tag is later copied into the single-page sysfs buffer by p9_mount_tag_show() (memcpy(buf, chan->tag, tag_len + 1)), a host-controlled out-of-bounds write of up to ~64 KiB past the PAGE_SIZE attribute buffer.
Reject an overlong tag at probe time. A 9p mount tag is a name-like identifier, so bound it by NAME_MAX (255): that limit is independent of the sysfs/seq_file page size and is far above any legitimate mount tag, which keeps p9_mount_tag_show() safe at the root without hard-coding a seq_file implementation detail.
Message-ID: <[email protected]>
--- net/9p/trans_virtio.c | 5 +++++ 1 file changed, 5 insertions(+)
net/9p/trans_virtio.c +5 -0
@@ -629,6 +629,11 @@ static int p9_virtio_probe(struct virtio_device *vdev) err = -EINVAL ; goto out_free_vq; } +if (tag_len >NAME_MAX ) { +dev_err (&vdev->dev,"mount tag too long (%u bytes)\n" , tag_len); + err = -EINVAL ; + goto out_free_vq; + } tag =kzalloc (tag_len +1 ,GFP_KERNEL );if (!tag) { err = -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1403/3318 9p/xen: fix refcount leak in p9_xen_response() on wrong tag
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifei Gao <[email protected]>
[ Upstream commit 4d183e6f153245aca2534e372152583b868dd925 ]
p9_xen_response() looks up the request for an incoming reply with p9_tag_lookup(), which takes a reference on the returned p9_req_t. When the tag does not resolve to a request in REQ_STATUS_SENT, the function warns and continues the loop without dropping that reference, permanently leaking the p9_req_t and its msize buffers. The reply header, including the tag, is supplied by the backend, so a malicious or buggy 9P backend can leak kernel memory on every crafted response.
Drop the reference before continuing.
Message-ID: <[email protected]>
--- net/9p/trans_xen.c | 2 ++ 1 file changed, 2 insertions(+)
net/9p/trans_xen.c +2 -0
@@ -202,6 +202,8 @@ static void p9_xen_response(struct work_struct *work) req =p9_tag_lookup (priv->client, h.tag);if (!req || req->status !=REQ_STATUS_SENT ) {dev_warn (&priv->dev->dev,"Wrong req tag=%x\n" , h.tag); +if (req) +p9_req_put (priv->client, req); cons += h.size;virt_mb (); ring->intf->in_cons = cons;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1404/3318 9p: fix caches_show() out-of-bounds write
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Zhang <[email protected]>
[ Upstream commit 2acd800de8827b7cdce8cb5c2c63b8e8608ec8e3 ]
The sysfs show handler for /sys/fs/9p/caches appends cache tags with snprintf(buf + count, limit, ...) and then advances count and limit by the return value. This is incorrect for truncation because snprintf() returns the full would-have-been length, not the number of bytes stored.
Once the accumulated output exceeds PAGE_SIZE, count can advance past the sysfs buffer and limit can become negative. A later iteration then passes an out-of-bounds destination pointer and an oversized size_t into snprintf(), leading to an out-of-bounds write.
Use sysfs_emit_at() for the append instead. It follows the sysfs buffer contract and returns the number of bytes actually stored, so the offset remains bounded even when the output is truncated.
Message-ID: <abfb65f4800634dafb08238bba20cb48797e796f.1781908090.git.zzhan461@ucr.edu>
--- fs/9p/v9fs.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
fs/9p/v9fs.c +5 -11
@@ -16,6 +16,7 @@#include <linux/parser.h> #include <linux/slab.h> #include <linux/seq_file.h> +#include <linux/sysfs.h> #include <net/9p/9p.h> #include <net/9p/client.h> #include <net/9p/transport.h>
@@ -555,21 +556,14 @@ static ssize_t caches_show(struct kobject *kobj,struct kobj_attribute *attr, char *buf) { - ssize_t n = 0, count = 0, limit = PAGE_SIZE; + ssize_t count = 0;struct v9fs_session_info *v9ses;spin_lock (&v9fs_sessionlist_lock);list_for_each_entry (v9ses, &v9fs_sessionlist, slist) { -if (v9ses->cachetag) { - n =snprintf (buf + count, limit,"%s\n" , v9ses->cachetag); -if (n <0 ) { - count = n; -break ; - } - - count += n; - limit -= n; - } +if (v9ses->cachetag) + count +=sysfs_emit_at (buf, count,"%s\n" , + v9ses->cachetag); }spin_unlock (&v9fs_sessionlist_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1405/3318 xfrm: interface: validate the IP header on xmit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang <[email protected]>
[ Upstream commit 86de3a1118a16dbbbe5fabe9aa20ffb93c072ed5 ]
Packets injected into an xfrm interface (e.g. AF_PACKET on an xfrmi device) reach the xfrm output path without IP header validation, but xfrm4_transport_output() uses iph->ihl for __skb_pull() and memmove() and expects the header to be valid.
vti_tunnel_xmit() already calls pskb_inet_may_pull() before handing packets to the xfrm output path. Do the same in xfrmi_xmit() and perform the header checks ip_rcv_core()/ip6_rcv_core() do on entry to the IP stack: reject wrong IP versions and malformed IPv4 header lengths.
--- net/xfrm/xfrm_interface_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/xfrm/xfrm_interface_core.c +8 -0
@@ -533,8 +533,13 @@ static netdev_tx_t xfrmi_xmit(struct sk_buff *skb, struct net_device *dev)memset (&fl,0 ,sizeof (fl)); +if (!pskb_inet_may_pull (skb)) + goto tx_err; +switch (skb->protocol) {case htons (ETH_P_IPV6 ): +if (ipv6_hdr (skb)->version !=6 ) + goto tx_err;memset (IP6CB (skb),0 ,sizeof (*IP6CB (skb)));xfrm_decode_session (skb, &fl,AF_INET6 );if (!dst) {
@@ -550,6 +555,9 @@ static netdev_tx_t xfrmi_xmit(struct sk_buff *skb, struct net_device *dev) }break ;case htons (ETH_P_IP ): +if (ip_hdr (skb)->version !=4 ||ip_hdr (skb)->ihl <5 || + !pskb_network_may_pull (skb,ip_hdr (skb)->ihl *4 )) + goto tx_err;memset (IPCB (skb),0 ,sizeof (*IPCB (skb)));xfrm_decode_session (skb, &fl,AF_INET );if (!dst) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1406/3318 xfrm: espintcp: reorder operations within espintcp_init_sk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit f9a11716c8445b496e9fafeec7e8412d384d02e2 ]
When enabled on a socket, espintcp sets the socket callbacks to its own before it has finished setting up its context and published it as icsk_ulp_data. Any one of those callbacks that gets called before will dereference a NULL icsk_ulp_data.
Fix this by reording the operations, and add memory barriers to ensure callers will have a struct espintcp_ctx available. Add a few WRITE_ONCE/READ_ONCE too while we're there.
--- include/net/espintcp.h | 5 +++-- net/xfrm/espintcp.c | 43 +++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 19 deletions(-)
include/net/espintcp.h +3 -2
@@ -34,7 +34,8 @@ static inline struct espintcp_ctx *espintcp_getctx(const struct sock *sk) {struct inet_connection_sock *icsk =inet_csk (sk); -/* RCU is only needed for diag */ -return (__force void *)icsk->icsk_ulp_data; +/* pairs with smp_wmb() in espintcp_init_sk() */ +smp_rmb (); +return (__force void *)READ_ONCE (icsk->icsk_ulp_data); }#endif
net/xfrm/espintcp.c +26 -17
67 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1407/3318 drm/drm_crtc: ensure dma_fence_ops remain valid during device unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
[ Upstream commit 3be436cbd3d265fe4fcfbb5b650edad7b2108443 ]
In [1], sashiko reported the following issue:
=== snip ===
Looking at how these fences are managed, drm_crtc_create_fence() creates a dma_fence without taking a reference to the drm_device or drm_crtc. Because the sync_file framework exposes this fence to userspace, the fence can outlive the CRTC.
The dma_fence contract requires that data accessed by dma_fence_ops (like get_driver_name) must remain valid for an RCU grace period after the fence is signaled. However, drm_crtc_cleanup() and the subsequent freeing of the device do not wait for an RCU grace period via synchronize_rcu().
If userspace calls ioctl(SYNC_IOC_FILE_INFO) concurrently with a device hot-unplug:
CPU1 (Userspace)sync_file_get_name()
ops = rcu_dereference(fence->ops);
if (!dma_fence_test_signaled_flag())
// Preempted or delayed here
CPU2 (Driver Teardown)
Signals the fence (setting fence->ops = NULL)
Destroys and frees the CRTC without waiting for an RCU grace period
CPU1 (Resumes)
ops->get_driver_name(fence) -> drm_crtc_fence_get_driver_name() crtc = fence_to_crtc(fence); // Casts to the freed CRTC return crtc->dev->driver->name; // Use-after-free
...
Does the CRTC or DRM device need to be kept alive for the RCU grace period, or should the fence hold a proper reference to prevent the use-after-free when get_driver_name() and get_timeline_name() access the freed CRTC structure?
=== snap ===
I believe this to be a correct observation and this patch implements the suggestion of waiting for an RCU grace period before proceeding with destruction of the drm_crtc, so that get_driver_name() and get_timeline_name() can still work.
--- drivers/gpu/drm/drm_crtc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +12 -3
@@ -489,14 +489,23 @@ EXPORT_SYMBOL(__drmm_crtc_alloc_with_planes);* drm_crtc_cleanup - Clean up the core crtc usage * @crtc: CRTC to cleanup * -* This function cleans up @crtc and removes it from the DRM mode setting -* core. Note that the function does *not* free the crtc structure itself, -* this is the responsibility of the caller. +* This function cleans up @crtc and removes it from the DRM mode setting core, +* after first waiting an RCU grace period to ensure @crtc->dev can safely be +* dereferenced by our dma_fence_ops. +* +* Note that the function does *not* free the crtc structure itself, this is the +* responsibility of the caller. */ void drm_crtc_cleanup (struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev; +/* Ensure our dma_fence_ops remain valid for an RCU grace period after +* the fence is signaled. This is necessary because our dma_fence_ops +* dereference crtc->dev. +*/ +synchronize_rcu (); +/* Note that the crtc_list is considered to be static; should we * remove the drm_crtc at runtime we would have to decrement all * the indices on the drm_crtc after us in the crtc_list.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1408/3318 wifi: mac80211: reload TDLS header pointer after skb_linearize()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit 35c5a5ea4418571997a7e7af3e7e8922b136f6e6 ]
ieee80211_process_tdls_channel_switch() sets tf = skb->data before it calls skb_linearize(), and reads tf->action_code afterwards.
ieee80211_rx_h_data() queues TDLS channel switch requests and responses to the interface after pulling only offsetof(struct ieee80211_tdls_data, u) bytes, so the skb can still be non-linear when the interface work handles it. Drivers that build paged RX skbs do this for every frame that does not fit into the skb head, e.g. iwlwifi (mvm), which is also the only mac80211 driver that sets NL80211_FEATURE_TDLS_CHANNEL_SWITCH. If the remaining data does not fit into the tailroom, skb_linearize() moves the data to a new head and frees the old one, and the action code is then read from freed memory. Depending on what that memory holds by then, the frame is handled as before or ends in the WARN_ON_ONCE() of the default case.
The frame only has to be a data frame with the TDLS ethertype from an authorized peer, e.g. relayed by the AP from another station in the BSS; the read happens before the sender is checked to be a TDLS peer.
Load tf after skb_linearize(), as the request and response handlers already do.
Found by static analysis tool CodeQL.
--- net/mac80211/tdls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tdls.c +2 -1
@@ -2060,7 +2060,7 @@ void ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) { - struct ieee80211_tdls_data *tf = (void *)skb->data; + struct ieee80211_tdls_data *tf;struct wiphy *wiphy = sdata->local->hw.wiphy;lockdep_assert_wiphy (wiphy);
@@ -2076,6 +2076,7 @@ ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata,* The packet/size was already validated by mac80211 Rx path, only look * at the action type. */ + tf = (void *)skb->data;switch (tf->action_code) {case WLAN_TDLS_CHANNEL_SWITCH_REQUEST :ieee80211_process_tdls_channel_switch_req (sdata, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1409/3318 wifi: rsi: Skip TX aggregation setup for non-QoS frames
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Kazinsky <[email protected]>
[ Upstream commit 71f756a4c064b0312f46617c20893ecc17c332e4 ]
When transmitting a non-QoS unicast frame to a station in AP mode, rsi_core_xmit() assigns IEEE80211_NONQOS_TID (16) to tid. The station lookup succeeds, allowing tid to index start_tx_aggr[], which has only IEEE80211_NUM_TIDS (16) elements. This causes an out-of-bounds read and, if the value read is zero, an out-of-bounds write.
Only access the aggregation state for tids below IEEE80211_NUM_TIDS, excluding the non-QoS sentinel from TX aggregation setup.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/rsi/rsi_91x_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/rsi/rsi_91x_core.c +1 -1
@@ -458,7 +458,7 @@ void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb) tx_params->sta_id =0 ; } -if (rsta) { +if (rsta && tid <IEEE80211_NUM_TIDS ) {/* Start aggregation if not done for this tid */ if (!rsta->start_tx_aggr[tid]) { rsta->start_tx_aggr[tid] = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1410/3318 wifi: cfg80211: fix out-of-bounds read in valid_rule()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijing Yin <[email protected]>
[ Upstream commit 9d8ec0b5b5295bd23d979d1b2b905de25c36fff2 ]
valid_rule() validates a struct fwdb_rule from the regulatory database firmware file, but bounds checks only the first byte of the structure, the length field itself.
It then uses that length, which comes straight out of the file, to decide whether the optional fields are present, and reads rule->wmm_ptr at offset 18 of the 20-byte structure once the length claims 20 bytes or more.
A rule placed in the last bytes of the file therefore makes the parser read up to 19 bytes past the end of the firmware image. The image comes from vmalloc() in kernel_read_file(), so with the rule at the end of a page the read falls into the guard page and oopses, with no memory debugging enabled.
A length of at least offsetofend(max_bw) but below offsetofend(wmm_ptr) takes the other branch, so valid_rule() returns true having read nothing out of bounds, and the database is accepted. regdb_query_country() does not re-check the rule, and reads rule->start, rule->end, rule->max_bw and rule->cac_timeout off the end of the kmemdup()ed copy.
A malformed regulatory.db is parsed by cfg80211's own request_firmware_nowait() at init time, and on demand from user space through NL80211_CMD_RELOAD_REGDB, which needs CAP_NET_ADMIN but no wireless hardware. Both paths require write access to the firmware search path and CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=n.
Bound the whole declared rule, not just its length field. The existing check on sizeof(rule->len) is still needed, since rule->len has to be shown to be inside the file before it can be read, so the new test goes after it. A rule reaching past the end of the file is now rejected, which fails the database rather than reading out of bounds. That also gives regdb_query_country() the bound it already assumes.
--- net/wireless/reg.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/reg.c +3 -0
@@ -689,6 +689,9 @@ static bool valid_rule(const u8 *data, unsigned int size, u16 rule_ptr)/* mandatory fields */ if (rule->len < offsetofend(struct fwdb_rule, max_bw))return false; +/* the rule must lie entirely within the database */ +if ((u8 *)rule + rule->len > data + size) +return false; if (rule->len >= offsetofend(struct fwdb_rule, wmm_ptr)) {u32 wmm_ptr =be16_to_cpu (rule->wmm_ptr) <<2 ;struct fwdb_wmm_rule *wmm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1411/3318 drm/vc4: Publish the output fence outside of job_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 9ee552a42c3905b4547e83173d46413137ec329a ]
job_lock is taken by the V3D interrupt handler, so nesting an IRQ-unsafe lock under it creates an inversion. drm_syncobj_replace_fence() takes drm_syncobj::lock, which other paths acquire with interrupts enabled. For example, a thread interrupted while holding it blocks the handler on job_lock, and the handler can only make progress once the submit path releases job_lock, which it cannot do while waiting for drm_syncobj::lock.
This is reported by lockdep:
[ 188.139076] ========================================================
[ 188.139086] WARNING: possible irq lock inversion dependency detected
[ 188.139096] 7.3.0-rc3-00067-gc4f3feeaf60f #67 Tainted: G C
[ 188.139108] --------------------------------------------------------
[ 188.139116] swapper/0/0 just changed the state of lock:
[ 188.139125] ffff0000054f8ff8 (&vc4->job_lock){-...}-{3:3}, at: vc4_irq+0xa8/0x28c [vc4]
[ 188.139234] but this lock took another, HARDIRQ-unsafe lock in the past:
[ 188.139242] (&syncobj->lock){+.+.}-{3:3}
[ 188.139256] and interrupts could create inverse lock ordering between them.
[ 188.139267] other info that might help us debug this:
[ 188.139275] Possible interrupt unsafe locking scenario:
[ 188.139284] CPU0 CPU1
[ 188.139291] ---- ----
[ 188.139299] lock(&syncobj->lock);
[ 188.139312] local_irq_disable();
[ 188.139320] lock(&vc4->job_lock);
[ 188.139335] lock(&syncobj->lock);
[ 188.139350] <Interrupt>
[ 188.139358] lock(&vc4->job_lock);
[ 188.139372] *** DEADLOCK ***Hand the fence over after job_lock is dropped. The job can complete and drop exec->fence in that window, so take a reference first and publish through the local pointer, as exec may already be gone.
--- drivers/gpu/drm/vc4/vc4_gem.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_gem.c +9 -1
@@ -706,8 +706,11 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, fence->seqno = exec->seqno; exec->fence = &fence->base; +/* The job can complete and drop exec->fence as soon as job_lock is +* released, so hold our own reference. +*/ if (out_sync) -drm_syncobj_replace_fence (out_sync, exec->fence); +dma_fence_get (&fence->base);vc4_update_bo_seqnos (exec, seqno);
@@ -729,6 +732,11 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,spin_unlock_irqrestore (&vc4->job_lock, irqflags); +if (out_sync) { +drm_syncobj_replace_fence (out_sync, &fence->base); +dma_fence_put (&fence->base); + } +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1412/3318 wifi: mac80211: reinstate IEEE80211_TX_CTL_AMPDU flag in ieee80211_tx_prep_agg()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 25e73f1d6868c759c8eb56cad4e411692c5341b4 ]
The commit 592234e941f1 ("wifi: mac80211: Fix iTXQ AMPDU fragmentation handling") changed the way handling of the IEEE80211_TX_CTL_AMPDU flag is done in mac80211, so the only place it is set is in ieee80211_tx_dequeue().
This means that any frames that are sent to the driver via drv_tx() will no longer have the flag set. In particular, this affects packets going through ieee80211_tx_pending(). Evan reported that this can result in the ath9k driver failing to account such packets in its block ack window, eventually overrunning the window and stalling TX.
Fix this by reinstating the flag in ieee80211_tx_prep_agg() when inside a valid block ack window. This should be harmless for the TXQ path, and will reinstate the previous behaviour for drivers that use the flag as a signal to track the packet in the window.
--- net/mac80211/tx.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/tx.c +2 -0
@@ -1126,6 +1126,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,struct sk_buff *purge_skb =NULL ;if (test_bit (HT_AGG_STATE_OPERATIONAL , &tid_tx->state)) { + info->flags |=IEEE80211_TX_CTL_AMPDU ; reset_agg_timer = true; }else if (test_bit (HT_AGG_STATE_WANT_START , &tid_tx->state)) {/*
@@ -1157,6 +1158,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,if (!tid_tx) {/* do nothing, let packet pass through */ }else if (test_bit (HT_AGG_STATE_OPERATIONAL , &tid_tx->state)) { + info->flags |=IEEE80211_TX_CTL_AMPDU ; reset_agg_timer = true; }else { queued = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/3318 scsi: aic7xxx: Use default settings on the SGI O2 onboard controllers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
[ Upstream commit 696bdfc58975fbc70d2e2347a74e0b562e7e2494 ]
The SGI O2 firmware runs its onboard aic7880s without the Adaptec BIOS, so scratch RAM holds no settings. The left over BIOS path reads uninitialised bytes, and bad parity panics the boot.
Use the defaults there with host ID 0. ahc_init() keeps the default host ID ahc_pci_config() chose, 7 on other PCI controllers, so only the O2 changes.
--- drivers/scsi/aic7xxx/aic7xxx_core.c | 8 ++++++-- drivers/scsi/aic7xxx/aic7xxx_pci.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_core.c +6 -2
@@ -5266,9 +5266,13 @@ ahc_init(struct ahc_softc *ahc)/* * Assume we have a board at this stage and it has been reset. +* PCI controllers keep the host ID ahc_pci_config() chose. */ -if ((ahc->flags &AHC_USEDEFAULTS ) !=0 ) - ahc->our_id = ahc->our_id_b =7 ; +if ((ahc->flags &AHC_USEDEFAULTS ) !=0 ) { +if ((ahc->chip &AHC_PCI ) ==0 ) + ahc->our_id =7 ; + ahc->our_id_b =7 ; + }/* * Default to allowing initiator operations.
drivers/scsi/aic7xxx/aic7xxx_pci.c +19 -1
@@ -701,6 +701,21 @@ ahc_find_pci_device(ahc_dev_softc_t pci)return (NULL ); } +/* +* The SGI O2 firmware runs its onboard controllers, in slots 1 and 2 of the +* root bus, without the Adaptec BIOS and at host ID 0. It leaves no settings +* in scratch RAM, which may still hold power-on contents with bad parity. +*/ +static bool +ahc_pci_sgi_o2_onboard (struct ahc_softc *ahc) +{ +int slot =ahc_get_pci_slot (ahc->dev_softc); + +return IS_ENABLED (CONFIG_SGI_IP32 ) && +ahc_get_pci_bus (ahc->dev_softc) ==0 && + (slot ==1 || slot ==2 ); +} +int ahc_pci_config (struct ahc_softc *ahc,const struct ahc_pci_identity *entry) {
@@ -782,6 +797,9 @@ ahc_pci_config(struct ahc_softc *ahc, const struct ahc_pci_identity *entry) ahc->bus_intr = ahc_pci_intr; ahc->bus_chip_init = ahc_pci_chip_init; +if (ahc_pci_sgi_o2_onboard (ahc)) + ahc->flags |=AHC_NO_BIOS_INIT ; +/* Remember how the card was setup in case there is no SEEPROM */ if ((ahc_inb (ahc,HCNTRL ) &POWRDN ) ==0 ) {ahc_pause (ahc);
@@ -898,7 +916,7 @@ ahc_pci_config(struct ahc_softc *ahc, const struct ahc_pci_identity *entry)* Assume only one connector and always turn * on termination. */ - our_id =0x07 ; + our_id =ahc_pci_sgi_o2_onboard (ahc) ?0 :0x07 ; sxfrctl1 =STPWEN ; }ahc_outb (ahc,SCSICONF , our_id|ENSPCHK |RESET_SCSI );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/3318 9p/xen: validate the response size from the backend
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 9b4cf60c6b739461c5b4ec9c52587da6b2608786 ]
p9_xen_response() takes the length of an incoming response from the ring -- the first field of the 9p header, which the Xen transport reuses as its framing header -- and uses it to advance the consumer index, but never checks that it is at least the header size or no larger than the number of bytes the backend has actually produced.
A malicious or buggy backend can post a response whose size is smaller than the header (for example 0). The consumer index then never advances, so the response work re-reads the same ring contents instead of making progress. In testing this raced with the teardown that the malformed reply triggers and dereferenced a freed p9_client:
9pfs 9pfs-0: Wrong req tag=ffff
BUG: kernel NULL pointer dereference, address: 0000000000000060 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted 7.2.0-rc5 #6 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014 Workqueue: events p9_xen_response RIP: 0010:idr_find+0x4/0x10 RSP: 0018:ffffbf5d80063de8 EFLAGS: 00010202 RAX: 0000000000000001 RBX: ffffa229c21195a0 RCX: ffffa229c2400000 RDX: ffffa229c11c2200 RSI: 000000000000ffff RDI: 0000000000000050 RBP: 000000000000ffff R08: 3fffffffffffdfff R09: ffffffffffffffff R10: 3fffffffffffdfff R11: ffffffff87a60e80 R12: 0000000000000050 R13: 0000000000000000 R14: 000000000000ffff R15: 0000000000100000 FS: 0000000000000000(0000) GS:ffffa22a7661c000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000060 CR3: 000000003ac34002 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <TASK> p9_tag_lookup+0x2b/0x90 p9_xen_response+0x17c/0x2e0 process_one_work+0x16a/0x3a0 worker_thread+0x172/0x2e0 kthread+0xdd/0x110 ret_from_fork+0x18b/0x240 ret_from_fork_asm+0x1a/0x30 </TASK> Modules linked in: CR2: 0000000000000060 ---[ end trace 0000000000000000 ]---
Reject a response whose size is outside [sizeof(header), queued] before using it, matching the validation the backend already applies to incoming requests.
Message-ID: <[email protected]>
--- net/9p/trans_xen.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/9p/trans_xen.c +8 -0
@@ -199,6 +199,14 @@ static void p9_xen_response(struct work_struct *work) masked_prod, &masked_cons, XEN_9PFS_RING_SIZE(ring)); +if (h.size <sizeof (h) || + h.size >xen_9pfs_queued (prod, cons, +XEN_9PFS_RING_SIZE (ring))) { +dev_warn_ratelimited (&priv->dev->dev, +"bad response size %u from backend\n" , h.size); +break ; + } + req =p9_tag_lookup (priv->client, h.tag);if (!req || req->status !=REQ_STATUS_SENT ) {dev_warn (&priv->dev->dev,"Wrong req tag=%x\n" , h.tag);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/3318 9p: dont decrement a server-owned zero nlink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanfu Xie <[email protected]>
[ Upstream commit 4e915aa8566173b44146bc46177c85afbe6bdf96 ]
A 9P2000.L server can report nlink=0 for a regular file that still exists. On a cache=loose or cache=fscache mount, lookup stores that value with set_nlink(). A later successful unlink calls v9fs_dec_count(), which still calls drop_nlink() for a non-directory. drop_nlink() warns, and the unsigned link count wraps to 4294967295. fstat() on a descriptor opened before the unlink shows 0 before and 4294967295 after.
The warning on the unpatched kernel, trimmed:
WARNING: fs/inode.c:408 at drop_nlink+0xac/0xd0, CPU#1: trigger/188 CPU: 1 UID: 0 PID: 188 Comm: trigger Tainted: G N 7.3.0-rc4-00537-ga3ff15db6820 #1 PREEMPT(lazy) RIP: 0010:drop_nlink+0xac/0xd0 Call Trace: <TASK> v9fs_remove+0x529/0x750 vfs_unlink+0x2f0/0xbd0 filename_unlinkat+0x340/0x6c0 __x64_sys_unlink+0x46/0x70 do_syscall_64+0xe8/0x4f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]---
Directories whose cached nlink is at most 2 already skip this decrement, because the exported filesystem may not maintain nlink (commit ac89b2ef9b559). cache=none skips it as well (commit 574aa0b479947). cache=mmap does not take this path: it sets neither CACHE_META nor CACHE_LOOSE. A regular file on cache=loose or cache=fscache still does. Its count came from GETATTR and may already be zero, so skip the decrement when i_nlink is already 0.
Verified on 7.3-rc4-00537-ga3ff15db6820 with only this change. A server that advertises nlink=0 and accepts the unlink no longer warns, and the open descriptor stays at nlink 0. An honest server on the same mount still goes from 1 to 0. A rejected unlink leaves the count unchanged. cache=none is unchanged. With panic_on_warn the unpatched kernel panics on the warning; the patched kernel does not.
Message-ID: <[email protected]>
--- fs/9p/vfs_inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/9p/vfs_inode.c +8 -0
@@ -526,6 +526,12 @@ static int v9fs_at_to_dotl_flags(int flags)* nothing and races with concurrent metadata fetches that may already * have observed the post-unlink value (nlink == 0). * +* The same applies to a regular file whose cached nlink has already been +* driven to zero by the server: in the cached modes the attributes come +* from GETATTR and are applied verbatim, so decrementing a link count the +* server does not maintain only trips the drop_nlink() WARN_ON and +* underflows i_nlink. +* * @inode: inode whose nlink is being dropped */ static void v9fs_dec_count (struct inode *inode)
@@ -534,6 +540,8 @@ static void v9fs_dec_count(struct inode *inode)if (!(v9ses->cache & (CACHE_META |CACHE_LOOSE )))return ; +if (inode->i_nlink ==0 ) +return ;if (!S_ISDIR (inode->i_mode) || inode->i_nlink >2 )drop_nlink (inode); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/3318 batman-adv: dat: initialize orig_node of unfilled candidate slots
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
[ Upstream commit 4eb19a389d74f06901b4cd6f24b996b2e84eaefc ]
batadv_dat_select_candidates() allocates the candidate array without zeroing it. batadv_choose_next_candidate() marks each slot as BATADV_DAT_CANDIDATE_NOT_FOUND but only sets orig_node when an eligible originator was found. In the following rounds, batadv_is_orig_node_eligible() compares res[j].orig_node of all previous slots against the evaluated originator. For slots without candidates, it reads uninitialized memory.
The orig_node has to be cleared together with theBATADV_DAT_CANDIDATE_NOT_FOUND type.
--- net/batman-adv/distributed-arp-table.c | 1 + 1 file changed, 1 insertion(+)
net/batman-adv/distributed-arp-table.c +1 -0
@@ -583,6 +583,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,* NOT_FOUND */ cands[select].type =BATADV_DAT_CANDIDATE_NOT_FOUND ; + cands[select].orig_node =NULL ;/* iterate over the originator list and find the node with the closest * dat_address which has not been selected yet
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/3318 batman-adv: fix skb leak when hard_iface is being released
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
[ Upstream commit 522e4aece2e96cacbb8a6ae1eec0d4c0dd6f4fed ]
batadv_batman_skb_recv() owns the skb it is given. When the hard_iface refcount already dropped to zero, the function jumped to err_out, which only returned NET_RX_DROP and skipped the kfree_skb() under err_free.
To avoid a leak, free the skb before returning in this case.
--- net/batman-adv/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/batman-adv/main.c +4 -3
@@ -448,8 +448,10 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,* shut down otherwise the packet may trigger de-reference errors * further down in the receive path. */ -if (!kref_get_unless_zero (&hard_iface->refcount)) - goto err_out; +if (!kref_get_unless_zero (&hard_iface->refcount)) { +kfree_skb (skb); +return NET_RX_DROP ; + } skb =skb_share_check (skb,GFP_ATOMIC );
@@ -508,7 +510,6 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,kfree_skb (skb); err_put:batadv_hardif_put (hard_iface); -err_out:return NET_RX_DROP ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/3318 net: jme: keep RX MAC clock enabled for WoL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Franck Baur <[email protected]>
[ Upstream commit ed9179fc7228315fb745dc3b111bae446e6894d2 ]
On the JMicron JMC250 revision 03, the MAC reset performed during suspend leaves GPREG1_RXCLKOFF set. Although the driver enables Magic Packet detection, the gated RX MAC clock prevents wake-up from ACPI S3.
Keep the RX MAC clock enabled while WoL is armed. Restore the gated clock state immediately after disabling WoL during resume, preserving the RX engine initialization ordering.
Prevent concurrent link-change work from gating the clock again after WoL has been armed. Quiesce interrupt-driven link-change scheduling, synchronize pending interrupts, and cancel outstanding link-change work before programming WoL in suspend and shutdown paths.
Restore the deferred processing state before requesting link reinitialization on resume.
Tested on an ASUS K42JE with JMC250 [197b:0250] rev 03 using a Debian 6.12.111 kernel and an externally built module. ACPI S3 wake with a Magic Packet completed in 19 seconds, while a control without a Magic Packet resumed through the RTC alarm after 123 seconds. Ethernet and SSH recovered after resume.
S4 and S5 wake behaviour has not been validated with this revision.
--- drivers/net/ethernet/jme.c | 37 ++++++++++++++++++++++++++++++++----- drivers/net/ethernet/jme.h | 1 + 2 files changed, 33 insertions(+), 5 deletions(-)
drivers/net/ethernet/jme.c +32 -5
@@ -1502,7 +1502,8 @@ jme_intr_msi(struct jme_adapter *jme, u32 intrstat)* all other events are ignored */ jwrite32 (jme,JME_IEVE , intrstat); -schedule_work (&jme->linkch_task); +if (!test_bit (JME_FLAG_WOL_QUIESCE , &jme->flags)) +schedule_work (&jme->linkch_task); goto out_reenable; }
@@ -1546,7 +1547,8 @@ jme_intr_msi(struct jme_adapter *jme, u32 intrstat)/* * Re-enable interrupt */ -jwrite32f (jme,JME_IENS ,INTR_ENABLE ); +if (!test_bit (JME_FLAG_WOL_QUIESCE , &jme->flags)) +jwrite32f (jme,JME_IENS ,INTR_ENABLE ); } static irqreturn_t
@@ -1892,6 +1894,7 @@ jme_powersave_phy(struct jme_adapter *jme)jme_set_100m_half (jme);if (jme->reg_pmcs & (PMCS_LFEN |PMCS_LREN ))jme_wait_link (jme); +jme_mac_rxclk_on (jme);jme_clear_pm_enable_wol (jme); }else {jme_phy_off (jme);
@@ -3158,6 +3161,21 @@ jme_shutdown(struct pci_dev *pdev)struct net_device *netdev =pci_get_drvdata (pdev);struct jme_adapter *jme =netdev_priv (netdev); +if (netif_running (netdev)) { +set_bit (JME_FLAG_WOL_QUIESCE , &jme->flags); +netif_device_detach (netdev); +netif_stop_queue (netdev); +jme_stop_irq (jme); +synchronize_irq (pdev->irq); +jme_stop_irq (jme); +cancel_work_sync (&jme->linkch_task); +tasklet_disable (&jme->pcc_task); +napi_disable (&jme->napi); +tasklet_disable (&jme->txclean_task); +tasklet_disable (&jme->rxclean_task); +tasklet_disable (&jme->rxempty_task); + } +jme_powersave_phy (jme);pci_pme_active (pdev, true); }
@@ -3172,11 +3190,16 @@ jme_suspend(struct device *dev)if (!netif_running (netdev))return 0 ; -atomic_dec (&jme->link_changing); - +set_bit (JME_FLAG_WOL_QUIESCE , &jme->flags);netif_device_detach (netdev);netif_stop_queue (netdev);jme_stop_irq (jme); +synchronize_irq (jme->pdev->irq); +jme_stop_irq (jme); +cancel_work_sync (&jme->linkch_task); +tasklet_disable (&jme->pcc_task); +napi_disable (&jme->napi); +atomic_dec (&jme->link_changing);tasklet_disable (&jme->txclean_task);tasklet_disable (&jme->rxclean_task);
@@ -3215,6 +3238,7 @@ jme_resume(struct device *dev)return 0 ;jme_clear_pm_disable_wol (jme); +jme_mac_rxclk_off (jme);jme_phy_on (jme);if (test_bit (JME_FLAG_SSET , &jme->flags))jme_set_link_ksettings (netdev, &jme->old_cmd);
@@ -3226,8 +3250,11 @@ jme_resume(struct device *dev)atomic_inc (&jme->link_changing); -jme_reset_link (jme); +napi_enable (&jme->napi); +tasklet_enable (&jme->pcc_task); +clear_bit (JME_FLAG_WOL_QUIESCE , &jme->flags); +jme_reset_link (jme);jme_start_irq (jme);return 0 ;
drivers/net/ethernet/jme.h +1 -0
@@ -450,6 +450,7 @@ enum jme_flags_bits {JME_FLAG_SSET =2 ,JME_FLAG_POLL =5 ,JME_FLAG_SHUTDOWN =6 , + JME_FLAG_WOL_QUIESCE = 7, };#define TX_TIMEOUT (5 * HZ)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/3318 ipv6: raw: fix use-after-free in rawv6_send_hdrinc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhou Qiuyue <[email protected]>
[ Upstream commit 66dfb2cacda7faae614d688943d85e75abf7f586 ]
rawv6_send_hdrinc() caches the route before handing the skb to l3mdev_ip6_out(). The VRF output path may replace skb->dst and release the original route, leaving the cached pointer stale.
The function later dereferences that pointer for statistics accounting and as the output device passed to NF_HOOK(). Its RCU read-side critical section starts after l3mdev_ip6_out(), so it cannot prevent the old route from being reclaimed in between.
Reload the route from the current skb destination after l3mdev_ip6_out() returns.
KASAN reports a slab-use-after-free in rawv6_sendmsg(), with the route allocated by ip6_dst_alloc(), freed by dst_destroy() from rcu_core(), and the related RCU callback queued from vrf_l3_out().
--- net/ipv6/raw.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/raw.c +3 -0
@@ -646,6 +646,9 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,if (unlikely (!skb))return 0 ; +/* l3mdev_ip6_out() may have replaced the skb dst. */ + rt =dst_rt6_info (skb_dst (skb)); +/* Acquire rcu_read_lock() in case we need to use rt->rt6i_idev * in the error path. Since skb has been freed, the dst could * have been queued for deletion.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/3318 drm/vc4: hdmi: always cancel the scrambling work synchronously
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Tanure <[email protected]>
[ Upstream commit 2e47848f0d076dec66df3bc403214073cd2214ac ]
The scrambling work re-arms itself every second while a scrambled mode is active. When the output is disabled, the work may be executing at that moment rather than pending, and delayed_work_pending() is then false, so the cancel is skipped. The running instance finishes after the disable, sees the sink report scrambling off, writes the SCDC scrambling and clock ratio bits back on, and queues itself again. The sink is left configured for a scrambled 1/40 link that no longer exists and the work keeps running until the next enable.
cancel_delayed_work_sync() handles both states: it waits for a running instance and blocks it from queueing itself again.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -2
@@ -1058,8 +1058,7 @@ static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) vc4_hdmi->scdc_enabled = false; -if (delayed_work_pending (&vc4_hdmi->scrambling_work)) -cancel_delayed_work_sync (&vc4_hdmi->scrambling_work); +cancel_delayed_work_sync (&vc4_hdmi->scrambling_work);if (!drm_dev_enter (drm, &idx))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/3318 drm/vc4: hdmi: enable scrambling before the TMDS clock starts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Tanure <[email protected]>
[ Upstream commit 81383bd290a18f06ccf9b0bfb29e1a3ef73d9357 ]
HDMI 2.0 requires a source to suspend the TMDS clock, write the TMDS_Bit_Clock_Ratio bit in the sink's SCDC registers, wait at least 1 ms and only then resume the clock. vc4 does the opposite: the PHY starts at the new rate first, and the SCDC bits are written tens of milliseconds later, at the very end of the enable sequence, together with the source side scrambler. On disable the bits are cleared while the clock is still running.
Some sinks sample the bit only when the clock appears. One HDMI 2.0 sink we tested then sets up its receiver for a 1/10 clock and never
recovers: a Raspberry Pi 5 at 3840x2160@60 shows no picture, while 1080p60 and 4K30 work and other sources work at 4K60 on the same sink. Writing the bit by hand before enabling the output makes the same mode lock every time.
Enable scrambling, on the sink and in the controller, before the PHY is started, and disable it only after the PHY has been stopped. The SCDC helper already waits the required time after writing the ratio bit.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -3
@@ -1121,8 +1121,6 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder, HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE);spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); -vc4_hdmi_disable_scrambling (encoder); -drm_dev_exit (idx); out:
@@ -1151,6 +1149,8 @@ static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder,if (vc4_hdmi->variant->phy_disable) vc4_hdmi->variant->phy_disable (vc4_hdmi); +vc4_hdmi_disable_scrambling (encoder); +clk_disable_unprepare (vc4_hdmi->pixel_bvb_clock);clk_disable_unprepare (vc4_hdmi->pixel_clock);
@@ -1769,6 +1769,8 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, goto err_disable_pixel_clock; } +vc4_hdmi_enable_scrambling (encoder); +if (vc4_hdmi->variant->phy_init) vc4_hdmi->variant->phy_init (vc4_hdmi, vc4_conn_state);
@@ -1905,7 +1907,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, }vc4_hdmi_recenter_fifo (vc4_hdmi); -vc4_hdmi_enable_scrambling (encoder);drm_dev_exit (idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/3318 sctp: account for chunk padding in sctp_init_cause()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masafumi Suzuki <[email protected]>
[ Upstream commit ed6c53b27be492643da2017c6f8e2732be5edf1a ]
sctp_init_cause() accepts a chunk when skb_tailroom() can hold the cause header and the payload. sctp_addto_chunk() then writes 0-3 bytes of padding before that header so the chunk stays 4-byte aligned. The check does not include the padding, and the following skb_put() calls skb_over_panic() from softirq.
Count the padding sctp_addto_chunk() is about to write. The cause length on the wire stays the header plus the payload.
Found by LLM inspection, triggered and tested the fix.
--- net/sctp/sm_make_chunk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/sctp/sm_make_chunk.c +8 -1
@@ -145,6 +145,7 @@ int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, size_t paylen) {struct sctp_errhdr err; +int chunklen, padlen;__u16 len;/* Cause code constants are now defined in network order. */
@@ -152,7 +153,13 @@ int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, len =sizeof (err) + paylen; err.length =htons (len); -if (skb_tailroom (chunk->skb) < len) +/* sctp_addto_chunk() pads the chunk up to a 4-byte boundary before +* appending the cause, so account for that padding here as well. +*/ + chunklen =ntohs (chunk->chunk_hdr->length); + padlen =SCTP_PAD4 (chunklen) - chunklen; + +if (skb_tailroom (chunk->skb) < padlen + len)return -ENOSPC ; chunk->subh.err_hdr =sctp_addto_chunk (chunk,sizeof (err), &err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/3318 btrfs: sysfs: restore NOFS context on early return in btrfs_sysfs_add_block_group_type()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: guolingxing <[email protected]>
[ Upstream commit 4172be965c2ce887ebfb1117c634a68555be8c11 ]
btrfs_sysfs_add_block_group_type() sets up a NOFS context with memalloc_nofs_save() because kobject_add() performs GFP_KERNEL allocations deep in its call chain, and the function may be called while holding a transaction handle or a lock required for a transaction commit, where reclaim could deadlock.
Every other return path of this function calls memalloc_nofs_restore() except the early return taken when another thread has already created the kobject for the same raid index (this can happen when restriping). Taking that path leaves PF_MEMALLOC_NOFS set on the calling task, so all subsequent memory allocations performed by that task remain restricted to the NOFS scope, which may lead to unexpected allocation failures or deadlocks later on.
Restore the NOFS context before returning from that path.
--- fs/btrfs/sysfs.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/sysfs.c +1 -0
@@ -1599,6 +1599,7 @@ void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache)if (space_info->block_group_kobjs[index]) {spin_unlock (&space_info->lock);kobject_put (&rkobj->kobj); +memalloc_nofs_restore (nofs_flag);return ; }else { space_info->block_group_kobjs[index] = &rkobj->kobj;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/3318 scsi: bsg: Report synchronous data copyback failures
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingjie Wang <[email protected]>
[ Upstream commit a52f2ad45726d788755b525adcf51f65a6b836ff ]
scsi_bsg_sg_io_fn() ignores the result of blk_rq_unmap_user(). For a data-in command that uses a bounce buffer, unmapping copies the completed data to userspace. If that copy fails, SG_IO can report success despite the copyback failure.
Capture the unmap status. Preserve an earlier sense-buffer copy error and otherwise return the data copyback error. This matches the error precedence used by scsi_complete_sghdr_rq().
On x86_64, a virtio-scsi INQUIRY with an unaligned PROT_NONE destination made ioctl() return 0 in 20/20 runs before this change and return -1 with errno EFAULT in 20/20 runs afterward. Writable controls succeeded in 20/20 runs on both kernels.
--- drivers/scsi/scsi_bsg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/scsi_bsg.c +4 -2
@@ -15,7 +15,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,struct scsi_cmnd *scmd;struct request *rq;struct bio *bio; -int ret; +int ret, unmap_ret;if (hdr->protocol !=BSG_PROTOCOL_SCSI || hdr->subprotocol !=BSG_SUB_PROTOCOL_SCSI_CMD )
@@ -89,7 +89,9 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,else hdr->dout_resid = scmd->resid_len; -blk_rq_unmap_user (bio); + unmap_ret =blk_rq_unmap_user (bio); +if (!ret) + ret = unmap_ret; out_put_request:blk_mq_free_request (rq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/3318 scsi: target: Verify the iSCSI ISID is null-terminated
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanhe Shu <[email protected]>
[ Upstream commit cdf4b87a18cb6a0ee26865cb1b7b5660a491d302 ]
iscsi_parse_pr_out_transport_id() returns the ISID of a FORMAT CODE 01b TransportID as a pointer into the PERSISTENT RESERVE OUT parameter list, lowercased in place and never null-terminated. spc4r37 Table 508 requires the field to be null-terminated, but a non-conforming initiator can omit the NULL; when the ISID ends at the end of the received buffer, the pointer is not a C string.
The registration code still consumes it as one: strcmp() in __core_scsi3_locate_pr_reg() and in the REGISTER AND MOVE path, and snprintf("%s") in __core_scsi3_do_alloc_registration(), which also reads its first 8 bytes unconditionally with get_unaligned_be64() - a NUL check does not bound that read.
When the parameter list spans more than one page, transport_kmap_data_sg() maps it with vmap(), and the over-read walks off the end of the mapping into the vmalloc() guard page and oopses. Reproduced with a PR OUT REGISTER + SPEC_I_PT parameter list of exactly 8192 bytes whose final TransportID carries a 12-byte ISID without a terminating NUL:
BUG: unable to handle page fault for address: ffffc9000138c000 RIP: 0010:strcmp+0xc/0x30 Call Trace: __core_scsi3_locate_pr_reg+0xd3/0x120 [target_core_mod] core_scsi3_decode_spec_i_port+0x8fc/0x13a0 [target_core_mod] core_scsi3_emulate_pro_register+0x73c/0x900 [target_core_mod] ... iscsi_target_rx_thread+0xef/0x1d0 [iscsi_target_mod]
With a single-page parameter list the buffer is a kmap() direct mapping, so the over-read continues into the physically adjacent page instead of faulting. snprintf("%s") then copies whatever follows the ISID in memory into pr_reg_isid, and PR IN READ FULL STATUS reports the registration back to any initiator, turning the over-read into an info leak of kernel heap contents. Reproduced with a 4096-byte parameter list whose last TransportID ends at the end of the buffer with a 4-byte ISID and no NUL, interleaved with I/O to populate adjacent pages: the READ FULL STATUS response returned the ISID as "0xleak" followed by raw bytes that were not part of the parameter list. The snprintf() into pr_reg_isid[PR_REG_ISID_LEN] caps the echoed ISID at 15 characters, so at most 11 bytes past the buffer are leaked per command, but the PR OUT command is not rate limited.
Any initiator that can send PR OUT to an iSCSI-exported LUN can trigger either variant, including a guest via vhost-scsi.
Require 8 bytes to remain after the ",i,0x" separator, and a NUL inside the rest of the descriptor, before the ISID pointer is returned. REGISTER AND MOVE fails with TCM_INVALID_PARAMETER_LIST; on SPEC_I_PT no target port claims the malformed TransportID, and the command fails the same way.
--- drivers/target/target_core_fabric_lib.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/target/target_core_fabric_lib.c +10 -0
@@ -370,6 +370,16 @@ static bool iscsi_parse_pr_out_transport_id(pr_err ("Missing ISID in iSCSI Initiator port TransportID\n" );return false; } +/* +* The registration code reads the ISID as a C string, +* and its first 8 bytes with get_unaligned_be64(), so +* require 8 bytes after the separator and a NUL inside +* the rest of the descriptor. +*/ +if (buf + tid_len - p <8 || !memchr (p,'\0' , buf + tid_len - p)) { +pr_err ("Incomplete or unterminated ISID in iSCSI Initiator port TransportID\n" ); +return false; + } *port_nexus_ptr = p;/* * Go ahead and do the lower case conversion of the received
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/3318 scsi: target: tcmu: Fix divide-by-zero in data_pages_per_blk store
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <[email protected]>
[ Upstream commit b8d0bb6a8ba0d3878940a914a19336844101867b ]
tcmu_set_data_pages_per_blk() only validates the upper bound of the value parsed from data_pages_per_blk=. Zero passes that check and is then used as the divisor when computing udev->max_blocks:
divide error: 0000 [#1] SMP
...
tcmu_set_data_pages_per_blk
tcmu_configure_device
Reject non-positive values, as the neighbouring max_data_area_mb and cmd_ring_size setters already do.
--- drivers/target/target_core_user.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/target/target_core_user.c +5 -0
@@ -2514,6 +2514,11 @@ static int tcmu_set_data_pages_per_blk(struct tcmu_dev *udev, substring_t *arg)return ret; } +if (val <=0 ) { +pr_err ("Invalid data_pages_per_blk %d.\n" , val); +return -EINVAL ; + } +if (val >TCMU_MBS_TO_PAGES (udev->data_area_mb)) { pr_err("Invalid data_pages_per_blk %d: greater than max_data_area_mb %d -> %zd pages).\n", val, udev->data_area_mb,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/3318 drm/loongson: Fix framebuffer selection in async cursor updates
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evanshenf <[email protected]>
[ Upstream commit fa66daafbb6d5c984de2502809ff533ab66f6573 ]
An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the live state before this swap. When an enabled cursor changes buffers, the address-update condition is therefore false and the hardware continues scanning the previous buffer.
Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.
Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.
AI assistance was used to investigate the existing report, prepare the fix and test tools, run the build and hardware comparison, and draft this message.
--- drivers/gpu/drm/loongson/lsdc_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
@@ -228,7 +228,7 @@ static void lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane, new_state =drm_atomic_get_new_plane_state (state, plane); - new_fb = plane->state->fb; + new_fb = new_state->fb; plane->state->crtc_x = new_state->crtc_x; plane->state->crtc_y = new_state->crtc_y;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/3318 drm/loongson: Fix double free on BO initialization failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evanshenf <[email protected]>
[ Upstream commit f086dbdeb6e56510e158a853d752c6d8ed9e0674 ]
If ttm_bo_init_validate() fails, it drops the buffer object's reference and cleans it up through the supplied destroy callback. lsdc_bo_destroy() releases the GEM object and frees the enclosing lsdc_bo, so freeing it again in lsdc_bo_create() causes a double free on a synchronous failure path.
Let TTM own the cleanup after initialization has started and return the error directly. Keep the explicit free on drm_gem_object_init() failure, which occurs before ownership is passed to TTM.
Tested on LS7A2000 by making drm_vma_offset_add() return -ENOSPC for one selected dumb-buffer creation. The error reached userspace, the destroy callback ran once, and no handle was published or tracked BO retained. Normal buffer creation, zeroing, mapping, readback and release passed.
AI assistance was used for the ownership analysis, fix, fault-injection tools, build and test execution.
--- drivers/gpu/drm/loongson/lsdc_ttm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/loongson/lsdc_ttm.c +1 -3
@@ -480,10 +480,8 @@ struct lsdc_bo *lsdc_bo_create(struct drm_device *ddev, ret =ttm_bo_init_validate (bdev, tbo, bo_type, &lbo->placement,0 , false, sg, resv, lsdc_bo_destroy); -if (ret) { -kfree (lbo); +if (ret)return ERR_PTR (ret); - }return lbo; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/3318 drm/loongson: Handle buffer mapping failures when clearing a BO
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evanshenf <[email protected]>
[ Upstream commit f00d7a241f846b053e89c0bb2285ef5988d4cafc ]
lsdc_bo_clear() ignores the return value from lsdc_bo_kmap() and writes to lbo->kptr unconditionally. When the first mapping of a newly allocated buffer fails, kptr is still NULL and the subsequent memset accesses it.
Return the mapping error without touching the buffer and propagate it from lsdc_gem_object_create(). Install the GEM object functions before clearing so that drm_gem_object_put() can release the buffer correctly on failure. Do not add the failed object to the tracking list or return an uncleared buffer to the caller.
Imported buffers still skip clearing, and successfully mapped buffers are cleared and unmapped as before.
Tested on LS7A2000 with a one-shot range error in ttm_bo_kmap(). Its -EINVAL return reached userspace, the object was destroyed once, and no GEM handle was published. Normal create/map/zero/write/read/close cycles passed, with the tracked BO count and VRAM usage unchanged.
AI assistance was used for the lifetime analysis, fix, fault-injection tools, build and test execution.
--- drivers/gpu/drm/loongson/lsdc_gem.c | 12 ++++++++---- drivers/gpu/drm/loongson/lsdc_ttm.c | 10 ++++++++-- drivers/gpu/drm/loongson/lsdc_ttm.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/loongson/lsdc_gem.c +8 -4
@@ -164,14 +164,18 @@ struct drm_gem_object *lsdc_gem_object_create(struct drm_device *ddev,return ERR_PTR (ret); } + gobj = &lbo->tbo.base; + gobj->funcs = &lsdc_gem_object_funcs; +if (!sg) {/* VRAM is filled with random data */ -lsdc_bo_clear (lbo); + ret =lsdc_bo_clear (lbo); +if (ret) { +drm_gem_object_put (gobj); +return ERR_PTR (ret); + } } - gobj = &lbo->tbo.base; - gobj->funcs = &lsdc_gem_object_funcs; -/* tracking the BOs we created */ mutex_lock (&ldev->gem.mutex);list_add_tail (&lbo->list, &ldev->gem.objects);
drivers/gpu/drm/loongson/lsdc_ttm.c +8 -2
@@ -393,9 +393,13 @@ void lsdc_bo_kunmap(struct lsdc_bo *lbo)ttm_bo_kunmap (&lbo->kmap); } -void lsdc_bo_clear (struct lsdc_bo *lbo) +int lsdc_bo_clear (struct lsdc_bo *lbo) { -lsdc_bo_kmap (lbo); +int ret; + + ret =lsdc_bo_kmap (lbo); +if (ret) +return ret;if (lbo->is_iomem)memset_io ((void __iomem *)lbo->kptr,0 , lbo->size);
@@ -403,6 +407,8 @@ void lsdc_bo_clear(struct lsdc_bo *lbo)memset (lbo->kptr,0 , lbo->size);lsdc_bo_kunmap (lbo); + +return 0 ; }int lsdc_bo_evict_vram (struct drm_device *ddev)
drivers/gpu/drm/loongson/lsdc_ttm.h +1 -1
@@ -89,7 +89,7 @@ size_t lsdc_bo_size(struct lsdc_bo *lbo);int lsdc_bo_kmap (struct lsdc_bo *lbo);void lsdc_bo_kunmap (struct lsdc_bo *lbo); -void lsdc_bo_clear (struct lsdc_bo *lbo); +int lsdc_bo_clear (struct lsdc_bo *lbo);int lsdc_bo_evict_vram (struct drm_device *ddev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/3318 ALSA: us122l: Add missing NULL check in usb_stream_hwdep_mmap()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit f5d3eb483fed59fc0f3b059b8b6a32cedc922360 ]
usb_stream_hwdep_mmap() reads us122l->sk.s and dereferences it without checking for NULL. The stream object is released by usb_stream_free(), which is reached through us122l_stop() both when the device is disconnected and when us122l_start() fails, and it leaves us122l->sk.s set to NULL. The hwdep file stays usable after that, so a later mmap()
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:usb_stream_hwdep_mmap+0x107/0x890 sound/usb/usx2y/us122l.c:182
crashes while reading s->read_size, which sits at offset 0x10.
That NULL is an expected state for this field: usb_stream_hwdep_vm_fault(), usb_stream_hwdep_poll(), usb_stream_hwdep_ioctl(), usb_stream_stop() and usb_stream_free() all test it before use. Only the mmap callback misses the check, so let it return -ENODEV, matching what the other hwdep mapping in usx2yhwdeppcm.c does when its shared buffer has not been allocated.
--- sound/usb/usx2y/us122l.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/usx2y/us122l.c +2 -0
@@ -200,6 +200,8 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, offset = area->vm_pgoff <<PAGE_SHIFT ;mutex_lock (&us122l->mutex); s = us122l->sk.s; +if (!s) +return -ENODEV ; read = offset < s->read_size;if (read) {if (area->vm_flags &VM_WRITE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/3318 ALSA: us122l: Fix NULL dereference at hwdep open and release
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit 820e0050866942b5498488496462d12c6ce1c7a9 ]
usb_stream_hwdep_open() and usb_stream_hwdep_release() pass the result of usb_ifnum_to_if() straight to usb_autopm_get_interface() and usb_autopm_put_interface(), without checking it for NULL.
usb_ifnum_to_if() returns NULL once the device is gone, since usb_disable_device() clears udev->actconfig on disconnect. The hwdep file can outlive the disconnect: the card is released with snd_card_free_when_closed(), so a process that keeps the character device open reaches the driver's release callback after the USB configuration has been dropped, and interface_to_usbdev() then dereferences the NULL interface at offsetof(struct device, parent). The open callback has the same problem when it races with the disconnect.
Check both lookups and fail the open with -ENODEV; in release, skip the runtime PM put when the interface is already gone and still run the rest of the per-file cleanup. Move the us122l->first bookkeeping after the checks so that a failed open no longer leaves a stale file pointer behind.
--- sound/usb/usx2y/us122l.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
sound/usb/usx2y/us122l.c +17 -8
@@ -148,19 +148,26 @@ static const struct vm_operations_struct usb_stream_hwdep_vm_ops = {static int usb_stream_hwdep_open (struct snd_hwdep *hw,struct file *file) {struct us122l *us122l = hw->private_data; -struct usb_interface *iface; +struct usb_interface *iface, *iface0 =NULL ;if (hw->used >=2 )return -EBUSY ; -if (!us122l->first) - us122l->first = file; -if (us122l->is_us144) { - iface =usb_ifnum_to_if (us122l->dev,0 ); -usb_autopm_get_interface (iface); + iface0 =usb_ifnum_to_if (us122l->dev,0 ); +if (!iface0) +return -ENODEV ; } + iface =usb_ifnum_to_if (us122l->dev,1 ); +if (!iface) +return -ENODEV ; + +if (!us122l->first) + us122l->first = file; + +if (iface0) +usb_autopm_get_interface (iface0);usb_autopm_get_interface (iface);return 0 ; }
@@ -172,10 +179,12 @@ static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)if (us122l->is_us144) { iface =usb_ifnum_to_if (us122l->dev,0 ); -usb_autopm_put_interface (iface); +if (iface) +usb_autopm_put_interface (iface); } iface =usb_ifnum_to_if (us122l->dev,1 ); -usb_autopm_put_interface (iface); +if (iface) +usb_autopm_put_interface (iface);if (us122l->first == file) us122l->first =NULL ;mutex_lock (&us122l->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/3318 ALSA: usx2y: Initialize idle URBs before submitting streams
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit ceb0d8c22473933099b46cec70639d0f1f7c68ad ]
usb_stream_start() submits the first two capture and playback URBs and only afterwards assigns sk->idle_inurb, sk->idle_outurb, sk->completed_inurb and sk->completed_outurb to the remaining two URBs of each direction.
A transfer can complete as soon as usb_submit_urb() has been called, so the completion handler i_capture_start() or i_playback_start() may run before those pointers are set. While the stream is still being synchronized (state below usb_stream_sync1), stream_start() then calls playback_prep_freqn(sk, sk->idle_outurb) with sk->idle_outurb still NULL, and the packet descriptors are written through that NULL pointer:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000018: 0000 [#1] SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000c0-0x00000000000000c7] RIP: 0010:playback_prep_freqn+0x11c/0x4a0 sound/usb/usx2y/usb_stream.c:33 Call Trace: <IRQ> stream_start+0x5dc/0x8d0 sound/usb/usx2y/usb_stream.c:596 i_capture_start+0x3da/0x710 sound/usb/usx2y/usb_stream.c:654 __usb_hcd_giveback_urb+0x238/0x550 drivers/usb/core/hcd.c:1657 usb_giveback_urb_bh+0x20b/0x530 drivers/usb/core/hcd.c:1691 tasklet_hi_action+0xa/0x20 kernel/softirq.c:994 handle_softirqs+0x16f/0x440 kernel/softirq.c:645 </IRQ>
The four URBs referenced by these pointers are allocated long before and do not depend on any transfer state, so assign them before the submit loop. Keeping the assignment inside the retry path also restores a well-defined URB rotation when the start frame mismatch handling kills and resubmits the streams.
--- sound/usb/usx2y/usb_stream.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sound/usb/usx2y/usb_stream.c +4 -5
@@ -682,6 +682,10 @@ int usb_stream_start(struct usb_stream_kernel *sk) s->sync_packet =-1 ; s->inpacket_head =-1 ; sk->iso_frame_balance =0 ; + sk->idle_inurb = sk->inurb[USB_STREAM_NURBS -2 ]; + sk->idle_outurb = sk->outurb[USB_STREAM_NURBS -2 ]; + sk->completed_inurb = sk->inurb[USB_STREAM_NURBS -1 ]; + sk->completed_outurb = sk->outurb[USB_STREAM_NURBS -1 ]; ++try;for (u =0 ; u <2 ; u++) {struct urb *inurb = sk->inurb[u];
@@ -740,11 +744,6 @@ int usb_stream_start(struct usb_stream_kernel *sk)return -EFAULT ; } - sk->idle_inurb = sk->inurb[USB_STREAM_NURBS -2 ]; - sk->idle_outurb = sk->outurb[USB_STREAM_NURBS -2 ]; - sk->completed_inurb = sk->inurb[USB_STREAM_NURBS -1 ]; - sk->completed_outurb = sk->outurb[USB_STREAM_NURBS -1 ]; -/* wait, check */ {int wait_ms =3000 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/3318 ALSA: hwdep: Serialize DSP load requests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit aee83c204f80d56b4d55f53acdb8594308ddcd4a ]
The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively.
This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice.
Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY.
--- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 2 ++ 2 files changed, 3 insertions(+)
include/sound/hwdep.h +1 -0
@@ -57,6 +57,7 @@ struct snd_hwdep {struct mutex open_mutex;int used;/* reference counter */ +struct mutex dsp_mutex;/* serializes DSP load requests */ unsigned int dsp_loaded;/* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ };
sound/core/hwdep.c +2 -0
@@ -212,6 +212,7 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,return -ENXIO ;if (info->index >=32 )return -EINVAL ; +guard (mutex)(&hw->dsp_mutex);/* check whether the dsp was already loaded */ if (hw->dsp_loaded & (1u << info->index))return -EBUSY ;
@@ -382,6 +383,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex); +mutex_init (&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device;if (id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/3318 bpf: Fix skb_pull() BUG in __bpf_redirect_neigh()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 23503acb214cbefaf3945d05ab9667ff11ae3de9 ]
The issue:
This is a follow-up to the short link-layer header fixes from Eric. After vlan pop_eth, a privileged SCHED_ACT BPF program can call bpf_skb_change_head(skb, 1, 0) and then bpf_redirect_neigh().
__bpf_redirect_neigh() calls skb_pull(skb, sizeof(*ethh)) after checking only that mac_header < network_header. Nothing verifies that the MAC header is long enough, that it is linear, or that the IP header the redirect goes on to read is linear either.
A SCHED_ACT BPF program can do:
bpf_skb_change_head(skb, 1, 0);
bpf_redirect_neigh(lo, NULL, 0, 0);after vlan pop_eth. The skb then has mac_len == 1 and only one byte of linear data; skb_pull(ETH_HLEN) trips the skb->len < skb->data_len BUG in __skb_pull():
kernel BUG at ./include/linux/skbuff.h:2839!
RIP: skb_pull+0x40/0x50
Call Trace: skb_do_redirect -> packet_xmit -> packet_sendmsg Kernel panic - not syncing: Fatal exception in interrupt
The v4 and v6 paths read ip_hdr() and ipv6_hdr() as soon as the MAC header is gone. On the AF_PACKET frame below that leaves headlen == 0 after the pull, so the network header sits at skb->tail and the route lookup reads ip4h->protocol, ip4h->saddr and ip4h->daddr past the linear area.
The Fix:
Use skb_network_offset(), which is the MAC header span, instead of skb->mac_len. mac_len is zero for locally generated tc egress and netkit packets, while the span still rejects the one-byte header produced by pop_eth + bpf_skb_change_head(skb, 1, 0). The single check also covers the mac_header >= network_header test it replaces.
Use pskb_may_pull() to make the Ethernet header linear before it is read or pulled, and to make the IP header linear in both the v4 and the v6 path before ip_hdr()/ipv6_hdr() is read. The header pointers are taken after the pull, since pskb_may_pull() may reallocate skb->head.
Conditions to recreate the bug:
On x86-64 with 4 KiB pages, enable CONFIG_PACKET, CONFIG_BPF_SYSCALL, CONFIG_NET_SCH_INGRESS, CONFIG_NET_CLS_MATCHALL, CONFIG_NET_ACT_VLAN and CONFIG_NET_ACT_BPF. Run as root with BPF loading, network administration and raw-packet privileges. Bring lo up and attach a SCHED_ACT program that calls bpf_skb_change_head(skb, 1, 0), then returns bpf_redirect_neigh(skb->ifindex, NULL, 0, 0):
ip link set lo up
tc qdisc add dev lo clsact
tc filter add dev lo egress matchall action vlan pop_eth pipe \
action bpf object-file neigh_chghead.o section action
Send an untagged ETH_P_IP frame of ETH_HLEN + 8192 bytes through an AF_PACKET/SOCK_RAW socket bound to lo, without PACKET_VNET_HDR or PACKET_QDISC_BYPASS. Use a unicast destination MAC. The sender's skb has a 14-byte linear Ethernet prefix and a fragmented payload; pop_eth removes that prefix and change_head restores only one linear byte. The unfixed neighbor redirect then tries to pull 14 bytes and BUGs.
Sending the same frame without pop_eth and change_head leaves the IP header in the frags, which is the route lookup reading past skb->tail.
--- net/core/filter.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
net/core/filter.c +14 -7
@@ -2262,9 +2262,13 @@ static int bpf_out_neigh_v6(struct net *net, struct sk_buff *skb,static int __bpf_redirect_neigh_v6 (struct sk_buff *skb,struct net_device *dev,struct bpf_nh_params *nh) { -const struct ipv6hdr *ip6h =ipv6_hdr (skb);struct net *net =dev_net (dev);int err, ret =NET_XMIT_DROP ; +const struct ipv6hdr *ip6h; + +if (unlikely (!pskb_may_pull (skb,sizeof (*ip6h)))) + goto out_drop; + ip6h =ipv6_hdr (skb);if (!nh) {struct dst_entry *dst;
@@ -2368,9 +2372,13 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,static int __bpf_redirect_neigh_v4 (struct sk_buff *skb,struct net_device *dev,struct bpf_nh_params *nh) { -const struct iphdr *ip4h =ip_hdr (skb);struct net *net =dev_net (dev);int err, ret =NET_XMIT_DROP ; +const struct iphdr *ip4h; + +if (unlikely (!pskb_may_pull (skb,sizeof (*ip4h)))) + goto out_drop; + ip4h =ip_hdr (skb);if (!nh) { struct flowi4 fl4 = {
@@ -2420,15 +2428,14 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev,static int __bpf_redirect_neigh (struct sk_buff *skb,struct net_device *dev,struct bpf_nh_params *nh) { -struct ethhdr *ethh =eth_hdr (skb); - -if (unlikely (skb->mac_header >= skb->network_header)) +if (unlikely (skb_network_offset (skb) <ETH_HLEN || + !pskb_may_pull (skb,ETH_HLEN ))) goto out;bpf_push_mac_rcsum (skb); -if (is_multicast_ether_addr (ethh->h_dest)) +if (is_multicast_ether_addr (eth_hdr (skb)->h_dest)) goto out; -skb_pull (skb,sizeof (*ethh)); +skb_pull (skb,ETH_HLEN );skb_unset_mac_header (skb);skb_reset_network_header (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/3318 ksmbd: require DELETE access for delete-on-close opens
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 1dd91081ba3c692565f9c1f884149178d5a06d1e ]
smb2_open() accepts FILE_DELETE_ON_CLOSE on an existing file without DELETE in DesiredAccess. When the request asks only for FILE_READ_ATTRIBUTES or READ_CONTROL, it also skips inode_permission() and the parent directory MAY_WRITE | MAY_EXEC check that delete-on-close is meant to get. The file is then marked for deletion by a caller who could not delete it.
The unlink happens later, in __ksmbd_inode_close(), when the last handle on the inode is closed, and it runs with the credentials of that handle. If the caller closes last, the unlink fails. If another user who can write the parent directory, such as the file's owner, still has the file open, the file is deleted when that user closes it. Until then new opens of the file fail with STATUS_DELETE_PENDING. So a user with only search permission on a directory can delete a file in it, or block opens of it, while the owner has it open.
A MAXIMUM_ALLOWED open that also requests DELETE has the same problem. The requested access is replaced with the maximal access, which does not include DELETE when the caller cannot write the parent directory, and the later permission checks are skipped as already done.
MS-FSA 2.1.5.1 requires an open with FILE_DELETE_ON_CLOSE and without DELETE in DesiredAccess to fail with STATUS_INVALID_PARAMETER, and Samba does the same. Add that check to the CreateOptions validation, using the generic-mapped DesiredAccess so that GENERIC_ALL still qualifies. This also refuses MAXIMUM_ALLOWED with FILE_DELETE_ON_CLOSE but no explicit DELETE, as MS-FSA and Samba do. When MAXIMUM_ALLOWED is requested with DELETE but the maximal access does not include DELETE, fail with STATUS_ACCESS_DENIED. With DELETE requested, delete-on-close opens go through the existing parent directory check.
--- fs/smb/server/smb2pdu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/smb/server/smb2pdu.c +15 -0
@@ -3152,6 +3152,14 @@ int smb2_open(struct ksmbd_work *work) req->CreateOptions = ~(FILE_NO_COMPRESSION_LE ); } } + +/* MS-FSA 2.1.5.1: delete-on-close requires DELETE access */ +if (req->CreateOptions &FILE_DELETE_ON_CLOSE_LE && + !(smb_map_generic_desired_access (req->DesiredAccess) & +FILE_DELETE_LE )) { + rc = -EINVAL ; + goto err_out2; + } } if (le32_to_cpu(req->CreateDisposition) >
@@ -3332,6 +3340,13 @@ int smb2_open(struct ksmbd_work *work) maximal_access = daccess; } +/* MAXIMUM_ALLOWED may not have granted the requested DELETE */ +if (req->CreateOptions &FILE_DELETE_ON_CLOSE_LE && + !(daccess &FILE_DELETE_LE )) { + rc = -EACCES ; + goto err_out; + } + open_flags = smb2_create_open_flags(file_present, daccess, req->CreateDisposition, &may_flags,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/3318 drm/i915/gem: Reset err for each fence entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Yao <[email protected]>
[ Upstream commit 31643dc89818d9b65bf42ecb1c67c99b64146fba ]
If dma_fence_chain_find_seqno() failed once, 'err' will store val in the following loop. May causing returns '-EINVAL' even though that entry never called dma_fence_chain_find_seqno() at all.
--- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +1 -1
@@ -2796,7 +2796,6 @@ add_timeline_fence_array(struct i915_execbuffer *eb,u64 __user *user_values;struct eb_fence *f;u64 nfences; -int err =0 ; nfences = timeline_fences->fence_count;if (!nfences)
@@ -2834,6 +2833,7 @@ add_timeline_fence_array(struct i915_execbuffer *eb,struct drm_syncobj *syncobj;struct dma_fence *fence =NULL ;u64 point; +int err =0 ; if (__copy_from_user(&user_fence, user_fences++,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/3318 net: atl1c: drop oversized RX frames instead of panicking
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Federico Musto <[email protected]>
[ Upstream commit c4ba1716853de5178a9df785844ebb5e397a80e6 ]
atl1c sizes its receive buffers from the netdev MTU plus a fixed set of L2 overheads, which comes to 1522 bytes at the default MTU. A link partner that sends a longer frame - in practice a MikroTik CCR2004-1G-2XS-PCIe, whose RouterOS side defaults to l2mtu 1600 while the host stays at MTU 1500
- makes the length reported by the RX return descriptor exceed what the hardware wrote, and skb_put() then either includes bytes that were never received or trips skb_over_panic and takes the host down.
Compare the descriptor length against buffer_info->length, the length the hardware was given, rather than against skb_tailroom(): the skb carries 64 bytes of slack for the DMA erratum, so tailroom is larger than the DMA buffer and a frame in between would pass the check and still be delivered with a tail the device never wrote. The same test rejects frames shorter than ETH_HLEN + ETH_FCS_LEN; before this change a reported length below ETH_FCS_LEN underflowed in skb_put().
The frame is dropped with kfree_skb_reason(SKB_DROP_REASON_PKT_TOO_BIG) so drop_monitor and the kfree_skb tracepoint see it, and counted through dev_core_stats_rx_dropped_inc(), which survives atl1c_get_stats() overwriting the hardware counters on every read. It also counts as work:atl1c_clean_rfd() has already recycled the RFD, and the refill at the end of the poll only runs when work_done is non-zero, so sustained oversized traffic would otherwise drain the ring and stop RX.
Tested on a MikroTik CCR2004-1G-2XS-PCIe (4x AR8151) in a Proxmox VE host, with atl1c built from a DKMS tree carrying this change: the l2mtu-1600 traffic that panics the stock driver is dropped and counted with the patch applied, and received normally once the host MTU is raised to match.
This complements commit 36c2009d90f2 ("net: atl1c: fix soft lockup on out-of-range tpd_cons read"), which fixed the TX side of the same "host dies while the card resets" problem.
--- .../net/ethernet/atheros/atl1c/atl1c_main.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +33 -0
@@ -1933,6 +1933,39 @@ static int atl1c_clean_rx(struct napi_struct *napi, int budget)break ; }atl1c_clean_rfd (rfd_ring, rrs, rfd_num); + +/* A link partner whose l2mtu is larger than ours can hand us a +* frame that does not fit the buffer the hardware was given: +* the descriptor reports the untruncated length while at most +* buffer_info->length bytes were written. skb_put() of such a +* length would pull in whatever the tail of the buffer holds +* and, past the end of the skb, trips skb_over_panic and takes +* the host down. Bound it by what the device actually wrote +* rather than by skb_tailroom(): the skb carries 64 bytes of +* slack for the DMA erratum, so the two are not the same. +* +* Frames shorter than an Ethernet header plus its FCS are +* rejected by the same test; before this, a length below +* ETH_FCS_LEN underflowed in skb_put(). +*/ +if (unlikely (length <ETH_HLEN +ETH_FCS_LEN || + length > buffer_info->length)) { +dev_core_stats_rx_dropped_inc (netdev); +if (netif_msg_rx_err (adapter)) +dev_warn_ratelimited (&pdev->dev, +"dropped rx frame: %u bytes, buffer %u\n" , + length, buffer_info->length); +kfree_skb_reason (skb,SKB_DROP_REASON_PKT_TOO_BIG ); +/* atl1c_clean_rfd() has already recycled the RFD, so +* count the drop as work: the refill at the end of the +* poll only runs when work_done is non-zero, and +* sustained oversized traffic would otherwise drain the +* ring and stop RX for good. +*/ + work_done++; +continue ; + } +skb_put (skb, length -ETH_FCS_LEN ); skb->protocol =eth_type_trans (skb, netdev);atl1c_rx_checksum (adapter, skb, rrs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/3318 ksmbd: grant a POSIX ACL group entry only to the groups members
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit c00ec7ad449b68c291a4986e481941302ed399c5 ]
When no ACE of the DACL matches the caller, Everyone or Authenticated Users, smb_check_perm_dacl() falls back to the file's POSIX ACL. It takes the first ACL_USER or ACL_GROUP entry whose id equals the caller's uid. For ACL_GROUP, this compares a gid with the caller's uid. A numerical match grants the group's permissions even when the caller is not a member.
Match a group entry only when the caller is also in the group.
--- fs/smb/server/smbacl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/server/smbacl.c +4 -1
@@ -1596,7 +1596,10 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,else continue ; -if (id == uid) { +/* A group entry grants only to the group's members */ +if (id == uid && + (pa_entry->e_tag ==ACL_USER || +in_group_p (make_kgid (&init_user_ns, id)))) {mode_to_access_flags (pa_entry->e_perm,0777 , &access_bits);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/3318 mm/mempolicy: charge shared policy nodes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 68b2aa37afa390f08de13bc0bac61a9ded3318bc ]
Any local user can bypass memory.max with mbind() on a tmpfs file, and allocate unbounded kernel memory.
mbind() sets a NUMA memory policy for a range of a mapping. If the mapping is of a shmem and friends, the kernel also stores the policy on the inode, in a tree with one entry per range of the file.
Each mbind() on a single page of a mapping can add one shared policy node (struct sp_node) and one struct mempolicy to that tree. They outlive the mapping and stay around until the inode is destroyed. The tree is not bounded by the file size, so the file can be empty.
Memory that user space can allocate must be charged to a memory cgroup. A slab cache does that for all of its objects if it is created with SLAB_ACCOUNT. numa_policy_init() creates the slab caches for both structs without SLAB_ACCOUNT, so they are not charged to any cgroup.
Reproduced with mbind() on single pages of an empty tmpfs file, from a cgroup with memory.max=8M: the global OOM killer killed tasks owned by root, and the machine panicked.
Fix this by creating both caches with SLAB_ACCOUNT. This change implies that mbind() can now fail when running into memcg limits. Further, the policy_cache also serves task and VMA policies, so they are similarly accounted now.
Note that per-file limits are not really helpful, as the user could simply use many files; having limits per user is tricky as well.
Fix generated by an LLM and submitted by Chris Mason in private.
--- mm/mempolicy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mempolicy.c +2 -2
@@ -2898,11 +2898,11 @@ void __init numa_policy_init(void) policy_cache =kmem_cache_create ("numa_policy" ,sizeof (struct mempolicy ), -0 ,SLAB_PANIC ,NULL ); +0 ,SLAB_PANIC |SLAB_ACCOUNT ,NULL ); sn_cache =kmem_cache_create ("shared_policy_node" ,sizeof (struct sp_node ), -0 ,SLAB_PANIC ,NULL ); +0 ,SLAB_PANIC |SLAB_ACCOUNT ,NULL );for_each_node (nid) { preferred_node_policy[nid] = (struct mempolicy ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/3318 tmpfs: keep the quota soft limits of an unused id
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 968d73463059156e1b89bfa6b189acd7d27197b2 ]
When the last reference to a dquot goes away, shmem_release_dquot() stores its limits in the rb tree of the mount, unless shmem_is_empty_dquot() says that there is nothing worth storing. That function looks at the usage and at the two hard limits only.
So if the administrator sets nothing but soft limits for an id that owns no file yet, the entry is thrown away as soon as the dquot that Q_SETQUOTA used is released, and the id never gets to see a limit.
To fix it, compare the soft limits as well: an entry can be empty only if both soft limits are zero as well, which is exactly what shmem_acquire_dquot() sets for a new entry.
Fix generated by an LLM and sent by Josef Bacik in private.
--- mm/shmem_quota.c | 2 ++ 1 file changed, 2 insertions(+)
mm/shmem_quota.c +2 -0
@@ -253,6 +253,8 @@ static bool shmem_is_empty_dquot(struct dquot *dquot)if (test_bit (DQ_FAKE_B , &dquot->dq_flags) || (dquot->dq_dqb.dqb_curspace ==0 && dquot->dq_dqb.dqb_curinodes ==0 && + dquot->dq_dqb.dqb_bsoftlimit ==0 && + dquot->dq_dqb.dqb_isoftlimit ==0 && dquot->dq_dqb.dqb_bhardlimit == bhardlimit && dquot->dq_dqb.dqb_ihardlimit == ihardlimit))return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/3318 tmpfs: preserve explicitly disabled quota limits
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit d5d861ee303da01e59fdf8e8b2f7096c76e7efd5 ]
An administrator’s decision to disable a user’s or group’s quota limits can be silently lost when tmpfs restores the mount defaults after releasing and reacquiring the quota record. This can cause later file creation or writes to fail with EDQUOT, even though the administrator has explicitly disabled quota limits for the user or group.
do_set_dqblk() sets DQ_FAKE_B when all block and inode limits are zero. This means quota enforcement is disabled for that user or group. shmem_is_empty_dquot() treats the flag as a reason to discard the entry from the mount's quota tree. The next shmem_acquire_dquot() finds no saved entry and recreates it with the mount's default hard limits.
If the cached dquot is reused, DQ_FAKE_B remains set: Q_GETQUOTA reports the restored defaults, but enforcement is still disabled. Once that dquot has been reclaimed, a new dquot enforces the restored defaults.
Remove the DQ_FAKE_B test. Only discard entries with zero usage, zero soft limits and hard limits equal to the mount defaults. Explicitly disabled limits are then preserved whenever the mount defaults are nonzero.
Explicitly disabled limits now retain a quota-tree entry, just like other limits that differ from the mount defaults.
Rename shmem_is_empty_dquot() to shmem_is_default_dquot() to describe the check for default values.
Fix generated by an LLM and sent by Josef Bacik in private.
--- mm/shmem_quota.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
mm/shmem_quota.c +15 -15
@@ -236,7 +236,7 @@ static int shmem_acquire_dquot(struct dquot *dquot)return ret; } -static bool shmem_is_empty_dquot (struct dquot *dquot) +static bool shmem_is_default_dquot (struct dquot *dquot) {struct shmem_sb_info *sbinfo = dquot->dq_sb->s_fs_info;qsize_t bhardlimit;
@@ -250,21 +250,21 @@ static bool shmem_is_empty_dquot(struct dquot *dquot) ihardlimit = sbinfo->qlimits.grpquota_ihardlimit; } -if (test_bit (DQ_FAKE_B , &dquot->dq_flags) || - (dquot->dq_dqb.dqb_curspace ==0 && - dquot->dq_dqb.dqb_curinodes ==0 && - dquot->dq_dqb.dqb_bsoftlimit ==0 && - dquot->dq_dqb.dqb_isoftlimit ==0 && - dquot->dq_dqb.dqb_bhardlimit == bhardlimit && - dquot->dq_dqb.dqb_ihardlimit == ihardlimit)) -return true; - -return false; +/* +* Defaults are zero usage and soft limits, and the mount's hard limits. +* DQ_FAKE_B only means that *all* limits are zero, which need not match +* the mount defaults. +*/ +return dquot->dq_dqb.dqb_curspace ==0 && + dquot->dq_dqb.dqb_curinodes ==0 && + dquot->dq_dqb.dqb_bsoftlimit ==0 && + dquot->dq_dqb.dqb_isoftlimit ==0 && + dquot->dq_dqb.dqb_bhardlimit == bhardlimit && + dquot->dq_dqb.dqb_ihardlimit == ihardlimit; }/* -* Store limits from dquot in the tree unless it's fake. If it is fake -* remove the id from the tree since there is no useful information in -* there. +* Remove the ID from the tree if it has no usage and its limits match +* the mount defaults. Otherwise, save its limits for the next acquire. */ static int shmem_release_dquot (struct dquot *dquot) {
@@ -299,7 +299,7 @@ static int shmem_release_dquot(struct dquot *dquot)return -ENOENT ; found: -if (shmem_is_empty_dquot (dquot)) { +if (shmem_is_default_dquot (dquot)) {/* Remove entry from the tree */ rb_erase (&entry->node, info->dqi_priv);kfree (entry);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/3318 mm/shmem: stop retrying folios that cannot be split
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit a842a1f947da8a7020e72f885ffbf2ce6a93685f ]
A fault or collapse can insert a large folio crossing EOF after shmem_undo_range() has handled the boundary folios. If splitting that folio fails, truncate_inode_partial_folio() retains it when it is dirty. The final scan then repeatedly finds it because it restarts from an unchanged start.
Truncation keeps the inode lock and ignores fatal signals while looping. A concurrent unlink() can then block other directory operations while holding the directory lock and waiting for the file's lock.
Advance start past the retained folio, whose truncated part has already been zeroed. Do not move start backwards if the failed split has shrunk the folio.
Fix generated by an LLM and sent by Chris Mason in private.
--- mm/shmem.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/shmem.c +9 -0
@@ -1119,6 +1119,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, index = start;break ; } + }else if (folio->mapping) { +/* +* Splitting failed, but the part in the +* range is already zeroed. The folio +* was not dropped, so skip it when +* restarting the scan to avoid retrying +* it forever. +*/ + start =max (start,folio_next_index (folio)); } }folio_unlock (folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/3318 mm/shmem: preserve data in clean folios when splitting fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 0c800435394a172f33bf4df4a5a04e187546cc9b ]
A shared writable mapping can have dirty PTEs while its shmem folio is still clean. A read fault can install a writable PTE, and a later store sets the PTE's dirty bit without marking the folio dirty.
After shmem_undo_range() has handled the boundary folios, a concurrent read fault into a hole below the new EOF can allocate a large folio. For example, on a tmpfs mount with huge=always, the fault's offset must be within the file, but the allocated folio can extend beyond i_size. The final scan then finds this folio and calls truncate_inode_partial_folio() without marking it dirty.
Splitting normally collects the PTE dirty bits when unmapping the folio. An extra reference, for example from vmsplice(), can make it fail before that step. The fallback unmapping on split failure excludes shmem, so the helper still sees a clean folio and drops it, losing data outside the range.
CPU0: ftruncate(fd, 3M) CPU1: MAP_SHARED, tmpfs huge=always
───────────────────────────────────── ────────────────────────────────── i_size = 3Mshmem_undo_range(3M, -1)
first pass: hole, nothing to do
boundary folio at 3M: hole, none
read fault at 2M+x (below EOF)
PMD folio [2M,4M), crosses EOF writable PTE, folio clean
store to 2M+x
PTE dirty, folio still clean
vmsplice(2M+x)
extra folio reference
whole_folios: finds [2M,4M) folio truncate_inode_partial_folio()
zero [3M,4M)
folio_split()
unmap_folio(): extra ref
→ -EAGAIN, PTE dirty bit
never reaches the folio
folio clean
→ truncate_inode_folio(whole)
[2M,3M) dropped
read 2M+x → refault → zeroes
Mark large folios dirty before partial truncation in the final scan, as the boundary handling already does. Exclude failed-fallocate rollback, which must discard the folios it added.
Fix generated by an LLM and sent by Chris Mason in private.
--- mm/shmem.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/shmem.c +9 -0
@@ -1103,6 +1103,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,VM_BUG_ON_FOLIO (folio_test_writeback (folio), folio); +/* +* A shared mapping can have dirty PTEs while +* the folio is still clean. Mark the folio +* dirty so a failed split cannot discard data +* outside the range. +*/ +if (!unfalloc &&folio_test_large (folio)) +folio_mark_dirty (folio); +if (!folio_test_large (folio)) {truncate_inode_folio (mapping, folio); }else if (truncate_inode_partial_folio (folio, lstart, lend)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/3318 mm/shmem: discard whole new large folios on fallocate rollback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 23f2a880c0b9518fcb7e7e2ad54a29c0a2c4fba0 ]
When undoing a failed fallocate(), shmem_undo_range() must discard each newly allocated folio. Its second scan instead passes large folios to truncate_inode_partial_folio(), which does not necessarily discard the entire large folio, but instead tries splitting it to discard only the requested range.
For example, with huge=always, a failed allocation starting at offset 4 KiB can leave page 0 allocated in an otherwise empty file.
Discard the whole folio when unfalloc is set. Note that we enter this path only for folios that are not uptodate, and can consequently be dropped without losing any data.
--- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
@@ -1112,7 +1112,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,if (!unfalloc &&folio_test_large (folio))folio_mark_dirty (folio); -if (!folio_test_large (folio)) { +if (unfalloc || !folio_test_large (folio)) {truncate_inode_folio (mapping, folio); }else if (truncate_inode_partial_folio (folio, lstart, lend)) {/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/3318 mm/shmem: fix truncation of files containing only swapin-error markers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 59511d630a6942356ac4b6984797998a8f3a9017 ]
It might not be very common, but we can end up with shmem files that are composed only of swapin-error/poison markers.
Such markers are not counted in info->alloced. Consequently, shmem_setattr() can skip shmem_truncate_range(), leaving the markers behind.
Truncating the file to zero and growing it again will result in reads failing with -EIO instead of returning zeroes.
Check whether the mapping contains entries, in addition to info->alloced, before skipping the truncation. Keep the info->alloced check so that shmem_recalc_inode(), called at the end of shmem_undo_range(), can fix up accounting after reclaim has emptied the mapping.
--- mm/shmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/shmem.c +2 -1
@@ -1232,7 +1232,8 @@ static int shmem_setattr(struct mnt_idmap *idmap,if (oldsize > holebegin)unmap_mapping_range (inode->i_mapping, holebegin,0 ,1 ); -if (info->alloced) +/* Swapin-error markers are not counted in alloced. */ +if (info->alloced || !mapping_empty (inode->i_mapping))shmem_truncate_range (inode, newsize, (loff_t)-1 );/* unmap again to remove racily COWed private pages */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/3318 mm/mglru: dont use stack pointers when walking PUD and PMD tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 65a9bf08a3e4d6e58df211ed900c16bafb79b267 ]
MGLRU passes stack copies of page-table entries in walk_pud_range() and walk_pmd_range() when walking to the next level. These copies can become stale when khugepaged or MADV_DONTNEED (CONFIG_PT_RECLAIM) removes a PTE table concurrently.
This pattern dates back to commit bd74fdaea146 ("mm: multi-gen LRU:
support page table walks"). Likely, earlier locking masked the latent bug. Later changes exposed it: commit 1d65b771bc08 ("mm/khugepaged:retract_page_tables() without mmap or vma lock") allowed concurrent retraction, and commit cf4a65539c13 ("memcg-v1: no need for memcg locking for MGLRU") dropped the walker's outer RCU protection.
The fix is simple, so just fix the original commit so we don't have to speculate. To fix it, pass the actual PMD/PUD pointers. This restores the RCU-protected lookup and validation against the live PMD. Note that the PUD handling is required as well to handle folded page tables correctly in all cases.
Fix generated by an LLM and sent by Josef Bacik in private.
[ david: handle walk_pud_range() as well, clarify+simplify description,
adjust Fixes: ]
--- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/vmscan.c +2 -2
@@ -4212,7 +4212,7 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end, walk->mm_stats[MM_NONLEAF_FOUND ]++; -if (!walk_pte_range (&val, addr, next, args)) +if (!walk_pte_range (pmd + i, addr, next, args))continue ; walk->mm_stats[MM_NONLEAF_ADDED ]++;
@@ -4248,7 +4248,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end,if (!pud_present (val) ||WARN_ON_ONCE (pud_leaf (val)))continue ; -walk_pmd_range (&val, addr, next, args); +walk_pmd_range (pud + i, addr, next, args);if (need_resched () || walk->batched >=MAX_LRU_BATCH ) { end = (addr | ~PUD_MASK ) +1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/3318 mm/memfd: make f_pos accesses atomic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 5426cd43a4d28f1041c9ca45955121b921f29548 ]
Commit 9c225f2655e3 ("vfs: atomic f_pos accesses as per POSIX") made read(), write() and lseek() on a shared open file description of a regular file serialize on ->f_pos_lock. The flag that asks for it, FMODE_ATOMIC_POS, is set in do_dentry_open(). A memfd is a regular file too, but its struct file comes from alloc_file_pseudo() and never passes through do_dentry_open(), so it does not get the flag:
CPU0 CPU1
write(memfd, "a", 1) write(memfd, "b", 1)
pos = file->f_pos (= 0)
pos = file->f_pos (= 0)
vfs_write(..., &pos)
vfs_write(..., &pos)
file->f_pos = pos (= 1)
file->f_pos = pos (= 1)One of the two bytes is overwritten. Two threads writing 100000 bytes each, one at a time, to a memfd end up with a file that is far shorter than 200000 bytes, while the same program on a tmpfs file never loses a byte.
Set the flag when the memfd is created. As for any other regular file the lock is only taken if the file is reachable in more than one way, and nothing a memfd does in read or write waits for another operation on the same file. This cannot be done for all alloc_file_pseudo() files: anon inode files such as eventfd are S_IFREG as well, and a blocked read holding ->f_pos_lock would lock out the write that is supposed to wake it.
Fix generated by an LLM and sent by Josef Bacik in private.
--- mm/memfd.c | 2 ++ 1 file changed, 2 insertions(+)
mm/memfd.c +2 -0
@@ -366,6 +366,8 @@ SYSCALL_DEFINE2(memfd_create, goto err_fd; } file->f_mode |=FMODE_LSEEK |FMODE_PREAD |FMODE_PWRITE ; +/* a regular file like any other: POSIX.1-2008/SUSv4 Section XSI 2.9.7 */ + file->f_mode |=FMODE_ATOMIC_POS ; file->f_flags |=O_LARGEFILE ;if (flags &MFD_NOEXEC_SEAL ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/3318 mm/filemap: dont lose a folio lock wakeup to a signal
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 8ccb6ded6a47b59b4907ed4f8c293cf8122de889 ]
An exclusive waiter in folio_wait_bit_common() can leave the wait loop because of a fatal signal, then be woken by folio_unlock() before finish_wait(). If the waker did not hand over the lock, the waiter returns -EINTR without trying to acquire it.
folio_wake_bit() stops after waking the first exclusive waiter, so this loses the wakeup and can leave other waiters asleep indefinitely on an unlocked folio.
After finish_wait(), let a waiter woken without a lock handoff try once more to acquire the lock. If successful, return success so the caller's eventual unlock wakes the next waiter. Otherwise, the current lock owner will do so.
Fix generated by an LLM and sent by Josef Bacik in private.
--- mm/filemap.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
mm/filemap.c +15 -3
@@ -1375,10 +1375,22 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,* return value based on that state without races. * * Also note that WQ_FLAG_WOKEN is sufficient for a non-exclusive -* waiter, but an exclusive one requires WQ_FLAG_DONE. +* waiter, but an exclusive one must also acquire the bit. */ -if (behavior ==EXCLUSIVE ) -return wait->flags &WQ_FLAG_DONE ?0 : -EINTR ; +if (behavior ==EXCLUSIVE ) { +if (wait->flags &WQ_FLAG_DONE ) +return 0 ; +/* +* We might have just been woken up and the waker will not +* wake up anybody else. If we ignore that now, the remaining +* waiters may not get woken up: take the bit now if it is +* still free. +*/ +if ((wait->flags &WQ_FLAG_WOKEN ) && + !test_and_set_bit (bit_nr,folio_flags (folio,0 ))) +return 0 ; +return -EINTR ; + }return wait->flags &WQ_FLAG_WOKEN ?0 : -EINTR ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/3318 ext2: preserve completed DIO bytes when buffered fallback fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit cbf04dde8b3c5a7e043e91cefad68b8980ea0d18 ]
ext2_dio_write_iter() can complete part of a direct write before falling back to buffered I/O for a hole inside i_size. If generic_perform_write() then fails, its error overwrites the completed direct-I/O byte count.
For example, on a full filesystem, an 8 KiB write to a file with an allocated 4 KiB prefix and a 4 KiB hole overwrites the prefix but returns ENOSPC and leaves the file position unchanged. GNU dd with oflag=direct consequently reports zero bytes written.
Preserve a positive direct-I/O result and return the buffered error when no bytes were direct-written. This restores the fallback policy of generic_file_write_iter(), which ext2 used before its iomap conversion.
--- fs/ext2/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext2/file.c +2 -1
@@ -254,7 +254,8 @@ static ssize_t ext2_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) pos = iocb->ki_pos; status =generic_perform_write (iocb, from);if (unlikely (status <0 )) { - ret = status; +if (!ret) + ret = status; goto out_unlock; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/3318 drm/v3d: Initialize timedout_batches when running a CSD job
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jose Maria Casanova Crespo <[email protected]>
[ Upstream commit 0afdbdd5b1af729108de8f893d179c3b99eac29d ]
v3d_csd_job_timedout() decides whether a compute job made progress by comparing CSD_CURRENT_CFG4, the number of batches the dispatcher still has to start, against the value saved at the previous timeout. That saved value is never initialized, so it is zero on the first timeout.
On V3D 7.1.6 and later, CFG4 counts down to zero once the dispatcher has started the last batch, but the dispatch keeps running until the batches in flight complete. If the first timeout fires in that window, the handler sees no change and resets the GPU while the job is about to complete. For example, this happens with long dispatches that only keep a single supergroup in flight.
Initialize timedout_batches to the value programmed in CFG4 when the job is started. The register does not return to it once a batch has started:
it counts down to zero on V3D 7.1.6 and later (CFG4 holds the number of batches), and to 0xffffffff on V3D 4.2 (CFG4 holds the number of batches minus one).
--- drivers/gpu/drm/v3d/v3d_sched.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_sched.c +2 -0
@@ -260,6 +260,8 @@ v3d_csd_job_run(struct drm_sched_job *sched_job)dma_fence_put (job->base.irq_fence); job->base.irq_fence =dma_fence_get (fence); + job->timedout_batches = job->args.cfg[4 ]; +trace_v3d_submit_csd (dev,to_v3d_fence (fence)->seqno);v3d_switch_perfmon (v3d, &job->base);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/3318 vhost-vdpa: fix pinned page leak in vhost_vdpa_pa_map() error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit fd1462c96bafe2cb14e88c837b270f8990b717b5 ]
When pin_user_pages() or vhost_vdpa_map() fails, vhost_vdpa_pa_map() is supposed to unpin the pages pinned after the last successfully mapped chunk, i.e. the range [map_pfn, last_pfn]. The unpin is guarded by nchunks, but nchunks is reset to 0 every time a chunk is mapped from inside the current page list, so a failure after any such boundary leaves that pending range pinned forever. With physically scattered memory nearly every page list contains a boundary, so the leak happens on practically every failed IOTLB update.
The pending range is non-empty exactly when a page has been pinned, which last_pfn already tells us, so drop nchunks and test last_pfn.
Message-ID: <[email protected]>
--- drivers/vhost/vdpa.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/vhost/vdpa.c +2 -6
@@ -1090,7 +1090,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v,unsigned long list_size =PAGE_SIZE /sizeof (struct page *);unsigned int gup_flags =FOLL_LONGTERM ;unsigned long npages, cur_base, map_pfn, last_pfn =0 ; -unsigned long lock_limit, sz2pin, nchunks, i; +unsigned long lock_limit, sz2pin, i;unsigned long page_offset;u64 start = iova;long pinned;
@@ -1126,7 +1126,6 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, cur_base = uaddr &PAGE_MASK ; iova &=PAGE_MASK ; - nchunks =0 ;while (npages) { sz2pin = min_t(unsigned long, npages, list_size);
@@ -1141,7 +1140,6 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, } goto out; } - nchunks++;if (!last_pfn) map_pfn =page_to_pfn (page_list[0 ]);
@@ -1172,7 +1170,6 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, map_pfn = this_pfn; iova += csize; - nchunks =0 ; } last_pfn = this_pfn;
@@ -1187,7 +1184,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, PFN_PHYS(map_pfn), perm, NULL); out:if (ret) { -if (nchunks) { +if (last_pfn) {unsigned long pfn;/*
@@ -1199,7 +1196,6 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v,* the corresponding unpinning will be handled by * vdpa_unmap(). */ -WARN_ON (!last_pfn);for (pfn = map_pfn; pfn <= last_pfn; pfn++)unpin_user_page (pfn_to_page (pfn)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/3318 vringh: bound top-level re-entry into indirect tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fang Xieyan <[email protected]>
[ Upstream commit f898439ace7f89922e853b43bcbfcd26ea2e0a98 ]
In __vringh_iov(), the F_INDIRECT branch descends into the indirect table and continues before the descriptor accounting runs. A top-level indirect descriptor is therefore never charged to count. If such a descriptor sets NEXT to point back at itself, returning from the indirect table resumes at the same top-level descriptor, which is again not counted, so the walk never makes forward progress.
Because count stays flat and indirect_count is reset to 0 on every return to the top-level table, neither bound in the loop check trips. A guest can spin the vringh worker at 100% CPU inside __vringh_iov(), an uninterruptible host DoS.
Move the descriptor accounting above the indirect switch so that a top-level indirect descriptor is charged one top-level traversal step before the walk descends into its table, bringing this re-entry under the existing vrh->vring.num bound. Each top-level descriptor is still charged at most one step and indirect_count still bounds a single table, so legitimate chains (including the multiple-indirect case in tools/virtio/vringh_test.c) stay within vring.num, while a cyclic indirect descriptor is now rejected with -ELOOP.
Message-ID: <[email protected]>
--- drivers/vhost/vringh.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/vhost/vringh.c +11 -11
@@ -334,6 +334,17 @@ __vringh_iov(struct vringh *vrh, u16 i,if (unlikely (err)) goto fail; +if (up_next ==-1 ) + count++; +else + indirect_count++; + +if (count > vrh->vring.num || indirect_count > desc_max) { +vringh_bad ("Descriptor loop in %p" , descs); + err = -ELOOP ; + goto fail; + } +if (unlikely (desc.flags &cpu_to_vringh16 (vrh,VRING_DESC_F_INDIRECT ))) {u64 a =vringh64_to_cpu (vrh, desc.addr);
@@ -359,17 +370,6 @@ __vringh_iov(struct vringh *vrh, u16 i,continue ; } -if (up_next ==-1 ) - count++; -else - indirect_count++; - -if (count > vrh->vring.num || indirect_count > desc_max) { -vringh_bad ("Descriptor loop in %p" , descs); - err = -ELOOP ; - goto fail; - } -if (desc.flags &cpu_to_vringh16 (vrh,VRING_DESC_F_WRITE )) iov = wiov;else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/3318 vringh: reject empty / undersized indirect descriptor tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fang Xieyan <[email protected]>
[ Upstream commit 60a792b97933a686316737838cd007d27963011e ]
move_to_indirect() validates an indirect descriptor table only with "len % sizeof(struct vring_desc)". A descriptor flagged VRING_DESC_F_INDIRECT with len == 0 passes that test, so *desc_max is set to 0 while *descs points at the empty table. __vringh_iov() then copies one struct vring_desc from descs[0] -- 16 bytes past the end of the table -- before the "indirect_count > desc_max" loop detection aborts the walk. The over-read value is discarded when the walk aborts and is never used to map anything, but the access itself is out of bounds.
Reject any len smaller than one descriptor, alongside the existing stride check, so an empty table is refused with -EINVAL and no descriptor is ever fetched from it.
Message-ID: <[email protected]>
--- drivers/vhost/vringh.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/vhost/vringh.c +3 -2
@@ -197,8 +197,9 @@ static int move_to_indirect(const struct vringh *vrh, } len =vringh32_to_cpu (vrh, desc->len); -if (unlikely (len %sizeof (struct vring_desc ))) { -vringh_bad ("Strange indirect len %u" , desc->len); +if (unlikely (len <sizeof (struct vring_desc ) || + len %sizeof (struct vring_desc ))) { +vringh_bad ("Invalid indirect len %u" , desc->len);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/3318 veth: keep carrier off when resizing channels with a down peer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xia Yan <[email protected]>
[ Upstream commit 2d02191779345b13de91048db441191b20264d16 ]
veth_set_channels() temporarily turns carrier off while reconfiguring a running interface. It then turns carrier on for both ends without checking whether the peer is administratively up. If only one end is up, changing its channel counts therefore reports LOWER_UP even though the peer remains down.
For example, after creating a pair with two RX and TX queues per end:
ip link set vca up
ethtool -L vca rx 1 tx 1
vca incorrectly reports LOWER_UP while vcb is still down.
Only restore carrier when the peer has IFF_UP, matching veth_open(). The local interface is already known to be running at this point.
Found during LLM-assisted source review and reproduced with a veth pair in network namespaces, without kernel instrumentation or error injection. The companion veth.sh test reproduces the two mixed up/down failures before the fix and passes after it.
--- drivers/net/veth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/veth.c +3 -2
@@ -1393,9 +1393,10 @@ static int veth_set_channels(struct net_device *dev,* to identify the range we have to disable */ veth_disable_range_safe (dev, new_rx_count, old_rx_count); -netif_carrier_on (dev); -if (peer) +if (peer && (peer->flags &IFF_UP )) { +netif_carrier_on (dev);netif_carrier_on (peer); + } }/* update XDP supported features */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/3318 hwmon: (corsair-cpro) Cache fan target only after a successful command
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baek Kyu, Kim <[email protected]>
[ Upstream commit e2c26431b4e47892378582a414b4bbaa9edf1798 ]
set_target() updates the cached fan target before sending the command. If the command fails, subsequent fanN_target reads report the failed request instead of the previous value. For example, after successfully setting 1200 RPM, a rejected request for 1800 RPM returns an error but leaves fanN_target reporting 1800. A failed request also replaces -ENODATA when no target has been successfully set.
Update the target cache under the existing mutex only after send_usb_cmd() succeeds, as set_pwm() already does when invalidating the target. Preserve the previous cached value and return the original error on failure.
--- drivers/hwmon/corsair-cpro.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/corsair-cpro.c +2 -1
@@ -208,10 +208,11 @@ static int set_target(struct ccp_device *ccp, int channel, long val)int ret; val =clamp_val (val,0 ,0xFFFF ); - ccp->target[channel] = val;mutex_lock (&ccp->mutex); ret =send_usb_cmd (ccp,CTL_SET_FAN_TARGET , channel, val >>8 , val); +if (!ret) + ccp->target[channel] = val;mutex_unlock (&ccp->mutex);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/3318 hwmon: (aquacomputer_d5next) Check maxcollection when probing AQUAERO devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit b7743c6dbe3ab94045164ef298f65cfb9b0b450a ]
When a USB HID device matching USB_PRODUCT_ID_AQUAERO presents a malformed report descriptor, an out-of-bounds array access occurs in aqc_probe() due to an unchecked index into the parsed collections array. During device initialization, the driver distinguishes between the multiple logical interfaces exposed by the Aquaero device by evaluating the type of the second element in the collection array. The driver unconditionally accesses hdev->collection[1] without verifying that hdev->maxcollection is greater than 1. Because the collection array is dynamically allocated by the HID core based on the number of collections found in the report descriptor, a crafted device exposing fewer than two collections causes an immediate heap out-of-bounds read or NULL pointer dereference. This leads to a kernel panic during the device probe phase.
Add the missing check to fix the problem.
--- drivers/hwmon/aquacomputer_d5next.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/aquacomputer_d5next.c +1 -1
@@ -1533,7 +1533,7 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)* they present. The two other devices have the type of the second element in * their respective collections set to 1, while the real device has it set to 0. */ -if (hdev->collection[1 ].type !=0 ) { +if (hdev->maxcollection <2 || hdev->collection[1 ].type !=0 ) { ret = -ENODEV ; goto fail_and_close; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/3318 hwmon: (asus_wmi_sensors) Avoid global struct mutation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 59d586c9e47d1205563bc9b5a5d443adc3ba5bc5 ]
In the asus_wmi_sensors driver, device-managed memory allocated in asus_wmi_configure_sensor_setup() is assigned to a global static structure, leading to a potential use-after-free when the device is unbound. The driver defines a single global asus_wmi_chip_info structure to register with the hwmon core. During probe, it dynamically allocates the .info channel array using devm_kcalloc() and assigns it directly to this global structure. When a device is unbound, its device-managed memory is automatically freed, leaving asus_wmi_chip_info.info as a dangling pointer. Furthermore, if multiple WMI devices are probed sequentially, each probe overwrites the same global pointer, forcing all registered hwmon instances to reference the channel information of the most recently probed device.
While it is unlikely if not impossible that multiple WMI devices of the same kind exist, modifying a global static data structure is undesirable. Remove the static data structure and allocate it as part of struct asus_wmi_sensors to avoid the potential problem.
--- drivers/hwmon/asus_wmi_sensors.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/hwmon/asus_wmi_sensors.c +5 -8
@@ -164,6 +164,7 @@ struct asus_wmi_wmi_info {struct asus_wmi_sensors {struct asus_wmi_wmi_info wmi; +struct hwmon_chip_info chip_info;/* lock access to internal cache */ struct mutex lock; };
@@ -496,11 +497,6 @@ static const struct hwmon_ops asus_wmi_hwmon_ops = { .read_string = asus_wmi_hwmon_read_string, }; -static struct hwmon_chip_info asus_wmi_chip_info = { - .ops = &asus_wmi_hwmon_ops, - .info =NULL , -}; -static int asus_wmi_configure_sensor_setup (struct device *dev,struct asus_wmi_sensors *sensor_data) {
@@ -508,7 +504,7 @@ static int asus_wmi_configure_sensor_setup(struct device *dev,struct hwmon_channel_info *asus_wmi_hwmon_chan;int nr_count[hwmon_max] = {}, nr_types =0 ;struct asus_wmi_sensor_info *temp_sensor; -const struct hwmon_chip_info *chip_info; +struct hwmon_chip_info *chip_info;enum hwmon_sensor_types type;struct device *hwdev;int i, idx;
@@ -549,8 +545,9 @@ static int asus_wmi_configure_sensor_setup(struct device *dev,if (!ptr_asus_wmi_ci)return -ENOMEM ; - asus_wmi_chip_info.info = ptr_asus_wmi_ci; - chip_info = &asus_wmi_chip_info; + chip_info = &sensor_data->chip_info; + chip_info->ops = &asus_wmi_hwmon_ops; + chip_info->info = ptr_asus_wmi_ci; sensor_data->wmi.info_by_id = devm_kcalloc(dev, sensor_data->wmi.sensor_count, sizeof(*sensor_data->wmi.info_by_id),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/3318 hwmon: (hp-wmi-sensors) Avoid global struct mutation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit dc992efeace99e479aec7a8f0c49a9493c729606 ]
In the HP WMI sensors driver, make_chip_info() assigns a device-managed memory allocation to a static global structure, resulting in a use-after-free when the device unbinds.
During hp_wmi_sensors_probe(), make_chip_info() dynamically allocates a hwmon_channel_info array using devm_kcalloc() and assigns it to the static global hp_wmi_chip_info.info pointer.
If multiple instances probe sequentially or concurrently, the shared global pointer is overwritten by each new device. When any device unbinds, its devm-managed memory is automatically freed, leaving the global hp_wmi_chip_info struct and any other active device instances with a dangling pointer. Subsequent accesses by the hwmon core (such as thermal zone reads) will dereference this freed memory, causing a use-after-free.
While this is not supposed to happen in the real world (there should only be one instance of the driver in any system), modifying global structures is undesirable and should be avoided whenever possible. Allocate struct hwmon_chip_info as part of struct hp_wmi_sensors instead and initialize it in make_chip_info() to avoid mutating the global structure.
--- drivers/hwmon/hp-wmi-sensors.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/hwmon/hp-wmi-sensors.c +4 -7
@@ -390,6 +390,7 @@ struct hp_wmi_info {*/ struct hp_wmi_sensors {struct wmi_device *wdev; +struct hwmon_chip_info chip_info;struct hp_wmi_info **info_map[hwmon_max];u8 channel_count[hwmon_max];bool has_intrusion;
@@ -1517,11 +1518,6 @@ static const struct hwmon_ops hp_wmi_hwmon_ops = { .write = hp_wmi_hwmon_write, }; -static struct hwmon_chip_info hp_wmi_chip_info = { - .ops = &hp_wmi_hwmon_ops, - .info =NULL , -}; -static struct hp_wmi_info *match_fan_event (struct hp_wmi_sensors *state,const char *event_description) {
@@ -1958,7 +1954,8 @@ static int make_chip_info(struct hp_wmi_sensors *state, bool has_events)if (!ptr_channel_info)return -ENOMEM ; - hp_wmi_chip_info.info = ptr_channel_info; + state->chip_info.ops = &hp_wmi_hwmon_ops; + state->chip_info.info = ptr_channel_info;for (type = hwmon_chip; type < hwmon_max; type++) { count = channel_count[type];
@@ -2049,7 +2046,7 @@ static int hp_wmi_sensors_init(struct hp_wmi_sensors *state)return err; hwdev =devm_hwmon_device_register_with_info (dev,"hp_wmi_sensors" , - state, &hp_wmi_chip_info, + state, &state->chip_info,NULL );return PTR_ERR_OR_ZERO (hwdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/3318 hwmon: (hp-wmi-sensors) Fix unbounded loops in scale_numeric_sensor()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 185039b1c0389b70ec52a6d3e3c1494e2d0e23da ]
In scale_numeric_sensor() in the hp-wmi-sensors hwmon driver, an unbounded loop occurs if the ACPI WMI implementation provides a highly anomalous or malformed UnitModifier value for a numeric sensor.
The UnitModifier property is extracted from a WMI ACPI object without bounds checking and cast to a signed 32-bit integer. This value directly controls the iteration count of two scaling loops. If the provided unit_modifier is extremely negative (e.g., INT_MIN), the first loop executes billions of times before reaching target_modifier. Conversely, if unit_modifier is extremely large (e.g., INT_MAX) and the current sensor reading (val) is exactly 0, the second loop's overflow safeguard (val > LONG_MAX / 10) never evaluates to true, resulting in billions of unnecessary iterations. This prolonged execution causes severe CPU stalls and thread soft lockups during driver initialization or whenever a user-space process reads the sensor attribute via sysfs, resulting in a denial of service on the affected CPU core.
Fix the problem in the first loop by exiting it as soon as val is zero. Fix the problem with the second loop by only entering it if val is not zero. Also add a check for val < LONG_MIN / 10 and exit the loop if that is the case.
--- drivers/hwmon/hp-wmi-sensors.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwmon/hp-wmi-sensors.c +12 -6
@@ -725,15 +725,21 @@ static long scale_numeric_sensor(const struct hp_wmi_numeric_sensor *nsensor) val = current_reading; -for (; unit_modifier < target_modifier; unit_modifier++) +for (; val && unit_modifier < target_modifier; unit_modifier++) val =DIV_ROUND_CLOSEST (val,10 ); -for (; unit_modifier > target_modifier; unit_modifier--) { -if (val >LONG_MAX /10 ) { - val =LONG_MAX ; -break ; +if (val) { +for (; unit_modifier > target_modifier; unit_modifier--) { +if (val >LONG_MAX /10 ) { + val =LONG_MAX ; +break ; + } +if (val <LONG_MIN /10 ) { + val =LONG_MIN ; +break ; + } + val *=10 ; } - val *=10 ; }if (sensor_type ==HP_WMI_TYPE_TEMPERATURE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1460/3318 hwmon: (lm87) Fix drvdata type confusion in vrm_show() and vrm_store()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 5b51ff0887b9f88d042b92dd07fcdda4132f0ebc ]
When an LM87 or ADM1024 device is probed with VID support enabled, reading from or writing to the vrm sysfs attribute triggers a driver data type confusion in vrm_show() and vrm_store() in drivers/hwmon/lm87.c.
In lm87_probe(), the driver stores the struct lm87_data pointer on the I2C client via i2c_set_clientdata() and passes the struct i2c_client pointer as the drvdata argument to devm_hwmon_device_register_with_groups(), which attaches the attribute groups to the registered hwmon device with client as its driver_data. Unlike the other sysfs callbacks that retrieve client via dev_get_drvdata() and then obtain data via i2c_get_clientdata(), vrm_show() and vrm_store() assign dev_get_drvdata(dev) directly to struct lm87_data *. Dereferencing data->vrm therefore accesses the struct i2c_client instance at offsetof(struct lm87_data, vrm), causing vrm_show() to leak an unrelated byte from struct i2c_client to userspace and vrm_store() to corrupt a byte within struct i2c_client while failing to update the actual VRM value.
Fix the problem by assigning the return value from dev_get_drvdata(dev) to struct i2c_client *client and using i2c_get_clientdata() to get the actual client data.
--- drivers/hwmon/lm87.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/hwmon/lm87.c +5 -2
@@ -600,13 +600,16 @@ static DEVICE_ATTR_RO(cpu0_vid);static ssize_t vrm_show (struct device *dev,struct device_attribute *attr,char *buf) { -struct lm87_data *data =dev_get_drvdata (dev); +struct i2c_client *client =dev_get_drvdata (dev); +struct lm87_data *data =i2c_get_clientdata (client); +return sprintf (buf,"%d\n" , data->vrm); }static ssize_t vrm_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -struct lm87_data *data =dev_get_drvdata (dev); +struct i2c_client *client =dev_get_drvdata (dev); +struct lm87_data *data =i2c_get_clientdata (client);unsigned long val;int err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1461/3318 hwmon: (nct6683) Fix incorrect struct cast in show_pwm() and store_pwm()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit c4a01c2a80b203ab5f80885f6994346fe217f19c ]
On big-endian architectures, reading or writing the pwm[1-8] sysfs attributes in the nct6683 hardware monitoring driver always redirects to channel 0 due to an incorrect struct downcast in show_pwm() and store_pwm().
The driver defines the PWM sysfs attributes using SENSOR_TEMPLATE(), which initializes them as struct sensor_device_attribute (where the index is a 32-bit int). However, the sysfs callbacks show_pwm() and store_pwm() incorrectly downcast the attribute to a struct sensor_device_attribute_2 (where the index is an 8-bit u8). Because both structs start with struct device_attribute, container_of() resolves to the same base address. On big-endian architectures, reading the 8-bit index field from the memory layout of a 32-bit int fetches the most significant byte (which is 0), rather than the intended channel number.
This type mismatch causes all PWM reads to return data for channel 0, and any writes intended to configure other channels will silently overwrite the duty cycle of PWM channel 0 instead.
Fix the type casts in show_pwm() and store_pwm() to solve the problem.
--- drivers/hwmon/nct6683.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/nct6683.c +2 -2
@@ -912,7 +912,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, char *buf) { struct nct6683_data *data = nct6683_update_device(dev); -struct sensor_device_attribute_2 *sattr =to_sensor_dev_attr_2 (attr); +struct sensor_device_attribute *sattr =to_sensor_dev_attr (attr);int index = sattr->index;return sprintf (buf,"%d\n" , data->pwm[index]);
@@ -922,7 +922,7 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);struct nct6683_data *data =dev_get_drvdata (dev);int index = sattr->index;unsigned long val;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1462/3318 hwmon: (peci/dimmtemp) Fix devres leak and UAF on concurrent unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 61bc4514b8e99e9733c04de028885f6fc906d628 ]
When a peci_dimmtemp device is unbound concurrently with its delayed initialization work (detect_work), newly allocated devm resources and the hwmon device are leaked, leading to a use-after-free when reading the lingering hwmon sysfs attributes.
In peci_dimmtemp_probe(), detect_work is registered for cancellation via devm_delayed_work_autocancel(). During driver detach, devres_release_all() first moves all existing entries from dev->devres_head onto a local todo list before invoking their release callbacks in reverse order. If create_dimm_temp_info_delayed() is already running when devm_delayed_work_drop() calls cancel_delayed_work_sync(), create_dimm_temp_info() can allocate dimmtemp_label strings via devm_kzalloc()/devm_kasprintf() and register the hwmon device via devm_hwmon_device_register_with_info(), appending new devres entries to the now-empty dev->devres_head. Once the work finishes, devres_release_all() frees priv and priv->name from the local todo list without re-evaluating dev->devres_head, leaving the late devres allocations and registered hwmon device behind with a dangling priv pointer.
Cancel detect_work synchronously in a driver .remove() callback instead of relying on devm_delayed_work_autocancel() so that the work is fully drained before devres_release_all() detaches dev->devres_head, allowing any devm resources registered by the delayed work to be released in proper reverse order. Also only schedule detect_work when check_populated_dimms() returns -EAGAIN so that probe failure paths do not leave delayed work pending.
--- drivers/hwmon/peci/dimmtemp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/hwmon/peci/dimmtemp.c +14 -7
@@ -4,7 +4,6 @@#include <linux/auxiliary_bus.h> #include <linux/bitfield.h> #include <linux/bitops.h> -#include <linux/devm-helpers.h> #include <linux/hwmon.h> #include <linux/jiffies.h> #include <linux/module.h>
@@ -331,11 +330,13 @@ static int create_dimm_temp_info(struct peci_dimmtemp *priv)if (ret == -ENODEV ) {dev_dbg (priv->dev,"No DIMMs found\n" );return 0 ; - }else if (ret) { + } +if (ret == -EAGAIN ) {schedule_delayed_work (&priv->detect_work,DIMM_MASK_CHECK_DELAY_JIFFIES );dev_dbg (priv->dev,"Deferred populating DIMM temp info\n" ); -return ret; } +if (ret) +return ret; channels = priv->gen_info->chan_rank_max * priv->gen_info->dimm_idx_max;
@@ -405,10 +406,8 @@ static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxil"Unexpected PECI revision %#x, some features may be unavailable\n" , peci_dev->info.peci_revision); - ret =devm_delayed_work_autocancel (priv->dev, &priv->detect_work, - create_dimm_temp_info_delayed); -if (ret) -return ret; +auxiliary_set_drvdata (adev, priv); +INIT_DELAYED_WORK (&priv->detect_work, create_dimm_temp_info_delayed); ret =create_dimm_temp_info (priv);if (ret && ret != -EAGAIN ) {
@@ -419,6 +418,13 @@ static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxilreturn 0 ; } +static void peci_dimmtemp_remove (struct auxiliary_device *adev) +{ +struct peci_dimmtemp *priv =auxiliary_get_drvdata (adev); + +cancel_delayed_work_sync (&priv->detect_work); +} +static int read_thresholds_hsx (struct peci_dimmtemp *priv,int dimm_order,int chan_rank,u32 *data) {
@@ -655,6 +661,7 @@ MODULE_DEVICE_TABLE(auxiliary, peci_dimmtemp_ids);static struct auxiliary_driver peci_dimmtemp_driver = { .probe = peci_dimmtemp_probe, + .remove = peci_dimmtemp_remove, .id_table = peci_dimmtemp_ids, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1463/3318 hwmon: (pmbus/q54sj108a2) Add missing NULL pointer check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit a5802c587da97a4ff85c04aad6043fa26640fc9b ]
When CONFIG_DEBUG_FS is enabled and per-client PMBus debugfs directory creation fails during pmbus_do_probe(), q54sj108a2_probe() passes the NULL pointer returned by pmbus_get_debugfs_dir() to debugfs_create_dir() without validation, creating its debugfs directory at the debugfs root instead of under the client directory.
If pmbus_init_debugfs() fails to create the client directory, data->debugfs is left as NULL or an ERR_PTR, which pmbus_get_debugfs_dir() converts to NULL. Passing a NULL parent to debugfs_create_dir() places q54sj108a2_dir in the root of the debugfs filesystem and populates it with attribute files whose private data pointers reference psu->debugfs_entries. Because this root-level directory is outside the client debugfs hierarchy, PMBus core cleanup does not remove it on device unbind, leaking the debugfs entries and causing a use-after-free of the devm-allocated struct q54sj108a2_data if the orphaned files are accessed via q54sj108a2_debugfs_read() or q54sj108a2_debugfs_write() after device removal.
Fix the problem by adding the missing NULL pointer check.
--- drivers/hwmon/pmbus/q54sj108a2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/pmbus/q54sj108a2.c +2 -0
@@ -343,6 +343,8 @@ static int q54sj108a2_probe(struct i2c_client *client) psu->client = client; debugfs =pmbus_get_debugfs_dir (client); +if (!debugfs) +return 0 ; q54sj108a2_dir =debugfs_create_dir (client->name, debugfs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1464/3318 hwmon: (pmbus) Release devres allocated memory after devm_thermal_of_zone_register error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 9aa6cc563e881c3cad96ea36926cadceee151f32 ]
In pmbus_thermal_add_sensor(), a devres memory leak occurs when a PMBus temperature sensor is initialized but no thermal zone is configured for it.
The function allocates a pmbus_thermal_data structure using devm_kzalloc(). It then attempts to register the sensor with the thermal subsystem via devm_thermal_of_zone_register(). If this registration returns -ENODEV (e.g., when no thermal zone is mapped in the Device Tree or CONFIG_THERMAL_OF is disabled), the function intentionally catches the error and returns 0 to allow device probing to continue.
Because devm_kfree() is not called on the -ENODEV path, the unused tdata structure remains allocated on the device's managed resource list. Since most PMBus temperature sensors are not attached to thermal zones, this results in an accumulation of unused objects that needlessly consume kernel memory for the lifetime of the PMBus device.
Add the missing call to devm_kfree() to fix the problem.
--- drivers/hwmon/pmbus/pmbus_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus_core.c +3 -1
@@ -1355,8 +1355,10 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data,* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, * so ignore that error but forward any other error. */ -if (IS_ERR (tzd) && (PTR_ERR (tzd) != -ENODEV )) +if (IS_ERR (tzd) && (PTR_ERR (tzd) != -ENODEV )) { +devm_kfree (dev, tdata);return PTR_ERR (tzd); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1465/3318 hwmon: (pmbus) Fix return value check from thermal zone registration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 4fc79634af8cdf734e0a633923ba4817e30d29ad ]
The PMBus core used to call devm_thermal_zone_of_sensor_register() to register thermal zones. Commit 613ed3f676092 ("hwmon: pm_bus: core:
Switch to new of thermal API") changed this to call devm_thermal_of_zone_register() instead. The code subsequently checks if the call failed because the thermal subsystem is not configured. devm_thermal_zone_of_sensor_register() used to return -ENODEV in this case. devm_thermal_of_zone_register() returns -ENOTSUPP. The code currently still checks for -ENOVEV. This results in driver instantiation failures if the thermal subsystem is disabled.
Check for -ENOTSUPP to fix the problem. Keep checking for -ENODEV because this indicates that no thermal zone is configured for the sensor, which is acceptable for the driver and must not cause a registration failure.
--- drivers/hwmon/pmbus/pmbus_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +4 -3
@@ -1352,10 +1352,11 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data, tzd =devm_thermal_of_zone_register (dev, index, tdata, &pmbus_thermal_ops);/* -* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, -* so ignore that error but forward any other error. +* If CONFIG_THERMAL_OF is disabled, devm_thermal_of_zone_register() +* returns -ENOTSUPP. If no thermal zone is configured for the sensor, +* it returns -ENODEV. Ignore those errors but forward any other error. */ -if (IS_ERR (tzd) && (PTR_ERR (tzd) != -ENODEV )) { +if (IS_ERR (tzd) &&PTR_ERR (tzd) != -ENODEV &&PTR_ERR (tzd) != -ENOTSUPP ) {devm_kfree (dev, tdata);return PTR_ERR (tzd); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1466/3318 hwmon: (coretemp) Check for NULL platform device in hotplug callbacks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 0f9c7ed3b5009a037e5533eac03a0d4d45ecf1f0 ]
coretemp_get_pdev() returns NULL when topology_logical_die_id(cpu) is negative (such as -ENODEV or -ERANGE from topology_get_logical_id() on a firmware/hardware APIC ID mismatch) or exceeds max_zones (for example, under asymmetric or anomalous ACPI die topologies where topology_max_packages() * topology_max_dies_per_package() is smaller than the logical die count).
Commit 6d03bbff456b ("hwmon: (coretemp) Simplify platform device handling") pre-allocated zone_devices[0 .. max_zones - 1] during module init and dropped the NULL checks on pdev in coretemp_cpu_online() and coretemp_cpu_offline(), passing pdev unconditionally to platform_get_drvdata(). When coretemp_get_pdev() returns NULL, platform_get_drvdata(pdev) dereferences &pdev->dev and triggers a kernel NULL pointer dereference.
Check for a NULL pdev and return 0 in both coretemp_cpu_online() and coretemp_cpu_offline() before calling platform_get_drvdata(). Returning 0 in coretemp_cpu_online() ignores the unmapped CPU without blocking CPU bringup or tearing down valid thermal zones on other dies.
--- drivers/hwmon/coretemp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hwmon/coretemp.c +6 -0
@@ -664,6 +664,9 @@ static int coretemp_cpu_online(unsigned int cpu)if (!housekeeping_cpu (cpu,HK_TYPE_MISC ))return 0 ; +if (!pdev) +return 0 ; + pdata =platform_get_drvdata (pdev);if (!pdata->hwmon_dev) {struct device *hwmon;
@@ -715,6 +718,9 @@ static int coretemp_cpu_offline(unsigned int cpu)return 0 ;/* If the physical CPU device does not exist, just return */ +if (!pdev) +return 0 ; + pd =platform_get_drvdata (pdev);if (!pd->hwmon_dev)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1467/3318 hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vas Zayarskiy <[email protected]>
[ Upstream commit c221091f7e30c64280e4cbfa27dc4c05edc96d0c ]
High Flow Next power is reported in watts. Multiplying the 16-bit value by one million can overflow both the signed intermediate and the u32 cache. Store power in long, perform the conversion in u64, and clamp to LONG_MAX. The other existing power conversions fit in a signed 32-bit value. Return -ENODATA for unavailable power instead of exposing the stored error as a reading.
The power cache is updated by HID reports without the hwmon read mutex. Read it once with READ_ONCE() and use that snapshot for both the availability check and the returned value. Mark the corresponding updates with WRITE_ONCE() so that the shared accesses are explicit.
Widen the shared current cache to u32. The Aquastream XT conversion to milliamperes can exceed 65535 mA; clamp its negative conversion results to zero before assigning to the unsigned cache. This also permits devices with scaled aggregate currents to store milliamperes directly.
--- drivers/hwmon/aquacomputer_d5next.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
drivers/hwmon/aquacomputer_d5next.c +18 -11
@@ -18,6 +18,7 @@#include <linux/hwmon.h> #include <linux/jiffies.h> #include <linux/ktime.h> +#include <linux/limits.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/seq_file.h>
@@ -571,9 +572,9 @@ struct aqc_data {u32 speed_input_min[1 ];u32 speed_input_target[1 ];u32 speed_input_max[1 ]; -u32 power_input[8 ]; +long power_input[8 ];u16 voltage_input[8 ]; -u16 current_input[8 ]; +u32 current_input[8 ];/* Label values */ const char *const *temp_label;
@@ -954,7 +955,7 @@ static int aqc_legacy_read(struct aqc_data *priv)/* Calculation derived from linear regression */ sensor_value =get_unaligned_le16 (priv->buffer +AQUASTREAMXT_PUMP_CURR_OFFSET ); - priv->current_input[0 ] =DIV_ROUND_CLOSEST (sensor_value *176 ,100 ) -52 ; + priv->current_input[0 ] =max (DIV_ROUND_CLOSEST (sensor_value *176 ,100 ) -52 ,0 ); sensor_value =get_unaligned_le16 (priv->buffer +AQUASTREAMXT_PUMP_VOLTAGE_OFFSET ); priv->voltage_input[0 ] =DIV_ROUND_CLOSEST (sensor_value *1000 ,61 );
@@ -976,6 +977,7 @@ static int aqc_legacy_read(struct aqc_data *priv)static int aqc_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long *val) { +long power;int ret;struct aqc_data *priv =dev_get_drvdata (dev);
@@ -1040,7 +1042,10 @@ static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, }break ;case hwmon_power: - *val = priv->power_input[channel]; + power =READ_ONCE (priv->power_input[channel]); +if (power == -ENODATA ) +return -ENODATA ; + *val = power;break ;case hwmon_pwm:switch (priv->kind) {
@@ -1337,9 +1342,9 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 priv->speed_input[i] =get_unaligned_be16 (data + priv->fan_sensor_offsets[i] + priv->fan_structure->speed); - priv->power_input[i] = -get_unaligned_be16 (data + priv->fan_sensor_offsets[i] + - priv->fan_structure->power) *10000 ; +WRITE_ONCE (priv->power_input[i], +get_unaligned_be16 (data + priv->fan_sensor_offsets[i] + + priv->fan_structure->power) *10000 ); priv->voltage_input[i] =get_unaligned_be16 (data + priv->fan_sensor_offsets[i] + priv->fan_structure->voltage) *10 ;
@@ -1379,7 +1384,8 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 priv->speed_input[2 ] =get_unaligned_be16 (data +AQUASTREAMULT_PRESSURE_OFFSET ); priv->speed_input[3 ] =get_unaligned_be16 (data +AQUASTREAMULT_FLOW_SENSOR_OFFSET ); - priv->power_input[1 ] =get_unaligned_be16 (data +AQUASTREAMULT_PUMP_POWER ) *10000 ; +WRITE_ONCE (priv->power_input[1 ], +get_unaligned_be16 (data +AQUASTREAMULT_PUMP_POWER ) *10000 ); priv->voltage_input[1 ] =get_unaligned_be16 (data +AQUASTREAMULT_PUMP_VOLTAGE ) *10 ;
@@ -1392,10 +1398,11 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8case highflownext:/* If external temp sensor is not connected, its power reading is also N/A */ if (priv->temp_input[1 ] == -ENODATA ) - priv->power_input[0 ] = -ENODATA ; +WRITE_ONCE (priv->power_input[0 ], -ENODATA );else - priv->power_input[0 ] = -get_unaligned_be16 (data +HIGHFLOWNEXT_POWER ) *1000000 ; +WRITE_ONCE (priv->power_input[0 ], +min_t (u64,get_unaligned_be16 (data +HIGHFLOWNEXT_POWER ) * +1000000ULL ,LONG_MAX )); priv->voltage_input[0 ] =get_unaligned_be16 (data +HIGHFLOWNEXT_5V_VOLTAGE ) *10 ; priv->voltage_input[1] =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1468/3318 KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit b2691b3a6cd230209736c89684dab90d939aa56b ]
Conditionally reschedule when retrying a guest PTE walk because the CMPXCHG to update A/D bits failed, e.g. because a different task/vCPU modified the relevant gPTEs. On kernels without involuntary preemption of some kind, a misbehaving guest can "capture" a pCPU effectively indefinitely and trigger soft lockups by continuously modifying its gPTEs such that the result of the walk is remains valid.
Message-ID: <[email protected]>
--- arch/x86/kvm/mmu/paging_tmpl.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/paging_tmpl.h +10 -1
@@ -321,6 +321,13 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,gpa_t real_gpa;gfn_t gfn; +/* +* KVM might sleep/resched when retrying the walk if the updating A/D +* fails because the gPTE changed between reading the gPTE and trying +* the CMPXHG to set A/D bits. +*/ +might_sleep (); +trace_kvm_mmu_pagetable_walk (addr, access); retry_walk: walker->level = mmu->cpu_role.base.level;
@@ -468,8 +475,10 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, addr, write_fault);if (unlikely (ret <0 )) goto error; -else if (ret) +else if (ret) { +cond_resched (); goto retry_walk; + } }return 1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/3318 KVM: x86: Conditionally resched when restarting REP string emulation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit ae85ac25eb671d174811cc3101549448671fd505 ]
When restarting emulation, e.g. of a REP-prefixed string instruction, conditionally reschedule as emulating guest writes can be deceptively slow and expensive, e.g. when shadow paging is in use and each write can trigger write tracking.
In a perfect world, restarting emulation (or not) would be less arbitrary, e.g. would honor not only host events (NEED_RESCHED, signals, etc.) but also guest events (e.g. by checking kvm_vcpu_has_events()). Unfortunately, as pointed out by Sashiko, pio_in_emulated()'s read-ahead logic is baked into the restart logic, as KVM relies on restarting emulation to drain the cache and avoid duplicate reads from the I/O port. I.e. re-entering the guest on kvm_vcpu_has_events() or __xfer_to_guest_mode_work_pending() would introduce architecturally-incorrect, guest-visible changes.
Message-ID: <[email protected]>
--- arch/x86/kvm/x86.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +4 -2
@@ -9130,10 +9130,12 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, }else if (vcpu->arch.complete_userspace_io) { writeback = false; r =0 ; - }else if (r ==EMULATION_RESTART ) + }else if (r ==EMULATION_RESTART ) { +cond_resched (); goto restart; -else + }else { r =1 ; + } writeback:if (writeback) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/3318 KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit c33ef9d334059f7cb167569ed7b4779752fe4425 ]
Add a missing "break" in the inner for-loop of the open coded mess that unwinds MSRs back to the pre-VM-Enter state when VMLAUNCH/VMRESUME VM-Fails due to a consistency check that is caught by hardware but missed by KVM. I.e. move on to the next MSR in the VM-Entry load list after performing a write using a value found in the VM-Exit load list. Processing *every* matching entry in the VM-Exit load list makes the processing quadratic, which is problematic if the load lists are full of MSRs that are expensive to emulate. E.g. writing APIC_BASE triggers kvm_recalculate_apic_map() and a whole pile of unnecessary work.
Functionally, arbitrarily restoring the value of the first matching entry is "fine", because none of this is architecturally correct: the load lists are never supposed to have been used in the first place. In practice, it's likely a moot point as no well-behaved VMM will have multiple, diverging entries in the load lists.
Message-ID: <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/vmx/nested.c +1 -0
@@ -4841,6 +4841,7 @@ static void nested_vmx_restore_host_state(struct kvm_vcpu *vcpu) __func__, j, h.index, h.value); goto vmabort; } +break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/3318 KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit)
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit e4558c3d7198ed9a0adc3304681f561f4e4d80e1 ]
When potentially reusing a shadow page, zap the shadow page if its number of parent PTEs exceeds KVM's (mostly) arbitrary rmap recycling threshold. Letting the guest create a (mostly) unbounded number of parent PTEs allows the guest to coerce KVM into creating lists containing millions of PTEs, effectively bounded only by the maximum number of shadow pages.
Because PTE lists are simple singly linked lists, removal is O(n). Even worse, if a list is constructed just so, teardown can be O(n^2), e.g. if SPTEs are built such that zapping child SPTEs always zaps the last entry in the list. To cap things off, all paths that walk PTE lists do so while holding mmu_lock, without conditionally rescheduling.
Using a doubly linked list would not address the issue, as removal would remain O(n) since KVM still wouldn't know where in the list to remove from. Removal could be made O(1) by storing a per-SPTE pointer, but that would largely defeat the purpose of reusing SPs, and would penalize well-behaved guests, especially for nested TDP where aliasing page tables is uncommon.
So, cap the maximum number of parent PTEs at the rmap limit. In practice, well-behaved guests will likely never run afoul of the limit. E.g. when running Linux as L1 with TDP, the number of parent PTEs for a single SP tops out at under 200 (though undoubtedly obscure workloads can push it higher). Deliberately use a "greater than or equal" as opposed to rmap's strictly "greater than", as the rmap code checks the threshold immediately *after* inserting into the list, i.e. the limit is 1000 for rmaps, KVM just very briefly blows past it.
Apply the check to both indirect and direct SPs, because while a fully direct MMU naturally limits the number of parent PTEs to '1', direct SPs in indirect MMUs have no such constraint. E.g. if the guest maps a huge PTE into many locations in its page tables, and KVM is backing the hugepage with a direct SP, i.e. with a series of smaller pages, then KVM could end up with a direct SP with many parents.
Note, shadow_mmu_try_split_huge_pages() always restarts the rmap walk or bails entirely if it gets to the point where it tries to grab a SP, i.e. there is *no* pre-existing bug that would be tripped by zapping a SP and thus rmaps when getting a SP.
Message-ID: <[email protected]>
--- arch/x86/kvm/mmu/mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/kvm/mmu/mmu.c +10 -0
@@ -2164,6 +2164,16 @@ static struct kvm_mmu_page *kvm_mmu_find_shadow_page(struct kvm *kvm,continue ; } +/* +* Note! Unlike fully direct MMUs, direct SPs in indirect MMUs +* can have an arbitrary number of parents, e.g if the guest is +* mapping a huge PTE at many points in its page tables. +*/ +if (pte_list_count (&sp->parent_ptes) >=RMAP_RECYCLE_THRESHOLD ) { +kvm_mmu_prepare_zap_page (kvm, sp, &invalid_list); +break ; + } +/* unsync and write-flooding only apply to indirect SPs. */ if (sp->role.direct) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1472/3318 KVM: x86: Unconditionally reset MMU context when emulating INIT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit c7c288d178cb0b78d3464a616b16b1aa0b316049 ]
Force an MMU reset when emulating an INIT even if paging was already disabled, as the MMU page role includes guest_mode (L2), i.e. an INIT while L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU context.
Alternatively, the reset could be scoped strictly to paging being enabled or L2 being active, but SMM is also encoded in the page role. Even though it _should_ be impossible for the vCPU to be INIT'd while SMM is active, there's zero value in not handling SMM. At that point, the only scenario where KVM _doesn't_ need to reset the MMU context is on an INIT with the vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those modes is somewhat common, it's far from a hot path and re-initializing the MMU is not expensive, especially when the role isn't changing (KVM elides most of the re-configuration in that case).
Note, like the Fixes commit, this bug only affects nested SVM as INIT is an unconditional intercept on VMX, i.e. it's impossible to emulate INIT while L2 is active.
Temporarily keep the guest TLB flush when CR0.PG is being cleared even though it is fully redundant with the flush that is emitted on all INIT events (KVM itself only does RESET when a vCPU is being created, i.e. when CR0.PG must be '0').
Message-ID: <[email protected]>
--- arch/x86/kvm/x86.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
arch/x86/kvm/x86.c +15 -10
@@ -12327,18 +12327,23 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)static_call (kvm_x86_set_efer)(vcpu,0 );static_call (kvm_x86_update_exception_bitmap)(vcpu); +if (old_cr0 &X86_CR0_PG ) +kvm_make_request (KVM_REQ_TLB_FLUSH_GUEST , vcpu); +/* -* On the standard CR0/CR4/EFER modification paths, there are several -* complex conditions determining whether the MMU has to be reset and/or -* which PCIDs have to be flushed. However, CR0.WP and the paging-related -* bits in CR4 and EFER are irrelevant if CR0.PG was '0'; and a reset+flush -* is needed anyway if CR0.PG was '1' (which can only happen for INIT, as -* CR0 will be '0' prior to RESET). So we only need to check CR0.PG here. +* Unconditionally reset the MMU, even though super strictly speaking, +* a MMU reset is only necessary if and only one of the page role bits +* is changing. All of the CR0/CR4/EFER bits effectively get covered +* by checking CR0.PG=1, as CR0.WP and the paging-related bits in CR4 +* and EFER are irrelevant if CR0.PG was '0'. Subtly, if the vCPU was +* in guest mode (L2) or SMM (although emulating INIT in SMM _should_ +* be impossible), an MMU reset is also necessary as "guest mode" and +* "smm" are both encoded in the shadow page role. As a result, the +* only scenarios where an MMU reset is *not* needed is if the vCPU is +* in Real Mode or Unpaged Protected Mode, and micro-optimizing those +* paths are not worth the risk of running with a stale MMU context. */ -if (old_cr0 &X86_CR0_PG ) { -kvm_make_request (KVM_REQ_TLB_FLUSH_GUEST , vcpu); -kvm_mmu_reset_context (vcpu); - } +kvm_mmu_reset_context (vcpu);/* * Intel's SDM states that all TLB entries are flushed on INIT. AMD's
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1473/3318 Bluetooth: hci_sync: re-enable legacy advertising on resume
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Valentin Kindschi <[email protected]>
[ Upstream commit 737139f4157d302292a6b937d96922879ecabfa3 ]
hci_resume_advertising_sync() never re-enables advertising on a controller without extended advertising.
It restores HCI_ADVERTISING from advertising_old_state, then calls hci_schedule_adv_instance_sync(), which starts with:
if (hci_dev_test_flag(hdev, HCI_ADVERTISING) && !ext_adv_capable(hdev))
return -EPERM;The flag it tests was set a few lines earlier by the resume itself, so the call returns -EPERM without sending anything. The return value is discarded by every caller, so the failure is silent: advertising_paused is cleared, HCI_ADVERTISING is set, and the controller is not advertising.
Observed on a BCM43455 (no extended advertising) after an active scan:
btmon shows the pause disabling advertising and no re-enable in the ten seconds that follow, the device does not appear in another controller's scan, and btmgmt info still reports "advertising" in current settings.
Enable instance 0x00 directly in that case, the way reenable_adv_sync() already does for the same situation. Instances continue to go through hci_schedule_adv_instance_sync() so the software rotation loop is rearmed.
This affects every caller of hci_resume_advertising_sync(), not only the scan path: address resolution changes, accept list updates, discovery stop, suspend/resume and the end of an LE connection attempt all leave advertising disabled on such a controller today.
The resume does nothing when the controller is already advertising, as it is after directed advertising was started for a peripheral connection, so it does not replace that advertising.
err is initialised because the extended branch leaves it unset when adv_instances is empty and HCI_LE_ADV_0 is clear.
--- net/bluetooth/hci_sync.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/hci_sync.c +8 -2
@@ -2755,7 +2755,7 @@ static int hci_pause_advertising_sync(struct hci_dev *hdev)static int hci_resume_advertising_sync (struct hci_dev *hdev) {struct adv_info *adv, *tmp; -int err; +int err =0 ;/* If advertising has not been paused there is nothing to do. */ if (!hdev->advertising_paused)
@@ -2788,13 +2788,19 @@ static int hci_resume_advertising_sync(struct hci_dev *hdev)*/ if (hci_dev_test_and_clear_flag (hdev,HCI_LE_ADV_0 )) err =hci_enable_ext_advertising_sync (hdev,0x00 ); - }else { + }else if (hdev->cur_adv_instance) {/* Schedule for most recent instance to be restarted and begin * the software rotation loop */ err =hci_schedule_adv_instance_sync (hdev, hdev->cur_adv_instance, true); + }else if (hci_dev_test_flag (hdev,HCI_ADVERTISING ) && + !hci_dev_test_flag (hdev,HCI_LE_ADV )) { +/* hci_schedule_adv_instance_sync() rejects instance 0x00 while +* HCI_ADVERTISING is set, so enable it directly. +*/ + err =hci_start_adv_sync (hdev,0x00 ); } hdev->advertising_paused = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1474/3318 ASoC: qcom: q6apm: Guard callbacks until probe data is ready
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohit Sharma <[email protected]>
[ Upstream commit ef7062864c0511bba52775d0eb3aa72d886b5f3a ]
The GPR bus needs to make response callbacks available before invoking a client probe because clients can issue synchronous commands from probe. This creates a short interval where a callback can run before the client has published its private data.
Make q6apm publish its driver data only after all callback-visible state has been initialized. Have the q6apm and q6prm callbacks ignore packets received before driver data is available.
--- sound/soc/qcom/qdsp6/q6apm.c | 6 ++++-- sound/soc/qcom/qdsp6/q6prm.c | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-)
sound/soc/qcom/qdsp6/q6apm.c +4 -2
@@ -762,8 +762,6 @@ static int apm_probe(gpr_device_t *gdev)if (!apm)return -ENOMEM ; -dev_set_drvdata (dev, apm); -mutex_init (&apm->lock); apm->dev = dev; apm->gdev = gdev;
@@ -777,6 +775,7 @@ static int apm_probe(gpr_device_t *gdev)idr_init (&apm->modules_idr); +dev_set_drvdata (dev, apm); g_apm = apm;q6apm_get_apm_state (apm);
@@ -817,6 +816,9 @@ static int apm_callback(struct gpr_resp_pkt *data, void *priv, int op)struct gpr_ibasic_rsp_result_t *result;struct gpr_hdr *hdr = &data->hdr; +if (!apm) +return 0 ; + result = data->payload;switch (hdr->opcode) {
sound/soc/qcom/qdsp6/q6prm.c +3 -0
@@ -197,6 +197,9 @@ static int prm_callback(struct gpr_resp_pkt *data, void *priv, int op)struct gpr_ibasic_rsp_result_t *result;struct gpr_hdr *hdr = &data->hdr; +if (!prm) +return 0 ; +switch (hdr->opcode) {case PRM_CMD_RSP_REQUEST_HW_RSC :case PRM_CMD_RSP_RELEASE_HW_RSC :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1475/3318 mm/hugetlb: fix mremap move length truncation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Zhe <[email protected]>
[ Upstream commit dfb190302d2b4af86c6ae48af0d3b09f28b35460 ]
Patch series "mm/hugetlb: fix mremap bugs", v3.
This series fixes a few hugetlb mremap bugs.
Patch 1 fixes the return type of move_hugetlb_page_tables(), so large hugetlb moves cannot be truncated when reported back to the generic mremap code.
Patch 2 disables hugetlb PMD sharing for UFFD missing mode, so UFFDIO_POISON markers cannot become visible through shared PMD page tables.
Patch 3 fixes the recursive i_mmap_rwsem deadlock in the hugetlb mremap path by avoiding the destination PMD sharing allocation path while the mapping lock is already held for write.
This patch (of 3):
move_hugetlb_page_tables() returns the number of bytes moved, but its return type is int while the generic move_page_tables() path uses unsigned long lengths.
A hugetlb mremap() move length above INT_MAX can therefore be misreported to copy_vma_and_data(). The out-of-range conversion to int is implementation-defined; on common 64-bit builds, for example, a 4 GiB move can be reported as zero, making the caller treat the move as a failure and use the wrong length for rollback.
Return unsigned long from move_hugetlb_page_tables(), matching move_page_tables() and preserving the full byte count.
--- include/linux/hugetlb.h | 15 ++++++--------- mm/hugetlb.c | 7 +++---- 2 files changed, 9 insertions(+), 13 deletions(-)
include/linux/hugetlb.h +6 -9
@@ -127,10 +127,9 @@ void hugepage_put_subpool(struct hugepage_subpool *spool);void hugetlb_dup_vma_private (struct vm_area_struct *vma);void clear_vma_resv_huge_pages (struct vm_area_struct *vma); -int move_hugetlb_page_tables (struct vm_area_struct *vma, -struct vm_area_struct *new_vma, -unsigned long old_addr,unsigned long new_addr, -unsigned long len); +unsigned long move_hugetlb_page_tables (struct vm_area_struct *vma, +struct vm_area_struct *new_vma,unsigned long old_addr, +unsigned long new_addr,unsigned long len);int copy_hugetlb_page_range (struct mm_struct *,struct mm_struct *,struct vm_area_struct *,struct vm_area_struct *); struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma,
@@ -348,11 +347,9 @@ static inline int copy_hugetlb_page_range(struct mm_struct *dst,return 0 ; } -static inline int move_hugetlb_page_tables (struct vm_area_struct *vma, -struct vm_area_struct *new_vma, -unsigned long old_addr, -unsigned long new_addr, -unsigned long len) +static inline unsigned long move_hugetlb_page_tables (struct vm_area_struct *vma, +struct vm_area_struct *new_vma,unsigned long old_addr, +unsigned long new_addr,unsigned long len) {BUG ();return 0 ;
mm/hugetlb.c +3 -4
@@ -5271,10 +5271,9 @@ static void move_huge_pte(struct vm_area_struct *vma, unsigned long old_addr,spin_unlock (dst_ptl); } -int move_hugetlb_page_tables (struct vm_area_struct *vma, -struct vm_area_struct *new_vma, -unsigned long old_addr,unsigned long new_addr, -unsigned long len) +unsigned long move_hugetlb_page_tables (struct vm_area_struct *vma, +struct vm_area_struct *new_vma,unsigned long old_addr, +unsigned long new_addr,unsigned long len) {struct hstate *h =hstate_vma (vma);struct address_space *mapping = vma->vm_file->f_mapping;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1476/3318 mm/ksm: keep soft-dirty when merging a page
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samarth Narang <[email protected]>
[ Upstream commit 2efc6332f18bfd848f74f3d5ba45b31450601faa ]
replace_page() maps the KSM page with a PTE built from scratch, so the soft-dirty bit of the PTE it replaces is lost. A page written since "clear_refs 4" then no longer shows as soft-dirty once it is merged, and a soft-dirty based dumper treats it as unchanged.
Copy the soft-dirty bit from the original PTE to the new PTE.
--- mm/ksm.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/ksm.c +4 -0
@@ -1252,6 +1252,10 @@ static int replace_page(struct vm_area_struct *vma, struct page *page,dec_mm_counter (mm,MM_ANONPAGES ); } +/* Preserve soft-dirty when replacing the page. */ +if (pte_soft_dirty (orig_pte)) + newpte =pte_mksoft_dirty (newpte); +flush_cache_page (vma, addr,pte_pfn (ptep_get (ptep)));/* * No need to notify as we are replacing a read only page with another
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/3318 mm: make swapoff interruptible when unusing mms/shmem
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Down <[email protected]>
[ Upstream commit 740128dd1a3f2bd81a80314d079b6b03c39ba3af ]
try_to_unuse() only checks for a pending signal between mms, and shmem_unuse() doesn't check at all. That means that once swapoff gets to a process or a shmem file with a lot swapped out, nothing can interrupt it until every last page of it has been read back in.
Just as one example of where this can concretely show up, freezing tasks for suspend or hibernation has to wait for swapoff to notice the freezer's fake signal, and gives up after freeze_timeout_msecs (20 seconds by default).
Here's a facetious example where one swaps out 2GiB of one process to a swap file on ext4, starts swapoff, and half a second later tries to freeze with pm_test=freezer. Writing to /sys/power/state then fails with EBUSY and this in dmesg:
Freezing user space processes failed after 20.003 seconds (1 tasks refusing to freeze, wq_busy=0):
task:swapoff state:D stack:0 pid:3175 tgid:3175 ppid:2955 task_flags:0x400100 flags:0x00000419
Call trace:
[...]
io_schedule+0x44/0x70
folio_wait_bit_common+0x1ec/0x3d0
__folio_lock+0x24/0x40
unuse_pte_range+0x2d0/0x348
unuse_vma+0x158/0x248
unuse_mm+0xfc/0x150
try_to_unuse+0x104/0x3f8
__do_sys_swapoff+0x220/0x5d8
[...]The same goes for anything else that wants swapoff to stop, like an admin hitting ^C in a panic, of course.
Prior to commit b56a2d8af914 ("mm: rid swapoff of quadratic complexity") try_to_unuse() was driven by find_next_to_unuse() which checks for a signal before every entry, so let's restore that behaviour.
Just as an example of the improvements, here's how long freezing takes in the same test while swapoff is happening on my computer:
before after
400MiB anon 8.925s 0.028s
400MiB shmem 1.639s 0.003s
2GiB anon failed after 20.003s 0.011s--- mm/shmem.c | 4 ++++ mm/swapfile.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
mm/shmem.c +4 -0
@@ -1405,6 +1405,10 @@ static int shmem_unuse_inode(struct inode *inode, unsigned int type)if (ret <0 )break ; +if (signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; + } start = indices[folio_batch_count (&fbatch) -1 ]; }while (true);
mm/swapfile.c +3 -1
@@ -1926,6 +1926,8 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud, pmd =pmd_offset (pud, addr); do { cond_resched(); + if (signal_pending(current)) + return -ERESTARTSYS; next = pmd_addr_end(addr, end); ret = unuse_pte_range(vma, pmd, addr, next, type); if (ret)
@@ -2136,7 +2138,7 @@ static int try_to_unuse(unsigned int type)if (READ_ONCE (si->inuse_pages)) {if (!signal_pending (current)) goto retry; -return -EINTR ; +return -ERESTARTSYS ; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/3318 mm/migrate: untag addresses when querying page nodes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 7d8746d7dc9cc4003661011424e5880ea7ae364b ]
When move_pages() is used with nodes == NULL, do_pages_stat_array() passes each page address directly to vma_lookup(). A valid tagged address therefore fails the VMA lookup and gets -EFAULT in its status entry, instead of the node reported for the corresponding untagged address.
The tagged address ABI permits these pointers, and the migration path already removes their tags. Apply the target mm's untagging rules to the query path as well, while holding its mmap read lock.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -2291,7 +2291,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,mmap_read_lock (mm);for (i =0 ; i < nr_pages; i++) { -unsigned long addr = (unsigned long )(*pages); +unsigned long addr = (unsigned long )untagged_addr_remote (mm, *pages);struct vm_area_struct *vma;struct page *page;int err = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/3318 mm: memcontrol: fix NULL pointer deref and UAF from high_work_func() on dying memcg
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: T.J. Mercier <[email protected]>
[ Upstream commit dd94d8c7660a60dbfcd425e0d10120de6d02a7bd ]
When memory.high is exceeded in non-task context, try_charge_memcg() schedules memcg->high_work without taking a reference on the memcg, and high_work_func() invokes reclaim_high() without pinning the memcg.
With obj_cgroup reparenting, introduced in commit bf4f059954dc ("mm:
memcg/slab: obj_cgroup API"), objects charged to a child memcg are reparented to its parent in mem_cgroup_css_offline() instead of holding a reference on the child until uncharged. Subsequent uncharges of those objects go to the parent, which can leave the child's memory use permanently above its high limit, so any later charge on the offlined memcg in non-task context schedules high_work. This was later widened from kernel memory to LRU folios when commit f1cf8d2f36dc ("mm:
memcontrol: eliminate the problem of dying memory cgroup for LRU folios") converted LRU folios to use obj_cgroup reparenting.
cancel_work_sync(&memcg->high_work) only runs at the end of teardown in mem_cgroup_css_free(), so high_work_func() can start or still be running reclaim_high() after mem_cgroup_css_released() or shrink_many() has called lru_gen_release_memcg() and unhashed lruvec->lrugen.list. If reclaim tries to rotate the memcg, lru_gen_rotate_memcg() dereferences a NULL pprev pointer. This issue is specific to MGLRU and was introduced with the memcg LRU in commit e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists").
With either traditional LRU or MGLRU, css_free_rwork_fn() calls css_rstat_exit() which frees per-CPU rstat data before calling mem_cgroup_css_free(). If reclaim_high() is still running, rstat updates via mod_lruvec_state() -> __css_rstat_updated() cause a use-after-free on the per-CPU rstat data. This was introduced when commit 5da3bfa029d6 ("cgroup: use separate rstat trees for each subsystem") moved css_rstat_exit() ahead of ss->css_free().
Fix both problems by acquiring a reference with css_tryget_online() in high_work_func() before calling reclaim_high(), and by resetting memory.high and swap.high to PAGE_COUNTER_MAX in mem_cgroup_css_offline() so that charges via references on an offlined memcg do not trigger high_work on the dead child and skip checking live ancestors in try_charge_memcg().
Acquiring the reference in high_work_func() rather than before scheduling high_work is safe because mem_cgroup_css_free() calls irq_work_sync() and cancel_work_sync() which cancels pending work and waits for an already running high_work_func() to complete before mem_cgroup_free() frees the memcg. css_tryget_online() uses percpu_ref_tryget_live() and is safe to call after percpu_ref_exit() before the cgroup is freed unlike css_tryget().
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 UID: 0 PID: 27 Comm: kworker/1:0 Tainted: G B W 7.3.0-rc5-g2bba28e98578 #284 PREEMPT(full) Tainted: [B]=BAD_PAGE, [W]=WARN <-- Taint from lru_gen_rotate_memcg() VM_WARN_ON_ONCE Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 Workqueue: events high_work_func RIP: 0010:lru_gen_rotate_memcg+0x1a3/0xe90 Call Trace: <TASK> ? read_ctrl_pos+0x22f/0x3f0 shrink_lruvec+0x16cb/0x1b80 ? ret_from_fork_asm+0x1a/0x30 ? lapic_next_event+0x15/0x20 ? clockevents_program_event+0x2bb/0x6f0 ? lapic_next_event+0x15/0x20 ? __pfx_shrink_lruvec+0x10/0x10 ? __pfx_clockevents_program_event+0x10/0x10 ? _raw_spin_lock+0x84/0xe0 ? __pfx__raw_spin_lock+0x10/0x10 ? kasan_save_stack+0x30/0x50 ? psi_group_change+0x381/0x740 ? __pfx_sched_clock_cpu+0x10/0x10 ? save_fpregs_to_fpstate+0xc4/0x2c0 ? finish_task_switch.isra.0+0x1de/0xac0 ? __schedule+0xf62/0x42c0 ? __pfx___schedule+0x10/0x10 ? __pfx___irq_work_queue_local+0x10/0x10 ? shrink_node+0x626/0x31e0 shrink_node+0x626/0x31e0 ? ring_buffer_unlock_commit+0x11d/0x5c0 ? kswapd_clear_hopeless+0xa0/0x150 ? __pfx_shrink_node+0x10/0x10 ? 0xffffffffc0000095 do_try_to_free_pages+0x255/0x13b0 ? ring_buffer_unlock_commit+0x11d/0x5c0 ? reclaim_high+0x10a/0x1b0 try_to_free_mem_cgroup_pages+0x1f9/0x5a0 ? __pfx_try_to_free_mem_cgroup_pages+0x10/0x10 ? irqentry_exit+0xc6/0x670 reclaim_high+0x10a/0x1b0 ? __pfx_reclaim_high+0x10/0x10 ? process_one_work+0x5ff/0x1030 ? __pfx_high_work_func+0x10/0x10 process_one_work+0x6e2/0x1030 ? __pfx___schedule+0x10/0x10 ? __pfx_process_one_work+0x10/0x10 worker_thread+0x422/0xbb0 ? __pfx_worker_thread+0x10/0x10 kthread+0x2cd/0x3a0 ? recalc_sigpending+0x15c/0x200 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x368/0x590 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x588/0xf50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK>
--- mm/memcontrol.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/memcontrol.c +5 -0
@@ -2443,7 +2443,10 @@ static void high_work_func(struct work_struct *work)struct mem_cgroup *memcg; memcg = container_of(work, struct mem_cgroup, high_work); +if (!css_tryget_online (&memcg->css)) +return ;reclaim_high (memcg,MEMCG_CHARGE_BATCH ,GFP_KERNEL ); +css_put (&memcg->css); }/*
@@ -5546,6 +5549,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)page_counter_set_min (&memcg->memory,0 );page_counter_set_low (&memcg->memory,0 ); +page_counter_set_high (&memcg->memory,PAGE_COUNTER_MAX ); +page_counter_set_high (&memcg->swap,PAGE_COUNTER_MAX );memcg_offline_kmem (memcg);reparent_shrinker_deferred (memcg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1480/3318 openrisc: export __mulsi3 for modules
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <[email protected]>
[ Upstream commit 8ff981aa283a0ce516c2dc65a48a185ed336c657 ]
OpenRISC configurations without hardware multiplication fail to build modules which contain compiler-generated calls to __mulsi3. The failure is widespread, affecting filesystems, drivers and KUnit tests at modpost.
When CONFIG_OPENRISC_HAVE_INST_MUL is disabled, the architecture Makefile passes -msoft-mul to GCC. The multiplication helper is supplied by the libgcc archive linked into vmlinux, but or32_ksyms.c does not export it. Built-in callers can therefore link while module callers cannot resolve the symbol.
Export __mulsi3 alongside the other compiler-generated helpers.
The omission predates 7c3f4d699f34 ("resource, kunit: stop selecting GET_FREE_REGION"), which the robot identified when reporting an additional failing module. It was already present in the initial OpenRISC export list.
--- arch/openrisc/kernel/or32_ksyms.c | 1 + 1 file changed, 1 insertion(+)
arch/openrisc/kernel/or32_ksyms.c +1 -0
@@ -35,6 +35,7 @@ DECLARE_EXPORT(__divsi3);DECLARE_EXPORT (__umodsi3);DECLARE_EXPORT (__modsi3);DECLARE_EXPORT (__muldi3); +DECLARE_EXPORT (__mulsi3);DECLARE_EXPORT (__ashrdi3);DECLARE_EXPORT (__ashldi3);DECLARE_EXPORT (__lshrdi3);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1481/3318 ocfs2: find the xattr entry again after defragmenting a bucket
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 9a40c050f58344615a0604701b5d299519833163 ]
ocfs2_xattr_set_entry_bucket() hands loc.xl_entry to ocfs2_xa_set() twice:
once for the bucket as it stands, and, if that reports -ENOSPC, once more after ocfs2_defrag_xattr_bucket() has packed the name/value pairs down.
Defragmenting ends by sorting the entry array on xe_name_hash. Buckets are kept sorted, so the sort only permutes entries that share a hash, but lib/sort.c is an unstable heapsort and it does permute them. loc.xl_entry is an address inside xh_entries[], so afterwards it denotes whichever entry landed in that slot rather than the one the search found.
The second ocfs2_xa_set() then works on the wrong entry. Nothing on that path compares the entry's name with xi->xi_name, so what happens depends on how the two entries compare in size: ocfs2_xa_reuse_entry() trips its BUG_ON() when the padded name sizes differ, and otherwise the new value is written into the neighbouring attribute's value slot while the attribute being set is left untouched. setxattr() reports success either way.
Remember the entry's hash before defragmenting and look the entry up again afterwards, the way ocfs2_xattr_bucket_find() does. An entry that cannot be found again means the bucket no longer holds what the search found, so fail with -EFSCORRUPTED rather than writing through the stale pointer.
--- fs/ocfs2/xattr.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
fs/ocfs2/xattr.c +29 -1
@@ -5859,13 +5859,18 @@ static int ocfs2_xattr_set_entry_bucket(struct inode *inode,struct ocfs2_xattr_search *xs, struct ocfs2_xattr_set_ctxt *ctxt) { - int ret; + int ret, found = 0; +u16 xe_index; +u32 name_hash;struct ocfs2_xa_loc loc;trace_ocfs2_xattr_set_entry_bucket (xi->xi_name);ocfs2_init_xattr_bucket_xa_loc (&loc, xs->bucket, xs->not_found ?NULL : xs->here); +/* Defragmenting below may move this entry, so remember its hash. */ + name_hash = loc.xl_entry ?le32_to_cpu (loc.xl_entry->xe_name_hash) :0 ; + ret =ocfs2_xa_set (&loc, xi, ctxt);if (!ret) { xs->here = loc.xl_entry;
@@ -5884,6 +5889,29 @@ static int ocfs2_xattr_set_entry_bucket(struct inode *inode, goto out; } +/* +* ocfs2_defrag_xattr_bucket() sorts the entries by name hash and +* lib/sort.c is not stable, so entries sharing a hash may have traded +* slots. Look the entry up again before writing through it. +*/ +if (loc.xl_entry) { + ret =ocfs2_find_xe_in_bucket (inode, xs->bucket, + xi->xi_name_index, xi->xi_name, + name_hash, &xe_index, &found); +if (ret) { +mlog_errno (ret); + goto out; + } +if (!found) { +mlog (ML_ERROR ,"xattr entry not found in bucket %llu after defrag\n" , + (unsigned long long )bucket_blkno (xs->bucket)); + ret = -EFSCORRUPTED ; + goto out; + } + loc.xl_entry = &bucket_xh (xs->bucket)->xh_entries[xe_index]; + xs->here = loc.xl_entry; + } + ret =ocfs2_xa_set (&loc, xi, ctxt);if (!ret) { xs->here = loc.xl_entry;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/3318 ocfs2: find the xattr entry again after converting a block to a bucket
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 9c191a7a44882487e291e09f095d2ae4d7cca146 ]
ocfs2_xattr_create_index_block() turns a non-indexed xattr block into a tree by copying it into a bucket, and the copy sorts the entries: a block holds them in insertion order, a bucket by name hash. ocfs2_xattr_update_xattr_search() nevertheless relocates the caller's search by the index the entry had in the block, so unless the two orders agreed it points at an unrelated entry, and nothing between there and the write compares that entry's name with the one being set.
Setting an xattr whose new value no longer fits the block arrives here with xs->not_found clear. The block gave up because ocfs2_xa_block_can_reuse() wants an exact namevalue size match, while ocfs2_xa_bucket_can_reuse() only wants an entry at least as large as the new one, so the bucket accepts a pair the block rejected and the update lands on whichever entry the sort left at that index. Equal padded name lengths get that other attribute's value replaced in place and its name left alone, so setxattr returns success while the attribute asked for keeps its old value. A longer one trips ocfs2_xa_reuse_entry()'s BUG_ON, and a shorter one is refused by the bucket as well, so ocfs2_xa_prepare_entry() wipes the entry and writes the new name over it, leaving xe_name_hash describing a name that is no longer there.
Find the entry again by the name being set, matching the type as well. The copy carries every entry and every name over unchanged, and (type, name) pairs are unique within a block, so the match is exact. The type matters because the handlers strip their prefix before calling ocfs2_xattr_set(), so user.foo and trusted.foo share a stored name, a stored length and a hash, and both can sit in the same block.
The name has to come from xi rather than from xs->here: a failed set can remove the entry xs->here names, and only the "growing" caller sets ctxt->set_abort, which is what stops the conversion. Scan every entry rather than narrowing on the hash the way ocfs2_find_xe_in_bucket() does, since an existing entry keeps the hash it was stored under, which a kernel that sign-extended the name bytes made different from the one computed now. An empty result means the entry did not survive the failed set and this has become an insert; leaving xs->here alone would keep it pointing into the block, which is rewritten as a tree root before the caller reads it again.
--- fs/ocfs2/xattr.c | 54 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 10 deletions(-)
fs/ocfs2/xattr.c +44 -10
@@ -256,6 +256,7 @@ static int ocfs2_xattr_tree_list_index_block(struct inode *inode, size_t buffer_size);static int ocfs2_xattr_create_index_block (struct inode *inode, +struct ocfs2_xattr_info *xi,struct ocfs2_xattr_search *xs,struct ocfs2_xattr_set_ctxt *ctxt);
@@ -3228,7 +3229,7 @@ static int ocfs2_xattr_block_set(struct inode *inode,else if ((ret != -ENOSPC ) || ctxt->set_abort) goto end;else { - ret =ocfs2_xattr_create_index_block (inode, xs, ctxt); + ret =ocfs2_xattr_create_index_block (inode, xi, xs, ctxt);if (ret) goto end; }
@@ -4565,13 +4566,10 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,* real place of the xattr. */ static void ocfs2_xattr_update_xattr_search (struct inode *inode, -struct ocfs2_xattr_search *xs, -struct buffer_head *old_bh) +struct ocfs2_xattr_info *xi, +struct ocfs2_xattr_search *xs) { -char *buf = old_bh->b_data; -struct ocfs2_xattr_block *old_xb = (struct ocfs2_xattr_block *)buf; -struct ocfs2_xattr_header *old_xh = &old_xb->xb_attrs.xb_header; -int i; +int i, count; xs->header =bucket_xh (xs->bucket); xs->base =bucket_block (xs->bucket,0 );
@@ -4580,11 +4578,47 @@ static void ocfs2_xattr_update_xattr_search(struct inode *inode,if (xs->not_found)return ; - i = xs->here - old_xh->xh_entries; - xs->here = &xs->header->xh_entries[i]; +/* +* A block holds its entries in insertion order while a bucket holds +* them by name hash, so ocfs2_cp_xattr_block_to_bucket() sorted the +* copies and the index this entry had in the block no longer says +* where it is. It copied every entry and every name unchanged, and +* (type, name) pairs are unique within a block, so find it again by +* name. +* +* Search for the name being set, not for the name xs->here carries. +* A failed set may have removed that entry, and ocfs2_xa_remove_entry() +* then memmoves its successor into the slot. Comparing every entry +* rather than narrowing on the hash also finds an entry stored under +* the legacy signed hash, which ocfs2_find_xe_in_bucket() would skip. +*/ + count =le16_to_cpu (xs->header->xh_count); +for (i =0 ; i < count; i++) { +struct ocfs2_xattr_entry *xe = &xs->header->xh_entries[i]; + +if (ocfs2_xattr_get_type (xe) != xi->xi_name_index) +continue ; +if (xe->xe_name_len != xi->xi_name_len) +continue ; +if (!memcmp (xs->base +le16_to_cpu (xe->xe_name_offset), + xi->xi_name, xi->xi_name_len)) { + xs->here = xe; +return ; + } + } + +/* +* The entry did not survive the failed set, so this has become an +* insert. Point xs->here back inside the bucket: it still refers to +* the block being converted, which is about to be rewritten as a tree +* root. +*/ + xs->not_found = -ENODATA ; + xs->here = xs->header->xh_entries; }static int ocfs2_xattr_create_index_block (struct inode *inode, +struct ocfs2_xattr_info *xi,struct ocfs2_xattr_search *xs,struct ocfs2_xattr_set_ctxt *ctxt) {
@@ -4651,7 +4685,7 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,ocfs2_cp_xattr_block_to_bucket (inode, xb_bh, xs->bucket);ocfs2_xattr_bucket_journal_dirty (handle, xs->bucket); -ocfs2_xattr_update_xattr_search (inode, xs, xb_bh); +ocfs2_xattr_update_xattr_search (inode, xi, xs);/* Change from ocfs2_xattr_header to ocfs2_xattr_tree_root */ memset(&xb->xb_attrs, 0, inode->i_sb->s_blocksize -
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1483/3318 ocfs2: do not read the entry array of an empty xattr bucket
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit e8de099f2958c84aa23186c5481e69f7ffd39355 ]
ocfs2_check_xattr_bucket_collision() decides whether splitting a bucket can make room by comparing the hash being inserted against the first and the last entry. xh_count comes off disk and is never checked, and a bucket is allowed to hold no entries: ocfs2_xa_remove_entry() keeps the last slot when it removes the only one, so that an empty bucket still carries the hash it is keyed by. xh_count then reads back as 0 while xh_entries[0] is still meaningful, and the second comparison indexes xh_entries[-1].
That is outside the __counted_by_le(xh_count) bounds of xh_entries[] and lands on the header. An entry is 16 bytes and xe_name_hash is its first field, so the value read is xh_count | xh_free_start << 16. It stays inside the block, but the answer is arbitrary, and for an empty bucket it says there is no collision, so a new bucket gets added on the strength of it.
An empty bucket holds no entries to collide with. Return before reading the array.
One way to reach the test with an empty bucket is a set that removes the bucket's only entry during cleanup and then fails for space again, since it is that second -ENOSPC which calls this. Growing a value past OCFS2_XATTR_INLINE_SIZE is the easy route: the cluster allocation fails, the "!orig_clusters" arm of ocfs2_xa_cleanup_value_truncate() removes the entry, and although the "growing" caller does set ctxt->set_abort, only ocfs2_xattr_block_set() and __ocfs2_xattr_set_handle() look at it, so ocfs2_xattr_set_entry_index_block() goes straight on to the collision check.
This sits on commit a9ea8b397864 ("ocfs2: use the stored hash when checking xattr bucket collision"), which gave the collision check its two argument form and is marked for 6.2 and later. The read fixed here is present in the three argument version too, but a tree without that commit needs the hunk adapted by hand.
--- fs/ocfs2/xattr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/xattr.c +10 -1
@@ -5868,11 +5868,20 @@ static int ocfs2_check_xattr_bucket_collision(struct ocfs2_xattr_bucket *bucket, u32 name_hash) {struct ocfs2_xattr_header *xh =bucket_xh (bucket); +u16 count =le16_to_cpu (xh->xh_count); + +/* +* An empty bucket keeps the hash of the entry that was removed in +* xh_entries[0] so that it can still be found, but it holds no +* entries to collide with. +*/ +if (!count) +return 0 ;if (name_hash !=le32_to_cpu (xh->xh_entries[0 ].xe_name_hash))return 0 ; -if (xh->xh_entries[le16_to_cpu (xh->xh_count) -1 ].xe_name_hash == +if (xh->xh_entries[count -1 ].xe_name_hash == xh->xh_entries[0 ].xe_name_hash) { mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, " "hash = %u\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1484/3318 ocfs2: do not index before the entry array when dividing an empty bucket
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 7133a0d0954c109f1764ebf8ab32d7e757a6c587 ]
ocfs2_divide_xattr_bucket() appends an empty bucket carrying a sentinel hash when the source bucket has no divide position, taking that hash from xh_entries[start - 1]. ocfs2_xattr_find_divide_pos() returns count when every entry shares one hash, and its loop does not run at all for count < 2, so an empty bucket comes back with start == count == 0 and the read is xh_entries[-1].
That is outside the __counted_by_le(xh_count) bounds of xh_entries[] and lands on the header, so the value picked up isxh_count | xh_free_start << 16. One above it is written into the new bucket's xh_entries[0] and committed, which leaves a bucket whose first hash does not follow the bucket before it. ocfs2_xattr_bucket_find() binary searches on xh_entries[0], so the broken key hides the range the sentinel was meant to cover: getxattr() answers -ENODATA for an attribute that is stored, and an insert can go to the wrong bucket and leave two copies of a name. The cross cluster divide hands the same value back as a tree record's e_cpos, which then claims a hash range it does not cover.
Read xh_entries[0] instead. The branch is only reached when every entry shares one hash, so for a non-empty bucket it holds the same value, and for an empty one it is the slot that carries the bucket key.
An empty bucket reaches the divide from ocfs2_check_xattr_bucket_collision(), which reports no collision for one, through ocfs2_add_new_xattr_bucket() and ocfs2_extend_xattr_bucket(). It does not take a failed set to get
there: a divide that finds no position is itself what leaves an empty sentinel bucket behind, and a later extend can pick it as the target.
--- fs/ocfs2/xattr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/ocfs2/xattr.c +9 -1
@@ -5038,7 +5038,15 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode, start =ocfs2_xattr_find_divide_pos (xh);if (start == count) { - xe = &xh->xh_entries[start-1 ]; +/* +* start == count means every entry shares one hash, so the +* first of them carries it too. An empty bucket has no +* entries[start - 1], but its entries[0] still carries the +* bucket key: either the hash ocfs2_xa_remove_entry() +* deliberately leaves behind, or the sentinel a previous +* divide wrote. +*/ + xe = &xh->xh_entries[0 ];/* * initialized a new empty bucket here.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1485/3318 ocfs2: do not read the entry array of an empty xattr block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit cd7c3563a98fe8c984463d83772e518cb7e68356 ]
ocfs2_cp_xattr_block_to_bucket() sizes the name and value area it has to carry over from the block's last entry, so an empty block makes it read xh_entries[-1]. That lands on the header, where xe_name_offset overlaps xh_name_value_len, and block storage never maintains that field, so it reads as 0 and the copy runs from the header to the end of the block.
The bucket that comes out has xh_count 0 but a name_value_len of blocksize less the header, and a matching xh_free_start that claims those bytes are in use -- nearly the whole bucket with the common 4K block size -- while the last block of the bucket holds a copy of the old block's bytes. Nothing but a trace event reads xh_name_value_len, the copied bytes came from the same inode and were wiped before the entry was removed, and ocfs2_defrag_xattr_bucket() recomputes xh_free_start, so this corrupts the header rather than leaking anything.
Leave the bucket empty instead, carrying over the hash the block was keyed by, since ocfs2_add_new_xattr_bucket() and ocfs2_xattr_bucket_find() both read xh_entries[0] of an empty bucket. That read is the exception ocfs2_xa_remove_entry() documents rather than a new out of bounds access.
A block reaches the conversion empty when truncating an external value back fails partway through: the "reusing" and "overwriting" callers of ocfs2_xa_cleanup_value_truncate() remove the entry without setting ctxt->set_abort, so ocfs2_xattr_block_set() sees a plain -ENOSPC and converts. The "growing" caller does set it, and the block form makes a single attempt with no defragment and retry in between, so that is the only route here.
--- fs/ocfs2/xattr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/ocfs2/xattr.c +15 -0
@@ -4520,6 +4520,21 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,for (i =0 ; i < blks; i++)memset (bucket_block (bucket, i),0 , blocksize); +/* +* An empty block has no names or values to carry over, and the +* xh_entries[count - 1] below would be xh_entries[-1]. Leave the +* bucket empty, but carry over the hash ocfs2_xa_remove_entry() left +* in the block's xh_entries[0] so that the bucket still holds the key +* it is looked up by. +*/ +if (!count) { + xh->xh_num_buckets =cpu_to_le16 (1 ); + xh->xh_free_start =cpu_to_le16 (OCFS2_XATTR_BUCKET_SIZE ); + xh->xh_entries[0 ].xe_name_hash = + xb_xh->xh_entries[0 ].xe_name_hash; +return ; + } +/* * Since the xe_name_offset is based on ocfs2_xattr_header, * there is a offset change corresponding to the change of
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1486/3318 fat: hold truncate_lock in fat_write_failed()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matheus Alves de Almeida <[email protected]>
[ Upstream commit 7b90009546f5d3f3ac9428040cd7ffbdfd60f2eb ]
The current fat_write_failed() implementation calls into fat_truncate_blocks() without holding truncate_lock.
A failed or short extending write racing with FIBMAP can spuriously make a FAT filesystem read-only. FIBMAP bounds its lookup by i_blocks, so it can walk allocated clusters beyond i_size while fat_write_failed() is removing them. If the chain is shortened during the walk, the mapper can report a bogus "request beyond EOF" error, triggering the default read-only error policy. Hold truncate_lock for write around the block cleanup to serialize it with _fat_bmap().
For comparison, fat_setattr() correctly holds truncate_lock during truncation:
down_write(&MSDOS_I(inode)->truncate_lock); truncate_setsize(inode, attr->ia_size); fat_truncate_blocks(inode, attr->ia_size); up_write(&MSDOS_I(inode)->truncate_lock);
Make it so ->truncate_lock is held exclusive while truncating.
--- fs/fat/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/fat/inode.c +2 -0
@@ -216,7 +216,9 @@ static void fat_write_failed(struct address_space *mapping, loff_t to)if (to > inode->i_size) {truncate_pagecache (inode, inode->i_size); +down_write (&MSDOS_I (inode)->truncate_lock);fat_truncate_blocks (inode, inode->i_size); +up_write (&MSDOS_I (inode)->truncate_lock); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1487/3318 ocfs2: keep locking_state within the cluster connection lifetime
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 5bdef466851e39ba752634cbea68e5ea24ccfb24 ]
The locking_state reader calls ocfs2_dlm_lvb() through the selected cluster stack. Its debug-object reference keeps the tracking list alive, but does not keep that stack selected without a cluster connection.
DLM initialization publishes the file before establishing its connection, and DLM shutdown drops the connection while the file still exists. Both the mount error unwind in ocfs2_mount_volume() and ocfs2_dismount_volume() remove the debugfs subtree only after ocfs2_dlm_shutdown() has returned. Whenever the disconnect releases the last stack reference, which is the case for a failed mount and for any unmount without a pending hangup, a concurrent reader dereferences a NULL active_stack:
Mount error unwind Debugfs reader
------------------ --------------
ocfs2_mount_volume(): out_dlm
ocfs2_dlm_shutdown()
disconnect last cluster
clear active_stack
read locking_state
ocfs2_dlm_seq_show()
ocfs2_dlm_lvb()
dereference active_stack fill_super(): out_debugfs
remove debugfs subtree
Publish the debug files only after the connection and the mount lock resources are initialized, so a failed DLM initialization has no debug reference to drop. Remove them again in the common DLM shutdown helper before the connection is dropped: debugfs removal waits for readers that are inside the file operations, and the parent directory is still present at that point in every caller. This covers the mount error unwind, the ocfs2_fill_super() failures after a successful mount that dismount with mnt_err set, and unmounts whose disconnect releases the stack directly.
Only the relevant frames of the report are kept:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] RIP: 0010:ocfs2_dlm_lvb+0x38/0xf0 Call Trace: <TASK> ocfs2_dlm_seq_show+0x36a/0xb70 seq_read_iter+0x480/0x1110 seq_read+0x362/0x5a0 full_proxy_read+0x11f/0x180 vfs_read+0x1a0/0xc20 ksys_read+0x111/0x200 </TASK>
--- fs/ocfs2/dlmglue.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
fs/ocfs2/dlmglue.c +13 -5
@@ -3339,6 +3339,14 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb) {struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug; +/* +* Drain the readers before the cluster stack goes away: the +* locking_state reader resolves ocfs2_dlm_lvb() through the +* stack. Every caller removes the parent directory later. +*/ +debugfs_lookup_and_remove ("locking_state" , osb->osb_debug_root); +debugfs_lookup_and_remove ("locking_filter" , osb->osb_debug_root); +if (dlm_debug)ocfs2_put_dlm_debug (dlm_debug); }
@@ -3353,8 +3361,6 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) goto local; } -ocfs2_dlm_init_debug (osb); -/* launch downconvert thread */ osb->dc_task =kthread_run (ocfs2_downconvert_thread, osb,"ocfs2dc-%s" , osb->uuid_str);
@@ -3394,9 +3400,10 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)ocfs2_orphan_scan_lock_res_init (&osb->osb_orphan_scan.os_lockres, osb); osb->cconn = conn; +if (conn) +ocfs2_dlm_init_debug (osb); bail:if (status <0 ) { -ocfs2_dlm_shutdown_debug (osb);if (osb->dc_task)kthread_stop (osb->dc_task); }
@@ -3426,10 +3433,11 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,ocfs2_lock_res_free (&osb->osb_orphan_scan.os_lockres);if (osb->cconn) { +/* The disconnect below may release the selected stack. */ +ocfs2_dlm_shutdown_debug (osb); +ocfs2_cluster_disconnect (osb->cconn, hangup_pending); osb->cconn =NULL ; - -ocfs2_dlm_shutdown_debug (osb); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1488/3318 ocfs2/dlm: serialize migration MLE cleanup on failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 61469249aab03799b0d3294b7a0cd25dd303017a ]
A migration MLE has a base reference for the mastering answer and an in-use reference held by dlm_migrate_lockres(). The finishing assertion consumes the base reference, but migration failure drops it again without checking whether the assertion already consumed it.
The target queues its migration worker before it acknowledges the ALL_DONE packet, so its finishing assertion can be handled while the sender still waits for the status. If the connection fails before the status arrives, dlm_send_one_lockres() returns an error for a migration that the target has already completed:
Old-master sender Finishing assertion
----------------- -------------------
publish MLE; take in-use reference
send ALL_DONE; wait for status
take lookup reference unlink MLE
put lookup and base references
send returns a connection error
put base reference again; free MLE
put in-use reference; access freed MLE
dlm_assert_master_handler() holds dlm->spinlock from the MLE lookup to the final puts, and it takes dlm->master_lock around the unlink and the puts. Decide under the same locks: if the MLE is already unhashed, the assertion consumed the base reference, so drop only the sender's in-use reference. Otherwise unlink it before consuming the base reference so a later assertion no longer finds it.
An assertion that got there first has also made the target the owner and cleared DLM_LOCK_RES_MIGRATING. Treating the attempt as failed at that point would leave the lockres owned by the target while this node still holds the other nodes' locks and refmap bits, so it could neither be purged nor migrated again. Finish our side as a completed migration does instead: drop those locks under res->spinlock if the target still owns the lockres, and recalculate its usage.
Use the same cleanup for the pre-send failure, the send failure and the target-death failure paths. The sender's in-use reference keeps the MLE alive until its final put outside the nested locks. Successful migration retains its existing in-use-only put.
A target that has died cannot assert after the sender has seen its death. The o2net node-down callback runs before the DLM one; it disconnects the node and flushes the workqueue that runs the message handlers, so an assertion already received has been handled by the time the DLM removes the node from the domain map. A node that leaves the domain cleanly sends its exit message only after its assertions have been answered.
Two windows of the hand-over itself are left as they are: the handler switches the owner and the sender drops the other nodes' locks moments later, and an assertion from a live target that arrives after the sender has given up still meets the owner check in the handler. Waiting for the target before giving up would only stretch the first window into the time in which recovery of the target can observe it.
KASAN report, only the relevant frames are kept:
BUG: KASAN: slab-use-after-free in dlm_put_mle_inuse+0xce/0xe0 Read of size 8 at addr ffff8881190e3c20 by task umount/593 Call Trace: <TASK> dlm_put_mle_inuse+0xce/0xe0 dlm_migrate_lockres+0x16af/0x20d0 dlm_empty_lockres+0x60a/0xbd0 dlm_unregister_domain+0x53b/0x11d0 o2cb_cluster_disconnect+0xa5/0x110 ocfs2_cluster_disconnect+0x73/0xc0 ocfs2_dlm_shutdown+0x311/0x440 ocfs2_dismount_volume+0x696/0x940 generic_shutdown_super+0x15f/0x490 kill_block_super+0x40/0xa0 deactivate_locked_super+0xae/0x120 deactivate_super+0xa2/0xc0 cleanup_mnt+0x217/0x450 task_work_run+0x144/0x230 </TASK> Allocated by task 593: kmem_cache_alloc_noprof+0x20b/0x5c0 dlm_migrate_lockres+0x20e/0x20d0 dlm_empty_lockres+0x60a/0xbd0 dlm_unregister_domain+0x53b/0x11d0 o2cb_cluster_disconnect+0xa5/0x110 ocfs2_cluster_disconnect+0x73/0xc0 ocfs2_dlm_shutdown+0x311/0x440 ocfs2_dismount_volume+0x696/0x940 Freed by task 593: kmem_cache_free+0x242/0x580 __dlm_put_mle+0x4b2/0x660 dlm_migrate_lockres+0x1690/0x20d0 dlm_empty_lockres+0x60a/0xbd0 dlm_unregister_domain+0x53b/0x11d0 o2cb_cluster_disconnect+0xa5/0x110 ocfs2_cluster_disconnect+0x73/0xc0 ocfs2_dlm_shutdown+0x311/0x440 The buggy address belongs to the object at ffff8881190e3c00 which belongs to the cache o2dlm_mle of size 480
The buggy address is located 32 bytes inside of
freed 480-byte region [ffff8881190e3c00, ffff8881190e3de0)
--- fs/ocfs2/dlm/dlmmaster.c | 70 ++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 9 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +61 -9
@@ -2537,6 +2537,52 @@ static int dlm_is_lockres_migratable(struct dlm_ctxt *dlm,*/ +/* +* Drop the sender's references on a migration MLE after the attempt has +* failed. The finishing assert from the target may already have unlinked +* the MLE and consumed its base reference; decide under the locks the +* assert handler holds, and only drop the base reference while the MLE is +* still hashed. Returns true when the assert got there first: the target +* has become the master, so the caller must complete the migration. +*/ +static bool dlm_put_migration_mle (struct dlm_ctxt *dlm, +struct dlm_master_list_entry *mle) +{ +bool asserted; + +spin_lock (&dlm->spinlock); +spin_lock (&dlm->master_lock); +__dlm_mle_detach_hb_events (dlm, mle); + asserted =hlist_unhashed (&mle->master_hash_node); +if (!asserted) { +__dlm_unlink_mle (dlm, mle); +__dlm_put_mle (mle); + } +spin_unlock (&dlm->master_lock); +spin_unlock (&dlm->spinlock); + +dlm_put_mle_inuse (mle); +return asserted; +} + +/* +* The finishing assert got there first: it switched the owner to the +* target and cleared DLM_LOCK_RES_MIGRATING. Drop the other nodes' locks +* as a completed migration does, unless recovery has taken the lockres +* over since, and let the usage be recalculated. +*/ +static void dlm_migrate_lockres_asserted (struct dlm_ctxt *dlm, +struct dlm_lock_resource *res, +u8 target) +{ +spin_lock (&res->spinlock); +if (res->owner == target) +dlm_remove_nonlocal_locks (dlm, res); +spin_unlock (&res->spinlock); + +dlm_lockres_calc_usage (dlm, res); +} +static int dlm_migrate_lockres (struct dlm_ctxt *dlm,struct dlm_lock_resource *res,u8 target) {
@@ -2621,9 +2667,10 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,if (ret <0 ) {if (mle_added) { -dlm_mle_detach_hb_events (dlm, mle); -dlm_put_mle (mle); -dlm_put_mle_inuse (mle); +if (dlm_put_migration_mle (dlm, mle)) { +dlm_migrate_lockres_asserted (dlm, res, target); + ret =0 ; + } }else if (mle) {kmem_cache_free (dlm_mle_cache, mle); mle =NULL ;
@@ -2652,9 +2699,11 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,mlog (0 ,"migration to node %u failed with %d\n" , target, ret);/* migration failed, detach and clean up mle */ -dlm_mle_detach_hb_events (dlm, mle); -dlm_put_mle (mle); -dlm_put_mle_inuse (mle); +if (dlm_put_migration_mle (dlm, mle)) { +dlm_migrate_lockres_asserted (dlm, res, target); + ret =0 ; + goto leave; + }spin_lock (&res->spinlock); res->state &= ~DLM_LOCK_RES_MIGRATING ; wake =1 ;
@@ -2698,9 +2747,12 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, res->lockname.name, target); ret = -EINVAL ;/* migration failed, detach and clean up mle */ -dlm_mle_detach_hb_events (dlm, mle); -dlm_put_mle (mle); -dlm_put_mle_inuse (mle); +if (dlm_put_migration_mle (dlm, mle)) { +dlm_migrate_lockres_asserted (dlm, res, + target); + ret =0 ; + goto leave; + }spin_lock (&res->spinlock); res->state &= ~DLM_LOCK_RES_MIGRATING ; wake =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/3318 ocfs2: stop recovery before shutting down local allocators
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 126429e2f503ade63502978beb0c519066442250 ]
Recovery completion needs the local allocators until it has finished reclaiming a failed node's allocation window and truncate log. During unmount, quota recovery is stopped first, but that leaves recovery_state at OCFS2_REC_QUOTA_DISABLED. New non-quota recovery can still start.
ocfs2_truncate_log_shutdown() drains existing completion work and releases osb_tl_bh before ocfs2_recovery_exit() closes that publication path:
Unmount Recovery
------- --------
stop quota recovery; disable quotas truncate_log_shutdown()
flush existing completion work
recover another failed node
queue completion
flush local log; release buffer
complete_truncate_log_recovery()
use released osb_tl_bh
recovery_exit(): disable and drain
An extra buffer reference alone would still let completion append new records after the final truncate-log flush.
Split stopping and draining recovery from freeing its state. Stop all recovery producers and drain completion work before shutting down either local allocator. Keep recovery-state release at its existing later point, so its lifetime relative to other teardown users stays unchanged. The second stop at recovery_exit() is harmless once recovery is disabled.
KASAN report as below:
BUG: KASAN: slab-use-after-free in ocfs2_truncate_log_needs_flush+0x23d/0x360
Read of size 8 at addr ffff8881093711e8 by task kworker/u16:3/53
CPU: 0 UID: 0 PID: 53 Comm: kworker/u16:3 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: ocfs2_wq ocfs2_complete_recovery
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? ocfs2_truncate_log_needs_flush+0x23d/0x360
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20e/0x420
? ocfs2_truncate_log_needs_flush+0x23d/0x360
kasan_report+0xe0/0x110
? ocfs2_truncate_log_needs_flush+0x23d/0x360
ocfs2_truncate_log_needs_flush+0x23d/0x360
? __pfx_ocfs2_truncate_log_needs_flush+0x10/0x10
? __pfx_down_write+0x10/0x10
ocfs2_complete_truncate_log_recovery+0x315/0x780
? trace_hardirqs_on+0x18/0x160
? __pfx_ocfs2_complete_truncate_log_recovery+0x10/0x10
? ocfs2_complete_recovery+0x666/0x11b0
? srso_alias_return_thunk+0x5/0xfbef5
? kfree+0x308/0x580
ocfs2_complete_recovery+0x676/0x11b0
? __pfx_ocfs2_complete_recovery+0x10/0x10
? reacquire_held_locks+0xdd/0x200
? process_one_work+0x7c8/0x1b40
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x190/0x300
? __pfx_autoremove_wake_function+0x10/0x10
? process_one_work+0x834/0x1b40
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x9a8/0x1b40
? __pfx_process_one_work+0x10/0x10
? lock_acquire+0x190/0x300
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x177/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_worker_thread+0x10/0x10
kthread+0x351/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf70
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 538:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_slab_alloc+0x89/0x90
kmem_cache_alloc_noprof+0x20b/0x5c0
alloc_buffer_head+0x26/0x120
folio_alloc_buffers+0x122/0x1d0
bdev_getblk+0x299/0x4f0
ocfs2_read_blocks_sync+0x513/0xbc0
ocfs2_iget+0x9cd/0x1a00
ocfs2_get_system_file_inode+0x25e/0x7a0
ocfs2_fill_super+0x1b05/0x3930
get_tree_bdev_flags+0x35d/0x5f0
vfs_get_tree+0x93/0x320
fc_mount+0x1d/0x200
path_mount+0x592/0x1e00
__x64_sys_mount+0x24b/0x2d0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 553:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kmem_cache_free+0x242/0x580
free_buffer_head+0x4b/0xc0
try_to_free_buffers+0x1dc/0x330
ocfs2_truncate_log_shutdown+0x789/0x1290
ocfs2_dismount_volume+0x1da/0x940
generic_shutdown_super+0x15f/0x490
kill_block_super+0x40/0xa0
deactivate_locked_super+0xae/0x120
deactivate_super+0xa2/0xc0
cleanup_mnt+0x217/0x450
task_work_run+0x144/0x230
exit_to_user_mode_loop+0x17d/0x570
do_syscall_64+0x4d1/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff8881093711c0
which belongs to the cache buffer_head of size 160
The buggy address is located 40 bytes inside of
freed 160-byte region [ffff8881093711c0, ffff888109371260)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109371
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881008883c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000120012 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888109371080: 00 00 00 00 fc fc fc fc fc fc fc fc 00 00 00 00
ffff888109371100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888109371180: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
^
ffff888109371200: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff888109371280: fc fc fc fc 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================--- fs/ocfs2/journal.c | 15 ++++++++++++--- fs/ocfs2/journal.h | 1 + fs/ocfs2/super.c | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-)
fs/ocfs2/journal.c +12 -3
@@ -230,13 +230,22 @@ void ocfs2_recovery_disable_quota(struct ocfs2_super *osb)ocfs2_recovery_disable (osb,OCFS2_REC_QUOTA_WANT_DISABLE ); } +/* Stop producers and drain completion work without freeing recovery state. */ +void ocfs2_recovery_stop (struct ocfs2_super *osb) +{ +ocfs2_recovery_disable (osb,OCFS2_REC_WANT_DISABLE ); +} +void ocfs2_recovery_exit (struct ocfs2_super *osb) {struct ocfs2_recovery_map *rm; -/* disable any new recovery threads and wait for any currently -* running ones to exit. Do this before setting the vol_state. */ -ocfs2_recovery_disable (osb,OCFS2_REC_WANT_DISABLE ); +/* +* Disable producers and drain work before freeing recovery state. +* Do this before setting vol_state to VOLUME_DISMOUNTED: completion +* work may still be waiting in __ocfs2_wait_on_mount(). +*/ +ocfs2_recovery_stop (osb);/* * Now that recovery is shut down, and the osb is about to be
fs/ocfs2/journal.h +1 -0
@@ -147,6 +147,7 @@ void ocfs2_complete_recovery(struct work_struct *work);void ocfs2_wait_for_recovery (struct ocfs2_super *osb);int ocfs2_recovery_init (struct ocfs2_super *osb); +void ocfs2_recovery_stop (struct ocfs2_super *osb);void ocfs2_recovery_exit (struct ocfs2_super *osb);void ocfs2_recovery_disable_quota (struct ocfs2_super *osb);
fs/ocfs2/super.c +3 -0
@@ -1885,6 +1885,9 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)/* Wait for worker to be done with the work structure in osb */ cancel_work_sync (&osb->dquot_drop_work); +/* Stop recovery producers before releasing their local allocators. */ +ocfs2_recovery_stop (osb); +ocfs2_shutdown_local_alloc (osb);ocfs2_truncate_log_shutdown (osb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1490/3318 ocfs2/cluster: unlink socket containers before releasing resources
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 0988f0c0c7c908f0ff77fd8b90ce9918a1f41479 ]
A socket container's node and socket must remain alive while the container is on sock_containers. The debugfs formatter reads sc_node and sc_sock under o2net_debug_lock without taking their references, but sc_kref_release() releases both before taking that lock to unlink the container.
With CONFIG_DEBUG_FS enabled, a synchronous sender can retain its last socket-container reference after o2net_disconnect_node() has detached the connection and flushed o2net_wq. The caller runs outside that workqueue. After the sender removes its configfs dependency, node removal can proceed without waiting for the sender's final sc_put():
Sender (final sc_put) Configfs rmdir Debugfs reader
-------------------- -------------- --------------
o2nm_undepend_item()
Drop node item refs
o2nm_node_put()
[node can be freed]
sc_seq_show()
Lock debug lock Read sc_node->nd_name Unlock debug lock
sc_node = NULL
o2net_debug_del_sc()
The earlier socket release has a similar window. The container is still selectable while its socket has been released and sc_sock has not yet been cleared:
Sender (final sc_put) Debugfs reader
-------------------- --------------
sock_release(sc->sc_sock)
[socket can be freed]
sc_seq_show()
Lock debug lock Read sc_sock->sk fields Unlock debug lock
sc_sock = NULL
...
o2net_debug_del_sc()
Move o2net_debug_del_sc() before releasing either resource. Unlinking under the existing debug lock waits for an active formatter to finish and prevents later readers from selecting the container. This covers both socket fields and node fields, including nd_num in the stats formatter.
KASAN report as below:
BUG: KASAN: slab-use-after-free in string+0x42b/0x470
Read of size 1 at addr ffff88810f56fc90 by task python3/506
CPU: 0 UID: 0 PID: 506 Comm: python3 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
kasan_report+0xe0/0x110
string+0x42b/0x470
vsnprintf+0x330/0x1110
seq_printf+0x1a8/0x260
sc_seq_show+0x604/0x9f0
seq_read_iter+0x480/0x1110
seq_read+0x362/0x5a0
full_proxy_read+0x11f/0x180
vfs_read+0x1a0/0xc20
ksys_read+0x111/0x200
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f(User register dump omitted.)
</TASK>
Allocated by task 497:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x28d/0x610
o2nm_node_group_make_item+0xea/0x1a0
configfs_mkdir+0x762/0xca0
vfs_mkdir+0x399/0x7e0
filename_mkdirat+0x129/0x450
__x64_sys_mkdir+0x70/0xa0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 505:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x308/0x580
config_item_cleanup+0x14b/0x230
config_item_put+0x79/0x90
sc_put+0x454/0x6e0
o2net_send_message_vec+0x63d/0x1560
o2net_send_message+0xa6/0xe0
validation_send_write+0x17f/0x1d0
full_proxy_write+0x11f/0x180
vfs_write+0x25a/0x1010
ksys_write+0x111/0x200
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88810f56fc00
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 144 bytes inside of
freed 512-byte region [ffff88810f56fc00, ffff88810f56fe00)(Page and shadow-memory dumps omitted.)
--- fs/ocfs2/cluster/tcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/cluster/tcp.c +3 -2
@@ -391,6 +391,9 @@ static void sc_kref_release(struct kref *kref)sclog (sc,"releasing\n" ); +/* Unlink before freeing anything the debugfs readers dereference. */ +o2net_debug_del_sc (sc); +if (sc->sc_sock) {sock_release (sc->sc_sock); sc->sc_sock =NULL ;
@@ -400,8 +403,6 @@ static void sc_kref_release(struct kref *kref)o2nm_node_put (sc->sc_node); sc->sc_node =NULL ; -o2net_debug_del_sc (sc); -if (sc->sc_page)__free_page (sc->sc_page);kfree (sc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1491/3318 ocfs2: wait for filecheck kobject release after a failed add
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit a25c02af29c3e95128e4343fceb4bdace8e480a0 ]
The filecheck kobject and its release completion are embedded in ocfs2_super, so the osb must outlive the kobject. On a failed kobject_init_and_add(), creation clears fs_fcheck and calls kobject_put(), but returns without waiting for the release callback.
With CONFIG_DEBUG_KOBJECT_RELEASE, the last put queues delayed cleanup. Mount failure can then free the containing osb before the embedded release timer expires:
Mount failure Delayed cleanup
------------- ---------------
ocfs2_filecheck_create_sysfs()
kobject_init_and_add() fails
fs_fcheck = NULL
kobject_put()
queue delayed release
return to mount error cleanup
ocfs2_dismount_volume()
remove_sysfs() skips the wait
kfree(osb)
expire embedded release timer
access freed osb
The normal removal path waits for fs_kobj_unregister, but it returns early when fs_fcheck is NULL. The failed-add path therefore leaves the delayed work and its completion in freed storage.
Wait for the existing release completion after the failed-add kobject_put(), before returning to mount error cleanup. This keeps the enclosing osb alive until the kobject has finished releasing, matching the normal teardown path.
KASAN report as below:
BUG: KASAN: slab-use-after-free in __run_timers+0xa6d/0xa90
Write of size 8 at addr ffff8881178a5658 by task swapper/0/0
CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<IRQ>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? __run_timers+0xa6d/0xa90
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20e/0x420
? __run_timers+0xa6d/0xa90
kasan_report+0xe0/0x110
? __run_timers+0xa6d/0xa90
__run_timers+0xa6d/0xa90
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx___run_timers+0x10/0x10
? __lock_acquire+0x5a3/0x2140
? __pfx_do_raw_spin_lock+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
timer_expire_remote+0xfa/0x160
? __pfx_timer_expire_remote+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
tmigr_handle_remote_up+0x4ba/0x9d0
? __pfx_tmigr_handle_remote_up+0x10/0x10
? tmigr_handle_remote+0x21a/0x340
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? __pfx_tmigr_handle_remote_up+0x10/0x10
__walk_groups_from+0x5a/0x160
tmigr_handle_remote+0x24f/0x340
? __pfx_tmigr_handle_remote+0x10/0x10
? lock_acquire+0x190/0x300
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
run_timer_softirq+0x222/0x270
? __pfx_run_timer_softirq+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xb8/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
handle_softirqs+0x1fa/0x8d0
? __pfx_handle_softirqs+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? _raw_spin_unlock+0x23/0x40
? srso_alias_return_thunk+0x5/0xfbef5
? __hrtimer_rearm_deferred+0x1fb/0x5d0
__irq_exit_rcu+0x113/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20
RIP: 0010:pv_native_safe_halt+0xf/0x20
Code: fa 18 01 e9 ee 37 ff fa 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa eb 07 0f 00 2d 23 c7 14 00 fb f4 <e9> c7 37 ff fa 66 2e 0f 1f 84 00 00 00 00 00 66 90 90 90 90 90 90
RSP: 0018:ffffffff87c07cf8 EFLAGS: 00000206
RAX: 0000000000045d0f RBX: ffffffff87c2d4c0 RCX: ffffffff86111e95
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff815b508e
RBP: fffffbfff0f85a98 R08: 0000000000000001 R09: ffffed10310c68ba
R10: ffff8881886345d3 R11: 0000000000000000 R12: 0000000000000001
R13: 0000000000000000 R14: 1ffffffff0f80fa4 R15: dffffc0000000000
? ct_kernel_exit.constprop.0+0xc5/0xf0
? do_idle+0x3ae/0x650
default_idle+0x9/0x10
default_idle_call+0x6c/0xb0
do_idle+0x3ae/0x650
? __pfx___schedule+0x10/0x10
? __pfx_do_idle+0x10/0x10
? rest_init+0x1cd/0x330
? srso_alias_return_thunk+0x5/0xfbef5
cpu_startup_entry+0x54/0x60
rest_init+0x1e1/0x330
? __pfx_acpi_read_bit_register+0x10/0x10
? __pfx_rest_init+0x10/0x10
? acpi_os_write_port+0x23/0xb0
? __pfx_kernel_init+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? acpi_ut_status_exit+0xd6/0x180
? srso_alias_return_thunk+0x5/0xfbef5
? acpi_ut_status_exit+0xd6/0x180
? srso_alias_return_thunk+0x5/0xfbef5
? acpi_enable_subsystem+0x2b0/0x4e0
? __pfx_x86_late_time_init+0x10/0x10
start_kernel+0x417/0x4b0
x86_64_start_reservations+0x18/0x30
x86_64_start_kernel+0x111/0x120
common_startup_64+0x13e/0x158
</TASK>
Allocated by task 494:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x28d/0x610
ocfs2_initialize_super.isra.0+0xab/0x3070
ocfs2_fill_super+0x801/0x3920
get_tree_bdev_flags+0x35d/0x5f0
vfs_get_tree+0x93/0x320
fc_mount+0x1d/0x200
path_mount+0x592/0x1e00
__x64_sys_mount+0x24b/0x2d0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 494:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x308/0x580
ocfs2_dismount_volume+0x43c/0x9b0
ocfs2_fill_super+0x258f/0x3920
get_tree_bdev_flags+0x35d/0x5f0
vfs_get_tree+0x93/0x320
fc_mount+0x1d/0x200
path_mount+0x592/0x1e00
__x64_sys_mount+0x24b/0x2d0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff8881178a4000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 5720 bytes inside of
freed 8192-byte region [ffff8881178a4000, ffff8881178a6000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1178a0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100043880 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000020002 00000000f5000000 0000000000000000
head: 0200000000000040 ffff888100043880 dead000000000122 0000000000000000
head: 0000000000000000 0000000000020002 00000000f5000000 0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8881178a5500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881178a5580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881178a5600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881178a5680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881178a5700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- fs/ocfs2/filecheck.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ocfs2/filecheck.c +2 -0
@@ -189,6 +189,8 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)/* Mount failure still calls ocfs2_filecheck_remove_sysfs(). */ entry->fs_fcheck =NULL ;kobject_put (&entry->fs_kobj); +/* Keep ocfs2_super alive until the kobject is released. */ +wait_for_completion (&entry->fs_kobj_unregister);kfree (fcheck);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1492/3318 x86/init: Initialize wall clock in get_rtc_noop()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naman Jain <[email protected]>
[ Upstream commit 7d5af1f256fdecff6a7986bbc9146b69cb355bb5 ]
get_rtc_noop() is used when an RTC is unavailable, but leaves its output argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled, timekeeping_init() may therefore receive a nonzero invalid persistent clock value and warn:
"Persistent clock returned invalid value"
Initialize the output to zero, the documented representation of an unsupported persistent clock.
--- arch/x86/kernel/x86_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/x86_init.c +1 -1
@@ -36,7 +36,7 @@ static void iommu_shutdown_noop(void) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { }int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -void get_rtc_noop (struct timespec64 *now) { } +void get_rtc_noop (struct timespec64 *now) { *now = (struct timespec64 ){0 }; }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1493/3318 xfs: fix temporary cursor leak in btree shift corruption paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianyun Gao <[email protected]>
[ Upstream commit 2bbca049deeb1699cafd966cb2793fee576ee409 ]
In xfs_btree_lshift and xfs_btree_rshift, when XFS_IS_CORRUPT detects an invalid firstrec/lastrec result after xfs_btree_dup_cursor has successfully allocated a temporary cursor, the error path jumps to error0 which returns without freeing tcur. This leaks the cursor memory, the xfs_group reference, and the per-level buffer references held by the duplicated cursor. Jump to error1 instead, which calls xfs_btree_del_cursor(tcur, XFS_BTREE_ERROR) to properly release all resources.
--- fs/xfs/libxfs/xfs_btree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_btree.c +2 -2
@@ -2467,7 +2467,7 @@ xfs_btree_lshift( i =xfs_btree_firstrec (tcur, level);if (XFS_IS_CORRUPT (tcur->bc_mp, i !=1 )) { error = -EFSCORRUPTED ; - goto error0; + goto error1; } error =xfs_btree_decrement (tcur, level, &i);
@@ -2637,7 +2637,7 @@ xfs_btree_rshift( i =xfs_btree_lastrec (tcur, level);if (XFS_IS_CORRUPT (tcur->bc_mp, i !=1 )) { error = -EFSCORRUPTED ; - goto error0; + goto error1; } error =xfs_btree_increment (tcur, level, &i);
Signature · 1 line
2.53.0