5.15.224-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 120/571 netfilter: nf_tables: set->ops->insert returns opaque set element in case of EEXIST
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 078996fcd657e6e0c3a72b7d5806d04c32e74250 ]
Return struct nft_elem_priv instead of struct nft_set_ext for consistency with ("netfilter: nf_tables: expose opaque set element as struct nft_elem_priv") and to prepare the introduction of element timeout updates from control path.
Backport adaptation for Linux 5.15:
This tree represents opaque set elements as void pointers and does not have struct nft_elem_priv, the backend priv members, or nft_elem_priv_cast(). Use void ** for the insert output parameter and return the existing backend element pointer directly. Keep the frontend conversion through nft_set_elem_ext() when insertion returns -EEXIST.
Resolve the pipapo conflict by retaining its existing initialization of e at declaration and returning e directly. Update the output parameter's documentation and omit the unrelated timeout declaration reordering. No functions or element layout changes are introduced.
This preserves the catchall insertion context needed for target commit 70194dc37670bd08e44b471389861cc01bd3a3c9, whose two hunks apply unchanged.
Stable-dep-of: 70194dc37670 ("netfilter: nf_tables: skip expired catchall elements on insert and delete")
--- include/net/netfilter/nf_tables.h | 2 +- net/netfilter/nf_tables_api.c | 15 +++++++++------ net/netfilter/nft_set_bitmap.c | 4 ++-- net/netfilter/nft_set_hash.c | 8 ++++---- net/netfilter/nft_set_pipapo.c | 10 +++++----- net/netfilter/nft_set_rbtree.c | 10 +++++----- 6 files changed, 26 insertions(+), 23 deletions(-)
include/net/netfilter/nf_tables.h +1 -1
@@ -435,7 +435,7 @@ struct nft_set_ops {int (*insert)(const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext); +void **priv);void (*activate)(const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem);
net/netfilter/nf_tables_api.c +9 -6
@@ -6075,7 +6075,7 @@ EXPORT_SYMBOL_GPL(nft_set_catchall_lookup);static int nft_setelem_catchall_insert (const struct net *net,struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **pext) +void **priv) {struct nft_set_elem_catchall *catchall;u8 genmask =nft_genmask_next (net);
@@ -6084,7 +6084,7 @@ static int nft_setelem_catchall_insert(const struct net *net,list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (nft_set_elem_active (ext, genmask)) { - *pext = ext; + *priv = catchall->elem;return -EEXIST ; } }
@@ -6102,14 +6102,15 @@ static int nft_setelem_catchall_insert(const struct net *net,static int nft_setelem_insert (const struct net *net,struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext,unsigned int flags) +void **elem_priv, +unsigned int flags) {int ret;if (flags &NFT_SET_ELEM_CATCHALL ) - ret =nft_setelem_catchall_insert (net, set, elem, ext); + ret =nft_setelem_catchall_insert (net, set, elem, elem_priv);else - ret = set->ops->insert (net, set, elem, ext); + ret = set->ops->insert (net, set, elem, elem_priv);return ret; }
@@ -6255,6 +6256,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,struct nft_data_desc desc;enum nft_registers dreg;struct nft_trans *trans; +void *elem_priv;u64 timeout;u64 expiration;int err, i;
@@ -6549,9 +6551,10 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, ext->genmask =nft_genmask_cur (ctx->net); - err =nft_setelem_insert (ctx->net, set, &elem, &ext2, flags); + err =nft_setelem_insert (ctx->net, set, &elem, &elem_priv, flags); if (err) { if (err == -EEXIST) { + ext2 = nft_set_elem_ext(set, elem_priv); if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^ nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) || nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^
net/netfilter/nft_set_bitmap.c +2 -2
@@ -123,7 +123,7 @@ static void *nft_bitmap_get(const struct net *net, const struct nft_set *set,static int nft_bitmap_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_bitmap *priv =nft_set_priv (set);struct nft_bitmap_elem *new = elem->priv, *be;
@@ -132,7 +132,7 @@ static int nft_bitmap_insert(const struct net *net, const struct nft_set *set, be =nft_bitmap_elem_find (set, new, genmask);if (be) { - *ext = &be->ext; + *elem_priv = be;return -EEXIST ; }
net/netfilter/nft_set_hash.c +4 -4
@@ -168,7 +168,7 @@ static bool nft_rhash_update(struct nft_set *set, const u32 *key,static int nft_rhash_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rhash *priv =nft_set_priv (set);struct nft_rhash_elem *he = elem->priv;
@@ -185,7 +185,7 @@ static int nft_rhash_insert(const struct net *net, const struct nft_set *set,if (IS_ERR (prev))return PTR_ERR (prev);if (prev) { - *ext = &prev->ext; + *elem_priv = prev;return -EEXIST ; }return 0 ;
@@ -588,7 +588,7 @@ static u32 nft_jhash(const struct nft_set *set, const struct nft_hash *priv,static int nft_hash_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_hash_elem *this = elem->priv, *he;struct nft_hash *priv =nft_set_priv (set);
@@ -600,7 +600,7 @@ static int nft_hash_insert(const struct net *net, const struct nft_set *set,if (!memcmp (nft_set_ext_key (&this->ext),nft_set_ext_key (&he->ext), set->klen) &&nft_set_elem_active (&he->ext, genmask)) { - *ext = &he->ext; + *elem_priv = he;return -EEXIST ; } }
net/netfilter/nft_set_pipapo.c +5 -5
@@ -1233,13 +1233,13 @@ static struct nft_pipapo_match *pipapo_maybe_clone(const struct nft_set *set)* @net: Network namespace * @set: nftables API set representation * @elem: nftables API element representation containing key data -* @ext2: Filled with pointer to &struct nft_set_ext in inserted element +* @elem_priv: Filled with private pointer to inserted or existing element * * Return: 0 on success, error pointer on failure. */ static int nft_pipapo_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext2) +void **elem_priv) {const struct nft_set_ext *ext =nft_set_elem_ext (set, elem->priv);union nft_pipapo_map_bucket rulemap[NFT_PIPAPO_MAX_FIELDS ];
@@ -1274,7 +1274,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,if (!memcmp (start, dup_key->data,sizeof (*dup_key->data)) && !memcmp (end, dup_end->data,sizeof (*dup_end->data))) { - *ext2 = &dup->ext; + *elem_priv = dup;return -EEXIST ; }
@@ -1290,7 +1290,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,if (PTR_ERR (dup) != -ENOENT ) {if (IS_ERR (dup))return PTR_ERR (dup); - *ext2 = &dup->ext; + *elem_priv = dup;return -ENOTEMPTY ; }
@@ -1352,7 +1352,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,put_cpu_ptr (m->scratch); } - *ext2 = &e->ext; + *elem_priv = e;pipapo_map (m, rulemap, e);
net/netfilter/nft_set_rbtree.c +5 -5
@@ -319,7 +319,7 @@ static struct nft_rbtree_elem *nft_rbtree_prev_active(struct nft_rbtree_elem *rbstatic int __nft_rbtree_insert (const struct net *net,const struct nft_set *set,struct nft_rbtree_elem *new, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rbtree_elem *rbe, *rbe_le =NULL , *rbe_ge =NULL , *rbe_prev;struct rb_node *node, *next, *parent, **p, *first =NULL ;
@@ -437,7 +437,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,*/ if (rbe_ge && !nft_rbtree_cmp (set, new, rbe_ge) &&nft_rbtree_interval_start (rbe_ge) ==nft_rbtree_interval_start (new)) { - *ext = &rbe_ge->ext; + *elem_priv = rbe_ge;return -EEXIST ; }
@@ -446,7 +446,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,*/ if (rbe_le && !nft_rbtree_cmp (set, new, rbe_le) &&nft_rbtree_interval_end (rbe_le) ==nft_rbtree_interval_end (new)) { - *ext = &rbe_le->ext; + *elem_priv = rbe_le;return -EEXIST ; }
@@ -506,7 +506,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,static int nft_rbtree_insert (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem, -struct nft_set_ext **ext) +void **elem_priv) {struct nft_rbtree *priv =nft_set_priv (set);struct nft_rbtree_elem *rbe = elem->priv;
@@ -520,7 +520,7 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set,write_lock_bh (&priv->lock);write_seqcount_begin (&priv->count); - err =__nft_rbtree_insert (net, set, rbe, ext); + err =__nft_rbtree_insert (net, set, rbe, elem_priv);write_seqcount_end (&priv->count);write_unlock_bh (&priv->lock); }while (err == -EAGAIN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 121/571 netfilter: nf_tables: skip expired catchall elements on insert and delete
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
[ Upstream commit 70194dc37670bd08e44b471389861cc01bd3a3c9 ]
nft_setelem_catchall_insert() looks up duplicates with nft_set_elem_active() only, while nft_set_catchall_lookup() and the dump path additionally skip expired elements.
Once a catchall element with a timeout expires, this predicate drift makes it invisible to userspace dumps, yet it still blocks
re-insertion: with NLM_F_EXCL the request fails with -EEXIST, and without it the request reports success but silently inserts nothing. The stale entry only goes away when the (user-tunable) gc interval elapses, so the catchall rule may silently stop matching for an arbitrarily long time after its first expiration.
The delete path shows the same drift: nft_setelem_catchall_deactivate() picks the first active-next entry in the catchall list, so with an expired entry still pending GC it retires the stale entry instead of the fresh one, and it deactivates an element that userspace no longer sees instead of failing with -ENOENT.
Align both walks with the lookup and dump predicates: only an element that is active and not expired counts as a duplicate or delete candidate, using the per-netns timestamp taken at transaction start, in line with the set backend .insert/.deactivate and catchall GC sync paths.
--- net/netfilter/nf_tables_api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +8 -2
@@ -6079,11 +6079,14 @@ static int nft_setelem_catchall_insert(const struct net *net, {struct nft_set_elem_catchall *catchall;u8 genmask =nft_genmask_next (net); +u64 tstamp =nft_net_tstamp (net);struct nft_set_ext *ext;list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem); -if (nft_set_elem_active (ext, genmask)) { +if (nft_set_elem_active (ext, genmask) && + !__nft_set_elem_expired (ext, tstamp) && + !nft_set_elem_is_dead (ext)) { *priv = catchall->elem;return -EEXIST ; }
@@ -6144,11 +6147,14 @@ static int nft_setelem_catchall_deactivate(const struct net *net, struct nft_set_elem *elem) {struct nft_set_elem_catchall *catchall; +u64 tstamp =nft_net_tstamp (net);struct nft_set_ext *ext;list_for_each_entry (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem); -if (!nft_is_active_next (net, ext)) +if (!nft_is_active_next (net, ext) || +__nft_set_elem_expired (ext, tstamp) || +nft_set_elem_is_dead (ext))continue ;kfree (elem->priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 122/571 smb: client: use finish_no_open() for non-regular inodes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit e66cf1625ec4a3fe68346119f371def713fd0a4d ]
An O_CREAT open can find an existing symlink or another non-regular inode. cifs_atomic_open() calls finish_open() on it and attaches a cifsFileInfo. Symlink inodes have no CIFS release operation, so the dentry reference held by cifsFileInfo is leaked. FMODE_OPENED also prevents the VFS from following the symlink.
Track whether cifs_do_create() returned an open server handle. For non-regular inodes, close the handle if present, remove the pending open, and call finish_no_open() so the VFS can continue the lookup. Do not set FMODE_CREATED unless a regular file was opened. For O_NOFOLLOW with __O_REGULAR, return -ELOOP before the VFS's -EFTYPE check.
Defer closing a legacy POSIX handle on a non-regular inode until after inode lookup. This avoids closing it again if lookup fails.
--- fs/cifs/dir.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
fs/cifs/dir.c +27 -10
@@ -167,7 +167,7 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)static int cifs_do_create (struct inode *inode,struct dentry *direntry,unsigned int xid,struct tcon_link *tlink,unsigned oflags,umode_t mode, -__u32 *oplock,struct cifs_fid *fid) +__u32 *oplock,struct cifs_fid *fid,bool *opened) {int rc = -ENOENT ;int create_options =CREATE_NOT_DIR ;
@@ -182,6 +182,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,struct TCP_Server_Info *server = tcon->ses->server;struct cifs_open_parms oparms; + *opened = false; *oplock =0 ;if (tcon->ses->server->oplocks) *oplock =REQ_OPLOCK ;
@@ -199,6 +200,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, oflags, oplock, &fid->netfid, xid);switch (rc) {case 0 : + *opened = true;if (newinode ==NULL ) {/* query inode info */ goto cifs_create_get_file_info;
@@ -215,11 +217,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,/* * The server may allow us to open things like * FIFOs, but the client isn't set up to deal -* with that. If it's not a regular file, just -* close it and proceed as if it were a normal -* lookup. +* with that. Keep the handle until the caller +* can finish the lookup. */ -CIFSSMBClose (xid, tcon, fid->netfid); goto cifs_create_get_file_info; }/* success, no need to query */
@@ -314,6 +314,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,cifs_dbg (FYI ,"cifs_create returned 0x%x\n" , rc); goto out; } + *opened = true;/* * If Open reported that we actually created a file then we now have to
@@ -398,7 +399,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,return rc; out_err: -if (server->ops->close) +if (*opened && server->ops->close) server->ops->close (xid, tcon, fid);if (newinode)iput (newinode);
@@ -418,6 +419,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,struct cifs_pending_open open;__u32 oplock;struct cifsFileInfo *file_info; +bool is_regular; +bool opened;if (unlikely (cifs_forced_shutdown (CIFS_SB (inode->i_sb))))return -EIO ;
@@ -475,16 +478,29 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,cifs_add_pending_open (&fid, tlink, &open); rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, - &oplock, &fid); + &oplock, &fid, &opened);if (rc) {cifs_del_pending_open (&open); goto out; } -if ((oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) + is_regular =d_is_reg (direntry); +if (!is_regular || !opened) { +if (opened && server->ops->close) + server->ops->close (xid, tcon, &fid); +cifs_del_pending_open (&open); + } + +if (is_regular && opened && + (oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) file->f_mode |=FMODE_CREATED ; +if (!is_regular || !opened) { + rc =finish_no_open (file,NULL ); + goto out; + } + rc =finish_open (file, direntry, generic_file_open);if (rc) {if (server->ops->close)
@@ -534,6 +550,7 @@ int cifs_create(struct user_namespace *mnt_userns, struct inode *inode,struct TCP_Server_Info *server;struct cifs_fid fid;__u32 oplock; +bool opened;cifs_dbg (FYI ,"cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n" , inode, direntry, direntry);
@@ -555,8 +572,8 @@ int cifs_create(struct user_namespace *mnt_userns, struct inode *inode, server->ops->new_lease_key (&fid); rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, - &oplock, &fid); -if (!rc && server->ops->close) + &oplock, &fid, &opened); +if (!rc && opened && server->ops->close) server->ops->close (xid, tcon, &fid);cifs_put_tlink (tlink);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 123/571 smb: client: validate POSIX create context length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc ]
parse_posix_ctxt() reads the fixed nlink, reparse_tag, and mode fields before checking that the POSIX create context contains them. A short context can pass the generic checks and still make these fixed-width reads run past its declared data.
The current in-tree smb2_open_file() path passes a NULL posix pointer, so this handler is not reached on the ordinary open path. Still require the POSIX data to cover all three fields before reading them because the helper performs those unguarded reads. Keep the existing soft-failure behavior so malformed optional metadata does not fail the open.
--- fs/cifs/smb2pdu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +5 -2
@@ -2036,12 +2036,15 @@ static void parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info, struct create_posix_rsp *posix) { - int sid_len; u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset); -u8 *end = beg +le32_to_cpu (cc->DataLength); +u32 dlen =le32_to_cpu (cc->DataLength); +u8 *end = beg + dlen; +int sid_len;u8 *sid;memset (posix,0 ,sizeof (*posix)); +if (dlen <3 *sizeof (__le32)) +return ; posix->nlink =get_unaligned_le32 (beg); posix->reparse_tag =get_unaligned_le32 (beg +4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 124/571 Bluetooth: mgmt: fix race in read_unconf_index_list()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit b5dbb41b212c50c095a4dbee3017a84fe94f033b ]
read_unconf_index_list() counts unconfigured controllers before allocating its response, then checks the device flags again while filling it.
hci_dev_list_lock stabilizes list membership, but it does not serialize the per-device flags. During asynchronous controller setup, the worker can set HCI_UNCONFIGURED and clear HCI_SETUP between the two passes. A controller omitted from the allocation count can then become eligible for the fill pass, causing an out-of-bounds write to rp->index[].
Allocate space for every device on hci_dev_list. Since list membership cannot change while hci_dev_list_lock is held, the response remains large enough regardless of flag transitions. The reported count and response length still include only eligible unconfigured controllers.
--- net/bluetooth/mgmt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
net/bluetooth/mgmt.c +3 -6
@@ -459,13 +459,10 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev,read_lock (&hci_dev_list_lock); count =0 ; -list_for_each_entry (d, &hci_dev_list, list) { -if (d->dev_type ==HCI_PRIMARY && -hci_dev_test_flag (d,HCI_UNCONFIGURED )) - count++; - } +list_for_each_entry (d, &hci_dev_list, list) + count++; - rp_len =sizeof (*rp) + (2 * count); + rp_len =sizeof (*rp) + (sizeof (__le16) * count); rp =kmalloc (rp_len,GFP_ATOMIC );if (!rp) {read_unlock (&hci_dev_list_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 125/571 Bluetooth: btusb: Add IMC Networks QCA9377 to quirks table
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tibor Harcsa <[email protected]>
[ Upstream commit dc16388d45ecbd3be0d8c9424dbbaa2c81806578 ]
Add the USB ID (13d3:3503) for the IMC Networks Qualcomm Atheros QCA9377 Bluetooth controller to the btusb quirks table. This device requires Qualcomm Rome firmware and wideband speech support to function properly; otherwise, BLE scanning fails with HCI unexpected event opcode 0x2005 errors.
The device reports the following in /sys/kernel/debug/usb/devices:
P: Vendor=13d3 ProdID=3503 Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -301,6 +301,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3503), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, /* QCA WCN6855 chipset */ { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 126/571 HID: core: remove #ifdef CONFIG_PM from hid_driver
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit df8b030d82dd1224881acb4e778fa06c4824f72b ]
Allow HID drivers to pass ->suspend, ->resume and ->reset_resume via pm_ptr().
Through the usage of pm_ptr() the CONFIG_PM-dependent code will always be compiled, protecting against bitrot.
The linker will then garbage-collect the unused function avoiding any overhead.
The only overhead in the final kernel image and at runtime are a few extra bytes in 'struct hid_driver'.
The same approach is chosen by 'struct usb_driver' and other subsystems.
--- include/linux/hid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/hid.h +2 -2
@@ -815,11 +815,11 @@ struct hid_driver {void (*feature_mapping)(struct hid_device *hdev,struct hid_field *field,struct hid_usage *usage); -#ifdef CONFIG_PM +int (*suspend)(struct hid_device *hdev,pm_message_t message);int (*resume)(struct hid_device *hdev);int (*reset_resume)(struct hid_device *hdev); -#endif +/* private: */ struct device_driver driver; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 127/571 HID: hid-alps: use default remove for hid device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcus Folkesson <[email protected]>
[ Upstream commit 989f7cc94f1174269282a4a46bb735c7f11527de ]
hid_device_remove() will call hid_hw_stop() as default .remove function if no function is specified.
Stable-dep-of: aa9dde93e05a ("HID: alps: unregister DualPoint Stick input device on remove")
--- drivers/hid/hid-alps.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/hid/hid-alps.c +0 -6
@@ -825,11 +825,6 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)return 0 ; } -static void alps_remove (struct hid_device *hdev) -{ -hid_hw_stop (hdev); -} -static const struct hid_device_id alps_id[] = { {HID_DEVICE (HID_BUS_ANY ,HID_GROUP_ANY ,USB_VENDOR_ID_ALPS_JP ,HID_DEVICE_ID_ALPS_U1_DUAL ) },
@@ -847,7 +842,6 @@ static struct hid_driver alps_driver = { .name = "hid-alps", .id_table = alps_id, .probe = alps_probe, - .remove = alps_remove, .raw_event = alps_raw_event, .input_mapping = alps_input_mapping, .input_configured = alps_input_configured,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 128/571 HID: hid-alps: Use pm_ptr instead of #ifdef CONFIG_PM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Nocera <[email protected]>
[ Upstream commit 5e130f58629a2819c9d053507ad368160d25eb65 ]
This increases build coverage and allows to drop an #ifdef.
Stable-dep-of: aa9dde93e05a ("HID: alps: unregister DualPoint Stick input device on remove")
--- drivers/hid/hid-alps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-alps.c +2 -4
@@ -845,10 +845,8 @@ static struct hid_driver alps_driver = { .raw_event = alps_raw_event, .input_mapping = alps_input_mapping, .input_configured = alps_input_configured, -#ifdef CONFIG_PM - .resume = alps_post_resume, - .reset_resume = alps_post_reset, -#endif + .resume = pm_ptr(alps_post_resume), + .reset_resume = pm_ptr(alps_post_reset), };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 129/571 HID: alps: unregister DualPoint Stick input device on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit aa9dde93e05a837645fdfd577eea71f0733f0694 ]
alps_input_configured() allocates a second input device ("DualPoint Stick") with input_allocate_device() and registers it, but the alps_driver struct has no .remove handler and input2 is not tracked in hdev->inputs. The default remove path (hid_hw_stop -> hidinput_disconnect) only iterates hdev->inputs, so input2 is never unregistered and leaks on every device removal.
Add a .remove handler that stops the device first (preventing URB callbacks from touching input2 during teardown) and then unregisters input2.
--- drivers/hid/hid-alps.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/hid/hid-alps.c +19 -0
@@ -825,6 +825,24 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)return 0 ; } +static void alps_remove (struct hid_device *hdev) +{ +struct alps_dev *data =hid_get_drvdata (hdev); + +/* +* input2 ("DualPoint Stick") is allocated separately and is not +* tracked in hdev->inputs, so the default remove path +* (hid_hw_stop -> hidinput_disconnect) does not unregister it. +* +* Stop the device first so that no URB callback can touch input2 +* while it is being unregistered, then drop it explicitly. +*/ +hid_hw_stop (hdev); + +if (data->input2) +input_unregister_device (data->input2); +} +static const struct hid_device_id alps_id[] = { {HID_DEVICE (HID_BUS_ANY ,HID_GROUP_ANY ,USB_VENDOR_ID_ALPS_JP ,HID_DEVICE_ID_ALPS_U1_DUAL ) },
@@ -847,6 +865,7 @@ static struct hid_driver alps_driver = { .input_configured = alps_input_configured, .resume = pm_ptr(alps_post_resume), .reset_resume = pm_ptr(alps_post_reset), + .remove = alps_remove, };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 130/571 smb/client: use stack-allocated smb2_file_all_info in smb3_query_mf_symlink()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit fc8789bb57e625e5f32ac57ca2e7d3e7b7fda225 ]
SMB2_open() only fills the fixed fields, so a stack-allocated smb2_file_all_info is sufficient here.
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/cifs/link.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
fs/cifs/link.c +3 -12
@@ -384,7 +384,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,int buf_type =CIFS_NO_BUFFER ;__le16 *utf16_path;__u8 oplock =SMB2_OPLOCK_LEVEL_NONE ; -struct smb2_file_all_info *pfile_info =NULL ; +struct smb2_file_all_info file_info = {}; oparms.tcon = tcon; oparms.cifs_sb = cifs_sb;
@@ -398,20 +398,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,if (utf16_path ==NULL )return -ENOMEM ; - pfile_info =kzalloc (sizeof (struct smb2_file_all_info ) +PATH_MAX *2 , -GFP_KERNEL ); - -if (pfile_info ==NULL ) { -kfree (utf16_path); -return -ENOMEM ; - } - - rc =SMB2_open (xid, &oparms, utf16_path, &oplock, pfile_info,NULL , + rc =SMB2_open (xid, &oparms, utf16_path, &oplock, &file_info,NULL ,NULL ,NULL );if (rc) goto qmf_out_open_fail; -if (pfile_info->EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) { +if (file_info.EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) {/* it's not a symlink */ rc = -ENOENT ;/* Is there a better rc to return? */ goto qmf_out;
@@ -429,7 +421,6 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,SMB2_close (xid, tcon, fid.persistent_fid, fid.volatile_fid); qmf_out_open_fail:kfree (utf16_path); -kfree (pfile_info);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 131/571 smb/client: pass cifs_open_info_data to SMB2_open()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 1f551e407bb49dce0bbd34ed6a499dad69e18020 ]
Let SMB2_open() fill the smb2_file_all_info embedded in cifs_open_info_data directly. This removes the temporary smb2_file_all_info copy in smb2_open_file().
[5.15 dependency adaptation]
The cifs_open_info_data wrapper is absent from this stable tree. Keep the existing SMB2_open() argument type and callers, and use the file_info alias directly for the supplied smb2_file_all_info buffer. Drop the upstream caller and prototype changes instead of importing newer open and symlink handling APIs into fs/cifs.
Move the existing success trace after smb2_parse_contexts(), retaining the six-argument trace interface in 5.15. Together with the file_info alias, this provides the merge context needed by 566820af017e ("smb:
client: close handle after create-context parsing failure"). No functions are added, and the handle-close fix remains in the target commit.
[ sashal: Reduced backport -- upstream 1f551e407bb49 touches 4 file(s), this
backport carries 1. Not backported here:
fs/smb/client/link.c
fs/smb/client/smb2file.c
fs/smb/client/smb2pdu.c
fs/smb/client/smb2proto.h
This note is generated from the file lists only; see the resolution record for the reasoning. ]
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/cifs/smb2pdu.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
fs/cifs/smb2pdu.c +16 -15
@@ -2966,6 +2966,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,int resp_buftype =CIFS_NO_BUFFER ;int rc =0 ;int flags =0 ; +struct smb2_file_all_info *file_info = buf;cifs_dbg (FYI ,"create/open\n" );if (!ses || !server)
@@ -3008,10 +3009,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, tcon->need_reconnect = true; } goto creat_exit; - }else -trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, - ses->Suid, oparms->create_options, - oparms->desired_access); + }atomic_inc (&tcon->num_remote_opens); oparms->fid->persistent_fid = rsp->PersistentFileId;
@@ -3021,21 +3019,24 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, oparms->fid->mid =le64_to_cpu (rsp->hdr.MessageId);#endif /* CIFS_DEBUG2 */ -if (buf) { - buf->CreationTime = rsp->CreationTime; - buf->LastAccessTime = rsp->LastAccessTime; - buf->LastWriteTime = rsp->LastWriteTime; - buf->ChangeTime = rsp->ChangeTime; - buf->AllocationSize = rsp->AllocationSize; - buf->EndOfFile = rsp->EndofFile; - buf->Attributes = rsp->FileAttributes; - buf->NumberOfLinks =cpu_to_le32 (1 ); - buf->DeletePending =0 ; +if (file_info) { + file_info->CreationTime = rsp->CreationTime; + file_info->LastAccessTime = rsp->LastAccessTime; + file_info->LastWriteTime = rsp->LastWriteTime; + file_info->ChangeTime = rsp->ChangeTime; + file_info->AllocationSize = rsp->AllocationSize; + file_info->EndOfFile = rsp->EndofFile; + file_info->Attributes = rsp->FileAttributes; + file_info->NumberOfLinks =cpu_to_le32 (1 ); + file_info->DeletePending =0 ; } rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, - oparms->fid->lease_key, oplock, buf, posix); + oparms->fid->lease_key, oplock, file_info, posix); + +trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, + oparms->create_options, oparms->desired_access); creat_exit:SMB2_open_free (&rqst);free_rsp_buf (resp_buftype, rsp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 132/571 smb: client: close handle after create-context parsing failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 566820af017e81497fb5e9d3ad6e7ffe2828bc8b ]
SMB2_open() accounts a successful CREATE response as a remote open before parsing its create contexts. If smb2_parse_contexts() rejects malformed context data, SMB2_open() returns without closing the handle, leaving the server-side handle open and num_remote_opens elevated.
Close the handle after a post-CREATE context parsing failure so the error path releases the remote resource and balances the open count.
--- fs/cifs/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb2pdu.c +3 -0
@@ -3034,6 +3034,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, oparms->fid->lease_key, oplock, file_info, posix); +if (rc) +SMB2_close (xid, tcon, oparms->fid->persistent_fid, + oparms->fid->volatile_fid);trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, oparms->create_options, oparms->desired_access);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 133/571 smb: client: close completed creates on compound wait errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 ]
compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.
Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.
--- fs/cifs/smb2misc.c | 9 ++++--- fs/cifs/transport.c | 62 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 15 deletions(-)
fs/cifs/smb2misc.c +6 -3
@@ -787,7 +787,8 @@ smb2_cancelled_close_fid(struct work_struct *work)*/ static int __smb2_handle_cancelled_cmd (struct cifs_tcon *tcon,__u16 cmd,__u64 mid, -__u64 persistent_fid,__u64 volatile_fid) +__u64 persistent_fid,__u64 volatile_fid, +bool account_remote_open) {struct close_cancelled_open *cancelled;
@@ -801,6 +802,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, cancelled->cmd = cmd; cancelled->mid = mid;INIT_WORK (&cancelled->work, smb2_cancelled_close_fid); +if (account_remote_open) +atomic_inc (&tcon->num_remote_opens);WARN_ON (queue_work (cifsiod_wq, &cancelled->work) == false);return 0 ;
@@ -837,7 +840,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,spin_unlock (&cifs_tcp_ses_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , - persistent_fid, volatile_fid); + persistent_fid, volatile_fid, false);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_close);
@@ -865,7 +868,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *servele16_to_cpu (hdr->Command),le64_to_cpu (hdr->MessageId), rsp->PersistentFileId, - rsp->VolatileFileId); + rsp->VolatileFileId, true);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_mid);
fs/cifs/transport.c +50 -12
103 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 134/571 ALSA: usb-audio: Apply IGNORE_CTL_ERROR quirk to all Audient devices
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a154f7b9f197b3d5e41fa3ad62083f5aa93b1fe8 ]
Faaris reported a problem with Audient EVO4 device and it turned out to be a regression by the recent fix commit 87a6f2fa6e6c ("ALSA:
usb-audio: Propagate write errors in generic mixer put callbacks"). It exhibited that the hardware gives errors at accessing the mixer unit 10 on certain channels, and the change above made it a fatal error.
We had already a quirk for Audient iD14 to work around such errors from the mixer controls, and we can simply apply the same for EVO4. OTOH, it's highly possible that other Audient devices suffer from the same issue; they must be using similar firmware, after all.
So, in this patch, we apply the quirk generically to all devices with the vendor ID Audient (2708), instead. Ignoring the control error isn't usually less critical than overreaction to the firmware misbehavior.
--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
@@ -1947,8 +1947,6 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_SET_IFACE_FIRST),DEVICE_FLG (0x262a ,0x9302 ,/* ddHiFi TC44C */ QUIRK_FLAG_DSD_RAW ), -DEVICE_FLG (0x2708 ,0x0002 ,/* Audient iD14 */ -QUIRK_FLAG_IGNORE_CTL_ERROR ),DEVICE_FLG (0x2772 ,0x0502 ,/* Musical Fidelity M6s DAC */ 0 ),/* for avoiding QUIRK_FLAG_DSD_RAW with vendor match */ DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */
@@ -2006,6 +2004,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_DSD_RAW),VENDOR_FLG (0x25ce ,/* Mytek devices */ QUIRK_FLAG_DSD_RAW ), +VENDOR_FLG (0x2708 ,/* Audient devices */ +QUIRK_FLAG_IGNORE_CTL_ERROR ),VENDOR_FLG (0x278b ,/* Rotel? */ QUIRK_FLAG_DSD_RAW ), VENDOR_FLG(0x292b, /* Gustard/Ess based devices */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 135/571 audit: fix exe mark UAF in kill_rules()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
commit aa650d87a498844060eecb1d336f4d46f4d1b0b3 upstream.
kill_rules() removes mixed AUDIT_DIR and AUDIT_EXE rules when an audit tree is pruned. It drops entry->rule.exe before removing the rule from the RCU-visible filter lists.
After a rule has been installed with AUDIT_ADD_RULE, which requires CAP_AUDIT_CONTROL, removing the watched directory can race with another task that is still evaluating the rule. In that case, fsnotify can free the executable mark before the reader reaches audit_mark_compare(), causing a use-after-free.
KASAN reports:
BUG: KASAN: slab-use-after-free in audit_mark_compare+0x8d/0xa0
Unlink the published rules from the RCU-visible lists and retain them on tree->rules for cleanup. If any rule has an executable mark, wait for a single RCU grace period before removing the marks and scheduling the entries for freeing. Otherwise, call_rcu() already provides the required deferred freeing without a synchronous wait.
--- kernel/audit_tree.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/audit_tree.c +20 -4
@@ -543,22 +543,38 @@ static void kill_rules(struct audit_cont {struct audit_krule *rule, *next;struct audit_entry *entry; +bool need_sync = false;list_for_each_entry_safe (rule, next, &tree->rules, rlist) { entry = container_of(rule, struct audit_entry, rule); -list_del_init (&rule->rlist);if (rule->tree) {/* not a half-baked one */ audit_tree_log_remove_rule (context, rule); -if (entry->rule.exe) -audit_remove_mark (entry->rule.exe); rule->tree =NULL ;list_del_rcu (&entry->list);list_del (&entry->rule.list); -call_rcu (&entry->rcu, audit_free_rule_rcu); +if (entry->rule.exe) + need_sync = true; + }else { +list_del_init (&rule->rlist); } } + +if (list_empty (&tree->rules)) +return ; + +if (need_sync) +synchronize_rcu (); + +list_for_each_entry_safe (rule, next, &tree->rules, rlist) { + entry = container_of(rule, struct audit_entry, rule); + +list_del_init (&rule->rlist); +if (entry->rule.exe) +audit_remove_mark (entry->rule.exe); +call_rcu (&entry->rcu, audit_free_rule_rcu); + } }/*
Greg Kroah-Hartman
maintainerPATCH 136/571 of/irq: Fix remaining refcount leaks in of_irq_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 30724547b221e0e670ddfef140fc7d816b2aaec6 upstream.
Successfully initialized controllers are moved to intc_parent_list, but the final cleanup only frees the descriptors. The device node references taken with of_node_get() and the interrupt parent references are therefore leaked on the normal return path. Drop both before kfree(), as the intc_desc_list cleanup already does.
--- drivers/of/irq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/irq.c +2 -0
@@ -582,6 +582,8 @@ void __init of_irq_init(const struct of_list_for_each_entry_safe (desc, temp_desc, &intc_parent_list, list) {list_del (&desc->list); +of_node_put (desc->interrupt_parent); +of_node_put (desc->dev);kfree (desc); } err:
Greg Kroah-Hartman
maintainerPATCH 137/571 of/overlay: put property on deadprops only after changeset add succeeds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 814f2da6995772c07a7c9c2cc6028b6e3f3ecc9c upstream.
add_changeset_property() links a new property of a not-yet-live target node into the node's deadprops list before handing it to of_changeset_add_property(). If that fails, the error path frees the property but leaves the freed pointer linked in deadprops, and of_node_release() frees it a second time when the aborted overlay's node is released.
Record the changeset entry first and link the property into deadprops only on success. of_changeset_add_property() never looks at the node's property lists, so the order of the two steps is otherwise immaterial, and the error path frees a property that nothing references.
--- drivers/of/overlay.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/of/overlay.c +4 -3
@@ -346,12 +346,13 @@ static int add_changeset_property(structreturn -ENOMEM ;if (!prop) { -if (!target->in_livetree) { + ret =of_changeset_add_property (&ovcs->cset, target->np, + new_prop); +/* the detached node owns the property until the apply */ +if (!ret && !target->in_livetree) { new_prop->next = target->np->deadprops; target->np->deadprops = new_prop; } - ret =of_changeset_add_property (&ovcs->cset, target->np, - new_prop); }else { ret =of_changeset_update_property (&ovcs->cset, target->np, new_prop);
Greg Kroah-Hartman
maintainerPATCH 138/571 of/overlay: only treat a positive changeset id as registered
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 44081d708b5b885487bac792db78324b7b4c267d upstream.
of_overlay_fdt_apply() stores the idr_alloc() return value in ovcs->id before checking it. On failure the stored id is negative, free_overlay_changeset()'s "if (ovcs->id)" check passes, idr_remove() is called with a negative id and list_del() runs on ovcs->ovcs_list, which is not initialized until after the id allocation. An allocation failure at that point dereferences NULL.
Make free_overlay_changeset() treat only a strict-positive id as registered. The rest of the function already copes with a partially-initialized ovcs, so the error path stays a plain goto err_free_ovcs.
--- drivers/of/overlay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/overlay.c +2 -1
@@ -840,7 +840,8 @@ static void free_overlay_changeset(strucif (ovcs->cset.entries.next)of_changeset_destroy (&ovcs->cset); -if (ovcs->id) { +/* a failed idr_alloc() leaves its negative error in ovcs->id */ +if (ovcs->id >0 ) {idr_remove (&ovcs_idr, ovcs->id);list_del (&ovcs->ovcs_list); ovcs->id =0 ;
Greg Kroah-Hartman
maintainerPATCH 139/571 netfilter: nft_flow_offload: drop flowtable reference on init error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit 747928b5d4ff8c8de55138a54c13980e4bb88578 upstream.
nft_flow_offload_init() bumps the flowtable use count with nft_use_inc() before calling nf_ct_netns_get(). When the latter fails, the error is returned as-is and the reference is leaked.
The upper layers do not balance it either: nf_tables_newexpr() clears expr->ops when the expression init callback fails, so the nft_expr_more() iteration in nft_rule_expr_deactivate() and nf_tables_rule_destroy() stops right before the failed expression and its ->destroy callback, which would drop the reference, never runs.
Each failed rule addition therefore leaks one flowtable reference and the flowtable can no longer be removed: NFT_MSG_DELFLOWTABLE keeps reporting -EBUSY even though no rule references it.
Save the nf_ct_netns_get() return value and undo the nft_use_inc() when it fails, restoring the inc/dec pairing within nft_flow_offload_init() itself.
--- net/netfilter/nft_flow_offload.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nft_flow_offload.c +6 -1
@@ -394,6 +394,7 @@ static int nft_flow_offload_init(const sstruct nft_flow_offload *priv =nft_expr_priv (expr);u8 genmask =nft_genmask_next (ctx->net);struct nft_flowtable *flowtable; +int err;if (!tb[NFTA_FLOW_TABLE_NAME ])return -EINVAL ;
@@ -408,7 +409,11 @@ static int nft_flow_offload_init(const s priv->flowtable = flowtable; -return nf_ct_netns_get (ctx->net, ctx->family); + err =nf_ct_netns_get (ctx->net, ctx->family); +if (err <0 ) +nft_use_dec (&flowtable->use); + +return err; } static void nft_flow_offload_deactivate(const struct nft_ctx *ctx,
Greg Kroah-Hartman
maintainerPATCH 140/571 net/packet: prevent TX_RING byte count overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilkka Lappeteläinen <[email protected]>
commit 2cf81fc9505b148b1b70068303ea6ea4b1212403 upstream.
tpacket_snd() drains every SEND_REQUEST frame in a TX ring and adds each valid packet length to the signed int len_sum. Userspace can recycle completed frames concurrently, so a single blocking send call is not bounded by the ring size.
After enough successful transmissions len_sum wraps into the negative range. In particular, 65536 65535-byte frames followed by a 65007-byte frame produce 0xfffffdef, or -EIOCBQUEUED. sock_sendmsg_nosec() treats that as an impossible return and triggers a BUG. On systems configured to panic on oops, a CAP_NET_RAW holder can panic the host kernel.
Stop before the next frame would make the byte count exceed INT_MAX. The positive short count leaves that frame pending for a later send call.
A two-thread TPACKET_V2 reproducer triggered the BUG on an arm64 build of Linux 7.3-rc4. With this change, the same reproducer returned the expected positive short count without an oops.
--- net/packet/af_packet.c | 3 +++ 1 file changed, 3 insertions(+)
net/packet/af_packet.c +3 -0
@@ -2871,6 +2871,9 @@ static int tpacket_snd(struct packet_soc vnet_hdr.hdr_len); has_vnet_hdr = true; } +/* Prevent the byte count from wrapping into a negative errno */ +if (unlikely (tp_len >INT_MAX - len_sum)) +break ; copylen =max_t (int, copylen, hard_header_len); skb = sock_alloc_send_skb(&po->sk, hlen + tlen + sizeof(struct sockaddr_ll) +
Greg Kroah-Hartman
maintainerPATCH 141/571 rtc: spear: initialize IRQ state before requesting alarm IRQ
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 055ef5ce9f67a6a3a1363fa663007f8196cc0fb8 upstream.
devm_request_irq() enables the interrupt before it returns, so the handler may run while probe is still initializing the device. Initialize the MMIO address and spinlock before requesting the alarm IRQ.
--- drivers/rtc/rtc-spear.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/rtc/rtc-spear.c +6 -5
@@ -357,6 +357,12 @@ static int spear_rtc_probe(struct platfoif (irq <0 )return irq; + config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (config->ioaddr)) +return PTR_ERR (config->ioaddr); + +spin_lock_init (&config->lock); + status =devm_request_irq (&pdev->dev, irq, spear_rtc_irq,0 , pdev->name, config);if (status) {
@@ -365,10 +371,6 @@ static int spear_rtc_probe(struct platforeturn status; } - config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (config->ioaddr)) -return PTR_ERR (config->ioaddr); - config->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (config->clk))return PTR_ERR (config->clk);
@@ -377,7 +379,6 @@ static int spear_rtc_probe(struct platfoif (status <0 )return status; -spin_lock_init (&config->lock);platform_set_drvdata (pdev, config); config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
Greg Kroah-Hartman
maintainerPATCH 142/571 sctp: check RCV_SHUTDOWN after the sendmsg connect wait
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
commit 4f1da630d13de0370e2f6361f961f1c8b384af1c upstream.
sctp_wait_for_connect() drops the socket lock while it sleeps. An out-of-the-blue ABORT can then be processed from the socket backlog and unlink the association. If a concurrent shutdown(fd, SHUT_RD) sets RCV_SHUTDOWN, the waiter breaks with err == 0 before checking asoc->base.dead. Its final sctp_association_put() can then free the association, leaving sctp_sendmsg_to_asoc() to continue with a dangling pointer.
Check RCV_SHUTDOWN along with the wait error in sctp_sendmsg_to_asoc() before using the association again. The check only accesses the socket, so it needs no additional association reference. Return the existing -ESRCH so that sctp_sendmsg() skips freeing a new association that may already have been destroyed.
Keep sctp_wait_for_connect() unchanged to preserve its behavior for the connect() caller.
--- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -1844,7 +1844,7 @@ static int sctp_sendmsg_to_asoc(struct sif (asoc->ep->intl_enable) { timeo =sock_sndtimeo (sk,0 ); err =sctp_wait_for_connect (asoc, &timeo); -if (err) { +if (err || sk->sk_shutdown &RCV_SHUTDOWN ) { err = -ESRCH ; goto err; }
Greg Kroah-Hartman
maintainerPATCH 143/571 wifi: cfg80211: avoid double free if updating BSS fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Berg <[email protected]>
[ Upstream commit acc44cbd7727115f9381c35c2898b1b5af665ec8 ]
cfg80211_update_known_bss will always consume the passed IEs. As such, cfg80211_update_assoc_bss_entry also needs to always set the pointers to NULL so that no double free can occur.
Note that hitting this would probably require being connected to a hidden BSS which is then doing a channel switch while also switching to be not hidden anymore at the same time.
--- net/wireless/scan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/wireless/scan.c +3 -4
@@ -2756,10 +2756,9 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,if (new) {/* to save time, update IEs for transmitting bss only */ -if (cfg80211_update_known_bss (rdev, cbss, new, false)) { - new->pub.proberesp_ies =NULL ; - new->pub.beacon_ies =NULL ; - } +cfg80211_update_known_bss (rdev, cbss, new, false); + new->pub.proberesp_ies =NULL ; + new->pub.beacon_ies =NULL ; list_for_each_entry_safe(nontrans_bss, tmp, &new->pub.nontrans_list,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 144/571 drm/msm/adreno: Assign msm_gpu->pdev earlier to avoid nullptrs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 16007768551d5bfe53426645401435ca8d2ef54f ]
There are some cases, such as the one uncovered by Commit 46d4efcccc68 ("drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails") where
msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
is called on gpu->pdev == NULL, as the GPU device has not been fully initialized yet.
Turns out that there's more than just the aforementioned path that causes this to happen (e.g. the case when there's speedbin data in the catalog, but opp-supported-hw is missing in DT).
Assigning msm_gpu->pdev earlier seems like the least painful solution to this, therefore do so.
Patchwork: https://patchwork.freedesktop.org/patch/602742/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 ++ drivers/gpu/drm/msm/msm_gpu.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -0
@@ -934,6 +934,8 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu->revn = adreno_gpu->info->revn; adreno_gpu->rev = config->rev; + gpu->pdev = pdev; + adreno_gpu_config.ioname ="kgsl_3d0_reg_memory" ; adreno_gpu_config.nr_rings = nr_rings;
drivers/gpu/drm/msm/msm_gpu.c +0 -1
@@ -900,7 +900,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,if (IS_ERR (gpu->gpu_cx)) gpu->gpu_cx =NULL ; - gpu->pdev = pdev;platform_set_drvdata (pdev, &gpu->adreno_smmu);msm_devfreq_init (gpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 145/571 drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 46d4efcccc688cbacdd70a238bedca510acaa8e4 ]
Calling a6xx_destroy() before adreno_gpu_init() leads to a null pointer dereference on:
msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
as gpu->pdev is only assigned in:
a6xx_gpu_init()
|_ adreno_gpu_init
|_ msm_gpu_init()
Instead of relying on handwavy null checks down the cleanup chain, explicitly de-allocate the LLC data and free a6xx_gpu instead.
Patchwork: https://patchwork.freedesktop.org/patch/588919/
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -1
@@ -1867,7 +1867,8 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) ret =a6xx_set_supported_hw (&pdev->dev, config->rev);if (ret) { -a6xx_destroy (&(a6xx_gpu->base.base)); +a6xx_llc_slices_destroy (a6xx_gpu); +kfree (a6xx_gpu);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 146/571 openvswitch: add nf_ct_is_confirmed check before assigning the helper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 3c1860543fccc1d0cfe3fd6b190e414a418fe60e ]
A WARN_ON call trace would be triggered when 'ct(commit, alg=helper)' applies on a confirmed connection:
WARNING: CPU: 0 PID: 1251 at net/netfilter/nf_conntrack_extend.c:98 RIP: 0010:nf_ct_ext_add+0x12d/0x150 [nf_conntrack] Call Trace: <TASK> nf_ct_helper_ext_add+0x12/0x60 [nf_conntrack] __nf_ct_try_assign_helper+0xc4/0x160 [nf_conntrack] __ovs_ct_lookup+0x72e/0x780 [openvswitch] ovs_ct_execute+0x1d8/0x920 [openvswitch] do_execute_actions+0x4e6/0xb60 [openvswitch] ovs_execute_actions+0x60/0x140 [openvswitch] ovs_packet_cmd_execute+0x2ad/0x310 [openvswitch] genl_family_rcv_msg_doit.isra.15+0x113/0x150 genl_rcv_msg+0xef/0x1f0
which can be reproduced with these OVS flows:
table=0, in_port=veth1,tcp,tcp_dst=2121,ct_state=-trk actions=ct(commit, table=1)
table=1, in_port=veth1,tcp,tcp_dst=2121,ct_state=+trk+new actions=ct(commit, alg=ftp),normal
The issue was introduced by commit 248d45f1e193 ("openvswitch: Allow attaching helper in later commit") where it somehow removed the check of nf_ct_is_confirmed before asigning the helper. This patch is to fix it by bringing it back.
--- net/openvswitch/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/conntrack.c +2 -1
@@ -1037,7 +1037,8 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,* connections which we will commit, we may need to attach * the helper here. */ -if (info->commit && info->helper && !nfct_help (ct)) { +if (!nf_ct_is_confirmed (ct) && info->commit && + info->helper && !nfct_help (ct)) {int err =__nf_ct_try_assign_helper (ct, info->ct,GFP_ATOMIC );if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 147/571 rds_tcp: close NULL deref window in rds_tcp_set_callbacks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
commit d2bfdbb69cf87676981b1043010b6224d84c6d3a upstream.
rds_tcp_set_callbacks() links a new rds_tcp_connection onto rds_tcp_tc_list under rds_tcp_tc_list_lock. It releases the lock, then assigns tc->t_sock = sock outside the lock.
rds_tcp_tc_info() and rds6_tcp_tc_info() walk rds_tcp_tc_list under the same lock. Both dereference tc->t_sock->sk without a NULL check.
A reader can acquire rds_tcp_tc_list_lock between the writer's spin_unlock and the t_sock store. It then sees a list entry whose t_sock is NULL. The dereference of tc->t_sock->sk is a NULL access.
Move tc->t_sock = sock inside rds_tcp_tc_list_lock, before list_add_tail. A reader holding the lock then observes the linkage and the t_sock store together.
The restore path is safe. rds_tcp_restore_callbacks() does list_del_init inside the lock. The matching tc->t_sock = NULL after unlink is harmless to readers holding the lock.
[ achender: resolved context conflict; tc->t_rtn initialization is not
present in this tree ]
--- net/rds/tcp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/rds/tcp.c +6 -3
@@ -231,16 +231,19 @@ void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp)rdsdebug ("setting sock %p callbacks to tc %p\n" , sock, tc);write_lock_bh (&sock->sk->sk_callback_lock); -/* done under the callback_lock to serialize with write_space */ +/* done under the callback_lock to serialize with write_space. +* Set t_sock inside rds_tcp_tc_list_lock so readers walking +* rds_tcp_tc_list under the same lock cannot observe an +* entry whose t_sock is NULL. +*/ spin_lock (&rds_tcp_tc_list_lock); + tc->t_sock = sock;list_add_tail (&tc->t_list_item, &rds_tcp_tc_list);spin_unlock (&rds_tcp_tc_list_lock);/* accepted sockets need our listen data ready undone */ if (sock->sk->sk_data_ready == rds_tcp_listen_data_ready) sock->sk->sk_data_ready = sock->sk->sk_user_data; - - tc->t_sock = sock; tc->t_cpath = cp; tc->t_orig_data_ready = sock->sk->sk_data_ready; tc->t_orig_write_space = sock->sk->sk_write_space;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 148/571 vxlan: use one headroom snapshot for neighbour replies
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 481506a756dcd828ef42391cb08f38d8d96d38fc ]
vxlan_na_create() samples LL_RESERVED_SPACE() to size the reply skb and then samples it again to reserve headroom. A concurrent vxlan_changelink() can update needed_headroom between the two reads, creating a TOCTOU race. The second value can exceed the allocation and make the Ethernet header write out of bounds.
The race is reproducible on the unpatched kernel. It occurred when vxlan_na_create() generated a neighbour reply while vxlan_changelink() changed the link headroom. KASAN caught a four-byte write two bytes beyond a 704-byte skbuff_small_head allocation.
Snapshot the headroom once and use that value for both allocation and reservation.
--- drivers/net/vxlan/vxlan_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -2
@@ -2086,13 +2086,15 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,struct ipv6hdr *pip6;u8 *daddr;int na_olen =8 ;/* opt hdr + ETH_ALEN for target */ +int headroom;int ns_olen;int i, len;if (dev ==NULL || !pskb_may_pull (request, request->len))return NULL ; - len =LL_RESERVED_SPACE (dev) +sizeof (struct ipv6hdr ) + + headroom =LL_RESERVED_SPACE (dev); + len = headroom +sizeof (struct ipv6hdr ) +sizeof (*na) + na_olen + dev->needed_tailroom; reply =alloc_skb (len,GFP_ATOMIC );if (reply ==NULL )
@@ -2100,7 +2102,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request, reply->protocol =htons (ETH_P_IPV6 ); reply->dev = dev; -skb_reserve (reply,LL_RESERVED_SPACE (request->dev)); +skb_reserve (reply, headroom);skb_push (reply,sizeof (struct ethhdr ));skb_reset_mac_header (reply);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 149/571 of/irq: add missing of_node_put() for interrupt parent node
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clément Léger <[email protected]>
[ Upstream commit eb2b4ecf7299ee39ee9cecc4d3f2633aeb10cefb ]
After calling of_irq_parse_one(), the node provided in the of_phandle_args has a refcount increment by one. Add missing of_node_put in of_irq_get() to decrement the refcount once used.
--- drivers/of/irq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/of/irq.c +9 -3
@@ -407,10 +407,16 @@ int of_irq_get(struct device_node *dev, int index)return rc; domain =irq_find_host (oirq.np); -if (!domain) -return -EPROBE_DEFER ; +if (!domain) { + rc = -EPROBE_DEFER ; + goto out; + } -return irq_create_of_mapping (&oirq); + rc =irq_create_of_mapping (&oirq); +out: +of_node_put (oirq.np); + +return rc; }EXPORT_SYMBOL_GPL (of_irq_get);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 150/571 vt: skip screen update for DEC alignment test on backgroup consoles
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
commit 0928ed9bd7946baee911efa401088697836e3b1e upstream.
[BUG]
Recently, we encountered a KASAN warning as follows:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0x11f/0x140 Read of size 1 at addr ff1100015fd9f6a4 by task tty_fbcon_oob/1239 CPU: 7 UID: 0 PID: 1239 Comm: tty_fbcon_oob Not tainted 7.3.0-rc1 #100 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc41 04/01/2014 Call Trace: <TASK> ... kasan_report+0xf0/0x120 fb_pad_aligned_buffer+0x11f/0x140 ccw_putcs+0x86c/0xa80 fbcon_putcs+0x338/0x410 do_update_region+0x21d/0x450 do_con_write+0x1e0e/0x4880 con_write+0x13/0x80 n_tty_write+0x374/0x1010 file_tty_write.isra.0+0x404/0x7a0 ...
reproduce:
1) open /dev/tty0, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 8 and op.height = 16 (visible VC1)
2) open /dev/tty1, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 28 and op.height = 24 (invisible VC2)
3) echo 3 > /sys/devices/virtual/graphics/fbcon/rotate_all
4) write EShash8(esc hash8) to tty1
[CAUSE]
All VCs render to the framebuffer. setfont only modifies the target VC's font without resizing the framebuffer backing buffer (par->rotated.buf); the buffer is only resized for the visible VC (fbcon_do_set_font -> ... -> vc_do_resize -> update_screen). This relies on the con_should_update() check performed before every update_region().
However, the ESC # 8 path (do_con_trol -> do_update_region) omits the con_should_update() check. After changing the font size of an invisible VC, do_update_region() fills using the new font size against a buffer that was never resized, causing an out-of-bounds access.
[FIX]
Only push the update when the console is visible and not blanked, add the con_should_update() check in the do_con_trol() like every other call site of do_update_region() (update_region(), invert_screen(), ...).
--- drivers/tty/vt/vt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vt/vt.c +2 -1
@@ -2543,7 +2543,8 @@ static void do_con_trol(struct tty_struccsi_J (vc,2 ); vc->vc_video_erase_char = (vc->vc_video_erase_char &0xff00 ) |' ' ; -do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); +if (con_should_update (vc)) +do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); }return ;case ESsetG0:
Greg Kroah-Hartman
maintainerPATCH 151/571 ALSA: caiaq: unregister the input device when probe fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
commit 0b7bd20f6379bc5e431fd74d866390f5b5b63f3c upstream.
setup_card() registers the input device, whose name and phys point into struct snd_usb_caiaqdev, and then goes on to snd_card_register() and snd_usb_caiaq_control_init(). If either fails, snd_probe() calls snd_card_free(), which frees the device state but leaves the input device registered: card_free() only clears the pointer, and the input device is unregistered from snd_disconnect() alone. Reading its "uevent" attribute afterwards dereferences freed memory:
BUG: KASAN: slab-use-after-free in string+0x4a9/0x4f0 Read of size 1 at addr ffff8880208f5043 by task caiaq/4967 add_uevent_var+0x183/0x3a0 input_dev_uevent+0x162/0x900 dev_uevent+0x2f1/0x870 uevent_show+0x1ca/0x3a0 ...
Unregister the input device on the probe error path, as snd_disconnect() does. snd_usb_caiaq_input_disconnect() is a no-op when no input device was registered.
Reproduced with a raw-gadget Audio Kontrol 1 and a temporary hack that makes snd_usb_caiaq_control_init() fail.
--- sound/usb/caiaq/device.c | 3 +++ 1 file changed, 3 insertions(+)
sound/usb/caiaq/device.c +3 -0
@@ -562,6 +562,9 @@ static int snd_probe(struct usb_interfac ret =init_card (caiaqdev (card));if (ret <0 ) {dev_err (&usb_dev->dev,"unable to init card! (ret=%d)\n" , ret); +#ifdef CONFIG_SND_USB_CAIAQ_INPUT +snd_usb_caiaq_input_disconnect (caiaqdev (card)); +#endif snd_card_free (card);return ret; }
Greg Kroah-Hartman
maintainerPATCH 152/571 ALSA: line6: reject oversized playback packets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 61b0a5a114fa4552892da5c0ff2f42e63bf08c6b upstream.
Each playback URB is handed a slice of out.buffer that is exactly LINE6_ISO_PACKETS * max_packet_size_out bytes, sized from the OUT endpoint, but the number of bytes written into that slice is never compared against it.
submit_audio_out_urb() takes the frame count from prev_fsize, which audio_in_callback() derived from the *IN* endpoint's received packet length, and rescales it with the playback frame size; when prev_fsize is still zero it synthesizes a length from the sample rate instead. On a device declaring a large IN wMaxPacketSize and a small OUT wMaxPacketSize, the resulting memcpy(), or the memset() when the playback stream is idle, runs past its slice and, as the reproducer below shows, beyond the allocation.
usb_submit_urb() is not a backstop. max_packet_size_out comes from usb_maxpacket(), which returns only the low 11 bits of wMaxPacketSize, while USB core validates a high-speed isochronous length against that base scaled by usb_endpoint_maxp_mult(). A length of up to three times the allocated slice is therefore accepted, and even a rejected URB is only rejected after the write.
Reject a packet that does not fit the slice the driver allocated for it. Clamping it instead would silently shorten the capture-derived rate feedback and desynchronize the two streams.
BUG: KASAN: slab-out-of-bounds in submit_audio_out_urb (sound/usb/line6/playback.c:229) Write of size 1024 at addr ffff888100bbd400 by task kworker/1:2/5002 Workqueue: events line6_startup_work Call Trace: __asan_memcpy (mm/kasan/shadow.c:106) submit_audio_out_urb (sound/usb/line6/playback.c:229) line6_submit_audio_out_all_urbs (sound/usb/line6/playback.c:291) line6_stream_start (sound/usb/line6/pcm.c:194) line6_pcm_acquire (sound/usb/line6/pcm.c:337) line6_startup_work (sound/usb/line6/driver.c:728) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) The buggy address belongs to the object at ffff888100bbd400 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 0 bytes inside of allocated 256-byte region [ffff888100bbd400, ffff888100bbd500)
--- sound/usb/line6/playback.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/line6/playback.c +7 -0
@@ -182,6 +182,13 @@ static int submit_audio_out_urb(struct s fsize *= bytes_per_frame; +if (fsize > line6pcm->max_packet_size_out) { +dev_err (line6pcm->line6->ifcdev, +"playback packet too large: %d > %d\n" , + fsize, line6pcm->max_packet_size_out); +return -EMSGSIZE ; + } + fout->offset = urb_size; fout->length = fsize; urb_size += fsize;
Greg Kroah-Hartman
maintainerPATCH 153/571 perf/core: Fix WARN in perf_sigtrap()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
[ Upstream commit 3da6bb419750f3ad834786d6ba7c9d5d062c770b ]
Since exit_task_work() runs after perf_event_exit_task_context() updated ctx->task to TASK_TOMBSTONE, perf_sigtrap() from perf_pending_task() might observe event->ctx->task == TASK_TOMBSTONE.
Swap the early exit tests in order not to hit WARN_ON_ONCE().
--- kernel/events/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/events/core.c +7 -7
@@ -6691,18 +6691,18 @@ void perf_event_wakeup(struct perf_event *event)static void perf_sigtrap (struct perf_event *event) {/* -* We'd expect this to only occur if the irq_work is delayed and either -* ctx->task or current has changed in the meantime. This can be the -* case on architectures that do not implement arch_irq_work_raise(). +* Both perf_pending_task() and perf_pending_irq() can race with the +* task exiting. */ -if (WARN_ON_ONCE (event->ctx->task != current)) +if (current->flags &PF_EXITING )return ;/* -* Both perf_pending_task() and perf_pending_irq() can race with the -* task exiting. +* We'd expect this to only occur if the irq_work is delayed and either +* ctx->task or current has changed in the meantime. This can be the +* case on architectures that do not implement arch_irq_work_raise(). */ -if (current->flags &PF_EXITING ) +if (WARN_ON_ONCE (event->ctx->task != current))return ; send_sig_perf((void __user *)event->pending_addr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 154/571 watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit 573601521277119f2e2ba5f28ae6e87fc594f4d4 ]
When the cpu5wdt module is removing, the origin code uses del_timer() to de-activate the timer. If the timer handler is running, del_timer() could not stop it and will return directly. If the port region is released by release_region() and then the timer handler cpu5wdt_trigger() calls outb() to write into the region that is released, the use-after-free bug will happen.
Change del_timer() to timer_shutdown_sync() in order that the timer handler could be finished before the port region is released.
--- drivers/watchdog/cpu5wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/cpu5wdt.c +1 -1
@@ -252,7 +252,7 @@ static void cpu5wdt_exit(void)if (cpu5wdt_device.queue) { cpu5wdt_device.queue =0 ;wait_for_completion (&cpu5wdt_device.stop); -del_timer (&cpu5wdt_device.timer); +timer_shutdown_sync (&cpu5wdt_device.timer); }misc_deregister (&cpu5wdt_misc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 155/571 hsr: Remove WARN_ONCE() in hsr_addr_is_self().
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit afd0f17ca46258cec3a5cc48b8df9327fe772490 ]
syzbot reported the warning [0] in hsr_addr_is_self(), whose assumption is simply wrong.
hsr->self_node is cleared in hsr_del_self_node(), which is called from hsr_dellink().
Since dev->rtnl_link_ops->dellink() is called before unregister_netdevice_many(), there is a window when user can find the device but without hsr->self_node.
Let's remove WARN_ONCE() in hsr_addr_is_self().
[0]:
HSR: No self node
WARNING: net/hsr/hsr_framereg.c:39 at hsr_addr_is_self+0x211/0x3f0 net/hsr/hsr_framereg.c:39, CPU#0: syz.4.16848/17220
Modules linked in:
CPU: 0 UID: 0 PID: 17220 Comm: syz.4.16848 Tainted: G L syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
RIP: 0010:hsr_addr_is_self+0x211/0x3f0 net/hsr/hsr_framereg.c:39
Code: 33 2f 41 0f b7 dd 89 ee 09 de 31 ff e8 c8 b4 c6 f6 09 dd 74 54 e8 0f b0 c6 f6 31 ed eb 53 e8 06 b0 c6 f6 48 8d 3d 2f 50 9c 04 <67> 48 0f b9 3a 31 ed eb 42 e8 c1 13 1f 00 89 c5 31 ff 89 c6 e8 96
RSP: 0018:ffffc900041c70e0 EFLAGS: 00010283
RAX: ffffffff8afdc6ca RBX: ffffffff8afdc4e6 RCX: 0000000000080000
RDX: ffffc90010493000 RSI: 0000000000000948 RDI: ffffffff8f9a1700
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: ffffc900041c71e8 R11: fffff52000838e3f R12: dffffc0000000000
R13: ffff888041f9e3c0 R14: ffff888086ee3802 R15: 0000000000000000
FS: 00007f6fe985d6c0(0000) GS:ffff888126176000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f80bd437dac CR3: 0000000025096000 CR4: 00000000003526f0
DR0: ffffffffffffffff DR1: 00000000000001f8 DR2: 0000000000000002
DR3: ffffffffefffff15 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
check_local_dest net/hsr/hsr_forward.c:592 [inline]
fill_frame_info net/hsr/hsr_forward.c:728 [inline]
hsr_forward_skb+0xa11/0x2a80 net/hsr/hsr_forward.c:739
hsr_dev_xmit+0x253/0x370 net/hsr/hsr_device.c:236
__netdev_start_xmit include/linux/netdevice.h:5368 [inline]
netdev_start_xmit include/linux/netdevice.h:5377 [inline]
xmit_one net/core/dev.c:3888 [inline]
dev_hard_start_xmit+0x2df/0x860 net/core/dev.c:3904
__dev_queue_xmit+0x1428/0x3900 net/core/dev.c:4870
neigh_output include/net/neighbour.h:556 [inline]
ip_finish_output2+0xcec/0x10b0 net/ipv4/ip_output.c:237
ip_send_skb net/ipv4/ip_output.c:1510 [inline]
ip_push_pending_frames+0x8b/0x110 net/ipv4/ip_output.c:1530
raw_sendmsg+0x1547/0x1a50 net/ipv4/raw.c:659
sock_sendmsg_nosec net/socket.c:787 [inline]
__sock_sendmsg net/socket.c:802 [inline]
____sys_sendmsg+0x7da/0x9c0 net/socket.c:2698
___sys_sendmsg+0x2a5/0x360 net/socket.c:2752
__sys_sendmsg net/socket.c:2784 [inline]
__do_sys_sendmsg net/socket.c:2789 [inline]
__se_sys_sendmsg net/socket.c:2787 [inline]
__x64_sys_sendmsg+0x1c3/0x2a0 net/socket.c:2787
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6feb62ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6fe985d028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f6feb8a6090 RCX: 00007f6feb62ce59
RDX: 0000000000000000 RSI: 0000200000000000 RDI: 0000000000000004
RBP: 00007f6feb6c2d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f6feb8a6128 R14: 00007f6feb8a6090 R15: 00007ffcf01cc488
</TASK>--- net/hsr/hsr_framereg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/hsr/hsr_framereg.c +1 -3
@@ -45,10 +45,8 @@ bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr)rcu_read_lock (); sn =rcu_dereference (hsr->self_node); -if (!sn) { -WARN_ONCE (1 ,"HSR: No self node\n" ); +if (!sn) goto out; - }if (ether_addr_equal (addr, sn->macaddress_A) ||ether_addr_equal (addr, sn->macaddress_B))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 156/571 scsi: qla2xxx: Initialize NVMe abort_work once at submission
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit 7e85f6dbc85616de2172bce8eaf84b387a723cd1 ]
qla_nvme_fcp_abort() and qla_nvme_ls_abort() ran INIT_WORK() on priv->abort_work immediately before schedule_work(). INIT_WORK() reinitializes the work_struct, resetting its list head and clearing the pending bit. If an abort is issued more than once for the same command (for example, concurrent transport teardown and a timeout-driven abort), the second INIT_WORK() reinitializes a work item that is already queued, which can corrupt the workqueue list and lead to crashes or a looping worker.
Initialize priv->abort_work once at command submission, next to the existing per-command spin_lock_init(&priv->cmd_lock), and leave only schedule_work() in the abort paths. schedule_work() already does nothing when the work item is still pending, so a repeated abort no longer disturbs an in-flight work item. The command is not returned to the transport until the final kref_put()/release callback runs after abort_work has completed, so the work item is idle before priv is reused and the single submission-time INIT_WORK() is safe.
--- drivers/scsi/qla2xxx/qla_nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_nvme.c +2 -2
@@ -304,7 +304,6 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -INIT_WORK (&priv->abort_work, qla_nvme_abort_work);schedule_work (&priv->abort_work); }
@@ -342,6 +341,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, priv->sp = sp;kref_init (&sp->cmd_kref);spin_lock_init (&priv->cmd_lock); +INIT_WORK (&priv->abort_work, qla_nvme_abort_work); nvme = &sp->u.iocb_cmd; priv->fd = fd; nvme->u.nvme.desc = fd;
@@ -386,7 +386,6 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -INIT_WORK (&priv->abort_work, qla_nvme_abort_work);schedule_work (&priv->abort_work); }
@@ -646,6 +645,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,kref_init (&sp->cmd_kref);spin_lock_init (&priv->cmd_lock); +INIT_WORK (&priv->abort_work, qla_nvme_abort_work); sp->priv = priv; priv->sp = sp; sp->type =SRB_NVME_CMD ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 157/571 scsi: qla2xxx: Fix NVMe abort reference leak on repeated abort
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit 06b5b2a5d499323f1c3256ead35798e8e3d15e60 ]
qla_nvme_ls_abort() and qla_nvme_fcp_abort() take a command reference with kref_get_unless_zero() and then call schedule_work() on priv->abort_work, ignoring its return value. qla_nvme_abort_work() runs once and drops exactly one reference via kref_put(&sp->cmd_kref, sp->put_fn).
Since the per-abort INIT_WORK() was moved to submission time, schedule_work() now returns false when the work is already pending, for example on a concurrent transport teardown and timeout-driven abort of the same command. In that case the reference taken for the second abort is never released because the work still executes only once, leaking a reference. The command is then never returned to the NVMe-FC transport, which can hang the port.
Drop the reference when schedule_work() returns false, so each kref_get_unless_zero() is balanced regardless of whether the work was newly queued. The held reference keeps priv->sp valid for the put.
--- drivers/scsi/qla2xxx/qla_nvme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_nvme.c +4 -2
@@ -304,7 +304,8 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -schedule_work (&priv->abort_work); +if (!schedule_work (&priv->abort_work)) +kref_put (&priv->sp->cmd_kref, priv->sp->put_fn); } static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
@@ -386,7 +387,8 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -schedule_work (&priv->abort_work); +if (!schedule_work (&priv->abort_work)) +kref_put (&priv->sp->cmd_kref, priv->sp->put_fn); }static inline int qla2x00_start_nvme_mq (srb_t *sp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 158/571 mtd: core: clear out unregistered devices a bit more
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
[ Upstream commit 00596576a05145a1b5672897a82ef87af00becf4 ]
This allows an MTD device that has been unregistered to be easily re-registered later without triggering spurious "already registered" warnings in mtd_device_parse_register() and add_mtd_device().
Stable-dep-of: 12b31d1acd20 ("mtd: core: call _get_device() with the master MTD")
--- drivers/mtd/mtdcore.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +6 -1
@@ -750,6 +750,9 @@ int del_mtd_device(struct mtd_info *mtd)device_unregister (&mtd->dev); +/* Clear dev so mtd can be safely re-registered later if desired */ +memset (&mtd->dev,0 ,sizeof (mtd->dev)); +idr_remove (&mtd_idr, mtd->index);of_node_put (mtd_get_of_node (mtd));
@@ -1031,8 +1034,10 @@ int mtd_device_unregister(struct mtd_info *master) {int err; -if (master->_reboot) +if (master->_reboot) {unregister_reboot_notifier (&master->reboot_notifier); +memset (&master->reboot_notifier,0 ,sizeof (master->reboot_notifier)); + }if (master->otp_user_nvmem)nvmem_unregister (master->otp_user_nvmem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 159/571 mtd: core: Drop duplicate NULL checks around nvmem_unregister()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit bcf4ef28b0839a55bfae75b2bf4794c1d7244e61 ]
Since nvmem_unregister() checks for NULL, no need to repeat in the caller. Drop duplicate NULL checks.
Stable-dep-of: 12b31d1acd20 ("mtd: core: call _get_device() with the master MTD")
--- drivers/mtd/mtdcore.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/mtd/mtdcore.c +4 -9
@@ -745,8 +745,7 @@ int del_mtd_device(struct mtd_info *mtd)debugfs_remove_recursive (mtd->dbg.dfs_dir);/* Try to remove the NVMEM provider */ -if (mtd->nvmem) -nvmem_unregister (mtd->nvmem); +nvmem_unregister (mtd->nvmem);device_unregister (&mtd->dev);
@@ -927,8 +926,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)return 0 ; err: -if (mtd->otp_user_nvmem) -nvmem_unregister (mtd->otp_user_nvmem); +nvmem_unregister (mtd->otp_user_nvmem);return err; }
@@ -1039,11 +1037,8 @@ int mtd_device_unregister(struct mtd_info *master)memset (&master->reboot_notifier,0 ,sizeof (master->reboot_notifier)); } -if (master->otp_user_nvmem) -nvmem_unregister (master->otp_user_nvmem); - -if (master->otp_factory_nvmem) -nvmem_unregister (master->otp_factory_nvmem); +nvmem_unregister (master->otp_user_nvmem); +nvmem_unregister (master->otp_factory_nvmem); err =del_mtd_partitions (master);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 160/571 mtd: core: Fix refcount error in del_mtd_device()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shang XiaoJing <[email protected]>
[ Upstream commit 56570bdad5e31c5c538cd6efff5c4510256e1bb4 ]
del_mtd_device() will call of_node_put() to mtd_get_of_node(mtd), which is mtd->dev.of_node. However, memset(&mtd->dev, 0) is called before of_node_put(). As the result, of_node_put() won't do anything in del_mtd_device(), and causes the refcount leak.
del_mtd_device()
memset(&mtd->dev, 0, sizeof(mtd->dev) # clear mtd->dev
of_node_put()
mtd_get_of_node(mtd) # mtd->dev is cleared, can't locate of_node
# of_node_put(NULL) won't do anythingFix the error by caching the pointer of the device_node.
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /spi/spi-sram@0
CPU: 3 PID: 275 Comm: python3 Tainted: G N 6.1.0-rc3+ #54
0d8a1edddf51f172ff5226989a7565c6313b08e2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x67/0x83
kobject_get+0x155/0x160
of_node_get+0x1f/0x30
of_fwnode_get+0x43/0x70
fwnode_handle_get+0x54/0x80
fwnode_get_nth_parent+0xc9/0xe0
fwnode_full_name_string+0x3f/0xa0
device_node_string+0x30f/0x750
pointer+0x598/0x7a0
vsnprintf+0x62d/0x9b0
...
cfs_overlay_release+0x30/0x90
config_item_release+0xbe/0x1a0
config_item_put+0x5e/0x80
configfs_rmdir+0x3bd/0x540
vfs_rmdir+0x18c/0x320
do_rmdir+0x198/0x330
__x64_sys_rmdir+0x2c/0x40
do_syscall_64+0x37/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcdStable-dep-of: 12b31d1acd20 ("mtd: core: call _get_device() with the master MTD")
--- drivers/mtd/mtdcore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +3 -1
@@ -724,6 +724,7 @@ int del_mtd_device(struct mtd_info *mtd) {int ret;struct mtd_notifier *not; +struct device_node *mtd_of_node;mutex_lock (&mtd_table_mutex);
@@ -742,6 +743,7 @@ int del_mtd_device(struct mtd_info *mtd) mtd->index, mtd->name, mtd->usecount); ret = -EBUSY ; }else { + mtd_of_node =mtd_get_of_node (mtd);debugfs_remove_recursive (mtd->dbg.dfs_dir);/* Try to remove the NVMEM provider */
@@ -753,7 +755,7 @@ int del_mtd_device(struct mtd_info *mtd)memset (&mtd->dev,0 ,sizeof (mtd->dev));idr_remove (&mtd_idr, mtd->index); -of_node_put (mtd_get_of_node (mtd)); +of_node_put (mtd_of_node);module_put (THIS_MODULE ); ret =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 161/571 mtd: use refcount to prevent corruption
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomas Winkler <[email protected]>
[ Upstream commit 19bfa9ebebb5ec0695def57eb1d80de7e9cab369 ]
When underlying device is removed mtd core will crash in case user space is holding open handle. Need to use proper refcounting so device is release only when has no users.
Stable-dep-of: 12b31d1acd20 ("mtd: core: call _get_device() with the master MTD")
--- drivers/mtd/mtdcore.c | 72 ++++++++++++++++++++++------------------- drivers/mtd/mtdcore.h | 1 + drivers/mtd/mtdpart.c | 14 ++++---- include/linux/mtd/mtd.h | 2 +- 4 files changed, 49 insertions(+), 40 deletions(-)
drivers/mtd/mtdcore.c +39 -33
@@ -92,10 +92,33 @@ static void mtd_release(struct device *dev)struct mtd_info *mtd =dev_get_drvdata (dev);dev_t index =MTD_DEVT (mtd->index); +if (mtd_is_partition (mtd)) +release_mtd_partition (mtd); +/* remove /dev/mtdXro node */ device_destroy (&mtd_class, index +1 ); } +static void mtd_device_release (struct kref *kref) +{ + struct mtd_info *mtd = container_of(kref, struct mtd_info, refcnt); + +debugfs_remove_recursive (mtd->dbg.dfs_dir); + +/* Try to remove the NVMEM provider */ +nvmem_unregister (mtd->nvmem); + +device_unregister (&mtd->dev); + +/* Clear dev so mtd can be safely re-registered later if desired */ +memset (&mtd->dev,0 ,sizeof (mtd->dev)); + +idr_remove (&mtd_idr, mtd->index); +of_node_put (mtd_get_of_node (mtd)); + +module_put (THIS_MODULE ); +} +#define MTD_DEVICE_ATTR_RO (name) \ static DEVICE_ATTR(name, 0444, mtd_##name##_show, NULL)
@@ -623,7 +646,7 @@ int add_mtd_device(struct mtd_info *mtd) } mtd->index = i; - mtd->usecount =0 ; +kref_init (&mtd->refcnt);/* default value if not set by driver */ if (mtd->bitflip_threshold ==0 )
@@ -724,7 +747,6 @@ int del_mtd_device(struct mtd_info *mtd) {int ret;struct mtd_notifier *not; -struct device_node *mtd_of_node;mutex_lock (&mtd_table_mutex);
@@ -738,28 +760,8 @@ int del_mtd_device(struct mtd_info *mtd)list_for_each_entry (not, &mtd_notifiers, list) not->remove (mtd); -if (mtd->usecount) { -printk (KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n" , - mtd->index, mtd->name, mtd->usecount); - ret = -EBUSY ; - }else { - mtd_of_node =mtd_get_of_node (mtd); -debugfs_remove_recursive (mtd->dbg.dfs_dir); - -/* Try to remove the NVMEM provider */ -nvmem_unregister (mtd->nvmem); - -device_unregister (&mtd->dev); - -/* Clear dev so mtd can be safely re-registered later if desired */ -memset (&mtd->dev,0 ,sizeof (mtd->dev)); - -idr_remove (&mtd_idr, mtd->index); -of_node_put (mtd_of_node); - -module_put (THIS_MODULE ); - ret =0 ; - } +kref_put (&mtd->refcnt, mtd_device_release); + ret =0 ; out_error:mutex_unlock (&mtd_table_mutex);
@@ -1158,19 +1160,21 @@ int __get_mtd_device(struct mtd_info *mtd)if (!try_module_get (master->owner))return -ENODEV ; +kref_get (&mtd->refcnt); +if (master->_get_device) { err = master->_get_device (mtd);if (err) { +kref_put (&mtd->refcnt, mtd_device_release);module_put (master->owner);return err; } } - master->usecount++; -while (mtd->parent) { - mtd->usecount++; +if (IS_ENABLED (CONFIG_MTD_PARTITIONED_MASTER ) || mtd->parent != master) +kref_get (&mtd->parent->refcnt); mtd = mtd->parent; }
@@ -1229,18 +1233,20 @@ void __put_mtd_device(struct mtd_info *mtd) {struct mtd_info *master =mtd_get_master (mtd); -while (mtd->parent) { - --mtd->usecount; -BUG_ON (mtd->usecount <0 ); - mtd = mtd->parent; - } +while (mtd != master) { +struct mtd_info *parent = mtd->parent; - master->usecount--; +kref_put (&mtd->refcnt, mtd_device_release); + mtd = parent; + }if (master->_put_device) master->_put_device (master);module_put (master->owner); + +if (IS_ENABLED (CONFIG_MTD_PARTITIONED_MASTER )) +kref_put (&master->refcnt, mtd_device_release); }EXPORT_SYMBOL_GPL (__put_mtd_device);
drivers/mtd/mtdcore.h +1 -0
@@ -12,6 +12,7 @@ int __must_check add_mtd_device(struct mtd_info *mtd);int del_mtd_device (struct mtd_info *mtd);int add_mtd_partitions (struct mtd_info *,const struct mtd_partition *,int );int del_mtd_partitions (struct mtd_info *); +void release_mtd_partition (struct mtd_info *mtd);struct mtd_partitions ;
drivers/mtd/mtdpart.c +8 -6
@@ -31,6 +31,12 @@ static inline void free_partition(struct mtd_info *mtd)kfree (mtd); } +void release_mtd_partition (struct mtd_info *mtd) +{ +WARN_ON (!list_empty (&mtd->part.node)); +free_partition (mtd); +} +static struct mtd_info *allocate_partition (struct mtd_info *parent,const struct mtd_partition *part,int partno,uint64_t cur_offset)
@@ -309,13 +315,11 @@ static int __mtd_del_partition(struct mtd_info *mtd)sysfs_remove_files (&mtd->dev.kobj, mtd_partition_attrs); +list_del_init (&mtd->part.node); err =del_mtd_device (mtd);if (err)return err; -list_del (&mtd->part.node); -free_partition (mtd); -return 0 ; }
@@ -334,6 +338,7 @@ static int __del_mtd_partitions(struct mtd_info *mtd)__del_mtd_partitions (child);pr_info ("Deleting %s MTD partition\n" , child->name); +list_del_init (&child->part.node); ret =del_mtd_device (child);if (ret <0 ) { pr_err("Error when deleting partition \"%s\" (%d)\n",
@@ -341,9 +346,6 @@ static int __del_mtd_partitions(struct mtd_info *mtd) err = ret;continue ; } - -list_del (&child->part.node); -free_partition (child); }return err;
include/linux/mtd/mtd.h +1 -1
@@ -377,7 +377,7 @@ struct mtd_info {struct module *owner;struct device dev; -int usecount; +struct kref refcnt;struct mtd_debug_info dbg;struct nvmem_device *nvmem;struct nvmem_device *otp_user_nvmem;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 162/571 mtd: call external _get and _put in right order
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
[ Upstream commit 79c4a56250216991f1d965ee26dcd273376e4e91 ]
MTD provider provides mtd_info object to mtd subsystem. With kref patch the mtd_info object can be alive after provider released mtd device.
Fix calling order in _get and _put functions to allow mtd provider to safely alloc and release mtd object.
Execute:
1) call external _get
2) get_module
3) add internal kref
in the get function and opposite order in the put one.
The _put_device callback should be the last in put as the master struct memory may be freed in this callback.
Stable-dep-of: 12b31d1acd20 ("mtd: core: call _get_device() with the master MTD")
--- drivers/mtd/mtdcore.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/mtd/mtdcore.c +14 -14
@@ -1157,21 +1157,20 @@ int __get_mtd_device(struct mtd_info *mtd)struct mtd_info *master =mtd_get_master (mtd);int err; -if (!try_module_get (master->owner)) -return -ENODEV ; - -kref_get (&mtd->refcnt); -if (master->_get_device) { err = master->_get_device (mtd); - -if (err) { -kref_put (&mtd->refcnt, mtd_device_release); -module_put (master->owner); +if (err)return err; - } } +if (!try_module_get (master->owner)) { +if (master->_put_device) + master->_put_device (master); +return -ENODEV ; + } + +kref_get (&mtd->refcnt); +while (mtd->parent) {if (IS_ENABLED (CONFIG_MTD_PARTITIONED_MASTER ) || mtd->parent != master)kref_get (&mtd->parent->refcnt);
@@ -1240,13 +1239,14 @@ void __put_mtd_device(struct mtd_info *mtd) mtd = parent; } -if (master->_put_device) - master->_put_device (master); +if (IS_ENABLED (CONFIG_MTD_PARTITIONED_MASTER )) +kref_put (&master->refcnt, mtd_device_release);module_put (master->owner); -if (IS_ENABLED (CONFIG_MTD_PARTITIONED_MASTER )) -kref_put (&master->refcnt, mtd_device_release); +/* must be the last as master can be freed in the _put_device */ +if (master->_put_device) + master->_put_device (master); }EXPORT_SYMBOL_GPL (__put_mtd_device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 163/571 mtd: core: call _get_device() with the master MTD
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 12b31d1acd20b3185bb5f0748db0cf6874c8e9d1 ]
__get_mtd_device() calls the master's _get_device() callback with mtd, which may be a partition. __put_mtd_device() passes the master.
This breaks gluebi partitions because gluebi_get_device() uses container_of() and therefore requires the master MTD. Pass the master to _get_device(), matching _put_device().
--- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
@@ -1158,7 +1158,7 @@ int __get_mtd_device(struct mtd_info *mtd)int err;if (master->_get_device) { - err = master->_get_device (mtd); + err = master->_get_device (master);if (err)return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 164/571 nvmet: preserve device path on allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit 2f271b812170d4cad578bae1f91db72f3c2e36e7 ]
nvmet_ns_device_path_store() frees the old path before allocating its replacement, losing the existing configuration if allocation fails. Allocate the new path before freeing the old one.
--- drivers/nvme/target/configfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvme/target/configfs.c +6 -3
@@ -339,6 +339,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,struct nvmet_subsys *subsys = ns->subsys;size_t len;int ret; +char *new_path =NULL ;mutex_lock (&subsys->lock); ret = -EBUSY ;
@@ -350,12 +351,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,if (!len) goto out_unlock; -kfree (ns->device_path); ret = -ENOMEM ; - ns->device_path =kmemdup_nul (page, len,GFP_KERNEL ); -if (!ns->device_path) + new_path =kmemdup_nul (page, len,GFP_KERNEL ); +if (!new_path) goto out_unlock; +kfree (ns->device_path); + ns->device_path = new_path; +mutex_unlock (&subsys->lock);return count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 165/571 of/overlay: dont leak fragment references when changeset init fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 1d62f0f2bc7edb12ed09f71203df0e47fa4efca4 ]
init_overlay_changeset() stores the number of initialized fragments in ovcs->count only on full success. When find_target() or the __symbols__ lookup fails partway through, the target and overlay references taken for the fragments initialized so far are never
dropped: free_overlay_changeset() bounds its cleanup loop by ovcs->count, which is still 0.
Store the running count on the error path so free_overlay_changeset() puts whatever was set up. The store is guarded by ovcs->fragments because on the allocation-failure path cnt still holds the counting pass total while there is no fragments array; everywhere else cnt only counts fully-initialized fragments.
--- drivers/of/overlay.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/of/overlay.c +4 -0
@@ -830,6 +830,10 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs) err_out:pr_err ("%s() failed, ret = %d\n" , __func__, ret); +/* let free_overlay_changeset() put the fragments set up so far */ +if (ovcs->fragments) + ovcs->count = cnt; +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 166/571 of/overlay: dont create "//" paths for fragments targeting the root
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 21c89ff1fc86ffa517f3a9ca1ba5c48e9e37c1ba ]
dup_and_fixup_symbol_prop() rewrites a symbol value by replacing its "/fragment/__overlay__" prefix with the fragment's target path. When the fragment targets the root node the target path is "/" and the result starts with "//", which __of_find_node_by_full_path() cannot
resolve: symbols pointing into such fragments silently stop resolving.
Drop the target path when it is the root and the tail is non-empty. A value naming the fragment root itself (empty tail) keeps the "/".
--- drivers/of/overlay.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/overlay.c +3 -0
@@ -241,6 +241,9 @@ static struct property *dup_and_fixup_symbol_prop(if (!target_path)return NULL ; target_path_len =strlen (target_path); +/* a root target renders as "/"; drop it to avoid "//" results */ +if (target_path_len ==1 && target_path[0 ] =='/' && path_tail_len) + target_path_len =0 ; new_prop =kzalloc (sizeof (*new_prop),GFP_KERNEL );if (!new_prop)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 167/571 ASoC: wm8903: Move the DRC QR threshold to the register that holds it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit e31ae4aeb049983fe3be0cf1e12c8074811a7685 ]
The DRC_THRESH_QR field is bits 7 and 6 of DRC_1, but the control sits on DRC_0. Its shift and max are right for the field, only the register is wrong.
Those bits of DRC_0 belong to DRC_STARTUP_GAIN, which "DRC Startup Volume" claims as bits 10 to 6. So the two controls share bits 7 and 6. Writing either one moves the other, and the quick release threshold is never reached at all.
The six fields of DRC_1 tile it exactly, so there is nowhere else the threshold could live. Point the control at DRC_1.
Found by a sweep for two controls claiming the same bits of one register. No board with this codec was to hand, the register map is the driver's own wm8903.h.
--- sound/soc/codecs/wm8903.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +1 -1
@@ -678,7 +678,7 @@ SOC_ENUM("DRC Decay Rate", drc_decay),SOC_ENUM ("DRC FF Delay" , drc_ff_delay),SOC_SINGLE ("DRC Anticlip Switch" ,WM8903_DRC_0 ,1 ,1 ,0 ),SOC_SINGLE ("DRC QR Switch" ,WM8903_DRC_0 ,2 ,1 ,0 ), -SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_0 ,6 ,3 ,0 , drc_tlv_max), +SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_1 ,6 ,3 ,0 , drc_tlv_max),SOC_ENUM ("DRC QR Decay Rate" , drc_qr_decay),SOC_SINGLE ("DRC Smoothing Switch" ,WM8903_DRC_0 ,3 ,1 ,0 ), SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 168/571 wifi: ath11k: reset ar->num_stations on hardware start
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit 7e0ad05ebc72fffba2bdf2400400902d94ed7272 ]
When (multiple) hw restart occurs, we end up in a situation where we cannot accept new stations / mesh peers. This seems to be the 'num_stations' in 'struct ath11k' that did not get reset properly in this case. In ath11k_mac_op_start(), it was indeed the only accounting var that did not get reset so let's clear it too.
This avoids problems like those:
[1248828.088023] WARNING: CPU: 0 PID: 12281 at net/mac80211/util.c:1682 ieee80211_reconfig_stations+0x98/0xc0 [1248828.088115] Call trace: [1248828.088116] ieee80211_reconfig_stations+0x98/0xc0 (P) [1248828.088119] ieee80211_reconfig+0x774/0x1438 [1248828.088123] ieee80211_restart_work+0x10c/0x178 [1248828.088127] process_one_work+0x178/0x3c0 [1248828.088130] worker_thread+0x280/0x440 [1248828.088133] kthread+0xe0/0xf8 [1248828.088137] ret_from_fork+0x10/0x20 [1248828.088141] ---[ end trace 0000000000000000 ]--- [1248836.686604] ath11k_pci 0000:04:00.0: refusing to associate station: too many connected already (128) [1248836.686609] ath11k_pci 0000:04:00.0: Failed to add station: xx:xx:xx:xx:xx:xx for VDEV: 1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/mac.c +1 -0
@@ -4500,6 +4500,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) ar->num_started_vdevs =0 ; ar->num_created_vdevs =0 ; ar->num_peers =0 ; + ar->num_stations =0 ; ar->allocated_vdev_map =0 ;/* Configure monitor status ring with default rx_filter to get rx status
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 169/571 wifi: cfg80211: preserve hidden-group beacon IE ownership
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit cc45f313d85533d647ce619326302aad6f797c14 ]
A hidden-group probe-response entry borrows its beacon IEs from the group's beacon entry. cfg80211_update_assoc_bss_entry() can pass such an entry to cfg80211_update_known_bss() when merging scan entries after a channel switch.
Copying the borrowed beacon_ies into the associated entry gives the same allocation two owners. Releasing the group's beacon entry can then leave the associated entry pointing to freed IEs, which are freed again when that entry is released.
Skip beacon IE replacement when the source entry belongs to a hidden group. Preserve probe-response processing, the subsequent metadata updates, and the existing rejection path for conflicting hidden beacon updates.
--- net/wireless/scan.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
net/wireless/scan.c +12 -10
@@ -1767,20 +1767,22 @@ cfg80211_update_known_bss(struct cfg80211_registered_device *rdev,return false; } - old =rcu_access_pointer (known->pub.beacon_ies); +if (!new->pub.hidden_beacon_bss) { + old =rcu_access_pointer (known->pub.beacon_ies); -rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); +rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); -/* Override IEs if they were from a beacon before */ -if (old ==rcu_access_pointer (known->pub.ies)) -rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); +/* Override IEs if they were from a beacon before */ +if (old ==rcu_access_pointer (known->pub.ies)) +rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); -cfg80211_update_hidden_bsses (known, -rcu_access_pointer (new->pub.beacon_ies), - old); +cfg80211_update_hidden_bsses (known, +rcu_access_pointer (new->pub.beacon_ies), + old); -if (old) -kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); +if (old) +kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); + } } known->pub.beacon_interval = new->pub.beacon_interval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 170/571 ASoC: codecs: rt274: Fix format setting for 44100 rate
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 6eda8938a790f65bd24fcfaae7b40ad4613fb7a2 ]
As per specification, Sample Base Rate (bit 14) shall be set to 1 for 44.1 kHz.
--- sound/soc/codecs/rt274.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt274.c +3 -1
@@ -619,9 +619,11 @@ static int rt274_hw_params(struct snd_pcm_substream *substream,unsigned int val =0 ;int d_len_code =0 , c_len_code =0 ; +/* bit 14 Sample Rate Base, 0: 48kHz 1: 44.1kHz */ switch (params_rate (params)) { -/* bit 14 0:48K 1:44.1K */ case 44100 : + val |=BIT (14 ); +break ;case 48000 :break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 171/571 Bluetooth: hci_core: free the HCI ID if naming fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit d1ac915fb4184faad1b62148be50f317de7c24b5 ]
hci_register_dev() allocates an ID before calling dev_set_name(). If naming fails, it returns without releasing that ID. The device has not been registered and hdev->id has not been assigned, so the normal unregister path cannot release it.
Free the allocated ID before returning the naming error.
--- net/bluetooth/hci_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +3 -1
@@ -3949,8 +3949,10 @@ int hci_register_dev(struct hci_dev *hdev)return id; error =dev_set_name (&hdev->dev,"hci%u" , id); -if (error) +if (error) { +ida_free (&hci_index_ida, id);return error; + } hdev->name =dev_name (&hdev->dev); hdev->id = id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 172/571 Bluetooth: btintel: validate DDC record lengths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Teja Aluvala <[email protected]>
[ Upstream commit c9c15d4d8956df8c564f7c210e4dc5b9b820d97a ]
Parse DDC record lengths in unsigned storage so 0xFF does not wrap. Reject records smaller than the mandatory three-byte header, records exceeding U8_MAX, and records exceeding remaining firmware bytes before issuing Intel_Write_DDC.
This issue was reported by Claude Mythos.
--- drivers/bluetooth/btintel.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +10 -2
@@ -358,8 +358,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)/* DDC file contains one or more DDC structure which has * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2). */ -while (fw->size > fw_ptr - fw->data) { -u8 cmd_plen = fw_ptr[0 ] +sizeof (u8); +while (fw->size > (size_t )(fw_ptr - fw->data)) { +size_t remaining = fw->size - (fw_ptr - fw->data); +unsigned int cmd_plen = fw_ptr[0 ] +1U ; + +if (cmd_plen <3 || cmd_plen >U8_MAX || cmd_plen > remaining) { +bt_dev_err (hdev,"Malformed DDC record (plen=%u, remaining=%zu)" , + cmd_plen, remaining); +release_firmware (fw); +return -EINVAL ; + } skb =__hci_cmd_sync (hdev,0xfc8b , cmd_plen, fw_ptr,HCI_INIT_TIMEOUT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 173/571 mctp: Add refcounts to mctp_dev
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Kerr <[email protected]>
[ Upstream commit 43f55f23f70881e9c397557f15c8090b368d0af2 ]
Currently, we tie the struct mctp_dev lifetime to the underlying struct net_device, and hold/put that device as a proxy for a separate mctp_dev refcount. This works because we're not holding any references to the mctp_dev that are different from the netdev lifetime.
In a future change we'll break that assumption though, as we'll need to hold mctp_dev references in a workqueue, which might live past the netdev unregister notification.
In order to support that, this change introduces a refcount on the mctp_dev, currently taken by the net_device->mctp_ptr reference, and released on netdev unregister events. We can then use this for future references that might outlast the net device.
Stable-dep-of: aadf655e8ea9 ("net/mctp: publish the mctp_dev only after it is initialised")
--- include/net/mctpdevice.h | 5 +++++ net/mctp/device.c | 25 ++++++++++++++++--------- net/mctp/neigh.c | 4 ++-- net/mctp/route.c | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-)
include/net/mctpdevice.h +5 -0
@@ -17,6 +17,8 @@struct mctp_dev {struct net_device *dev; +refcount_t refs; +unsigned int net;/* Only modified under RTNL. Reads have addrs_lock held */
@@ -32,4 +34,7 @@ struct mctp_dev {struct mctp_dev *mctp_dev_get_rtnl (const struct net_device *dev);struct mctp_dev *__mctp_dev_get (const struct net_device *dev); +void mctp_dev_hold (struct mctp_dev *mdev); +void mctp_dev_put (struct mctp_dev *mdev); +#endif /* __NET_MCTPDEVICE_H */
net/mctp/device.c +16 -9
@@ -35,14 +35,6 @@ struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev)return rtnl_dereference (dev->mctp_ptr); } -static void mctp_dev_destroy (struct mctp_dev *mdev) -{ -struct net_device *dev = mdev->dev; - -dev_put (dev); -kfree_rcu (mdev, rcu); -} -static int mctp_fill_addrinfo (struct sk_buff *skb,struct netlink_callback *cb,struct mctp_dev *mdev,mctp_eid_t eid) {
@@ -263,6 +255,19 @@ static int mctp_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,return 0 ; } +void mctp_dev_hold (struct mctp_dev *mdev) +{ +refcount_inc (&mdev->refs); +} + +void mctp_dev_put (struct mctp_dev *mdev) +{ +if (refcount_dec_and_test (&mdev->refs)) { +dev_put (mdev->dev); +kfree_rcu (mdev, rcu); + } +} +static struct mctp_dev *mctp_add_dev (struct net_device *dev) {struct mctp_dev *mdev;
@@ -278,7 +283,9 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev) mdev->net =mctp_default_net (dev_net (dev));/* associate to net_device */ +refcount_set (&mdev->refs,1 );rcu_assign_pointer (dev->mctp_ptr, mdev); +dev_hold (dev); mdev->dev = dev;
@@ -353,7 +360,7 @@ static void mctp_unregister(struct net_device *dev)mctp_neigh_remove_dev (mdev);kfree (mdev->addrs); -mctp_dev_destroy (mdev); +mctp_dev_put (mdev); }static int mctp_register (struct net_device *dev)
net/mctp/neigh.c +2 -2
@@ -47,7 +47,7 @@ static int mctp_neigh_add(struct mctp_dev *mdev, mctp_eid_t eid, }INIT_LIST_HEAD (&neigh->list); neigh->dev = mdev; -dev_hold (neigh->dev->dev); +mctp_dev_hold (neigh->dev); neigh->eid = eid; neigh->source = source;memcpy (neigh->ha, lladdr, lladdr_len);
@@ -63,7 +63,7 @@ static void __mctp_neigh_free(struct rcu_head *rcu) { struct mctp_neigh *neigh = container_of(rcu, struct mctp_neigh, rcu); -dev_put (neigh->dev->dev); +mctp_dev_put (neigh->dev);kfree (neigh); }
net/mctp/route.c +2 -2
@@ -420,7 +420,7 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)static void mctp_route_release (struct mctp_route *rt) {if (refcount_dec_and_test (&rt->refs)) { -dev_put (rt->dev->dev); +mctp_dev_put (rt->dev);kfree_rcu (rt, rcu); } }
@@ -777,7 +777,7 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start, rt->max = daddr_start + daddr_extent; rt->mtu = mtu; rt->dev = mdev; -dev_hold (rt->dev->dev); +mctp_dev_hold (rt->dev); rt->type = type; rt->output = rtfn;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 174/571 net/mctp: publish the mctp_dev only after it is initialised
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit aadf655e8ea9a8ffa24bb8d69f504572e8d18181 ]
mctp_add_dev() links the new mctp_dev into dev->mctp_ptr before mdev->dev is assigned, so a reader that picks the device up in that window dereferences a net_device pointer that is still NULL:
KASAN: null-ptr-deref in range [0x00000000000000b0-0x00000000000000b7] Call Trace: <TASK> ? __pfx_mctp_sendmsg (./include/linux/sockptr.h:49) ? __pfx_mctp_dst_output (net/mctp/route.c:41) ? selinux_socket_sendmsg (security/selinux/hooks.c:5278) ____sys_sendmsg (net/socket.c:775 (discriminator 1) net/socket.c:790 (discriminator 1) net/socket.c:2684 (discriminator 1)) ? __pfx_____sys_sendmsg (net/socket.c:1131) ? __pfx_copy_msghdr_from_user (net/socket.c:2590) ? update_cfs_rq_load_avg (kernel/sched/fair.c:5478) ___sys_sendmsg (net/socket.c:2738) ? __pfx____sys_sendmsg (net/socket.c:2625) ? perf_event_task_tick (./include/linux/rcupdate.h:838) ? sched_tick (kernel/sched/core.c:5818) ? clockevents_program_event (kernel/time/clockevents.c:372) ? fdget (./include/linux/rcupdate.h:873 fs/file.c:1100) __sys_sendmsg (net/socket.c:2770) ? __pfx___sys_sendmsg (net/socket.c:2751) do_syscall_64 (arch/x86/entry/syscall_64.c:63) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Fix by publishing only once the object is fully initialised:__mctp_dev_get() runs under rcu_read_lock() only and hands this object to readers as soon as mctp_ptr is assigned, so they must never observe mdev->dev == NULL.
--- net/mctp/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/mctp/device.c +3 -3
@@ -282,13 +282,13 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev) mdev->net =mctp_default_net (dev_net (dev)); -/* associate to net_device */ refcount_set (&mdev->refs,1 ); -rcu_assign_pointer (dev->mctp_ptr, mdev); -dev_hold (dev); mdev->dev = dev; +/* Associate to net_device, publish the mdev. */ +rcu_assign_pointer (dev->mctp_ptr, mdev); +return mdev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 175/571 net/sched: cls_api: reclaim an empty proto on the error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 0bb8eab29b55045281a4963d4557f2776cdf8cfa ]
Two racing tc filter add requests on the same chain/prio of an unlocked classifier both run change() on the shared proto and both can fail: the winner's tcf_chain_tp_delete_empty() attempt gives up because the loser's handle is still in the idr, and the loser's error path drops only its own reference without a second reclamation attempt. The empty proto stays linked in the chain, holding the chain reference, a block reference and the classifier module reference until the chain or block is torn down.
Reclaim the proto on the error path of any failed request that holds a proto reference. The reclamation is emptiness-gated:tcf_chain_tp_delete_empty() unlinks the proto only when delete_empty() admits it is empty, so a live shared proto is never unlinked. A proto the request created is reclaimed unconditionally - it is the only owner, so marking it for deletion is safe even without a delete_empty callback. Classifiers without one (the check marks the proto unconditionally) are rtnl-serialized, so the raced window this guard closes cannot arise for them.
This is a follow-up to commit d4e359b3608a ("net/sched: cls_api: fix teardown of an adopted proto on insert-race loss"), which stopped the loser of the insert race from unlinking the winner's live proto but left the empty-proto residual in place.
Conditions to recreate:
- CONFIG_NET_CLS_FLOWER=y; veth pair
- tc qdisc add dev veth0 ingress
- two concurrent tc filter add dev veth0 ingress protocol ip pref 1 flower skip_sw ... action drop (both fail in fl_hw_replace_filter after publishing their handle in the idr); repeat in a loop
- an empty flower tp stays linked after both requests fail; visible as a bare filter protocol ip pref 1 flower chain 0 header in tc filter show with no filter entries
- CAP_NET_ADMIN (namespace-local via unshare -Urn suffices)
--- net/sched/cls_api.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/sched/cls_api.c +14 -1
@@ -2155,7 +2155,20 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_state ==TP_CREATED ) +if (err && !IS_ERR_OR_NULL (tp) && + (tp_state ==TP_CREATED || tp->ops->delete_empty)) +/* +* The request is dropping its reference to tp. If it was +* the last user (the idr is empty now), reclaim the proto. +* A tp this request created is reclaimed unconditionally: +* it is the only owner, so marking it for deletion is +* safe. Otherwise only classifiers with a delete_empty +* callback are reclaimed -- the callback admits an empty +* proto only, so a live shared proto is never unlinked. +* Classifiers without one (deleting is set +* unconditionally) are rtnl-serialized, so the raced +* window this guard closes cannot arise for them. +*/ tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 176/571 netfilter: ipset: do not update comments from kernel-side adds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit a442c8a89fb9c531f9d6ab86120c31decd778d51 ]
'Fixes' commit stopped calling ip_set_init_comment() for hash types from kernel-side-adds (xtables .. -j SET). ip_set_init_comment() says:
"The kadt functions don't use the comment extensions in any way."
But bitmap set type calls the function from kadt cb too.
While this appears to be safe (serialized via the set spinlock), it seems better to not call the init function either, least of all to keep behaviour consistent.
ip_set_list calls ip_set_init_comment() only from uadt cb, it can be kept as-is.
This was triggered by yet another LLM review, hinting that the existing rcu_dereference_protected() cannot be downgraded to only check if the nfnl mutex is held.
--- net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
@@ -157,7 +157,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (SET_WITH_COUNTER (set))ip_set_init_counter (ext_counter (x, set), ext); -if (SET_WITH_COMMENT (set)) +if (SET_WITH_COMMENT (set) && !ext->target)ip_set_init_comment (set,ext_comment (x, set), ext);if (SET_WITH_SKBINFO (set))ip_set_init_skbinfo (ext_skbinfo (x, set), ext);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 177/571 net: systemport: Fix RUNT MIB counter register offset calculation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 242935adfeb096f09b29fb2cfcf12f9eb2911fc6 ]
In UniMAC hardware, there is a 0xC byte gap between the RX MIB counters and the TX MIB counters, and a second 0xC byte gap between the TX MIB counters and the RX RUNT MIB counters.
In bcm_sysport_update_mib_counters(), 'offset' was only set to UMAC_MIB_STAT_OFFSET (0xC) for all non-RX counters, omitting the second 0xC gap for BCM_SYSPORT_STAT_RUNT counters. As a result, all 4 RUNT MIB counters were read from unmapped gap register space.
Fix this by setting offset to 2 * UMAC_MIB_STAT_OFFSET (0x18) when reading BCM_SYSPORT_STAT_RUNT counters.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -1
@@ -422,8 +422,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv)if (priv->is_lite)continue ; -if (s->type !=BCM_SYSPORT_STAT_MIB_RX ) +if (s->type ==BCM_SYSPORT_STAT_MIB_TX ) offset =UMAC_MIB_STAT_OFFSET ; +else if (s->type ==BCM_SYSPORT_STAT_RUNT ) + offset =2 *UMAC_MIB_STAT_OFFSET ; val =umac_readl (priv,UMAC_MIB_START + j + offset);break ;case BCM_SYSPORT_STAT_RXCHK :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 178/571 tipc: prevent GCM nonce reuse on peer key changes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 512ccd3d0e91e791fb37442aa0a2599aca19783d ]
TIPC can encrypt traffic between nodes using a different transmit key for each node. In this mode, the AES-GCM nonce for a packet sent to a known peer consists of a 32-bit prefix (a per-key salt XOR the peer's address) followed by a 64-bit counter. That counter is stored in the peer's RX crypto object. When the peer reports a change in which key it uses to receive packets, TIPC resets this counter. The sender can still be using the same TX key and salt, so subsequent packets reuse earlier nonces. This nonce reuse breaks confidentiality and exposes GCM's authentication key. This makes forgeries trivial: an attacker can exploit CTR malleability to alter captured ciphertexts and use the recovered authentication key to compute a valid tag for the modified ciphertext, under the same key and nonce.
Use the TX key's existing aead->seqno counter instead. All encryptions using that key object share the same atomic counter, so concurrent encryptions get distinct nonce counter values. The counter survives key activation and peer reconnection, and peer key-status reports cannot reset it. This prevents those transitions from causing nonce reuse while the same TX key remains installed.
The nonce format is unchanged, and receivers do not require consecutive counter values, so sharing the counter across peers remains compatible with existing receivers. A pre-existing check still invokes key revocation in the unlikely event that the counter wraps to zero.
--- net/tipc/crypto.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
net/tipc/crypto.c +5 -15
@@ -144,7 +144,7 @@ struct tipc_tfm {* @rcu: struct rcu_head * @key: the aead key * @gen: the key's generation -* @seqno: the key seqno (cluster scope) +* @seqno: the per-key TX nonce counter * @refcnt: the key reference counter */ struct tipc_aead {
@@ -190,7 +190,6 @@ struct tipc_crypto_stats {* @rekeying_intv: rekeying interval (in minutes) * @stats: the crypto statistics * @name: the crypto name -* @sndnxt: the per-peer sndnxt (TX) * @timer1: general timer 1 (jiffies) * @timer2: general timer 2 (jiffies) * @working: the crypto is working or not
@@ -219,7 +218,6 @@ struct tipc_crypto {struct tipc_crypto_stats __percpu *stats;char name[48 ]; -atomic64_t sndnxt____cacheline_aligned ;unsigned long timer1;unsigned long timer2;union {
@@ -1071,14 +1069,11 @@ static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead,WARN_ON (skb_headroom (skb) < ehsz); ehdr = (struct tipc_ehdr *)skb_push (skb, ehsz); -/* Obtain a seqno first: -* Use the key seqno (= cluster wise) if dest is unknown or we're in -* cluster key mode, otherwise it's better for a per-peer seqno! +/* +* Keep the nonce unique for the lifetime of the TX key, +* including key state changes and peer reconnection. */ -if (!__rx || aead->mode ==CLUSTER_KEY ) - seqno =atomic64_inc_return (&aead->seqno); -else - seqno =atomic64_inc_return (&__rx->sndnxt); + seqno =atomic64_inc_return (&aead->seqno);/* Revoke the key if seqno is wrapped around */ if (unlikely (!seqno))
@@ -1257,7 +1252,6 @@ void tipc_crypto_key_flush(struct tipc_crypto *c)tipc_crypto_key_set_state (c,0 ,0 ,0 );for (k =KEY_MIN ; k <=KEY_MAX ; k++)tipc_crypto_key_detach (c->aead[k], &c->lock); -atomic64_set (&c->sndnxt,0 );spin_unlock_bh (&c->lock); }
@@ -1404,8 +1398,6 @@ static struct tipc_aead *tipc_crypto_key_pick_tx(struct tipc_crypto *tx,* It also considers if peer has no key, then we need to make own master key * (if any) taking over i.e. starting grace period and also trigger key * distributing process. -* -* The "per-peer" sndnxt is also reset when the peer key has switched. */ static void tipc_crypto_key_synch (struct tipc_crypto *rx,struct sk_buff *skb) {
@@ -1456,7 +1448,6 @@ static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)if (cur)tipc_aead_users_dec (tx->aead[cur],0 ); -atomic64_set (&rx->sndnxt,0 );/* Mark the point TX key users changed */ tx->timer1 = jiffies;
@@ -1521,7 +1512,6 @@ int tipc_crypto_start(struct tipc_crypto **crypto, struct net *net,tipc_crypto_key_set_state (c,0 ,0 ,0 );atomic_set (&c->key_distr,0 );atomic_set (&c->peer_rx_active,0 ); -atomic64_set (&c->sndnxt,0 ); c->timer1 = jiffies; c->timer2 = jiffies; c->rekeying_intv =TIPC_REKEYING_INTV_DEF ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 179/571 net/sched: fq_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d031465acc362866f27e4f8f79cfecf1037fe2e5 ]
commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu") clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX]. The two fields mean different things: quantum is a DRR credit that wants the 256 floor, but cparams.mtu is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"). On a link whose maximum transmitted packet size is below 256, the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Split the clamp. quantum keeps [256, FQ_CODEL_QUANTUM_MAX]; cparams.mtu tracks psched_mtu() (the device MTU plus its hard-header length) with only the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device).
Conditions to recreate the bug: attach an fq_codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Basic Testing done: with dev->mtu=100 and hard_header_len=14, a return probe on fq_codel_init() observed cparams.mtu change from 256 to 114
--- net/sched/sch_fq_codel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +2 -2
@@ -499,8 +499,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->flows_cnt =1024 ; q->memory_limit =32 <<20 ;/* 32 MBytes */ q->drop_batch_size =64 ; - mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,FQ_CODEL_QUANTUM_MAX ); - q->quantum = mtu; + mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),FQ_CODEL_QUANTUM_MAX ); + q->quantum =clamp_t (u32, mtu,256 ,FQ_CODEL_QUANTUM_MAX );INIT_LIST_HEAD (&q->new_flows);INIT_LIST_HEAD (&q->old_flows);codel_params_init (&q->cparams);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 180/571 net/sched: sch_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 54518e0e827f4ca9229ae657022c60bf60f5c1bf ]
commit 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid disabling CoDel") clamped q->params.mtu to [256, 1 << 20]. The value is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"), so on a link whose maximum transmitted packet size is below 256 the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Keep the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device) but drop the 256 floor, so the threshold tracks the real device packet size.
Conditions to recreate the bug: attach a codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
@@ -231,7 +231,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,codel_params_init (&q->params);codel_vars_init (&q->vars);codel_stats_init (&q->stats); - q->params.mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 ); + q->params.mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),1 <<20 );if (opt) {int err =codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 181/571 tcp: refresh TS.Recent for accepted old ACKs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Jo <[email protected]>
[ Upstream commit 1b92780ae4fc3be64f05d97ed8833c445e73b0cf ]
A TCP packet can carry new data while acknowledging traffic in the opposite direction. With overlapping traffic in both directions, a delayed packet's acknowledgment can be older than one Linux has already accepted, even when that packet fills a gap in the received data.
Linux accepts the data, but tcp_ack() takes the old_ack path and skips updating TS.Recent, the timestamp saved for outgoing acknowledgments. The reply therefore echoes an older timestamp. If the sender uses this echo to measure round-trip time after a long idle period, its estimate includes the idle time and can reduce its sending rate.
Update TS.Recent in old_ack using tcp_replace_ts_recent(), before SACK processing can trigger a transmission. This reuses the existing timestamp and sequence checks, including PAWS protection against old duplicate packets. ACK validation already rejects old ACKs in SYN_RECV before this path, so no additional state check is needed.
Echoing the timestamp of the packet that fills the receive gap follows RFC 7323 section 4.3. In a socket reproduction with 300 seconds idle, controlled reordering and retransmission to exercise timestamp-based RTT sampling, the sender's smoothed round-trip time was 37.5 seconds without the fix and 15.5 ms with it.
--- net/ipv4/tcp_input.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp_input.c +6 -0
@@ -4017,6 +4017,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)return 1 ; old_ack: +/* An old ACK can carry new data. Update TS.Recent before SACK +* processing can trigger a retransmission. +*/ +if (flag &FLAG_UPDATE_TS_RECENT ) +tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); +/* If data was SACKed, tag it and see if we should send more data. * If data was DSACKed, see if we can undo a cwnd reduction. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 182/571 ipvs: fix missing counter decrement in lblc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit bdac17779f46817f60103baf09f0370546c3f023 ]
LBLC may delete cache entries for destinations that are removed or overloaded and replace them with available ones. But ip_vs_lblc_new() forgets to decrement the tbl->entries counter after calling ip_vs_lblc_del(). This can lead to increased shrinking of the cache with every new garbage collection.
--- net/netfilter/ipvs/ip_vs_lblc.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/ipvs/ip_vs_lblc.c +1 -0
@@ -205,6 +205,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,if (en->dest == dest)return en;ip_vs_lblc_del (en); +atomic_dec (&tbl->entries); } en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 183/571 ipvs: do not create invisible templates
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 616cf5c06934364ab1002b420ebe975850b4b208 ]
The IP_VS_CONN_F_ONE_PACKET flag was implemented for normal connections. When conn template inherits this flag from dest->conn_flags it will not be hashed. As result, we will create new template for every new normal connection.
Fix it to allow one template to be used by many normal connections.
--- net/netfilter/ipvs/ip_vs_conn.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/ipvs/ip_vs_conn.c +3 -0
@@ -591,6 +591,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)if (cp->protocol !=IPPROTO_UDP ) conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ; flags = cp->flags; +/* Only visible templates can control multiple connections */ +if (flags &IP_VS_CONN_F_TEMPLATE ) + conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ;/* Bind with the destination and its corresponding transmitter */ if (flags &IP_VS_CONN_F_SYNC ) {/* Synced conns are hashed, so they can not get this flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 184/571 ipvs: filter some flags received in the backup server
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit f96e91748f6304668fe647e686d199d7207d36f1 ]
While the IPVS SYNC protocol is not secure by design we can still protect the backup server from messages that can wreak havoc.
This commit addresses problems from received connection flags or their combinations. We now drop messages as follows:
1. the NO_CPORT+TEMPLATE combination allows lookups for normal connections to hit template which can break in many ways. While the master does not sync connections with NO_CPORT flag, i.e. before they are established, we still accept NO_CPORT without TEMPLATE.
2. ONE_PACKET: it is not sent by master, so we do not expect it in backup. Before now it was ignored by IP_VS_CONN_F_BACKUP_MASK for protocol v1 while protocol v0 created connections that are not hashed and dropped immediately. Better to apply the IP_VS_CONN_F_BACKUP_MASK also to the flags from v0 messages for consistency with v1.
--- net/netfilter/ipvs/ip_vs_sync.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +30 -3
@@ -950,6 +950,21 @@ static void ip_vs_proc_conn(struct netns_ipvs *ipvs, struct ip_vs_conn_param *paip_vs_conn_put (cp); } +/* Check for incompatible flags */ +static bool ip_vs_sync_validate_flags (u32 flags) +{ +/* We do not expect NO_CPORT, especially to allow lookups +* to hit templates +*/ +if (flags &IP_VS_CONN_F_NO_CPORT ) { +if (flags &IP_VS_CONN_F_TEMPLATE ) +return false; + } +if (flags &IP_VS_CONN_F_ONE_PACKET ) +return false; +return true; +} +/* * Process received multicast message for Version 0 */
@@ -973,8 +988,7 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *bufferreturn ; } s = (struct ip_vs_sync_conn_v0 *) p; - flags =ntohs (s->flags) |IP_VS_CONN_F_SYNC ; - flags &= ~IP_VS_CONN_F_HASHED ; + flags =ntohs (s->flags);if (flags &IP_VS_CONN_F_SEQ_MASK ) { opt = (struct ip_vs_sync_conn_options *)&s[1 ]; p +=FULL_CONN_SIZE ;
@@ -987,6 +1001,13 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer p +=SIMPLE_CONN_SIZE ; } +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (2 ,"BACKUP v0, Invalid flags 0x%X\n" , flags); +continue ; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; + flags |=IP_VS_CONN_F_SYNC ; + state =ntohs (s->state);if (!(flags &IP_VS_CONN_F_TEMPLATE )) { pp =ip_vs_proto_get (s->protocol);
@@ -1142,7 +1163,13 @@ static inline int ip_vs_proc_sync_conn(struct netns_ipvs *ipvs, __u8 *p, __u8 *m }/* Get flags and Mask off unsupported */ - flags =ntohl (s->v4.flags) &IP_VS_CONN_F_BACKUP_MASK ; + flags =ntohl (s->v4.flags); +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (3 ,"BACKUP, Invalid flags 0x%X\n" , flags); + retc =25 ; + goto out; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; flags |=IP_VS_CONN_F_SYNC ; state =ntohs (s->v4.state);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 185/571 netfilter: nf_tables: avoid skb access on nf_stolen
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit e34b9ed96ce3b06c79bf884009b16961ca478f87 ]
When verdict is NF_STOLEN, the skb might have been freed.
When tracing is enabled, this can result in a use-after-free:
1. access to skb->nf_trace
2. access to skb->mark
3. computation of trace id
4. dump of packet payload
To avoid 1, keep a cached copy of skb->nf_trace in the trace state struct.
Refresh this copy whenever verdict is != STOLEN.
Avoid 2 by skipping skb->mark access if verdict is STOLEN.
3 is avoided by precomputing the trace id.
Only dump the packet when verdict is not "STOLEN".
Stable-dep-of: 8ec454dcd00c ("ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()")
--- include/net/netfilter/nf_tables.h | 16 ++++++----- net/netfilter/nf_tables_core.c | 24 ++++++++++++++--- net/netfilter/nf_tables_trace.c | 44 +++++++++++++++++-------------- 3 files changed, 55 insertions(+), 29 deletions(-)
include/net/netfilter/nf_tables.h +10 -6
@@ -1373,24 +1373,28 @@ void nft_unregister_flowtable_type(struct nf_flowtable_type *type);/** * struct nft_traceinfo - nft tracing information and state * +* @trace: other struct members are initialised +* @nf_trace: copy of skb->nf_trace before rule evaluation +* @type: event type (enum nft_trace_types) +* @skbid: hash of skb to be used as trace id +* @packet_dumped: packet headers sent in a previous traceinfo message * @pkt: pktinfo currently processed * @basechain: base chain currently processed * @chain: chain currently processed * @rule: rule that was evaluated * @verdict: verdict given by rule -* @type: event type (enum nft_trace_types) -* @packet_dumped: packet headers sent in a previous traceinfo message -* @trace: other struct members are initialised */ struct nft_traceinfo { +bool trace; +bool nf_trace; +bool packet_dumped; +enum nft_trace_types type:8 ; +u32 skbid;const struct nft_pktinfo *pkt;const struct nft_base_chain *basechain;const struct nft_chain *chain;const struct nft_rule *rule;const struct nft_verdict *verdict; -enum nft_trace_types type; -bool packet_dumped; -bool trace; }; void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,
net/netfilter/nf_tables_core.c +21 -3
@@ -25,9 +25,7 @@ static noinline void __nft_trace_packet(struct nft_traceinfo *info, const struct nft_chain *chain, enum nft_trace_types type) { -const struct nft_pktinfo *pkt = info->pkt; - -if (!info->trace || !pkt->skb->nf_trace) + if (!info->trace || !info->nf_trace) return; info->chain = chain;
@@ -42,11 +40,24 @@ static inline void nft_trace_packet(struct nft_traceinfo *info, enum nft_trace_types type) {if (static_branch_unlikely (&nft_trace_enabled)) { +const struct nft_pktinfo *pkt = info->pkt; + + info->nf_trace = pkt->skb->nf_trace; info->rule = rule;__nft_trace_packet (info, chain, type); } } +static inline void nft_trace_copy_nftrace (struct nft_traceinfo *info) +{ +if (static_branch_unlikely (&nft_trace_enabled)) { +const struct nft_pktinfo *pkt = info->pkt; + +if (info->trace) + info->nf_trace = pkt->skb->nf_trace; + } +} +static void nft_bitwise_fast_eval (const struct nft_expr *expr,struct nft_regs *regs) {
@@ -85,6 +96,7 @@ static noinline void __nft_trace_verdict(struct nft_traceinfo *info,const struct nft_chain *chain, const struct nft_regs *regs) { + const struct nft_pktinfo *pkt = info->pkt;enum nft_trace_types type;switch (regs->verdict.code) {
@@ -92,8 +104,13 @@ static noinline void __nft_trace_verdict(struct nft_traceinfo *info,case NFT_RETURN : type =NFT_TRACETYPE_RETURN ;break ; +case NF_STOLEN : + type =NFT_TRACETYPE_RULE ; +/* can't access skb->nf_trace; use copy */ +break ;default : type =NFT_TRACETYPE_RULE ; + info->nf_trace = pkt->skb->nf_trace;break ; }
@@ -244,6 +261,7 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)switch (regs.verdict.code) {case NFT_BREAK : regs.verdict.code =NFT_CONTINUE ; +nft_trace_copy_nftrace (&info);continue ;case NFT_CONTINUE : nft_trace_packet(&info, chain, rule,
net/netfilter/nf_tables_trace.c +24 -20
91 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 186/571 net: add and use skb_get_hash_net
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit b975d3ee5962237c1e2f5d5aeeaaf0dc2173486c ]
Years ago flow dissector gained ability to delegate flow dissection to a bpf program, scoped per netns.
Unfortunately, skb_get_hash() only gets an sk_buff argument instead of both net+skb. This means the flow dissector needs to obtain the netns pointer from somewhere else.
The netns is derived from skb->dev, and if that is not available, from skb->sk. If neither is set, we hit a (benign) WARN_ON_ONCE().
Trying both dev and sk covers most cases, but not all, as recently reported by Christoph Paasch.
In case of nf-generated tcp reset, both sk and dev are NULL:
WARNING: .. net/core/flow_dissector.c:1104
skb_flow_dissect_flow_keys include/linux/skbuff.h:1536 [inline] skb_get_hash include/linux/skbuff.h:1578 [inline] nft_trace_init+0x7d/0x120 net/netfilter/nf_tables_trace.c:320 nft_do_chain+0xb26/0xb90 net/netfilter/nf_tables_core.c:268 nft_do_chain_ipv4+0x7a/0xa0 net/netfilter/nft_chain_filter.c:23 nf_hook_slow+0x57/0x160 net/netfilter/core.c:626 __ip_local_out+0x21d/0x260 net/ipv4/ip_output.c:118 ip_local_out+0x26/0x1e0 net/ipv4/ip_output.c:127 nf_send_reset+0x58c/0x700 net/ipv4/netfilter/nf_reject_ipv4.c:308 nft_reject_ipv4_eval+0x53/0x90 net/ipv4/netfilter/nft_reject_ipv4.c:30 [..]
syzkaller did something like this:
table inet filter {
chain input {
type filter hook input priority filter; policy accept; meta nftrace set 1
tcp dport 42 reject with tcp reset
}
chain output {
type filter hook output priority filter; policy accept; # empty chain is enough
}
}
... then sends a tcp packet to port 42.
Initial attempt to simply set skb->dev from nf_reject_ipv4 doesn't cover all cases: skbs generated via ipv4 igmp_send_report trigger similar splat.
Moreover, Pablo Neira found that nft_hash.c uses __skb_get_hash_symmetric() which would trigger same warn splat for such skbs.
Lets allow callers to pass the current netns explicitly. The nf_trace infrastructure is adjusted to use the new helper.
__skb_get_hash_symmetric is handled in the next patch.
Stable-dep-of: 8ec454dcd00c ("ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()")
--- include/linux/skbuff.h | 12 ++++++++++-- net/core/flow_dissector.c | 15 +++++++++++---- net/netfilter/nf_tables_trace.c | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-)
include/linux/skbuff.h +10 -2
@@ -1346,7 +1346,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)__skb_set_hash (skb, hash, true, is_l4); } -void __skb_get_hash (struct sk_buff *skb); +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb);u32 __skb_get_hash_symmetric (const struct sk_buff *skb);u32 skb_get_poff (const struct sk_buff *skb); u32 __skb_get_poff(const struct sk_buff *skb, const void *data,
@@ -1426,10 +1426,18 @@ void skb_flow_dissect_hash(const struct sk_buff *skb,struct flow_dissector *flow_dissector, void *target_container); +static inline __u32 skb_get_hash_net (const struct net *net,struct sk_buff *skb) +{ +if (!skb->l4_hash && !skb->sw_hash) +__skb_get_hash_net (net, skb); + +return skb->hash; +} +static inline __u32 skb_get_hash (struct sk_buff *skb) {if (!skb->l4_hash && !skb->sw_hash) -__skb_get_hash (skb); +__skb_get_hash_net (NULL , skb);return skb->hash; }
net/core/flow_dissector.c +11 -4
@@ -1685,7 +1685,8 @@ u32 __skb_get_hash_symmetric(const struct sk_buff *skb)EXPORT_SYMBOL_GPL (__skb_get_hash_symmetric);/** -* __skb_get_hash: calculate a flow hash +* __skb_get_hash_net: calculate a flow hash +* @net: associated network namespace, derived from @skb if NULL * @skb: sk_buff to calculate flow hash from * * This function calculates a flow hash based on src/dst addresses
@@ -1693,18 +1694,24 @@ EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);* on success, zero indicates no valid hash. Also, sets l4_hash in skb * if hash is a canonical 4-tuple hash over transport ports. */ -void __skb_get_hash (struct sk_buff *skb) +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb) {struct flow_keys keys;u32 hash; +memset (&keys,0 ,sizeof (keys)); + +__skb_flow_dissect (net, skb, &flow_keys_dissector, + &keys,NULL ,0 ,0 ,0 , +FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL ); +__flow_hash_secret_init (); - hash =___skb_get_hash (skb, &keys, &hashrnd); + hash =__flow_hash_from_keys (&keys, &hashrnd);__skb_set_sw_hash (skb, hash,flow_keys_have_l4 (&keys)); } -EXPORT_SYMBOL (__skb_get_hash); +EXPORT_SYMBOL (__skb_get_hash_net);__u32 skb_get_hash_perturb (const struct sk_buff *skb,const siphash_key_t *perturb)
net/netfilter/nf_tables_trace.c +1 -1
@@ -289,7 +289,7 @@ void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,net_get_random_once (&trace_key,sizeof (trace_key)); info->skbid = (u32 )siphash_3u32 (hash32_ptr (skb), -skb_get_hash (skb), +skb_get_hash_net (nft_net (pkt), skb), skb->skb_iif, &trace_key); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 187/571 ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ec454dcd00ce3375119111c6394964455b36d0d ]
Since commit d58e468b1112 ("flow_dissector: implements flow dissector BPF hook") __skb_flow_dissect() needs a net pointer, either from skb->dev, skb->sk, or since commit 3cbf4ffba5ee ("net: plumb network namespace into __skb_flow_dissect") a caller provided pointer.
syzbot was able to reach seg6_make_flowlabel() with an skb having neither skb->dev nor skb->sk set: a TIPC UDP bearer sends a discovery message through an IPv4 route using seg6 encap, while net.ipv6.seg6_flowlabel is set to 1.
seg6_make_flowlabel() already has a net pointer, use skb_get_hash_net().
WARNING: net/core/flow_dissector.c:1131 at __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126, CPU#0: syz.0.17/4930 Call trace: __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126 (P) __skb_get_hash_net+0xe0/0x29c net/core/flow_dissector.c:1903 skb_get_hash include/linux/skbuff.h:1663 [inline] seg6_make_flowlabel+0xcc/0x1ec net/ipv6/seg6_iptunnel.c:132 __seg6_do_srh_encap+0x320/0xbf4 net/ipv6/seg6_iptunnel.c:161 seg6_do_srh+0x4b4/0xa44 net/ipv6/seg6_iptunnel.c:431 seg6_output_core+0x164/0x688 net/ipv6/seg6_iptunnel.c:681 seg6_output+0x44/0x1ac net/ipv6/seg6_iptunnel.c:744 lwtunnel_output+0x3d0/0x664 net/core/lwtunnel.c:356 dst_output include/net/dst.h:470 [inline] ip_local_out+0x110/0x148 net/ipv4/ip_output.c:131 iptunnel_xmit+0x50c/0xd38 net/ipv4/ip_tunnel_core.c:97 udp_tunnel_xmit_skb+0x220/0x348 net/ipv4/udp_tunnel_core.c:187 tipc_udp_xmit+0x75c/0x9c0 net/tipc/udp_media.c:202 tipc_udp_send_msg+0x214/0x374 net/tipc/udp_media.c:274 tipc_bearer_xmit_skb+0x260/0x3b0 net/tipc/bearer.c:576 tipc_enable_bearer net/tipc/bearer.c:366 [inline] __tipc_nl_bearer_enable+0xc90/0xfb0 net/tipc/bearer.c:1048 tipc_nl_bearer_enable+0x2c/0x48 net/tipc/bearer.c:1057 genl_family_rcv_msg_doit+0x1e4/0x2d4 net/netlink/genetlink.c:1114
--- net/ipv6/seg6_iptunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6_iptunnel.c +1 -1
@@ -116,7 +116,7 @@ static __be32 seg6_make_flowlabel(struct net *net, struct sk_buff *skb,u32 hash;if (do_flowlabel >0 ) { - hash =skb_get_hash (skb); + hash =skb_get_hash_net (net, skb); hash =rol32 (hash,16 ); flowlabel = (__force __be32 )hash &IPV6_FLOWLABEL_MASK ; }else if (!do_flowlabel && skb->protocol ==htons (ETH_P_IPV6 )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 188/571 i2c: at91: release DMA channels when probe defers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjian Dai <[email protected]>
[ Upstream commit c98bf3b86609a18ab16d067280257326e557c636 ]
at91_twi_probe_master() can return -EPROBE_DEFER from at91_init_twi_recovery_info() after at91_twi_configure_dma() has already claimed the tx/rx DMA channels. at91_twi_probe() then returns without releasing them, and since dma_request_chan() is not devres-managed the channels leak on every deferred probe attempt.
Release the channels before deferring the probe.
--- drivers/i2c/busses/i2c-at91-master.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-at91-master.c +7 -1
@@ -919,8 +919,14 @@ int at91_twi_probe_master(struct platform_device *pdev,at91_calc_twi_clock (dev); rc =at91_init_twi_recovery_info (pdev, dev); -if (rc == -EPROBE_DEFER ) +if (rc == -EPROBE_DEFER ) { +/* +* The DMA channels were already set up above, release them +* before deferring the probe so they are not leaked. +*/ +at91_twi_dma_release (dev);return rc; + } dev->adapter.algo = &at91_twi_algorithm; dev->adapter.quirks = &at91_twi_quirks;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 189/571 perf: Fix race between perf_event_exit_task() and perf_pending_task()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luo Gengkun <[email protected]>
[ Upstream commit ffb684f2aa141eeb0caa6308422e7e05d1ded7c4 ]
A race condition exists between perf_event_exit_task() and perf_pending_task() during begin_new_exec().
During begin_new_exec(), perf_event_exit_task() may be called, and the PF_EXITING flag is not set on task. So perf_sigtrap() continues to execute and triggers WARN_ON_ONCE(event->ctx->task != current).
Since both task exit and exec paths can call perf_event_exit_task() which sets ctx->task to TASK_TOMBSTONE, fix this by explicitly checking if event->ctx->task equals TASK_TOMBSTONE and dropping the redundant PF_EXITING check.
--- kernel/events/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/events/core.c +4 -2
@@ -6692,9 +6692,11 @@ static void perf_sigtrap(struct perf_event *event) {/* * Both perf_pending_task() and perf_pending_irq() can race with the -* task exiting. +* task exiting or exec-ing. We can determine if such a race has +* occurred by checking if perf_event_exit_task(), which will set +* ctx->task to TASK_TOMBSTONE, has already been called. */ -if (current->flags &PF_EXITING ) +if (event->ctx->task ==TASK_TOMBSTONE )return ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 190/571 PCI: Accept AtomicOps already enabled by the hypervisor
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Prica <[email protected]>
[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]
pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology.
In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk.
After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success.
--- drivers/pci/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci.c +14 -1
@@ -3637,8 +3637,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) } root =pcie_find_root_port (dev); -if (!root) +if (!root) { + +/* +* A hypervisor may expose a topology with the root port +* not visible to the guest. If the hypervisor has already +* set AtomicOp Requester Enable in the endpoint, we assume +* it has verified support in the root port, so it is safe +* for the driver to use AtomicOps. +*/ +pcie_capability_read_dword (dev,PCI_EXP_DEVCTL2 , &ctl2); +if (ctl2 &PCI_EXP_DEVCTL2_ATOMIC_REQ ) +return 0 ; +return -EINVAL ; + }pcie_capability_read_dword (root,PCI_EXP_DEVCAP2 , &cap);if ((cap & cap_mask) != cap_mask)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 191/571 drm/radeon: Read the VRAM VBIOS signature with readb()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
commit de1eab13efef83fd2b76f4688de5bf672644596f upstream.
igp_read_bios_from_vram() checked bios[0]/bios[1] with a plain __iomem load, which faults on sparc64 before the copy runs at all. radeon_read_bios() already reads its two signature bytes with readb() ahead of its own copy; use the same accessor here, keeping the check before the allocation.
--- drivers/gpu/drm/radeon/radeon_bios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_bios.c +5 -1
@@ -49,6 +49,7 @@static bool igp_read_bios_from_vram (struct radeon_device *rdev) {uint8_t __iomem *bios; +uint8_t val1, val2;resource_size_t vram_base;resource_size_t size =256 *1024 ;/* ??? */
@@ -63,7 +64,10 @@ static bool igp_read_bios_from_vram(strureturn false; } -if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { + val1 =readb (&bios[0 ]); + val2 =readb (&bios[1 ]); + +if (size ==0 || val1 !=0x55 || val2 !=0xaa ) {iounmap (bios);return false; }
Greg Kroah-Hartman
maintainerPATCH 192/571 kgdboc: Fix tty driver reference leak in configure_kgdboc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit ef3134cd0d4831ae2137aee2883987859b80b2c6 upstream.
tty_find_polling_driver() returns the tty driver with an extra reference taken by tty_driver_kref_get(). configure_kgdboc() stores it in kgdb_tty_driver but the reference is never dropped: it is leaked when kgdb_register_io_module() fails, when the configuration is cleared, and on every reconfigure.
Release the reference both when unconfiguring and on the error path.
--- drivers/tty/serial/kgdboc.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/tty/serial/kgdboc.c +9 -0
@@ -190,6 +190,11 @@ static void cleanup_kgdboc(void)return ;kgdboc_unregister_kbd ();kgdb_unregister_io_module (&kgdboc_io_ops); + +if (kgdb_tty_driver) { +tty_driver_kref_put (kgdb_tty_driver); + kgdb_tty_driver =NULL ; + } }static int configure_kgdboc (void )
@@ -250,6 +255,10 @@ nmi_con_failed:kgdb_unregister_io_module (&kgdboc_io_ops); noconfig:kgdboc_unregister_kbd (); +if (kgdb_tty_driver) { +tty_driver_kref_put (kgdb_tty_driver); + kgdb_tty_driver =NULL ; + } configured =0 ;return err;
Greg Kroah-Hartman
maintainerPATCH 193/571 Input: atkbd - skip deactivate for Lenovo IdeaPad Slim 3 15IWC11
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martino Papero <[email protected]>
commit 3bf8d603fd45649c106cae6290a10f20b1bbb569 upstream.
The internal keyboard on the Lenovo IdeaPad Slim 3 15IWC11 (83RR) does not work correctly with the default i8042 settings. Using i8042.nopnp=1 and i8042.dumbkbd=1 restores keyboard input, but prevents the Caps Lock LED from working. Using i8042.nopnp=1 alone does not fix the keyboard.
The laptop works correctly when atkbd_deactivate_fixup is used instead. Add a DMI quirk for the 83RR to enable it.
This was tested without any i8042 command-line parameters. Keyboard input and the Caps Lock LED work correctly, including after suspend and resume and after a cold boot.
--- drivers/input/keyboard/atkbd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/input/keyboard/atkbd.c +8 -0
@@ -1970,6 +1970,14 @@ static const struct dmi_system_id atkbd_ .callback = atkbd_deactivate_fixup, }, { +/* Lenovo IdeaPad Slim 3 15IWC11 (83RR) */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "83RR"), + }, + .callback = atkbd_deactivate_fixup, + }, + {/* Xiaomi Book Pro 14 (TM2424) */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
Greg Kroah-Hartman
maintainerPATCH 194/571 Input: i8042 - add nomux quirk for Fujitsu LIFEBOOK U7410
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit 495cd7f858b45d2ffa9b685bba3a8c23c1ca4dd3 upstream.
On the Fujitsu LIFEBOOK U7410 the internal keyboard and touchpad die shortly after boot if i8042 multiplexing controller is probed and switched to muxed mode. These multiplexing setup commands disturb the EC emulated keyboard and atkbd reports "Spurious ACK" and "Unknown key pressed" warnings, after which both keyboard and touchpad stop delivering events. Both touchpad and keyboard work in BIOS and GRUB.
Disabling multiplexer using i8042.nomux=1 makes both devices work on warm/cold boot.
Add a DMI quirk to force nomux mode for this model.
--- drivers/input/serio/i8042-acpipnpio.h | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +9 -0
@@ -661,6 +661,15 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOAUX) }, { +/* Fujitsu LIFEBOOK U7410 */ +/* Mux mode also disturbs the EC keyboard, causing spurious ACKs */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU CLIENT COMPUTING LIMITED" ), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U7410"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX ) + }, + {/* Gigabyte M912 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
Greg Kroah-Hartman
maintainerPATCH 195/571 Input: synaptics - add LEN205b entry to smbus_pnp_ids for ThinkPad T490
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit a961417c5ae77bbb728a23d9577ecd8f4d8a4b5a upstream.
Lenovo ThinkPad T490 has a Synaptics Touchpad that supports SMBus/RMI4 mode, but is not listed in smbus_pnp_ids table.
Add LEN205b to smbus_pnp_ids[] passlist.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -188,6 +188,7 @@ static const char * const smbus_pnp_ids["LEN2054" ,/* E480 */ "LEN2055" ,/* E580 */ "LEN2058" ,/* E490 */ +"LEN205b" ,/* T490 */ "LEN2068" ,/* T14 Gen 1 */ "SYN1221" ,/* TUXEDO InfinityBook Pro 14 v5 */ "SYN3003", /* HP EliteBook 850 G1 */
Greg Kroah-Hartman
maintainerPATCH 196/571 Input: synaptics - limit T440p InterTouch quirk to LEN0036
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphaël Larocque <[email protected]>
commit f0fd8993082ca229faa3f9844f1c9fe182eca20b upstream.
The ThinkPad L440 also uses board id 2722, but does not have the SMBus initialization problem seen on the T440p. On the L440, the SMBus companion becomes available shortly after psmouse probes, allowing the touchpad to use SMBus/RMI4 normally.
The T440p's quirk is currently applied to all Synaptics touchpads with board id 2722, unnecessarily disabling SMBus InterTouch on the L440, as reported by Daniel Salmun.
Restrict the quirk to PNP ID LEN0036, which identifies the T440p, so that other devices sharing board id 2722 retain their normal SMBus/RMI4 operation.
--- drivers/input/mouse/synaptics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +4 -2
@@ -1809,8 +1809,10 @@ static int synaptics_setup_intertouch(streturn -ENXIO ; } -/* Disable intertouch on known-broken board revisions */ -if (info->board_id ==2722 ) { +/* Disable intertouch on known-broken T440p board revisions */ +if (info->board_id ==2722 && +psmouse_matches_pnp_id (psmouse, + (const char *const []){"LEN0036" ,NULL })) {psmouse_info (psmouse,"Disabling intertouch for board id %u\n" , info->board_id);
Greg Kroah-Hartman
maintainerPATCH 197/571 nitro_enclaves: fix use-after-free on SLOT_ALLOC failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuxiao Wang <[email protected]>
commit 9bc184a2eda8b773c88ecbff934001ad649b9cc1 upstream.
When ne_create_vm_ioctl() fails the SLOT_ALLOC request after anon_inode_getfile() has succeeded, the error path calls fput(enclave_file) and then frees ne_enclave.
In normal userspace context, fput() defers the final __fput() via task_work. ne_enclave_release() therefore runs after ne_enclave has already been freed and dereferences ne_enclave->slot_uid, causing a
use-after-free: KASAN: slab-use-after-free in ne_enclave_release.
The enclave has no slot allocated and is not yet linked into the enclaves list on this error path, so ne_enclave_release() is expected to return early when slot_uid is zero. However, reading slot_uid already accesses the freed object.
Clear enclave_file->private_data before fput() on the error path. ne_enclave_release() then returns immediately when private_data is NULL, leaving the ioctl error path as the sole owner of ne_enclave. This is safe because the file has not been fd_install()'d yet.
Tested on an AWS EC2 m5.2xlarge with CONFIG_KASAN=y. Without the patch, the reproducer triggers a KASAN slab-use-after-free on every SLOT_ALLOC failure. With the patch, no KASAN report is produced and the SLOT_ALLOC error is still returned. Normal enclave creation and teardown are unaffected.
--- drivers/virt/nitro_enclaves/ne_misc_dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/virt/nitro_enclaves/ne_misc_dev.c +1 -0
@@ -1654,6 +1654,7 @@ static int ne_create_vm_ioctl(struct ne_return enclave_fd; put_file: + enclave_file->private_data =NULL ;fput (enclave_file); put_fd:put_unused_fd (enclave_fd);
Greg Kroah-Hartman
maintainerPATCH 198/571 USB: cdc-acm: fix racy TIOCMIWAIT implementation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit be4219dd98608736e13e0b790ef742b76a13254d upstream.
Check the wakeup condition after adding the task to the waitqueue and updating the task state to avoid missing a racing modem status update or disconnect.
Store the old icount on entry and do not update it in the completion handler to avoid missing events or reporting spurious ones (due to modem status changes before TIOCMIWAIT was called).
--- drivers/usb/class/cdc-acm.c | 36 +++++++++++++++++++----------------- drivers/usb/class/cdc-acm.h | 1 - 2 files changed, 19 insertions(+), 18 deletions(-)
drivers/usb/class/cdc-acm.c +19 -17
@@ -320,7 +320,6 @@ static void acm_process_notification(str difference = acm->ctrlin ^ newctrl;spin_lock_irqsave (&acm->read_lock, flags); acm->ctrlin = newctrl; - acm->oldcount = acm->iocount;if (difference &ACM_CTRL_DSR ) acm->iocount.dsr++;
@@ -994,11 +993,16 @@ static int wait_serial_change(struct acmDECLARE_WAITQUEUE (wait, current);struct async_icount old, new; - do { +spin_lock_irq (&acm->read_lock); + old = acm->iocount; +spin_unlock_irq (&acm->read_lock); + +add_wait_queue (&acm->wioctl, &wait); +for (;;) { +set_current_state (TASK_INTERRUPTIBLE ); +spin_lock_irq (&acm->read_lock); - old = acm->oldcount; new = acm->iocount; - acm->oldcount = new;spin_unlock_irq (&acm->read_lock); if ((arg & TIOCM_DSR) &&
@@ -1011,22 +1015,20 @@ static int wait_serial_change(struct acm old.rng != new.rng)break ; -add_wait_queue (&acm->wioctl, &wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule (); -remove_wait_queue (&acm->wioctl, &wait);if (acm->disconnected) { -if (arg &TIOCM_CD ) -break ; -else - rv = -ENODEV ; - }else { -if (signal_pending (current)) - rv = -ERESTARTSYS ; + rv = -ENODEV ; +break ; } - }while (!rv); - +schedule (); + +if (signal_pending (current)) { + rv = -ERESTARTSYS ; +break ; + } + } +__set_current_state (TASK_RUNNING ); +remove_wait_queue (&acm->wioctl, &wait);return rv; }
drivers/usb/class/cdc-acm.h +0 -1
@@ -118,7 +118,6 @@ struct acm {unsigned int ctrlin;/* input control lines (DCD, DSR, RI, break, overruns) */ unsigned int ctrlout;/* output control lines (DTR, RTS) */ struct async_icount iocount;/* counters for control line changes */ -struct async_icount oldcount;/* for comparison of counter */ wait_queue_head_t wioctl;/* for ioctl */ unsigned int writesize;/* max packet size for the output bulk endpoint */ unsigned int readsize,ctrlsize;/* buffer sizes for freeing */
Greg Kroah-Hartman
maintainerPATCH 199/571 USB: serial: fix port tear down use-after-free
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 33c920f7c5952dfc42d1b8ea6efe16b1f0bb0c5b upstream.
Some drivers for multiport devices access port driver data from completion handlers of shared URBs submitted at attach() or first open() and stopped at disconnect() or last close(), respectively.
A simple NULL check before accessing the driver data makes sure that a port state container has at least been allocated, but a completion handler can still race with port tear down.
Reorder the disconnect handling so that ports are not deregistered (and their driver data freed) until after all ports have been hung up and the driver disconnect() callback has run so that all I/O has been stopped.
--- drivers/usb/serial/usb-serial.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/serial/usb-serial.c +7 -2
@@ -1198,12 +1198,17 @@ static void usb_serial_disconnect(structusb_serial_port_poison_urbs (port);wake_up_interruptible (&port->port.delta_msr_wait);cancel_work_sync (&port->work); -if (device_is_registered (&port->dev)) -device_del (&port->dev); } +if (serial->type->disconnect) serial->type->disconnect (serial); +for (i =0 ; i < serial->num_ports; ++i) { + port = serial->port[i]; +if (device_is_registered (&port->dev)) +device_del (&port->dev); + } +release_sibling (serial, interface);/* let the last holder of this object cause it to be cleaned up */
Greg Kroah-Hartman
maintainerPATCH 200/571 usb: storage: sierra_ms: reject short SWoC info transfers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Syed Labeeq Sajid Bukhari <[email protected]>
commit 8a0200d14acd9db388b85cd016e68a4e60d900ec upstream.
sierra_get_swoc_info() requests sizeof(struct swoc_info) (60) bytes from the device via usb_control_msg(), but its callers only treat a negative return value as failure. A device that answers the vendor-specific GetSwocInfo request with a short IN transfer is therefore accepted, leaving the tail of the freshly allocated (kmalloc(), non-zeroing) swoc_info buffer uninitialized.
truinst_show() subsequently prints swocInfo->rev, swocInfo->LinuxSKU and swocInfo->LinuxVer from that buffer into the world-readable (0444) "truinst" sysfs attribute. An emulated/malicious USB device (VID 0x1199, PID 0x0fff) can exploit this to disclose up to 5 bytes of stale kernel heap memory (kmalloc-64) to unprivileged userspace, once per sysfs read, indefinitely. On kernels built without init_on_alloc this leaks recently freed heap contents.
Only accept the transfer when the full structure was received. sierra_ms_init() already retries failed queries, so well-behaved devices are unaffected.
--- drivers/usb/storage/sierra_ms.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/sierra_ms.c +7 -0
@@ -77,6 +77,13 @@ static int sierra_get_swoc_info(struct usizeof (struct swoc_info ),/* __u16 size */ USB_CTRL_SET_TIMEOUT); /* int timeout */ +/* +* A short IN transfer leaves the tail of swocInfo uninitialized; +* only a full transfer is valid. +*/ +if (result !=sizeof (struct swoc_info )) +return -EIO ; + swocInfo->LinuxSKU =le16_to_cpu (swocInfo->LinuxSKU); swocInfo->LinuxVer =le16_to_cpu (swocInfo->LinuxVer);return result;
Greg Kroah-Hartman
maintainerPATCH 201/571 usb: hub: use shorter 120ms post resume hold for SS root hubs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit 29480b05e6e226594dc11ccf2a036fbd5cdd0e42 upstream.
Holding a USB3 hub PM runtime reference for 200ms at hub resume triggers an AMD platform issue. Users running Android adb report crashes after adb has been polling and waking up the USB subsystem once a second for some time. Vendors are working on a solution. Disabling USB runtime PM is one way to prevent this issue, but it is also proven that reducing the hold time to 120ms in resume also mitigates it. See Link for more details.
Reducing the hold time to 120ms for the USB3 roothub is in itself a valid change and optimization, as the current 200ms is excessive: a root hub has no upstream suspended hub whose wake propagation needs to be accounted for, but still need some time for USB3 link training to complete.
Keep the 200ms hold for external hubs that commit 8f5b7e2bec1c ("usb: hub: fix detection of high tier USB3 devices behind suspended hubs") is intended for.
--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +6 -1
@@ -56,8 +56,11 @@/* * Give SS hubs 200ms time after wake to train downstream links before * assuming no port activity and allowing hub to runtime suspend back. +* Root hubs have no upstream hub whose wake propagation needs to be +* accounted for, so they need less time, use 120ms for them. */ #define USB_SS_PORT_U0_WAKE_TIME 200/* ms */ +#define USB_SS_RH_PORT_U0_WAKE_TIME 120/* ms */ /* Protect struct usb_device->state and ->children members * Note: Both are also protected by ->dev.sem, except that ->state can
@@ -1319,7 +1322,9 @@ static void hub_activate(struct usb_hubqueue_delayed_work (system_power_efficient_wq, &hub->post_resume_work, -msecs_to_jiffies (USB_SS_PORT_U0_WAKE_TIME )); +msecs_to_jiffies (hdev->parent ? +USB_SS_PORT_U0_WAKE_TIME : +USB_SS_RH_PORT_U0_WAKE_TIME ));return ; }
Greg Kroah-Hartman
maintainerPATCH 202/571 usb: ohci-da8xx: disable controller wakeup on cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 901197dd4c7dcffbf97426487d4c047555c98554 upstream.
The OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Probe enables wakeup, but neither removal nor a later notifier registration failure disables it, leaving the wakeup source attached.
Disable controller wakeup after removing the HCD on both paths.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-da8xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/ohci-da8xx.c +2 -0
@@ -464,6 +464,7 @@ static int ohci_da8xx_probe(struct platf err_remove_hcd:usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller); err:usb_put_hcd (hcd);return error;
@@ -474,6 +475,7 @@ static int ohci_da8xx_remove(struct platstruct usb_hcd *hcd =platform_get_drvdata (pdev);usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);usb_put_hcd (hcd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 203/571 usb: ohci-s3c2410: disable controller wakeup on removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 8dd8451c527e2a723bca20da5a6d724b8592551f upstream.
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind.
Disable controller wakeup after removing the HCD.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-s3c2410.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-s3c2410.c +1 -0
@@ -337,6 +337,7 @@ ohci_hcd_s3c2410_remove(struct platform_struct usb_hcd *hcd =platform_get_drvdata (dev);usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);s3c2410_stop_hc (dev);usb_put_hcd (hcd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 204/571 usb: ohci-st: disable controller wakeup on removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 08b2ccd7eb7e41f77a04a09112ca3edcc588e3f0 upstream.
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind.
Disable controller wakeup after removing the HCD.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-st.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-st.c +1 -0
@@ -243,6 +243,7 @@ static int st_ohci_platform_remove(strucint clk;usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);if (pdata->power_off) pdata->power_off (dev);
Greg Kroah-Hartman
maintainerPATCH 205/571 usb: gadget: f_uac1_legacy: validate bRequest index in generic_{set,get}_cmd
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Chao <[email protected]>
commit 9062d50e75c24dc7911be05c9b1719b3b256af15 upstream.
generic_set_cmd() and generic_get_cmd() use the low nibble of ctrl->bRequest as an index into con->data[]:
u8 cmd = (ctrl->bRequest & 0x0F); /* 0 .. 15 */
...
con->data[cmd] = value; /* OOB when cmd >= 5 */struct usb_audio_control (include/linux/usb/audio.h) declares data as a 5-element array, so indices 5 through 15 write (or read) up to 44 bytes past the end of the array on the heap.
A malicious USB host can craft a class-specific SET_CUR / GET_CUR request with an arbitrary bRequest value, triggering the out-of-bounds access from an IRQ completion handler with no further preconditions.
Add an ARRAY_SIZE() guard to both functions.
--- drivers/usb/gadget/function/f_uac1_legacy.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/gadget/function/f_uac1_legacy.c +6 -0
@@ -797,6 +797,9 @@ fail:static int generic_set_cmd (struct usb_audio_control *con,u8 cmd,int value) { +if (cmd >=ARRAY_SIZE (con->data)) +return -EINVAL ; + con->data[cmd] = value;return 0 ;
@@ -804,6 +807,9 @@ static int generic_set_cmd(struct usb_austatic int generic_get_cmd (struct usb_audio_control *con,u8 cmd) { +if (cmd >=ARRAY_SIZE (con->data)) +return -EINVAL ; +return con->data[cmd]; }
Greg Kroah-Hartman
maintainerPATCH 206/571 usb: gadget: aspeed-vhub: cancel wake work on device removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 20388c8d1d74c203fec8194c45cd31afdfab934e upstream.
wake_work is armed from the gadget .wakeup callback to resume suspended downstream ports, and it is never cancelled in ast_vhub_remove(), so a work item queued before or during removal can run after devm has freed vhub and its ports, a use-after-free.
Cancelling the work alone is not sufficient: usb_gadget_wakeup() takes no lock and the unbind path never clears wakeup_en, so a remote-wakeup request in flight on another CPU can re-arm the work after the cancel and before vhub is freed.
ast_vhub_del_dev() already clears d->registered under vhub->lock before unregistering the gadget. Refuse the wakeup in ast_vhub_udc_wakeup() once d->registered is clear: the check and the schedule_work() are then atomic against the unbind, so a wakeup that passed before the flag was cleared is drained by the cancel_work_sync() after the del_dev loop, and one that arrives later returns without arming. Also move INIT_WORK() to the top of ast_vhub_probe(), since the probe error path reuses ast_vhub_remove() and would otherwise cancel a never-initialized work item.
This issue was found by an in-house static analysis tool.
--- drivers/usb/gadget/udc/aspeed-vhub/core.c | 4 ++++ drivers/usb/gadget/udc/aspeed-vhub/dev.c | 2 +- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 5 +++-- drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/aspeed-vhub/core.c +4 -0
@@ -267,6 +267,9 @@ static int ast_vhub_remove(struct platfofor (i =0 ; i < vhub->max_ports; i++)ast_vhub_del_dev (&vhub->ports[i].dev); +/* Final drain; the worker takes vhub->lock, so stay outside of it */ +cancel_work_sync (&vhub->wake_work); +spin_lock_irqsave (&vhub->lock, flags);/* Mask & ack all interrupts */
@@ -327,6 +330,7 @@ static int ast_vhub_probe(struct platforreturn -ENOMEM ;spin_lock_init (&vhub->lock); +INIT_WORK (&vhub->wake_work, ast_vhub_wake_work); vhub->pdev = pdev; vhub->port_irq_mask =GENMASK (VHUB_IRQ_DEV1_BIT + vhub->max_ports -1 ,VHUB_IRQ_DEV1_BIT );
drivers/usb/gadget/udc/aspeed-vhub/dev.c +1 -1
@@ -270,7 +270,7 @@ static int ast_vhub_udc_wakeup(struct usint rc = -EINVAL ;spin_lock_irqsave (&d->vhub->lock, flags); -if (!d->wakeup_en) +if (!d->wakeup_en || !d->registered) goto err;DDBG (d,"Device initiated wakeup\n" );
drivers/usb/gadget/udc/aspeed-vhub/hub.c +3 -2
@@ -527,7 +527,7 @@ void ast_vhub_device_connect(struct ast_ast_vhub_send_host_wakeup (vhub); } -static void ast_vhub_wake_work (struct work_struct *work) +void ast_vhub_wake_work (struct work_struct *work) { struct ast_vhub *vhub = container_of(work, struct ast_vhub,
@@ -557,6 +557,8 @@ static void ast_vhub_wake_work(struct wovoid ast_vhub_hub_wake_all (struct ast_vhub *vhub) { +lockdep_assert_held (&vhub->lock); +/* * A device is trying to wake the world, because this * can recurse into the device, we break the call chain
@@ -1041,7 +1043,6 @@ static int ast_vhub_init_desc(struct astint ast_vhub_init_hub (struct ast_vhub *vhub) { vhub->speed =USB_SPEED_UNKNOWN ; -INIT_WORK (&vhub->wake_work, ast_vhub_wake_work);return ast_vhub_init_desc (vhub); }
drivers/usb/gadget/udc/aspeed-vhub/vhub.h +1 -0
@@ -545,6 +545,7 @@ void ast_vhub_hub_suspend(struct ast_vhuvoid ast_vhub_hub_resume (struct ast_vhub *vhub);void ast_vhub_hub_reset (struct ast_vhub *vhub);void ast_vhub_hub_wake_all (struct ast_vhub *vhub); +void ast_vhub_wake_work (struct work_struct *work);/* dev.c */ int ast_vhub_init_dev (struct ast_vhub *vhub,unsigned int idx);
Greg Kroah-Hartman
maintainerPATCH 207/571 USB: gadget: dummy-hcd: Fix wait for outstanding request completions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit b263ff9b0fc5c1f371d65c4eb196b31263d039ff upstream.
The dummy-hcd driver emulates synchronize_irq() by waiting until its private callback_usage counter drops to 0 (with the private lock not held). This counter is incremented whenever a gadget driver callback occurs (which requires the private lock to be dropped), but not when a request completion handler is called.
This is an oversight. Request completion is triggered by timer interrupts (emulating device IRQs in a real UDC), and the interrupt handlers are supposed to have completed when the synchronize_irq() emulation routine returns -- they aren't supposed to be in the middle of a completion callback. If this happens it can lead to a gadget driver's unbind routine running before all outstanding request completions have finished, maybe even allowing the gadget driver's module to be unloaded while a completion handler is still running.
Fix the oversight by incrementing the callback_usage value across request completion callbacks.
--- drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +4 -0
@@ -339,9 +339,11 @@ static void dummy_giveback(struct dummy {bool fifo = req == &dum->fifo_req; + ++dum->callback_usage;spin_unlock (&dum->lock);usb_gadget_giveback_request (_ep, &req->req);spin_lock (&dum->lock); + --dum->callback_usage;if (fifo) dum->fifo_req_busy =0 ; }
@@ -755,11 +757,13 @@ static int dummy_queue(struct usb_ep *_e req->req.complete = fifo_complete;list_add_tail (&req->queue, &ep->queue); + ++dum->callback_usage;spin_unlock (&dum->lock); _req->actual = _req->length; _req->status =0 ;usb_gadget_giveback_request (_ep, _req);spin_lock (&dum->lock); + --dum->callback_usage; }else list_add_tail (&req->queue, &ep->queue);spin_unlock_irqrestore (&dum->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 208/571 usb: gadget: f_fs: Fix NULL pointer dereference in FUNCTIONFS_ENDPOINT_DESC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchao Zhang <[email protected]>
commit 9cd072788c76595529eb38f42bf94d23852f8534 upstream.
When user space sets up FunctionFS with only full-speed descriptors (e.g., flags = FUNCTIONFS_HAS_FS_DESC) and the gadget operates at a higher speed (such as USB_SPEED_HIGH or USB_SPEED_SUPER), config_ep_by_speed() detects that the function lacks descriptors for the current speed, logs a warning, and falls back to full-speed descriptors. The endpoint is then successfully enabled via usb_ep_enable(), and epfile->ep becomes valid.
However, when user space subsequently issues the FUNCTIONFS_ENDPOINT_DESC ioctl to query the endpoint descriptor, ffs_epfile_ioctl() selects the descriptor index solely based on gadget->speed:
switch (epfile->ffs->gadget->speed) {
case USB_SPEED_SUPER:
case USB_SPEED_SUPER_PLUS:
desc_idx = 2;
break;
case USB_SPEED_HIGH:
desc_idx = 1;
break;
default:
desc_idx = 0;
}
desc = epfile->ep->descs[desc_idx];
memcpy(&desc1, desc, desc->bLength);Because user space only supplied full-speed descriptors, epfile->ep->descs[1] is NULL. Dereferencing desc->bLength triggers an immediate kernel NULL pointer dereference panic.
Fix this by falling back through lower speed descriptors if the current speed descriptor was not supplied, matching the fallback logic in config_ep_by_speed() and historical f_fs behavior. If still missing, fall back to epfile->ep->ep->desc (the active descriptor), and return -EINVAL safely if no valid descriptor is found. In addition, mark desc as const to match struct usb_ep::desc and avoid discarding qualifiers.
--- drivers/usb/gadget/function/f_fs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_fs.c +13 -2
@@ -1351,8 +1351,9 @@ static long ffs_epfile_ioctl(struct filebreak ;case FUNCTIONFS_ENDPOINT_DESC : { +const struct usb_endpoint_descriptor *desc; +struct usb_endpoint_descriptor desc1;int desc_idx; -struct usb_endpoint_descriptor desc1, *desc;switch (epfile->ffs->gadget->speed) {case USB_SPEED_SUPER :
@@ -1366,7 +1367,17 @@ static long ffs_epfile_ioctl(struct file desc_idx =0 ; } - desc = epfile->ep->descs[desc_idx]; +do { + desc = epfile->ep->descs[desc_idx]; + }while (!desc && --desc_idx >=0 ); + +if (!desc) + desc = epfile->ep->ep->desc; +if (!desc) { + ret = -EINVAL ; +break ; + } +memcpy (&desc1, desc, desc->bLength);spin_unlock_irq (&epfile->ffs->eps_lock);
Greg Kroah-Hartman
maintainerPATCH 209/571 usb: core: clear both ep_in and ep_out for non-ep0 control endpoints
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit 0e8baa78d872f2db440d8b9ded946ab8dceb89eb upstream.
In usb_enable_endpoint(), non-zero control endpoints (where usb_endpoint_xfer_control(&ep->desc) is true) populate both dev->ep_in[epnum] and dev->ep_out[epnum] with the same struct usb_host_endpoint pointer.
However, usb_disable_endpoint() only clears either dev->ep_out[epnum] or dev->ep_in[epnum] depending on the direction bit of epaddr when reset_hardware is set, leaving the opposite direction's array slot pointing to the disabled/freed endpoint.
Clear both dev->ep_out[epnum] and dev->ep_in[epnum] when disabling a non-ep0 control endpoint with reset_hardware set, and update the function kerneldoc accordingly.
Tested in QEMU against Linux 7.3.0-rc3 using dummy_hcd and raw-gadget to enumerate a USB device with a non-zero control endpoint (bEndpointAddress 0x01, bmAttributes USB_ENDPOINT_XFER_CONTROL), verifying that both dev->ep_in[1] and dev->ep_out[1] are cleared when the interface is disabled.
--- drivers/usb/core/message.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/core/message.c +7 -1
@@ -1331,7 +1331,8 @@ static void remove_intf_ep_devs(struct u* * Disables the endpoint for URB submission and nukes all pending URBs. * If @reset_hardware is set then also deallocates hcd/hardware state -* for the endpoint. +* for the endpoint (clearing both ep_in and ep_out pointers for +* bidirectional non-ep0 control endpoints). */ void usb_disable_endpoint (struct usb_device *dev,unsigned int epaddr,bool reset_hardware)
@@ -1352,6 +1353,11 @@ void usb_disable_endpoint(struct usb_dev dev->ep_in[epnum] =NULL ; }if (ep) { +if (reset_hardware && epnum !=0 && +usb_endpoint_xfer_control (&ep->desc)) { + dev->ep_out[epnum] =NULL ; + dev->ep_in[epnum] =NULL ; + } ep->enabled =0 ;usb_hcd_flush_endpoint (dev, ep);if (reset_hardware)
Greg Kroah-Hartman
maintainerPATCH 210/571 usb: typec: tcpm: recover after failure to start the frs ams
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Sunil Dhamne <[email protected]>
commit 90156585765b29304f07b0e4a1c56a969876fcfc upstream.
Reset the port if the tcpm fails to start the FAST_ROLE_SWAP AMS by initiating error recovery on it.
This helps in cases where some cables (incorrectly) signal an FRS to an FRS capable port during disconnection. The TCPC autonomously starts sourcing VBUS on detecting the FRS signal. However, the VBUS sourcing is left on when the FAST_ROLE_SWAP AMS fails to start (as tcpm_sink_tx_ok is 0 as CC is open due to the cable disconnect). This is because the code sets the state to INVALID_STATE without resetting the port state.
Log snippet before changes:
[ 101.401960] AMS FAST_ROLE_SWAP start [ 101.401971] Sink TX No Go [ 101.401982] sourcing vbus [ 101.401987] VBUS on [ 101.402159] VBUS on [ 109.257809] CC1: 0 -> 0, CC2: 5 -> 0 [state SNK_READY, polarity 1, disconnected] [ 111.267442] VBUS on
After changes:
[ 70.541211] AMS FAST_ROLE_SWAP start [ 70.541220] Sink TX No Go [ 70.541228] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS] [ 70.541362] VBUS on [ 70.541365] sourcing vbus [ 70.541367] VBUS on [ 70.541374] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS] [ 70.541410] disable vbus discharge ret:0 [ 70.543028] Setting usb_comm capable false [ 70.544009] Setting voltage/current limit 0 mV 0 mA [ 70.544034] polarity 0 [ 70.544239] Requesting mux state 0, usb-role 0, orientation 0 [ 70.555550] cc:=0 [ 70.555595] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS] [ 70.555697] VBUS off [ 70.555702] VBUS VSAFE0V [ 70.555762] CC1: 5 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected] [ 70.587794] VBUS off [ 70.587799] VBUS VSAFE0V [ 70.655672] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms] [ 70.655682] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev3 NONE_AMS] [ 70.655686] Start toggling [ 70.656274] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -5459,7 +5459,7 @@ static void tcpm_pd_event_handler(struct port->upcoming_state =FR_SWAP_SEND ; ret =tcpm_ams_start (port,FAST_ROLE_SWAP );if (ret == -EAGAIN ) - port->upcoming_state =INVALID_STATE ; +tcpm_set_state (port,ERROR_RECOVERY ,0 ); }else {tcpm_log (port,"Discarding FRS_SIGNAL! Not in sink ready" ); }
Greg Kroah-Hartman
maintainerPATCH 211/571 usb: typec: tipd: fix uninitialized typec_partner_desc in tps6598x_connect()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radhey Shyam Pandey <[email protected]>
commit c4b27b3605788bbf9e4251f3cd4ab94645ab036f upstream.
tps6598x_connect() passes a stack-allocated typec_partner_desc to typec_register_partner() after initializing only usb_pd, accessory and identity.
typec_register_partner() copies attach and deattach from the descriptor into the partner. With those fields left unset, garbage function pointers may be stored and later invoked from typec_partner_link_device() when a USB device is linked to the port. Uninitialized pd_revision and usb_capability similarly leak stack data through partner sysfs.
Zero-initialize the descriptor so optional callbacks remain NULL and the remaining fields are zero.
--- drivers/usb/typec/tipd/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/typec/tipd/core.c +1 -2
@@ -218,7 +218,7 @@ static void tps6598x_set_data_role(strucstatic int tps6598x_connect (struct tps6598x *tps,u32 status) { -struct typec_partner_desc desc; +struct typec_partner_desc desc = { };enum typec_pwr_opmode mode;u16 pwr_status;int ret;
@@ -234,7 +234,6 @@ static int tps6598x_connect(struct tps65 desc.usb_pd = mode ==TYPEC_PWR_MODE_PD ; desc.accessory =TYPEC_ACCESSORY_NONE ;/* XXX: handle accessories */ - desc.identity =NULL ;if (desc.usb_pd) { ret =tps6598x_read_partner_identity (tps);
Greg Kroah-Hartman
maintainerPATCH 212/571 usb: typec: ucsi: Get the connector fwnode based on reg value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
commit 6c51f09c6db5868a5090e8dd4d7764660c87f1ad upstream.
ucsi_find_fwnode() currently maps UCSI connectors to Device tree connector nodes based on the order in which connector child nodes are described in DT.
This can fail because the ordering of child nodes isn't guaranteed in Device-tree. For example, DTB may contain connector@1 before connector@0, causing connector numbers to be associated with the wrong fwnode. As a result, role switch and Type-C notifications can be delivered to the wrong remote endpoints.
Fix this by using the "reg" property of each connector to match its corresponding fwnode. While at it, if the reg property isn't present, then fall back to the old method.
--- drivers/usb/typec/ucsi/ucsi.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +14 -3
@@ -1081,10 +1081,21 @@ static struct fwnode_handle *ucsi_find_f {struct fwnode_handle *fwnode;int i =1 ; +int ret; +u32 port; -device_for_each_child_node (con->ucsi->dev, fwnode) -if (i++ == con->num) -return fwnode; +device_for_each_child_node (con->ucsi->dev, fwnode) { + ret =fwnode_property_read_u32 (fwnode,"reg" , &port); +if (ret <0 ) { +if (i == con->num) +return fwnode; + }else { +if (port == con->num -1 ) +return fwnode; + } + + i++; + }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 213/571 usb: typec: ucsi: displayport: Current CAM OOB index fixup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jameson Thies <[email protected]>
commit ea31c6498c61307dc0d8ce338a7f268cb8cbdd57 upstream.
Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.
--- drivers/usb/typec/ucsi/displayport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +6 -3
@@ -71,11 +71,14 @@ static int ucsi_displayport_enter(structif (ret <0 ) {if (ucsi->version >0x0100 ) goto err_unlock; - cur =0xff ; } -if (cur <UCSI_MAX_ALTMODES ) { - ret = dp->con->port_altmode[cur] == alt ?0 : -EBUSY ; +if (cur !=0xff ) { +if (cur <UCSI_MAX_ALTMODES ) + ret = dp->con->port_altmode[cur] == alt ?0 : -EBUSY ; +else + ret = -EINVAL ; + goto err_unlock; }
Greg Kroah-Hartman
maintainerPATCH 214/571 usb: cdns3: fix use-after-free in cdns3_gadget_exit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit ebe9b68c396792c15d0ac690d592e449e74ed804 upstream.
cdns3_gadget_start() arms two works on system_freezable_wq:pending_status_wq for the deferred ep0 status stage and aligned_buf_wq for realigned request buffers. Both handlers use the cdns3_device the works are embedded in, and cdns3_pending_setup_status_handler() also calls the ep0 request completion.
cdns3_gadget_exit() does not wait for these works. It frees all endpoints and aligned buffers and drops the last reference to the gadget device, which frees priv_dev, so a work queued before the exit can run after the free.
Fix this by waiting for both works after the gadget driver is unbound and the IRQ is freed, when no new work can be queued, and before the endpoints and buffers are released.
This issue was found by an in-house static analysis tool.
--- drivers/usb/cdns3/cdns3-gadget.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/cdns3/cdns3-gadget.c +4 -0
@@ -3265,6 +3265,10 @@ static void cdns3_gadget_exit(struct cdnusb_del_gadget (&priv_dev->gadget);devm_free_irq (cdns->dev, cdns->dev_irq, priv_dev); +/* The works can still be queued until the IRQ is freed. */ +cancel_work_sync (&priv_dev->pending_status_wq); +cancel_work_sync (&priv_dev->aligned_buf_wq); +cdns3_free_all_eps (priv_dev);while (!list_empty (&priv_dev->aligned_buf_list)) {
Greg Kroah-Hartman
maintainerPATCH 215/571 usb: cdns3: Fix NULL pointer dereference in cdns3_pci_probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Deng <[email protected]>
commit e5052f2c5c73c1dcca42bafc0bc737af2b2af059 upstream.
The Cadence USBSS controller is a two-function PCI device. The first probed function allocates the driver data and stores it with pci_set_drvdata(), while the second function reuses it via pci_get_drvdata() when pci_is_enabled() reports that the first function has already been probed.
When the second function is probed while the first one has been enabled but has not yet set its driver data, pci_get_drvdata() returns NULL, and the subsequent wrap->devfn assignment dereferences a NULL pointer and crashes the kernel.
logs:
Call trace: cdns3_pci_probe+0xa4/0x300 local_pci_probe+0x44/0xa8 pci_call_probe+0x54/0x158 pci_device_probe+0x84/0x100 really_probe+0x184/0x3d0 __driver_probe_device+0x80/0x178 driver_probe_device+0x44/0xe8 __driver_attach+0xec/0x1f8 bus_for_each_dev+0x7c/0xe0 driver_attach+0x28/0x38 bus_add_driver+0x110/0x238 driver_register+0x64/0x128 __pci_register_driver+0x50/0x60 cdns3_pci_driver_init+0x28/0x38 do_one_initcall+0x5c/0x280 do_initcalls+0x104/0x1d8 kernel_init_freeable+0x140/0x218 kernel_init+0x28/0x1f8 ret_from_fork+0x10/0x20
Return -EPROBE_DEFER in this case so that probing is retried after the first function has completed its probe.
--- drivers/usb/cdns3/cdns3-pci-wrap.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/cdns3/cdns3-pci-wrap.c +5 -0
@@ -99,6 +99,11 @@ static int cdns3_pci_probe(struct pci_deif (pci_is_enabled (func)) { wrap =pci_get_drvdata (func); +if (!wrap) { +dev_err (&pdev->dev, +"second function not initialized, retrying\n" ); +return -EPROBE_DEFER ; + } }else { wrap =kzalloc (sizeof (*wrap),GFP_KERNEL );if (!wrap)
Greg Kroah-Hartman
maintainerPATCH 216/571 tty: amiserial: fix broken TIOCMIWAIT
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 615f35fd5aee169cc4881a8594f2fa234a4d0bb8 upstream.
A change replacing interruptible_sleep_on() inadvertently broke the TIOCMIWAIT implementation which now immediately returns -EIO (unless there is a racing modem status update).
Replace the old hangup (and signal) detection with a check for the TTY_IO_ERROR flag which is set on hangup.
--- drivers/tty/amiserial.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/amiserial.c +4 -5
@@ -1144,11 +1144,6 @@ static int rs_ioctl(struct tty_struct *tlocal_irq_save (flags); cnow = info->icount;/* atomic copy */ local_irq_restore (flags); -if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { - ret = -EIO ;/* no change => error */ -break ; - } if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
@@ -1156,6 +1151,10 @@ static int rs_ioctl(struct tty_struct *t ret =0 ;break ; } +if (tty_io_error (tty)) { + ret = -EIO ; +break ; + }schedule ();/* see if a signal did it */ if (signal_pending (current)) {
Greg Kroah-Hartman
maintainerPATCH 217/571 tty: vcc: zero-initialize control packet in vcc_send_ctl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
commit 1f71f565e3585da1098ff19ca3c24687dab59185 upstream.
The stack-allocated struct vio_vcc pkt was partially initialized, leaving the tag.stype_env field uninitialized before being sent via ldc_write(), potentially leaking kernel stack data to the LDC peer.
--- drivers/tty/vcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vcc.c +1 -1
@@ -491,7 +491,7 @@ static ssize_t domain_show(struct devicestatic int vcc_send_ctl (struct vcc_port *port,int ctl) { -struct vio_vcc pkt; +struct vio_vcc pkt = {};int rv; pkt.tag.type =VIO_TYPE_CTRL ;
Greg Kroah-Hartman
maintainerPATCH 218/571 tty: vcc: hold port lock when clearing tty pointer in vcc_cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
commit 03b49c991abb8d021ca6fe51cd173447236b0552 upstream.
vcc_cleanup() sets port->tty to NULL without holding port->lock, racing with vcc_event() LDC callbacks that read port->tty under port->lock and then use tty->port. This can cause a use-after-free when the callback dereferences tty->port after cleanup has already destroyed and freed it.
--- drivers/tty/vcc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vcc.c +2 -1
@@ -985,7 +985,8 @@ static void vcc_cleanup(struct tty_struc port =vcc_get (tty->index, true);if (port) { - port->tty =NULL ; +scoped_guard (spinlock_irqsave, &port->lock) + port->tty = NULL;if (port->removed) {vcc_table_remove (tty->index);
Greg Kroah-Hartman
maintainerPATCH 219/571 tty: serial: qcom_geni_serial: Keep console RX functional after deep idle
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viken Dadhaniya <[email protected]>
commit 63ef71d1474b5417b5b2dec700cd251c44a570d9 upstream.
At baud rates up to 115200, the serial console uses only a 1 kBps keepalive vote for the GENI_TO_CORE ("qup-core") ICC path. This vote keeps the path active but does not request a QUP Core 2X clock rate.
When the CPU enters a deeper idle state, the missing Core clock vote can leave the console RX path unresponsive.
Use the 19.2 MHz Core 2X vote at low baud rates, while retaining the 50 MHz vote at higher baud rates, so that console RX remains functional after deep idle transitions.
--- drivers/tty/serial/qcom_geni_serial.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +2 -3
@@ -1017,9 +1017,8 @@ static void qcom_geni_serial_set_termios* Bump up BW vote on CPU and CORE path as driver supports FIFO mode * only. */ - avg_bw_core = (baud >115200 ) ?Bps_to_icc (CORE_2X_50_MHZ ) - :GENI_DEFAULT_BW ; - port->se.icc_paths[GENI_TO_CORE ].avg_bw = avg_bw_core; + avg_bw_core = baud >115200 ?CORE_2X_50_MHZ :CORE_2X_19_2_MHZ ; + port->se.icc_paths[GENI_TO_CORE ].avg_bw =Bps_to_icc (avg_bw_core); port->se.icc_paths[CPU_TO_GENI ].avg_bw =Bps_to_icc (baud);geni_icc_set_bw (&port->se);
Greg Kroah-Hartman
maintainerPATCH 220/571 serial: 8250_bcm7271: fix use-after-free in brcmuart_remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 189b9dc8c96ec9486482f27c1372b04a7152175e upstream.
brcmuart_handle_irq() starts priv->hrt to work around a receive-timeout quirk of the 8250 core when hardware flow control is enabled; the timer callback brcmuart_hrtimer_func() dereferences priv.
brcmuart_remove() cancels the hrtimer before it unregisters the port, so a receive-timeout interrupt that arrives in between re-arms the timer. After devm frees priv, the callback runs on freed memory.
Unregister the port before cancelling the hrtimer. serial8250_unregister_port() shuts the port down and frees its IRQ, so brcmuart_handle_irq() can no longer restart the timer, and the final hrtimer_cancel() drains any timer that was armed before or during the unregister.
This issue was found by an in-house static analysis tool.
--- drivers/tty/serial/8250/8250_bcm7271.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_bcm7271.c +1 -1
@@ -1155,8 +1155,8 @@ static int brcmuart_remove(struct platfostruct brcmuart_priv *priv =platform_get_drvdata (pdev);debugfs_remove_recursive (priv->debugfs_dir); -hrtimer_cancel (&priv->hrt);serial8250_unregister_port (priv->line); +hrtimer_cancel (&priv->hrt);brcmuart_free_bufs (&pdev->dev, priv);clk_disable_unprepare (priv->baud_mux_clk);if (priv->dma_enabled)
Greg Kroah-Hartman
maintainerPATCH 221/571 serial: tegra: dont clear the Tx FIFO on an Rx-only reset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Gassner <[email protected]>
commit 8aebfde6e84dceb7d47fe8001e50b754eb45d5df upstream.
tegra_uart_fifo_reset() applies the Tegra30 workaround for "cannot clear the Tx FIFO while FIFO mode is enabled"
unconditionally: it leaves FIFO mode, writes the requested FCR clear bits, and re-enters FIFO mode. Leaving FIFO mode empties both FIFOs, so an Rx-only reset discards queued Tx data as well.
The break handler in tegra_uart_decode_rx_error() calls it with UART_FCR_CLEAR_RCVR only. On a half-duplex RS485 board whose Rx line is pulled low while the transceiver drives the bus, every transmission raises a spurious break, and all but the first character of the frame is lost.
Only take the FIFO-mode path when the caller actually asked for CLEAR_XMIT. Likewise only wait for TEMT in that case: with the Tx FIFO deliberately left intact, that loop would otherwise spin for a full frame time in hard IRQ context with the port lock held.
Tested on a Colibri T30 (Tegra30) with Rx DMA:
- Break during transmission: the reset still fires from tegra_uart_decode_rx_error(), and the complete frame now reaches the peer. Before this change only the character in the shift register was sent.
- Internal loopback with a generated break: the Rx FIFO is correctly cleared by the plain FCR write, and subsequent receive works with no frame, parity or overrun errors.
--- drivers/tty/serial/serial-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +16 -2
@@ -307,11 +307,19 @@ static void tegra_uart_fifo_reset(struct {unsigned long fcr = tup->fcr_shadow;unsigned int lsr, tmout =10000 ; +bool clear_tx = !!(fcr_bits &UART_FCR_CLEAR_XMIT );if (tup->rts_active)set_rts (tup, false); -if (tup->cdata->allow_txfifo_reset_fifo_mode) { +/* +* Leaving FIFO mode below is a workaround for a Tegra30 +* restriction on clearing the Tx FIFO while FIFO mode is +* enabled. It empties both FIFOs, so applying it to an +* Rx-only reset would destroy an in-flight transmission. +* Only take that path when the caller asked for CLEAR_XMIT. +*/ +if (tup->cdata->allow_txfifo_reset_fifo_mode || !clear_tx) { fcr |= fcr_bits & (UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT );tegra_uart_write (tup, fcr,UART_FCR ); }else {
@@ -336,9 +344,15 @@ static void tegra_uart_fifo_reset(struct*/ tegra_uart_wait_cycle_time (tup,32 ); +/* +* Only wait for the transmitter to drain when the Tx FIFO was +* part of the reset. For an Rx-only reset it is left intact, +* and waiting for TEMT here would spin for a full frame time. +*/ do { lsr =tegra_uart_read (tup,UART_LSR ); -if ((lsr &UART_LSR_TEMT ) && !(lsr &UART_LSR_DR )) +if ((!clear_tx || (lsr &UART_LSR_TEMT )) && + !(lsr &UART_LSR_DR ))break ;udelay (1 ); }while (--tmout);
Greg Kroah-Hartman
maintainerPATCH 222/571 serial: vt8500: Fix clock reference leak in vt8500_serial_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 9d8955281d9229a899e2041659a59b389027b711 upstream.
of_clk_get() returns a clock with a reference that has to be released with clk_put(). If clk_prepare_enable() fails the function returns without doing so, leaking the reference.
Add the missing clk_put() on that error path.
--- drivers/tty/serial/vt8500_serial.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/vt8500_serial.c +1 -0
@@ -677,6 +677,7 @@ static int vt8500_serial_probe(struct pl ret =clk_prepare_enable (vt8500_port->clk);if (ret) {dev_err (&pdev->dev,"failed to enable clock\n" ); +clk_put (vt8500_port->clk);return ret; }
Greg Kroah-Hartman
maintainerPATCH 223/571 ASoC: qcom: lpass-cpu: use DAI table index for playback constraints
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zimeng Li <[email protected]>
commit ca51771c8efde5df05476ac98dd1b2af4e2b149f upstream.
The DAI ID is a hardware port ID and is not necessarily the index of the corresponding entry in variant->dai_driver.
When configuring a DAI with LPAIF_I2SCTL_MODE_QUAD01, the probe code currently uses dai_id to index variant->dai_driver. This is incorrect for platforms where DAI IDs are sparse. For example, the IPQ806x MI2S DAI has ID 4 while it is the only entry in the DAI driver table. If that DAI is configured for QUAD01 and probe reaches this branch, the code writes beyond that single entry via dai_driver[4] instead of updating the DAI being processed.
Use the loop index i when updating the current DAI's playback channel constraints, while retaining dai_id for indexing the hardware-port specific playback SD-line mode array.
This fixes the incorrect DAI table access for platforms where the DAI ID does not match its position in the driver table.
--- sound/soc/qcom/lpass-cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/qcom/lpass-cpu.c +2 -2
@@ -967,8 +967,8 @@ int asoc_qcom_lpass_cpu_platform_probe(s }if (drvdata->mi2s_playback_sd_mode[dai_id] ==LPAIF_I2SCTL_MODE_QUAD01 ) { - variant->dai_driver[dai_id].playback.channels_min =4 ; - variant->dai_driver[dai_id].playback.channels_max =4 ; + variant->dai_driver[i].playback.channels_min =4 ; + variant->dai_driver[i].playback.channels_max =4 ; } }
Greg Kroah-Hartman
maintainerPATCH 224/571 ALSA: ua101: reject mismatched capture/playback packet sizes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 86f86e6fdedc33c5b8d38b9208b350f8accf57ee upstream.
detect_usb_format() cross-checks bSubframeSize, bBitResolution and tSamFreq between the capture and playback interfaces, but never relates the two endpoints' wMaxPacketSize and bNrChannels. Each playback URB gets a buffer of ua->playback.max_packet_bytes, while the number of bytes written into it is derived from the capture stream:capture_urb_complete() computes frames from the received capture packet and capture.frame_bytes, and start_usb_playback() and playback_work() multiply that by playback.frame_bytes.
A device declaring a large capture wMaxPacketSize with few capture channels and a small playback wMaxPacketSize with many playback channels therefore memset()s and memcpy()s past the end of the playback buffer, in open() of the PCM node the driver registers during probe. usb_submit_urb() rejects the over-long iso_frame_desc[0].length with -EMSGSIZE, but only after the write.
Reject such descriptors at probe time. Genuine UA-101/UA-1000 hardware declares proportional packet sizes and is unaffected.
BUG: KASAN: slab-out-of-bounds in start_usb_playback (sound/usb/misc/ua101.c:586) Write of size 2048 at addr ffff8881098f3c00 by task exploit/5021 Call Trace: __asan_memset (mm/kasan/shadow.c:84) start_usb_playback (sound/usb/misc/ua101.c:586) playback_pcm_open (sound/usb/misc/ua101.c:679) snd_pcm_open_substream (sound/core/pcm_native.c:2829) snd_pcm_open (sound/core/pcm_native.c:2865 sound/core/pcm_native.c:2932) snd_pcm_playback_open (sound/core/pcm_native.c:2891) snd_open (sound/core/sound.c:166) chrdev_open (fs/char_dev.c:411) do_dentry_open (fs/open.c:996) vfs_open (fs/open.c:1101) path_openat (fs/namei.c:4837 fs/namei.c:5000) do_file_open (fs/namei.c:5029) do_sys_openat2 (fs/open.c:1417) __x64_sys_openat (fs/open.c:1423 fs/open.c:1439 fs/open.c:1434) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address belongs to the object at ffff8881098f3c00 which belongs to the cache kmalloc-192 of size 192 The buggy address is located 0 bytes inside of allocated 168-byte region [ffff8881098f3c00, ffff8881098f3ca8)
--- sound/usb/misc/ua101.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/usb/misc/ua101.c +9 -0
@@ -1022,6 +1022,15 @@ static int detect_usb_format(struct ua10 } ua->playback.usb_pipe =usb_sndisocpipe (ua->dev,usb_endpoint_num (epd)); ua->playback.max_packet_bytes =usb_endpoint_maxp (epd); + +if (ua->capture.max_packet_bytes / ua->capture.frame_bytes * + ua->playback.frame_bytes > ua->playback.max_packet_bytes) { +dev_err (&ua->dev->dev, +"playback packet size %u too small for %u capture frames\n" , + ua->playback.max_packet_bytes, + ua->capture.max_packet_bytes / ua->capture.frame_bytes); +return -ENXIO ; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 225/571 Bluetooth: RFCOMM: Fix initial port reference race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 2d696c1ed3468dcb62578a3911e687110d463520 upstream.
For RFCOMM_RELEASE_ONHUP devices, rfcomm_tty_install() and __rfcomm_release_dev() both use RFCOMM_TTY_OWNED to decide who drops the initial tty_port reference. The release path tests the bit separately from the install path setting it, so both can drop that reference.
The synchronous hangup does not prevent this race: port->tty is not assigned until tty_port_open(), after installation. The following interleaving is possible:
1. Install and release each obtain a reference with rfcomm_dev_get().
2. Release observes RFCOMM_TTY_OWNED clear.
3. Install sets RFCOMM_TTY_OWNED and drops the initial reference.
4. Release drops the same initial reference again.
5. TTY cleanup drops its reference and frees the device.
6. Release performs its final tty_port_put() on the freed port.
KASAN reported:
BUG: KASAN: slab-use-after-free in tty_port_put+0x22/0x190 Write of size 4 at addr ffff8881001d3d5c by task poc/92 Call Trace: tty_port_put+0x22/0x190 rfcomm_dev_ioctl+0x1d4/0x1930 sock_do_ioctl+0x110/0x260 sock_ioctl+0x380/0x590 __x64_sys_ioctl+0x134/0x1c0 Allocated by task 88: rfcomm_dev_ioctl+0x8f6/0x1930 sock_do_ioctl+0x110/0x260 sock_ioctl+0x380/0x590 __x64_sys_ioctl+0x134/0x1c0 Freed by task 65: kfree+0x131/0x3c0 rfcomm_dev_destruct+0x23b/0x2f0 release_one_tty+0xc1/0x370 process_one_work+0x661/0x1090
Use test_and_set_bit() in both paths so that only the caller that changes RFCOMM_TTY_OWNED from clear to set drops the initial reference. Each path keeps its own lookup reference until release or TTY cleanup, preserving the existing callback ordering and error handling.
--- net/bluetooth/rfcomm/tty.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/bluetooth/rfcomm/tty.c +3 -4
@@ -471,7 +471,7 @@ static int __rfcomm_release_dev(void __utty_kref_put (tty); } -if (!test_bit (RFCOMM_TTY_OWNED , &dev->status)) +if (!test_and_set_bit (RFCOMM_TTY_OWNED , &dev->status))tty_port_put (&dev->port);tty_port_put (&dev->port);
@@ -736,10 +736,9 @@ static int rfcomm_tty_install(struct tty* when the last process closes the tty. The behaviour is expected by * userspace. */ -if (test_bit (RFCOMM_RELEASE_ONHUP , &dev->flags)) { -set_bit (RFCOMM_TTY_OWNED , &dev->status); +if (test_bit (RFCOMM_RELEASE_ONHUP , &dev->flags) && + !test_and_set_bit (RFCOMM_TTY_OWNED , &dev->status))tty_port_put (&dev->port); - }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 226/571 Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
commit 74847177eca5638827ab74cdf77f0b10fc40ca6c upstream.
On 64-bit systems, outgoing BR/EDR connections always fall back to page scan repetition mode R2 with no clock offset once the system has been up for more than five minutes, even when inquiry found the peer only seconds earlier. This lengthens paging and can increase the risk of a Page Timeout.
The inquiry cache stores jiffies in __u32 timestamps, but its age helpers subtract them from unsigned long jiffies. INITIAL_JIFFIES casts -300 * HZ through unsigned int, so jiffies crosses 2^32 five minutes after boot on 64-bit systems. Assigning it to __u32 then drops the upper 32 bits. In one trace, a 7.6-second-old entry (HZ=1000) was reported as 2^32 + 7620 ticks old and rejected by hci_acl_create_conn_sync(). hci_inquiry() is affected by the same truncation when checking the whole cache. 32-bit systems are unaffected because unsigned long is 32 bits wide there.
Use unsigned long for both timestamps so they have the same width as jiffies on 32-bit and 64-bit systems, and update the debugfs format specifier accordingly.
--- include/net/bluetooth/hci_core.h | 4 ++-- net/bluetooth/hci_debugfs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/bluetooth/hci_core.h +2 -2
@@ -60,7 +60,7 @@ struct inquiry_entry {NAME_PENDING ,NAME_KNOWN , } name_state; -__u32 timestamp; +unsigned long timestamp;struct inquiry_data data; };
@@ -76,7 +76,7 @@ struct discovery_state {struct list_head all;/* All devices found during inquiry */ struct list_head unknown;/* Name state not known */ struct list_head resolve;/* Name needs to be resolved */ -__u32 timestamp; +unsigned long timestamp;bdaddr_t last_adv_addr;u8 last_adv_addr_type;s8 last_adv_rssi;
net/bluetooth/hci_debugfs.c +1 -1
@@ -366,7 +366,7 @@ static int inquiry_cache_show(struct seqlist_for_each_entry (e, &cache->all, all) {struct inquiry_data *data = &e->data; - seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", + seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %lu\n", &data->bdaddr, data->pscan_rep_mode, data->pscan_period_mode, data->pscan_mode, data->dev_class[2],
Greg Kroah-Hartman
maintainerPATCH 227/571 Bluetooth: hci_core: Serialize ACL scheduling with channel deletion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit f4845ab191a4f686a5da481fbba90ed73bb693b0 upstream.
hci_chan_sent() selects a channel under RCU but drops the read lock before accessing chan->conn and returning the channel. The ACL and LE schedulers then use its packet queue and update its transmit counters without any protection against channel deletion.
After TX selects a channel and releases RCU, a disconnect command timeout on the separate request workqueue can run hci_conn_failed() and l2cap_conn_del(). hci_chan_del() can then unlink the channel, complete synchronize_rcu(), purge its queue and free it before TX resumes. This causes use-after-free both in hci_chan_sent() and in its callers.
KASAN reported:
BUG: KASAN: slab-use-after-free in hci_chan_sent+0x892/0x9b0 Workqueue: hci0 hci_tx_work Call Trace: hci_chan_sent+0x892/0x9b0 hci_tx_work+0x5e6/0xb70 Allocated by task 91: hci_chan_create+0xe3/0x350 l2cap_conn_add.part.0+0x12/0xa30 l2cap_chan_connect+0x110d/0x1b60 l2cap_sock_connect+0x310/0x530 Freed by task 99: hci_chan_del+0x11f/0x170 l2cap_conn_del+0x4f1/0x800 l2cap_connect_cfm+0x88c/0xd30 hci_conn_failed+0x150/0x250 hci_abort_conn_sync+0x3e3/0x800 hci_cmd_sync_run+0x7e/0xc0 hci_abort_conn+0x105/0x1f0 disconnect_sync+0x157/0x290 hci_cmd_sync_work+0x13c/0x290
Hold the existing device mutex across channel selection and transmission in both schedulers to serialize them with channel teardown. Keep timeout handling outside the critical sections because hci_link_tx_to() acquires the same mutex. This also permits the transmit path to sleep, unlike extending the RCU read-side critical section across packet submission.
--- net/bluetooth/hci_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/hci_core.c +8 -0
@@ -4794,6 +4794,8 @@ static void hci_sched_acl_pkt(struct hci__check_timeout (hdev, cnt,ACL_LINK ); +hci_dev_lock (hdev); +while (hdev->acl_cnt && (chan =hci_chan_sent (hdev,ACL_LINK , "e))) {u32 priority = (skb_peek (&chan->data_q))->priority;
@@ -4825,6 +4827,8 @@ static void hci_sched_acl_pkt(struct hciif (cnt != hdev->acl_cnt)hci_prio_recalculate (hdev,ACL_LINK ); + +hci_dev_unlock (hdev); }static void hci_sched_acl_blk (struct hci_dev *hdev)
@@ -4919,6 +4923,8 @@ static void hci_sched_le(struct hci_dev__check_timeout (hdev, *cnt,LE_LINK ); +hci_dev_lock (hdev); + tmp = *cnt;while (*cnt && (chan =hci_chan_sent (hdev,LE_LINK , "e))) {u32 priority = (skb_peek (&chan->data_q))->priority;
@@ -4947,6 +4953,8 @@ static void hci_sched_le(struct hci_devif (*cnt != tmp)hci_prio_recalculate (hdev,LE_LINK ); + +hci_dev_unlock (hdev); }static void hci_tx_work (struct work_struct *work)
Greg Kroah-Hartman
maintainerPATCH 228/571 Bluetooth: btintel: fix buffer over-read in btintel_hw_error()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrashekar Devegowda <[email protected]>
commit 40eb4b18ad167b63644c27fa67a7400ba050379a upstream.
The "Exception info %s" print uses skb->data + 1, but the 12-byte payload is not guaranteed to be NUL-terminated and can be read past its end.
Bound the print with "%.*s" and skb->len - 1.
--- drivers/bluetooth/btintel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btintel.c +2 -1
@@ -246,7 +246,8 @@ static void btintel_hw_error(struct hci_return ; } -bt_dev_err (hdev,"Exception info %s" , (char *)(skb->data +1 )); +bt_dev_err (hdev,"Exception info %.*s" , (int )(skb->len -1 ), + (char *)(skb->data +1 ));kfree_skb (skb); }
Greg Kroah-Hartman
maintainerPATCH 229/571 ipvs: bound LBLCR and LBLC cache growth
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 2a3c3de660f96865f303fd25f1285f2ffbfd521d ]
ip_vs_lblcr_new() and ip_vs_lblc_new() create cache entries for every previously unseen destination address. The table max_size only tells the periodic collector to reclaim entries after the cache has already exceeded the limit. It does not reclaim entries that the attacker continues to use.
Reject new cache entries once either table reaches max_size * 3 / 2. The extra headroom lets the periodic collector catch up while the existing scheduler fallback continues to use the selected destination when cache creation fails. New traffic therefore stays serviceable without growing the tables further.
--- net/netfilter/ipvs/ip_vs_lblc.c | 3 +++ net/netfilter/ipvs/ip_vs_lblcr.c | 3 +++ 2 files changed, 6 insertions(+)
net/netfilter/ipvs/ip_vs_lblc.c +3 -0
@@ -207,6 +207,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,ip_vs_lblc_del (en);atomic_dec (&tbl->entries); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)return NULL ;
net/netfilter/ipvs/ip_vs_lblcr.c +3 -0
@@ -365,6 +365,9 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, en =ip_vs_lblcr_get (af, tbl, daddr);if (!en) { +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/571 kprobes: Skip disarmed probes when checking optkprobe overlap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 7a39c732a22ec4a369af9e19fbe3d666ec83eec4 ]
On x86, an optkprobe at A replaces five bytes with a jump. If a disabled probe B is at A+2, get_optimized_kprobe() stops at B when arming a new probe C at A+4. It leaves A optimized:
A A+1 A+2 A+3 A+4 A's jump | e9 | d0 | d1 | d2 | d3 | after C | e9 | d0 | d1 | d2 | cc |
The INT3 for C overwrites the last byte of A's jump displacement, so execution can jump to the wrong address. B can have prepared optinsns while disarmed, but has no jump to unoptimize.
Continue past disarmed and unprepared probes to find the active optimized probe before arming a probe in its jump.
--- kernel/kprobes.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/kprobes.c +5 -3
@@ -485,14 +485,16 @@ static int kprobe_queued(struct kprobe *p)static struct kprobe *get_optimized_kprobe (unsigned long addr) {int i; -struct kprobe *p =NULL ; +struct kprobe *p;struct optimized_kprobe *op;/* Don't check i == 0, since that is a breakpoint case. */ -for (i =1 ; !p && i <MAX_OPTIMIZED_LENGTH ; i++) +for (i =1 ; i <MAX_OPTIMIZED_LENGTH ; i++) { p =get_kprobe ((void *)(addr - i)); +/* A disabled probe can have prepared, but inactive, optinsns. */ +if (!p || !kprobe_optready (p) ||kprobe_disarmed (p)) +continue ; -if (p &&kprobe_optready (p)) { op = container_of(p, struct optimized_kprobe, kp);if (arch_within_optimized_kprobe (op, addr))return p;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/571 nvme-multipath: fix underflow in ANA log bounds checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit 63fa2d9c9c37020bd2703fe2a6a38027b5abeb15 upstream.
The number of ANA groups advertised through Identify Controller sizes the ANA log buffer. The ANA log header and group descriptors independently supply the number of groups and namespace IDs to parse.
Both bounds checks subtract an untrusted object size from ana_log_size before comparing the current offset. If the object is larger than the buffer, the size_t subtraction underflows and lets the parser read beyond ana_log_buf.
Check the current offset before the first subtraction and compare each object size with the remaining buffer instead. This rejects inconsistent ANA data before dereferencing a truncated group descriptor or walking an oversized namespace ID array.
--- drivers/nvme/host/multipath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/multipath.c +3 -2
@@ -548,7 +548,8 @@ static int nvme_parse_ana_log(struct nvmu32 nr_nsids;size_t nsid_buf_size; -if (WARN_ON_ONCE (offset > ctrl->ana_log_size -sizeof (*desc))) +if (WARN_ON_ONCE (offset > ctrl->ana_log_size || +sizeof (*desc) > ctrl->ana_log_size - offset))return -EINVAL ; nr_nsids =le32_to_cpu (desc->nnsids);
@@ -564,7 +565,7 @@ static int nvme_parse_ana_log(struct nvmreturn -EINVAL ; offset +=sizeof (*desc); -if (WARN_ON_ONCE (offset > ctrl->ana_log_size - nsid_buf_size)) +if (WARN_ON_ONCE (nsid_buf_size > ctrl->ana_log_size - offset))return -EINVAL ; error =cb (ctrl, desc, data);
Greg Kroah-Hartman
maintainerPATCH 232/571 mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 21f027016b1290d13c30b198ae7a00e6b3d1d5a5 upstream.
The Cadence NAND interrupt handler uses both the IRQ lock and completion object. Registering the IRQ before initializing them leaves a window in which a pending interrupt can access uninitialized synchronization state.
Initialize them before registering the handler.
--- drivers/mtd/nand/raw/cadence-nand-controller.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/cadence-nand-controller.c +3 -3
@@ -2850,6 +2850,9 @@ static int cadence_nand_init(struct cdns goto free_buf_desc; } +spin_lock_init (&cdns_ctrl->irq_lock); +init_completion (&cdns_ctrl->complete); +if (devm_request_irq (cdns_ctrl->dev, cdns_ctrl->irq, cadence_nand_isr,IRQF_SHARED ,"cadence-nand-controller" , cdns_ctrl)) {
@@ -2858,9 +2861,6 @@ static int cadence_nand_init(struct cdns goto free_buf; } -spin_lock_init (&cdns_ctrl->irq_lock); -init_completion (&cdns_ctrl->complete); - ret =cadence_nand_hw_init (cdns_ctrl);if (ret) goto disable_irq;
Greg Kroah-Hartman
maintainerPATCH 233/571 mtd: rawnand: vf610_nfc: fix reads on chips with more than 64 bytes of OOB
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
commit 37adc9c5789c76db3b1ee7aeec3999b8503020d0 upstream.
The controller transfers 64 spare bytes per page and the driver only implements the matching 64-byte ECC layout, so attach_chip() shrinks mtd->oobsize when the chip provides more. That clamp does not survive:nand_scan_tail() runs nanddev_init() after ->attach_chip(), and it restores mtd->oobsize from the memory organization, which still holds the value detected from the chip. The driver then transfers writesize plus the chip's full OOB size, the hardware ECC parity ends up at a different offset than the layout the controller was set up for, and every ECC-protected read fails with -EBADMSG.
Measured on a Colibri VF61 (MX30LF4G28AC, 2048-byte pages, 112 bytes of OOB): with the clamp lost, UBI cannot read the erase counter headers of the pages U-Boot has just written, and the on-flash bad block table written by an older kernel reads back with ECC errors, so the board does not boot. Kernels before commit a7ab085d7c16 ("mtd: rawnand:
Initialize the nand_device object") are not affected because nothing overwrote the clamp there, which is why the same chip works with a v4.4 kernel and with U-Boot, whose copy of this driver has no memory organization to restore the value from. Edward Karpicz reported that the clamp no longer takes effect on this chip; see the link below.
Instead of modifying the memory organization, keep the detected OOB size and give the driver its own mtd_ooblayout_ops: the same layout the NAND core uses for large pages, but computed on the first 64 OOB bytes instead of the whole OOB, so the ECC bytes stay where U-Boot and the old kernels put them. The data paths transfer writesize plus those 64 bytes, as the controller always has.
Since mtd->oobsize now reports the chip's real spare size, fill the tail of oob_poi with 0xff after the 64 transferred bytes on ECC page
reads: the core may copy the full mtd->oobsize from it, which would otherwise expose whatever the buffer held before. 0xff also matches what a raw read returns from flash, since the write path only ever programs the first 64 spare bytes.
--- drivers/mtd/nand/raw/vf610_nfc.c | 72 ++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 12 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +60 -12
@@ -504,6 +504,11 @@ static int vf610_nfc_exec_op(struct nand check_only); } +static unsigned int vf610_nfc_spare_size (struct mtd_info *mtd) +{ + return min_t(unsigned int, mtd->oobsize, 64); +} +static inline int vf610_nfc_correct_data (struct nand_chip *chip,uint8_t *dat,uint8_t *oob,int page) {
@@ -521,7 +526,7 @@ static inline int vf610_nfc_correct_datareturn ecc_count; nfc->data_access = true; -nand_read_oob_op (&nfc->chip, page,0 , oob, mtd->oobsize); +nand_read_oob_op (&nfc->chip, page,0 , oob,vf610_nfc_spare_size (mtd)); nfc->data_access = false;/*
@@ -529,7 +534,7 @@ static inline int vf610_nfc_correct_data* at least less then half of the ECC strength. */ return nand_check_erased_ecc_chunk (dat, nfc->chip.ecc.size, oob, - mtd->oobsize,NULL ,0 , +vf610_nfc_spare_size (mtd),NULL ,0 , flips_threshold); }
@@ -550,7 +555,7 @@ static int vf610_nfc_read_page(struct na {struct vf610_nfc *nfc =chip_to_nfc (chip);struct mtd_info *mtd =nand_to_mtd (chip); -int trfr_sz = mtd->writesize + mtd->oobsize; +int trfr_sz = mtd->writesize +vf610_nfc_spare_size (mtd);u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;int stat;
@@ -576,11 +581,16 @@ static int vf610_nfc_read_page(struct na*/ vf610_nfc_rd_from_sram (buf, nfc->regs +NFC_MAIN_AREA (0 ), mtd->writesize, false); -if (oob_required) +if (oob_required) { +unsigned int spare =vf610_nfc_spare_size (mtd); +vf610_nfc_rd_from_sram (chip->oob_poi, nfc->regs +NFC_MAIN_AREA (0 ) + mtd->writesize, - mtd->oobsize, false); + spare, false); +/* Not transferred, and never written: reads back erased */ +memset (chip->oob_poi + spare,0xff , mtd->oobsize - spare); + } stat =vf610_nfc_correct_data (chip, buf, chip->oob_poi, page);
@@ -598,7 +608,7 @@ static int vf610_nfc_write_page(struct n {struct vf610_nfc *nfc =chip_to_nfc (chip);struct mtd_info *mtd =nand_to_mtd (chip); -int trfr_sz = mtd->writesize + mtd->oobsize; +int trfr_sz = mtd->writesize +vf610_nfc_spare_size (mtd);u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;u8 status;int ret;
@@ -739,6 +749,49 @@ static void vf610_nfc_init_controller(st } } +/* +* With 64 byte OOB chips the core's large page layout matches what +* U-Boot uses, and on chips with more, U-Boot and older kernels clamped +* mtd->oobsize to 64. Modifying the OOB size is no longer possible, the +* actual chip geometry must be respected, so to avoid breaking those +* existing setups use our own layout: the core's large page one, +* computed over the first 64 spare bytes only. +*/ +static int vf610_nfc_ooblayout_ecc (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section || !total_ecc_bytes) +return -ERANGE ; + + oobregion->length = total_ecc_bytes; + oobregion->offset =vf610_nfc_spare_size (mtd) - oobregion->length; + +return 0 ; +} + +static int vf610_nfc_ooblayout_free (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section) +return -ERANGE ; + + oobregion->length =vf610_nfc_spare_size (mtd) - total_ecc_bytes -2 ; + oobregion->offset =2 ; + +return 0 ; +} + +static const struct mtd_ooblayout_ops vf610_nfc_ooblayout_ops = { + .ecc = vf610_nfc_ooblayout_ecc, + .free = vf610_nfc_ooblayout_free, +}; +static int vf610_nfc_attach_chip (struct nand_chip *chip) {struct mtd_info *mtd =nand_to_mtd (chip);
@@ -769,12 +822,7 @@ static int vf610_nfc_attach_chip(structreturn -ENXIO ; } -/* Only 64 byte ECC layouts known */ -if (mtd->oobsize >64 ) - mtd->oobsize =64 ; - -/* Use default large page ECC layout defined in NAND core */ -mtd_set_ooblayout (mtd,nand_get_large_page_ooblayout ()); +mtd_set_ooblayout (mtd, &vf610_nfc_ooblayout_ops);if (chip->ecc.strength ==32 ) { nfc->ecc_mode =ECC_60_BYTE ; chip->ecc.bytes =60 ;
Greg Kroah-Hartman
maintainerPATCH 234/571 mtd: spinand: fix zero oobavail when no ECC engine is used
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
commit 636fe10d8f3559210ff63108a208d39ea2e9c3bd upstream.
Commit 00c15b78b4b4 ("mtd: spinand: Allow the case where there is no ECC engine") made the OOB free bytes count conditional on having an ECC engine so that probing would not fail when none is requested. However mtd->oobavail is still assigned from ret just after that block, and ret is 0 there, so the device ends up advertising no available OOB bytes at all.
mtd_oobavail() returns mtd->oobavail for MTD_OPS_AUTO_OOB, so a zero value makes every automatic OOB access fail with -EINVAL. JFFS2 fares
worse: it keeps its cleanmarker in the OOB area on NAND and refuses to mount outright, reporting "inconsistent device description".
No ECC engine also means no ooblayout was ever installed, which would make the count return -ENOTSUPP, so install the same fallback layout the on-die path already uses before counting unconditionally.
--- drivers/mtd/nand/spi/core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/mtd/nand/spi/core.c +9 -4
@@ -1241,12 +1241,17 @@ static int spinand_init(struct spinand_d mtd->_max_bad_blocks = nanddev_mtd_max_bad_blocks; mtd->_resume = spinand_mtd_resume; -if (nand->ecc.engine) { - ret =mtd_ooblayout_count_freebytes (mtd); -if (ret <0 ) - goto err_cleanup_ecc_engine; +if (!nand->ecc.engine) { +if (spinand->eccinfo.ooblayout) +mtd_set_ooblayout (mtd, spinand->eccinfo.ooblayout); +else +mtd_set_ooblayout (mtd, &spinand_noecc_ooblayout); } + ret =mtd_ooblayout_count_freebytes (mtd); +if (ret <0 ) + goto err_cleanup_ecc_engine; + mtd->oobavail = ret;/* Propagate ECC information to mtd_info */
Greg Kroah-Hartman
maintainerPATCH 235/571 wifi: cw1200: fix TX padding OOB read leaking heap data to device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 7c1611780823b76219cb1478db53dfd890c4a9a2 upstream.
The TX path rounds the transfer size up to the bus alignment (align_size(), up to 511 bytes for SDIO, 1 byte for SPI) but sends the padded length straight from the frame buffer, which has no room reserved for the padding. cw1200_data_write() therefore reads past the end of the frame and the bus transfer carries those bytes to the device. A bogus device can collect up to 511 bytes of kernel heap data per TX frame.
The RX path does not have this problem: it allocates the skb with the aligned length (alloc_len) before reading.
Compute the exact padding with the bus align_size() callback, make sure queued TX frames have tailroom for it, and zero the padding bytes before the transfer so nothing past the frame is exposed.
This is not expected to change driver behavior on most cases: frame contents and transfer sizes are unchanged, only the content of the padding bytes (previously undefined stale memory, now zero), which the device never reads since the WSM header carries the real frame length. The skb expansion can only fail under memory exhaustion, in which case the frame is dropped like on the existing error paths of cw1200_tx().
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- drivers/net/wireless/st/cw1200/bh.c | 8 +++++++- drivers/net/wireless/st/cw1200/txrx.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/wireless/st/cw1200/bh.c +7 -1
@@ -349,6 +349,7 @@ static int cw1200_bh_tx_helper(struct cw int *tx_burst) {size_t tx_len; +size_t aligned_len;u8 *data;int ret;struct wsm_hdr *wsm;
@@ -381,9 +382,14 @@ static int cw1200_bh_tx_helper(struct cwatomic_inc (&priv->bh_tx); - tx_len = priv->hwbus_ops->align_size ( + aligned_len = priv->hwbus_ops->align_size ( priv->hwbus_priv, tx_len); +/* Zero the bus alignment padding so no stale data is sent. */ +if (aligned_len > tx_len) +memset (data + tx_len,0 , aligned_len - tx_len); + tx_len = aligned_len; +/* Check if not exceeding CW1200 capabilities */ if (WARN_ON_ONCE (tx_len >EFFECTIVE_BUF_SIZE ))pr_debug ("Write aligned len: %zu\n" , tx_len);
drivers/net/wireless/st/cw1200/txrx.c +14 -0
@@ -14,6 +14,7 @@#include "wsm.h" #include "bh.h" #include "sta.h" +#include "hwbus.h" #include "debug.h" #define CW1200_INVALID_RATE_ID (0xFF)
@@ -716,6 +717,7 @@ void cw1200_tx(struct ieee80211_hw *dev,struct ieee80211_sta *sta;struct wsm_tx *wsm;bool tid_update = false; +size_t pad_len;u8 flags =0 ;int ret;
@@ -765,6 +767,18 @@ void cw1200_tx(struct ieee80211_hw *dev,rcu_read_lock (); sta =rcu_dereference (t.sta); +/* +* The bus transfer is padded up to the bus alignment and the +* padding is transferred from the frame buffer. Make sure the +* buffer has room for the padding so the device never receives +* data past the end of the frame. +*/ + pad_len = priv->hwbus_ops->align_size (priv->hwbus_priv, skb->len) - + skb->len; +if (skb_tailroom (skb) < pad_len && +pskb_expand_head (skb,0 , pad_len,GFP_ATOMIC )) + goto drop; +spin_lock_bh (&priv->ps_state_lock); { tid_update =cw1200_tx_h_pm_state (priv, &t);
Greg Kroah-Hartman
maintainerPATCH 236/571 wifi: iwlegacy: 3945: free EEPROM data on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit f8ebe286394c0bbb4a6dbacb182a34ab6376922d upstream.
il3945_pci_probe() calls il_eeprom_init(), which allocates memory for the EEPROM data. The probe failure paths release this allocation with il_eeprom_free(), but the remove path does not free it after a successful probe.
As a result, the EEPROM data is leaked when the PCI device is removed.
Free the EEPROM data in il3945_pci_remove() before releasing the mac80211 hardware structure.
This issue was found by manual code inspection.
--- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlegacy/3945-mac.c +1 -0
@@ -3845,6 +3845,7 @@ il3945_pci_remove(struct pci_dev *pdev)il_free_channel_map (il);il_free_geos (il); +il_eeprom_free (il);kfree (il->scan_cmd);dev_kfree_skb (il->beacon_skb);ieee80211_free_hw (il->hw);
Greg Kroah-Hartman
maintainerPATCH 237/571 wifi: mac80211: drain PS delivery work during station teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
commit 67a9e80c3ca20c9044cd6ee72cd6278dd19b5023 upstream.
Removing an AP or mesh station can notify the driver and wake TXQs after the station has already been removed from the driver, and can update num_sta_ps and the power-save queues after station cleanup has purged them.
sta_deliver_ps_frames() tests sta->dead only before it starts delivery. A worker that passes that test can be delayed while teardown sets sta->dead and removes the station from the driver; when it resumes it still runs the full delivery.
The existing cancel_work_sync() sits near the end of __cleanup_single_sta(), after the final driver state transition and after PS accounting and queue purging, so it drains the worker only once the state it has to protect has already changed. Before commit d34ba2168a3c ("mac80211: don't delay station destruction") cleanup was deferred through the same ordered workqueue as the delivery work, which kept the two ordered.
Cancel the work after setting sta->dead and before moving the driver state, and move the existing cancellation to the start of __cleanup_single_sta(). The first drain closes the driver-lifetime window; driver callbacks during the remaining state transitions can still queue drv_deliver_wk through ieee80211_sta_block_awake(), so retain the second drain at the start of __cleanup_single_sta(). That drain also covers insertion failures, which reach cleanup without setting sta->dead.
--- net/mac80211/sta_info.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +4 -2
@@ -89,6 +89,8 @@ static void __cleanup_single_sta(structstruct ieee80211_local *local = sdata->local;struct ps_data *ps; +cancel_work_sync (&sta->drv_deliver_wk); +if (test_sta_flag (sta,WLAN_STA_PS_STA ) ||test_sta_flag (sta,WLAN_STA_PS_DRIVER ) ||test_sta_flag (sta,WLAN_STA_PS_DELIVER )) {
@@ -129,8 +131,6 @@ static void __cleanup_single_sta(structif (ieee80211_vif_is_mesh (&sdata->vif))mesh_sta_cleanup (sta); -cancel_work_sync (&sta->drv_deliver_wk); -/* * Destroy aggregation state here. It would be nice to wait for the * driver to finish aggregation stop and then clean up, but for now
@@ -1090,6 +1090,8 @@ static void __sta_info_destroy_part2(str sta->dead = true; +cancel_work_sync (&sta->drv_deliver_wk); + local->num_sta--; local->sta_generation++;
Greg Kroah-Hartman
maintainerPATCH 238/571 wifi: mac80211: minstrel_ht: validate fixed rate index
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuqi Xu <[email protected]>
commit 15fb9e3cea55fbc378261ce35a32b0f8828f0000 upstream.
The fixed_rate_idx debugfs file is a plain u32 attribute, so any value can be written to it. minstrel_ht_update_stats() then copies the value into mi->max_tp_rate[] and mi->max_prob_rate, and minstrel_ht_set_rate() uses MI_RATE_GROUP()/MI_RATE_IDX() to index minstrel_mcs_groups[] (42 entries) and mi->groups[].rates[] (10 entries) with it.
Writing e.g. 65535 selects group 4095 and rate index 15, far outside both arrays. The out-of-bounds entries are dereferenced and updated as struct minstrel_rate_stats (retry counts, etc.), so the invalid index corrupts adjacent kernel memory. With CONFIG_UBSAN_BOUNDS the access is reported as an array-index-out-of-bounds in minstrel_ht_set_rate().
Only a valid group/rate pair, or U32_MAX to disable fixed rate processing, can be used safely, so reject any other value when the debugfs file is written.
The file is only reachable through a root-only debugfs mount, so this is not a privilege boundary. The out-of-bounds access is still a bug that must not be reachable through a writable debugfs attribute.
--- net/mac80211/rc80211_minstrel_ht.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +28 -2
@@ -7,6 +7,7 @@#include <linux/types.h> #include <linux/skbuff.h> #include <linux/debugfs.h> +#include <linux/limits.h> #include <linux/random.h> #include <linux/moduleparam.h> #include <linux/ieee80211.h>
@@ -1852,14 +1853,39 @@ minstrel_ht_alloc(struct ieee80211_hw *h }#ifdef CONFIG_MAC80211_DEBUGFS +static int minstrel_ht_fixed_rate_idx_get (void *data,u64 *val) +{ + *val = *(u32 *)data; +return 0 ; +} + +static int minstrel_ht_fixed_rate_idx_set (void *data,u64 val) +{ +u32 idx = val; + +/* U32_MAX is the default and keeps fixed rate processing disabled */ +if (val !=U32_MAX && + (val >U16_MAX || +MI_RATE_GROUP (idx) >=ARRAY_SIZE (minstrel_mcs_groups) || +MI_RATE_IDX (idx) >=MCS_GROUP_RATES )) +return -EINVAL ; + + *(u32 *)data = idx; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (minstrel_ht_fixed_rate_idx_fops, + minstrel_ht_fixed_rate_idx_get, + minstrel_ht_fixed_rate_idx_set,"%llu\n" ); +static void minstrel_ht_add_debugfs (struct ieee80211_hw *hw,void *priv,struct dentry *debugfsdir) {struct minstrel_priv *mp = priv; mp->fixed_rate_idx = (u32) -1 ; -debugfs_create_u32 ("fixed_rate_idx" ,S_IRUGO |S_IWUGO , debugfsdir, - &mp->fixed_rate_idx); +debugfs_create_file ("fixed_rate_idx" ,S_IRUGO |S_IWUGO , debugfsdir, + &mp->fixed_rate_idx, &minstrel_ht_fixed_rate_idx_fops); }#endif
Greg Kroah-Hartman
maintainerPATCH 239/571 wifi: mac80211: release mesh path quota on failed additions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
commit 7325a44474f20c1393a1c114c6811abce6ddfaf4 upstream.
Repeated failed or duplicate mesh path additions can exhaust MESH_MAX_MPATHS while the path table holds fewer paths, which stops new paths to reachable destinations from being created.
mesh_path_add() reserves a slot before allocating and inserting a path. If allocation fails, the function returns without releasing the slot. If the rhashtable insertion reports an error or an existing destination, the function discards its candidate but retains the reservation. No new path is installed in any of these cases.
Release the reservation whenever the candidate is not installed.
--- net/mac80211/mesh_pathtbl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +4 -1
@@ -407,8 +407,10 @@ struct mesh_path *mesh_path_add(struct ireturn ERR_PTR (-ENOSPC ); new_mpath =mesh_path_new (sdata, dst,GFP_ATOMIC ); -if (!new_mpath) +if (!new_mpath) { +atomic_dec (&sdata->u.mesh.mpaths);return ERR_PTR (-ENOMEM ); + } tbl = &sdata->u.mesh.mesh_paths;spin_lock_bh (&tbl->walk_lock);
@@ -421,6 +423,7 @@ struct mesh_path *mesh_path_add(struct iif (mpath) {kfree (new_mpath); +atomic_dec (&sdata->u.mesh.mpaths);if (IS_ERR (mpath))return mpath;
Greg Kroah-Hartman
maintainerPATCH 240/571 wifi: mac80211: handle empty FILS association request payload
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuqi Xu <[email protected]>
commit 5bfd4b0b40b79781d900cb2f7da0685070f53c67 upstream.
fils_encrypt_assoc_req() accepts a (Re)Association Request frame whose last element is the FILS Session element. crypt_len is then zero and aes_siv_encrypt() is called with an empty plaintext.
kmemdup() returns ZERO_SIZE_PTR for a zero-length allocation, so the unconditional sg_init_one() puts an invalid page into the scatterlist. With CONFIG_DEBUG_SG this triggers a kernel BUG in sg_set_buf(); without the debug check the bogus page is handed to the crypto backend.
AES-SIV is defined for empty plaintext and the S2V result is then the complete output, so handle this case before the CTR step, which has nothing to encrypt.
--- net/mac80211/fils_aead.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mac80211/fils_aead.c +8 -0
@@ -95,6 +95,14 @@ static int aes_siv_encrypt(const u8 *keyif (res)return res; +/* With an empty plaintext there is no ciphertext to produce and +* the S2V result is the complete output. +*/ +if (!plain_len) { +memcpy (out, v,AES_BLOCK_SIZE ); +return 0 ; + } +/* Use a temporary buffer of the plaintext to handle need for * overwriting this during AES-CTR. */
Greg Kroah-Hartman
maintainerPATCH 241/571 USB: serial: cp210x: add Corsair AX1500i Power Supply
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Carrat <[email protected]>
commit d84e27d87738634b92001500435ae4dadba10a13 upstream.
The Corsair AX1500i power supply exposes its Corsair Link monitoring interface on a mini-USB port through an on-board CP2103, using a Corsair-specific product ID. Without the ID in the table no driver binds and no tty is created.
Tested by forcing the driver association with
echo 1b1c 1c02 > /sys/bus/usb-serial/drivers/cp210x/new_id
and then setting the serial port to 115200 8N1. Adding the ID is sufficient to talk to the device: the tty reaches a USB-to-SMBus bridge sitting behind the UART, which identifies itself as "USB to SMB Bridge (Firmware by Ross Fosler)" version 0.9 and relays PMBus reads to the power supply controller. Input voltage and current, input and output power, internal temperature and fan speed were all read back on an AX1500i.
[ 7.806181] usb 3-14: New USB device found, idVendor=1b1c, idProduct=1c02, bcdDevice= 1.00 [ 698.526754] usbcore: registered new interface driver cp210x [ 698.526767] usbserial: USB Serial support registered for cp210x [ 698.527863] cp210x 3-14:1.0: cp210x converter detected [ 698.529263] usb 3-14: cp210x converter now attached to ttyUSB0
The related AX1600i (1b1c:1c11, iProduct "USB API") is expected to be the same kind of device but has not been tested here, so it is not added.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -223,6 +223,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */ { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ + { USB_DEVICE(0x1B1C, 0x1C02) }, /* Corsair AX1500i Power Supply */ { USB_DEVICE(0x1B93, 0x1013) }, /* Phoenix Contact UPS Device */ { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
Greg Kroah-Hartman
maintainerPATCH 242/571 USB: serial: quatech2: fix baud rate overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ec06546b43b612cefc851558981b4955c0ef9e46 upstream.
The requested baud rate is incorrectly truncated to 16 bits so that line speeds above 65535 bps cannot be set.
Use 32 bits for the rate while rejecting rates outside of [50,921600] to avoid having the 16-bit divisor overflow.
--- drivers/usb/serial/quatech2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/usb/serial/quatech2.c +16 -3
@@ -54,6 +54,7 @@#define QT2_XMIT_FLUSH 0x05/* no following info */ #define QT2_CONTROL_ESCAPE 0xff/* pass through previous 2 control bytes */ +#define MIN_BAUD_RATE 50#define MAX_BAUD_RATE 921600#define DEFAULT_BAUD_RATE 9600
@@ -158,7 +159,7 @@ static inline int calc_baud_divisor(intstatic inline int qt2_set_port_config (struct usb_device *dev,unsigned char port_number, -u16 baudrate,u16 lcr) +speed_t baudrate,u16 lcr) {int divisor =calc_baud_divisor (baudrate);u16 index = ((u16) (lcr <<8 ) | (u16) (port_number));
@@ -267,9 +268,9 @@ static void qt2_set_termios(struct tty_sstruct usb_device *dev = port->serial->dev;struct qt2_port_private *port_priv;struct ktermios *termios = &tty->termios; -u16 baud;unsigned int cflag = termios->c_cflag;u16 new_lcr =0 ; +speed_t baud;int status; port_priv =usb_get_serial_port_data (port);
@@ -301,6 +302,18 @@ static void qt2_set_termios(struct tty_sif (!baud) baud =9600 ; +if (baud <MIN_BAUD_RATE || baud >MAX_BAUD_RATE ) { +if (old_termios) + baud =tty_termios_baud_rate (old_termios); +else + baud =clamp (baud,MIN_BAUD_RATE ,MAX_BAUD_RATE ); + +tty_encode_baud_rate (tty, baud, baud); + +if (!baud) + baud =9600 ; + } + status =qt2_set_port_config (dev, port_priv->device_port, baud, new_lcr);if (status <0 )
@@ -397,7 +410,7 @@ static int qt2_open(struct tty_struct *t port_priv->device_port = (u8 ) device_port;if (tty) -qt2_set_termios (tty, port, &tty->termios); +qt2_set_termios (tty, port,NULL );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 243/571 USB: serial: ssu100: fix baud rate overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit afc235a217360c6859068d2e37a4df305c4d1be2 upstream.
The requested baud rate is incorrectly truncated to 16 bits so that line speeds above 65535 bps cannot be set.
Use 32 bits for the rate and remainder while rejecting rates outside of [50,460800] to avoid having the divisor or remainder overflow.
This issue was flagged by an LLM.
--- drivers/usb/serial/ssu100.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/usb/serial/ssu100.c +16 -2
@@ -34,6 +34,7 @@#define SERIAL_EVEN_PARITY (UART_LCR_PARITY | UART_LCR_EPAR) +#define MIN_BAUD_RATE 50#define MAX_BAUD_RATE 460800#define ATC_DISABLED 0x00
@@ -219,9 +220,10 @@ static void ssu100_set_termios(struct tt {struct usb_device *dev = port->serial->dev;struct ktermios *termios = &tty->termios; -u16 baud, divisor, remainder; +speed_t baud, remainder;unsigned int cflag = termios->c_cflag;u16 urb_value =0 ;/* will hold the new flags */ +u16 divisor;int result;if (cflag &PARENB ) {
@@ -251,6 +253,18 @@ static void ssu100_set_termios(struct ttif (!baud) baud =9600 ; +if (baud <MIN_BAUD_RATE || baud >MAX_BAUD_RATE ) { +if (old_termios) + baud =tty_termios_baud_rate (old_termios); +else + baud =clamp (baud,MIN_BAUD_RATE ,MAX_BAUD_RATE ); + +tty_encode_baud_rate (tty, baud, baud); + +if (!baud) + baud =9600 ; + } +dev_dbg (&port->dev,"%s - got baud = %d\n" , __func__, baud);
@@ -326,7 +340,7 @@ static int ssu100_open(struct tty_structdev_dbg (&port->dev,"%s - set uart failed\n" , __func__);if (tty) -ssu100_set_termios (tty, port, &tty->termios); +ssu100_set_termios (tty, port,NULL );return usb_serial_generic_open (tty, port); }
Greg Kroah-Hartman
maintainerPATCH 244/571 USB: serial: fix dynamic id driver deregistration race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 63594e8ffe097bc0b7639936f33799a7653dded2 upstream.
Only free the dynamic ids after having deregistered the driver and removed the "new_id" attribute to avoid leaking any id added by a racing write to the attribute.
--- drivers/usb/serial/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/bus.c +1 -1
@@ -167,7 +167,7 @@ int usb_serial_bus_register(struct usb_svoid usb_serial_bus_deregister (struct usb_serial_driver *driver) { -free_dynids (driver);driver_unregister (&driver->driver); +free_dynids (driver); }
Greg Kroah-Hartman
maintainerPATCH 245/571 USB: serial: option: add support for SIMCom SIM8260C
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
commit 35c950c9ec2c4c4d45dc9b63cfe8fca774ce33a0 upstream.
Add support for SIMCom SIM8260C (1e0e:902b).
T: Bus=08 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=1e0e ProdID=902b Rev= 5.04 S: Manufacturer=SIMCOM S: Product=SDXLEMUR-LITE-MTP _SN:120696AB S: SerialNumber=0123456789ABCDEF C:* #Ifs= 8 Cfg#= 1 Atr=a0 MxPwr=896mA A: FirstIf#= 5 IfCount= 3 Cls=01(audio) Sub=00 Prot=20 I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan_simcom E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=20 Driver=snd-usb-audio I:* If#= 6 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio I: If#= 6 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio E: Ad=05(O) Atr=0d(Isoc) MxPS= 34 Ivl=1ms I:* If#= 7 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=(none) I: If#= 7 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=20 Driver=(none) E: Ad=89(I) Atr=0d(Isoc) MxPS= 34 Ivl=1ms
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -2169,6 +2169,8 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */ .driver_info = RSVD(7) }, + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x902b, 0xff), + .driver_info = RSVD(4) }, { USB_DEVICE(0x1e0e, 0x9071), /* Simcom SIM8230 RMNET mode */ .driver_info = RSVD(3) | RSVD(4) }, { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9078, 0xff), /* Simcom SIM8230 ECM mode */
Greg Kroah-Hartman
maintainerPATCH 246/571 USB: serial: option: add Quectel EG060W
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlo Szelinsky <[email protected]>
commit cd243401994880b8b6810c53177bce56eebaece5 upstream.
Add Quectel EG060W with product ID 0x6004.
The three vendor-specific interfaces are DIAG, NMEA and AT; the CDC-NCM data interfaces are handled by the cdc_ncm driver.
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=2c7c ProdID=6004 Rev= 3.18 S: Manufacturer=Quectel S: Product=EG060W-EAAA S: SerialNumber=123456789ABCD C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr= 2mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0d Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=82(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -281,6 +281,7 @@ static void option_instat_callback(struc#define QUECTEL_PRODUCT_EC200U 0x0901#define QUECTEL_PRODUCT_EG912Y 0x6001#define QUECTEL_PRODUCT_EC200S_CN 0x6002 +#define QUECTEL_PRODUCT_EG060W 0x6004#define QUECTEL_PRODUCT_EC200A 0x6005#define QUECTEL_PRODUCT_EG916Q 0x6007#define QUECTEL_PRODUCT_EM061K_LWW 0x6008
@@ -1269,6 +1270,7 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200A, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200U, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200S_CN, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG060W, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG912Y, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG916Q, 0xff, 0x00, 0x00) },
Greg Kroah-Hartman
maintainerPATCH 247/571 USB: serial: option: add Compal EXM-G1x support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Lin <[email protected]>
commit 7f11480cda081de78a05d8c97073df66326b50b3 upstream.
The Compal EXM-G1x is a Qualcomm SDX12-based LTE modem. Add support for its vendor-specific serial interfaces with protocols 0x30, 0x40, and 0x60.
Relevant output from usb-devices:
T: Bus=04 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs= 1 P: Vendor=04b7 ProdID=8217 Rev=05.04 S: Manufacturer=COMPAL S: Product=EXM-G1x C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=896mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option I: If#= 4 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
Tested on a Compal EXM-G1x modem.
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -2434,6 +2434,9 @@ static const struct usb_device_id option .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) }, { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */ .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */
Greg Kroah-Hartman
maintainerPATCH 248/571 USB: serial: option: add Quectel RG660QB
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Sjoholm <[email protected]>
commit 6177bcd94be83f80a032c2e69a06606d325335b9 upstream.
Add support for the Quectel RG660QB 5G module (USB ID 2c7c:013d). The interface layout is the same as the RG650V:
If 0: DIAG ff/ff/30, 2 endpoints If 1: NMEA ff/00/00, 2 endpoints If 2: AT ff/00/00, 3 endpoints If 3: Modem ff/00/00, 3 endpoints If 4: QMI ff/ff/ff, 3 endpoints
Match the serial interfaces on class/subclass/protocol so that the QMI interface is left to qmi_wwan.
# lsusb -v -d 2c7c:013d
Bus 004 Device 002: ID 2c7c:013d Quectel Wireless Solutions Co., Ltd. RG660QB-EU Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.20
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 9
idVendor 0x2c7c Quectel Wireless Solutions Co., Ltd.
idProduct 0x013d
bcdDevice 6.06
iManufacturer 1 Quectel
iProduct 2 RG660QB-EU
iSerial 3 f50119d0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0105
bNumInterfaces 5
bConfigurationValue 1
iConfiguration 4 DIAG_SER_RMNET
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 896mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 48
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 6 CDEV Serial
** UNRECOGNIZED: 05 24 00 10 01
** UNRECOGNIZED: 05 24 01 00 00
** UNRECOGNIZED: 04 24 02 02
** UNRECOGNIZED: 05 24 06 00 00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x000a 1x 10 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 6 CDEV Serial
** UNRECOGNIZED: 05 24 00 10 01
** UNRECOGNIZED: 05 24 01 00 00
** UNRECOGNIZED: 04 24 02 02
** UNRECOGNIZED: 05 24 06 00 00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x000a 1x 10 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 4
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 7 RmNet
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x88 EP 8 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x87 EP 7 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 6
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 2
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0023
bNumDeviceCaps 2
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000f
Device can operate at Low Speed (1Mbps)
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 0 micro seconds
bU2DevExitLat 0 micro seconds
SuperSpeedPlus USB Device Capability:
bLength 20
bDescriptorType 16
bDevCapabilityType 10
bmAttributes 0x00000001
Sublink Speed Attribute count 1
Sublink Speed ID count 0
wFunctionalitySupport 0x1100
bmSublinkSpeedAttr[0] 0x000a4030
Speed Attribute ID: 0 10Gb/s Symmetric RX SuperSpeedPlus
bmSublinkSpeedAttr[1] 0x000a40b0
Speed Attribute ID: 0 10Gb/s Symmetric TX SuperSpeedPlus
Device Status: 0x0000
(Bus Powered)
Tested with an early sample of the module on a Quectel 5G EVB connected over USB 3 to a Raspberry Pi 5.
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -261,6 +261,7 @@ static void option_instat_callback(struc#define QUECTEL_PRODUCT_EM060K_12a 0x012a#define QUECTEL_PRODUCT_EM060K_12b 0x012b#define QUECTEL_PRODUCT_EM060K_12c 0x012c +#define QUECTEL_PRODUCT_RG660QB 0x013d#define QUECTEL_PRODUCT_EG91 0x0191#define QUECTEL_PRODUCT_EG95 0x0195#define QUECTEL_PRODUCT_BG96 0x0296
@@ -1277,6 +1278,8 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500K, 0xff, 0x00, 0x00) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x40) },
Greg Kroah-Hartman
maintainerPATCH 249/571 USB: serial: option: add Compal EXC-T1 support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Lin <[email protected]>
commit b51faf3f2e307f114854bbe6d495f03cd5370686 upstream.
The Compal EXC-T1 is a Qualcomm MDM9207-based LTE modem which reports "EXC-x1" as its USB product string. It exposes diagnostic, modem, AT, and NMEA ports as vendor-specific interfaces with subclass 0x10 and protocols 0x01 through 0x04.
Add exact interface matches for these four ports, leaving the ff/ff/ff interface unbound.
Relevant output from usb-devices:
T: Bus=03 Lev=02 Prnt=03 Port=03 Cnt=01 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=04b7 ProdID=4d22 Rev=03.18 S: Manufacturer=CEI S: Product=EXC-x1 C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=10 Prot=01 Driver=option I: If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=02 Driver=option I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=03 Driver=option I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=04 Driver=option I: If#= 4 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=05 Driver=qmi_wwan
Tested on a Compal EXC-T1 modem using an Ubuntu kernel build. The four serial interfaces bound to option and exposed ttyUSB3 through ttyUSB6.
--- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -2437,6 +2437,10 @@ static const struct usb_device_id option .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x01) }, /* Compal EXC-T1 */ + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x02) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x03) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x04) }, { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) },
Greg Kroah-Hartman
maintainerPATCH 250/571 thunderbolt: Reject oversized XDomain properties responses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit 80756e263846ab694984e749e8c626897331438f upstream.
tb_xdp_properties_request() allocates room for 45 data dwords in its 252-byte response buffer. The XDomain length field is six bits wide, however, and a malicious peer can set it to 63. After the fixed response fields are subtracted, the driver treats this as 48 data dwords.
Commit 322e93448d90 ("thunderbolt: Clamp XDomain response data copy to allocation size") only bounds the copy against data_len. If data_len is at least 48, memcpy() reads 192 bytes from the 180-byte res->data array, causing a 12-byte heap out-of-bounds read. Commit 4db2bd2ed478 ("thunderbolt: Limit XDomain response copy to actual frame size") limits the earlier copy but does not constrain this header-derived length.
Reject response data lengths that exceed the allocated source buffer before copying them into the assembled property block.
--- drivers/thunderbolt/xdomain.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thunderbolt/xdomain.c +4 -0
@@ -353,6 +353,10 @@ static int tb_xdp_properties_request(str len +=sizeof (res->hdr.xd_hdr) /4 ; len -=sizeof (*res) /4 ; +if (len >TB_XDP_PROPERTIES_MAX_DATA_LENGTH ) { + ret = -EINVAL ; + goto err; + }if (res->offset != req.offset) { ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 251/571 iio: accel: kxcjk-1013: reject duplicate event disable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
commit dd30c10ff60d2b30386c23bb7c61cc97f2385c97 upstream.
The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), dropping a runtime PM reference that was not acquired for this request. This can underflow the runtime PM usage count and trigger a "Runtime PM usage count underflow" warning.
Return early when the requested state already matches ev_enable_state.
--- drivers/iio/accel/kxcjk-1013.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kxcjk-1013.c +1 -1
@@ -1050,7 +1050,7 @@ static int kxcjk1013_write_event_config(struct kxcjk1013_data *data =iio_priv (indio_dev);int ret; -if (state && data->ev_enable_state) +if (state == data->ev_enable_state)return 0 ;mutex_lock (&data->mutex);
Greg Kroah-Hartman
maintainerPATCH 252/571 iio: accel: sca3000: fix frequency divider condition check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit d380bf5f94a892e546d9a94e8557ad866b043a2a upstream.
When setting the sampling frequency, the check for base_freq / 2 is followed by an independent if statement for base_freq / 4. If val equals base_freq / 2, the second check fails and falls through to the else if (val != base_freq) branch, returning -EINVAL erroneously.
Fix this by chaining the checks with else if.
--- drivers/iio/accel/sca3000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/sca3000.c +1 -1
@@ -645,7 +645,7 @@ static int sca3000_write_raw_samp_freq(sif (val == base_freq /2 ) ctrlval |=SCA3000_REG_OUT_CTRL_BUF_DIV_2 ; -if (val == base_freq /4 ) +else if (val == base_freq /4 ) ctrlval |=SCA3000_REG_OUT_CTRL_BUF_DIV_4 ;else if (val != base_freq)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 253/571 iio: adc: sun4i-gpadc-iio: clean up on thermal zone registration failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit 2cdc7ef31827db4fbc6283750420639569e1f0e9 upstream.
If devm_thermal_of_zone_register() fails, probe returns without unregistering the IIO map array or disabling runtime PM.
Jump to err_map to release them.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +4 -4
@@ -645,10 +645,10 @@ static int sun4i_gpadc_probe(struct plat* thermal because no thermal DT node is found. */ if (IS_ERR (info->tzd) &&PTR_ERR (info->tzd) != -ENODEV ) { -dev_err (&pdev->dev, -"could not register thermal sensor: %ld\n" , -PTR_ERR (info->tzd)); -return PTR_ERR (info->tzd); + ret =dev_err_probe (&pdev->dev, +PTR_ERR (info->tzd), +"could not register thermal sensor\n" ); + goto err_map; } }
Greg Kroah-Hartman
maintainerPATCH 254/571 iio: adc: sun4i-gpadc-iio: drop underflowing pm_runtime_put() calls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit 8b958dd214ad0c003f56549e9e039cb8067dc1a2 upstream.
Neither the error path in sun4i_gpadc_probe() nor sun4i_gpadc_remove() ever holds a runtime PM usage count. So the pm_runtime_put() in both places always triggers the "Runtime PM usage count underflow!" warning on every failed probe and every unbind.
Drop both calls.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +0 -2
@@ -664,7 +664,6 @@ err_map:if (!info->no_irq &&IS_ENABLED (CONFIG_THERMAL_OF ))iio_map_array_unregister (indio_dev); -pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);return ret;
@@ -675,7 +674,6 @@ static int sun4i_gpadc_remove(struct plastruct iio_dev *indio_dev =platform_get_drvdata (pdev);struct sun4i_gpadc_iio *info =iio_priv (indio_dev); -pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);if (!IS_ENABLED (CONFIG_THERMAL_OF ))
Greg Kroah-Hartman
maintainerPATCH 255/571 iio: gyro: adis16136: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit 2b498df75d6c29aa3e760127ae0f0003df598b53 upstream.
The serial_number file operations are open coded and never call debugfs_file_get(), which debugfs_create_file_unsafe() requires. debugfs_remove_recursive() therefore does not wait for a read in progress, and unbind frees the iio_dev underneath it.
Use debugfs_create_file() instead.
--- drivers/iio/gyro/adis16136.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/adis16136.c +1 -1
@@ -145,7 +145,7 @@ static int adis16136_debugfs_init(structstruct adis16136 *adis16136 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); -debugfs_create_file_unsafe ("serial_number" ,0400 , +debugfs_create_file ("serial_number" ,0400 , d, adis16136, &adis16136_serial_fops);debugfs_create_file_unsafe ("product_id" ,0400 , d, adis16136, &adis16136_product_id_fops);
Greg Kroah-Hartman
maintainerPATCH 256/571 iio: imu: adis16400: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit d94787287a113a1326211647d5e0deed1e9de105 upstream.
adis16400_serial_number_fops is open coded and never calls debugfs_file_get(), so debugfs_remove_recursive() does not wait for a read in progress and unbind frees the iio_dev underneath it.
Commit ae1d37a9bb4b ("iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE") converted product_id and flash_count to DEFINE_DEBUGFS_ATTRIBUTE, which protects itself, but moved all three files to debugfs_create_file_unsafe().
serial_number prints three registers as "%.4x-%.4x-%.4x" and DEFINE_DEBUGFS_ATTRIBUTE() formats a single u64, so it cannot be converted without changing what the file returns. adis16475 and adis16550 already use debugfs_create_file() for their open coded files. Use it here too.
--- drivers/iio/imu/adis16400.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +1 -1
@@ -279,7 +279,7 @@ static int adis16400_debugfs_init(structstruct dentry *d =iio_get_debugfs_dentry (indio_dev);if (st->variant->flags &ADIS16400_HAS_SERIAL_NUMBER ) -debugfs_create_file_unsafe ("serial_number" ,0400 , +debugfs_create_file ("serial_number" ,0400 , d, st, &adis16400_serial_number_fops);if (st->variant->flags &ADIS16400_HAS_PROD_ID ) debugfs_create_file_unsafe("product_id", 0400,
Greg Kroah-Hartman
maintainerPATCH 257/571 iio: imu: adis16480: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit e1dea54496f90a62318cf4eeaa1e9ef8316e92b6 upstream.
The firmware_revision and firmware_date file operations are open coded and never call debugfs_file_get(), which debugfs_create_file_unsafe() requires. debugfs_remove_recursive() therefore does not wait for a read in progress, and unbind frees the iio_dev underneath it.
Use debugfs_create_file() instead.
--- drivers/iio/imu/adis16480.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/adis16480.c +2 -2
@@ -300,9 +300,9 @@ static int adis16480_debugfs_init(structstruct adis16480 *adis16480 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); -debugfs_create_file_unsafe ("firmware_revision" ,0400 , +debugfs_create_file ("firmware_revision" ,0400 , d, adis16480, &adis16480_firmware_revision_fops); -debugfs_create_file_unsafe ("firmware_date" ,0400 , +debugfs_create_file ("firmware_date" ,0400 , d, adis16480, &adis16480_firmware_date_fops);debugfs_create_file_unsafe ("serial_number" ,0400 , d, adis16480, &adis16480_serial_number_fops);
Greg Kroah-Hartman
maintainerPATCH 258/571 iio: light: gp2ap020a00f: drain irq_work after free_irq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 63213927b141085b6c8719b8037dab3074b7e0fe upstream.
The threaded IRQ handler queues data->work through irq_work_queue() so the trigger is polled from a per-CPU context. free_irq() does not flush an irq_work the handler already queued, so after gp2ap020a00f_remove() returns that work may still run and call iio_trigger_poll() on data->trig, which the devm cleanup has already freed, causing a use-after-free.
Add irq_work_sync(&data->work) after free_irq() in remove() and in the probe error path, mirroring commit 78601726d4a5 ("iio: trigger: sysfs:
fix use-after-free on remove").
Found by an in-house static analysis tool, confirmed by manual review.
--- drivers/iio/light/gp2ap020a00f.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/light/gp2ap020a00f.c +2 -0
@@ -1570,6 +1570,7 @@ error_trigger_unregister:iio_trigger_unregister (data->trig); error_free_irq:free_irq (client->irq, indio_dev); +irq_work_sync (&data->work); error_uninit_buffer:iio_triggered_buffer_cleanup (indio_dev); error_regulator_disable:
@@ -1592,6 +1593,7 @@ static int gp2ap020a00f_remove(struct i2iio_device_unregister (indio_dev);iio_trigger_unregister (data->trig);free_irq (client->irq, indio_dev); +irq_work_sync (&data->work);iio_triggered_buffer_cleanup (indio_dev);regulator_disable (data->vled_reg);
Greg Kroah-Hartman
maintainerPATCH 259/571 iio: proximity: isl29501: Fix return type of isl29501_register_write
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit e8dd273d199f5bbe295a8e3d8b777c5505b6b2e1 upstream.
isl29501_register_write() was returning a u32 instead of an int. Since the function returns negative error codes (such as -ERANGE or return values from i2c_smbus_write_byte_data()), returning an unsigned integer type prevents callers from correctly checking for negative error conditions.
Fix this by changing the function return type from u32 to int.
This was found through manual code review.
--- drivers/iio/proximity/isl29501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/isl29501.c +1 -1
@@ -227,7 +227,7 @@ err:return ret; } -static u32 isl29501_register_write (struct isl29501_private *isl29501, +static int isl29501_register_write (struct isl29501_private *isl29501,enum isl29501_register_name name,u32 value) {
Greg Kroah-Hartman
maintainerPATCH 260/571 iio: proximity: pulsedlight: fix iio_device left registered on PM setup failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
commit 4daa9ca557b4b98ae1ad38a6d1deaa3e31eb8edf upstream.
pm_runtime_set_active() failing in probe() jumps to error_unreg_buffer, which only calls iio_triggered_buffer_cleanup() -- it does not undo the iio_device_register() that already succeeded a few lines above. probe() then returns the error, the devm-managed indio_dev is freed, but the iio core still has it registered: the sysfs/chardev nodes stay live and point at freed memory.
Add an error_unreg_dev label that unregisters the iio device before falling through to the existing buffer cleanup, mirroring the teardown order already used in lidar_remove().
--- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +3 -1
@@ -299,12 +299,14 @@ static int lidar_probe(struct i2c_client ret =pm_runtime_set_active (&client->dev);if (ret) - goto error_unreg_buffer; + goto error_unreg_dev;pm_runtime_enable (&client->dev);pm_runtime_idle (&client->dev);return 0 ; +error_unreg_dev: +iio_device_unregister (indio_dev); error_unreg_buffer:iio_triggered_buffer_cleanup (indio_dev);
Greg Kroah-Hartman
maintainerPATCH 261/571 iio: proximity: vcnl3020: fix ISR bitmask check in IRQ handler
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit 7d38af8f20239a66e90de7632a79c9425256c574 upstream.
The threaded IRQ handler contained multiple issues in handling interrupt events and clearing status flags:
1. ISR bit check: The handler incorrectly checked the Interrupt Status Register (VCNL_ISR) against VCNL_ICR_THRES_EN (BIT(1)), which is a bitmask meant for the Control Register (VCNL_PS_ICR). In VCNL_ISR, BIT(1) corresponds only to low-threshold interrupts. A high-threshold interrupt (VCNL_INT_TH_HI, BIT(0)) on its own was completely ignored and returned IRQ_NONE.
2. Event direction & channel index: The handler unconditionally pushed a RISING event code on channel index 1. The driver only registers a single proximity channel (index 0), and low-threshold interrupts should be reported with IIO_EV_DIR_FALLING.
3. ISR clearing: The write-back to acknowledge the interrupt only preserved BIT(1) instead of masking against both valid status bits.
Fix this by checking both VCNL_INT_TH_HI and VCNL_INT_TH_LOW bits in VCNL_ISR, pushing separate IIO events with the correct direction and channel index (0), and properly clearing handled status bits.
--- drivers/iio/proximity/vcnl3020.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/iio/proximity/vcnl3020.c +17 -7
@@ -584,16 +584,26 @@ static irqreturn_t vcnl3020_handle_irq_treturn IRQ_HANDLED ; } -if (!(isr &VCNL_ICR_THRES_EN )) +if (!(isr & (VCNL_INT_TH_HI |VCNL_INT_TH_LOW )))return IRQ_NONE ; -iio_push_event (indio_dev, -IIO_UNMOD_EVENT_CODE (IIO_PROXIMITY ,1 , -IIO_EV_TYPE_THRESH , -IIO_EV_DIR_RISING ), -iio_get_time_ns (indio_dev)); +if (isr &VCNL_INT_TH_HI ) { +iio_push_event (indio_dev, +IIO_UNMOD_EVENT_CODE (IIO_PROXIMITY ,0 , +IIO_EV_TYPE_THRESH , +IIO_EV_DIR_RISING ), +iio_get_time_ns (indio_dev)); + } + +if (isr &VCNL_INT_TH_LOW ) { +iio_push_event (indio_dev, +IIO_UNMOD_EVENT_CODE (IIO_PROXIMITY ,0 , +IIO_EV_TYPE_THRESH , +IIO_EV_DIR_FALLING ), +iio_get_time_ns (indio_dev)); + } - rc =regmap_write (data->regmap,VCNL_ISR , isr &VCNL_ICR_THRES_EN ); + rc =regmap_write (data->regmap,VCNL_ISR , isr & (VCNL_INT_TH_HI |VCNL_INT_TH_LOW ));if (rc)dev_err (data->dev,"Error (%d) writing in reg (0x%x)\n" , rc,VCNL_ISR );
Greg Kroah-Hartman
maintainerPATCH 262/571 iio: trigger: cancel reenable_work before freeing trigger
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 2a57b9246cecd5dd797a42eb310d6c8816f26d9e upstream.
iio_trigger_notify_done_atomic() defers ->reenable() into trig->reenable_work on the system workqueue, and the worker dereferences the owning trigger through container_of(). Nothing cancels this work before iio_trig_release() frees the trigger, so a worker armed by the last in-flight IRQ can outlive the free and touch freed memory.
Cancel it at the top of iio_trig_release(), which every free path reaches through the device core's final put_device().
Found by an in-house static analysis tool.
--- drivers/iio/industrialio-trigger.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/industrialio-trigger.c +2 -0
@@ -513,6 +513,8 @@ static void iio_trig_release(struct devistruct iio_trigger *trig =to_iio_trigger (device);int i; +cancel_work_sync (&trig->reenable_work); +if (trig->subirq_base) {for (i =0 ; i <CONFIG_IIO_CONSUMERS_PER_TRIGGER ; i++) { irq_modify_status(trig->subirq_base + i,
Greg Kroah-Hartman
maintainerPATCH 263/571 net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 9cb36faedeafb9720ac236aeae2ea57091d90a09 ]
When u32_replace_hw_knode fails, we need to undo the tcf_bind_filter operation done at u32_set_parms.
--- net/sched/cls_u32.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)
net/sched/cls_u32.c +29 -9
@@ -709,8 +709,23 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { [TCA_U32_FLAGS] = { .type = NLA_U32 }, }; +static void u32_unbind_filter (struct tcf_proto *tp,struct tc_u_knode *n, +struct nlattr **tb) +{ +if (tb[TCA_U32_CLASSID ]) +tcf_unbind_filter (tp, &n->res); +} + +static void u32_bind_filter (struct tcf_proto *tp,struct tc_u_knode *n, +unsigned long base,struct nlattr **tb) +{ +if (tb[TCA_U32_CLASSID ]) { + n->res.classid =nla_get_u32 (tb[TCA_U32_CLASSID ]); +tcf_bind_filter (tp, &n->res, base); + } +} +static int u32_set_parms (struct net *net,struct tcf_proto *tp, -unsigned long base,struct tc_u_knode *n,struct nlattr **tb,struct nlattr *est,u32 flags,struct netlink_ext_ack *extack)
@@ -756,10 +771,6 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,if (ht_old) ht_old->refcnt--; } -if (tb[TCA_U32_CLASSID ]) { - n->res.classid =nla_get_u32 (tb[TCA_U32_CLASSID ]); -tcf_bind_filter (tp, &n->res, base); - }if (ifindex >=0 ) n->ifindex = ifindex;
@@ -898,7 +909,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,if (!new)return -ENOMEM ; - err =u32_set_parms (net, tp, base, new, tb, + err =u32_set_parms (net, tp, new, tb, tca[TCA_RATE ], flags, extack);if (err) {
@@ -906,8 +917,12 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,return err; } +u32_bind_filter (tp, new, base, tb); + err =u32_replace_hw_knode (tp, new, flags, extack);if (err) { +u32_unbind_filter (tp, new, tb); +__u32_destroy_key (new);return err; }
@@ -1108,15 +1123,18 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, }#endif - err =u32_set_parms (net, tp, base, n, tb, tca[TCA_RATE ], flags, + err =u32_set_parms (net, tp, n, tb, tca[TCA_RATE ], flags, extack); + +u32_bind_filter (tp, n, base, tb); +if (err ==0 ) {struct tc_u_knode __rcu **ins;struct tc_u_knode *pins; err =u32_replace_hw_knode (tp, n, flags, extack);if (err) - goto errhw; + goto errunbind;if (!tc_in_hw (n->flags)) n->flags |=TCA_CLS_FLAGS_NOT_IN_HW ;
@@ -1134,7 +1152,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,return 0 ; } -errhw: +errunbind: +u32_unbind_filter (tp, n, tb); +#ifdef CONFIG_CLS_U32_MARK free_percpu (n->pcpu_success);#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 264/571 Revert "scsi: sd: sd_zbc: Use logical blocks as unit when querying zones"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Liebold <[email protected]>
This reverts commit 9c78f3cf77855600c0d27f5b5acdf918bc61328e, the 5.15.y backport of upstream 43af5da09efb.
43af5da09efb is a cleanup ("slightly simplifies sd_zbc_report_zones()"), not a fix. It entered 5.15.y only as a Stable-dep-of: 93dde0bf2f39 ("scsi: scsi_debug: Fix REPORT ZONES alloc_len underflow OOB write"), which touches only scsi_debug.c and does not actually depend on it.
On its own it zeroes the capacity of host-managed SMR drives at boot. It changed the REPORT ZONES loop advance from
sector += sd_zbc_zone_sectors(sdkp) * i; /* sector_t, 64-bit */ to lba += sdkp->zone_blocks * i; /* u32, wraps */
(zone_info.zone_blocks on 5.15.y after bffcb7d6a287). zone_blocks is u32, so the product is computed in 32 bits and wraps before being widened into the 64-bit lba. A drive returning >= 8192 zones in one REPORT ZONES (~2 TiB+ at 256 MiB zones, i.e. any modern HM-SMR part) overflows on the first iteration; the next batch is requested at a wrapped LBA, the block layer rejects the backward jump, and sd truncates the device to zero:
sdX: Zone gap at sectors 18219532288..1039663104 sdX: failed to revalidate zones
(524288 * 34751 = 18219532288, mod 2^32 = 1039663104.)
Mainline never shipped this: in the same series, patch 7 c976e588b34e ("scsi: sd: sd_zbc: Hide gap zones") rewrote the loop to advance per descriptor from 64-bit device values. 5.15.y took patch 4 and the intervening 628617be8968 but not c976e588b34e, keeping the broken intermediate state.
Reverting is preferred over pulling in c976e588b34e: it is a ZBC-2 feature (gap zones, constant zone-starting-LBA granularity) adding ~130 lines across sd_zbc.c, sd.h and include/scsi/scsi_proto.h. It gains nothing for the constant-zone-size HM-SMR drives 5.15.y serves, which the restored sector_t advance already handles correctly.
The revert conflicted with bffcb7d6a287 (which renamed the field on the advance line); resolved by keeping the restored "sector += sd_zbc_zone_sectors(sdkp) * i", which reads zone_info.zone_blocks via logical_to_sectors() and is 64-bit. 93dde0bf2f39 stays in place and is unaffected.
--- drivers/scsi/sd_zbc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/scsi/sd_zbc.c +6 -5
@@ -223,7 +223,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data) { struct scsi_disk *sdkp = scsi_disk(disk); -sector_t lba =sectors_to_logical (sdkp->device, sector); +sector_t capacity =logical_to_sectors (sdkp->device, sdkp->capacity);unsigned int nr, i;unsigned char *buf;size_t offset, buflen =0 ;
@@ -234,7 +234,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,/* Not a zoned device */ return -EOPNOTSUPP ; -if (!sdkp->capacity) +if (!capacity)/* Device gone or invalid */ return -ENODEV ;
@@ -242,8 +242,9 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,if (!buf)return -ENOMEM ; -while (zone_idx < nr_zones && lba < sdkp->capacity) { - ret =sd_zbc_do_report_zones (sdkp, buf, buflen, lba, true); +while (zone_idx < nr_zones && sector < capacity) { + ret =sd_zbc_do_report_zones (sdkp, buf, buflen, +sectors_to_logical (sdkp->device, sector), true);if (ret) goto out;
@@ -261,7 +262,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, zone_idx++; } - lba += sdkp->zone_info.zone_blocks * i; + sector +=sd_zbc_zone_sectors (sdkp) * i; } ret = zone_idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 265/571 Input: exc3000 - properly stop timer on shutdown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 79c81d137d36f9635bbcbc3916c0cccb418a61dd ]
We need to stop the timer on driver unbind or probe failures, otherwise we get UAF/Oops.
--- drivers/input/touchscreen/exc3000.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/input/touchscreen/exc3000.c +10 -0
@@ -109,6 +109,11 @@ static inline void exc3000_schedule_timer(struct exc3000_data *data)mod_timer (&data->timer, jiffies +msecs_to_jiffies (EXC3000_TIMEOUT_MS )); } +static void exc3000_shutdown_timer (void *timer) +{ +timer_shutdown_sync (timer); +} +static int exc3000_read_frame (struct exc3000_data *data,u8 *buf) {struct i2c_client *client = data->client;
@@ -386,6 +391,11 @@ static int exc3000_probe(struct i2c_client *client)if (error)return error; + error =devm_add_action_or_reset (&client->dev, exc3000_shutdown_timer, + &data->timer); +if (error) +return error; + error =devm_request_threaded_irq (&client->dev, client->irq,NULL , exc3000_interrupt,IRQF_ONESHOT , client->name, data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/571 arm64: dts: qcom: sdm845-db845c: Mark cont splash memory region as reserved
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Pundir <[email protected]>
[ Upstream commit 110e70fccce4f22b53986ae797d665ffb1950aa6 ]
Adding a reserved memory region for the framebuffer memory (the splash memory region set up by the bootloader).
It fixes a kernel panic (arm-smmu: Unhandled context fault at this particular memory region) reported on DB845c running v5.10.y.
--- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-db845c.dts +9 -0
@@ -85,6 +85,14 @@ hdmi_con: endpoint { }; }; + reserved-memory { + /* Cont splash region set up by the bootloader */ + cont_splash_mem: framebuffer@9d400000 { + reg = <0x0 0x9d400000 0x0 0x2400000>; + no-map; + }; + }; + lt9611_1v8: lt9611-vdd18-regulator { compatible = "regulator-fixed"; regulator-name = "LT9611_1V8";
@@ -488,6 +496,7 @@ &i2c14 { }; &mdss { + memory-region = <&cont_splash_mem>; status = "okay"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/571 drm/amd/powerplay: fix VoltageObjectInfo zero-stride loop and OOB read
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Asad Kamal <[email protected]>
[ Upstream commit 5d3cc8e388464f485d0944b87b8f9426e637d082 ]
Reject voltage objects whose usSize is smaller than the header or would advance the cursor past the table end, preventing an infinite loop or heap OOB read when the VBIOS supplies a malformed VoltageObjectInfo table.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 10 ++++++++-- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomfwctrl.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +8 -2
@@ -269,15 +269,21 @@ static const ATOM_VOLTAGE_OBJECT_V3 *atomctrl_lookup_voltage_type_v3( unsigned int offset = offsetof(ATOM_VOLTAGE_OBJECT_INFO_V3_1, asVoltageObj[0]);uint8_t *start = (uint8_t *)voltage_object_info_table; -while (offset < size) { +while (offset +sizeof (ATOM_VOLTAGE_OBJECT_HEADER_V3 ) <= size) {const ATOM_VOLTAGE_OBJECT_V3 *voltage_object = (const ATOM_VOLTAGE_OBJECT_V3 *)(start + offset); +u16 obj_size; + + obj_size =le16_to_cpu (voltage_object->asGpioVoltageObj.sHeader.usSize); +if (obj_size <sizeof (voltage_object->asGpioVoltageObj.sHeader) || + offset + obj_size > size) +break ;if (voltage_type == voltage_object->asGpioVoltageObj.sHeader.ucVoltageType && voltage_mode == voltage_object->asGpioVoltageObj.sHeader.ucVoltageMode)return voltage_object; - offset +=le16_to_cpu (voltage_object->asGpioVoltageObj.sHeader.usSize); + offset += obj_size; }return NULL ;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomfwctrl.c +8 -3
@@ -36,16 +36,21 @@ static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4( offsetof(struct atom_voltage_objects_info_v4_1, voltage_object[0]);unsigned long start = (unsigned long )voltage_object_info_table; -while (offset < size) { +while (offset +sizeof (struct atom_voltage_object_header_v4 ) <= size) {const union atom_voltage_object_v4 *voltage_object = (const union atom_voltage_object_v4 *)(start + offset); +u16 obj_size; + + obj_size =le16_to_cpu (voltage_object->gpio_voltage_obj.header.object_size); +if (obj_size <sizeof (voltage_object->gpio_voltage_obj.header) || + offset + obj_size > size) +break ;if (voltage_type == voltage_object->gpio_voltage_obj.header.voltage_type && voltage_mode == voltage_object->gpio_voltage_obj.header.voltage_mode)return voltage_object; - offset +=le16_to_cpu (voltage_object->gpio_voltage_obj.header.object_size); - + offset += obj_size; }return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/571 SUNRPC: fix gssx_dec_option_array error path bugs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 5e9a94539b1ec17a89177d952badfd0d844d694a ]
Four coupled defects in the gssx XDR option-array decoder make the error paths unsafe: a NULL deref in the caller, a refcount leak on the decoded group_info, and a latent use-after-free that the leak fix would otherwise expose.
gssx_dec_option_array() sets oa->count = 1 before allocating oa->data. If that allocation fails, -ENOMEM is returned with oa->count == 1 and oa->data == NULL. All other error paths jump to free_oa: which frees oa->data and NULLs it but also leaves oa->count == 1. The caller trusts the count:
gssp_accept_sec_context_upcall()
gssx_dec_accept_sec_context()
gssx_dec_option_array() /* fails, count=1 data=NULL */
data = res.options.data[0].value /* NULL deref */
Independently, free_creds: releases the partially decoded svc_cred with a bare kfree(creds). gssx_dec_linux_creds() installs a groups_alloc() result into creds->cr_group_info; that object is kvmalloc-backed and refcounted, and only put_group_info() reaches kvfree(). A plain kfree(creds) drops the wrapper and leaks the group_info allocation.
The natural fix for the leak is to call free_svc_cred(creds) before kfree(creds), but free_svc_cred() invokes put_group_info() on creds->cr_group_info unconditionally when non-NULL. The existingout_free_groups: path in gssx_dec_linux_creds() already called groups_free() on that pointer without clearing it, so once free_svc_cred() is wired in, the subsequent put_group_info() would touch freed memory.
Fix all four together:
- Move the oa->count = 1 assignment below the oa->data allocation
so it is never set when oa->data is NULL.
- Reset oa->count to 0 at free_oa: so count and data stay coherent and the caller sees an empty option array.
- Call free_svc_cred(creds) before kfree(creds) at free_creds:
so the refcounted cr_group_info is released. free_svc_cred() either NULL-guards each field explicitly (cr_group_info has an if() check) or delegates to a helper that is NULL-safe itself (kfree for the string fields, gss_mech_put() which guards with if(gm) at gss_mech_switch.c:342), so it is safe to call on a partially decoded svc_cred where only cr_uid/cr_gid/cr_group_info have been written and everything else is zero from kzalloc.
- In gssx_dec_linux_creds()'s out_free_groups: path, release cr_group_info with put_group_info() rather than groups_free() so the teardown matches free_svc_cred()'s refcount-aware path, and clear the pointer so a later free_svc_cred() on the same creds does not release it a second time.
--- net/sunrpc/auth_gss/gss_rpc_xdr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sunrpc/auth_gss/gss_rpc_xdr.c +6 -3
@@ -222,7 +222,8 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr,return 0 ; out_free_groups: -groups_free (creds->cr_group_info); +put_group_info (creds->cr_group_info); + creds->cr_group_info =NULL ;return err; }
@@ -242,12 +243,12 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,return 0 ;/* we recognize only 1 currently: CREDS_VALUE */ - oa->count =1 ; - oa->data =kmalloc (sizeof (struct gssx_option ),GFP_KERNEL );if (!oa->data)return -ENOMEM ; + oa->count =1 ; + creds =kzalloc (sizeof (struct svc_cred ),GFP_KERNEL );if (!creds) { err = -ENOMEM ;
@@ -294,8 +295,10 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,return 0 ; free_creds: +free_svc_cred (creds);kfree (creds); free_oa: + oa->count =0 ;kfree (oa->data); oa->data =NULL ;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/571 SUNRPC: reject duplicate CREDS_VALUE options
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 2e4ce62385c1b8a887c5370af058ac7b52a8eaf9 ]
gssx_dec_option_array() walks the wire-supplied option array and, for every entry whose name matches CREDS_VALUE, calls gssx_dec_linux_creds() on the same struct svc_cred. That helper unconditionally installs a fresh groups_alloc() result into creds->cr_group_info without releasing whatever pointer was already there:
for (i = 0; i < count; i++) {
... decode name ...
if (length == sizeof(CREDS_VALUE) &&
memcmp(p, CREDS_VALUE, sizeof(CREDS_VALUE)) == 0) {
err = gssx_dec_linux_creds(xdr, creds);
...
}
}A reply that carries two CREDS_VALUE entries therefore overwrites cr_group_info on the second iteration and orphans the group_info allocated by the first call. The earlier free_creds path only releases the last cr_group_info via free_svc_cred(), so the first allocation's refcount stays at one and its kvmalloc-backed storage is leaked. No in-tree caller of gssp_accept_sec_context_upcall() expects more than one CREDS_VALUE per reply.
Fix by tracking whether a CREDS_VALUE option has already been decoded and returning -EINVAL on any subsequent match, so the free_creds path releases the single group_info that was installed.
--- net/sunrpc/auth_gss/gss_rpc_xdr.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sunrpc/auth_gss/gss_rpc_xdr.c +6 -0
@@ -231,6 +231,7 @@ static int gssx_dec_option_array(struct xdr_stream *xdr, struct gssx_option_array *oa) {struct svc_cred *creds; +bool creds_decoded = false;u32 count, i;__be32 *p;int err;
@@ -281,9 +282,14 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,if (length ==sizeof (CREDS_VALUE ) &&memcmp (p,CREDS_VALUE ,sizeof (CREDS_VALUE )) ==0 ) {/* We have creds here. parse them */ +if (creds_decoded) { + err = -EINVAL ; + goto free_creds; + } err =gssx_dec_linux_creds (xdr, creds);if (err) goto free_creds; + creds_decoded = true; oa->data[0 ].value.len =1 ;/* presence */ }else {/* consume uninteresting buffer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/571 vc_screen: reload vc pointer before if (ret) in vcs_write() to avoid UAF
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Yang <[email protected]>
[ Upstream commit 226bd5603371cd9f6642cbb9e9a677f445de3530 ]
The reload of 'vc' added by commit 8fb9ea65c9d1 ("vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF") sits after the 'if (ret)' block, so the copy-failure break path exits the loop without reloading vc. If the vc was kfree()'d via vc_port_destruct during the unlocked copy_from_user() window, the post-loop
'if (written && vc) vcs_scr_updated(vc)' is reached with a stale non-NULL vc. The '&& vc' guard from commit a287620312dc ("vc_screen:
fix null-ptr-deref in vcs_notifier() during concurrent vcs_write") only handles the NULL case, not this stale-non-NULL case; vcs_notifier() then reads param->vc->vc_num from freed memory:
BUG: KASAN: slab-use-after-free in vcs_notifier+0x7c/0xd0 Read of size 2 at addr ffff888007149190 Call Trace: vcs_notifier+0x7c/0xd0 atomic_notifier_call_chain+0x70/0xa0 vcs_scr_updated+0x77/0xa0 vcs_write+0x71b/0x7e0 Allocated by task: vc_allocate -> con_install -> tty_open Freed by task: kfree <- vt_ioctl (VT_DISALLOCATE -> vc_port_destruct)
Move the reload to immediately after console_lock(), before 'if (ret)', so every break path below passes a fresh vc to the post-loop vcs_scr_updated().
--- drivers/tty/vt/vc_screen.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/tty/vt/vc_screen.c +13 -12
@@ -643,6 +643,19 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ret =copy_from_user (con_buf, buf, this_round);console_lock (); +/* The vc might have been freed or vcs_size might have changed +* while we slept to grab the user buffer; recheck here, before +* if (ret), so every break path below passes a fresh vc to the +* post-loop vcs_scr_updated(). Return data written so far. +*/ + vc =vcs_vc (inode, &viewed); +if (!vc) { +if (written) +break ; + ret = -ENXIO ; + goto unlock_out; + } +if (ret) { this_round -= ret;if (!this_round) {
@@ -655,18 +668,6 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) goto unlock_out; } } - -/* The vc might have been freed or vcs_size might have changed -* while we slept to grab the user buffer, so recheck. -* Return data written up to now on failure. -*/ - vc =vcs_vc (inode, &viewed); -if (!vc) { -if (written) -break ; - ret = -ENXIO ; - goto unlock_out; - } size =vcs_size (vc, attr, false);if (size <0 ) {if (written)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/571 mtd: rawnand: vf610_nfc: fix false bitflips on reads of erased pages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit 68fe2faf5c69d0e21f94cd695d28f0ba677d484f ]
When the ECC engine fails to decode a page, the driver re-reads the OOB area with the engine bypassed, but runs the erased-page check for the data area on the buffer left in the controller SRAM by the failed transfer.
That buffer does not hold what is on the flash: the failing engine writes a bogus single-bit "correction" into it. In the 60-byte ECC mode the all-0xff content of an erased page always decodes to the same error location, so every erased page shows one stale zero bit at data offset 0x5FD, which the erased-page check then reports as a corrected bitflip.
Edward Karpicz discovered this behaviour and identified the offset on a Colibri VF61; the analysis and the fix build on his finding. Measured with an instrumented driver on a Colibri VF50 (MX30LF1G18AC, 32-bit ECC): reading a 126 MiB partition with nanddump increased the corrected counter by 18035, exactly one per erased page, while raw reads of the same pages return clean 0xff. A v4.4 kernel on the VF61 (MX30LF4G28AC) accumulates the same false counts, so the behaviour follows the controller rather than the chip or the driver generation. Neither the Vybrid reference manual nor the published mask set errata (VFXXX_2N02G) document it. The 45-byte ECC mode is not affected.
Restoring the known byte is not enough: on pages that fail to decode with content other than all-0xff the engine writes its correction wherever the syndrome points (measured at a different offset on such a page), so the check has to run on what the flash holds. Re-read the data area with the ECC engine bypassed, exactly as already done for the OOB area. The corrected counter then stays at zero on both boards.
--- drivers/mtd/nand/raw/vf610_nfc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +11 -4
@@ -518,6 +518,7 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat,u8 ecc_status;u8 ecc_count;int flips_threshold = nfc->chip.ecc.strength /2 ; +int ret; ecc_status =vf610_nfc_read (nfc, ecc_status_off) &0xff ; ecc_count = ecc_status &ECC_STATUS_ERR_COUNT ;
@@ -525,15 +526,21 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat,if (!(ecc_status &ECC_STATUS_MASK ))return ecc_count; +/* The failed decode leaves a bogus correction in SRAM; re-read without ECC */ nfc->data_access = true; -nand_read_oob_op (&nfc->chip, page,0 , oob,vf610_nfc_spare_size (mtd)); + ret =nand_read_page_op (&nfc->chip, page,0 , dat, mtd->writesize); +if (!ret) + ret =nand_read_oob_op (&nfc->chip, page,0 , oob, +vf610_nfc_spare_size (mtd)); nfc->data_access = false; +if (ret) +return ret;/* -* On an erased page, bit count (including OOB) should be zero or -* at least less then half of the ECC strength. +* Run the erased-page check with the driver's historic threshold +* of half the ECC strength. */ -return nand_check_erased_ecc_chunk (dat, nfc->chip.ecc.size, oob, +return nand_check_erased_ecc_chunk (dat, mtd->writesize, oob,vf610_nfc_spare_size (mtd),NULL ,0 , flips_threshold); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/571 smb: client: split cifsFileInfo bitfields to avoid shared-byte RMW races
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit 19465a9aeb664f1d710d0d22c07c31bfb7c85446 ]
The invalidHandle, swapfile, oplock_break_cancelled, offload, and status_file_deleted fields are stored in the same bitfield byte in struct cifsFileInfo, but are updated in different code paths that may run simultaneously, and are protected by different locks. Since bitfield assignments generate byte-level read-modify-write operations, a modification to one flag can overwrite a concurrent modification to another flag.
To avoid these races, convert these flags from a bitfield to separate bool fields.
--- fs/cifs/cifsglob.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +3 -3
@@ -1265,9 +1265,9 @@ struct cifsFileInfo {struct dentry *dentry;struct tcon_link *tlink;unsigned int f_flags; - bool invalidHandle:1; /* file closed via session abend */ - bool swapfile:1; - bool oplock_break_cancelled:1; +bool invalidHandle;/* file closed via session abend */ +bool swapfile; +bool oplock_break_cancelled;unsigned int oplock_epoch;/* epoch from the lease break */ __u32 oplock_level;/* oplock/lease level from the lease break */ int count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/571 wifi: wl12xx: Drop if with an always false condition
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 69ddcea564437ce4b0d5143f37a9154fcef8d3d2 ]
The remove callback is only called after probe completed successfully. In this case platform_set_drvdata() was called with a non-NULL argument (in wlcore_probe()) and so wl is never NULL.
This is a preparation for making platform remove callbacks return void.
Stable-dep-of: a8b8881d0c1a ("wifi: wlcore: Fix runtime PM leak in wlcore_remove()")
--- drivers/net/wireless/ti/wl12xx/main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +0 -3
@@ -1924,13 +1924,10 @@ static int wl12xx_remove(struct platform_device *pdev)struct wl1271 *wl =platform_get_drvdata (pdev);struct wl12xx_priv *priv; -if (!wl) - goto out; priv = wl->priv;kfree (priv->rx_mem_addr); -out:return wlcore_remove (pdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/571 wifi: wlcore: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit f00928012886a07ca6817ea70eb4856ce280ce05 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
wlcore_remove() returned zero unconditionally. With that converted to return void instead, the wl12xx and wl18xx driver can be converted to .remove_new trivially.
Stable-dep-of: a8b8881d0c1a ("wifi: wlcore: Fix runtime PM leak in wlcore_remove()")
--- drivers/net/wireless/ti/wl12xx/main.c | 6 +++--- drivers/net/wireless/ti/wl18xx/main.c | 2 +- drivers/net/wireless/ti/wlcore/main.c | 6 ++---- drivers/net/wireless/ti/wlcore/wlcore.h | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +3 -3
@@ -1919,7 +1919,7 @@ static int wl12xx_probe(struct platform_device *pdev)return ret; } -static int wl12xx_remove (struct platform_device *pdev) +static void wl12xx_remove (struct platform_device *pdev) {struct wl1271 *wl =platform_get_drvdata (pdev);struct wl12xx_priv *priv;
@@ -1928,7 +1928,7 @@ static int wl12xx_remove(struct platform_device *pdev)kfree (priv->rx_mem_addr); -return wlcore_remove (pdev); +wlcore_remove (pdev); }static const struct platform_device_id wl12xx_id_table[] = {
@@ -1939,7 +1939,7 @@ MODULE_DEVICE_TABLE(platform, wl12xx_id_table);static struct platform_driver wl12xx_driver = { .probe = wl12xx_probe, - .remove = wl12xx_remove, + .remove_new = wl12xx_remove, .id_table = wl12xx_id_table, .driver = { .name ="wl12xx_driver" ,
drivers/net/wireless/ti/wl18xx/main.c +1 -1
@@ -2033,7 +2033,7 @@ MODULE_DEVICE_TABLE(platform, wl18xx_id_table);static struct platform_driver wl18xx_driver = { .probe = wl18xx_probe, - .remove = wlcore_remove, + .remove_new = wlcore_remove, .id_table = wl18xx_id_table, .driver = { .name ="wl18xx_driver" ,
drivers/net/wireless/ti/wlcore/main.c +2 -4
@@ -6803,7 +6803,7 @@ int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev) }EXPORT_SYMBOL_GPL (wlcore_probe); -int wlcore_remove (struct platform_device *pdev) +void wlcore_remove (struct platform_device *pdev) {struct wlcore_platdev_data *pdev_data =dev_get_platdata (&pdev->dev);struct wl1271 *wl =platform_get_drvdata (pdev);
@@ -6818,7 +6818,7 @@ int wlcore_remove(struct platform_device *pdev)if (pdev_data->family && pdev_data->family->nvs_name)wait_for_completion (&wl->nvs_loading_complete);if (!wl->initialized) -return 0 ; +return ;if (wl->wakeirq >=0 ) {dev_pm_clear_wake_irq (wl->dev);
@@ -6838,8 +6838,6 @@ int wlcore_remove(struct platform_device *pdev)free_irq (wl->irq, wl);wlcore_free_hw (wl); - -return 0 ; }EXPORT_SYMBOL_GPL (wlcore_remove);
drivers/net/wireless/ti/wlcore/wlcore.h +1 -1
@@ -497,7 +497,7 @@ struct wl1271 { };int wlcore_probe (struct wl1271 *wl,struct platform_device *pdev); -int wlcore_remove (struct platform_device *pdev); +void wlcore_remove (struct platform_device *pdev);struct ieee80211_hw *wlcore_alloc_hw (size_t priv_size,u32 aggr_buf_size,u32 mbox_size);int wlcore_free_hw (struct wl1271 *wl);
Signature · 1 line
2.53.0