7.1.5-rc1 review
Subsystems (15)
Greg Kroah-Hartman
maintainerPATCH 518/2077 simpe_xattr: use per-sb cache
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
[ Upstream commit 1e7cd8a53b72a58a44c4d282aed95f6ce0e76db0 ]
Move the hash table to the super block to remove excessive overhead in case of small number of xattrs per inode.
Add linked list to the inode, used for listxattr and eviction. Listxattr uses rcu protection to iterate the list of xattrs.
Before being made per-sb, lazy allocation was protected by inode lock. Now inode lock no longer provides sufficient exclusion, so use cmpxchg() to ensure atomicity.
Though I haven't found a description of this pattern, after some research it seems that cmpxchg_release() and READ_ONCE() should provide the necessary memory barriers.
Use simple_xattr_free_rcu() in simple_xattrs_free(). This is needed because the hash table is now shared between inodes and lookup on a different inode might be running the compare function on the just freed element within the RCU grace period.
Following stats are based on slabinfo diff, after creating 100k empty files, then adding a "user.test=foo" xattr to each:
v7.0 (no rhashtable):
File creation: 993.40 bytes/file
Xattr addition: 79.99 bytes/file
v7.1-rc2 (per-inode rhashtable):
File creation: 939.73 bytes/file
Xattr addition: 1296.08 bytes/file
v7.1-rc2 + this patch (per-sb rhashtable)
File creation: 946.84 bytes/file
Xattr addition: 111.86 bytes/file
The overhead of a single xattr is reduced to nearly v7.0 levels. The per xattr overhead is slightly larger due to the addition of three pointers to struct simple_xattr.
--- fs/kernfs/dir.c | 5 +- fs/kernfs/inode.c | 10 +- fs/kernfs/kernfs-internal.h | 4 +- fs/pidfs.c | 14 +- fs/xattr.c | 283 +++++++++++++++++------------------- include/linux/shmem_fs.h | 3 +- include/linux/xattr.h | 26 ++-- mm/shmem.c | 13 +- net/socket.c | 12 +- 9 files changed, 192 insertions(+), 178 deletions(-)
fs/kernfs/dir.c +3 -2
@@ -609,7 +609,7 @@ void kernfs_put(struct kernfs_node *kn)kernfs_put (kn->symlink.target_kn);if (kn->iattr) -simple_xattrs_free (&kn->iattr->xattrs,NULL ); +simple_xattrs_free (&root->xa_cache, &kn->iattr->xattrs,NULL );spin_lock (&root->kernfs_idr_lock);idr_remove (&root->ino_idr, (u32 )kernfs_ino (kn));
@@ -624,6 +624,7 @@ void kernfs_put(struct kernfs_node *kn) }else {/* just released the root kn, free @root too */ idr_destroy (&root->ino_idr); +simple_xattr_cache_cleanup (&root->xa_cache);kfree_rcu (root, rcu); } }
@@ -709,7 +710,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, err_out4:if (kn->iattr) { -simple_xattrs_free (&kn->iattr->xattrs,NULL ); +simple_xattrs_free (&root->xa_cache, &kn->iattr->xattrs,NULL );kmem_cache_free (kernfs_iattrs_cache, kn->iattr); } err_out3:
fs/kernfs/inode.c +7 -3
@@ -37,6 +37,7 @@ static struct kernfs_iattrs *__kernfs_iattrs(struct kernfs_node *kn, bool alloc)if (!ret)return NULL ; +INIT_LIST_HEAD_RCU (&ret->xattrs);/* assign default attributes */ ret->ia_uid =GLOBAL_ROOT_UID ; ret->ia_gid =GLOBAL_ROOT_GID ;
@@ -296,11 +297,12 @@ int kernfs_xattr_get(struct kernfs_node *kn, const char *name, void *value, size_t size) {struct kernfs_iattrs *attrs =kernfs_iattrs_noalloc (kn); +struct simple_xattr_cache *cache = &kernfs_root (kn)->xa_cache;if (!attrs)return -ENODATA ; -return simple_xattr_get (&attrs->xattrs, name, value, size); +return simple_xattr_get (cache, &attrs->xattrs, name, value, size); } int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
@@ -308,6 +310,7 @@ int kernfs_xattr_set(struct kernfs_node *kn, const char *name, {struct simple_xattr *old_xattr;struct kernfs_iattrs *attrs; +struct simple_xattr_cache *cache = &kernfs_root (kn)->xa_cache; attrs =kernfs_iattrs (kn);if (!attrs)
@@ -322,7 +325,7 @@ int kernfs_xattr_set(struct kernfs_node *kn, const char *name,*/ CLASS (kernfs_node_lock, lock)(kn); - old_xattr =simple_xattr_set (&attrs->xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (cache, &attrs->xattrs, name, value, size, flags);if (IS_ERR (old_xattr))return PTR_ERR (old_xattr);
@@ -372,7 +375,8 @@ static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler,/* See comment in kernfs_xattr_set() about locking. */ CLASS (kernfs_node_lock, lock)(kn); -return simple_xattr_set_limited (&attrs->xattrs, &attrs->xattr_limits, +return simple_xattr_set_limited (&kernfs_root (kn)->xa_cache, + &attrs->xattrs, &attrs->xattr_limits, full_name, value, size, flags); }
fs/kernfs/kernfs-internal.h +3 -1
@@ -26,7 +26,7 @@ struct kernfs_iattrs {struct timespec64 ia_mtime;struct timespec64 ia_ctime; -struct simple_xattrs *xattrs; +struct list_head xattrs;struct simple_xattr_limits xattr_limits; };
@@ -54,6 +54,8 @@ struct kernfs_root {rwlock_t kernfs_rename_lock;struct rcu_head rcu; + +struct simple_xattr_cache xa_cache; };/* +1 to avoid triggering overflow warning when negating it */
fs/pidfs.c +9 -5
@@ -37,6 +37,8 @@ static struct kmem_cache *pidfs_attr_cachep __ro_after_init;static struct path pidfs_root_path = {}; +static struct simple_xattr_cache pidfs_xa_cache; +void pidfs_get_root (struct path *path) { *path = pidfs_root_path;
@@ -96,7 +98,7 @@ static const struct rhashtable_params pidfs_ino_ht_params = {* use file handles. */ struct pidfs_attr { -struct simple_xattrs *xattrs; +struct list_head xattrs;union {struct pidfs_anon_attr ;struct llist_node pidfs_llist;
@@ -196,7 +198,7 @@ static void pidfs_free_attr_work(struct work_struct *work) head =llist_del_all (&pidfs_free_list);llist_for_each_entry_safe (attr, next, head, pidfs_llist) { -simple_xattrs_free (&attr->xattrs,NULL ); +simple_xattrs_free (&pidfs_xa_cache, &attr->xattrs,NULL );kfree (attr); } }
@@ -224,7 +226,7 @@ void pidfs_free_pid(struct pid *pid)if (IS_ERR (attr))return ; -if (likely (!attr->xattrs)) +if (likely (list_empty (&attr->xattrs)))kfree (attr);else if (llist_add (&attr->pidfs_llist, &pidfs_free_list))schedule_work (&pidfs_free_work);
@@ -1007,6 +1009,8 @@ int pidfs_register_pid(struct pid *pid)if (!new_attr)return -ENOMEM ; +INIT_LIST_HEAD_RCU (&new_attr->xattrs); +/* Synchronize with pidfs_exit(). */ guard (spinlock_irq)(&pid->wait_pidfd.lock);
@@ -1048,7 +1052,7 @@ static int pidfs_xattr_get(const struct xattr_handler *handler,struct pid *pid = inode->i_private;const char *name =xattr_full_name (handler, suffix); -return simple_xattr_get (&pid->attr->xattrs, name, value, size); +return simple_xattr_get (&pidfs_xa_cache, &pid->attr->xattrs, name, value, size); } static int pidfs_xattr_set(const struct xattr_handler *handler,
@@ -1063,7 +1067,7 @@ static int pidfs_xattr_set(const struct xattr_handler *handler,/* Ensure we're the only one to set @attr->xattrs. */ WARN_ON_ONCE (!inode_is_locked (inode)); - old_xattr =simple_xattr_set (&pid->attr->xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (&pidfs_xa_cache, &pid->attr->xattrs, name, value, size, flags);if (IS_ERR (old_xattr))return PTR_ERR (old_xattr);
fs/xattr.c +136 -147
455 lines not on this page · raw message
include/linux/shmem_fs.h +2 -1
@@ -48,7 +48,7 @@ struct shmem_inode_info { };struct timespec64 i_crtime;/* file creation time */ struct shared_policy policy;/* NUMA memory alloc policy */ -struct simple_xattrs *xattrs;/* list of xattrs */ +struct list_head xattrs;/* list of xattrs */ pgoff_t fallocend;/* highest fallocate endindex */ unsigned int fsflags;/* for FS_IOC_[SG]ETFLAGS */ atomic_t stop_eviction;/* hold when working on inode */
@@ -89,6 +89,7 @@ struct shmem_sb_info {struct list_head shrinklist;/* List of shinkable inodes */ unsigned long shrinklist_len;/* Length of shrinklist */ struct shmem_quota_limits qlimits;/* Default quota limits */ +struct simple_xattr_cache xa_cache; };static inline struct shmem_inode_info *SHMEM_I (struct inode *inode)
include/linux/xattr.h +16 -10
@@ -106,12 +106,14 @@ static inline const char *xattr_prefix(const struct xattr_handler *handler)return handler->prefix ?: handler->name; } -struct simple_xattrs { -struct rhashtable ht; +struct simple_xattr_cache { +struct rhashtable *ht; };struct simple_xattr {struct rhash_head hash_node; +struct list_head *parent; +struct list_head node;struct rcu_head rcu;char *name;size_t size;
@@ -132,27 +134,31 @@ static inline void simple_xattr_limits_init(struct simple_xattr_limits *limits)atomic_set (&limits->xattr_size,0 ); } -int simple_xattrs_init (struct simple_xattrs *xattrs); -void simple_xattrs_free (struct simple_xattrs **xattrs,size_t *freed_space); +void simple_xattrs_free (struct simple_xattr_cache *cache,struct list_head *xattrs, +size_t *freed_space);size_t simple_xattr_space (const char *name,size_t size);struct simple_xattr *simple_xattr_alloc (const void *value,size_t size);void simple_xattr_free (struct simple_xattr *xattr);void simple_xattr_free_rcu (struct simple_xattr *xattr); -int simple_xattr_get (struct simple_xattrs **xattrs,const char *name, -void *buffer,size_t size); -struct simple_xattr *simple_xattr_set (struct simple_xattrs **xattrs, +int simple_xattr_get (struct simple_xattr_cache *cache,struct list_head *xattrs, +const char *name,void *buffer,size_t size); +struct simple_xattr *simple_xattr_set (struct simple_xattr_cache *cache, +struct list_head *xattrs,const char *name,const void *value,size_t size,int flags); -int simple_xattr_set_limited (struct simple_xattrs **xattrs, +int simple_xattr_set_limited (struct simple_xattr_cache *cache, +struct list_head *xattrs,struct simple_xattr_limits *limits,const char *name,const void *value,size_t size,int flags); -ssize_t simple_xattr_list (struct inode *inode,struct simple_xattrs **xattrs, +ssize_t simple_xattr_list (struct inode *inode,struct list_head *xattrs,char *buffer,size_t size); -int simple_xattr_add (struct simple_xattrs **xattrs, +int simple_xattr_add (struct simple_xattr_cache *cache,struct list_head *xattrs,struct simple_xattr *new_xattr);int xattr_list_one (char **buffer,ssize_t *remaining_size,const char *name); +void simple_xattr_cache_cleanup (struct simple_xattr_cache *cache); + DEFINE_CLASS(simple_xattr, struct simple_xattr *, if (!IS_ERR_OR_NULL(_T)) simple_xattr_free(_T),
mm/shmem.c +9 -4
@@ -1425,7 +1425,7 @@ static void shmem_evict_inode(struct inode *inode) } } -simple_xattrs_free (&info->xattrs, sbinfo->max_inodes ? &freed :NULL ); +simple_xattrs_free (&sbinfo->xa_cache, &info->xattrs, sbinfo->max_inodes ? &freed :NULL );shmem_free_inode (inode->i_sb, freed);WARN_ON (inode->i_blocks);
@@ -3084,6 +3084,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, inode->i_generation =get_random_u32 (); info =SHMEM_I (inode);memset (info,0 , (char *)inode - (char *)info); +INIT_LIST_HEAD_RCU (&info->xattrs);spin_lock_init (&info->lock);atomic_set (&info->stop_eviction,0 ); info->seals =F_SEAL_SEAL ;
@@ -4258,7 +4259,7 @@ static int shmem_initxattrs(struct inode *inode,if (!new_xattr->name)break ; -if (simple_xattr_add (&info->xattrs, new_xattr)) +if (simple_xattr_add (&sbinfo->xa_cache, &info->xattrs, new_xattr))break ;if (sbinfo->max_inodes)
@@ -4283,10 +4284,11 @@ static int shmem_xattr_handler_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size) { + struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);struct shmem_inode_info *info =SHMEM_I (inode); name =xattr_full_name (handler, name); -return simple_xattr_get (&info->xattrs, name, buffer, size); +return simple_xattr_get (&sbinfo->xa_cache, &info->xattrs, name, buffer, size); } static int shmem_xattr_handler_set(const struct xattr_handler *handler,
@@ -4314,7 +4316,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,return -ENOSPC ; } - old_xattr =simple_xattr_set (&info->xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (&sbinfo->xa_cache, &info->xattrs, name, value, size, flags);if (!IS_ERR (old_xattr)) { ispace =0 ;if (old_xattr && sbinfo->max_inodes)
@@ -4963,6 +4965,9 @@ static void shmem_put_super(struct super_block *sb)free_percpu (sbinfo->ino_batch);percpu_counter_destroy (&sbinfo->used_blocks);mpol_put (sbinfo->mpol); +#ifdef CONFIG_TMPFS_XATTR +simple_xattr_cache_cleanup (&sbinfo->xa_cache); +#endif kfree (sbinfo); sb->s_fs_info =NULL ; }
net/socket.c +7 -5
@@ -310,8 +310,10 @@ static int move_addr_to_user(struct sockaddr_storage *kaddr, int klen,static struct kmem_cache *sock_inode_cachep__ro_after_init ; +static struct simple_xattr_cache sockfs_xa_cache; +struct sockfs_inode { -struct simple_xattrs *xattrs; +struct list_head xattrs;struct simple_xattr_limits xattr_limits;struct socket_alloc ; };
@@ -328,7 +330,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb) si =alloc_inode_sb (sb, sock_inode_cachep,GFP_KERNEL );if (!si)return NULL ; - si->xattrs =NULL ; +INIT_LIST_HEAD_RCU (&si->xattrs);simple_xattr_limits_init (&si->xattr_limits);init_waitqueue_head (&si->socket.wq.wait);
@@ -348,7 +350,7 @@ static void sock_evict_inode(struct inode *inode) {struct sockfs_inode *si =SOCKFS_I (inode); -simple_xattrs_free (&si->xattrs,NULL ); +simple_xattrs_free (&sockfs_xa_cache, &si->xattrs,NULL );clear_inode (inode); }
@@ -441,7 +443,7 @@ static int sockfs_user_xattr_get(const struct xattr_handler *handler,const char *name =xattr_full_name (handler, suffix);struct sockfs_inode *si =SOCKFS_I (inode); -return simple_xattr_get (&si->xattrs, name, value, size); +return simple_xattr_get (&sockfs_xa_cache, &si->xattrs, name, value, size); } static int sockfs_user_xattr_set(const struct xattr_handler *handler,
@@ -453,7 +455,7 @@ static int sockfs_user_xattr_set(const struct xattr_handler *handler,const char *name =xattr_full_name (handler, suffix);struct sockfs_inode *si =SOCKFS_I (inode); -return simple_xattr_set_limited (&si->xattrs, &si->xattr_limits, +return simple_xattr_set_limited (&sockfs_xa_cache, &si->xattrs, &si->xattr_limits, name, value, size, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/2077 kernfs: link kn to its parent before the LSM init hook
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 6cccc49b027c7551ffc1d2532f2ef1922661f3da ]
After commit 12e9e3cd03b5 ("simpe_xattr: use per-sb cache"), kernfs_xattr_set() and kernfs_xattr_get() compute the cache via kernfs_root(kn) before any other check. kernfs_root(kn) walks kn->__parent first and falls back to kn->dir.root, both of which are NULL on a freshly kmem_cache_zalloc()'d kn. kn->__parent was being set in kernfs_new_node() after __kernfs_new_node() returned, and kn->dir.root is set even later by kernfs_create_dir_ns() / kernfs_create_empty_dir().
The LSM kernfs_init_security hook is invoked from inside __kernfs_new_node(), before either field has been initialized. selinux_kernfs_init_security() ends with kernfs_xattr_set(kn, XATTR_NAME_SELINUX, ...). kernfs_root(kn) then returns NULL, and &((struct kernfs_root *)NULL)->xa_cache evaluates to offsetof(struct kernfs_root, xa_cache) which faults:
BUG: kernel NULL pointer dereference, address: 00000000000000e0 RIP: 0010:simple_xattr_set+0x27/0x8b0 Call Trace: kernfs_xattr_set+0x63/0xb0 selinux_kernfs_init_security+0x13b/0x270 security_kernfs_init_security+0x36/0xc0 __kernfs_new_node+0x182/0x290 kernfs_new_node+0x80/0xc0 kernfs_create_dir_ns+0x2b/0xa0 cgroup_create+0x116/0x380 cgroup_mkdir+0x7c/0x1a0
Reproduces deterministically at PID 1 (systemd) on an SELinux-enabled distro. The first cgroup mkdir under /sys/fs/cgroup with a labelled parent panics the kernel.
The LSM hook's contract is that the kn_dir argument is the parent of the new kn, so kn->__parent should already point at kn_dir when the hook runs. Move kernfs_get(parent) and rcu_assign_pointer of kn->__parent from kernfs_new_node() into __kernfs_new_node() right before the security hook, and unwind the parent reference on the err_out4 path. kernfs_root(kn) then takes its parent branch during the hook and returns parent->dir.root, which is the correct root.
This also closes the same-shape latent bug in kernfs_xattr_get() (which today is hidden only by kernfs_iattrs_noalloc() returning NULL on a fresh kn).
--- fs/kernfs/dir.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/kernfs/dir.c +5 -4
@@ -701,6 +701,9 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, }if (parent) { +kernfs_get (parent); +rcu_assign_pointer (kn->__parent, parent); + ret =security_kernfs_init_security (parent, kn);if (ret) goto err_out4;
@@ -709,6 +712,8 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,return kn; err_out4: +RCU_INIT_POINTER (kn->__parent,NULL ); +kernfs_put (parent);if (kn->iattr) {simple_xattrs_free (&root->xa_cache, &kn->iattr->xattrs,NULL );kmem_cache_free (kernfs_iattrs_cache, kn->iattr);
@@ -745,10 +750,6 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, kn =__kernfs_new_node (kernfs_root (parent), parent, name, mode, uid, gid, flags); -if (kn) { -kernfs_get (parent); -rcu_assign_pointer (kn->__parent, parent); - }return kn; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/2077 wifi: wcn36xx: fix heap overflow from oversized firmware HAL response
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit 88a240d86d3d64521f9194abe185ac71cc74d0bd ]
The firmware response dispatcher copies all synchronous HAL responses into the 4096-byte hal_buf without validating the response length. A response exceeding WCN36XX_HAL_BUF_SIZE causes a heap buffer overflow with firmware-controlled content.
Add a bounds check on the response length.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/wcn36xx/smd.c +4 -0
@@ -3293,6 +3293,10 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,case WCN36XX_HAL_EXIT_IMPS_RSP :case WCN36XX_HAL_UPDATE_CHANNEL_LIST_RSP :case WCN36XX_HAL_ADD_BCN_FILTER_RSP : +if (len >WCN36XX_HAL_BUF_SIZE ) { +wcn36xx_warn ("HAL response too large: %d\n" , len); +break ; + }memcpy (wcn->hal_buf, buf, len); wcn->hal_rsp_len = len;complete (&wcn->hal_rsp_compl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/2077 wifi: wcn36xx: fix OOB read from firmware count in PRINT_REG_INFO indication
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit df2187acfca6c6cca372c5d35f42394d9c270b09 ]
The firmware-controlled rsp->count field is used as the loop bound for indexing into the flexible rsp->regs[] array without validation against the message length. A count exceeding the actual data causes out-of- bounds reads from the heap-allocated message buffer.
Add a check that count fits within the received message.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/wcn36xx/smd.c +6 -0
@@ -2805,6 +2805,12 @@ static int wcn36xx_smd_print_reg_info_ind(struct wcn36xx *wcn,return -EIO ; } +if (rsp->count > (len -sizeof (*rsp)) /sizeof (rsp->regs[0 ])) { +wcn36xx_warn ("Truncated print reg info indication: count %u, len %zu\n" , + rsp->count, len); +return -EIO ; + } +wcn36xx_dbg (WCN36XX_DBG_HAL ,"reginfo indication, scenario: 0x%x reason: 0x%x\n" , rsp->scenario, rsp->reason);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/2077 wifi: wcn36xx: fix OOB read from short trigger BA firmware response
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit b5e6f21923ca89d90256e7346301056f6502691e ]
The firmware response length is only checked against sizeof(*rsp) (20 bytes), but when candidate_cnt >= 1, a 22-byte candidate struct is read at buf + 20 without verifying the response contains it. This causes an out-of-bounds read of stale heap data, corrupting the BA session state.
Add validation that the response includes the candidate data.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/wcn36xx/smd.c +3 -0
@@ -2599,6 +2599,9 @@ static int wcn36xx_smd_trigger_ba_rsp(void *buf, int len, struct add_ba_info *baif (rsp->candidate_cnt <1 )return rsp->status ? rsp->status : -EINVAL ; +if (len <sizeof (*rsp) +sizeof (*candidate)) +return -EINVAL ; + candidate = (struct wcn36xx_hal_trigger_ba_rsp_candidate *)(buf +sizeof (*rsp));for (i =0 ; i <STACFG_MAX_TC ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/2077 ALSA: seq: Fix partial userptr event expansion
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 2b7bd6f548292aec92a386deebe62324d21d62a9 ]
snd_seq_expand_var_event_at() clamps the number of bytes to copy to the remaining variable-event length, but passes the original buffer size to expand_var_event().
For SNDRV_SEQ_EXT_USRPTR events, expand_var_event() copies exactly the size argument from userspace. On the final chunk, when the remaining event data is shorter than the caller's buffer, this can read past the declared event data and can spuriously fail with -EFAULT if the extra bytes cross an unmapped page.
Pass the clamped length instead. The chained and kernel-backed paths already reclamp in dump_var_event(), but the user-pointer path handles the size directly.
--- sound/core/seq/seq_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/seq_memory.c +1 -1
@@ -211,7 +211,7 @@ int snd_seq_expand_var_event_at(const struct snd_seq_event *event, int count, len -= offset;if (len > count) len = count; - err =expand_var_event (event, offset, count, buf, true); + err =expand_var_event (event, offset, len, buf, true);if (err <0 )return err;return len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/2077 ALSA: pcm: Fix unlocked runtime state reads in xfer ioctls
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit 98fe3988a2efe89a1a1ded213a0561e6543e94e2 ]
The recent runtime state locking cleanup converted several PCM ioctl state checks to snd_pcm_get_state(), including snd_pcm_pre_prepare(), snd_pcm_drain() and snd_pcm_kernel_ioctl(). The native and compat xfer ioctl paths still sample runtime->state directly before dispatching to the PCM transfer helpers, and snd_pcm_common_ioctl() still samples the DISCONNECTED state directly in its common precheck.
Use snd_pcm_get_state() for those ioctl-side prechecks as well. This keeps the externally visible ioctl entry checks consistent with the stream-locked state access used by the recent PCM state-read cleanup.
--- sound/core/pcm_compat.c | 4 ++-- sound/core/pcm_native.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-)
sound/core/pcm_compat.c +2 -2
@@ -293,7 +293,7 @@ static int snd_pcm_ioctl_xferi_compat(struct snd_pcm_substream *substream,return -ENOTTY ;if (substream->stream != dir)return -EINVAL ; -if (substream->runtime->state ==SNDRV_PCM_STATE_OPEN ) +if (snd_pcm_get_state (substream) ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; if (get_user(buf, &data32->buf) ||
@@ -338,7 +338,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,return -ENOTTY ;if (substream->stream != dir)return -EINVAL ; -if (substream->runtime->state ==SNDRV_PCM_STATE_OPEN ) +if (snd_pcm_get_state (substream) ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; ch = substream->runtime->channels;
sound/core/pcm_native.c +3 -4
@@ -3303,10 +3303,9 @@ static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, struct snd_xferi __user *_xferi) {struct snd_xferi xferi; -struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t result; -if (runtime->state ==SNDRV_PCM_STATE_OPEN ) +if (snd_pcm_get_state (substream) ==SNDRV_PCM_STATE_OPEN )return -EBADFD ;if (put_user (0 , &_xferi->result))return -EFAULT ;
@@ -3329,7 +3328,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, void *bufs __free(kfree) = NULL;snd_pcm_sframes_t result; -if (runtime->state ==SNDRV_PCM_STATE_OPEN ) +if (snd_pcm_get_state (substream) ==SNDRV_PCM_STATE_OPEN )return -EBADFD ;if (runtime->channels >128 )return -EINVAL ;
@@ -3392,7 +3391,7 @@ static int snd_pcm_common_ioctl(struct file *file,if (PCM_RUNTIME_CHECK (substream))return -ENXIO ; -if (substream->runtime->state ==SNDRV_PCM_STATE_DISCONNECTED ) +if (snd_pcm_get_state (substream) ==SNDRV_PCM_STATE_DISCONNECTED )return -EBADFD ; res =snd_power_wait (substream->pcm->card);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/2077 riscv: cpu_ops: Change return value type of cpu_is_stopped() to bool
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
[ Upstream commit 2b2b207e1162e577cd6208e184d3d3a0fcfa9cca ]
In the original sbi_cpu_is_stopped(), if rc doesn't equal to the SBI_HSM_STATE_STOPPED, it will return rc to the caller directly. But there is a hidden problem, the rc could be SBI_HSM_STATE_STARTED, if so, this function will report cpu stopped while the cpu isn't really stopped.
Furthermore, from the name of cpu_is_stopped(), it gives a sense the return value is a bool type, true means the cpu is stopped, conversely false means the cpu is not stopped.
Here change the return value type to bool and change the callers accordingly. This could fix the above two issues.
--- arch/riscv/include/asm/cpu_ops.h | 2 +- arch/riscv/kernel/cpu-hotplug.c | 4 ++-- arch/riscv/kernel/cpu_ops_sbi.c | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-)
arch/riscv/include/asm/cpu_ops.h +1 -1
@@ -24,7 +24,7 @@ struct cpu_operations { struct task_struct *tidle);#ifdef CONFIG_HOTPLUG_CPU void (*cpu_stop)(void ); -int (*cpu_is_stopped)(unsigned int cpu); +bool (*cpu_is_stopped)(unsigned int cpu);#endif };
arch/riscv/kernel/cpu-hotplug.c +2 -2
@@ -57,8 +57,8 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)/* Verify from the firmware if the cpu is really stopped*/ if (cpu_ops->cpu_is_stopped) ret = cpu_ops->cpu_is_stopped (cpu); -if (ret) -pr_warn ("CPU%u may not have stopped: %d\n" , cpu, ret); +if (!ret) +pr_warn ("CPU%u may not have stopped\n" , cpu); }/*
arch/riscv/kernel/cpu_ops_sbi.c +7 -4
@@ -88,16 +88,19 @@ static void sbi_cpu_stop(void) pr_crit("Unable to stop the cpu %d (%d)\n", smp_processor_id(), ret); } -static int sbi_cpu_is_stopped (unsigned int cpuid) +static bool sbi_cpu_is_stopped (unsigned int cpuid) {int rc;unsigned long hartid =cpuid_to_hartid_map (cpuid); rc =sbi_hsm_hart_get_status (hartid); -if (rc ==SBI_HSM_STATE_STOPPED ) -return 0 ; -return rc; +if (rc !=SBI_HSM_STATE_STOPPED ) { +pr_warn ("HART%lu isn't stopped; status %d\n" , hartid, rc); +return false; + } + +return true; }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/2077 riscv: stacktrace: Remove bogus -0x4 offset in non-FP walk_stackframe
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rui Qi <[email protected]>
[ Upstream commit 8ac35bac70e7e581d673b76878f7691cdadc33b8 ]
In the non-frame-pointer version of walk_stackframe, each value read from the stack is treated as a potential return address and has 0x4 subtracted before being used as the program counter. This was intended to convert the return address (the instruction after a call) back to the call site, but it is incorrect:
1. RISC-V has variable-length instructions due to the RVC (compressed instruction) extension. A call instruction can be either 4 bytes (regular) or 2 bytes (compressed, e.g. c.jal). Subtracting a fixed 0x4 assumes all call instructions are 4 bytes, which is wrong for compressed instructions.
2. Stack traces conventionally report return addresses, not call sites. Other architectures (ARM64, x86, ARM) do not subtract instruction size from return addresses in their stack unwinding code.
3. The frame-pointer version of walk_stackframe already dropped the -0x4 offset. Commit b785ec129bd9 ("riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support") replaced "pc = frame->ra - 0x4" with ftrace_graph_ret_addr(), and the commit message explicitly noted that "the original calculation, pc = frame->ra - 4, is buggy when the instruction at the return address happened to be a compressed inst." The non-FP version was simply overlooked.
Remove the bogus -0x4 offset to match the FP version and the conventions used by other architectures.
--- arch/riscv/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/stacktrace.c +1 -1
@@ -129,7 +129,7 @@ void notrace walk_stackframe(struct task_struct *task,while (!kstack_end (ksp)) {if (__kernel_text_address (pc) &&unlikely (!fn (arg, pc)))break ; - pc =READ_ONCE_NOCHECK (*ksp++) -0x4 ; + pc =READ_ONCE_NOCHECK (*ksp++); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/2077 ALSA: seq: Clear variable event pointer on read
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 705dd6dcbc0ea87351c660c1a6443f85f1001c76 ]
snd_seq_read() copies a queued variable-length event header to userspace before expanding the payload. Queued variable-length events use SNDRV_SEQ_EXT_CHAINED internally, and data.ext.ptr points at the first extension cell.
The read side strips SNDRV_SEQ_EXT_* bits from data.ext.len before the copy, but it leaves data.ext.ptr untouched. A userspace sequencer client can therefore write a direct variable event to itself and read back the extension-cell kernel address from the returned header.
Clear the temporary header pointer before copy_to_user(). The original queued event remains unchanged and is still passed to snd_seq_expand_var_event(), so payload expansion keeps using the internal chain.
--- sound/core/seq/seq_clientmgr.c | 1 + 1 file changed, 1 insertion(+)
sound/core/seq/seq_clientmgr.c +1 -0
@@ -441,6 +441,7 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count,memcpy (&tmpev, &cell->event, aligned_size); tmpev.data.ext.len &= ~SNDRV_SEQ_EXT_MASK ; + tmpev.data.ext.ptr =NULL ;if (copy_to_user (buf, &tmpev, aligned_size)) { err = -EFAULT ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/2077 riscv: alternative: Use IS_ENABLED() over ifdeffery for apply_vdso_alternatives()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 4fd6505f189d447abbed1f1f6fe6b82649f27a46 ]
IS_ENABLED() allows better compilation coverage while still optimizing away all the dead code. Also it will make some upcoming changes easier.
Stable-dep-of: d3e0634787a2 ("riscv: alternative: Also patch the CFI vDSO")
--- arch/riscv/kernel/alternative.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
arch/riscv/kernel/alternative.c +2 -5
@@ -173,7 +173,6 @@ static void __init_or_module _apply_alternatives(struct alt_entry *begin, stage); } -#ifdef CONFIG_MMU static void __init apply_vdso_alternatives (void ) {const Elf_Ehdr *hdr;
@@ -194,9 +193,6 @@ static void __init apply_vdso_alternatives(void) (struct alt_entry *)end, RISCV_ALTERNATIVES_BOOT); } -#else -static void __init apply_vdso_alternatives (void ) { } -#endif void __init apply_boot_alternatives (void ) {
@@ -207,7 +203,8 @@ void __init apply_boot_alternatives(void) (struct alt_entry *)__alt_end, RISCV_ALTERNATIVES_BOOT); -apply_vdso_alternatives (); +if (IS_ENABLED (CONFIG_MMU )) +apply_vdso_alternatives (); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/2077 riscv: alternative: Pass vDSO start as parameter to apply_vdso_alternatives()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 6386161abb02880ace2cc965e73f7857b351706c ]
The dedicated vDSO with CFI should also be patched in the same way. To prepare for that move the currently hardcoded vDSO start symbol into a parameter.
Stable-dep-of: d3e0634787a2 ("riscv: alternative: Also patch the CFI vDSO")
--- arch/riscv/kernel/alternative.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/kernel/alternative.c +3 -3
@@ -173,14 +173,14 @@ static void __init_or_module _apply_alternatives(struct alt_entry *begin, stage); } -static void __init apply_vdso_alternatives (void ) +static void __init apply_vdso_alternatives (void *start) {const Elf_Ehdr *hdr;const Elf_Shdr *shdr;const Elf_Shdr *alt;struct alt_entry *begin, *end; - hdr = (Elf_Ehdr *)vdso_start; + hdr = (Elf_Ehdr *)start; shdr = (void *)hdr + hdr->e_shoff; alt =find_section (hdr, shdr,".alternative" );if (!alt)
@@ -204,7 +204,7 @@ void __init apply_boot_alternatives(void) RISCV_ALTERNATIVES_BOOT);if (IS_ENABLED (CONFIG_MMU )) -apply_vdso_alternatives (); +apply_vdso_alternatives (vdso_start); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/2077 riscv: alternative: Also patch the CFI vDSO
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit d3e0634787a234b40a740b9c398fd320a68db81c ]
The dedicated vDSO for CFI-enabled userspace can also contain alternative entries.
Patch those, too.
--- arch/riscv/kernel/alternative.c | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/kernel/alternative.c +3 -0
@@ -205,6 +205,9 @@ void __init apply_boot_alternatives(void)if (IS_ENABLED (CONFIG_MMU ))apply_vdso_alternatives (vdso_start); + +if (IS_ENABLED (CONFIG_RISCV_USER_CFI )) +apply_vdso_alternatives (vdso_cfi_start); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/2077 bpf: Verifier support for sleepable tracepoint programs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit 8cfb77d3092052b52582e804e644202e2b10167a ]
Allow BPF_PROG_TYPE_RAW_TRACEPOINT, BPF_PROG_TYPE_TRACEPOINT, and BPF_TRACE_RAW_TP (tp_btf) programs to be sleepable by adding them to can_be_sleepable().
For BTF-based raw tracepoints (tp_btf), add a load-time check in bpf_check_attach_target() that rejects sleepable programs attaching to non-faultable tracepoints with a descriptive error message.
For raw tracepoints (raw_tp), add an attach-time check in bpf_raw_tp_link_attach() that rejects sleepable programs on non-faultable tracepoints. The attach-time check is needed because the tracepoint name is not known at load time for raw_tp.
The attach-time check for classic tracepoints (tp) in __perf_event_set_bpf_prog() was added in the previous patch.
Replace the verbose error message that enumerates allowed program types with a generic "Program of this type cannot be sleepable" message, since the list of sleepable-capable types keeps growing.
Stable-dep-of: 5b038319be44 ("bpf: Reject sleepable BPF_LSM_CGROUP programs at load time")
--- kernel/bpf/syscall.c | 5 +++++ kernel/bpf/verifier.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
kernel/bpf/syscall.c +5 -0
@@ -4288,6 +4288,11 @@ static int bpf_raw_tp_link_attach(struct bpf_prog *prog,if (!btp)return -ENOENT ; +if (prog->sleepable && !tracepoint_is_faultable (btp->tp)) { +bpf_put_raw_tracepoint (btp); +return -EINVAL ; + } + link =kzalloc_obj (*link,GFP_USER );if (!link) { err = -ENOMEM ;
kernel/bpf/verifier.c +11 -2
@@ -19317,6 +19317,12 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, btp =bpf_get_raw_tracepoint (tname);if (!btp)return -EINVAL ; +if (prog->sleepable && !tracepoint_is_faultable (btp->tp)) { +bpf_log (log,"Sleepable program cannot attach to non-faultable tracepoint %s\n" , + tname); +bpf_put_raw_tracepoint (btp); +return -EINVAL ; + } fname =kallsyms_lookup ((unsigned long )btp->bpf_func,NULL ,NULL ,NULL , trace_symbol);bpf_put_raw_tracepoint (btp);
@@ -19533,6 +19539,7 @@ static bool can_be_sleepable(struct bpf_prog *prog)case BPF_MODIFY_RETURN :case BPF_TRACE_ITER :case BPF_TRACE_FSESSION : +case BPF_TRACE_RAW_TP :return true;default :return false;
@@ -19540,7 +19547,9 @@ static bool can_be_sleepable(struct bpf_prog *prog) }return prog->type ==BPF_PROG_TYPE_LSM || prog->type ==BPF_PROG_TYPE_KPROBE /* only for uprobes */ || - prog->type ==BPF_PROG_TYPE_STRUCT_OPS ; + prog->type ==BPF_PROG_TYPE_STRUCT_OPS || + prog->type ==BPF_PROG_TYPE_RAW_TRACEPOINT || + prog->type ==BPF_PROG_TYPE_TRACEPOINT ; }static int check_attach_btf_id (struct bpf_verifier_env *env)
@@ -19562,7 +19571,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env) }if (prog->sleepable && !can_be_sleepable (prog)) { -verbose (env,"Only fentry/fexit/fsession/fmod_ret, lsm, iter, uprobe, and struct_ops programs can be sleepable\n" ); +verbose (env,"Program of this type cannot be sleepable\n" );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/2077 bpf: Reject sleepable BPF_LSM_CGROUP programs at load time
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Windsor <[email protected]>
[ Upstream commit 5b038319be442c620f774e6fc9e9283deeca1c75 ]
The cgroup shim runs under rcu_read_lock_dont_migrate(), so we should not attach any sleepable BPF programs there. Add support to the verifier to explicitly reject attempts to load sleepable BPF programs destined for LSM cgroup attachment.
Without this, we get the following splat from a BPF_LSM_CGROUP program marked BPF_F_SLEEPABLE attached to file_open when it calls bpf_get_dentry_xattr():
BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1567 in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 34317, name: load preempt_count: 0, expected: 0 RCU nest depth: 2, expected: 0 Call Trace: down_read+0x76/0x480 ext4_xattr_get+0x11f/0x700 __vfs_getxattr+0xf0/0x150 bpf_get_dentry_xattr+0xbb/0xf0 bpf_prog_e76a298dac9218c6_test_open+0x6a/0x85 __cgroup_bpf_run_lsm_current+0x326/0x840 bpf_trampoline_6442534646+0x62/0x14d security_file_open+0x34/0x60 do_dentry_open+0x340/0x1260 vfs_open+0x7a/0x440 path_openat+0x1bac/0x30a0
libbpf provides a .s named section variant for every sleepable program type except lsm_cgroup, reflecting that per-cgroup LSM programs are intended to only run in a non-sleepable context.
The above splat was obtained by bypassing libbpf by using bpf(2) directly.
--- kernel/bpf/verifier.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +4 -2
@@ -19545,8 +19545,10 @@ static bool can_be_sleepable(struct bpf_prog *prog)return false; } } -return prog->type ==BPF_PROG_TYPE_LSM || - prog->type ==BPF_PROG_TYPE_KPROBE /* only for uprobes */ || +if (prog->type ==BPF_PROG_TYPE_LSM ) +return prog->expected_attach_type !=BPF_LSM_CGROUP ; + +return prog->type ==BPF_PROG_TYPE_KPROBE /* only for uprobes */ || prog->type ==BPF_PROG_TYPE_STRUCT_OPS || prog->type ==BPF_PROG_TYPE_RAW_TRACEPOINT || prog->type ==BPF_PROG_TYPE_TRACEPOINT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/2077 netfilter: flowtable: avoid num_encaps underflow on bridge VLAN untag
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit e052f920773b73be49eb4d8702a9f85de7464363 ]
The DEV_PATH_BR_VLAN_UNTAG case post-decrements info->num_encaps inside WARN_ON_ONCE(). num_encaps is u8, so if it's already 0 the decrement still happens and wraps it to 255. The break only leaves the inner switch -- a later path entry can set info->indev back to a real device, and we end up returning with num_encaps == 255.
nft_dev_forward_path() then walks info.encap[] (size 2) up to num_encaps, which means an OOB stack read and a bogus count copied into the route descriptor.
Should only happen on a malformed bridge path stack, hence the WARN, but worth handling sanely. Move the decrement out of the WARN.
[ While at this, remove the WARN_ON_ONCE since this can only happen
with a buggy bridge path stack --pablo ].
--- net/netfilter/nf_flow_table_path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_flow_table_path.c +2 -1
@@ -163,10 +163,11 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack, info->num_encaps++;break ;case DEV_PATH_BR_VLAN_UNTAG : -if (WARN_ON_ONCE (info->num_encaps-- ==0 )) { +if (info->num_encaps ==0 ) { info->indev =NULL ;break ; } + info->num_encaps--;break ;case DEV_PATH_BR_VLAN_KEEP :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/2077 filelock: fix break_lease() stub signature for CONFIG_FILE_LOCKING=n
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 4bbcff264b678859cc404669bd145bcd6819804b ]
The CONFIG_FILE_LOCKING=n stub for break_lease() takes a 'bool wait' argument, whereas the CONFIG_FILE_LOCKING=y version and every caller pass an openmode as an 'unsigned int mode'. The mismatch was introduced when __break_lease() was reworked to use flags: only the stub was switched to 'bool wait', a stray leftover from the neighbouring break_layout() helper. The real prototype kept 'unsigned int mode'.
This was harmless until O_WRONLY changed from the octal literal 00000001 to (1 << 0). clang's -Wtautological-constant-compare then fires on the implicit shift-to-bool conversion at the first FILE_LOCKING=n caller:
fs/open.c:112:29: warning: converting the result of '<<' to a boolean
always evaluates to true [-Wtautological-constant-compare]
112 | error = break_lease(inode, O_WRONLY);
Restore the stub's parameter to 'unsigned int mode' so it matches the real prototype and every caller. The stub still just returns 0, so there is no functional change; it removes the type inconsistency and silences the warning.
Root cause diagnosed by Nathan Chancellor.
--- include/linux/filelock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/filelock.h +1 -1
@@ -564,7 +564,7 @@ static inline bool is_delegated(struct delegated_inode *di)return false; } -static inline int break_lease (struct inode *inode,bool wait) +static inline int break_lease (struct inode *inode,unsigned int mode) {return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/2077 bpf: Fix NMI/tracepoint re-entry deadlock on lru locks
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mykyta Yatsenko <[email protected]>
[ Upstream commit 89edbdfc5d0308cef57b71359331de5c4ddbf763 ]
NMI and tracepoint BPF programs can re-enter the per-CPU or global LRU lock that bpf_lru_pop_free()/push_free() already hold on the same CPU, AA-deadlocking. Lockdep reports "inconsistent {INITIAL USE} -> {IN-NMI}" on &l->lock (syzbot c69a0a2c816716f1e0d5) and "possible recursive locking detected" on &loc_l->lock (syzbot 18b26edb69b2e19f3b33).
Prior trylock and rqspinlock based fixes (see links) were nacked because compromised on reliability.
This patch converts every LRU lock site to rqspinlock_t and adds a recovery path for some failure windows to avoid node leaks.
Failure recovery:
- *_pop_free top-level: return NULL; prealloc_lru_pop() already treats that as no-free-element (-ENOMEM).
- Cross-CPU steal: skip the victim's locked loc_l, try next CPU.
- Post-steal local lock fail: publish stolen node to lockless per-CPU free_llist; next pop on this CPU picks it up.
- push_free fail: mark node pending_free=1. __local_list_flush(), __local_list_pop_pending() reclaim the node from pending_list. __bpf_lru_list_shrink_inactive() reclaims the node from inactive list. Nodes from active list are reclaimed by __bpf_lru_list_shrink() or after __bpf_lru_list_rotate_active() demotes it to the inactive.
--- kernel/bpf/bpf_lru_list.c | 165 +++++++++++++++++++++++--------------- kernel/bpf/bpf_lru_list.h | 25 ++++-- 2 files changed, 119 insertions(+), 71 deletions(-)
kernel/bpf/bpf_lru_list.c +100 -65
@@ -13,23 +13,8 @@#define PERCPU_FREE_TARGET (4)#define PERCPU_NR_SCANS PERCPU_FREE_TARGET -/* Helpers to get the local list index */ -#define LOCAL_LIST_IDX (t) ((t) - BPF_LOCAL_LIST_T_OFFSET) -#define LOCAL_FREE_LIST_IDX LOCAL_LIST_IDX(BPF_LRU_LOCAL_LIST_T_FREE) -#define LOCAL_PENDING_LIST_IDX LOCAL_LIST_IDX(BPF_LRU_LOCAL_LIST_T_PENDING)#define IS_LOCAL_LIST_TYPE (t) ((t) >= BPF_LOCAL_LIST_T_OFFSET) -/* Local list helpers */ -static struct list_head *local_free_list (struct bpf_lru_locallist *loc_l) -{ -return &loc_l->lists[LOCAL_FREE_LIST_IDX ]; -} - -static struct list_head *local_pending_list (struct bpf_lru_locallist *loc_l) -{ -return &loc_l->lists[LOCAL_PENDING_LIST_IDX ]; -} -/* bpf_lru_node helpers */ static bool bpf_lru_node_is_ref (const struct bpf_lru_node *node) {
@@ -72,6 +57,7 @@ static void __bpf_lru_node_move_to_free(struct bpf_lru_list *l,bpf_lru_list_count_dec (l, node->type); node->type = tgt_free_type; +WRITE_ONCE (node->pending_free,0 );list_move (&node->list, free_list); }
@@ -87,6 +73,9 @@ static void __bpf_lru_node_move_in(struct bpf_lru_list *l,bpf_lru_list_count_inc (l, tgt_type); node->type = tgt_type;bpf_lru_node_clear_ref (node); +/* Reset pending_free only when moving to the free list */ +if (tgt_type ==BPF_LRU_LIST_T_FREE ) +WRITE_ONCE (node->pending_free,0 );list_move (&node->list, &l->lists[tgt_type]); }
@@ -212,9 +201,11 @@ __bpf_lru_list_shrink_inactive(struct bpf_lru *lru,unsigned int i =0 ;list_for_each_entry_safe_reverse (node, tmp_node, inactive, list) { -if (bpf_lru_node_is_ref (node)) { +if (bpf_lru_node_is_ref (node) && + !READ_ONCE (node->pending_free)) {__bpf_lru_node_move (l, node,BPF_LRU_LIST_T_ACTIVE ); - }else if (lru->del_from_htab (lru->del_arg, node)) { + }else if (READ_ONCE (node->pending_free) || + lru->del_from_htab (lru->del_arg, node)) {__bpf_lru_node_move_to_free (l, node, free_list, tgt_free_type);if (++nshrinked == tgt_nshrink)
@@ -273,7 +264,8 @@ static unsigned int __bpf_lru_list_shrink(struct bpf_lru *lru,list_for_each_entry_safe_reverse (node, tmp_node, force_shrink_list, list) { -if (lru->del_from_htab (lru->del_arg, node)) { +if (READ_ONCE (node->pending_free) || + lru->del_from_htab (lru->del_arg, node)) {__bpf_lru_node_move_to_free (l, node, free_list, tgt_free_type);return 1 ;
@@ -290,8 +282,10 @@ static void __local_list_flush(struct bpf_lru_list *l,struct bpf_lru_node *node, *tmp_node;list_for_each_entry_safe_reverse (node, tmp_node, -local_pending_list (loc_l), list) { -if (bpf_lru_node_is_ref (node)) + &loc_l->pending_list, list) { +if (READ_ONCE (node->pending_free)) +__bpf_lru_node_move_in (l, node,BPF_LRU_LIST_T_FREE ); +else if (bpf_lru_node_is_ref (node))__bpf_lru_node_move_in (l, node,BPF_LRU_LIST_T_ACTIVE );else __bpf_lru_node_move_in(l, node,
@@ -307,9 +301,12 @@ static void bpf_lru_list_push_free(struct bpf_lru_list *l,if (WARN_ON_ONCE (IS_LOCAL_LIST_TYPE (node->type)))return ; -raw_spin_lock_irqsave (&l->lock, flags); +if (raw_res_spin_lock_irqsave (&l->lock, flags)) { +WRITE_ONCE (node->pending_free,1 ); +return ; + }__bpf_lru_node_move (l, node,BPF_LRU_LIST_T_FREE ); -raw_spin_unlock_irqrestore (&l->lock, flags); +raw_res_spin_unlock_irqrestore (&l->lock, flags); } static void bpf_lru_list_pop_free_to_local(struct bpf_lru *lru,
@@ -318,8 +315,10 @@ static void bpf_lru_list_pop_free_to_local(struct bpf_lru *lru,struct bpf_lru_list *l = &lru->common_lru.lru_list;struct bpf_lru_node *node, *tmp_node;unsigned int nfree =0 ; +LIST_HEAD (tmp_free); -raw_spin_lock (&l->lock); +if (raw_res_spin_lock (&l->lock)) +return ;__local_list_flush (l, loc_l);
@@ -327,7 +326,7 @@ static void bpf_lru_list_pop_free_to_local(struct bpf_lru *lru,list_for_each_entry_safe (node, tmp_node, &l->lists[BPF_LRU_LIST_T_FREE ], list) { -__bpf_lru_node_move_to_free (l, node,local_free_list (loc_l), +__bpf_lru_node_move_to_free (l, node, &tmp_free,BPF_LRU_LOCAL_LIST_T_FREE );if (++nfree == lru->target_free)break ;
@@ -335,10 +334,19 @@ static void bpf_lru_list_pop_free_to_local(struct bpf_lru *lru,if (nfree < lru->target_free)__bpf_lru_list_shrink (lru, l, lru->target_free - nfree, -local_free_list (loc_l), + &tmp_free,BPF_LRU_LOCAL_LIST_T_FREE ); -raw_spin_unlock (&l->lock); +raw_res_spin_unlock (&l->lock); + +/* +* Transfer the harvested nodes from the temporary list_head into +* the lockless per-CPU free llist. +*/ +list_for_each_entry_safe (node, tmp_node, &tmp_free, list) { +list_del (&node->list); +llist_add (&node->llist, &loc_l->free_llist); + } } static void __local_list_add_pending(struct bpf_lru *lru,
@@ -350,22 +358,21 @@ static void __local_list_add_pending(struct bpf_lru *lru, *(u32 *)((void *)node + lru->hash_offset) = hash; node->cpu = cpu; node->type =BPF_LRU_LOCAL_LIST_T_PENDING ; +WRITE_ONCE (node->pending_free,0 );bpf_lru_node_clear_ref (node); -list_add (&node->list,local_pending_list (loc_l)); +list_add (&node->list, &loc_l->pending_list); }static struct bpf_lru_node *__local_list_pop_free (struct bpf_lru_locallist *loc_l) { -struct bpf_lru_node *node; +struct llist_node *llnode; - node =list_first_entry_or_null (local_free_list (loc_l), - struct bpf_lru_node, - list); -if (node) -list_del (&node->list); + llnode =llist_del_first (&loc_l->free_llist); +if (!llnode) +return NULL ; -return node; + return container_of(llnode, struct bpf_lru_node, llist); } static struct bpf_lru_node *
@@ -376,10 +383,10 @@ __local_list_pop_pending(struct bpf_lru *lru, struct bpf_lru_locallist *loc_l) ignore_ref:/* Get from the tail (i.e. older element) of the pending list. */ -list_for_each_entry_reverse (node,local_pending_list (loc_l), - list) { +list_for_each_entry_reverse (node, &loc_l->pending_list, list) {if ((!bpf_lru_node_is_ref (node) || force) && - lru->del_from_htab (lru->del_arg, node)) { + (READ_ONCE (node->pending_free) || + lru->del_from_htab (lru->del_arg, node))) {list_del (&node->list);return node; }
@@ -404,7 +411,8 @@ static struct bpf_lru_node *bpf_percpu_lru_pop_free(struct bpf_lru *lru, l =per_cpu_ptr (lru->percpu_lru, cpu); -raw_spin_lock_irqsave (&l->lock, flags); +if (raw_res_spin_lock_irqsave (&l->lock, flags)) +return NULL ;__bpf_lru_list_rotate (lru, l);
@@ -420,7 +428,7 @@ static struct bpf_lru_node *bpf_percpu_lru_pop_free(struct bpf_lru *lru,__bpf_lru_node_move (l, node,BPF_LRU_LIST_T_INACTIVE ); } -raw_spin_unlock_irqrestore (&l->lock, flags); +raw_res_spin_unlock_irqrestore (&l->lock, flags);return node; }
@@ -437,7 +445,8 @@ static struct bpf_lru_node *bpf_common_lru_pop_free(struct bpf_lru *lru, loc_l =per_cpu_ptr (clru->local_list, cpu); -raw_spin_lock_irqsave (&loc_l->lock, flags); +if (raw_res_spin_lock_irqsave (&loc_l->lock, flags)) +return NULL ; node =__local_list_pop_free (loc_l);if (!node) {
@@ -448,17 +457,22 @@ static struct bpf_lru_node *bpf_common_lru_pop_free(struct bpf_lru *lru,if (node)__local_list_add_pending (lru, loc_l, cpu, node, hash); -raw_spin_unlock_irqrestore (&loc_l->lock, flags); +raw_res_spin_unlock_irqrestore (&loc_l->lock, flags);if (node)return node; -/* No free nodes found from the local free list and +/* +* No free nodes found from the local free list and * the global LRU list. * * Steal from the local free/pending list of the * current CPU and remote CPU in RR. It starts * with the loc_l->next_steal CPU. +* +* Acquire the victim's lock before touching either list. On +* acquisition failure (rqspinlock AA or timeout) skip the victim +* and try the next CPU. */ first_steal = loc_l->next_steal;
@@ -466,24 +480,36 @@ static struct bpf_lru_node *bpf_common_lru_pop_free(struct bpf_lru *lru,do { steal_loc_l =per_cpu_ptr (clru->local_list, steal); -raw_spin_lock_irqsave (&steal_loc_l->lock, flags); - - node =__local_list_pop_free (steal_loc_l); -if (!node) - node =__local_list_pop_pending (lru, steal_loc_l); - -raw_spin_unlock_irqrestore (&steal_loc_l->lock, flags); +if (!raw_res_spin_lock_irqsave (&steal_loc_l->lock, flags)) { + node =__local_list_pop_free (steal_loc_l); +if (!node) + node =__local_list_pop_pending (lru, steal_loc_l); +raw_res_spin_unlock_irqrestore (&steal_loc_l->lock, flags); + } steal =cpumask_next_wrap (steal, cpu_possible_mask); }while (!node && steal != first_steal); loc_l->next_steal = steal; -if (node) { -raw_spin_lock_irqsave (&loc_l->lock, flags); -__local_list_add_pending (lru, loc_l, cpu, node, hash); -raw_spin_unlock_irqrestore (&loc_l->lock, flags); +if (!node) +return NULL ; + +if (raw_res_spin_lock_irqsave (&loc_l->lock, flags)) { +/* +* The local pending lock can't be acquired (rqspinlock AA +* or timeout). Return the stolen node to the per-CPU +* free_llist instead of orphaning it; the next pop_free on +* this CPU will pick it up. +*/ + node->type =BPF_LRU_LOCAL_LIST_T_FREE ; +bpf_lru_node_clear_ref (node); +WRITE_ONCE (node->pending_free,0 ); +llist_add (&node->llist, &loc_l->free_llist); +return NULL ; } +__local_list_add_pending (lru, loc_l, cpu, node, hash); +raw_res_spin_unlock_irqrestore (&loc_l->lock, flags);return node; }
@@ -511,18 +537,24 @@ static void bpf_common_lru_push_free(struct bpf_lru *lru, loc_l =per_cpu_ptr (lru->common_lru.local_list, node->cpu); -raw_spin_lock_irqsave (&loc_l->lock, flags); +if (raw_res_spin_lock_irqsave (&loc_l->lock, flags)) { +WRITE_ONCE (node->pending_free,1 ); +return ; + }if (unlikely (node->type !=BPF_LRU_LOCAL_LIST_T_PENDING )) { -raw_spin_unlock_irqrestore (&loc_l->lock, flags); +raw_res_spin_unlock_irqrestore (&loc_l->lock, + flags); goto check_lru_list; } node->type =BPF_LRU_LOCAL_LIST_T_FREE ;bpf_lru_node_clear_ref (node); -list_move (&node->list,local_free_list (loc_l)); +list_del (&node->list); + +raw_res_spin_unlock_irqrestore (&loc_l->lock, flags); -raw_spin_unlock_irqrestore (&loc_l->lock, flags); +llist_add (&node->llist, &loc_l->free_llist);return ; }
@@ -538,11 +570,14 @@ static void bpf_percpu_lru_push_free(struct bpf_lru *lru, l =per_cpu_ptr (lru->percpu_lru, node->cpu); -raw_spin_lock_irqsave (&l->lock, flags); +if (raw_res_spin_lock_irqsave (&l->lock, flags)) { +WRITE_ONCE (node->pending_free,1 ); +return ; + }__bpf_lru_node_move (l, node,BPF_LRU_LIST_T_FREE ); -raw_spin_unlock_irqrestore (&l->lock, flags); +raw_res_spin_unlock_irqrestore (&l->lock, flags); }void bpf_lru_push_free (struct bpf_lru *lru,struct bpf_lru_node *node)
@@ -565,6 +600,7 @@ static void bpf_common_lru_populate(struct bpf_lru *lru, void *buf, node = (struct bpf_lru_node *)(buf + node_offset); node->type =BPF_LRU_LIST_T_FREE ; + node->pending_free =0 ;bpf_lru_node_clear_ref (node);list_add (&node->list, &l->lists[BPF_LRU_LIST_T_FREE ]); buf += elem_size;
@@ -594,6 +630,7 @@ static void bpf_percpu_lru_populate(struct bpf_lru *lru, void *buf, node = (struct bpf_lru_node *)(buf + node_offset); node->cpu = cpu; node->type =BPF_LRU_LIST_T_FREE ; + node->pending_free =0 ;bpf_lru_node_clear_ref (node);list_add (&node->list, &l->lists[BPF_LRU_LIST_T_FREE ]); i++;
@@ -618,14 +655,12 @@ void bpf_lru_populate(struct bpf_lru *lru, void *buf, u32 node_offset,static void bpf_lru_locallist_init (struct bpf_lru_locallist *loc_l,int cpu) { -int i; - -for (i =0 ; i <NR_BPF_LRU_LOCAL_LIST_T ; i++) -INIT_LIST_HEAD (&loc_l->lists[i]); +INIT_LIST_HEAD (&loc_l->pending_list); +init_llist_head (&loc_l->free_llist); loc_l->next_steal = cpu; -raw_spin_lock_init (&loc_l->lock); +raw_res_spin_lock_init (&loc_l->lock); }static void bpf_lru_list_init (struct bpf_lru_list *l)
@@ -640,7 +675,7 @@ static void bpf_lru_list_init(struct bpf_lru_list *l) l->next_inactive_rotation = &l->lists[BPF_LRU_LIST_T_INACTIVE ]; -raw_spin_lock_init (&l->lock); +raw_res_spin_lock_init (&l->lock); } int bpf_lru_init(struct bpf_lru *lru, bool percpu, u32 hash_offset,
kernel/bpf/bpf_lru_list.h +19 -6
@@ -6,11 +6,11 @@#include <linux/cache.h> #include <linux/list.h> -#include <linux/spinlock_types.h> +#include <linux/llist.h> +#include <asm/rqspinlock.h> #define NR_BPF_LRU_LIST_T (3)#define NR_BPF_LRU_LIST_COUNT (2) -#define NR_BPF_LRU_LOCAL_LIST_T (2)#define BPF_LOCAL_LIST_T_OFFSET NR_BPF_LRU_LIST_Tenum bpf_lru_list_type {
@@ -22,10 +22,22 @@ enum bpf_lru_list_type { };struct bpf_lru_node { -struct list_head list; +/* +* A node is in at most one list at a time. The free path on the +* per-CPU locallist uses an llist, so share storage via a union. +*/ +union { +struct list_head list; +struct llist_node llist; + };u16 cpu;u8 type;u8 ref; +/* +* Marks nodes whose *_push_free() lock acquire failed; reclaimed +* by flush/shrink which honor the flag instead of del_from_htab(). +*/ +u8 pending_free; };struct bpf_lru_list {
@@ -34,13 +46,14 @@ struct bpf_lru_list {/* The next inactive list rotation starts from here */ struct list_head *next_inactive_rotation; -raw_spinlock_t lock____cacheline_aligned_in_smp ; +rqspinlock_t lock____cacheline_aligned_in_smp ; };struct bpf_lru_locallist { -struct list_head lists[NR_BPF_LRU_LOCAL_LIST_T ]; +struct list_head pending_list; +struct llist_head free_llist;u16 next_steal; -raw_spinlock_t lock; +rqspinlock_t lock; };struct bpf_common_lru {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/2077 kunit:tool: Dont write to stdout when it should be disabled
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Gow <[email protected]>
[ Upstream commit 29afed142d64e181749214072315c976f8510bd7 ]
The kunit_parser module accepts a 'printer' object which is used as a destination for all output. This is typically set to stdout, so that the parsed results are visible, but can be set to a special 'null_printer' to implement options where not all results are always printed.
However, there are a few places where use of stdout is hardcoded, notably in handling crashed tests and in outputting the colour escape sequences.
Properly use the specified printer for all output. This is okay for the colour handling (as this is already gated behind isatty() anyway), and also for the crash handling, as cases where printer != stdout are separately printed afterwards.
--- tools/testing/kunit/kunit_parser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/kunit/kunit_parser.py +6 -6
@@ -17,7 +17,7 @@ import textwrap from enum import Enum, auto from typing import Iterable, Iterator, List, Optional, Tuple -from kunit_printer import Printer, stdout +from kunit_printer import Printer class Test: """
@@ -57,7 +57,7 @@ class Test: def add_error(self, printer: Printer, error_message: str) -> None: """Records an error that occurred while parsing this test.""" self.counts.errors += 1 - printer.print_with_timestamp(stdout.red('[ERROR]') + f' Test: {self.name}: {error_message}') + printer.print_with_timestamp(printer.red('[ERROR]') + f' Test: {self.name}: {error_message}') def ok_status(self) -> bool: """Returns true if the status was ok, i.e. passed or skipped."""
@@ -544,7 +544,7 @@ def format_test_result(test: Test, printer: Printer) -> str: return printer.yellow('[NO TESTS RUN] ') + test.name if test.status == TestStatus.TEST_CRASHED: print_log(test.log, printer) - return stdout.red('[CRASHED] ') + test.name + return printer.red('[CRASHED] ') + test.name print_log(test.log, printer) return printer.red('[FAILED] ') + test.name
@@ -651,11 +651,11 @@ def print_summary_line(test: Test, printer: Printer) -> None: printer - Printer object to output results """ if test.status == TestStatus.SUCCESS: - color = stdout.green + color = printer.green elif test.status in (TestStatus.SKIPPED, TestStatus.NO_TESTS): - color = stdout.yellow + color = printer.yellow else: - color = stdout.red + color = printer.red printer.print_with_timestamp(color(f'Testing complete. {test.counts}')) # Summarize failures that might have gone off-screen since we had a lot
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/2077 wifi: mac80211: bound S1G TIM PVB walk to the TIM element
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit b224d18b1e5d1cddfc67f63f41d80023b2ec8889 ]
ieee80211_s1g_check_tim() parses the S1G Partial Virtual Bitmap (PVB) of a received TIM element. The TIM is handed in as the element payload:ieee802_11_parse_elems_full() stores elems->tim = elem->data and elems->tim_len = elem->datalen (net/mac80211/parse.c), so the valid bytes are [tim, tim + tim_len).
When walking the encoded blocks the function passes the walker an end sentinel of (const u8 *)tim + tim_len + 2, i.e. two bytes past the end of the element. ieee80211_s1g_find_target_block() loops while (ptr + 1 <= end) and dereferences ptr (and the per-mode ieee80211_s1g_len_*() helpers read *ptr), so it can read up to two bytes beyond the TIM element -- an out-of-bounds read of adjacent skb/heap data when the TIM is the last element in the frame. The +2 appears to account for the element id/len header, but tim already points past that header at the element payload, so the addend is wrong.
Pass the correct element end, (const u8 *)tim + tim_len.
--- include/linux/ieee80211-s1g.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ieee80211-s1g.h +1 -1
@@ -556,7 +556,7 @@ static inline bool ieee80211_s1g_check_tim(const struct ieee80211_tim_ie *tim,*/ err =ieee80211_s1g_find_target_block (&enc_blk, &target_aid, tim->virtual_map, - (const u8 *)tim + tim_len +2 ); + (const u8 *)tim + tim_len);if (err)return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/2077 powerpc/8xx: implement get_direction() in cpm1
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 052f67a1ae6ffa6e43c82193bf2e6c0dfd2e6d8f ]
The lack of get_direction() callbacks in this driver causes GPIOLIB to emit a warning. Implement them for 16- and 32-bit variants.
--- arch/powerpc/platforms/8xx/cpm1.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/powerpc/platforms/8xx/cpm1.c +26 -0
@@ -472,6 +472,18 @@ static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)return 0 ; } +static int cpm1_gpio16_get_direction (struct gpio_chip *gc,unsigned int gpio) +{ +struct cpm1_gpio16_chip *cpm1_gc =gpiochip_get_data (gc); +struct cpm_ioport16 __iomem *iop = cpm1_gc->regs; +u16 pin_mask =1 << (15 - gpio); + +if (in_be16 (&iop->dir) & pin_mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; +} +int cpm1_gpiochip_add16 (struct device *dev) {struct device_node *np = dev->of_node;
@@ -498,6 +510,7 @@ int cpm1_gpiochip_add16(struct device *dev) gc->ngpio =16 ; gc->direction_input = cpm1_gpio16_dir_in; gc->direction_output = cpm1_gpio16_dir_out; + gc->get_direction = cpm1_gpio16_get_direction; gc->get = cpm1_gpio16_get; gc->set = cpm1_gpio16_set; gc->to_irq = cpm1_gpio16_to_irq;
@@ -604,6 +617,18 @@ static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)return 0 ; } +static int cpm1_gpio32_get_direction (struct gpio_chip *gc,unsigned int gpio) +{ +struct cpm1_gpio32_chip *cpm1_gc =gpiochip_get_data (gc); +struct cpm_ioport32b __iomem *iop = cpm1_gc->regs; +u32 pin_mask =1 << (31 - gpio); + +if (in_be32 (&iop->dir) & pin_mask) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; +} +int cpm1_gpiochip_add32 (struct device *dev) {struct device_node *np = dev->of_node;
@@ -621,6 +646,7 @@ int cpm1_gpiochip_add32(struct device *dev) gc->ngpio =32 ; gc->direction_input = cpm1_gpio32_dir_in; gc->direction_output = cpm1_gpio32_dir_out; + gc->get_direction = cpm1_gpio32_get_direction; gc->get = cpm1_gpio32_get; gc->set = cpm1_gpio32_set; gc->parent = dev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/2077 bpf: Fix NULL pointer dereference in bpf_task_from_vpid()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit 50dff00615522f3ec03449680ca23beb4cfc549c ]
bpf_task_from_vpid() looks up a task in the pid namespace of the current task, via find_task_by_vpid():
find_task_by_vpid(vpid)
find_task_by_pid_ns(vpid, task_active_pid_ns(current))
find_pid_ns(nr, ns) -> idr_find(&ns->idr, nr)cgroup_skb programs run in softirq, which may interrupt a task that is itself in do_exit(). Once that task has passedexit_notify() -> release_task() -> __unhash_process(), its thread_pid is cleared, so task_active_pid_ns(current) returns NULL and find_pid_ns() dereferences &NULL->idr:
BUG: kernel NULL pointer dereference, address: 0000000000000050 RIP: 0010:idr_find+0x11/0x30 lib/idr.c:176 Call Trace: <IRQ> find_pid_ns kernel/pid.c:370 [inline] find_task_by_pid_ns+0x3b/0xe0 kernel/pid.c:485 bpf_task_from_vpid+0x5b/0x200 kernel/bpf/helpers.c:2916 bpf_prog_run_array_cg+0x17e/0x530 kernel/bpf/cgroup.c:81 __cgroup_bpf_run_filter_skb+0x12b/0x250 kernel/bpf/cgroup.c:1612 sk_filter_trim_cap+0x1dc/0x4c0 net/core/filter.c:148 tcp_v4_rcv+0x18d1/0x2200 net/ipv4/tcp_ipv4.c:2223 </IRQ> <TASK> do_exit+0xa63/0x1270 kernel/exit.c:1010 get_signal+0x141c/0x1530 kernel/signal.c:3037
Bail out when current has no pid namespace.
--- kernel/bpf/helpers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/helpers.c +4 -2
@@ -2919,11 +2919,13 @@ __bpf_kfunc struct task_struct *bpf_task_from_vpid(s32 vpid) {struct task_struct *p; -rcu_read_lock (); +guard (rcu)(); +if (!task_active_pid_ns (current)) +return NULL ; + p =find_task_by_vpid (vpid);if (p) p =bpf_task_acquire (p); -rcu_read_unlock ();return p; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/2077 ACPI: IPMI: Fix message kref handling on dead device
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 63320db6a5d84ec3fed8b3d36ba5244d07ddd108 ]
acpi_ipmi_space_handler() takes an extra reference on tx_msg before checking whether the selected IPMI device is dead. The reference belongs to the tx_msg_list entry and is normally dropped by ipmi_cancel_tx_msg() or ipmi_flush_tx_msg() after the message is removed from the list.
On the dead-device path, the message has not been queued yet, but the error path still calls ipmi_msg_release() directly. That bypasses kref_put() and frees tx_msg while the queued-message reference is still recorded in the kref count.
Take the queued-message reference only after the dead-device check succeeds, immediately before adding tx_msg to the list.
--- drivers/acpi/acpi_ipmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_ipmi.c +1 -1
@@ -550,7 +550,6 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,return AE_TYPE ; } -acpi_ipmi_msg_get (tx_msg);mutex_lock (&driver_data.ipmi_lock);/* Do not add a tx_msg that can not be flushed. */ if (ipmi_device->dead) {
@@ -558,6 +557,7 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,ipmi_msg_release (tx_msg);return AE_NOT_EXIST ; } +acpi_ipmi_msg_get (tx_msg);spin_lock_irqsave (&ipmi_device->tx_msg_lock, flags);list_add_tail (&tx_msg->head, &ipmi_device->tx_msg_list);spin_unlock_irqrestore (&ipmi_device->tx_msg_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/2077 ACPI: processor: Add cpuidle driver check in acpi_processor_register_idle_driver()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony W Wang-oc <[email protected]>
[ Upstream commit 66c62e6773c54ce5233eb21c6d48999c3747bd13 ]
Commit 7a8c994cbb2d ("ACPI: processor: idle: Optimize ACPI idle driver registration") moved the ACPI idle driver registration to acpi_processor_driver_init(), but it didn't check whether a cpuidle driver was already registered.
For example, on Intel platforms, if the intel_idle driver is already loaded, the code would still evaluate the _CST object in the ACPI table and attempt to register the acpi_idle driver. This registration would fail with -EBUSY due to the existing check in cpuidle_register_driver.
Add a check at the beginning of acpi_processor_register_idle_driver() to avoid unnecessary _CST evaluate and potential registration failures.
--- drivers/acpi/processor_idle.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/acpi/processor_idle.c +9 -0
@@ -1355,6 +1355,15 @@ void acpi_processor_register_idle_driver(void)int ret = -ENODEV ;int cpu; +/* +* If a cpuidle driver is already registered, there is no need to +* evaluate _CST or attempt to register the ACPI idle driver. +*/ +if (cpuidle_get_driver ()) { +pr_debug ("cpuidle driver %pS already registered.\n" ,cpuidle_get_driver ()); +return ; + } +acpi_processor_update_max_cstate ();/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/2077 cpufreq: Documentation: fix conservative governor freq_step description
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengjie Zhang <[email protected]>
[ Upstream commit 03120e1425262c7d11f93362a88e579a1720390b ]
The conservative governor documentation incorrectly states that setting freq_step to 0 will use the default 5% frequency step. In reality, since at least commit 8e677ce83bf4 ("[CPUFREQ] conservative: fixup governor to function more like ondemand logic"), freq_step=0 has always caused the governor to skip frequency updates entirely.
Correct the documentation to reflect the actual behavior: freq_step=0 disables frequency changes by the governor entirely.
--- Documentation/admin-guide/pm/cpufreq.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/pm/cpufreq.rst +2 -2
@@ -586,8 +586,8 @@ This governor exposes the following tunables: 100 (5 by default). This is how much the frequency is allowed to change in one go. Setting - it to 0 will cause the default frequency step (5 percent) to be used - and setting it to 100 effectively causes the governor to periodically + it to 0 disables frequency changes by the governor entirely and setting + it to 100 effectively causes the governor to periodically switch the frequency between the ``scaling_min_freq`` and ``scaling_max_freq`` policy limits.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/2077 thermal: testing: reject missing command arguments
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit ef3e98b0aa4b348f44065d7130251273c83bd204 ]
The thermal testing debugfs command parser splits commands at ':' and passes the right-hand side to the command implementation. Commands such as deltz, tzaddtrip, tzreg, and tzunreg require a zone id, but writing one of those command names without ':' leaves the argument pointer NULL.
The command implementations parse the id with sscanf(arg, "%d", ...), so the missing-argument form dereferences a NULL pointer from the debugfs write path.
Reject missing arguments in tt_command_exec() before calling handlers that require an id.
--- drivers/thermal/testing/command.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/thermal/testing/command.c +12 -0
@@ -116,18 +116,30 @@ static int tt_command_exec(int index, const char *arg)break ;case TT_CMD_DELTZ : +if (!arg || !*arg) +return -EINVAL ; + ret =tt_del_tz (arg);break ;case TT_CMD_TZADDTRIP : +if (!arg || !*arg) +return -EINVAL ; + ret =tt_zone_add_trip (arg);break ;case TT_CMD_TZREG : +if (!arg || !*arg) +return -EINVAL ; + ret =tt_zone_reg (arg);break ;case TT_CMD_TZUNREG : +if (!arg || !*arg) +return -EINVAL ; + ret =tt_zone_unreg (arg);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/2077 btrfs: dont force DIO writes to be serialized
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Harmstone <[email protected]>
[ Upstream commit 14f9161e872072075284b8afa4c3f929e199a0f6 ]
Before btrfs switched to the new mount API in 2023, we were setting SB_NOSEC in btrfs_mount_root(). This flag tells the VFS that the filesystem may have files which don't have security xattrs, enabling it to do some optimizations.
Unfortunately this was missed in the transition, meaning that IS_NOSEC will always return false for a btrfs inode. This means that btrfs_direct_write() calls will always get the inode lock exclusively, meaning that DIO writes to the same file will be serialized.
On my machine, this one-line change results in a ~59% improvement in DIO throughput:
Before patch:
test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=io_uring, iodepth=64
...
fio-3.39
Starting 32 processes
test: Laying out IO file (1 file / 1024MiB)
Jobs: 32 (f=32): [w(32)][100.0%][w=764MiB/s][w=195k IOPS][eta 00m:00s]
test: (groupid=0, jobs=32): err= 0: pid=586: Wed Apr 22 13:03:04 2026
write: IOPS=202k, BW=787MiB/s (826MB/s)(46.1GiB/60012msec); 0 zone resets
bw ( KiB/s): min=498714, max=1199892, per=100.00%, avg=806659.03, stdev=4229.94, samples=3808
iops : min=124677, max=299971, avg=201661.82, stdev=1057.49, samples=3808
cpu : usr=0.32%, sys=1.27%, ctx=8329204, majf=0, minf=1163
IO depths : 1=0.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=100.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
issued rwts: total=0,12094328,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=64Run status group 0 (all jobs):
WRITE: bw=787MiB/s (826MB/s), 787MiB/s-787MiB/s (826MB/s-826MB/s), io=46.1GiB (49.5GB), run=60012-60012msec
After patch:
test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=io_uring, iodepth=64
...
fio-3.39
Starting 32 processes
test: Laying out IO file (1 file / 1024MiB)
Jobs: 32 (f=32): [w(32)][100.0%][w=1255MiB/s][w=321k IOPS][eta 00m:00s]
test: (groupid=0, jobs=32): err= 0: pid=572: Wed Apr 22 13:13:46 2026
write: IOPS=320k, BW=1250MiB/s (1311MB/s)(73.3GiB/60003msec); 0 zone resets
bw ( MiB/s): min= 619, max= 2289, per=100.00%, avg=1251.28, stdev= 9.64, samples=3808
iops : min=158538, max=586025, avg=320320.80, stdev=2468.97, samples=3808
cpu : usr=0.35%, sys=11.50%, ctx=1584847, majf=0, minf=1160
IO depths : 1=0.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=100.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
issued rwts: total=0,19203309,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=64Run status group 0 (all jobs):
WRITE: bw=1250MiB/s (1311MB/s), 1250MiB/s-1250MiB/s (1311MB/s-1311MB/s), io=73.3GiB (78.7GB), run=60003-60003msec
The script to reproduce that:
#!/bin/bash
mkfs.btrfs -f /dev/nvme0n1
mount /dev/nvme0n1 /mnt/test
mkdir /mnt/test/nocow
chattr +C /mnt/test/nocow
fio /root/test.fio
# cat /root/test.fio [global] rw=randwrite ioengine=io_uring iodepth=64 size=1g direct=1 startdelay=20 force_async=4 ramp_time=5 runtime=60 group_reporting=1 numjobs=32 time_based disk_util=0 clat_percentiles=0 disable_lat=1 disable_clat=1 disable_slat=1 filename=/mnt/test/nocow/fiofile [test] name=test bs=4k stonewall
This was on a VM with 8 cores and 8GB of RAM, with a real NVMe exposed through PCI passthrough. The figures for XFS and ext4 in comparison are both about ~3GB/s.
--- fs/btrfs/super.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/super.c +1 -0
@@ -1873,6 +1873,7 @@ static int btrfs_get_tree_super(struct fs_context *fc) fs_info->fs_devices = fs_devices;mutex_unlock (&uuid_mutex); + fc->sb_flags |=SB_NOSEC ; sb =sget_fc (fc, btrfs_fc_test_super, set_anon_super_fc);if (IS_ERR (sb)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/2077 ntfs: validate resident attribute lists and harden the validator
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 7d19e1ffee084c4f7d321a360c14ba43404f7cc8 ]
A base inode's $ATTRIBUTE_LIST is sanity-checked by load_attribute_list() only on the non-resident path; ntfs_read_locked_inode() copies a *resident* attribute list into ni->attr_list with a plain memcpy() and no validation at all. Every subsequent walk of ni->attr_list -- ntfs_external_attr_find(), ntfs_inode_attach_all_extents() and ntfs_attrlist_need() -- then trusts the entries are well-formed and reads attr_list_entry fixed-header fields
(lowest_vcn at offset 8, mft_reference at offset 16, and the name) with bounds that assume validation already happened. A crafted resident attribute list therefore reaches those walks unvalidated and can drive out-of-bounds reads of the attribute-list buffer.
load_attribute_list() itself reads ale->name_offset (offset 7), ale->mft_reference (offset 16) and the name length under only an "al < al_start + size" bound, so its own validation loop can over-read the fixed header of a truncated trailing entry by a few bytes.
Factor the per-entry validation into ntfs_attr_list_entry_is_valid(), which requires each entry's fixed header (offsetof(struct attr_list_entry, name)) to be in range before any field is dereferenced, that ale->length is a multiple of 8 covering the fixed header plus the name, and that the entry is in use and carries a live MFT reference. ntfs_attr_list_is_valid() walks the buffer with it and checks the entries tile it exactly. Use the list validator in load_attribute_list() (replacing the open-coded loop, closing its own over-read) and on the resident path in ntfs_read_locked_inode() (which previously skipped validation entirely); patches 2/3 reuse the per-entry helper at the other two attribute-list walks.
--- fs/ntfs/attrib.c | 78 ++++++++++++++++++++++++++++++++++++++---------- fs/ntfs/attrib.h | 4 +++ fs/ntfs/inode.c | 6 ++++ 3 files changed, 73 insertions(+), 15 deletions(-)
fs/ntfs/attrib.c +63 -15
@@ -843,11 +843,71 @@ char *ntfs_attr_name_get(const struct ntfs_volume *vol, const __le16 *uname,return NULL ; } +/* +* ntfs_attr_list_entry_is_valid - sanity check one $ATTRIBUTE_LIST entry +* @ale: the attribute-list entry to check +* @al_end: end of the attribute-list buffer @ale lives in +* +* Verify that @ale is a well-formed attr_list_entry wholly contained in +* [.., @al_end): its fixed header must lie in range before any field is +* dereferenced, its length must be a multiple of 8 that covers the fixed +* header plus the name, the name must lie within the buffer, the entry must +* be in use and carry a live MFT reference. Return true if valid. +*/ +bool ntfs_attr_list_entry_is_valid (const struct attr_list_entry *ale, +const u8 *al_end) +{ +const u8 *al = (const u8 *)ale; +u16 ale_len; + +/* The fixed header must be in bounds before it is parsed. */ +if (al + offsetof(struct attr_list_entry , name) > al_end) +return false; + ale_len =le16_to_cpu (ale->length); +/* On-disk entries are 8-byte aligned (see struct attr_list_entry). */ +if (ale_len &7 ) +return false; +if (ale->name_offset !=sizeof (struct attr_list_entry )) +return false; +if ((u32 )ale->name_offset + + (u32 )ale->name_length *sizeof (__le16) > ale_len || + al + ale_len > al_end) +return false; +if (ale->type ==AT_UNUSED ) +return false; +if (MSEQNO_LE (ale->mft_reference) ==0 ) +return false; +return true; +} + +/* +* ntfs_attr_list_is_valid - sanity check an in-memory $ATTRIBUTE_LIST +* @al_start: start of the attribute list buffer +* @size: length of the attribute list in bytes +* +* Verify that [@al_start, @al_start + @size) is a sequence of valid +* attr_list_entry records (see ntfs_attr_list_entry_is_valid()) that tile the +* buffer exactly. Return true if valid, false otherwise. +*/ +bool ntfs_attr_list_is_valid (const u8 *al_start,s64 size) +{ +const u8 *al = al_start; +const u8 *al_end = al_start + size; + +while (al < al_end) { +const struct attr_list_entry *ale = + (const struct attr_list_entry *)al; + +if (!ntfs_attr_list_entry_is_valid (ale, al_end)) +return false; + al +=le16_to_cpu (ale->length); + } +return al == al_end; +} +int load_attribute_list (struct ntfs_inode *base_ni,u8 *al_start,const s64 size) {struct inode *attr_vi =NULL ; -u8 *al; -struct attr_list_entry *ale;if (!al_start || size <=0 )return -EINVAL ;
@@ -869,19 +929,7 @@ int load_attribute_list(struct ntfs_inode *base_ni, u8 *al_start, const s64 size }iput (attr_vi); -for (al = al_start; al < al_start + size; al +=le16_to_cpu (ale->length)) { - ale = (struct attr_list_entry *)al; -if (ale->name_offset !=sizeof (struct attr_list_entry )) -break ; -if (le16_to_cpu (ale->length) <= ale->name_offset + ale->name_length || - al +le16_to_cpu (ale->length) > al_start + size) -break ; -if (ale->type ==AT_UNUSED ) -break ; -if (MSEQNO_LE (ale->mft_reference) ==0 ) -break ; - } -if (al != al_start + size) { +if (!ntfs_attr_list_is_valid (al_start, size)) {ntfs_error (base_ni->vol->sb,"Corrupt attribute list, mft = %llu" , base_ni->mft_no);return -EIO ;
fs/ntfs/attrib.h +4 -0
@@ -71,6 +71,10 @@ int ntfs_attr_lookup(const __le32 type, const __le16 *name, const u32 name_len, const u32 ic, const s64 lowest_vcn, const u8 *val, const u32 val_len, struct ntfs_attr_search_ctx *ctx); +bool ntfs_attr_list_entry_is_valid (const struct attr_list_entry *ale, +const u8 *al_end); +bool ntfs_attr_list_is_valid (const u8 *al_start,s64 size); +int load_attribute_list (struct ntfs_inode *base_ni,u8 *al_start,const s64 size);
fs/ntfs/inode.c +6 -0
@@ -848,6 +848,12 @@ static int ntfs_read_locked_inode(struct inode *vi) a->data.resident.value_offset),le32_to_cpu ( a->data.resident.value_length)); +/* A resident list is not validated on load; check it now. */ +if (!ntfs_attr_list_is_valid (ni->attr_list, + ni->attr_list_size)) { +ntfs_error (vi->i_sb,"Corrupt attribute list." ); + goto unm_err_out; + } } } skip_attr_list_load:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/2077 ntfs: bound the look-ahead attribute-list entry in ntfs_external_attr_find()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 344b18f389f9934d59c7b0cf3d20541ea2e0da58 ]
When resolving an attribute lookup with a non-zero @lowest_vcn, ntfs_external_attr_find() peeks at the next $ATTRIBUTE_LIST entry to decide whether to keep searching, but bounds that not-yet-validated entry only with "(u8 *)next_al_entry + 6 < al_end" (which proves just bytes 0..6 are in range) and "(u8 *)next_al_entry + length <= al_end" with an attacker-controlled, non-8-aligned length. It then reads next_al_entry->lowest_vcn (an __le64 at offset 8) and the name at next_al_entry->name_offset, both of which can lie past al_end -- the exact end of the kvmalloc'd attribute-list buffer (allocated at the on-disk attr_list_size, no rounding). A crafted on-disk $ATTRIBUTE_LIST whose last entry sits a few bytes before al_end therefore yields a slab out-of-bounds read when the inode is read.
Validate the look-ahead entry with ntfs_attr_list_entry_is_valid() (added in patch 1/3) before dereferencing lowest_vcn and the name, so the same fixed-header, length and name bounds the main attribute-list walk uses now guard this read too.
--- fs/ntfs/attrib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ntfs/attrib.c +2 -3
@@ -1185,9 +1185,8 @@ static int ntfs_external_attr_find(const __le32 type,* we have reached the right one or the search has failed. */ if (lowest_vcn && (u8 *)next_al_entry >= al_start && - (u8 *)next_al_entry + 6 < al_end && - (u8 *)next_al_entry + le16_to_cpu( - next_al_entry->length) <= al_end && + ntfs_attr_list_entry_is_valid(next_al_entry, + al_end) && le64_to_cpu(next_al_entry->lowest_vcn) <= lowest_vcn && next_al_entry->type == al_entry->type &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/2077 ntfs: bound the attribute-list entry in ntfs_read_inode_mount()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 98634df5b1cb56c26299b7409227025ddb0167d8 ]
The $MFT attribute-list walk in ntfs_read_inode_mount() validates each entry only with "(u8 *)al_entry + 6 > al_end" and
"(u8 *)al_entry + le16_to_cpu(al_entry->length) > al_end", but then reads al_entry->lowest_vcn (an __le64 at offset 8) and al_entry->mft_reference (offset 16) -- fields beyond the 6 bytes proven in range. al_entry->length is attacker-controlled and only required non-zero, so a short entry (e.g. length 8) placed at the tail passes both checks while the lowest_vcn / mft_reference reads fall past al_end.
al_end is ni->attr_list + attr_list_size (the on-disk size); the buffer is kvzalloc(round_up(attr_list_size, SECTOR_SIZE)), so the sector rounding usually absorbs the over-read -- but when attr_list_size is a multiple of SECTOR_SIZE there is no slack and a crafted $MFT attribute list produces an out-of-bounds read at mount time.
Validate the entry with ntfs_attr_list_entry_is_valid() (added in patch 1/3) before dereferencing it, matching the bound the other attribute-list walks now use. The validator already requires the length to cover the fixed header, which makes the separate "!al_entry->length" check redundant, so drop it too.
--- fs/ntfs/inode.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/ntfs/inode.c +1 -4
@@ -2000,10 +2000,7 @@ int ntfs_read_inode_mount(struct inode *vi)/* Catch the end of the attribute list. */ if ((u8 *)al_entry == al_end) goto em_put_err_out; -if (!al_entry->length) - goto em_put_err_out; -if ((u8 *)al_entry +6 > al_end || - (u8 *)al_entry +le16_to_cpu (al_entry->length) > al_end) +if (!ntfs_attr_list_entry_is_valid (al_entry, al_end)) goto em_put_err_out; next_al_entry = (struct attr_list_entry *)((u8 *)al_entry +le16_to_cpu (al_entry->length));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/2077 ntfs: fix u16 truncation of restart-area length check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 390936fb15053d8d8991ca3a22776e251a5a7f2f ]
ntfs_check_restart_area() validates that the $LogFile restart area and its trailing log client record array fit within the system page size:
u16 ra_ofs, ra_len, ca_ofs;
...
ra_len = ca_ofs + le16_to_cpu(ra->log_clients) *
sizeof(struct log_client_record);
if (ra_ofs + ra_len > le32_to_cpu(rp->system_page_size) || ...)
return false;ra_len is u16, but the right-hand side is computed in size_t (sizeof(struct log_client_record) == 160). Both ca_ofs and log_clients come straight from the on-disk restart area. With an on-disk log_clients of 410 the product 410 * 160 = 65600; adding ca_ofs and storing into the u16 ra_len truncates modulo 65536 (e.g. ca_ofs 64 gives ra_len 128), so the "fits in the page" check passes even though the client array described by log_clients extends far beyond the page.
ntfs_check_log_client_array() then walks the array bounded only by the on-disk log_clients count:
cr = ca + idx;
if (cr->prev_client != LOGFILE_NO_CLIENT) ...For log_clients 410 it dereferences records up to ca + 409 * 160, ~64 KiB past the kvzalloc(system_page_size) restart-page buffer -- an out-of-bounds read of attacker-controlled extent, reachable when a crafted NTFS image is mounted (load_and_check_logfile() at mount time). This is the in-kernel analogue of CVE-2022-30789, fixed in the ntfs-3g userspace driver but never in this revived classic driver.
Compute the restart-area length in a u32 so the existing bounds check rejects an over-large client array instead of being defeated by the truncation. Widen ra_ofs and ca_ofs to u32 as well: both are loaded from __le16 on-disk fields and every comparison already promotes to int/size_t, so this changes no result and keeps the declaration uniform.
--- fs/ntfs/logfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs/logfile.c +1 -1
@@ -132,7 +132,7 @@ static bool ntfs_check_restart_area(struct inode *vi, struct restart_page_header {u64 file_size;struct restart_area *ra; -u16 ra_ofs, ra_len, ca_ofs; +u32 ra_ofs, ra_len, ca_ofs;u8 fs_bits;ntfs_debug ("Entering." );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/2077 IB/mlx5: Dont take the rereg_mr fallback without a new translation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 55d339d200c908de83a408d023cfb7be779b0dd7 ]
Jumping to mlx5_ib_reg_user_mr() without IB_MR_REREG_TRANS set will use garbage values for start, length, and iova. Recovering the original mr parameters for ODP and DMABUF to properly recreate it is too hard in this flow, so just fail it.
--- drivers/infiniband/hw/mlx5/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +1 -1
@@ -1202,7 +1202,7 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, }/* DM or ODP MR's don't have a normal umem so we can't re-use it */ if (!mr->umem ||is_odp_mr (mr) ||is_dmabuf_mr (mr)) - goto recreate; +return ERR_PTR (-EOPNOTSUPP );/* * Only one active MR can refer to a umem at one time, revoke
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/2077 IB/mlx5: Properly support implicit ODP rereg_mr
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit ee7a8335069150c3f1893a697ab30bbeca00d796 ]
Due to all the child mkeys in the implicit ODP configuration we cannot change anything in place for the parent mkey. Instead the whole thing needs to be rebuilt if any change is requested. If the user does not specify a translation then force the implicit values which will then fall through the logic into mlx5_ib_reg_user_mr() to allocate a completely new MR.
Since implicit children were also touching the mr->pd, this removes another case where the access was racy.
--- drivers/infiniband/hw/mlx5/mr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/infiniband/hw/mlx5/mr.c +15 -0
@@ -1188,6 +1188,21 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,if (!(flags &IB_MR_REREG_PD )) new_pd = ib_mr->pd; +if (mr->is_odp_implicit && !(flags &IB_MR_REREG_TRANS )) { +if (!(new_access_flags &IB_ACCESS_ON_DEMAND )) +return ERR_PTR (-EOPNOTSUPP ); + +/* +* Due to all the child mkeys we cannot actually change an +* implicit MR in place. If the user did not specify a new +* translation then force the fixed implicit MR values. +*/ + start =0 ; + iova =0 ; + length =U64_MAX ; + flags |=IB_MR_REREG_TRANS ; + } +if (!(flags &IB_MR_REREG_TRANS )) {struct ib_umem *umem;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/2077 RDMA/nldev: Fix locking when accessing mr->pd
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 50d5c02ab8e62325548bd3a6e6b758a9dcd6e7c3 ]
Sashiko points out that, due to rereg_mr, the PD is actually variable and all the touches in nldev are racy.
Use mr->device instead of mr->pd->device.
Getting the PD restrack ID is more tricky. To avoid disturbing all the happy paths, add an rdma_restrack_sync() operation which is sort of like flush_workqueue() or synchronize_irq(): after it returns, all the old nldev touches to the mr are gone and everything sees the new PD. This makes it safe to reach into the PD pointer.
--- drivers/infiniband/core/nldev.c | 15 +++++---- drivers/infiniband/core/restrack.c | 49 ++++++++++++++++++++++++++++ drivers/infiniband/core/restrack.h | 1 + drivers/infiniband/core/uverbs_cmd.c | 10 ++++-- include/rdma/ib_verbs.h | 5 +++ 5 files changed, 72 insertions(+), 8 deletions(-)
drivers/infiniband/core/nldev.c +9 -6
@@ -695,7 +695,7 @@ static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin, struct rdma_restrack_entry *res, uint32_t port) { struct ib_mr *mr = container_of(res, struct ib_mr, res); -struct ib_device *dev = mr->pd->device; +struct ib_device *dev = mr->device;if (has_cap_net_admin) {if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_RKEY , mr->rkey))
@@ -711,9 +711,12 @@ static int fill_res_mr_entry(struct sk_buff *msg, bool has_cap_net_admin,if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_MRN , res->id))return -EMSGSIZE ; -if (!rdma_is_kernel_res (res) && -nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_PDN , mr->pd->res.id)) -return -EMSGSIZE ; +if (!rdma_is_kernel_res (res)) { +struct ib_pd *pd =READ_ONCE (mr->pd); + +if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_PDN , pd->res.id)) +return -EMSGSIZE ; + }if (fill_res_name_pid (msg, res))return -EMSGSIZE ;
@@ -727,7 +730,7 @@ static int fill_res_mr_raw_entry(struct sk_buff *msg, bool has_cap_net_admin, struct rdma_restrack_entry *res, uint32_t port) { struct ib_mr *mr = container_of(res, struct ib_mr, res); -struct ib_device *dev = mr->pd->device; +struct ib_device *dev = mr->device;if (!dev->ops.fill_res_mr_entry_raw)return -EINVAL ;
@@ -1017,7 +1020,7 @@ static int fill_stat_mr_entry(struct sk_buff *msg, bool has_cap_net_admin, struct rdma_restrack_entry *res, uint32_t port) { struct ib_mr *mr = container_of(res, struct ib_mr, res); -struct ib_device *dev = mr->pd->device; +struct ib_device *dev = mr->device;if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_MRN , res->id)) goto err;
drivers/infiniband/core/restrack.c +49 -0
61 lines not on this page · raw message
drivers/infiniband/core/restrack.h +1 -0
@@ -27,6 +27,7 @@ int rdma_restrack_init(struct ib_device *dev);void rdma_restrack_clean (struct ib_device *dev);void rdma_restrack_add (struct rdma_restrack_entry *res);void rdma_restrack_del (struct rdma_restrack_entry *res); +void rdma_restrack_sync (struct rdma_restrack_entry *res);void rdma_restrack_new (struct rdma_restrack_entry *res,enum rdma_restrack_type type); void rdma_restrack_set_name(struct rdma_restrack_entry *res,
drivers/infiniband/core/uverbs_cmd.c +8 -2
@@ -47,6 +47,7 @@#include "uverbs.h" #include "core_priv.h" +#include "restrack.h" /* * Copy a response to userspace. If the provided 'resp' is larger than the
@@ -819,6 +820,10 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) ret =PTR_ERR (new_pd); goto put_uobjs; } +if (new_pd == orig_pd) { +uobj_put_obj_read (new_pd); + cmd.flags &= ~IB_MR_REREG_PD ; + } }else { new_pd = mr->pd; }
@@ -866,9 +871,10 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) mr = new_mr; }else {if (cmd.flags &IB_MR_REREG_PD ) { -atomic_dec (&orig_pd->usecnt); - mr->pd = new_pd;atomic_inc (&new_pd->usecnt); +WRITE_ONCE (mr->pd, new_pd); +rdma_restrack_sync (&mr->res); +atomic_dec (&orig_pd->usecnt); }if (cmd.flags &IB_MR_REREG_TRANS ) { mr->iova = cmd.hca_va;
include/rdma/ib_verbs.h +5 -0
@@ -1977,6 +1977,11 @@ struct ib_dmah {struct ib_mr {struct ib_device *device; +/* +* Due to IB_MR_REREG_PD pd is not a fixed pointer and can change. For a +* user MR, this value should only be read from a system call that holds +* the uobject lock, or the driver should disable in-place REREG_PD. +*/ struct ib_pd *pd;u32 lkey;u32 rkey;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/2077 IB/mlx5: Remove unused mkc bits in mlx5r_umr_update_mr_page_shift()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 4910483bd7ee2b40d0cc8ebd537fa33c95562029 ]
The HW only processes mkc fields selected by mkey_mask. pd, qpn and mkey_7_0 are never selected so they can be left as zero.
This removes a racy read of mr->pd.
--- drivers/infiniband/hw/mlx5/umr.c | 16 +++------------- drivers/infiniband/hw/mlx5/umr.h | 3 +-- 2 files changed, 4 insertions(+), 15 deletions(-)
drivers/infiniband/hw/mlx5/umr.c +3 -13
@@ -937,8 +937,7 @@ int mlx5r_umr_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,* pinned and the HW can switch from 4K to huge-page alignment). */ int mlx5r_umr_update_mr_page_shift (struct mlx5_ib_mr *mr, -unsigned int page_shift, -bool dd) +unsigned int page_shift) {struct mlx5_ib_dev *dev =mr_to_mdev (mr);struct mlx5r_umr_wqe wqe = {};
@@ -953,16 +952,8 @@ int mlx5r_umr_update_mr_page_shift(struct mlx5_ib_mr *mr,/* Fill mkey segment with the new page size, keep the rest unchanged */ MLX5_SET (mkc, &wqe.mkey_seg, log_page_size, page_shift); -if (dd) -MLX5_SET (mkc, &wqe.mkey_seg, pd, dev->ddr.pdn); -else -MLX5_SET (mkc, &wqe.mkey_seg, pd,to_mpd (mr->ibmr.pd)->pdn); -MLX5_SET64 (mkc, &wqe.mkey_seg, start_addr, mr->ibmr.iova);MLX5_SET64 (mkc, &wqe.mkey_seg, len, mr->ibmr.length); -MLX5_SET (mkc, &wqe.mkey_seg, qpn,0xffffff ); -MLX5_SET (mkc, &wqe.mkey_seg, mkey_7_0, -mlx5_mkey_variant (mr->mmkey.key)); err =mlx5r_umr_post_send_wait (dev, mr->mmkey.key, &wqe, false);if (!err)
@@ -1049,7 +1040,7 @@ static int _mlx5r_umr_zap_mkey(struct mlx5_ib_mr *mr,* non-present. */ if (*nblocks) { - err =mlx5r_umr_update_mr_page_shift (mr, max_page_shift, dd); + err =mlx5r_umr_update_mr_page_shift (mr, max_page_shift);if (err) { mr->page_shift = old_page_shift;return err;
@@ -1114,8 +1105,7 @@ int mlx5r_umr_dmabuf_update_pgsz(struct mlx5_ib_mr *mr, u32 xlt_flags, goto err; } - err =mlx5r_umr_update_mr_page_shift (mr, mr->page_shift, - mr->data_direct); + err =mlx5r_umr_update_mr_page_shift (mr, mr->page_shift);if (err) goto err; err = _mlx5r_dmabuf_umr_update_pas(mr, xlt_flags, 0, zapped_blocks,
drivers/infiniband/hw/mlx5/umr.h +1 -2
@@ -106,8 +106,7 @@ int mlx5r_umr_update_mr_pas(struct mlx5_ib_mr *mr, unsigned int flags);int mlx5r_umr_update_xlt (struct mlx5_ib_mr *mr,u64 idx,int npages,int page_shift,int flags);int mlx5r_umr_update_mr_page_shift (struct mlx5_ib_mr *mr, -unsigned int page_shift, -bool dd); +unsigned int page_shift);int mlx5r_umr_dmabuf_update_pgsz (struct mlx5_ib_mr *mr,u32 xlt_flags,unsigned int page_shift);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/2077 IB/mlx5: Pull the pdn out of the depths of the umr machinery
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit f387a9f06ea4f05e607a91b161963c0b19436652 ]
Instead of getting the pdn deep inside the umr code, pass it in from the top. to_mpd(mr->ibmr.pd)->pdn is not safe due to the rereg races, so all the call sites need some revision to obtain the pdn in a safe way.
Mark them with mlx5_mr_pdn(); following patches will go through and remove these.
Cases where the XLT flags are known and do not require the PDN can pass 0, such as for mlx5_ib_dmabuf_invalidate_cb().
Also extract the DMABUF data_direct special case from inside the UMR code and into the only place that needs it, pagefault_dmabuf_mr(). The actual mr was created directly without using the UMR flow. Ultimately this will be moved into mlx5_ib_init_dmabuf_mr().
Stable-dep-of: 8e0a02a989c1 ("IB/mlx5: Don't mangle the mr->pd inside the rereg callback")
--- drivers/infiniband/hw/mlx5/mlx5_ib.h | 9 ++++ drivers/infiniband/hw/mlx5/mr.c | 8 +-- drivers/infiniband/hw/mlx5/odp.c | 12 +++-- drivers/infiniband/hw/mlx5/umr.c | 75 ++++++++++++++-------------- drivers/infiniband/hw/mlx5/umr.h | 6 +-- 5 files changed, 64 insertions(+), 46 deletions(-)
drivers/infiniband/hw/mlx5/mlx5_ib.h +9 -0
@@ -331,6 +331,10 @@ struct mlx5_ib_flow_db {#define MLX5_IB_QPT_DCT IB_QPT_RESERVED4#define MLX5_IB_WR_UMR IB_WR_RESERVED1 +/* +* A valid pdn is required when flags include MLX5_IB_UPD_XLT_ENABLE, +* MLX5_IB_UPD_XLT_PD or MLX5_IB_UPD_XLT_ACCESS. +*/ #define MLX5_IB_UPD_XLT_ZAP BIT(0)#define MLX5_IB_UPD_XLT_ENABLE BIT(1)#define MLX5_IB_UPD_XLT_ATOMIC BIT(2)
@@ -1209,6 +1213,11 @@ static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd) return container_of(ibpd, struct mlx5_ib_pd, ibpd); } +static inline u32 mlx5_mr_pdn (struct mlx5_ib_mr *mr) +{ +return to_mpd (mr->ibmr.pd)->pdn; +} +static inline struct mlx5_ib_srq *to_msrq (struct ib_srq *ibsrq) { return container_of(ibsrq, struct mlx5_ib_srq, ibsrq);
drivers/infiniband/hw/mlx5/mr.c +5 -3
@@ -781,7 +781,8 @@ static struct ib_mr *create_real_mr(struct ib_pd *pd, struct ib_umem *umem,* configured properly but left disabled. It is safe to go ahead * and configure it again via UMR while enabling it. */ - err =mlx5r_umr_update_mr_pas (mr,MLX5_IB_UPD_XLT_ENABLE ); + err =mlx5r_umr_update_mr_pas (mr,MLX5_IB_UPD_XLT_ENABLE , +to_mpd (pd)->pdn);if (err) {mlx5_ib_dereg_mr (&mr->ibmr,NULL );return ERR_PTR (err);
@@ -890,7 +891,8 @@ static void mlx5_ib_dmabuf_invalidate_cb(struct dma_buf_attachment *attach)if (!umem_dmabuf->sgt || !mr)return ; -mlx5r_umr_update_mr_pas (mr,MLX5_IB_UPD_XLT_ZAP ); +/* MLX5_IB_UPD_XLT_ZAP does not change the pdn */ +mlx5r_umr_update_mr_pas (mr,MLX5_IB_UPD_XLT_ZAP ,0 );ib_umem_dmabuf_unmap_pages (umem_dmabuf); }
@@ -1141,7 +1143,7 @@ static int umr_rereg_pas(struct mlx5_ib_mr *mr, struct ib_pd *pd, mr->ibmr.length = new_umem->length; mr->page_shift =order_base_2 (page_size); mr->umem = new_umem; - err =mlx5r_umr_update_mr_pas (mr, upd_flags); + err =mlx5r_umr_update_mr_pas (mr, upd_flags,mlx5_mr_pdn (mr));if (err) {/* * The MR is revoked at this point so there is no issue to free
drivers/infiniband/hw/mlx5/odp.c +9 -3
@@ -833,12 +833,14 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt, u32 *bytes_mapped, u32 flags) {struct ib_umem_dmabuf *umem_dmabuf =to_ib_umem_dmabuf (mr->umem); +struct mlx5_ib_dev *dev =mr_to_mdev (mr);int access_mode = mr->data_direct ?MLX5_MKC_ACCESS_MODE_KSM :MLX5_MKC_ACCESS_MODE_MTT ;unsigned int old_page_shift = mr->page_shift;unsigned int page_shift;unsigned long page_size;u32 xlt_flags =0 ; +u32 pdn =0 ;int err;if (flags &MLX5_PF_FLAGS_ENABLE )
@@ -857,8 +859,12 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt, err = -EINVAL ; }else { page_shift =order_base_2 (page_size); +if (mr->data_direct) + pdn = dev->ddr.pdn; +else + pdn =mlx5_mr_pdn (mr);if (page_shift != mr->page_shift && mr->dmabuf_faulted) { - err =mlx5r_umr_dmabuf_update_pgsz (mr, xlt_flags, + err =mlx5r_umr_dmabuf_update_pgsz (mr, xlt_flags, pdn, page_shift); }else { mr->page_shift = page_shift;
@@ -866,8 +872,8 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt, err =mlx5r_umr_update_data_direct_ksm_pas ( mr, xlt_flags); else - err =mlx5r_umr_update_mr_pas (mr, - xlt_flags); + err =mlx5r_umr_update_mr_pas (mr, xlt_flags, + pdn); } }dma_resv_unlock (umem_dmabuf->attach->dmabuf->resv);
drivers/infiniband/hw/mlx5/umr.c +38 -37
192 lines not on this page · raw message
drivers/infiniband/hw/mlx5/umr.h +3 -3
@@ -101,13 +101,13 @@ int mlx5r_umr_update_data_direct_ksm_pas_range(struct mlx5_ib_mr *mr, size_t nblocks);int mlx5r_umr_update_data_direct_ksm_pas (struct mlx5_ib_mr *mr,unsigned int flags);int mlx5r_umr_update_mr_pas_range (struct mlx5_ib_mr *mr,unsigned int flags, -size_t start_block,size_t nblocks); -int mlx5r_umr_update_mr_pas (struct mlx5_ib_mr *mr,unsigned int flags); +u32 pdn,size_t start_block,size_t nblocks); +int mlx5r_umr_update_mr_pas (struct mlx5_ib_mr *mr,unsigned int flags,u32 pdn);int mlx5r_umr_update_xlt (struct mlx5_ib_mr *mr,u64 idx,int npages,int page_shift,int flags);int mlx5r_umr_update_mr_page_shift (struct mlx5_ib_mr *mr,unsigned int page_shift); -int mlx5r_umr_dmabuf_update_pgsz (struct mlx5_ib_mr *mr,u32 xlt_flags, +int mlx5r_umr_dmabuf_update_pgsz (struct mlx5_ib_mr *mr,u32 xlt_flags,u32 pdn,unsigned int page_shift);#endif /* _MLX5_IB_UMR_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/2077 IB/mlx5: Dont mangle the mr->pd inside the rereg callback
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 8e0a02a989c156ce17f06a645d5f075277e06b95 ]
The rereg protocol expects the core code to change mr->pd and synchronize that change with the atomics and syncs. The driver should not touch it.
mlx5 needed to update it in umr_rereg_pas() because mlx5r_umr_update_mr_pas() required the updated mr->pd to build the UMR.
Simply switch mlx5r_umr_update_mr_pas() to use the pdn directly from the new pd and remove the mr->pd update.
--- drivers/infiniband/hw/mlx5/mr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +2 -4
@@ -1130,10 +1130,8 @@ static int umr_rereg_pas(struct mlx5_ib_mr *mr, struct ib_pd *pd,if (err)return err; -if (flags &IB_MR_REREG_PD ) { - mr->ibmr.pd = pd; +if (flags &IB_MR_REREG_PD ) upd_flags |=MLX5_IB_UPD_XLT_PD ; - }if (flags &IB_MR_REREG_ACCESS ) { mr->access_flags = access_flags; upd_flags |=MLX5_IB_UPD_XLT_ACCESS ;
@@ -1143,7 +1141,7 @@ static int umr_rereg_pas(struct mlx5_ib_mr *mr, struct ib_pd *pd, mr->ibmr.length = new_umem->length; mr->page_shift =order_base_2 (page_size); mr->umem = new_umem; - err =mlx5r_umr_update_mr_pas (mr, upd_flags,mlx5_mr_pdn (mr)); + err =mlx5r_umr_update_mr_pas (mr, upd_flags,to_mpd (pd)->pdn);if (err) {/* * The MR is revoked at this point so there is no issue to free
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/2077 spi: ep93xx: fix double-free of zeropage on DMA setup failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 7886054b06f762f62054957a8f6de0f14e6b7541 ]
If DMA setup fails after allocating the zeropage, the error path frees the page but leaves espi->zeropage dangling. A subsequent call to ep93xx_spi_release_dma() sees the non-NULL pointer and frees the page again.
Clear the pointer after freeing in the error path of ep93xx_spi_setup_dma().
--- drivers/spi/spi-ep93xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-ep93xx.c +1 -0
@@ -600,6 +600,7 @@ static int ep93xx_spi_setup_dma(struct device *dev, struct ep93xx_spi *espi) espi->dma_rx =NULL ; fail_free_page:free_page ((unsigned long )espi->zeropage); + espi->zeropage =NULL ;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/2077 ASoC: amd: acp-sdw-legacy: Bound DAI link iteration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Ma <[email protected]>
[ Upstream commit d49ecdf327cc91062d2f80996a163cf65fda1e60 ]
create_sdw_dailinks() walks soc_dais until it finds an entry with initialised cleared, but soc_dais is allocated with exactly num_ends entries. If all entries are initialised, the loop reads past the end of the array.
This was reported by KASAN:
BUG: KASAN: slab-out-of-bounds in mc_probe+0x26b3/0x2774 [snd_acp_sdw_legacy_mach] Read of size 1
Pass the allocated entry count to create_sdw_dailinks() and stop before reading past the array.
--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +4 -3
@@ -303,13 +303,14 @@ static int create_sdw_dailink(struct snd_soc_card *card,static int create_sdw_dailinks (struct snd_soc_card *card,struct snd_soc_dai_link **dai_links,int *be_id, -struct asoc_sdw_dailink *soc_dais, +struct asoc_sdw_dailink *soc_dais,int num_dais,struct snd_soc_codec_conf **codec_conf) {struct device *dev = card->dev;struct asoc_sdw_mc_private *ctx =snd_soc_card_get_drvdata (card);struct amd_mc_ctx *amd_ctx = (struct amd_mc_ctx *)ctx->private;struct snd_soc_dai_link_component *sdw_platform_component; +int i;int ret; sdw_platform_component = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
@@ -329,7 +330,7 @@ static int create_sdw_dailinks(struct snd_soc_card *card, }/* generate DAI links by each sdw link */ -while (soc_dais->initialised) { +for (i =0 ; i < num_dais && soc_dais->initialised; i++) {int current_be_id =0 ; ret = create_sdw_dailink(card, soc_dais, dai_links,
@@ -463,7 +464,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)/* SDW */ if (sdw_be_num) { ret =create_sdw_dailinks (card, &dai_links, &be_id, - soc_dais, &codec_conf); + soc_dais, num_ends, &codec_conf);if (ret)return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/2077 ASoC: amd: acp-sdw-sof: Bound DAI link iteration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Ma <[email protected]>
[ Upstream commit 4d992e63f52d58f52b724606c60ae7b37a1c582f ]
create_sdw_dailinks() walks sof_dais until it finds an entry with initialised cleared, but sof_dais is allocated with exactly num_ends entries. If all entries are initialised, the loop reads past the end of the array.
Pass the allocated entry count to create_sdw_dailinks() and stop before reading past the array.
--- sound/soc/amd/acp/acp-sdw-sof-mach.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/amd/acp/acp-sdw-sof-mach.c +4 -3
@@ -220,13 +220,14 @@ static int create_sdw_dailink(struct snd_soc_card *card,static int create_sdw_dailinks (struct snd_soc_card *card,struct snd_soc_dai_link **dai_links,int *be_id, -struct asoc_sdw_dailink *sof_dais, +struct asoc_sdw_dailink *sof_dais,int num_dais,struct snd_soc_codec_conf **codec_conf) { +int i;int ret;/* generate DAI links by each sdw link */ -while (sof_dais->initialised) { +for (i =0 ; i < num_dais && sof_dais->initialised; i++) {int current_be_id =0 ; ret = create_sdw_dailink(card, sof_dais, dai_links,
@@ -334,7 +335,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)/* SDW */ if (sdw_be_num) { ret =create_sdw_dailinks (card, &dai_links, &be_id, - sof_dais, &codec_conf); + sof_dais, num_ends, &codec_conf);if (ret)return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/2077 firmware_loader: Fix recursive lock in device_cache_fw_images()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Vyukov <[email protected]>
[ Upstream commit d3ec78f8f8d48a04a9fac38d47275c34645e5103 ]
A recursive locking deadlock can occur in the firmware loader's power management notification handler.
During system suspend or hibernation preparation, fw_pm_notify() calls device_cache_fw_images(). This function acquires fw_lock to set the firmware cache state to FW_LOADER_START_CACHE and then iterates over all devices using dpm_for_each_dev() while still holding the lock.
For each device, dev_cache_fw_image() schedules asynchronous work to cache the firmware. If memory allocation for the async work entry fails (e.g., in out-of-memory conditions), async_schedule_node_domain() falls back to executing the work function synchronously in the current thread.
The synchronous execution path (__async_dev_cache_fw_image() -> cache_firmware() -> request_firmware() -> assign_fw()) attempts to acquire fw_lock again. Since the current thread already holds fw_lock, this results in a recursive locking deadlock.
Fix this by releasing fw_lock immediately after updating the cache state and before calling dpm_for_each_dev(). The lock is only needed to protect the state update. Concurrent firmware requests will correctly see the FW_LOADER_START_CACHE state and use the piggyback mechanism, which is independently protected by its own fwc->name_lock.
--- drivers/base/firmware_loader/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/firmware_loader/main.c +2 -1
@@ -1503,9 +1503,10 @@ static void device_cache_fw_images(void)mutex_lock (&fw_lock); fwc->state =FW_LOADER_START_CACHE ; -dpm_for_each_dev (NULL , dev_cache_fw_image);mutex_unlock (&fw_lock); +dpm_for_each_dev (NULL , dev_cache_fw_image); +/* wait for completion of caching firmware for all devices */ async_synchronize_full_domain (&fw_cache_domain);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/2077 configfs: fix lockless traversals of ->s_children
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 9b9e8bb81c41fd27e7b57a1c936fde140548535f ]
Having the parent directory locked protects entries from removal by another thread, but it does *not* protect cursors from being moved around by lseek() - or freed, for that matter.
--- fs/configfs/dir.c | 54 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 13 deletions(-)
fs/configfs/dir.c +41 -13
@@ -235,15 +235,16 @@ static int configfs_dirent_exists(struct dentry *dentry)const unsigned char *new = dentry->d_name.name;struct configfs_dirent *sd; +spin_lock (&configfs_dirent_lock);list_for_each_entry (sd, &parent_sd->s_children, s_sibling) {if (sd->s_element) { -const unsigned char *existing =configfs_get_name (sd); -if (strcmp (existing, new)) -continue ; -else +if (strcmp (configfs_get_name (sd), new) ==0 ) { +spin_unlock (&configfs_dirent_lock);return -EEXIST ; + } } } +spin_unlock (&configfs_dirent_lock);return 0 ; }
@@ -575,11 +576,28 @@ static void configfs_detach_rollback(struct dentry *dentry)configfs_detach_rollback (sd->s_dentry); } +/* +* Find the next non-cursor. configfs_dirent_lock held by caller. +*/ +static struct configfs_dirent *next_dirent (struct configfs_dirent *parent, +struct configfs_dirent *last) +{ +struct configfs_dirent *s; + + s =list_prepare_entry (last, &parent->s_children, s_sibling); + +list_for_each_entry_continue (s, &parent->s_children, s_sibling) { +if (s->s_element) +return s; + } +return NULL ; +} +static void detach_attrs (struct config_item * item) {struct dentry * dentry =dget (item->ci_dentry); -struct configfs_dirent * parent_sd; -struct configfs_dirent * sd, * tmp; +struct configfs_dirent *parent_sd; +struct configfs_dirent *sd, *next;if (!dentry)return ;
@@ -588,15 +606,19 @@ static void detach_attrs(struct config_item * item) dentry->d_name.name); parent_sd = dentry->d_fsdata; -list_for_each_entry_safe (sd, tmp, &parent_sd->s_children, s_sibling) { -if (!sd->s_element || !(sd->s_type &CONFIGFS_NOT_PINNED )) + +spin_lock (&configfs_dirent_lock); +for (sd =next_dirent (parent_sd,NULL ); sd; sd = next) { + next =next_dirent (parent_sd, sd); +if (!(sd->s_type &CONFIGFS_NOT_PINNED ))continue ; -spin_lock (&configfs_dirent_lock);list_del_init (&sd->s_sibling);spin_unlock (&configfs_dirent_lock);configfs_drop_dentry (sd, dentry);configfs_put (sd); +spin_lock (&configfs_dirent_lock); } +spin_unlock (&configfs_dirent_lock);/** * Drop reference from dget() on entrance.
@@ -655,18 +677,20 @@ static void detach_groups(struct config_group *group)struct dentry * dentry =dget (group->cg_item.ci_dentry);struct dentry *child;struct configfs_dirent *parent_sd; -struct configfs_dirent *sd, *tmp; +struct configfs_dirent *sd, *next;if (!dentry)return ; parent_sd = dentry->d_fsdata; -list_for_each_entry_safe (sd, tmp, &parent_sd->s_children, s_sibling) { -if (!sd->s_element || - !(sd->s_type &CONFIGFS_USET_DEFAULT )) +spin_lock (&configfs_dirent_lock); +for (sd =next_dirent (parent_sd,NULL ); sd; sd = next) { + next =next_dirent (parent_sd, sd); +if (!(sd->s_type &CONFIGFS_USET_DEFAULT ))continue ; child = sd->s_dentry; +spin_unlock (&configfs_dirent_lock);inode_lock (d_inode (child));
@@ -678,7 +702,9 @@ static void detach_groups(struct config_group *group)d_delete (child);dput (child); +spin_lock (&configfs_dirent_lock); } +spin_unlock (&configfs_dirent_lock);/** * Drop reference from dget() on entrance.
@@ -1130,6 +1156,7 @@ configfs_find_subsys_dentry(struct configfs_dirent *root_sd,struct configfs_dirent *p;struct configfs_dirent *ret =NULL ; +spin_lock (&configfs_dirent_lock);list_for_each_entry (p, &root_sd->s_children, s_sibling) {if (p->s_type &CONFIGFS_DIR && p->s_element == subsys_item) {
@@ -1137,6 +1164,7 @@ configfs_find_subsys_dentry(struct configfs_dirent *root_sd,break ; } } +spin_unlock (&configfs_dirent_lock);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/2077 watchdog: unregister PM notifier on watchdog unregister
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit a298c7302ee9584a7a1ac1e8acbede8d98ab51a4 ]
watchdog_register_device() registers wdd->pm_nb when WDOG_NO_PING_ON_SUSPEND is set, but watchdog_unregister_device() does not remove it. This leaves an embedded notifier block on the PM notifier chain after the watchdog device has been unregistered.
A later suspend/resume notification can then call watchdog_pm_notifier() with a stale watchdog_device pointer, or at minimum after wdd->wd_data has been cleared by watchdog_dev_unregister().
Unregister the PM notifier before tearing down the watchdog device.
--- drivers/watchdog/watchdog_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/watchdog/watchdog_core.c +3 -0
@@ -391,6 +391,9 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status))unregister_reboot_notifier (&wdd->reboot_nb); +if (test_bit (WDOG_NO_PING_ON_SUSPEND , &wdd->status)) +unregister_pm_notifier (&wdd->pm_nb); +watchdog_dev_unregister (wdd);ida_free (&watchdog_ida, wdd->id); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/2077 pinctrl: qcom: Fix resolving register base address from device node
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sneh Mankad <[email protected]>
[ Upstream commit 4e31ab47997540d0ff4c9de801741bed03c1ab3f ]
Commit 56ffb63749f4 ("pinctrl: qcom: add multi TLMM region option parameter") added reg-names property based register reading. However multiple platforms are not using the reg-names as they have only single TLMM register region.
Commit tried to handle this using the default_region module parameter, however this condition is unreachable as the error return precedes it by just checking if reg-names property exists or not, making it impossible to use tlmm-test for the SoCs (x1e80100) which don't have reg-names property in TLMM device.
Fix this by moving the default_region check at the start of the tlmm_reg_base().
--- drivers/pinctrl/qcom/tlmm-test.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/tlmm-test.c +9 -10
@@ -581,6 +581,9 @@ static int tlmm_reg_base(struct device_node *tlmm, struct resource *res)int ret;int i; +if (!strcmp (tlmm_reg_name,"default_region" )) +return of_address_to_resource (tlmm,0 , res); + count =of_property_count_strings (tlmm,"reg-names" );if (count <=0 ) {pr_err ("failed to find tlmm reg name\n" );
@@ -597,18 +600,14 @@ static int tlmm_reg_base(struct device_node *tlmm, struct resource *res)return -EINVAL ; } -if (!strcmp (tlmm_reg_name,"default_region" )) { - ret =of_address_to_resource (tlmm,0 , res); - }else { -for (i =0 ; i < count; i++) { -if (!strcmp (reg_names[i], tlmm_reg_name)) { - ret =of_address_to_resource (tlmm, i, res); -break ; - } +for (i =0 ; i < count; i++) { +if (!strcmp (reg_names[i], tlmm_reg_name)) { + ret =of_address_to_resource (tlmm, i, res); +break ; } -if (i == count) - ret = -EINVAL ; } +if (i == count) + ret = -EINVAL ;kfree (reg_names);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/2077 scsi: target: Fix hexadecimal CHAP_I handling
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Disseldorp <[email protected]>
[ Upstream commit 7e161211f1dd5288b4ea802b30e70ef919ebc3da ]
A mutual CHAP handshake requires target processing of an initiator-sent CHAP_I identifier. The RFC 3720 specification states:
11.1.4. Challenge Handshake Authentication Protocol (CHAP)
...
CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
...
Where N, (A,A1,A2), I, C, and R are (correspondingly) the Name, Algorithm, Identifier, Challenge, and Response as defined in [RFC1994], N is a text string, A,A1,A2, and I are numbers
CHAP_I parsing currently calls extract_param(), which returns the @identifier string (stripped of any 0b/0B or 0x/0X prefix) and a @type which indicates DECIMAL, HEX, or BASE64 encoding (based on any stripped prefix).
Any HEX encoded CHAP_I string is further processed via:
ret = kstrtoul(&identifier[2], 0, &id);
This is incorrect for two reasons:
* The @identifier string has already been stripped of the 0x/0X prefix, so skipping the first two bytes omits part of the number.
* The kstrtoul() call specifies a base of 0, which will see &identifier[2] parsed as a decimal, unless a '0x' or (octal) '0' is erroneously present at that offset.
Fix this by passing the (zero-offset) identifier string to kstrtoul() along with a base=16 parameter. Also add an explicit error handler for BASE64 encoding.
Hex-encoded CHAP_I handling can be testing using the libiscsi EncodedI test linked below.
--- drivers/target/iscsi/iscsi_target_auth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/target/iscsi/iscsi_target_auth.c +4 -2
@@ -438,9 +438,11 @@ static int chap_server_compute_hash( }if (type ==HEX ) - ret =kstrtoul (&identifier[2 ],0 , &id); + ret =kstrtoul (identifier,16 , &id); +else if (type ==DECIMAL ) + ret =kstrtoul (identifier,10 , &id);else - ret =kstrtoul (identifier,0 , &id); + ret = -EINVAL ;if (ret <0 ) {pr_err ("kstrtoul() failed for CHAP identifier: %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/2077 scsi: ufs: core: Handle PM commands timeout before SCSI EH
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjie Fang <[email protected]>
[ Upstream commit 01d5e237b33931b970dd190dd6a19c5ef32c105d ]
A PM START STOP sent from the UFS well-known LU resume path can race with SCSI EH:
The "wl resume" task flow is:
__ufshcd_wl_resume()
ufshcd_set_dev_pwr_mode(UFS_ACTIVE_PWR_MODE)
ufshcd_execute_start_stop()
scsi_execute_cmd()
blk_execute_rq <-- wait
scsi_check_passthrough() <-- may retry START STOP
If the first START STOP time out, SCSI EH may already recover the link and reset the device before scsi_execute_cmd() returns:
scsi_timeout()
scsi_eh_scmd_add()
scsi_error_handler()
scsi_unjam_host()
scsi_eh_ready_devs()
scsi_eh_host_reset()
ufshcd_eh_host_reset_handler()
if (hba->pm_op_in_progress)
ufshcd_link_recovery()
ufshcd_device_reset()
ufshcd_host_reset_and_restore()
...
scsi_eh_flush_done_q() <-- wakeup "wl resume" task
... <-- host still in SHOST_RECOVERY
scsi_restart_operations()A later passthrough retry can then run while the host is still in SHOST_RECOVERY and hit the SCMD_FAIL_IF_RECOVERING path:
scsi_queue_rq()
if (scsi_host_in_recovery(shost) &&
cmd->flags & SCMD_FAIL_IF_RECOVERING)
return BLK_STS_OFFLINEThat retry completes with DID_ERROR or DID_NO_CONNECT even though EH may already have restored the device to an operational ACTIVE state.
Handle these PM timeouts directly from ufshcd_eh_timed_out() instead. After ufshcd_link_recovery(), complete the timed-out command immediately if it has not been completed already.
For regular SCSI commands, complete them with DID_REQUEUE to match the existing MCQ force-completion semantics and allow scsi_execute_cmd() to retry if needed. For reserved internal device-management commands, finish the request with DID_TIME_OUT without calling ufshcd_release_scsi_cmd() since those commands use different resource lifetime rules.
The system_suspending flag is no longer needed because PM command timeout handling now uses pm_op_in_progress.
--- drivers/ufs/core/ufshcd.c | 34 +++++++++++++++++++++++++++------- include/ufs/ufshcd.h | 3 --- 2 files changed, 27 insertions(+), 10 deletions(-)
drivers/ufs/core/ufshcd.c +27 -7
@@ -9466,22 +9466,44 @@ static enum scsi_timeout_action ufshcd_eh_timed_out(struct scsi_cmnd *scmd) {struct ufs_hba *hba =shost_priv (scmd->device->host); -if (!hba->system_suspending) { +if (!hba->pm_op_in_progress) {/* Activate the error handler in the SCSI core. */ return SCSI_EH_NOT_HANDLED ; }/* -* If we get here we know that no TMFs are outstanding and also that -* the only pending command is a START STOP UNIT command. Handle the -* timeout of that command directly to prevent a deadlock between +* Handle the timeout directly to prevent a deadlock between * ufshcd_set_dev_pwr_mode() and ufshcd_err_handler(). */ ufshcd_link_recovery (hba);dev_info (hba->dev,"%s() finished; outstanding_tasks = %#lx.\n" , __func__, hba->outstanding_tasks); -return scsi_host_busy (hba->host) ?SCSI_EH_RESET_TIMER :SCSI_EH_DONE ; +/* +* ufshcd_link_recovery() may already have completed @scmd, e.g. via +* the existing MCQ force-completion path. +*/ +if (!test_bit (SCMD_STATE_COMPLETE , &scmd->state)) { +if (!hba->mcq_enabled) { +unsigned long flags; +struct request *rq =scsi_cmd_to_rq (scmd); + +spin_lock_irqsave (&hba->outstanding_lock, flags); +__clear_bit (rq->tag, &hba->outstanding_reqs); +spin_unlock_irqrestore (&hba->outstanding_lock, flags); + } + +if (ufshcd_is_scsi_cmd (scmd)) { +set_host_byte (scmd,DID_REQUEUE ); +ufshcd_release_scsi_cmd (hba, scmd); + }else { +set_host_byte (scmd,DID_TIME_OUT ); + } + +scsi_done (scmd); + } + +return SCSI_EH_DONE ; }static const struct attribute_group *ufshcd_driver_groups[] = {
@@ -10518,7 +10540,6 @@ static int ufshcd_wl_suspend(struct device *dev) hba =shost_priv (sdev->host);down (&hba->host_sem); - hba->system_suspending = true;if (pm_runtime_suspended (dev)) goto out;
@@ -10560,7 +10581,6 @@ static int ufshcd_wl_resume(struct device *dev) hba->curr_dev_pwr_mode, hba->uic_link_state);if (!ret) hba->is_sys_suspended = false; - hba->system_suspending = false;up (&hba->host_sem);return ret; }
include/ufs/ufshcd.h +0 -3
@@ -1020,8 +1020,6 @@ enum ufshcd_mcq_opr {* @caps: bitmask with information about UFS controller capabilities * @devfreq: frequency scaling information owned by the devfreq core * @clk_scaling: frequency scaling information owned by the UFS driver -* @system_suspending: system suspend has been started and system resume has -* not yet finished. * @is_sys_suspended: UFS device has been suspended because of system suspend * @urgent_bkops_lvl: keeps track of urgent bkops level for device * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
@@ -1197,7 +1195,6 @@ struct ufs_hba {struct devfreq *devfreq;struct ufs_clk_scaling clk_scaling; -bool system_suspending;bool is_sys_suspended;enum bkops_status urgent_bkops_lvl;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/2077 scsi: target: Remove tcm_loop target reset handling
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
[ Upstream commit 7c08d430835a90414cd962e3a9602e5b002dee3b ]
tcm_loop_target_reset is supposed to handle all the LUNs on a target but it's only doing a TMR_LUN_RESET so only that one LUN is handled. This will cause us to return early while IOs to other LUNs are still hung in lower layers. This just removes the target reset handler for the driver because LIO doesn't support target resets and for the common case where this is run from the scsi-ml error hamdler we have already tried an abort and lun reset so waiting again is most likely useless.
--- drivers/target/loopback/tcm_loop.c | 64 ------------------------------ 1 file changed, 64 deletions(-)
drivers/target/loopback/tcm_loop.c +0 -64
@@ -270,69 +270,6 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)return (ret ==TMR_FUNCTION_COMPLETE ) ?SUCCESS :FAILED ; } -static bool tcm_loop_flush_work_iter (struct request *rq,void *data) -{ -struct scsi_cmnd *sc =blk_mq_rq_to_pdu (rq); -struct tcm_loop_cmd *tl_cmd =scsi_cmd_priv (sc); -struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd; - -flush_work (&se_cmd->work); -return true; -} - -static int tcm_loop_target_reset (struct scsi_cmnd *sc) -{ -struct tcm_loop_hba *tl_hba; -struct tcm_loop_tpg *tl_tpg; -struct Scsi_Host *sh = sc->device->host; -int ret; - -/* -* Locate the tcm_loop_hba_t pointer -*/ - tl_hba = *(struct tcm_loop_hba **)shost_priv (sh); -if (!tl_hba) { -pr_err ("Unable to perform device reset without active I_T Nexus\n" ); -return FAILED ; - } -/* -* Locate the tl_tpg pointer from TargetID in sc->device->id -*/ - tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; -if (!tl_tpg) -return FAILED ; - -/* -* Issue a LUN_RESET to drain all commands that the target core -* knows about. This handles commands not yet marked CMD_T_COMPLETE. -*/ - ret =tcm_loop_issue_tmr (tl_tpg, sc->device->lun,0 ,TMR_LUN_RESET ); -if (ret !=TMR_FUNCTION_COMPLETE ) -return FAILED ; - -/* -* Flush any deferred target core completion work that may still be -* queued. Commands that already had CMD_T_COMPLETE set before the TMR -* are skipped by the TMR drain, but their async completion work -* (transport_lun_remove_cmd → percpu_ref_put, release_cmd → scsi_done) -* may still be pending in target_completion_wq. -* -* The SCSI EH will reuse in-flight scsi_cmnd structures for recovery -* commands (e.g. TUR) immediately after this handler returns SUCCESS — -* if deferred work is still pending, the memset in queuecommand would -* zero the se_cmd while the work accesses it, leaking the LUN -* percpu_ref and hanging configfs unlink forever. -* -* Use blk_mq_tagset_busy_iter() to find all started requests and -* flush_work() on each — the same pattern used by mpi3mr, scsi_debug, -* and other SCSI drivers to drain outstanding commands during reset. -*/ -blk_mq_tagset_busy_iter (&sh->tag_set, tcm_loop_flush_work_iter,NULL ); - - tl_tpg->tl_transport_status =TCM_TRANSPORT_ONLINE ; -return SUCCESS ; -} -static const struct scsi_host_template tcm_loop_driver_template = { .show_info = tcm_loop_show_info, .proc_name ="tcm_loopback" ,
@@ -341,7 +278,6 @@ static const struct scsi_host_template tcm_loop_driver_template = { .change_queue_depth = scsi_change_queue_depth, .eh_abort_handler = tcm_loop_abort_task, .eh_device_reset_handler = tcm_loop_device_reset, - .eh_target_reset_handler = tcm_loop_target_reset, .this_id = -1, .sg_tablesize = 256, .max_sectors = 0xFFFF,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/2077 pinctrl: mediatek: mt8516: Fix Schmitt trigger register offset of pins 34-39
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 1c3044cab23a056ea28da47da1cdd667a39df0b8 ]
The correct Schmitt trigger register offset for pins 34-39 is 0xA00.
--- drivers/pinctrl/mediatek/pinctrl-mt8516.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mt8516.c +1 -1
@@ -244,7 +244,7 @@ static const struct mtk_pin_ies_smt_set mt8516_smt_set[] = {MTK_PIN_IES_SMT_SPEC (24 ,25 ,0xA00 ,12 ),MTK_PIN_IES_SMT_SPEC (26 ,30 ,0xA00 ,0 ),MTK_PIN_IES_SMT_SPEC (31 ,33 ,0xA00 ,1 ), -MTK_PIN_IES_SMT_SPEC (34 ,39 ,0xA900 ,2 ), +MTK_PIN_IES_SMT_SPEC (34 ,39 ,0xA00 ,2 ),MTK_PIN_IES_SMT_SPEC (40 ,40 ,0xA10 ,11 ),MTK_PIN_IES_SMT_SPEC (41 ,43 ,0xA00 ,10 ), MTK_PIN_IES_SMT_SPEC(44, 47, 0xA00, 11),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/2077 pinctrl: mediatek: mt8167: Fix Schmitt trigger register offset of pins 34-39
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 439bc91d20188901dac698bed4921caac76d9074 ]
The correct Schmitt trigger register offset for pins 34-39 is 0xA00. Value was verified with SoC data sheet.
--- drivers/pinctrl/mediatek/pinctrl-mt8167.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mt8167.c +1 -1
@@ -244,7 +244,7 @@ static const struct mtk_pin_ies_smt_set mt8167_smt_set[] = {MTK_PIN_IES_SMT_SPEC (24 ,25 ,0xA00 ,12 ),MTK_PIN_IES_SMT_SPEC (26 ,30 ,0xA00 ,0 ),MTK_PIN_IES_SMT_SPEC (31 ,33 ,0xA00 ,1 ), -MTK_PIN_IES_SMT_SPEC (34 ,39 ,0xA900 ,2 ), +MTK_PIN_IES_SMT_SPEC (34 ,39 ,0xA00 ,2 ),MTK_PIN_IES_SMT_SPEC (40 ,40 ,0xA10 ,11 ),MTK_PIN_IES_SMT_SPEC (41 ,43 ,0xA00 ,10 ), MTK_PIN_IES_SMT_SPEC(44, 47, 0xA00, 11),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/2077 dt-bindings: pinctrl: realtek,rtd1625: Fix input voltage property name
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu-Chun Lin <[email protected]>
[ Upstream commit 388d2fe16283d68e4be8c5317809a4a218ebeace ]
The property 'input-voltage-microvolt' is a typo. Rename it to 'input-threshold-voltage-microvolt' to align with the standard pin configuration defined in pincfg-node.yaml and parsed by pinconf-generic.c.
--- .../devicetree/bindings/pinctrl/realtek,rtd1625-pinctrl.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/pinctrl/realtek,rtd1625-pinctrl.yaml +1 -1
@@ -110,7 +110,7 @@ patternProperties: input-schmitt-disable: true - input-voltage-microvolt: + input-threshold-voltage-microvolt: description: | Select the input receiver voltage domain for the pin. Valid arguments are:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/2077 pinctrl: PINCTRL_STMFX should depend on CONFIG_OF
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Tabi <[email protected]>
[ Upstream commit fd9490bdd4536a8e0911578f62164176b9000552 ]
Commit e785c990adcc ("pinctrl: Kconfig: drop unneeded dependencies on OF_GPIO") removed a redundant dependecy on CONFIG_OF_GPIO for several pinctrl drivers, but this change also removed a dependency on CONFIG_OF for some of those drivers.
Normally, this wouldn't be a problem, but PINCTRL_STMFX also selected MFD_STMFX, which does depend on CONFIG_OF. This conflict allows MFD_STMFX to be enabled even if CONFIG_OF is disabled.
Fix this by also having PINCTRL_STMFX depend on CONFIG_OF. This is okay because the pinctrl-stmfx driver actually does depend on CONFIG_OF functions.
--- drivers/pinctrl/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/Kconfig +1 -0
@@ -548,6 +548,7 @@ config PINCTRL_ST config PINCTRL_STMFX tristate "STMicroelectronics STMFX GPIO expander pinctrl driver" + depends on OF depends on I2C depends on HAS_IOMEM select GENERIC_PINCONF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/2077 iommufd: Take dma_resv lock before dma_buf_unpin() in release path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ankit Soni <[email protected]>
[ Upstream commit e745cd2c749e557c14a15ac931761c3f58c24489 ]
dma_buf_unpin() requires the caller to hold the exporter's dma_resv lock:
void dma_buf_unpin(struct dma_buf_attachment *attach)
{
...
dma_resv_assert_held(dmabuf->resv);
...
}iopt_release_pages() calls dma_buf_unpin() without taking that lock, so every iommufd_ioas_destroy()/iommufd_ioas_unmap() that releases the last reference on a DMABUF-backed iopt_pages triggers a WARN. This was hit while running tools/testing/selftests/iommu/iommufd:
WARNING: drivers/dma-buf/dma-buf.c:1137 at dma_buf_unpin+0x62/0x70 RIP: 0010:dma_buf_unpin+0x62/0x70 Call Trace: <TASK> dma_buf_unpin+0x62/0x70 iopt_release_pages+0xe4/0x190 iopt_unmap_iova_range+0x1c7/0x290 iopt_unmap_all+0x1a/0x30 iommufd_ioas_destroy+0x1d/0x50 iommufd_fops_release+0x93/0x150 __fput+0xfc/0x2c0 __x64_sys_close+0x3d/0x80 do_syscall_64+0x65/0x180 </TASK>
Take the dma_resv lock around dma_buf_unpin() in iopt_release_pages(), matching the iopt_map_dmabuf() convention. dma_buf_detach() acquires the reservation lock internally, so it must remain outside the locked region.
--- drivers/iommu/iommufd/pages.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/iommufd/pages.c +2 -0
@@ -1663,7 +1663,9 @@ void iopt_release_pages(struct kref *kref)if (iopt_is_dmabuf (pages) && pages->dmabuf.attach) {struct dma_buf *dmabuf = pages->dmabuf.attach->dmabuf; +dma_resv_lock (dmabuf->resv,NULL );dma_buf_unpin (pages->dmabuf.attach); +dma_resv_unlock (dmabuf->resv);dma_buf_detach (dmabuf, pages->dmabuf.attach);dma_buf_put (dmabuf);WARN_ON (!list_empty (&pages->dmabuf.tracker));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/2077 iommufd: Destroy the pages content after detaching from dmabuf
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit f2d70dbd3dcefa8e3c380beff9c31f5f033a4221 ]
Sashiko points out this has gotten out of order, the mutex could still be in use through the dmabuf invalidation callbacks. Don't destroy any of the pages content until the dmabuf is fully detached.
--- drivers/iommu/iommufd/pages.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iommu/iommufd/pages.c +4 -4
@@ -1656,10 +1656,6 @@ void iopt_release_pages(struct kref *kref)WARN_ON (!RB_EMPTY_ROOT (&pages->domains_itree.rb_root));WARN_ON (pages->npinned);WARN_ON (!xa_empty (&pages->pinned_pfns)); -mmdrop (pages->source_mm); -mutex_destroy (&pages->mutex); -put_task_struct (pages->source_task); -free_uid (pages->source_user);if (iopt_is_dmabuf (pages) && pages->dmabuf.attach) {struct dma_buf *dmabuf = pages->dmabuf.attach->dmabuf;
@@ -1672,6 +1668,10 @@ void iopt_release_pages(struct kref *kref) }else if (pages->type ==IOPT_ADDRESS_FILE ) {fput (pages->file); } +mmdrop (pages->source_mm); +mutex_destroy (&pages->mutex); +put_task_struct (pages->source_task); +free_uid (pages->source_user);kfree (pages); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/2077 lib/test_hmm: fix memory leak in dmirror_migrate_to_system()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Ge <[email protected]>
[ Upstream commit 8f7275c174bc5bcc8fc1bec8024e2b3e6fe17f46 ]
Move the kvcalloc() calls after the early return checks to avoid leaking src_pfns and dst_pfns when end < start or mmget_not_zero() fails.
--- lib/test_hmm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/test_hmm.c +3 -3
@@ -1111,9 +1111,6 @@ static int dmirror_migrate_to_system(struct dmirror *dmirror,unsigned long *src_pfns;unsigned long *dst_pfns; - src_pfns =kvcalloc (PTRS_PER_PTE ,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); - dst_pfns =kvcalloc (PTRS_PER_PTE ,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); - start = cmd->addr; end = start + size;if (end < start)
@@ -1123,6 +1120,9 @@ static int dmirror_migrate_to_system(struct dmirror *dmirror,if (!mmget_not_zero (mm))return -EINVAL ; + src_pfns =kvcalloc (PTRS_PER_PTE ,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); + dst_pfns =kvcalloc (PTRS_PER_PTE ,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); + cmd->cpages =0 ;mmap_read_lock (mm);for (addr = start; addr < end; addr = next) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/2077 vmalloc: fix NULL pointer dereference in is_vm_area_hugepages()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Zhu <[email protected]>
[ Upstream commit c55dd3b46c1208d6d2ea737a8aefef4aa4c70cb8 ]
find_vm_area() can return NULL if the given address is not a valid vmalloc area. Check the return value before dereferencing it to avoid a kernel crash.
--- include/linux/vmalloc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/vmalloc.h +3 -1
@@ -265,7 +265,9 @@ static inline bool is_vm_area_hugepages(const void *addr)* allocated in the vmalloc layer. */ #ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC -return find_vm_area (addr)->page_order >0 ; +struct vm_struct *area =find_vm_area (addr); + +return area && area->page_order >0 ;#else return false;#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/2077 rust: kbuild: show the right `quiet_cmd_rustc_procmacrolibrary`
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
[ Upstream commit 70a8d5ada9fabf4a34732b718f9c992195eed2ea ]
When Clippy is skipped, RUSTC should be shown in quiet instead of CLIPPY to be accurate and to avoid confusion.
Thus do so, matching what we do in quiet_cmd_rustc_library.
--- rust/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/Makefile +1 -1
@@ -517,7 +517,7 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE $(call if_changed,exports) -quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@ +quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@ cmd_rustc_procmacrolibrary = \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 574/2077 remoteproc: qcom_q6v5_wcss: drop redundant wcss_q6_bcr_reset
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandru Gagniuc <[email protected]>
[ Upstream commit 6ad61d0acd41044a949e84f96a5f8e02284d350f ]
The wcss_q6_bcr_reset used on QCS404, and wcss_q6_reset used on IPQ are the same. "BCR reset" is redundant, and likely a mistake. Use the documented "wcss_q6_reset" instead. Drop ".wcss_q6_reset_required" from the descriptor, since all targets now need it.
This changes the bindings expectations, however, it actually fixes the driver to consume the intended ones (qcom,q6v5.txt), which lists "wcss_q6_reset" and *not* "wcss_q6_bcr_reset"
--- drivers/remoteproc/qcom_q6v5_wcss.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/remoteproc/qcom_q6v5_wcss.c +5 -18
@@ -96,7 +96,6 @@ struct wcss_data {unsigned int crash_reason_smem;u32 version;bool aon_reset_required; -bool wcss_q6_reset_required;const char *ssr_name;const char *sysmon_name;int ssctl_id;
@@ -134,7 +133,6 @@ struct q6v5_wcss {struct reset_control *wcss_aon_reset;struct reset_control *wcss_reset;struct reset_control *wcss_q6_reset; -struct reset_control *wcss_q6_bcr_reset;struct qcom_q6v5 q6v5;
@@ -309,7 +307,7 @@ static int q6v5_wcss_qcs404_power_on(struct q6v5_wcss *wcss)return ret;/* Remove reset to the WCNSS QDSP6SS */ -reset_control_deassert (wcss->wcss_q6_bcr_reset); +reset_control_deassert (wcss->wcss_q6_reset);/* Enable Q6SSTOP_AHBFABRIC_CBCR clock */ ret =clk_prepare_enable (wcss->ahbfabric_cbcr_clk);
@@ -803,19 +801,10 @@ static int q6v5_wcss_init_reset(struct q6v5_wcss *wcss,return PTR_ERR (wcss->wcss_reset); } -if (desc->wcss_q6_reset_required) { - wcss->wcss_q6_reset =devm_reset_control_get_exclusive (dev,"wcss_q6_reset" ); -if (IS_ERR (wcss->wcss_q6_reset)) { -dev_err (wcss->dev,"unable to acquire wcss_q6_reset\n" ); -return PTR_ERR (wcss->wcss_q6_reset); - } - } - - wcss->wcss_q6_bcr_reset =devm_reset_control_get_optional_exclusive (dev, -"wcss_q6_bcr_reset" ); -if (IS_ERR (wcss->wcss_q6_bcr_reset)) { -dev_err (wcss->dev,"unable to acquire wcss_q6_bcr_reset\n" ); -return PTR_ERR (wcss->wcss_q6_bcr_reset); + wcss->wcss_q6_reset =devm_reset_control_get_exclusive (dev,"wcss_q6_reset" ); +if (IS_ERR (wcss->wcss_q6_reset)) { +dev_err (wcss->dev,"unable to acquire wcss_q6_reset\n" ); +return PTR_ERR (wcss->wcss_q6_reset); }return 0 ;
@@ -1062,7 +1051,6 @@ static const struct wcss_data wcss_ipq8074_res_init = { .firmware_name = "IPQ8074/q6_fw.mdt", .crash_reason_smem = WCSS_CRASH_REASON, .aon_reset_required = true, - .wcss_q6_reset_required = true, .ops = &q6v5_wcss_ipq8074_ops, .requires_force_stop = true, };
@@ -1072,7 +1060,6 @@ static const struct wcss_data wcss_qcs404_res_init = { .firmware_name = "wcnss.mdt", .version = WCSS_QCS404, .aon_reset_required = false, - .wcss_q6_reset_required = false, .ssr_name = "mpss", .sysmon_name = "wcnss", .ssctl_id = 0x12,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 575/2077 hwspinlock: qcom: avoid uninitialized struct members
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 8752c396ce3b2136b3d4c906fe103f6efb6782d9 ]
The reg_field is allocated on stack, so using the REG_FIELD macro will ensure that unused members do not have uninitialized values.
--- drivers/hwspinlock/qcom_hwspinlock.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwspinlock/qcom_hwspinlock.c +1 -4
@@ -202,7 +202,6 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,static int qcom_hwspinlock_probe (struct platform_device *pdev) {struct hwspinlock_device *bank; -struct reg_field field;struct regmap *regmap;size_t array_size;u32 stride;
@@ -224,9 +223,7 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)platform_set_drvdata (pdev, bank);for (i =0 ; i <QCOM_MUTEX_NUM_LOCKS ; i++) { - field.reg = base + i * stride; - field.lsb =0 ; - field.msb =31 ; +struct reg_field field =REG_FIELD (base + i * stride,0 ,31 ); bank->lock[i].priv =devm_regmap_field_alloc (&pdev->dev, regmap, field);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/2077 sched/fair: Fix cpu_util runnable_avg arithmetic
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xia <[email protected]>
[ Upstream commit 29922fdfc2a4008d66418bedd0ebf5038fc54efa ]
If we take runnable_avg in max(runnable_avg, util_avg) in cpu_util(), we should then add or subtract task runnable_avg, but the arithmetic below is still with task util_avg. This mixes runnable_avg with util_avg which is incorrect.
Fix by always doing arithmetic with runnable_avg and only take max(runnable_avg, util_avg) at the last step.
--- kernel/sched/fair.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
kernel/sched/fair.c +15 -8
@@ -8256,25 +8256,32 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)static unsigned long cpu_util (int cpu,struct task_struct *p,int dst_cpu,int boost) { +bool add_task = p &&task_cpu (p) != cpu && dst_cpu == cpu; +bool sub_task = p &&task_cpu (p) == cpu && dst_cpu != cpu;struct cfs_rq *cfs_rq = &cpu_rq (cpu)->cfs;unsigned long util =READ_ONCE (cfs_rq->avg.util_avg);unsigned long runnable; -if (boost) { - runnable =READ_ONCE (cfs_rq->avg.runnable_avg); - util =max (util, runnable); - } -/* * If @dst_cpu is -1 or @p migrates from @cpu to @dst_cpu remove its * contribution. If @p migrates from another CPU to @cpu add its * contribution. In all the other cases @cpu is not impacted by the * migration so its util_avg is already correct. */ -if (p &&task_cpu (p) == cpu && dst_cpu != cpu) -lsub_positive (&util,task_util (p)); -else if (p &&task_cpu (p) != cpu && dst_cpu == cpu) +if (add_task) util +=task_util (p); +else if (sub_task) +lsub_positive (&util,task_util (p)); + +if (boost) { + runnable =READ_ONCE (cfs_rq->avg.runnable_avg); +if (add_task) + runnable +=READ_ONCE (p->se.avg.runnable_avg); +else if (sub_task) +lsub_positive (&runnable, +READ_ONCE (p->se.avg.runnable_avg)); + util =max (util, runnable); + }if (sched_feat (UTIL_EST )) {unsigned long util_est;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/2077 ARM: configs: Drop duplicated CONFIG_EXT4_FS
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit ae371a58117d30a496e3be27cce8d9d13acdd740 ]
Remove redundant, duplicated CONFIG_EXT4_FS to fix warnings like:
axm55xx_defconfig:198:warning: override: reassigning to symbol EXT4_FS
--- arch/arm/configs/axm55xx_defconfig | 1 - arch/arm/configs/dove_defconfig | 1 - arch/arm/configs/ep93xx_defconfig | 1 - arch/arm/configs/mmp2_defconfig | 1 - arch/arm/configs/mv78xx0_defconfig | 1 - 5 files changed, 5 deletions(-)
arch/arm/configs/axm55xx_defconfig +0 -1
@@ -195,7 +195,6 @@ CONFIG_PL320_MBOX=y # CONFIG_IOMMU_SUPPORT is not set CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y -CONFIG_EXT4_FS=y CONFIG_AUTOFS_FS=y CONFIG_FUSE_FS=y CONFIG_CUSE=y
arch/arm/configs/dove_defconfig +0 -1
@@ -97,7 +97,6 @@ CONFIG_MV_XOR=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=y CONFIG_ISO9660_FS=y CONFIG_JOLIET=y CONFIG_UDF_FS=m
arch/arm/configs/ep93xx_defconfig +0 -1
@@ -105,7 +105,6 @@ CONFIG_EP93XX_DMA=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_JFFS2_FS=y
arch/arm/configs/mmp2_defconfig +0 -1
@@ -54,7 +54,6 @@ CONFIG_RTC_DRV_MAX8925=y # CONFIG_RESET_CONTROLLER is not set CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y -CONFIG_EXT4_FS=y # CONFIG_DNOTIFY is not set CONFIG_MSDOS_FS=y CONFIG_FAT_DEFAULT_CODEPAGE=437
arch/arm/configs/mv78xx0_defconfig +0 -1
@@ -93,7 +93,6 @@ CONFIG_RTC_DRV_M41T80=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=m CONFIG_ISO9660_FS=m CONFIG_JOLIET=y CONFIG_UDF_FS=m
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/2077 wifi: mt76: mt7925: clean up DMA on probe failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 9629f31f505d74e76ac0d7a9492fd06c0316fc5d ]
mt7925_pci_probe() initializes DMA before registering the device. If mt7925_register_device() fails, probe returns through err_free_irq without tearing down DMA state.
That leaves the TX NAPI instance enabled and skips the DMA queue cleanup that the normal remove path performs through mt7925e_unregister_device(). Add a dedicated unwind label for failures after mt7925_dma_init() succeeds.
--- drivers/net/wireless/mediatek/mt76/mt7925/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +3 -1
@@ -415,10 +415,12 @@ static int mt7925_pci_probe(struct pci_dev *pdev, ret =mt7925_register_device (dev);if (ret) - goto err_free_irq; + goto err_free_dma;return 0 ; +err_free_dma: +mt792x_dma_cleanup (dev); err_free_irq:devm_free_irq (&pdev->dev, pdev->irq, dev); err_free_dev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 579/2077 wifi: mt76: mt7921: fix resource leak in probe error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 346dac35b1384af9338b34b6835e82e634ea4d2c ]
When pcim_iomap_region() or devm_kmemdup() fail, the code returns directly without cleaning up previously allocated resources:
- mt76_device allocated by mt76_alloc_device()
- pci irq vectors allocated by pci_alloc_irq_vectors()
Fix this by jumping to the existing error cleanup path instead of returning directly.
--- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +10 -5
@@ -343,11 +343,14 @@ static int mt7921_pci_probe(struct pci_dev *pdev,pci_set_drvdata (pdev, mdev); + dev = container_of(mdev, struct mt792x_dev, mt76); + regs =pcim_iomap_region (pdev,0 ,pci_name (pdev)); -if (IS_ERR (regs)) -return PTR_ERR (regs); +if (IS_ERR (regs)) { + ret =PTR_ERR (regs); + goto err_free_dev; + } - dev = container_of(mdev, struct mt792x_dev, mt76); dev->fw_features = features; dev->hif_ops = &mt7921_pcie_ops; dev->irq_map = &irq_map;
@@ -359,8 +362,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,/* MT7902 needs a mutable copy because wm2_complete_mask differs */ map =devm_kmemdup (&pdev->dev, &irq_map,sizeof (irq_map),GFP_KERNEL ); -if (!map) -return -ENOMEM ; +if (!map) { + ret = -ENOMEM ; + goto err_free_dev; + } map->rx.wm2_complete_mask =0 ; dev->irq_map = map;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 580/2077 wifi: mt76: use kfree_rcu for offchannel link in mt76_put_vif_phy_link
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rajat Gupta <[email protected]>
[ Upstream commit 7fae097aa9a56c30febf539d72ef3773165d3aa3 ]
mt76_put_vif_phy_link() frees the offchannel mlink with plain kfree() after rcu_assign_pointer(NULL). However, rcu_assign_pointer only prevents future RCU readers from obtaining the pointer -- it does not wait for existing readers that already hold it via rcu_dereference.
The TX datapath (e.g. mt7996_mac_write_txwi) dereferences mlink->wcid and mlink->idx under rcu_read_lock. If a TX softirq obtained the pointer via rcu_dereference just before the NULL assignment, it will dereference freed memory after the kfree.
struct mt76_vif_link already contains an rcu_head field that is unused at this free site -- a developer oversight, since the adjacent kfree_rcu_mightsleep call for rx_sc in the same function shows the pattern was understood.
Replace kfree(mlink) with kfree_rcu(mlink, rcu_head).
--- drivers/net/wireless/mediatek/mt76/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/channel.c +1 -1
@@ -307,7 +307,7 @@ void mt76_put_vif_phy_link(struct mt76_phy *phy, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->offchannel_link,NULL ); dev->drv->vif_link_remove (phy, vif, &vif->bss_conf, mlink); -kfree (mlink); +kfree_rcu (mlink, rcu_head); }void mt76_roc_complete (struct mt76_phy *phy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/2077 wifi: mt76: mt7996: add missing max_remain_on_channel_duration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit ac41612e0044fa29cf9bc45b6808dda6d87ac2da ]
Having this unset breaks remain-on-channel and mgmt TX. Move setting it to mt76 core to keep it in one place.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7615/init.c | 1 - drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -0
@@ -449,6 +449,8 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_AIRTIME_FAIRNESS );wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_AQL ); +if (!wiphy->max_remain_on_channel_duration) + wiphy->max_remain_on_channel_duration =5000 ;if (!wiphy->available_antennas_tx) wiphy->available_antennas_tx = phy->antenna_mask;if (!wiphy->available_antennas_rx)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +0 -1
@@ -195,7 +195,6 @@ mt7615_check_offload_capability(struct mt7615_dev *dev)ieee80211_hw_set (hw,SUPPORTS_DYNAMIC_PS ); wiphy->flags &= ~WIPHY_FLAG_4ADDR_STATION ; - wiphy->max_remain_on_channel_duration =5000 ; wiphy->features |=NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
drivers/net/wireless/mediatek/mt76/mt792x_core.c +0 -1
@@ -657,7 +657,6 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)BIT (NL80211_IFTYPE_P2P_CLIENT ) |BIT (NL80211_IFTYPE_P2P_GO ) |BIT (NL80211_IFTYPE_P2P_DEVICE ); - wiphy->max_remain_on_channel_duration =5000 ; wiphy->max_scan_ie_len =MT76_CONNAC_SCAN_IE_LEN ; wiphy->max_scan_ssids =4 ; wiphy->max_sched_scan_plan_interval =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/2077 wifi: mt76: mt7996: Fix NULL pointer dereference in mt7996_init_tx_queues()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6794edb55b5f5ef834e03b0b241b1a8b725f82c0 ]
When MT76_NPU and CONFIG_NET_MEDIATEK_SOC_WED are enabled and mt76 detects properly the Airoha NPU SoC, mt7996_init_tx_queues() will dereference a NULL WED pointer.
Fix the issue by always passing the WED pointer from mt7996_dma_init().
--- drivers/net/wireless/mediatek/mt76/mt7996/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/dma.c +1 -1
@@ -683,7 +683,7 @@ int mt7996_dma_init(struct mt7996_dev *dev) ret =mt7996_init_tx_queues (&dev->phy,MT_TXQ_ID (0 ),MT7996_NPU_TX_RING_SIZE ,MT_TXQ_RING_BASE (0 ) + hif1_ofs, -NULL ); + wed); else ret = mt7996_init_tx_queues(&dev->phy, MT_TXQ_ID(dev->mphy.band_idx),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/2077 wifi: mt76: mt7925: fix stale pointer comparisons in change_vif_links
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Tia <[email protected]>
[ Upstream commit 9f1accf3069a0cd42c14ca6c7d44d5b17cc48a80 ]
In the error path of mt7925_change_vif_links(), the free: label iterates over link_ids to clean up, but compares against mconf and mlink which hold stale values from the last loop iteration rather than the current link_id being freed.
Use array-indexed access (mconfs[link_id] / mlinks[link_id]) to compare against the correct per-link pointers.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -2
@@ -2182,9 +2182,9 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->link_conf[link_id],NULL );rcu_assign_pointer (mvif->sta.link[link_id],NULL ); -if (mconf != &mvif->bss_conf) +if (mconfs[link_id] != &mvif->bss_conf)devm_kfree (dev->mt76.dev, mconfs[link_id]); -if (mlink != &mvif->sta.deflink) +if (mlinks[link_id] != &mvif->sta.deflink)devm_kfree (dev->mt76.dev, mlinks[link_id]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/2077 wifi: mt76: mt7925: keep TX BA state in the primary WCID
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit d3c854068bad22a25db6515f12784f64c663fed2 ]
For MLO, the same TID can run over different links. Keeping TX BA state in a link WCID makes the state depend on which link starts aggregation first.
Store it in the primary WCID instead, so the BA state stays stable across links.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +7 -8
@@ -841,7 +841,6 @@ static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb, {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_link_sta *link_sta; -struct mt792x_link_sta *mlink;struct mt792x_sta *msta;bool is_8023;u16 fc, tid;
@@ -880,14 +879,14 @@ static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb, msta = (struct mt792x_sta *)sta->drv_priv; -if (sta->mlo && msta->deflink_id !=IEEE80211_LINK_UNSPECIFIED ) - mlink =rcu_dereference (msta->link[msta->deflink_id]); -else - mlink = &msta->deflink; - -if (!test_and_set_bit (tid, &mlink->wcid.ampdu_state)) { +/* Packets belonging to the same TID can be transmitted over multiple +* links. Keep the TX BA session state in the primary link so all links +* share the same AMPDU bookkeeping. +*/ +if (!test_and_set_bit (tid, &msta->deflink.wcid.ampdu_state)) {if (ieee80211_start_tx_ba_session (sta, tid,0 )) -clear_bit (tid, &mlink->wcid.ampdu_state); +clear_bit (tid, &msta->deflink.wcid.ampdu_state); + } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/2077 wifi: mt76: mt792x: skip MLD header rewrite for 802.3 encap TX
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit a1152244702bb31b64650e5ca8308142286c0e4a ]
mt792x_tx() rewrites addr1/addr2/addr3 by treating skb->data as an 802.11 header for MLD traffic.
That is only valid for native 802.11 frames. Direct 802.3 TX can also reach this path with IEEE80211_TX_CTL_HW_80211_ENCAP set, where skb->data is not an 802.11 header.
Skip the MLD header rewrite for HW-encap packets to avoid corrupting 802.3 frame contents.
--- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +2 -1
@@ -105,7 +105,8 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, wcid = &mvif->sta.deflink.wcid; } -if (vif && control->sta &&ieee80211_vif_is_mld (vif)) { +if (vif && control->sta &&ieee80211_vif_is_mld (vif) && + !(info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP )) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_link_sta *link_sta;struct ieee80211_bss_conf *conf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/2077 wifi: mt76: mt7925: validate skb length in testmode query
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aviel Zohar <[email protected]>
[ Upstream commit c7369a00860a0704461d440e7c3bf9b49bfdbaee ]
In mt7925_tm_query(), the response skb from mt76_mcu_send_and_get_msg() is used in a memcpy without validating its length:
memcpy(evt_resp, skb->data + 8, MT7925_EVT_RSP_LEN);
where MT7925_EVT_RSP_LEN is 512. If the firmware returns a response shorter than 520 bytes (8 + 512), this reads beyond the skb data buffer. The over-read data is then returned to userspace via nla_put() in mt7925_testmode_dump().
Add a length check before the memcpy to ensure the skb contains sufficient data.
--- drivers/net/wireless/mediatek/mt76/mt7925/testmode.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/testmode.c +5 -0
@@ -105,6 +105,11 @@ mt7925_tm_query(struct mt792x_dev *dev, struct mt7925_tm_cmd *req,if (ret) goto out; +if (skb->len <MT7925_EVT_RSP_LEN +8 ) { + ret = -EINVAL ; + goto out; + } +memcpy ((char *)evt_resp, (char *)skb->data +8 ,MT7925_EVT_RSP_LEN ); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/2077 wifi: mt76: mt7996: Fix possible token leak in mt7996_tx_prepare_skb()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 831074096d0450308357271fc0ffd3f600a2487e ]
If link_conf or link_sta lookup fails in mt7996_tx_prepare_skb routine, mt7996 driver leaks an already allocated tx token. Fix the issue releasing the token in case of error.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 8 ++++++-- drivers/net/wireless/mediatek/mt76/tx.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +6 -2
@@ -1067,11 +1067,11 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, link_conf =rcu_dereference (vif->link_conf[wcid->link_id]);if (!link_conf) -return -EINVAL ; + goto error_release_token; link_sta =rcu_dereference (sta->link[wcid->link_id]);if (!link_sta) -return -EINVAL ; + goto error_release_token;dma_sync_single_for_cpu (mdev->dma_dev, tx_info->buf[1 ].addr, tx_info->buf[1 ].len,DMA_TO_DEVICE );
@@ -1176,6 +1176,10 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, tx_info->nbuf =MT_CT_DMA_BUF_NUM ;return 0 ; + +error_release_token: +mt76_token_release (mdev, id,NULL ); +return -EINVAL ; }u32 mt7996_wed_init_buf (void *ptr,dma_addr_t phys,int token_id)
drivers/net/wireless/mediatek/mt76/tx.c +1 -1
@@ -933,7 +933,7 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)#endif } -if (dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && +if (wake && dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && dev->phy.q_tx[0 ]->blocked) *wake = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/2077 wifi: mt76: mt7996: Fix possible NULL pointer dereference in mt7996_mac_write_txwi_80211()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 61370e6674b5253de5686813ceeceebc35a7d3e5 ]
For injected frames (e.g. via radiotap), mac80211 can pass info->control.vif = NULL, as explicitly noted in struct ieee80211_tx_info. Check vif pointer before executing ieee80211_vif_is_mld() in mt7996_mac_write_txwi_80211 routine in order to avoid a possible NULL pointer dereference.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -3
@@ -757,6 +757,7 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi,bool multicast =is_multicast_ether_addr (hdr->addr1);u8 tid = skb->priority &IEEE80211_QOS_CTL_TID_MASK ;__le16 fc = hdr->frame_control, sc = hdr->seq_ctrl; +struct ieee80211_vif *vif = info->control.vif;u16 seqno =le16_to_cpu (sc);bool hw_bigtk = false;u8 fc_type, fc_stype;
@@ -819,7 +820,7 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi, txwi[3 ] |=cpu_to_le32 (MT_TXD3_REM_TX_COUNT ); } -if (multicast &&ieee80211_vif_is_mld (info->control.vif)) { +if (multicast && vif &&ieee80211_vif_is_mld (vif)) { val =MT_TXD3_SN_VALID |FIELD_PREP (MT_TXD3_SEQ ,IEEE80211_SEQ_TO_SN (seqno)); txwi[3 ] |=cpu_to_le32 (val);
@@ -839,12 +840,12 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi, txwi[3 ] &= ~cpu_to_le32 (MT_TXD3_HW_AMSDU ); } -if (ieee80211_vif_is_mld (info->control.vif) && +if (vif &&ieee80211_vif_is_mld (vif) && (multicast ||unlikely (skb->protocol ==cpu_to_be16 (ETH_P_PAE )))) txwi[5 ] |=cpu_to_le32 (MT_TXD5_FL );if (ieee80211_is_nullfunc (fc) &&ieee80211_has_a4 (fc) && -ieee80211_vif_is_mld (info->control.vif)) { + vif &&ieee80211_vif_is_mld (vif)) { txwi[5 ] |=cpu_to_le32 (MT_TXD5_FL ); txwi[6 ] |=cpu_to_le32 (MT_TXD6_DIS_MAT ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/2077 wifi: mt76: mt7996: fix reading zeroed info->control.flags after mt76_tx_status_skb_add()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 729c83a3330c0a56662cd0d8e40db96d41c00a54 ]
mt76_tx_status_skb_add() zeroes the mt76_tx_cb struct stored at info->status.status_driver_data via memset(). Since info->control and info->status are members of the same union in ieee80211_tx_info, this overwrites info->control.flags.
In mt7996_tx_prepare_skb(), mt76_tx_status_skb_add() is called before mt7996_mac_write_txwi(), which re-reads info->control.flags to extract IEEE80211_TX_CTRL_MLO_LINK. Because the field has been zeroed, the link_id always resolves to 0 for frames using global_wcid, leading to incorrect TXWI configuration.
Fix this by passing link_id as an explicit parameter to mt7996_mac_write_txwi(). In mt7996_tx_prepare_skb(), the link_id is already extracted from info->control.flags before the destructive mt76_tx_status_skb_add() call. For the beacon and inband discovery callers in mcu.c, use link_conf->link_id directly.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 14 ++++---------- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 5 +++-- drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 3 ++- 3 files changed, 9 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -10
@@ -857,7 +857,8 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi,void mt7996_mac_write_txwi (struct mt7996_dev *dev,__le32 *txwi,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_key_conf *key,int pid, -enum mt76_txq_id qid,u32 changed) +enum mt76_txq_id qid,u32 changed, +unsigned int link_id) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);
@@ -867,7 +868,6 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,bool is_8023 = info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ;struct mt76_vif_link *mlink =NULL ;struct mt7996_vif *mvif; -unsigned int link_id;u16 tx_count =15 ;u32 val; bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
@@ -875,17 +875,11 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,bool beacon = !!(changed & (BSS_CHANGED_BEACON |BSS_CHANGED_BEACON_ENABLED )) && (!inband_disc); -if (wcid != &dev->mt76.global_wcid) - link_id = wcid->link_id; -else - link_id =u32_get_bits (info->control.flags, -IEEE80211_TX_CTRL_MLO_LINK ); - mvif = vif ? (struct mt7996_vif *)vif->drv_priv :NULL ;if (mvif) {if (wcid->offchannel) mlink =rcu_dereference (mvif->mt76.offchannel_link); -if (!mlink) +if (!mlink && link_id !=IEEE80211_LINK_UNSPECIFIED ) mlink =rcu_dereference (mvif->mt76.link[link_id]); }
@@ -1097,7 +1091,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,/* Transmit non qos data by 802.11 header and need to fill txd by host*/ if (!is_8023 || pid >=MT_PACKET_ID_FIRST )mt7996_mac_write_txwi (dev, txwi_ptr, tx_info->skb, wcid, key, - pid, qid,0 ); + pid, qid,0 , link_id);/* MT7996 and MT7992 require driver to provide the MAC TXP for AddBA * req
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +3 -2
@@ -3098,7 +3098,7 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, buf = (u8 *)bcn +sizeof (*bcn);mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , -BSS_CHANGED_BEACON ); +BSS_CHANGED_BEACON , link_conf->link_id);memcpy (buf +MT_TXD_SIZE , skb->data, skb->len); }
@@ -3244,7 +3244,8 @@ int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev, buf = (u8 *)tlv +sizeof (*discov); -mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , changed); +mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , + changed, link_conf->link_id);memcpy (buf +MT_TXD_SIZE , skb->data, skb->len);
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +2 -1
@@ -855,7 +855,8 @@ void mt7996_mac_enable_nf(struct mt7996_dev *dev, u8 band);void mt7996_mac_write_txwi (struct mt7996_dev *dev,__le32 *txwi,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_key_conf *key,int pid, -enum mt76_txq_id qid,u32 changed); +enum mt76_txq_id qid,u32 changed, +unsigned int link_id);void mt7996_mac_update_beacons (struct mt7996_phy *phy);void mt7996_mac_set_coverage_class (struct mt7996_phy *phy);void mt7996_mac_work (struct work_struct *work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/2077 wifi: mt76: mt7996: remove redundant pdev->bus check in probe
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6b294950eaac246e6b0f42d74aa643ff36384c6e ]
Drop the unnecessary pdev->bus NULL check in mt7996_pci_probe() since the pointer is already dereferenced earlier in mt76_pci_disable_aspm(), making the check dead code. Silences the related Smatch warning.
--- drivers/net/wireless/mediatek/mt76/mt7996/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/pci.c +1 -1
@@ -141,7 +141,7 @@ static int mt7996_pci_probe(struct pci_dev *pdev, dev->hif2 = hif2;mt76_npu_init (mdev,pci_resource_start (pdev,0 ), - pdev->bus &&pci_domain_nr (pdev->bus) ?3 :2 ); +pci_domain_nr (pdev->bus) ?3 :2 ); ret =mt7996_mmio_wed_init (dev, pdev, false, &irq);if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/2077 wifi: mt76: mt7996: limit work in set_bitrate_mask
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dylan Eskew <[email protected]>
[ Upstream commit 5fd3385505600934f5faa9635e5b30fa38e548b9 ]
Calls to mt7996_set_bitrate_mask() would propagate work for all stations on the ieee80211_hw regardless of the vif specified in the call. To prevent unnecessary work in FW, limit setting the sta_rate to only the specified vif in mt7996_sta_rate_ctrl_update().
--- drivers/net/wireless/mediatek/mt76/mt7996/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +6 -3
@@ -1959,7 +1959,11 @@ static void mt7996_sta_rate_ctrl_update(void *data, struct ieee80211_sta *sta) {struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;struct mt7996_sta_link *msta_link; -u32 *changed = data; +struct mt7996_vif *mvif = data; +u32 changed =IEEE80211_RC_SUPP_RATES_CHANGED ; + +if (msta->vif != mvif) +return ; msta_link =rcu_dereference (msta->link[msta->deflink_id]);if (msta_link)
@@ -1972,7 +1976,6 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, {struct mt7996_dev *dev =mt7996_hw_dev (hw);struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; -u32 changed =IEEE80211_RC_SUPP_RATES_CHANGED ; mvif->deflink.bitrate_mask = *mask;
@@ -1985,7 +1988,7 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif,* then multiple MCS setting (MCS 4,5,6) is not supported. */ ieee80211_iterate_stations_atomic (hw, mt7996_sta_rate_ctrl_update, - &changed); + mvif);ieee80211_queue_work (hw, &dev->rc_work);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/2077 wifi: mt76: fix argument to ieee80211_is_first_frag()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjoern A. Zeeb <[email protected]>
[ Upstream commit 5832743279da8c6ae72f715bad2f7141eca6f4b8 ]
ieee80211_is_first_frag() operates on the seq_ctrl not the frame_control header field. Pass the correct one in; otherwise the results may vary.
Sponsored by: The FreeBSD Foundation
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +1 -1
@@ -1323,7 +1323,7 @@ mt76_check_ccmp_pn(struct sk_buff *skb)* All further fragments will be validated by mac80211 only. */ if (ieee80211_is_frag (hdr) && - !ieee80211_is_first_frag (hdr->frame_control)) + !ieee80211_is_first_frag (hdr->seq_ctrl))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/2077 wifi: mt76: mt7915: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 05e72b6167970043348bfbe8f72a3b67a38a9f1c ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +5 -5
@@ -912,16 +912,16 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) }if (!mtk_wed_device_active (&mdev->mmio.wed) && wcid) { -u32 tx_retries =0 , tx_failed =0 ; +u32 tx_retries =0 , tx_failed =0 , count;if (v3 && (info &MT_TX_FREE_MPDU_HEADER_V3 )) { - tx_retries = -FIELD_GET (MT_TX_FREE_COUNT_V3 , info) -1 ; + count =FIELD_GET (MT_TX_FREE_COUNT_V3 , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TX_FREE_STAT_V3 , info); }else if (!v3 && (info &MT_TX_FREE_MPDU_HEADER )) { - tx_retries = -FIELD_GET (MT_TX_FREE_COUNT , info) -1 ; + count =FIELD_GET (MT_TX_FREE_COUNT , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TX_FREE_STAT , info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/2077 wifi: mt76: mt7921: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 3c5671ed81b1fff97fa868dae771690599db94f7 ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +3 -2
@@ -530,8 +530,9 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len) stat =FIELD_GET (MT_TX_FREE_STATUS , info);if (wcid) { - wcid->stats.tx_retries += -FIELD_GET (MT_TX_FREE_COUNT , info) -1 ; +u32 count =FIELD_GET (MT_TX_FREE_COUNT , info); + + wcid->stats.tx_retries += count ? count -1 :0 ; wcid->stats.tx_failed += !!stat; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/2077 wifi: mt76: mt7925: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 1e1fd84571e62a2961cea44c053340ec5c99b2cb ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +3 -2
@@ -1140,8 +1140,9 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)if (info &MT_TXFREE_INFO_HEADER ) {if (wcid) { - wcid->stats.tx_retries += -FIELD_GET (MT_TXFREE_INFO_COUNT , info) -1 ; +u32 count =FIELD_GET (MT_TXFREE_INFO_COUNT , info); + + wcid->stats.tx_retries += count ? count -1 :0 ; wcid->stats.tx_failed += !!FIELD_GET (MT_TXFREE_INFO_STAT , info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/2077 wifi: mt76: mt7996: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 4d8bba99d645bcb46a442b18eb42402610cba03a ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +3 -3
@@ -1359,13 +1359,13 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) cur_info++;continue ; }else if (info &MT_TXFREE_INFO_HEADER ) { -u32 tx_retries =0 , tx_failed =0 ; +u32 tx_retries =0 , tx_failed =0 , count;if (!wcid)continue ; - tx_retries = -FIELD_GET (MT_TXFREE_INFO_COUNT , info) -1 ; + count =FIELD_GET (MT_TXFREE_INFO_COUNT , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TXFREE_INFO_STAT , info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/2077 btrfs: fix invalid pointer dereference in __btrfs_run_delayed_refs()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 486f8298b6188ff11ef1f4be7f1d5d2e4d1b1fae ]
In the beginning of the loop, we try to obtain a locked delayed ref head, if 'locked_ref' is currently NULL, by calling btrfs_select_ref_head(), which can return an error pointer. If the error pointer is -EAGAIN we do a continue and go back to the beginning of the loop, which will not try again to call btrfs_select_ref_head() since 'locked_ref' is no longer NULL but it's ERR_PTR(-EAGAIN), and then we do:
spin_lock(&locked_ref->lock);
against a ERR_PTR(-EAGAIN) value, generating an invalid pointer dereference.
Fix this by ensuring that 'locked_ref' is set to NULL when btrfs_select_ref_head() returns ERR_PTR(-EAGAIN) and incrementing 'count' as well, to prevent infinite looping. We do this by doing a goto to the bottom of the loop that already sets 'locked_ref' to NULL and does a cond_resched(), with an increment to 'count' right before the goto. These measures were in place before the refactoring in commit 0110a4c43451 ("btrfs: refactor __btrfs_run_delayed_refs loop") but were unintentionally lost afterwards.
--- fs/btrfs/extent-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +3 -2
@@ -2108,7 +2108,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, locked_ref =btrfs_select_ref_head (fs_info, delayed_refs);if (IS_ERR_OR_NULL (locked_ref)) {if (PTR_ERR (locked_ref) == -EAGAIN ) { -continue ; + count++; + goto again; }else {break ; }
@@ -2156,7 +2157,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,* Either success case or btrfs_run_delayed_refs_for_head * returned -EAGAIN, meaning we need to select another head */ - +again: locked_ref =NULL ;cond_resched (); } while ((min_bytes != U64_MAX && bytes_processed < min_bytes) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/2077 ALSA: aloop: Drop superfluous break
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 123fd13f35ccaf7d2b98f5a8cc6c8a3de378568d ]
At converting the spinlock to guard(), a break statement was put in the scoped_guard block in loopback_jiffies_timer_function(), but it's obviously superfluous (although it's harmless). Better to drop it for avoiding confusion.
--- sound/drivers/aloop.c | 1 - 1 file changed, 1 deletion(-)
sound/drivers/aloop.c +0 -1
@@ -728,7 +728,6 @@ static void loopback_jiffies_timer_function(struct timer_list *t)if (dpcm->period_update_pending) { dpcm->period_update_pending =0 ; period_elapsed = true; -break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/2077 gpio: mt7621: fix interrupt banks mapping on gpio chips
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Paracuellos <[email protected]>
[ Upstream commit a46f2e5720f5670feda145709d1f0d20be5c7263 ]
The GPIO controller's registers are organized as sets of eight 32-bit registers with each set controlling a bank of up to 32 pins. A single interrupt is shared for all of the banks handled by the controller. The driver implements this using three gpio chip instances every one with its own irq chip. Every single pin can generate interrupts having a total of 96 possible interrupts here. It looks like there is a problem with interrupts being properly mapped to the gpio bank using this solution. This problem report is in the following lore's link [0].
Device tree is using two cells for this, so only the interrupt pin and the interrupt type are described there. Changing to have three cells to setup also the bank and implement 'of_node_instance_match()' would also work but this would be an ABI breakage and also a bit incoherent since gpios itself are also using two cells and properly mapped in desired bank using through its pin number on 'of_xlate()'.
That said, register a linear IRQ domain of the total of 96 interrupts shared with the three gpio chip instances so the bank and the interrupt is properly decoded and devices using gpio IRQs properly work.
--- drivers/gpio/gpio-mt7621.c | 282 ++++++++++++++++++++++++++++--------- 1 file changed, 216 insertions(+), 66 deletions(-)
drivers/gpio/gpio-mt7621.c +216 -66
@@ -29,8 +29,8 @@#define GPIO_REG_EDGE 0xA0struct mtk_gc { -struct irq_chip irq_chip;struct gpio_generic_chip chip; +struct mtk *parent_priv;int bank;u32 rising;u32 falling;
@@ -41,20 +41,32 @@ struct mtk_gc {/** * struct mtk - state container for * data of the platform driver. It is 3 -* separate gpio-chip each one with its -* own irq_chip. -* @dev: device instance +* separate gpio-chip having an IRQ +* linear domain shared for all of them +* @pdev: platform device instance * @base: memory base address +* @irq_domain: IRQ linear domain shared across the three gpio chips * @gpio_irq: irq number from the device tree +* @num_gpios: total number of gpio pins on the three gpio chips * @gc_map: array of the gpio chips */ struct mtk { -struct device *dev; +struct platform_device *pdev;void __iomem *base; +struct irq_domain *irq_domain;int gpio_irq; +int num_gpios;struct mtk_gc gc_map[MTK_BANK_CNT ]; }; +static inline struct mtk * +mt7621_gpio_gc_to_priv (struct gpio_chip *gc) +{ +struct mtk_gc *bank =gpiochip_get_data (gc); + +return bank->parent_priv; +} +static inline struct mtk_gc *to_mediatek_gpio (struct gpio_chip *chip) {
@@ -67,7 +79,7 @@ static inline void mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) { struct gpio_chip *gc = &rg->chip.gc; -struct mtk *mtk =gpiochip_get_data (gc); +struct mtk *mtk =mt7621_gpio_gc_to_priv (gc); offset = (rg->bank *GPIO_BANK_STRIDE ) + offset;gpio_generic_write_reg (&rg->chip, mtk->base + offset, val);
@@ -77,41 +89,62 @@ static inline u32 mtk_gpio_r32(struct mtk_gc *rg, u32 offset) {struct gpio_chip *gc = &rg->chip.gc; -struct mtk *mtk =gpiochip_get_data (gc); +struct mtk *mtk =mt7621_gpio_gc_to_priv (gc); offset = (rg->bank *GPIO_BANK_STRIDE ) + offset;return gpio_generic_read_reg (&rg->chip, mtk->base + offset); } -static irqreturn_t -mediatek_gpio_irq_handler (int irq,void *data) +static void +mt7621_gpio_irq_bank_handler (struct mtk_gc *bank) { -struct gpio_chip *gc = data; -struct mtk_gc *rg =to_mediatek_gpio (gc); -irqreturn_t ret =IRQ_NONE ; +struct mtk *priv = bank->parent_priv; +struct irq_domain *domain = priv->irq_domain; +int hwbase = bank->chip.gc.offset;unsigned long pending; -int bit; +unsigned int offset; + + pending =mtk_gpio_r32 (bank,GPIO_REG_STAT ); +if (!pending) +return ; + +mtk_gpio_w32 (bank,GPIO_REG_STAT , pending); + +for_each_set_bit (offset, &pending,MTK_BANK_WIDTH ) +generic_handle_domain_irq (domain, hwbase + offset); +} + +static void +mt7621_gpio_irq_handler (struct irq_desc *desc) +{ +struct mtk *priv =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +int i; - pending =mtk_gpio_r32 (rg,GPIO_REG_STAT ); +chained_irq_enter (chip, desc); +for (i =0 ; i <MTK_BANK_CNT ; i++) { +struct mtk_gc *bank = &priv->gc_map[i]; -for_each_set_bit (bit, &pending,MTK_BANK_WIDTH ) { -generic_handle_domain_irq (gc->irq.domain, bit); -mtk_gpio_w32 (rg,GPIO_REG_STAT ,BIT (bit)); - ret |=IRQ_HANDLED ; +mt7621_gpio_irq_bank_handler (bank); } +chained_irq_exit (chip, desc); +} -return ret; +static int +mt7621_gpio_hwirq_to_offset (irq_hw_number_t hwirq,struct mtk_gc *bank) +{ +return hwirq - bank->chip.gc.offset; }static void mediatek_gpio_irq_unmask (struct irq_data *d) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =mt7621_gpio_hwirq_to_offset (d->hwirq, rg);u32 rise, fall, high, low; -gpiochip_enable_irq (gc, d->hwirq); +gpiochip_enable_irq (gc, mask);guard (gpio_generic_lock_irqsave)(&rg->chip);
@@ -119,18 +152,18 @@ mediatek_gpio_irq_unmask(struct irq_data *d) fall =mtk_gpio_r32 (rg,GPIO_REG_FEDGE ); high =mtk_gpio_r32 (rg,GPIO_REG_HLVL ); low =mtk_gpio_r32 (rg,GPIO_REG_LLVL ); -mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise | (BIT (pin) & rg->rising)); -mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall | (BIT (pin) & rg->falling)); -mtk_gpio_w32 (rg,GPIO_REG_HLVL , high | (BIT (pin) & rg->hlevel)); -mtk_gpio_w32 (rg,GPIO_REG_LLVL , low | (BIT (pin) & rg->llevel)); +mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise | (BIT (mask) & rg->rising)); +mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall | (BIT (mask) & rg->falling)); +mtk_gpio_w32 (rg,GPIO_REG_HLVL , high | (BIT (mask) & rg->hlevel)); +mtk_gpio_w32 (rg,GPIO_REG_LLVL , low | (BIT (mask) & rg->llevel)); }static void mediatek_gpio_irq_mask (struct irq_data *d) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =mt7621_gpio_hwirq_to_offset (d->hwirq, rg);u32 rise, fall, high, low; scoped_guard(gpio_generic_lock_irqsave, &rg->chip) {
@@ -138,22 +171,21 @@ mediatek_gpio_irq_mask(struct irq_data *d) fall =mtk_gpio_r32 (rg,GPIO_REG_FEDGE ); high =mtk_gpio_r32 (rg,GPIO_REG_HLVL ); low =mtk_gpio_r32 (rg,GPIO_REG_LLVL ); -mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_HLVL , high & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_LLVL , low & ~BIT (pin)); +mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_HLVL , high & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_LLVL , low & ~BIT (mask)); } -gpiochip_disable_irq (gc, d->hwirq); +gpiochip_disable_irq (gc, mask); }static int mediatek_gpio_irq_type (struct irq_data *d,unsigned int type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; -u32 mask =BIT (pin); +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =BIT (mt7621_gpio_hwirq_to_offset (d->hwirq, rg));if (type ==IRQ_TYPE_PROBE ) { if ((rg->rising | rg->falling |
@@ -190,6 +222,26 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)return 0 ; } +static int +mt7621_gpio_irq_reqres (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct mtk_gc *rg =gpiochip_get_data (gc); +unsigned int irq =mt7621_gpio_hwirq_to_offset (d->hwirq, rg); + +return gpiochip_reqres_irq (gc, irq); +} + +static void +mt7621_gpio_irq_relres (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct mtk_gc *rg =gpiochip_get_data (gc); +unsigned int irq =mt7621_gpio_hwirq_to_offset (d->hwirq, rg); + +gpiochip_relres_irq (gc, irq); +} +static int mediatek_gpio_xlate (struct gpio_chip *chip,const struct of_phandle_args *spec,u32 *flags)
@@ -208,14 +260,123 @@ mediatek_gpio_xlate(struct gpio_chip *chip,static const struct irq_chip mt7621_irq_chip = { .name ="mt7621-gpio" , + .irq_request_resources = mt7621_gpio_irq_reqres, + .irq_release_resources = mt7621_gpio_irq_relres, .irq_mask_ack = mediatek_gpio_irq_mask, .irq_mask = mediatek_gpio_irq_mask, .irq_unmask = mediatek_gpio_irq_unmask, .irq_set_type = mediatek_gpio_irq_type, .flags =IRQCHIP_IMMUTABLE , -GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; + +static void +mt7621_gpio_remove (struct platform_device *pdev) +{ +struct mtk *priv =platform_get_drvdata (pdev); +int offset, virq; + +if (priv->gpio_irq >0 ) +irq_set_chained_handler_and_data (priv->gpio_irq,NULL ,NULL ); + +/* Remove all IRQ mappings and delete the domain */ +if (priv->irq_domain) { +for (offset =0 ; offset < priv->num_gpios; offset++) { + virq =irq_find_mapping (priv->irq_domain, offset); +irq_dispose_mapping (virq); + } +irq_domain_remove (priv->irq_domain); + } +} + +static struct mtk_gc * +mt7621_gpio_hwirq_to_bank (struct mtk *priv,irq_hw_number_t hwirq) +{ +int i; + +for (i =0 ; i <MTK_BANK_CNT ; i++) { +struct mtk_gc *bank = &priv->gc_map[i]; + +if (hwirq >= bank->chip.gc.offset && + hwirq < (bank->chip.gc.offset + bank->chip.gc.ngpio)) +return bank; + } + +return NULL ; +} + +static int +mt7621_gpio_irq_map (struct irq_domain *d,unsigned int irq, +irq_hw_number_t hwirq) +{ +struct mtk *priv = d->host_data; +struct mtk_gc *bank =mt7621_gpio_hwirq_to_bank (priv, hwirq); +struct platform_device *pdev = priv->pdev; +int ret; + +if (!bank) +return -EINVAL ; + +dev_dbg (&pdev->dev,"Mapping irq %d for gpio line %d (bank %d)\n" , + irq, (int )hwirq, bank->bank); + + ret =irq_set_chip_data (irq, &bank->chip.gc); +if (ret <0 ) +return ret; + +irq_set_chip_and_handler (irq, &mt7621_irq_chip, handle_simple_irq); +irq_set_noprobe (irq); + +return 0 ; +} + +static void +mt7621_gpio_irq_unmap (struct irq_domain *d,unsigned int irq) +{ +irq_set_chip_and_handler (irq,NULL ,NULL ); +irq_set_chip_data (irq,NULL ); +} + +static const struct irq_domain_ops mt7621_gpio_irq_domain_ops = { + .map = mt7621_gpio_irq_map, + .unmap = mt7621_gpio_irq_unmap, + .xlate = irq_domain_xlate_twocell, }; +static int +mt7621_gpio_irq_setup (struct platform_device *pdev, +struct mtk *priv) +{ +struct device *dev = &pdev->dev; + + priv->irq_domain =irq_domain_create_linear (dev_fwnode (dev), + priv->num_gpios, + &mt7621_gpio_irq_domain_ops, + priv); +if (!priv->irq_domain) { +dev_err (dev,"Couldn't allocate IRQ domain\n" ); +return -ENXIO ; + } + +irq_set_chained_handler_and_data (priv->gpio_irq, + mt7621_gpio_irq_handler, priv); +irq_set_status_flags (priv->gpio_irq,IRQ_DISABLE_UNLAZY ); + +return 0 ; +} + +static int +mt7621_gpio_to_irq (struct gpio_chip *gc,unsigned int offset) +{ +struct mtk *priv =mt7621_gpio_gc_to_priv (gc); +/* gc_offset is relative to this gpio_chip; want real offset */ +int hwirq = offset + gc->offset; + +if (hwirq >= priv->num_gpios) +return -ENXIO ; + +return irq_create_mapping (priv->irq_domain, hwirq); +} +static int mediatek_gpio_bank_probe (struct device *dev,int bank) {
@@ -228,6 +389,7 @@ mediatek_gpio_bank_probe(struct device *dev, int bank) rg = &mtk->gc_map[bank];memset (rg,0 ,sizeof (*rg)); + rg->parent_priv = mtk; rg->bank = bank; dat = mtk->base +GPIO_REG_DATA + (rg->bank *GPIO_BANK_STRIDE );
@@ -253,41 +415,17 @@ mediatek_gpio_bank_probe(struct device *dev, int bank) rg->chip.gc.of_gpio_n_cells =2 ; rg->chip.gc.of_xlate = mediatek_gpio_xlate; + rg->chip.gc.ngpio =MTK_BANK_WIDTH ; rg->chip.gc.label =devm_kasprintf (dev,GFP_KERNEL ,"%s-bank%d" ,dev_name (dev), bank);if (!rg->chip.gc.label)return -ENOMEM ; rg->chip.gc.offset = bank *MTK_BANK_WIDTH ; +if (mtk->gpio_irq >0 ) + rg->chip.gc.to_irq = mt7621_gpio_to_irq; -if (mtk->gpio_irq) { -struct gpio_irq_chip *girq; - -/* -* Directly request the irq here instead of passing -* a flow-handler because the irq is shared. -*/ - ret =devm_request_irq (dev, mtk->gpio_irq, - mediatek_gpio_irq_handler,IRQF_SHARED , - rg->chip.gc.label, &rg->chip.gc); - -if (ret) { -dev_err (dev,"Error requesting IRQ %d: %d\n" , - mtk->gpio_irq, ret); -return ret; - } - - girq = &rg->chip.gc.irq; -gpio_irq_chip_set_chip (girq, &mt7621_irq_chip); -/* This will let us handle the parent IRQ in the driver */ - girq->parent_handler =NULL ; - girq->num_parents =0 ; - girq->parents =NULL ; - girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_simple_irq; - } - - ret =devm_gpiochip_add_data (dev, &rg->chip.gc, mtk); + ret =devm_gpiochip_add_data (dev, &rg->chip.gc, rg);if (ret <0 ) {dev_err (dev,"Could not register gpio %d, ret=%d\n" , rg->chip.gc.ngpio, ret);
@@ -322,7 +460,8 @@ mediatek_gpio_probe(struct platform_device *pdev)if (mtk->gpio_irq <0 )return mtk->gpio_irq; - mtk->dev = dev; + mtk->pdev = pdev; + mtk->num_gpios =MTK_BANK_WIDTH *MTK_BANK_CNT ;platform_set_drvdata (pdev, mtk);for (i =0 ; i <MTK_BANK_CNT ; i++) {
@@ -331,7 +470,17 @@ mediatek_gpio_probe(struct platform_device *pdev)return ret; } +if (mtk->gpio_irq >0 ) { + ret =mt7621_gpio_irq_setup (pdev, mtk); +if (ret) + goto fail; + } +return 0 ; + +fail: +mt7621_gpio_remove (pdev); +return ret; }static const struct of_device_id mediatek_gpio_match[] = {
@@ -342,6 +491,7 @@ MODULE_DEVICE_TABLE(of, mediatek_gpio_match);static struct platform_driver mediatek_gpio_driver = { .probe = mediatek_gpio_probe, + .remove = mt7621_gpio_remove, .driver = { .name ="mt7621_gpio" , .of_match_table = mediatek_gpio_match,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/2077 wifi: ath12k: fix EAPOL TX failure caused by stale tcl_metadata bits
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit fdea4d44e4b9c3f7021c85f8cd766e84e224472d ]
On WCN7850, after the following sequence:
1. load ath12k and connect to a non-MLO AP
2. disconnect and connect to an MLO AP
3. disconnect and reconnect to the non-MLO AP
the third connection always fails with a 4-Way handshake timeout. The supplicant transmits message 2 of 4 four times in response to AP retries of message 1, but the AP never sees any of them.
ath12k_dp_vdev_tx_attach() composes dp_link_vif->tcl_metadata using |=, but dp_link_vif is embedded in struct ath12k_dp_vif and its slots are reused across vif/peer teardown and setup. Since tcl_metadata is never cleared on detach, vdev_id bits from a previous attach remain set when the same link slot is reused with a different vdev_id. In this specific issue, the same link slot is used for vdev_id 0, then vdev_id 1, then vdev_id 0 again, the OR yields tcl_metadata == 0x9, which encodes vdev_id 1 in the HTT_TCL_META_DATA_VDEV_ID field even though ti.vdev_id is 0. Firmware then routes the EAPOL frame to the wrong vdev and the AP never receives message 2.
Use plain assignment instead of |= so the field is fully recomputed from the current arvif on every attach.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/dp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath12k/dp.c +5 -5
@@ -943,11 +943,11 @@ void ath12k_dp_vdev_tx_attach(struct ath12k *ar, struct ath12k_link_vif *arvif) dp_link_vif =ath12k_dp_vif_to_dp_link_vif (&ahvif->dp_vif, link_id); - dp_link_vif->tcl_metadata |=u32_encode_bits (1 ,HTT_TCL_META_DATA_TYPE ) | -u32_encode_bits (arvif->vdev_id, -HTT_TCL_META_DATA_VDEV_ID ) | -u32_encode_bits (ar->pdev->pdev_id, -HTT_TCL_META_DATA_PDEV_ID ); + dp_link_vif->tcl_metadata =u32_encode_bits (1 ,HTT_TCL_META_DATA_TYPE ) | +u32_encode_bits (arvif->vdev_id, +HTT_TCL_META_DATA_VDEV_ID ) | +u32_encode_bits (ar->pdev->pdev_id, +HTT_TCL_META_DATA_PDEV_ID );/* set HTT extension valid bit to 0 by default */ dp_link_vif->tcl_metadata &= ~HTT_TCL_META_DATA_VALID_HTT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/2077 wifi: ath12k: enable IEEE80211_VHT_EXT_NSS_BW_CAPABLE when NSS ratio is reported
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wen Gong <[email protected]>
[ Upstream commit 63abe299b12b317dfee5bcd09037da4668a4431a ]
When firmware reports NSS ratio support, SUPPORTS_VHT_EXT_NSS_BW is enabled in ath12k. However, IEEE80211_VHT_EXT_NSS_BW_CAPABLE must also be set to make the advertisement valid.
According to IEEE Std 802.11-2024, Subclause 9.4.2.156.3 (Supported VHT-MCS and NSS Set subfields), the VHT Extended NSS BW Capable bit indicates whether a STA is capable of interpreting the Extended NSS BW Support subfield of the VHT capabilities information field. Advertising extended NSS BW support without setting this capability bit is therefore invalid.
Without this change, mac80211 detects the inconsistency and logs:
ieee80211 phy0: copying sband (band 1) due to VHT EXT NSS BW flag
This indicates that mac80211 implicitly aligns IEEE80211_VHT_EXT_NSS_BW_CAPABLE during ieee80211_register_hw(). Explicitly setting the bit in ath12k avoids this fixup and ensures capabilities are advertised correctly by the driver.
This change follows the same approach as the existing ath11k fix.
https://lore.kernel.org/all/[email protected]/
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.5-01651-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/mac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath12k/mac.c +4 -0
@@ -8399,6 +8399,10 @@ ath12k_create_vht_cap(struct ath12k *ar, u32 rate_cap_tx_chainmask, vht_cap.vht_supported =1 ; vht_cap.cap = ar->pdev->cap.vht_cap; +if (ar->pdev->cap.nss_ratio_enabled) + vht_cap.vht_mcs.tx_highest |= +cpu_to_le16 (IEEE80211_VHT_EXT_NSS_BW_CAPABLE ); +ath12k_set_vht_txbf_cap (ar, &vht_cap.cap);/* 80P80 is not supported */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/2077 fbdev/arm: Export acorndata_8x8 font symbol for bootloader
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit 470ea955a18c76eeb10ca11ffcb2fe923bfc5515 ]
The text display code used in the Risc PC kernel image decompression code uses arch/arm/boot/compressed/font.c, which includes lib/fonts/font_acorn_8x8.c, which further includes <linux/font.h>.
Since commit 97df8960240a ("lib/fonts: Provide helpers for calculating glyph pitch and size") <linux/font.h> contains inline functions that require __do_div64, which is not linked into the ARM kernel decompressor. This makes Risc PC zImages fail to build.
Resolve this issue by defining the BOOTLOADER symbol and use it to avoid a static declaration of the acorndata_8x8 symbol. That way it can be referenced by the arm bootloader, and other static math functions and symbols (like __do_div64) stay static and don't get unneccesary included in the ARM kernel bootloader decompressor object file.
--- arch/arm/boot/compressed/Makefile | 2 +- lib/fonts/font_acorn_8x8.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/boot/compressed/Makefile +1 -1
@@ -157,4 +157,4 @@ $(obj)/piggy_data: $(obj)/../Image FORCE $(obj)/piggy.o: $(obj)/piggy_data -CFLAGS_font.o := -Dstatic= +CFLAGS_font.o := -DBOOTLOADER
lib/fonts/font_acorn_8x8.c +5 -0
@@ -5,7 +5,12 @@#define FONTDATAMAX 2048 +#ifdef BOOTLOADER +/* The acorndata_8x8 symbol is needed by the ARM bootloader too. */ +const struct font_data acorndata_8x8 = { +#else static const struct font_data acorndata_8x8 = { +#endif { 0, 0, FONTDATAMAX, 0 }, { /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/2077 fbdev: sm501fb: Fix buffer errors in OF binding code
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit d8421e09382cfe0bd2a044c8b0a822f64855dd4e ]
The code that gets the frame buffer mode from OF has 'use after free', 'buffer overrun' and memory leaks.
info->edid_data isn't free if the probe functions fail or if pd->def_mode is set.
If both the CRT and PANEL are enabled info->edid_data is used after being freed and is freed twice.
The string returned by of_get_property(np, "mode", &len) is just written over either the static "640x480-16@60" or the module parameter string without any regard for the length (which is most likely longer).
Use kstrump() for the OF mode and free everything before freeing 'info.
--- drivers/video/fbdev/sm501fb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/video/fbdev/sm501fb.c +12 -4
@@ -96,6 +96,7 @@ struct sm501fb_info {void __iomem *fbmem;/* remapped framebuffer */ size_t fbmem_len;/* length of remapped region */ u8 *edid_data; +char *fb_mode; };/* per-framebuffer private data */
@@ -1793,12 +1794,11 @@ static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head, fb->var.yres_virtual = fb->var.yres; }else {if (info->edid_data) { - ret =fb_find_mode (&fb->var, fb, fb_mode, + ret =fb_find_mode (&fb->var, fb, + info->fb_mode ?: fb_mode, fb->monspecs.modedb, fb->monspecs.modedb_len, &sm501_default_mode, default_bpp); -/* edid_data is no longer needed, free it */ -kfree (info->edid_data); }else { ret =fb_find_mode (&fb->var, fb,NULL ,NULL ,0 ,NULL ,8 );
@@ -1974,7 +1974,7 @@ static int sm501fb_probe(struct platform_device *pdev)/* Get EDID */ cp =of_get_property (np,"mode" , &len);if (cp) -strcpy (fb_mode, cp); + info->fb_mode =kstrdup (cp,GFP_KERNEL ); prop =of_get_property (np,"edid" , &len);if (prop && len ==EDID_LENGTH ) { info->edid_data = kmemdup(prop, EDID_LENGTH,
@@ -2031,6 +2031,12 @@ static int sm501fb_probe(struct platform_device *pdev) goto err_started_crt; } +/* These aren't needed any more */ +kfree (info->edid_data); +kfree (info->fb_mode); + info->edid_data =NULL ; + info->fb_mode =NULL ; +/* we registered, return ok */ return 0 ;
@@ -2048,6 +2054,8 @@ static int sm501fb_probe(struct platform_device *pdev)framebuffer_release (info->fb[HEAD_CRT ]); err_alloc: +kfree (info->edid_data); +kfree (info->fb_mode);kfree (info);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/2077 memory: tegra186-emc: stop borrowing MC aggregate hook for EMC
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Gupta <[email protected]>
[ Upstream commit 2e05f3d6005d9aa3e2e423d2471f290d9ccbe3d2 ]
tegra186_emc_interconnect_init() copies the MC's ICC aggregate hook into the EMC provider. That hook (tegra234_mc_icc_aggregate / tegra264_mc_icc_aggregate) uses container_of() to recover 'mc', which is only valid when the icc_provider is embedded in struct tegra_mc. For an EMC node the provider is embedded in struct tegra186_emc, so 'mc' points into unrelated memory.
This stayed harmless until commit faafd6ca7e6e ("memory: tegra:
make icc_set_bw return zero if BWMGR not supported") added an unconditional read of mc->bwmgr_mrq_supported at the top of the hook. UBSAN catches the stray load on every EMC aggregation:
UBSAN: invalid-load in drivers/memory/tegra/tegra234.c:1104:9 load of value 112 is not a valid value for type '_Bool'
No functional impact in practice, since the hook's only other mc dereference (mc->num_channels) sits inside a TEGRA_ICC_MC_CPU_CLUSTER* branch that EMC nodes never enter.
Fix this by setting the EMC provider's aggregate hook to icc_std_aggregate, instead of borrowing the MC's hook. The MC providers continue using their own aggregate hooks, where container_of() correctly resolves to struct tegra_mc.
--- drivers/memory/tegra/tegra186-emc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/memory/tegra/tegra186-emc.c +1 -3
@@ -258,15 +258,13 @@ static int tegra186_emc_icc_get_init_bw(struct icc_node *node, u32 *avg, u32 *pestatic int tegra186_emc_interconnect_init (struct tegra186_emc *emc) { -struct tegra_mc *mc =dev_get_drvdata (emc->dev->parent); -const struct tegra_mc_soc *soc = mc->soc;struct icc_node *node;int err; emc->provider.dev = emc->dev; emc->provider.set = tegra186_emc_icc_set_bw; emc->provider.data = &emc->provider; - emc->provider.aggregate = soc->icc_ops->aggregate; + emc->provider.aggregate = icc_std_aggregate; emc->provider.xlate = tegra186_emc_of_icc_xlate; emc->provider.get_bw = tegra186_emc_icc_get_init_bw;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/2077 vfs: add FS_USERNS_DELEGATABLE flag and set it for NFS
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit c5d6cac28646b0d5d81ef632be748ae93c1f36c7 ]
Commit e1c5ae59c0f2 ("fs: don't allow non-init s_user_ns for filesystems without FS_USERNS_MOUNT") prevents the mount of any filesystem inside a container that doesn't have FS_USERNS_MOUNT set.
This broke NFS mounts in our containerized environment. We have a daemon somewhat like systemd-mountfsd running in the init_ns. A process does a fsopen() inside the container and passes it to the daemon via unix socket.
The daemon then vets that the request is for an allowed NFS server and performs the mount. This now fails because the fc->user_ns is set to the value in the container and NFS doesn't set FS_USERNS_MOUNT. We don't want to add FS_USERNS_MOUNT to NFS since that would allow the container to mount any NFS server (even malicious ones).
Add a new FS_USERNS_DELEGATABLE flag, and enable it on NFS.
--- fs/nfs/fs_context.c | 8 ++++++-- fs/super.c | 11 ++++++----- include/linux/fs.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-)
fs/nfs/fs_context.c +6 -2
@@ -1769,7 +1769,9 @@ struct file_system_type nfs_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags =FS_RENAME_DOES_D_MOVE | +FS_BINARY_MOUNTDATA | + FS_USERNS_DELEGATABLE, };MODULE_ALIAS_FS ("nfs" );EXPORT_SYMBOL_GPL (nfs_fs_type);
@@ -1781,7 +1783,9 @@ struct file_system_type nfs4_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags =FS_RENAME_DOES_D_MOVE | +FS_BINARY_MOUNTDATA | + FS_USERNS_DELEGATABLE, };MODULE_ALIAS_FS ("nfs4" );MODULE_ALIAS ("nfs4" );
fs/super.c +6 -5
@@ -741,12 +741,13 @@ struct super_block *sget_fc(struct fs_context *fc,int err;/* -* Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT is -* not set, as the filesystem is likely unprepared to handle it. -* This can happen when fsconfig() is called from init_user_ns with -* an fs_fd opened in another user namespace. +* Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT or +* FS_USERNS_DELEGATABLE is not set, as the filesystem is likely +* unprepared to handle it. This can happen when fsconfig() is called +* from init_user_ns with an fs_fd opened in another user namespace. */ -if (user_ns != &init_user_ns && !(fc->fs_type->fs_flags &FS_USERNS_MOUNT )) { +if (user_ns != &init_user_ns && + !(fc->fs_type->fs_flags & (FS_USERNS_MOUNT |FS_USERNS_DELEGATABLE ))) {errorfc (fc,"VFS: Mounting from non-initial user namespace is not allowed" );return ERR_PTR (-EPERM ); }
include/linux/fs.h +1 -0
@@ -2281,6 +2281,7 @@ struct file_system_type {#define FS_MGTIME 64/* FS uses multigrain timestamps */ #define FS_LBS 128/* FS supports LBS */ #define FS_POWER_FREEZE 256/* Always freeze on suspend/hibernate */ +#define FS_USERNS_DELEGATABLE 1024/* Can be mounted inside userns from outside */ #define FS_RENAME_DOES_D_MOVE 32768/* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *);const struct fs_parameter_spec *parameters;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/2077 hwmon: (it87) Clamp negative values to zero in set_fan()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
[ Upstream commit 7f8581c70a3bd50a932d3d2d253e99c5ec3eda74 ]
set_fan() parses user input with kstrtol() and passes the resulting value to FAN16_TO_REG() on chips with 16-bit fan support.
Negative fan speeds are not meaningful and should be rejected before conversion. Worst scenario, one may be able to abuse undefined behaviour of signed overflow to possibly induce rpm * 2 == 0 in FAN16_TO_REG(), thus causing a division by zero.
Instead, clamp val < 0 to zero and keep the conversion in its valid input domain, avoiding unsafe arithmetic in the register conversion path.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/hwmon/it87.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/it87.c +3 -0
@@ -1412,6 +1412,9 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr,if (kstrtol (buf,10 , &val) <0 )return -EINVAL ; +if (val <0 ) + val =0 ; + err =it87_lock (data);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/2077 PM: QoS: Fix misc device registration unwind
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 51a7c560cffdd3653ac2b930d01410569b23b23e ]
cpu_latency_qos_init() registers cpu_dma_latency first and, when CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP is enabled, registers cpu_wakeup_latency afterwards. The second registration overwrites the first return value.
As a result, a failure to register cpu_dma_latency can be masked if the second registration succeeds. Conversely, if cpu_dma_latency succeeds and cpu_wakeup_latency fails, the function returns an error while leaving the first misc device registered.
Return immediately on the first registration failure and deregister cpu_dma_latency if the second registration fails.
--- kernel/power/qos.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/power/qos.c +8 -3
@@ -519,18 +519,23 @@ static int __init cpu_latency_qos_init(void)int ret; ret =misc_register (&cpu_latency_qos_miscdev); -if (ret <0 ) +if (ret <0 ) {pr_err ("%s: %s setup failed\n" , __func__, cpu_latency_qos_miscdev.name); +return ret; + }#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP ret =misc_register (&cpu_wakeup_latency_qos_miscdev); -if (ret <0 ) +if (ret <0 ) {pr_err ("%s: %s setup failed\n" , __func__, cpu_wakeup_latency_qos_miscdev.name); +misc_deregister (&cpu_latency_qos_miscdev); +return ret; + }#endif - return ret; + return 0; }late_initcall (cpu_latency_qos_init);#endif /* CONFIG_CPU_IDLE */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/2077 btrfs: zoned: dont account data relocation space-info in statfs free space
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 52416a27aabc43eab3792fd0ca9f5dabeab58f31 ]
Don't account the free space in a data relocation space-info sub-group as usable free space in statfs.
This is misleading as no user allocations can be made in this space-info sub-group. It is only a target for relocation.
--- fs/btrfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/super.c +2 -1
@@ -1740,7 +1740,8 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)int mixed =0 ;list_for_each_entry (found, &fs_info->space_info, list) { -if (found->flags &BTRFS_BLOCK_GROUP_DATA ) { +if (found->flags &BTRFS_BLOCK_GROUP_DATA && + found->subgroup_id !=BTRFS_SUB_GROUP_DATA_RELOC ) {int i; total_free_data += found->disk_total - found->disk_used;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/2077 btrfs: zoned: fix deadlock waiting for ticket during data relocation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 814c3b4ea357297c507158bceb07bcdc5fbe9808 ]
When performing data relocation on a zoned filesystem, BTRFS can deadlock in handle_reserve_tickets(). The relocation process is waiting on a space reservation ticket that can never be fulfilled, because the relocation itself is the operation responsible for freeing up that space.
Fix this by introducing a new flush state, BTRFS_RESERVE_FLUSH_ZONED_RELOCATION, specifically for data chunk allocation during zoned relocation. Like BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE, this state uses priority_reclaim_data_space() instead of the normal flushing path, which avoids re-entering the relocation code and breaking the deadlock cycle.
In btrfs_alloc_data_chunk_ondemand(), select this new flush state when the inode belongs to a data relocation root on a zoned filesystem.
--- fs/btrfs/delalloc-space.c | 2 ++ fs/btrfs/space-info.c | 2 ++ fs/btrfs/space-info.h | 11 +++++++++++ 3 files changed, 15 insertions(+)
fs/btrfs/delalloc-space.c +2 -0
@@ -134,6 +134,8 @@ int btrfs_alloc_data_chunk_ondemand(const struct btrfs_inode *inode, u64 bytes)if (btrfs_is_free_space_inode (inode)) flush =BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE ; +else if (btrfs_is_zoned (fs_info) &&btrfs_is_data_reloc_root (root)) + flush =BTRFS_RESERVE_FLUSH_ZONED_RELOCATION ;return btrfs_reserve_data_bytes (data_sinfo_for_inode (inode), bytes, flush); }
fs/btrfs/space-info.c +2 -0
@@ -1698,6 +1698,7 @@ static int handle_reserve_ticket(struct btrfs_space_info *space_info, ARRAY_SIZE(evict_flush_states));break ;case BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE : +case BTRFS_RESERVE_FLUSH_ZONED_RELOCATION :priority_reclaim_data_space (space_info, ticket);break ;default :
@@ -1961,6 +1962,7 @@ int btrfs_reserve_data_bytes(struct btrfs_space_info *space_info, u64 bytes,ASSERT (flush ==BTRFS_RESERVE_FLUSH_DATA || flush ==BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE || + flush ==BTRFS_RESERVE_FLUSH_ZONED_RELOCATION || flush ==BTRFS_RESERVE_NO_FLUSH ,"flush=%d" , flush); ASSERT(!current->journal_info || flush != BTRFS_RESERVE_FLUSH_DATA, "current->journal_info=0x%lx flush=%d",
fs/btrfs/space-info.h +11 -0
@@ -77,6 +77,17 @@ enum btrfs_reserve_flush_enum {*/ BTRFS_RESERVE_FLUSH_ALL_STEAL , +/* +* This is for relocation on zoned filesystems only. We need to use +* priority flushing for this, because otherwise we can deadlock on +* waiting for a ticket, that cannot be granted, because we cannot do +* any allocations. +* +* Apart from being specific to zoned relocation, it is equal to +* BTRFS_FLUSH_FREE_SPACE_INODE. +*/ + BTRFS_RESERVE_FLUSH_ZONED_RELOCATION, +/* * This is for btrfs_use_block_rsv only. We have exhausted our block * rsv and our global block rsv. This can happen for things like
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/2077 Revert "btrfs: fix the file offset calculation inside btrfs_decompress_buf2page()"
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 0279bed34c22dd5ebff12e5af8ef940de93c5523 ]
It seems that af566bdaff54 was tested against a tree which did not contain commit 12851bd921d4 ("fs: Turn page_offset() into a wrapper around folio_pos()). Unfortunately it has a bug of its own; on 32-bit systems, shifting by PAGE_SHIFT will overflow on files larger than 4GiB. Since page_offset() is now fixed, just revert af566bdaff54.
--- fs/btrfs/compression.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
fs/btrfs/compression.c +1 -17
@@ -1191,22 +1191,6 @@ void __cold btrfs_exit_compress(void)bioset_exit (&btrfs_compressed_bioset); } -/* -* The bvec is a single page bvec from a bio that contains folios from a filemap. -* -* Since the folio may be a large one, and if the bv_page is not a head page of -* a large folio, then page->index is unreliable. -* -* Thus we need this helper to grab the proper file offset. -*/ -static u64 file_offset_from_bvec (const struct bio_vec *bvec) -{ -const struct page *page = bvec->bv_page; -const struct folio *folio =page_folio (page); - -return (page_pgoff (folio, page) <<PAGE_SHIFT ) + bvec->bv_offset; -} -/* * Copy decompressed data from working buffer to pages. *
@@ -1259,7 +1243,7 @@ int btrfs_decompress_buf2page(const char *buf, u32 buf_len,* cb->start may underflow, but subtracting that value can still * give us correct offset inside the full decompressed extent. */ - bvec_offset =file_offset_from_bvec (&bvec) - cb->start; + bvec_offset =page_offset (bvec.bv_page) + bvec.bv_offset - cb->start;/* Haven't reached the bvec range, exit */ if (decompressed + buf_len <= bvec_offset)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/2077 btrfs: zoned: always set max_active_zones for zoned devices
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 21a3533b99b8a53a026cc9f5041b10795c1f3ae8 ]
When a block device does not report a maximum number of open or active zones, currently assign BTRFS_DEFAULT_MAX_ACTIVE_ZONES (128) to the internal limit, if the device has more than BTRFS_DEFAULT_MAX_ACTIVE_ZONES zones.
But if the device has less than BTRFS_DEFAULT_MAX_ACTIVE_ZONES the internal max_active_zones limit will stay at 0, even if the device has zone resource limits. Furthermore, if the device has a total number of zones that is less than BTRFS_DEFAULT_MAX_ACTIVE_ZONE, max_active_zones should be set to at most the number of zones.
Also move the max_active_zone calculation and setting into a dedicated helper, to shrink btrfs_get_dev_zone_info().
--- fs/btrfs/zoned.c | 64 +++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-)
fs/btrfs/zoned.c +39 -25
@@ -354,12 +354,33 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)return ret; } +static int btrfs_get_max_active_zones (struct btrfs_device *device, +struct btrfs_zoned_device_info *zone_info) +{ +struct block_device *bdev = device->bdev; +int max_active_zones; + +if (unlikely (zone_info->nr_zones <BTRFS_MIN_ACTIVE_ZONES )) { +btrfs_err (device->fs_info,"zoned: not enough zones to mount filesystem: %u < %d" , + zone_info->nr_zones,BTRFS_MIN_ACTIVE_ZONES ); +return -EINVAL ; + } + + max_active_zones =min_not_zero (bdev_max_active_zones (bdev), +bdev_max_open_zones (bdev)); +if (max_active_zones ==0 ) + max_active_zones =min (zone_info->nr_zones /4 , +BTRFS_DEFAULT_MAX_ACTIVE_ZONES ); + + zone_info->max_active_zones =max (max_active_zones,BTRFS_MIN_ACTIVE_ZONES ); +return 0 ; +} +int btrfs_get_dev_zone_info (struct btrfs_device *device,bool populate_cache) {struct btrfs_fs_info *fs_info = device->fs_info;struct btrfs_zoned_device_info *zone_info =NULL ;struct block_device *bdev = device->bdev; -unsigned int max_active_zones;unsigned int nactive;sector_t nr_sectors;sector_t sector =0 ;
@@ -424,19 +445,9 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)if (!IS_ALIGNED (nr_sectors, zone_sectors)) zone_info->nr_zones++; - max_active_zones =min_not_zero (bdev_max_active_zones (bdev), -bdev_max_open_zones (bdev)); -if (!max_active_zones && zone_info->nr_zones >BTRFS_DEFAULT_MAX_ACTIVE_ZONES ) - max_active_zones =BTRFS_DEFAULT_MAX_ACTIVE_ZONES ; -if (max_active_zones && max_active_zones <BTRFS_MIN_ACTIVE_ZONES ) { -btrfs_err (fs_info, -"zoned: %s: max active zones %u is too small, need at least %u active zones" , -rcu_dereference (device->name), max_active_zones, -BTRFS_MIN_ACTIVE_ZONES ); - ret = -EINVAL ; + ret =btrfs_get_max_active_zones (device, zone_info); +if (ret) goto out; - } - zone_info->max_active_zones = max_active_zones; zone_info->seq_zones =bitmap_zalloc (zone_info->nr_zones,GFP_KERNEL );if (!zone_info->seq_zones) {
@@ -517,26 +528,29 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) goto out; } -if (max_active_zones) { -if (unlikely (nactive > max_active_zones)) { -if (bdev_max_active_zones (bdev) ==0 ) { - max_active_zones =0 ; - zone_info->max_active_zones =0 ; - goto validate; - } +if (unlikely (nactive > zone_info->max_active_zones)) { +if (bdev_max_active_zones (bdev) >0 ) {btrfs_err (device->fs_info, -"zoned: %u active zones on %s exceeds max_active_zones %u" , - nactive,rcu_dereference (device->name), - max_active_zones); +"zoned: %u active zones on %s exceeds max_active_zones %u" , + nactive,rcu_dereference (device->name), + zone_info->max_active_zones); ret = -EIO ; goto out; } + +/* +* This is for backward compatibility with old filesystems that +* have a lot of active zones because the device doesn't report +* a maximum number of zones and we previously didn't care for +* the limit. +*/ + zone_info->max_active_zones =0 ; + }else {atomic_set (&zone_info->active_zones_left, - max_active_zones - nactive); + zone_info->max_active_zones - nactive);set_bit (BTRFS_FS_ACTIVE_ZONE_TRACKING , &fs_info->flags); } -validate:/* Validate superblock log */ nr_zones =BTRFS_NR_SB_LOG_ZONES ;for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/2077 btrfs: annotate lockless read of defrag_bytes in should_nocow()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 89c0dc3de7a73e8aba5e9bfef543eee047a3d0d2 ]
should_nocow() reads inode->defrag_bytes without holding inode->lock, while btrfs_set_delalloc_extent() and btrfs_clear_delalloc_extent() update it under that spinlock.
This is a data race. The read is a quick check used to decide whether to fall back to COW for a NOCOW inode: if defrag_bytes is non-zero and the range is tagged EXTENT_DEFRAG, we force COW so that defragmentation can rewrite the extent. Reading a stale value is harmless because:
- A missed increment may skip COW once, but the defrag pass will redo the extent later.
- A stale non-zero may force an unnecessary COW, which is a minor efficiency loss, not a correctness issue.
On 64-bit platforms an aligned u64 load is naturally atomic so tearing cannot happen. On 32-bit platforms u64 may tear, but we only test for zero vs non-zero, so the heuristic stays correct regardless. Use data_race() annotation.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -2317,7 +2317,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,static bool should_nocow (struct btrfs_inode *inode,u64 start,u64 end) {if (inode->flags & (BTRFS_INODE_NODATACOW |BTRFS_INODE_PREALLOC )) { -if (inode->defrag_bytes && +if (data_race (inode->defrag_bytes) &&btrfs_test_range_bit_exists (&inode->io_tree, start, end,EXTENT_DEFRAG ))return false;return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/2077 btrfs: fix deadlock cloning inline extent when using flushoncommit
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 532085d00eb54c074bdeae648b194765239f4d11 ]
In commit b48c980b6a7e ("btrfs: fix deadlock between reflink and transaction commit when using flushoncommit") a deadlock was fixed between reflinks and transaction commits when the fs is mounted with the flushoncommit option. This happened when we had to copy an inline extent's data to the destination file. However the issue was fixed only for the case where the destination offset is 0, it missed the case when the offset is greater than zero.
Fix this by ensuring we get i_size update whenever we copied an inline extent's data into the destination file.
Syzbot reported this with the following trace:
INFO: task kworker/u8:3:57 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u8:3 state:D stack:21600 pid:57 tgid:57 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: writeback wb_workfn (flush-btrfs-129)
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wait_extent_bit fs/btrfs/extent-io-tree.c:905 [inline]
btrfs_lock_extent_bits+0x59c/0x700 fs/btrfs/extent-io-tree.c:2008
btrfs_lock_extent fs/btrfs/extent-io-tree.h:152 [inline]
btrfs_invalidate_folio+0x440/0xc00 fs/btrfs/inode.c:7718
extent_writepage fs/btrfs/extent_io.c:1848 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2552 [inline]
btrfs_writepages+0x12f3/0x2410 fs/btrfs/extent_io.c:2684
do_writepages+0x32e/0x550 mm/page-writeback.c:2571
__writeback_single_inode+0x133/0x10e0 fs/fs-writeback.c:1764
writeback_sb_inodes+0x97f/0x1980 fs/fs-writeback.c:2056
wb_writeback+0x445/0xb00 fs/fs-writeback.c:2241
wb_do_writeback fs/fs-writeback.c:2388 [inline]
wb_workfn+0x3fd/0xf20 fs/fs-writeback.c:2428
process_one_work+0x98b/0x1630 kernel/workqueue.c:3318
process_scheduled_works kernel/workqueue.c:3401 [inline]
worker_thread+0xb49/0x1140 kernel/workqueue.c:3482
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
INFO: task syz.0.145:8523 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.145 state:D stack:22752 pid:8523 tgid:8522 ppid:5850 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wb_wait_for_completion+0x3e8/0x790 fs/fs-writeback.c:227
__writeback_inodes_sb_nr+0x24c/0x2d0 fs/fs-writeback.c:2847
try_to_writeback_inodes_sb+0x9a/0xc0 fs/fs-writeback.c:2895
btrfs_start_delalloc_flush fs/btrfs/transaction.c:2182 [inline]
btrfs_commit_transaction+0x813/0x2fc0 fs/btrfs/transaction.c:2371
btrfs_sync_file+0xdf4/0x1230 fs/btrfs/file.c:1822
generic_write_sync include/linux/fs.h:2663 [inline]
btrfs_do_write_iter+0x6a9/0x840 fs/btrfs/file.c:1473
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x629/0xba0 fs/read_write.c:688
ksys_write+0x156/0x270 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5a0bdece59
RSP: 002b:00007f5a0b446028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f5a0c065fa0 RCX: 00007f5a0bdece59
RDX: 000000000000029f RSI: 0000200000000200 RDI: 0000000000000004
RBP: 00007f5a0be82d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5a0c066038 R14: 00007f5a0c065fa0 R15: 00007ffe149206b8
</TASK>
INFO: task syz.0.145:8539 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.145 state:D stack:23704 pid:8539 tgid:8522 ppid:5850 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wait_current_trans+0x39f/0x590 fs/btrfs/transaction.c:536
start_transaction+0xbd8/0x1820 fs/btrfs/transaction.c:716
clone_copy_inline_extent fs/btrfs/reflink.c:299 [inline]
btrfs_clone+0x1316/0x2540 fs/btrfs/reflink.c:574
btrfs_clone_files+0x271/0x3f0 fs/btrfs/reflink.c:795
btrfs_remap_file_range+0x76b/0x1320 fs/btrfs/reflink.c:948
vfs_clone_file_range+0x435/0x7b0 fs/remap_range.c:403
ioctl_file_clone fs/ioctl.c:239 [inline]
ioctl_file_clone_range fs/ioctl.c:257 [inline]
do_vfs_ioctl+0xe15/0x1540 fs/ioctl.c:544
__do_sys_ioctl fs/ioctl.c:595 [inline]
__se_sys_ioctl+0x82/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5a0bdece59
RSP: 002b:00007f5a0b425028 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f5a0c066090 RCX: 00007f5a0bdece59
RDX: 00002000000000c0 RSI: 000000004020940d RDI: 0000000000000004
RBP: 00007f5a0be82d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5a0c066128 R14: 00007f5a0c066090 R15: 00007ffe149206b8
</TASK>--- fs/btrfs/reflink.c | 101 +++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 44 deletions(-)
fs/btrfs/reflink.c +57 -44
@@ -179,10 +179,12 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,struct btrfs_drop_extents_args drop_args = {0 };int ret;struct btrfs_key key; +bool copied_inline_to_page = false;if (new_key->offset >0 ) { ret =copy_inline_to_page (inode, new_key->offset, inline_data, size, datal, comp_type); + copied_inline_to_page = (ret ==0 ); goto out; }
@@ -288,6 +290,60 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,btrfs_abort_transaction (trans, ret); out:if (!ret && !trans) { +if (copied_inline_to_page && + new_key->offset + datal >i_size_read (&inode->vfs_inode)) { +/* +* If we copied the inline extent data to a page/folio +* beyond the i_size of the destination inode, then we +* need to increase the i_size before we start a +* transaction to update the inode item. This is to +* prevent a deadlock when the flushoncommit mount +* option is used, which happens like this: +* +* 1) Task A clones an inline extent from inode X to an +* offset of inode Y that is beyond Y's current +* i_size. This means we copied the inline extent's +* data to a folio of inode Y that is beyond its EOF, +* using the call above to copy_inline_to_page(); +* +* 2) Task B starts a transaction commit and calls +* btrfs_start_delalloc_flush() to flush delalloc; +* +* 3) The delalloc flushing sees the new dirty folio of +* inode Y and when it attempts to flush it, it ends +* up at extent_writepage() and sees that the offset +* of the folio is beyond the i_size of inode Y, so +* it attempts to invalidate the folio by calling +* folio_invalidate(), which ends up at btrfs' folio +* invalidate callback - btrfs_invalidate_folio(). +* There it tries to lock the folio's range in inode +* Y's extent io tree, but it blocks since it's +* currently locked by task A - during reflink we +* lock the inodes and the source and destination +* ranges after flushing all delalloc and waiting for +* ordered extent completion - after that we don't +* expect to have dirty folios in the ranges, the +* exception is if we have to copy an inline extent's +* data (because the destination offset is not zero); +* +* 4) Task A then does the 'goto out' below and attempts +* to start a transaction to update the inode item, +* and then it's blocked since the current +* transaction is in the TRANS_STATE_COMMIT_START +* state. Therefore task A has to wait for the +* current transaction to become unblocked (its +* state >= TRANS_STATE_UNBLOCKED). +* +* This leads to a deadlock - the task committing the +* transaction waiting for the delalloc flushing which +* is blocked during folio invalidation on the inode's +* extent lock and the reflink task waiting for the +* current transaction to be unblocked so that it can +* start a new one to update the inode item (while +* holding the extent lock). +*/ +i_size_write (&inode->vfs_inode, new_key->offset + datal); + }/* * No transaction here means we copied the inline extent into a * page of the destination inode.
@@ -320,50 +376,7 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode, ret =copy_inline_to_page (inode, new_key->offset, inline_data, size, datal, comp_type); - -/* -* If we copied the inline extent data to a page/folio beyond the i_size -* of the destination inode, then we need to increase the i_size before -* we start a transaction to update the inode item. This is to prevent a -* deadlock when the flushoncommit mount option is used, which happens -* like this: -* -* 1) Task A clones an inline extent from inode X to an offset of inode -* Y that is beyond Y's current i_size. This means we copied the -* inline extent's data to a folio of inode Y that is beyond its EOF, -* using the call above to copy_inline_to_page(); -* -* 2) Task B starts a transaction commit and calls -* btrfs_start_delalloc_flush() to flush delalloc; -* -* 3) The delalloc flushing sees the new dirty folio of inode Y and when -* it attempts to flush it, it ends up at extent_writepage() and sees -* that the offset of the folio is beyond the i_size of inode Y, so -* it attempts to invalidate the folio by calling folio_invalidate(), -* which ends up at btrfs' folio invalidate callback - -* btrfs_invalidate_folio(). There it tries to lock the folio's range -* in inode Y's extent io tree, but it blocks since it's currently -* locked by task A - during reflink we lock the inodes and the -* source and destination ranges after flushing all delalloc and -* waiting for ordered extent completion - after that we don't expect -* to have dirty folios in the ranges, the exception is if we have to -* copy an inline extent's data (because the destination offset is -* not zero); -* -* 4) Task A then does the 'goto out' below and attempts to start a -* transaction to update the inode item, and then it's blocked since -* the current transaction is in the TRANS_STATE_COMMIT_START state. -* Therefore task A has to wait for the current transaction to become -* unblocked (its state >= TRANS_STATE_UNBLOCKED). -* -* This leads to a deadlock - the task committing the transaction -* waiting for the delalloc flushing which is blocked during folio -* invalidation on the inode's extent lock and the reflink task waiting -* for the current transaction to be unblocked so that it can start a -* a new one to update the inode item (while holding the extent lock). -*/ -if (ret ==0 && new_key->offset + datal >i_size_read (&inode->vfs_inode)) -i_size_write (&inode->vfs_inode, new_key->offset + datal); + copied_inline_to_page = (ret ==0 ); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/2077 btrfs: lzo: reject compressed segment that overflows the compressed input
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit b0d27d43791b7a3057c3c4aedf9b4aa033d37c46 ]
lzo_decompress_bio() validates each on-disk segment length seg_len only against the workspace cbuf size, not against the compressed input size (compressed_len, the total folio bytes of the bio). A crafted extent can carry a segment whose seg_len passes the cbuf check but runs past the end of the bio, so copy_compressed_segment() walks off the last folio:get_current_folio() then returns the NULL folio from bio_next_folio(), and with CONFIG_BTRFS_ASSERT disabled (default) folio_size(NULL) faults.
BUG: KASAN: null-ptr-deref in lzo_decompress_bio (fs/btrfs/lzo.c:383) Read of size 8 at addr 0000000000000000 by task kworker/u8:1/29 Workqueue: btrfs-endio simple_end_io_work kasan_report (mm/kasan/report.c:590) lzo_decompress_bio (fs/btrfs/lzo.c:383) end_bbio_compressed_read (fs/btrfs/compression.c:1065) btrfs_bio_end_io (fs/btrfs/bio.c:135) btrfs_check_read_bio (fs/btrfs/bio.c:180 fs/btrfs/bio.c:285) simple_end_io_work process_one_work worker_thread
Reject any segment whose payload would extend beyond compressed_len before copying it, treating it as corruption like the other on-disk validation failures in this function.
--- fs/btrfs/lzo.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/btrfs/lzo.c +11 -0
@@ -491,6 +491,17 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)return -EIO ; } +/* The segment must not extend beyond the compressed input. */ +if (unlikely (cur_in + seg_len > compressed_len)) { +struct btrfs_inode *inode = cb->bbio.inode; + +btrfs_err (fs_info, +"lzo segment overflows compressed input, root %llu inode %llu offset %llu cur_in %u len %u compressed len %u" , +btrfs_root_id (inode->root),btrfs_ino (inode), + cb->start, cur_in, seg_len, compressed_len); +return -EUCLEAN ; + } +/* Copy the compressed segment payload into workspace */ copy_compressed_segment (cb, &fi, &cur_folio_index, workspace->cbuf, seg_len, &cur_in);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/2077 ixgbe: do not configure xps for XDP queues
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larysa Zaremba <[email protected]>
[ Upstream commit 7bd4355272de34c2e90e34b72c5613736d03c32b ]
netif_set_xps_queue() should not be called for an XDP Tx queue, since such queues are not netdev-exposed. On systems with number of CPUs >=64, on E610 adapter, netdev is configured with maximum number queue pairs being 63 (due to MSI-X assignment), but configuring XDP results in 64 XDP queues.
So, during XDP program load, when netif_set_xps_queue() is called for the last XDP queue, we get a WARNING with a call trace and KASAN report afterwards (if enabled).
[ 2012.699800] WARNING: net/core/dev.c:2854 at __netif_set_xps_queue+0x116a/0x1e40, CPU#36: xdpsock/103668 [...] [ 2012.700029] RIP: 0010:__netif_set_xps_queue+0x116a/0x1e40 [ 2012.700035] Code: b6 34 06 48 89 f8 83 e0 07 83 c0 01 40 38 f0 7c 09 40 84 f6 0f 85 03 0a 00 00 0f b7 44 24 40 66 43 89 44 6a 18 e9 01 fb ff ff <0f> 0b e9 f2 ee ff ff 44 8b 44 24 44 45 85 c0 74 50 4d 85 e4 0f 84 [ 2012.700040] RSP: 0018:ffff8882369aeb28 EFLAGS: 00010246 [ 2012.700046] RAX: 0000000000000000 RBX: 000000000000003f RCX: 0000000000000000 [ 2012.700050] RDX: 1ffff1111da3d891 RSI: ffff888120e34250 RDI: ffff8888ed1ec488 [ 2012.700054] RBP: ffff888913281560 R08: 0000000000000000 R09: ffff8888ed1ec000 [ 2012.700058] R10: ffff8888a2e83180 R11: 0000000000000000 R12: 0000000000007fa8 [ 2012.700061] R13: 000000000000003f R14: ffff888120e34854 R15: ffff8889132817c8 [ 2012.700065] FS: 00007fc8ea9ff740(0000) GS:ffff88884cefe000(0000) knlGS:0000000000000000 [ 2012.700069] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2012.700073] CR2: 00007f81c8000020 CR3: 00000002299f8006 CR4: 00000000007726f0 [ 2012.700077] PKRU: 55555554 [ 2012.700080] Call Trace: [ 2012.700084] <TASK> [ 2012.700087] ? ktime_get+0x61/0x150 [ 2012.700097] ? usleep_range_state+0x133/0x1b0 [ 2012.700108] ? __pfx_usleep_range_state+0x10/0x10 [ 2012.700114] netif_set_xps_queue+0x31/0x50 [ 2012.700119] ixgbe_configure_tx_ring+0x472/0x920 [ixgbe] [...] [ 2012.700486] ixgbe_xdp+0x38f/0x750 [ixgbe]
[...]
[ 2012.701094] BUG: KASAN: slab-out-of-bounds in __netif_set_xps_queue+0x1ac5/0x1e40 [ 2012.701100] Write of size 4 at addr ffff88888d43cff8 by task xdpsock/103668
Skip XPS configuration for XDP Tx queues.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
@@ -3958,7 +3958,8 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, }/* initialize XPS */ -if (!test_and_set_bit (__IXGBE_TX_XPS_INIT_DONE, ring->state)) { +if (!ring_is_xdp (ring) && + !test_and_set_bit (__IXGBE_TX_XPS_INIT_DONE, ring->state)) {struct ixgbe_q_vector *q_vector = ring->q_vector;if (q_vector)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/2077 igc: skip RX timestamp header for frame preemption verification
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: KhaiWenTan <[email protected]>
[ Upstream commit 38b7a274cf84af9b1f4b602b8e2741565b81947b ]
When RX hardware timestamping is enabled, a 16-byte inline timestamp header is added to the start of the packet buffer, causing FPE handshake verification to fail.
Because an incorrect packet buffer is passed to igc_fpe_handle_mpacket(), the mem_is_zero() check inspects the timestamp metadata instead of the actual mPacket payload. As a result, valid Verify/Response mPackets can be missed when inline RX timestamps are present.
Pass pktbuf + pkt_offset to igc_fpe_handle_mpacket() so it inspects the actual mPacket payload instead of the timestamp header.
--- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -2649,7 +2649,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) }if (igc_fpe_is_pmac_enabled (adapter) && -igc_fpe_handle_mpacket (adapter, rx_desc, size, pktbuf)) { +igc_fpe_handle_mpacket (adapter, rx_desc, size, pktbuf + pkt_offset)) {/* Advance the ring next-to-clean */ igc_is_non_eop (rx_ring, rx_desc); cleaned_count++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/2077 ASoC: sma1307: Fix uevent string leaks in fault worker
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit a750ca72af72dde9744468fdca6eda0b698a1cfc ]
sma1307_check_fault_worker() stores dynamically allocated uevent strings in envp[0]. Several fault conditions are checked in sequence, so a later fault can overwrite envp[0] before the final kfree() and leak the previous allocation.
The same flow can leave an OT1 volume entry in envp[1] while envp[0] has been overwritten by a later non-OT1 fault, causing an inconsistent uevent payload.
Use static STATUS strings and a stack buffer for the optional VOLUME entry. This removes the allocations from the worker and keeps VOLUME tied only to the OT1 events that produce it.
--- sound/soc/codecs/sma1307.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)
sound/soc/codecs/sma1307.c +21 -14
@@ -1592,6 +1592,7 @@ static void sma1307_check_fault_worker(struct work_struct *work)struct sma1307_priv *sma1307 = container_of(work, struct sma1307_priv, check_fault_work.work);unsigned int status1_val, status2_val; +char volume[sizeof ("VOLUME=0x12345678" )];char *envp[3 ] = {NULL ,NULL ,NULL };if (sma1307->tsdw_cnt)
@@ -1607,7 +1608,7 @@ static void sma1307_check_fault_worker(struct work_struct *work)if (~status1_val &SMA1307_OT1_OK_STATUS ) {dev_crit (sma1307->dev,"%s: OT1(Over Temperature Level 1)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT1" ); + envp[0 ] ="STATUS=OT1" ;if (sma1307->sw_ot1_prot) {/* Volume control (Current Volume -3dB) */ if ((sma1307->cur_vol +6 ) <=0xFA ) {
@@ -1615,8 +1616,9 @@ static void sma1307_check_fault_worker(struct work_struct *work)regmap_write (sma1307->regmap,SMA1307_0A_SPK_VOL , sma1307->cur_vol); - envp[1 ] =kasprintf (GFP_KERNEL , -"VOLUME=0x%02X" , sma1307->cur_vol); +snprintf (volume,sizeof (volume), +"VOLUME=0x%02X" , sma1307->cur_vol); + envp[1 ] = volume; } } sma1307->tsdw_cnt++;
@@ -1625,48 +1627,53 @@ static void sma1307_check_fault_worker(struct work_struct *work) SMA1307_0A_SPK_VOL, sma1307->init_vol); sma1307->tsdw_cnt =0 ; sma1307->cur_vol = sma1307->init_vol; - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT1_CLEAR" ); - envp[1 ] =kasprintf (GFP_KERNEL , -"VOLUME=0x%02X" , sma1307->cur_vol); + envp[0 ] ="STATUS=OT1_CLEAR" ; +snprintf (volume,sizeof (volume),"VOLUME=0x%02X" , + sma1307->cur_vol); + envp[1 ] = volume; }if (~status1_val &SMA1307_OT2_OK_STATUS ) {dev_crit (sma1307->dev,"%s: OT2(Over Temperature Level 2)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT2" ); + envp[0 ] ="STATUS=OT2" ; + envp[1 ] =NULL ; }if (status1_val &SMA1307_UVLO_STATUS ) {dev_crit (sma1307->dev,"%s: UVLO(Under Voltage Lock Out)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=UVLO" ); + envp[0 ] ="STATUS=UVLO" ; + envp[1 ] =NULL ; }if (status1_val &SMA1307_OVP_BST_STATUS ) {dev_crit (sma1307->dev,"%s: OVP_BST(Over Voltage Protection)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OVP_BST" ); + envp[0 ] ="STATUS=OVP_BST" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_OCP_SPK_STATUS ) {dev_crit (sma1307->dev,"%s: OCP_SPK(Over Current Protect SPK)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OCP_SPK" ); + envp[0 ] ="STATUS=OCP_SPK" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_OCP_BST_STATUS ) {dev_crit (sma1307->dev,"%s: OCP_BST(Over Current Protect Boost)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OCP_BST" ); + envp[0 ] ="STATUS=OCP_BST" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_CLK_MON_STATUS ) {dev_crit (sma1307->dev,"%s: CLK_FAULT(No clock input)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=CLK_FAULT" ); + envp[0 ] ="STATUS=CLK_FAULT" ; + envp[1 ] =NULL ; }if (envp[0 ] !=NULL ) {if (kobject_uevent_env (sma1307->kobj,KOBJ_CHANGE , envp))dev_err (sma1307->dev,"%s: Error sending uevent\n" , __func__); -kfree (envp[0 ]); -kfree (envp[1 ]); }if (sma1307->check_fault_status) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/2077 IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit bade9a3150d44ed20b8c6484c4c8a943b7289abb ]
Sashiko noticed mlx4 was using whatever random access flags were provided when IB_MR_REREG_ACCESS is not used. Since IB_MR_REREG_TRANS needs access_flags it used the random ones which means it doesn't work sensibly if userspace provides only IB_MR_REREG_TRANS.
Keep track of the current access_flag of the MR and use it if the user does not specify one.
Also fixup a little confusion around mmr.access, it is the HW access flags so the convert_access() was missing. But nothing reads this by the time rereg_mr can happen.
--- drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 + drivers/infiniband/hw/mlx4/mr.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -0
@@ -135,6 +135,7 @@ struct mlx4_ib_mr {dma_addr_t page_map;u32 npages;u32 max_pages; +int access_flags;struct mlx4_mr mmr;struct ib_umem *umem;size_t page_map_size;
drivers/infiniband/hw/mlx4/mr.c +7 -2
@@ -181,6 +181,7 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,if (err) goto err_mr; + mr->access_flags = access_flags; mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; mr->ibmr.page_size =1U << shift;
@@ -241,6 +242,8 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,if (err) goto release_mpt_entry; + }else { + mr_access_flags = mmr->access_flags; }if (flags &IB_MR_REREG_TRANS ) {
@@ -282,8 +285,10 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,* return a failure. But dereg_mr will free the resources. */ err =mlx4_mr_hw_write_mpt (dev->dev, &mmr->mmr, pmpt_entry); -if (!err && flags &IB_MR_REREG_ACCESS ) - mmr->mmr.access = mr_access_flags; +if (!err && flags &IB_MR_REREG_ACCESS ) { + mmr->access_flags = mr_access_flags; + mmr->mmr.access =convert_access (mr_access_flags); + } release_mpt_entry:mlx4_mr_hw_put_mpt (dev->dev, pmpt_entry);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/2077 NFSD: Handle layout stid in nfsd4_drop_revoked_stid()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 86b9898920a6d02b4149f4fef9efd77b8aa3b9ca ]
nfsd4_drop_revoked_stid() has no SC_TYPE_LAYOUT case, so when a client sends FREE_STATEID for an admin-revoked layout stid, the default branch releases cl_lock and returns without unhashing or releasing the stid. The stid remains in the IDR and on the per-client list until the client is destroyed.
Remove the layout stid from the per-client list and call nfs4_put_stid() to drop the creation reference. When the refcount reaches zero, nfsd4_free_layout_stateid() handles the remaining cleanup: cancelling the fence worker, removing from the per-file list, and freeing the slab object.
--- fs/nfsd/nfs4state.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/nfsd/nfs4state.c +7 -0
@@ -5056,6 +5056,7 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s) {struct nfs4_client *cl = s->sc_client;LIST_HEAD (reaplist); +struct nfs4_layout_stateid *ls;struct nfs4_ol_stateid *stp;struct nfs4_delegation *dp;bool unhashed;
@@ -5081,6 +5082,12 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)spin_unlock (&cl->cl_lock);nfs4_put_stid (s);break ; +case SC_TYPE_LAYOUT : + ls =layoutstateid (s); +list_del_init (&ls->ls_perclnt); +spin_unlock (&cl->cl_lock); +nfs4_put_stid (s); +break ;default :spin_unlock (&cl->cl_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/2077 lockd: Stop warning on nlm__int__drop_reply in !V4 cast_status
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 5cca6056f2bae9be14566e0f7f6e351103a6aef3 ]
cast_status folds internal lock-daemon sentinels into NLMv1/v3 wire status codes. The !CONFIG_LOCKD_V4 variant warns when an unrecognized status falls into the internal-sentinel range, gated by be32_to_cpu(status) >= 30000.
nlm__int__drop_reply is defined as cpu_to_be32(30000), so it sits at the lower edge of that range and trips pr_warn_once ("lockd: unhandled internal status %u"). The status is returned unchanged so the reply is still dropped, but every dropped reply on a !CONFIG_LOCKD_V4 build emits a spurious warning.
Compare against nlm__int__drop_reply directly so the warning still catches the genuinely unexpected sentinels deadlock, stale_fh, and failed (30001 through 30003) but excludes the legitimate dropped-reply marker.
--- fs/lockd/svcproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lockd/svcproc.c +1 -1
@@ -49,7 +49,7 @@ static inline __be32 cast_status(__be32 status) status = nlm_lck_denied_nolocks;break ;default : -if (be32_to_cpu (status) >=30000 ) +if (be32_to_cpu (status) >be32_to_cpu (nlm__int__drop_reply))pr_warn_once ("lockd: unhandled internal status %u\n" ,be32_to_cpu (status));break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/2077 lockd: Translate nlm__int__deadlock in __nlm4svc_proc_lock_msg()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 2175ca75882e346c9d8741a2196693d70f635340 ]
When nlmsvc_lock() detects a deadlock it returns the internal sentinel nlm__int__deadlock (30001), which version-specific handlers must translate to a wire-valid status before the reply is encoded. The xdrgen LOCK_MSG handler stores the sentinel unmodified in resp->status; the LOCK_RES callback then places 30001 on the v4 wire, where the client rejects the reply.
Commit 9e0d0c619407 ("lockd: Introduce nlm__int__deadlock") established the translation boundary and updated the synchronous v4 path nlm4svc_do_lock(), but the xdrgen LOCK_MSG handler added later in commit b2be4e28c23a ("lockd: Use xdrgen XDR functions for the NLMv4 LOCK_MSG procedure") missed the corresponding remap. Apply the same translation in __nlm4svc_proc_lock_msg() so deadlock results are reported as nlm4_deadlock on LOCK_RES.
--- fs/lockd/svc4proc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/lockd/svc4proc.c +2 -0
@@ -669,6 +669,8 @@ __nlm4svc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_res *resp) resp->status =nlmsvc_lock (rqstp, file, host, &argp->lock, argp->xdrgen.block, &resp->cookie, argp->xdrgen.reclaim); +if (resp->status == nlm__int__deadlock) + resp->status = nlm4_deadlock;nlmsvc_release_lockowner (&argp->lock); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/2077 lockd: Do not monitor when looking up the LOCK_MSG callback host
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit b3d200166a35305ac77941845dcab99bb6badd76 ]
A LOCK_MSG handler that fails to obtain a host returns rpc_system_err, which causes the dispatcher to send an RPC-level error rather than an NLM LOCK_RES denial. Before the xdrgen conversion, the outer host lookup was unmonitored, so an NSM upcall failure was reported back to the client through LOCK_RES with status nlm_lck_denied_nolocks generated by the inner helper.
The xdrgen conversion replaced the unmonitored lookup with nlm4svc_lookup_host(..., true). When nsm_monitor() fails, the outer lookup now returns NULL, so the procedure short-circuits to rpc_system_err and __nlm4svc_proc_lock_msg() never runs. The client therefore receives no LOCK_RES, regressing the legacy behavior.
The inner helper still performs a monitored lookup while building the LOCK_RES, so the outer call only needs an unmonitored host reference for the callback path. Pass false here to restore the previous semantics.
--- fs/lockd/svc4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lockd/svc4proc.c +1 -1
@@ -699,7 +699,7 @@ static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp)struct nlm4_lockargs_wrapper *argp = rqstp->rq_argp;struct nlm_host *host; - host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, true); + host =nlm4svc_lookup_host (rqstp, argp->xdrgen.alock.caller_name, false);if (!host)return rpc_system_err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/2077 lockd: Avoid hashing uninitialized bytes in nlm4svc_lookup_file()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6e4c62caecf792e8a15ad9bc7f371e57c17e3302 ]
file_hash() digests the first LOCKD_FH_HASH_SIZE bytes of nfs_fh.data when bucketing nlm_files[], independent of fh.size. Commit 3de744ee4e45 ("lockd: Use xdrgen XDR functions for the NLMv4 TEST procedure") set .pc_argzero to zero for the converted procedures and moved file-handle population into nlm4svc_lookup_file(), which copies only xdr_lock->fh.len bytes into lock->fh.data.
When an NLMv4 client presents a file handle shorter than LOCKD_FH_HASH_SIZE, bytes fh.len..31 retain whatever the argument buffer held from an earlier request. The same wire handle then hashes to different buckets across calls; nlm_lookup_file() misses the existing nlm_file entry, and lock-state lookups fail.
Zero only the tail bytes that file_hash() would otherwise consume. Handles of LOCKD_FH_HASH_SIZE or larger already populate every byte that file_hash() reads.
--- fs/lockd/lockd.h | 8 ++++++++ fs/lockd/svc4proc.c | 3 +++ fs/lockd/svcsubs.c | 3 +-- 3 files changed, 12 insertions(+), 2 deletions(-)
fs/lockd/lockd.h +8 -0
@@ -52,6 +52,14 @@*/ #define LOCKD_DFLT_TIMEO 10 +/* +* Number of leading bytes of nfs_fh.data that file_hash() +* digests when bucketing nlm_files[]. Sized for historical +* NFSv2 handles; nfs_fh.data must be initialized at least +* this far before lookup, regardless of fh.size. +*/ +#define LOCKD_FH_HASH_SIZE 32 +/* error codes new to NLMv4 */ #define nlm4_deadlock cpu_to_be32(NLM_DEADLCK)#define nlm4_rofs cpu_to_be32(NLM_ROFS)
fs/lockd/svc4proc.c +3 -0
@@ -157,6 +157,9 @@ nlm4svc_lookup_file(struct svc_rqst *rqstp, struct nlm_host *host,return nlm_lck_denied_nolocks; lock->fh.size = xdr_lock->fh.len;memcpy (lock->fh.data, xdr_lock->fh.data, xdr_lock->fh.len); +if (xdr_lock->fh.len <LOCKD_FH_HASH_SIZE ) +memset (lock->fh.data + xdr_lock->fh.len,0 , +LOCKD_FH_HASH_SIZE - xdr_lock->fh.len); lock->oh.len = xdr_lock->oh.len; lock->oh.data = xdr_lock->oh.data;
fs/lockd/svcsubs.c +1 -2
@@ -17,7 +17,6 @@#include <linux/sunrpc/addr.h> #include <linux/module.h> #include <linux/mount.h> -#include <uapi/linux/nfs2.h> #include "lockd.h" #include "share.h"
@@ -67,7 +66,7 @@ static inline unsigned int file_hash(struct nfs_fh *f) {unsigned int tmp=0 ;int i; -for (i=0 ; i<NFS2_FHSIZE ;i++) +for (i =0 ; i <LOCKD_FH_HASH_SIZE ; i++) tmp += f->data[i];return tmp & (FILE_NRHASH -1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/2077 spi: meson-spifc: fix runtime PM leak on remove
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 606c0826bd90384a54571c0c5475ca41f50164ea ]
pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error. meson_spifc_remove() uses it to resume the controller before disabling runtime PM, but never drops the usage counter again.
Balance the get with pm_runtime_put_noidle() after disabling runtime PM, matching the teardown pattern used by other SPI controller drivers.
Found by static analysis. I do not have hardware to test this.
--- drivers/spi/spi-meson-spifc.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-meson-spifc.c +1 -0
@@ -351,6 +351,7 @@ static void meson_spifc_remove(struct platform_device *pdev) {pm_runtime_get_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/2077 ASoC: codecs: aw88261: fix incorrect masks for boost regs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 79c053a1ff9d3ab31cefbc791e8d7816ba830491 ]
The boost-related register fields used in aw88261_reg_force_set use the exact same definitions as the rest of the fields, where the mask must be inverted when passing it to regmap_update_bits, but they weren't inverted here.
--- sound/soc/codecs/aw88261.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/codecs/aw88261.c +6 -6
@@ -284,22 +284,22 @@ static void aw88261_reg_force_set(struct aw88261 *aw88261)if (aw88261->frcset_en ==AW88261_FRCSET_ENABLE ) {/* set FORCE_PWM */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL3_REG , -AW88261_FORCE_PWM_MASK ,AW88261_FORCE_PWM_FORCEMINUS_PWM_VALUE ); + ~AW88261_FORCE_PWM_MASK ,AW88261_FORCE_PWM_FORCEMINUS_PWM_VALUE );/* set BOOST_OS_WIDTH */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL5_REG , -AW88261_BST_OS_WIDTH_MASK ,AW88261_BST_OS_WIDTH_50NS_VALUE ); + ~AW88261_BST_OS_WIDTH_MASK ,AW88261_BST_OS_WIDTH_50NS_VALUE );/* set BURST_LOOPR */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL6_REG , -AW88261_BST_LOOPR_MASK ,AW88261_BST_LOOPR_340K_VALUE ); + ~AW88261_BST_LOOPR_MASK ,AW88261_BST_LOOPR_340K_VALUE );/* set RSQN_DLY */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL7_REG , -AW88261_RSQN_DLY_MASK ,AW88261_RSQN_DLY_35NS_VALUE ); + ~AW88261_RSQN_DLY_MASK ,AW88261_RSQN_DLY_35NS_VALUE );/* set BURST_SSMODE */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL8_REG , -AW88261_BURST_SSMODE_MASK ,AW88261_BURST_SSMODE_FAST_VALUE ); + ~AW88261_BURST_SSMODE_MASK ,AW88261_BURST_SSMODE_FAST_VALUE );/* set BST_BURST */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL9_REG , -AW88261_BST_BURST_MASK ,AW88261_BST_BURST_30MA_VALUE ); + ~AW88261_BST_BURST_MASK ,AW88261_BST_BURST_30MA_VALUE ); }else {dev_dbg (aw88261->aw_pa->dev,"needn't set reg value" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/2077 bpf: Cancel special fields on map value recycle
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Suess <[email protected]>
[ Upstream commit a3a81d247651218e47153f2d2afd7aee236726fd ]
Map update and delete paths currently call bpf_obj_free_fields() when a value is being replaced or recycled. That makes field destruction depend on the context of the update/delete operation. For tracing programs this can include NMI context, where referenced kptr destructors, uptr unpinning, and graph root destruction are not generally safe.
Introduce bpf_obj_cancel_fields() for the reusable-value path. It only performs NMI-safe cleanup for timer, workqueue, and task_work fields. Fields that need full destruction are left attached to the recycled value and are destroyed by the final cleanup path instead.
Switch array and hashtab update/delete/recycle paths to this cancel helper. Keep bpf_obj_free_fields() for final map destruction and for bpf_mem_alloc destructors. Preallocated hashtabs do not have allocator destructors, so teardown continues to walk the normal and extra elements and fully destroy their fields.
This deliberately relaxes the eager-free semantics of map update/delete for special fields. Programs that relied on a recycled map slot becoming empty immediately after update/delete were relying on behavior that cannot be implemented safely from every BPF execution context without offloading arbitrary destructors.
There is a chance this change breaks programs making assumptions regarding the eager freeing of fields. If so, we can relax semantics to cancellation only when irqs_disabled() is true in the future. However, theoretically, map values that get reused eagerly already have weaker guarantees as parallel users can recreate freed fields before the new element becomes visible again.
--- include/linux/bpf.h | 1 + kernel/bpf/arraymap.c | 8 +-- kernel/bpf/hashtab.c | 32 +++++---- kernel/bpf/syscall.c | 5 ++ .../selftests/bpf/prog_tests/htab_update.c | 4 +- .../selftests/bpf/prog_tests/linked_list.c | 33 ++++----- .../selftests/bpf/prog_tests/map_kptr.c | 10 +-- .../bpf/prog_tests/refcounted_kptr.c | 8 ++- .../testing/selftests/bpf/progs/htab_update.c | 4 +- .../testing/selftests/bpf/progs/linked_list.c | 71 +++++++++++++++++++ .../selftests/bpf/progs/refcounted_kptr.c | 20 +++++- 11 files changed, 146 insertions(+), 50 deletions(-)
include/linux/bpf.h +1 -0
@@ -2596,6 +2596,7 @@ bool btf_record_equal(const struct btf_record *rec_a, const struct btf_record *rvoid bpf_obj_free_timer (const struct btf_record *rec,void *obj);void bpf_obj_free_workqueue (const struct btf_record *rec,void *obj);void bpf_obj_free_task_work (const struct btf_record *rec,void *obj); +void bpf_obj_cancel_fields (struct bpf_map *map,void *obj);void bpf_obj_free_fields (const struct btf_record *rec,void *obj);void __bpf_obj_drop_impl (void *p,const struct btf_record *rec,bool percpu);
kernel/bpf/arraymap.c +4 -4
@@ -386,7 +386,7 @@ static long array_map_update_elem(struct bpf_map *map, void *key, void *value,if (array->map.map_type ==BPF_MAP_TYPE_PERCPU_ARRAY ) { val =this_cpu_ptr (array->pptrs[index & array->index_mask]);copy_map_value (map, val, value); -bpf_obj_free_fields (array->map.record, val); +bpf_obj_cancel_fields (map, val); }else { val = array->value + (u64 )array->elem_size * (index & array->index_mask);
@@ -394,7 +394,7 @@ static long array_map_update_elem(struct bpf_map *map, void *key, void *value,copy_map_value_locked (map, val, value, false); elsecopy_map_value (map ,val ,value ); -bpf_obj_free_fields (array->map.record, val); +bpf_obj_cancel_fields (map, val); }return 0 ; }
@@ -434,14 +434,14 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value, cpu = map_flags >>32 ; ptr =per_cpu_ptr (pptr, cpu);copy_map_value (map, ptr, value); -bpf_obj_free_fields (array->map.record, ptr); +bpf_obj_cancel_fields (map, ptr); goto unlock; }for_each_possible_cpu (cpu) { ptr =per_cpu_ptr (pptr, cpu); val = (map_flags &BPF_F_ALL_CPUS ) ? value : value + size * cpu;copy_map_value (map, ptr, val); -bpf_obj_free_fields (array->map.record, ptr); +bpf_obj_cancel_fields (map, ptr); } unlock:rcu_read_unlock ();
kernel/bpf/hashtab.c +18 -14
@@ -242,6 +242,10 @@ static void htab_free_prealloced_fields(struct bpf_htab *htab)if (IS_ERR_OR_NULL (htab->map.record))return ; +/* +* Preallocated maps do not have a bpf_mem_alloc destructor, so fully +* destroy every element, including the extra elements. +*/ if (htab_has_extra_elems (htab)) num_entries +=num_possible_cpus ();for (i =0 ; i < num_entries; i++) {
@@ -834,8 +838,8 @@ static int htab_lru_map_gen_lookup(struct bpf_map *map,return insn - insn_buf; } -static void check_and_free_fields (struct bpf_htab *htab, -struct htab_elem *elem) +static void check_and_cancel_fields (struct bpf_htab *htab, +struct htab_elem *elem) {if (IS_ERR_OR_NULL (htab->map.record))return ;
@@ -845,11 +849,11 @@ static void check_and_free_fields(struct bpf_htab *htab,int cpu;for_each_possible_cpu (cpu) -bpf_obj_free_fields (htab->map.record,per_cpu_ptr (pptr, cpu)); +bpf_obj_cancel_fields (&htab->map,per_cpu_ptr (pptr, cpu)); }else {void *map_value =htab_elem_value (elem, htab->map.key_size); -bpf_obj_free_fields (htab->map.record, map_value); +bpf_obj_cancel_fields (&htab->map, map_value); } }
@@ -884,7 +888,7 @@ static bool htab_lru_map_delete_node(void *arg, struct bpf_lru_node *node)htab_unlock_bucket (b, flags);if (l == tgt_l) -check_and_free_fields (htab, l); +check_and_cancel_fields (htab, l);return l == tgt_l; }
@@ -949,7 +953,7 @@ static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key)static void htab_elem_free (struct bpf_htab *htab,struct htab_elem *l) { -check_and_free_fields (htab, l); +check_and_cancel_fields (htab, l);if (htab->map.map_type ==BPF_MAP_TYPE_PERCPU_HASH )bpf_mem_cache_free (&htab->pcpu_ma, l->ptr_to_pptr);
@@ -1002,7 +1006,7 @@ static void free_htab_elem(struct bpf_htab *htab, struct htab_elem *l)if (htab_is_prealloc (htab)) {bpf_map_dec_elem_count (&htab->map); -check_and_free_fields (htab, l); +check_and_cancel_fields (htab, l);pcpu_freelist_push (&htab->freelist, &l->fnode); }else {dec_elem_count (htab);
@@ -1019,7 +1023,7 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr,/* copy true value_size bytes */ ptr =this_cpu_ptr (pptr);copy_map_value (&htab->map, ptr, value); -bpf_obj_free_fields (htab->map.record, ptr); +bpf_obj_cancel_fields (&htab->map, ptr); }else {u32 size =round_up (htab->map.value_size,8 );void *val;
@@ -1029,7 +1033,7 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr, cpu = map_flags >>32 ; ptr =per_cpu_ptr (pptr, cpu);copy_map_value (&htab->map, ptr, value); -bpf_obj_free_fields (htab->map.record, ptr); +bpf_obj_cancel_fields (&htab->map, ptr);return ; }
@@ -1037,7 +1041,7 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr, ptr =per_cpu_ptr (pptr, cpu); val = (map_flags &BPF_F_ALL_CPUS ) ? value : value + size * cpu;copy_map_value (&htab->map, ptr, val); -bpf_obj_free_fields (htab->map.record, ptr); +bpf_obj_cancel_fields (&htab->map, ptr); } } }
@@ -1253,11 +1257,11 @@ static long htab_map_update_elem(struct bpf_map *map, void *key, void *value,if (l_old) {hlist_nulls_del_rcu (&l_old->hash_node); -/* l_old has already been stashed in htab->extra_elems, free -* its special fields before it is available for reuse. +/* l_old has already been stashed in htab->extra_elems, cancel +* its reusable special fields before it is available for reuse. */ if (htab_is_prealloc (htab)) -check_and_free_fields (htab, l_old); +check_and_cancel_fields (htab, l_old); }htab_unlock_bucket (b, flags);if (l_old && !htab_is_prealloc (htab))
@@ -1270,7 +1274,7 @@ static long htab_map_update_elem(struct bpf_map *map, void *key, void *value,static void htab_lru_push_free (struct bpf_htab *htab,struct htab_elem *elem) { -check_and_free_fields (htab, elem); +check_and_cancel_fields (htab, elem);bpf_map_dec_elem_count (&htab->map);bpf_lru_push_free (&htab->lru, &elem->lru_node); }
kernel/bpf/syscall.c +5 -0
@@ -807,6 +807,11 @@ void bpf_obj_free_task_work(const struct btf_record *rec, void *obj)bpf_task_work_cancel_and_free (obj + rec->task_work_off); } +void bpf_obj_cancel_fields (struct bpf_map *map,void *obj) +{ +bpf_map_free_internal_structs (map, obj); +} +void bpf_obj_free_fields (const struct btf_record *rec,void *obj) {const struct btf_field *fields;
tools/testing/selftests/bpf/prog_tests/htab_update.c +2 -2
@@ -23,7 +23,7 @@ static void test_reenter_update(void)if (!ASSERT_OK_PTR (skel,"htab_update__open" ))return ; -bpf_program__set_autoload (skel->progs.bpf_obj_free_fields, true); +bpf_program__set_autoload (skel->progs.bpf_obj_cancel_fields, true); err =htab_update__load (skel);if (!ASSERT_TRUE (!err,"htab_update__load" ) || err) goto out;
@@ -50,7 +50,7 @@ static void test_reenter_update(void)/* * Second update: replace existing element with same key and trigger * the reentrancy of bpf_map_update_elem(). -* check_and_free_fields() calls bpf_obj_free_fields() on the old +* check_and_cancel_fields() calls bpf_obj_cancel_fields() on the old * value, which is where fentry program runs and performs a nested * bpf_map_update_elem(), triggering -EDEADLK. */
tools/testing/selftests/bpf/prog_tests/linked_list.c +17 -16
@@ -131,13 +131,14 @@ static void test_linked_list_fail_prog(const char *prog_name, const char *err_mslinked_list_fail__destroy (skel); } -static void clear_fields (struct bpf_map *map) +static void clear_fields (struct bpf_program *prog) { -char buf[24 ]; -int key =0 ; +LIBBPF_OPTS (bpf_test_run_opts, opts); +int ret; -memset (buf,0xff ,sizeof (buf)); -ASSERT_OK (bpf_map__update_elem (map, &key,sizeof (key), buf,sizeof (buf),0 ),"check_and_free_fields" ); + ret =bpf_prog_test_run_opts (bpf_program__fd (prog), &opts); +ASSERT_OK (ret,"clear_fields" ); +ASSERT_OK (opts.retval,"clear_fields retval" ); }enum {
@@ -170,31 +171,31 @@ static void test_linked_list_success(int mode, bool leave_in_map)ASSERT_OK (ret,"map_list_push_pop" );ASSERT_OK (opts.retval,"map_list_push_pop retval" );if (!leave_in_map) -clear_fields (skel->maps.array_map); +clear_fields (skel->progs.clear_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.inner_map_list_push_pop), &opts);ASSERT_OK (ret,"inner_map_list_push_pop" );ASSERT_OK (opts.retval,"inner_map_list_push_pop retval" );if (!leave_in_map) -clear_fields (skel->maps.inner_map); +clear_fields (skel->progs.clear_inner_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.global_list_push_pop), &opts);ASSERT_OK (ret,"global_list_push_pop" );ASSERT_OK (opts.retval,"global_list_push_pop retval" );if (!leave_in_map) -clear_fields (skel->maps.bss_A); +clear_fields (skel->progs.clear_global_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.global_list_push_pop_nested), &opts);ASSERT_OK (ret,"global_list_push_pop_nested" );ASSERT_OK (opts.retval,"global_list_push_pop_nested retval" );if (!leave_in_map) -clear_fields (skel->maps.bss_A); +clear_fields (skel->progs.clear_global_nested_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.global_list_array_push_pop), &opts);ASSERT_OK (ret,"global_list_array_push_pop" );ASSERT_OK (opts.retval,"global_list_array_push_pop retval" );if (!leave_in_map) -clear_fields (skel->maps.bss_A); +clear_fields (skel->progs.clear_global_array_list);if (mode ==PUSH_POP ) goto end;
@@ -204,19 +205,19 @@ static void test_linked_list_success(int mode, bool leave_in_map)ASSERT_OK (ret,"map_list_push_pop_multiple" );ASSERT_OK (opts.retval,"map_list_push_pop_multiple retval" );if (!leave_in_map) -clear_fields (skel->maps.array_map); +clear_fields (skel->progs.clear_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.inner_map_list_push_pop_multiple), &opts);ASSERT_OK (ret,"inner_map_list_push_pop_multiple" );ASSERT_OK (opts.retval,"inner_map_list_push_pop_multiple retval" );if (!leave_in_map) -clear_fields (skel->maps.inner_map); +clear_fields (skel->progs.clear_inner_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.global_list_push_pop_multiple), &opts);ASSERT_OK (ret,"global_list_push_pop_multiple" );ASSERT_OK (opts.retval,"global_list_push_pop_multiple retval" );if (!leave_in_map) -clear_fields (skel->maps.bss_A); +clear_fields (skel->progs.clear_global_list);if (mode ==PUSH_POP_MULT ) goto end;
@@ -226,19 +227,19 @@ static void test_linked_list_success(int mode, bool leave_in_map)ASSERT_OK (ret,"map_list_in_list" );ASSERT_OK (opts.retval,"map_list_in_list retval" );if (!leave_in_map) -clear_fields (skel->maps.array_map); +clear_fields (skel->progs.clear_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.inner_map_list_in_list), &opts);ASSERT_OK (ret,"inner_map_list_in_list" );ASSERT_OK (opts.retval,"inner_map_list_in_list retval" );if (!leave_in_map) -clear_fields (skel->maps.inner_map); +clear_fields (skel->progs.clear_inner_map_list); ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.global_list_in_list), &opts);ASSERT_OK (ret,"global_list_in_list" );ASSERT_OK (opts.retval,"global_list_in_list retval" );if (!leave_in_map) -clear_fields (skel->maps.bss_A); +clear_fields (skel->progs.clear_global_list); end:linked_list__destroy (skel); }
tools/testing/selftests/bpf/prog_tests/map_kptr.c +1 -9
@@ -51,7 +51,6 @@ static void test_map_kptr_success(bool test_run) ret =bpf_map__update_elem (skel->maps.array_map, &key,sizeof (key), buf,sizeof (buf),0 );ASSERT_OK (ret,"array_map update" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" );
@@ -59,49 +58,42 @@ static void test_map_kptr_success(bool test_run) ret =bpf_map__update_elem (skel->maps.pcpu_array_map, &key,sizeof (key), pbuf, cpu *sizeof (buf),0 );ASSERT_OK (ret,"pcpu_array_map update" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"hash_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.pcpu_hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"pcpu_hash_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.hash_malloc_map, &key,sizeof (key),0 );ASSERT_OK (ret,"hash_malloc_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.pcpu_hash_malloc_map, &key,sizeof (key),0 );ASSERT_OK (ret,"pcpu_hash_malloc_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.lru_hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"lru_hash_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" ); ret =bpf_map__delete_elem (skel->maps.lru_pcpu_hash_map, &key,sizeof (key),0 );ASSERT_OK (ret,"lru_pcpu_hash_map delete" ); - skel->data->ref--; ret =bpf_prog_test_run_opts (bpf_program__fd (skel->progs.test_map_kptr_ref3), &opts);ASSERT_OK (ret,"test_map_kptr_ref3 refcount" );ASSERT_OK (opts.retval,"test_map_kptr_ref3 retval" );
@@ -175,7 +167,7 @@ void serial_test_map_kptr(void)ASSERT_OK (kern_sync_rcu (),"sync rcu" );wait_for_map_release (); -/* Observe refcount dropping to 1 on synchronous delete elem */ +/* Observe refcount dropping to 1 on map release. */ test_map_kptr_success (true); }
tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c +6 -2
@@ -57,6 +57,7 @@ void test_percpu_hash_refcounted_kptr_refcount_leak(void) .data_size_in = sizeof(pkt_v4), .repeat =1 , ); +LIBBPF_OPTS (bpf_test_run_opts, syscall_opts); cpu_nr =libbpf_num_possible_cpus ();if (!ASSERT_GT (cpu_nr,0 ,"libbpf_num_possible_cpus" ))
@@ -87,8 +88,11 @@ void test_percpu_hash_refcounted_kptr_refcount_leak(void)if (!ASSERT_EQ (opts.retval,2 ,"opts.retval" )) goto out; - err =bpf_map__update_elem (map, &key,sizeof (key), values, values_sz,0 ); -if (!ASSERT_OK (err,"bpf_map__update_elem" )) + fd =bpf_program__fd (skel->progs.clear_percpu_hash_kptr); + err =bpf_prog_test_run_opts (fd, &syscall_opts); +if (!ASSERT_OK (err,"bpf_prog_test_run_opts" )) + goto out; +if (!ASSERT_EQ (syscall_opts.retval,1 ,"syscall_opts.retval" )) goto out; fd =bpf_program__fd (skel->progs.check_percpu_hash_refcount);
tools/testing/selftests/bpf/progs/htab_update.c +2 -2
@@ -22,8 +22,8 @@ struct {int pid =0 ;int update_err =0 ; -SEC("?fentry/bpf_obj_free_fields") -int bpf_obj_free_fields (void *ctx) +SEC("?fentry/bpf_obj_cancel_fields") +int bpf_obj_cancel_fields (void *ctx) {__u32 key =0 ;struct val value = { .payload =1 };
tools/testing/selftests/bpf/progs/linked_list.c +71 -0
77 lines not on this page · raw message
tools/testing/selftests/bpf/progs/refcounted_kptr.c +19 -1
@@ -615,13 +615,31 @@ int percpu_hash_refcount_leak(void *ctx)struct map_value *v;int key =0 ; - v =bpf_map_lookup_elem (&percpu_hash, &key); + v =bpf_map_lookup_percpu_elem (&percpu_hash, &key,0 );if (!v)return 0 ;return __insert_in_list (&head, &lock, &v->node); } +SEC("syscall") +int clear_percpu_hash_kptr (void *ctx) +{ +struct node_data *n; +struct map_value *v; +int key =0 ; + + v =bpf_map_lookup_percpu_elem (&percpu_hash, &key,0 ); +if (!v) +return 0 ; + + n =bpf_kptr_xchg (&v->node,NULL ); +if (!n) +return 0 ; +bpf_obj_drop (n); +return probe_read_refcount (); +} + SEC("tc")int check_percpu_hash_refcount (void *ctx) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/2077 clocksource: move NXP timer selection to drivers/clocksource
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enric Balletbo i Serra <[email protected]>
[ Upstream commit a9ac745bc320cbdc2ed3c851eb78f91f22ff975b ]
The Kconfig logic for selecting the scheduler clocksource on NXP Vybrid (VF610) uses a choice block restricted to 32-bit ARM. This prevents 64-bit architectures, such as the NXP S32 family, from enabling the NXP Periodic Interrupt Timer (PIT) driver (CONFIG_NXP_PIT_TIMER).
Relocate the NXP clocksource selection from arch/arm/mach-imx/Kconfig to drivers/clocksource/Kconfig. This allows the configuration to be shared across different architectures.
Update the selection to include support for ARCH_S32 and add a "None" option restricted to ARCH_S32, since Vybrid lacks the ARM Architected Timer. The Vybrid Global Timer option is restricted to ARCH_MULTI_V7 SOC_VF610 platforms to prevent it from being visible on Cortex-M4 builds, which lack the ARM Global Timer hardware.
--- arch/arm/mach-imx/Kconfig | 21 --------------------- drivers/clocksource/Kconfig | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 21 deletions(-)
arch/arm/mach-imx/Kconfig +0 -21
@@ -227,27 +227,6 @@ config SOC_VF610 help This enables support for Freescale Vybrid VF610 processor. -choice - prompt "Clocksource for scheduler clock" - depends on SOC_VF610 - default VF_USE_ARM_GLOBAL_TIMER - - config VF_USE_ARM_GLOBAL_TIMER - bool "Use ARM Global Timer" - depends on ARCH_MULTI_V7 - select ARM_GLOBAL_TIMER - select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK - help - Use the ARM Global Timer as clocksource - - config VF_USE_PIT_TIMER - bool "Use PIT timer" - select NXP_PIT_TIMER - help - Use SoC Periodic Interrupt Timer (PIT) as clocksource - -endchoice - endif endif
drivers/clocksource/Kconfig +31 -0
@@ -793,4 +793,35 @@ config RTK_SYSTIMER this option only when building for a Realtek platform or for compilation testing. +choice + prompt "NXP clocksource for scheduler clock" + depends on SOC_VF610 || ARCH_S32 + # Default to Global Timer for Vybrid (32-bit) + default VF_USE_ARM_GLOBAL_TIMER if SOC_VF610 + # Default to None for S32 (64-bit) + default VF_TIMER_NONE if ARCH_S32 + + config VF_USE_ARM_GLOBAL_TIMER + bool "Use NXP Vybrid Global Timer" + depends on ARCH_MULTI_V7 && SOC_VF610 + select ARM_GLOBAL_TIMER + select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK + help + Use the NXP Vybrid Global Timer as clocksource. + + config VF_USE_PIT_TIMER + bool "Use NXP PIT timer" + select NXP_PIT_TIMER + help + Use NXP Periodic Interrupt Timer (PIT) as clocksource. + + config VF_TIMER_NONE + bool "None (Use standard Arch Timer)" + depends on ARCH_S32 + help + Do not use any specific NXP timer driver. Use the standard + ARM Architected Timer instead. + +endchoice + endmenu
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/2077 vduse: hold vduse_lock across IDR lookup in open path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang Tang <[email protected]>
[ Upstream commit e440e077748939839d9f76e24383b76b785f80ce ]
vduse_dev_open() looks up struct vduse_dev through the IDR and then acquires dev->lock only after vduse_lock has been dropped.
This leaves a window where a concurrent VDUSE_DESTROY_DEV can remove the same object from the IDR and free it before the open path locks the device, leading to a use-after-free.
Close this race by keeping vduse_lock held until dev->lock has been acquired in the open path, matching the lock ordering already used by the destroy path.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +7 -14
@@ -1637,26 +1637,18 @@ static int vduse_dev_release(struct inode *inode, struct file *file)return 0 ; } -static struct vduse_dev *vduse_dev_get_from_minor (int minor) +static int vduse_dev_open (struct inode *inode,struct file *file) { +int ret = -EBUSY ;struct vduse_dev *dev;mutex_lock (&vduse_lock); - dev =idr_find (&vduse_idr, minor); -mutex_unlock (&vduse_lock); - -return dev; -} - -static int vduse_dev_open (struct inode *inode,struct file *file) -{ -int ret; -struct vduse_dev *dev =vduse_dev_get_from_minor (iminor (inode)); - -if (!dev) + dev =idr_find (&vduse_idr,iminor (inode)); +if (!dev) { +mutex_unlock (&vduse_lock);return -ENODEV ; + } - ret = -EBUSY ;mutex_lock (&dev->lock);if (dev->connected) goto unlock;
@@ -1666,6 +1658,7 @@ static int vduse_dev_open(struct inode *inode, struct file *file) file->private_data = dev; unlock:mutex_unlock (&dev->lock); +mutex_unlock (&vduse_lock);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/2077 vhost/vdpa: validate virtqueue index in mmap and fault paths
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang Tang <[email protected]>
[ Upstream commit 929e4f044621c8cc30b612fb74e1410bef09e41b ]
vhost_vdpa_mmap() and vhost_vdpa_fault() use vma->vm_pgoff as a virtqueue index for get_vq_notification(), but they do not validate that the index is smaller than v->nvqs.
The ioctl path already performs both a bounds check and array_index_nospec(), but the mmap/fault path only checks that the index fits in u16. This allows an out-of-range queue index to reach driver-specific get_vq_notification() callbacks.
Fix this by extracting a unified vhost_vdpa_get_vq_notification() helper that validates the queue index against v->nvqs and applies array_index_nospec() before calling the driver callback. Both the mmap and fault paths use this helper, and the bounds checking is consolidated into a single location.
Quoted 1 line
From source inspection, the most defensible impact is out-of-bounds
access in the callback path, potentially leading to invalid PFN remaps and crash/DoS.
Message-ID: <[email protected]>
--- drivers/vhost/vdpa.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/vhost/vdpa.c +22 -7
@@ -1482,16 +1482,32 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep) }#ifdef CONFIG_MMU -static vm_fault_t vhost_vdpa_fault (struct vm_fault *vmf) +static int +vhost_vdpa_get_vq_notification (struct vhost_vdpa *v,unsigned long index, +struct vdpa_notification_area *notify) { -struct vhost_vdpa *v = vmf->vma->vm_file->private_data;struct vdpa_device *vdpa = v->vdpa;const struct vdpa_config_ops *ops = vdpa->config; + +if (index >65535 || index >= v->nvqs) +return -EINVAL ; + + index =array_index_nospec (index, v->nvqs); + + *notify = ops->get_vq_notification (vdpa, index); + +return 0 ; +} + +static vm_fault_t vhost_vdpa_fault (struct vm_fault *vmf) +{ +struct vhost_vdpa *v = vmf->vma->vm_file->private_data;struct vdpa_notification_area notify;struct vm_area_struct *vma = vmf->vma; -u16 index = vma->vm_pgoff; +unsigned long index = vma->vm_pgoff; - notify = ops->get_vq_notification (vdpa, index); +if (vhost_vdpa_get_vq_notification (v, index, ¬ify)) +return VM_FAULT_SIGBUS ;return vmf_insert_pfn (vma, vmf->address &PAGE_MASK ,PFN_DOWN (notify.addr)); }
@@ -1514,8 +1530,6 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)return -EINVAL ;if (vma->vm_flags &VM_READ )return -EINVAL ; -if (index >65535 ) -return -EINVAL ;if (!ops->get_vq_notification)return -ENOTSUPP ;
@@ -1523,7 +1537,8 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)* support the doorbell which sits on the page boundary and * does not share the page with other registers. */ - notify = ops->get_vq_notification (vdpa, index); +if (vhost_vdpa_get_vq_notification (v, index, ¬ify)) +return -EINVAL ;if (notify.addr & (PAGE_SIZE -1 ))return -EINVAL ;if (vma->vm_end - vma->vm_start != notify.size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/2077 virtio: rtc: tear down old virtqueues before restore
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Jia <[email protected]>
[ Upstream commit 548d2208455f14e6121404c6e30e997bfe0cd264 ]
virtio_device_restore() resets the device and restores the negotiated features before calling ->restore(). viortc_freeze() intentionally leaves the existing virtqueues in place so the alarm queue can still wake the system, but viortc_restore() immediately calls viortc_init_vqs() without first deleting those old queues.
If virtqueue reinitialization fails on virtio-pci, the transport error path can run vp_del_vqs() against a newly allocated vp_dev->vqs array while vdev->vqs still contains the old virtqueues. vp_del_vqs() then looks up queue state through the new array and can dereference a NULL info pointer in vp_del_vq(), crashing the guest kernel during restore.
This can also happen during a non-faulty reinitialization, when one of the vp_find_vqs_msix() attempts is unsuccessful before a later attempt would succeed.
Delete the stale virtqueues before rebuilding them. If restore fails before virtio_device_ready(), reuse the remove path to stop the device. Once the device is ready, return errors directly instead of deleting the virtqueues again.
Message-ID: <[email protected]>
--- drivers/virtio/virtio_rtc_driver.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/virtio/virtio_rtc_driver.c +20 -8
@@ -1257,6 +1257,15 @@ static int viortc_init_vqs(struct viortc_dev *viortc)return 0 ; } +static void __viortc_remove (struct viortc_dev *viortc) +{ +struct virtio_device *vdev = viortc->vdev; + +viortc_clocks_deinit (viortc); +virtio_reset_device (vdev); + vdev->config->del_vqs (vdev); +} +/** * viortc_probe() - probe a virtio_rtc virtio device * @vdev: virtio device
@@ -1282,7 +1291,7 @@ static int viortc_probe(struct virtio_device *vdev) ret =viortc_init_vqs (viortc);if (ret) -return ret; + goto err_reset_vdev;virtio_device_ready (vdev);
@@ -1329,10 +1338,7 @@ static void viortc_remove(struct virtio_device *vdev) {struct viortc_dev *viortc = vdev->priv; -viortc_clocks_deinit (viortc); - -virtio_reset_device (vdev); - vdev->config->del_vqs (vdev); +__viortc_remove (viortc); }static int viortc_freeze (struct virtio_device *dev)
@@ -1353,9 +1359,11 @@ static int viortc_restore(struct virtio_device *dev)bool notify = false;int ret; + dev->config->del_vqs (dev); + ret =viortc_init_vqs (viortc);if (ret) -return ret; + goto err_remove; alarm_viortc_vq = &viortc->vqs[VIORTC_ALARMQ ]; alarm_vq = alarm_viortc_vq->vq;
@@ -1364,7 +1372,7 @@ static int viortc_restore(struct virtio_device *dev) ret =viortc_populate_vq (viortc, alarm_viortc_vq,VIORTC_ALARMQ_BUF_CAP , false);if (ret) -return ret; + goto err_remove; notify =virtqueue_kick_prepare (alarm_vq); }
@@ -1372,8 +1380,12 @@ static int viortc_restore(struct virtio_device *dev)virtio_device_ready (dev);if (notify && !virtqueue_notify (alarm_vq)) - ret = -EIO ; +return -EIO ; + +return 0 ; +err_remove: +__viortc_remove (viortc);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/2077 virtio_console: read size from config space during device init
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filip Hejsek <[email protected]>
[ Upstream commit b3592a32b34f37874dc94aa1a0d15c4334ed86ca ]
Previously, the size was only read upon receiving the config interrupt. This interrupt is sent when the size changes. However, we also need to read the initial size.
Also make sure to only read the size from config if F_SIZE is enabled.
Message-ID: <[email protected]>
--- drivers/char/virtio_console.c | 52 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-)
drivers/char/virtio_console.c +31 -21
@@ -1771,32 +1771,40 @@ static void config_intr(struct virtio_device *vdev)schedule_work (&portdev->config_work); } -static void config_work_handler (struct work_struct *work) +static void update_size_from_config (struct ports_device *portdev) { -struct ports_device *portdev; +struct virtio_device *vdev; +struct port *port; +u16 rows, cols; - portdev = container_of(work, struct ports_device, config_work); -if (!use_multiport (portdev)) { -struct virtio_device *vdev; -struct port *port; -u16 rows, cols; + vdev = portdev->vdev; - vdev = portdev->vdev; - virtio_cread(vdev, struct virtio_console_config, cols, &cols); - virtio_cread(vdev, struct virtio_console_config, rows, &rows); +/* +* We'll use this way of resizing only for legacy support. +* For multiport devices, use control messages to indicate +* console size changes so that it can be done per-port. +* +* Don't test F_SIZE at all if we're rproc: not a valid feature. +*/ +if (is_rproc_serial (vdev) || +use_multiport (portdev) || + !virtio_has_feature (vdev,VIRTIO_CONSOLE_F_SIZE )) +return ; - port =find_port_by_id (portdev,0 ); -set_console_size (port, rows, cols); + virtio_cread(vdev, struct virtio_console_config, cols, &cols); + virtio_cread(vdev, struct virtio_console_config, rows, &rows); -/* -* We'll use this way of resizing only for legacy -* support. For newer userspace -* (VIRTIO_CONSOLE_F_MULTPORT+), use control messages -* to indicate console size changes so that it can be -* done per-port. -*/ -resize_console (port); - } + port =find_port_by_id (portdev,0 ); +set_console_size (port, rows, cols); +resize_console (port); +} + +static void config_work_handler (struct work_struct *work) +{ +struct ports_device *portdev; + + portdev = container_of(work, struct ports_device, config_work); +update_size_from_config (portdev); }static int init_vqs (struct ports_device *portdev)
@@ -2052,6 +2060,8 @@ static int virtcons_probe(struct virtio_device *vdev)__send_control_msg (portdev,VIRTIO_CONSOLE_BAD_ID ,VIRTIO_CONSOLE_DEVICE_READY ,1 ); +update_size_from_config (portdev); +return 0 ; free_chrdev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/2077 vduse: Requeue failed read to send_list head
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Tianci <[email protected]>
[ Upstream commit 373ec43ded742b2f3aecf14731ffe1a57f438f38 ]
When copy_to_iter() fails in vduse_dev_read_iter(), put the message back at the head of send_list to preserve FIFO ordering and retry the oldest pending request first.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_user/vduse_dev.c +7 -1
@@ -221,6 +221,12 @@ static void vduse_enqueue_msg(struct list_head *head,list_add_tail (&msg->list, head); } +static void vduse_enqueue_msg_head (struct list_head *head, +struct vduse_dev_msg *msg) +{ +list_add (&msg->list, head); +} +static void vduse_dev_broken (struct vduse_dev *dev) {struct vduse_dev_msg *msg, *tmp;
@@ -387,7 +393,7 @@ static ssize_t vduse_dev_read_iter(struct kiocb *iocb, struct iov_iter *to)spin_lock (&dev->msg_lock);if (ret != size) { ret = -EFAULT ; -vduse_enqueue_msg (&dev->send_list, msg); +vduse_enqueue_msg_head (&dev->send_list, msg); goto unlock; }vduse_enqueue_msg (&dev->recv_list, msg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/2077 vhost/net: complete zerocopy ubufs only once
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Ming <[email protected]>
[ Upstream commit 8f6898fe80794f2d7c3d38c1158c806e4074a1c4 ]
vhost-net initializes one ubuf_info per outstanding zerocopy TX descriptor and hands it to the backend socket. The networking stack may then clone a zerocopy skb before all skb references are released. For example, batman-adv fragmentation reaches skb_split(), which calls skb_zerocopy_clone() and increments the same ubuf_info refcount.
vhost_zerocopy_complete() currently treats every ubuf callback as a completed vhost descriptor. It dereferences ubuf->ctx, writes the descriptor completion state, and drops the vhost_net_ubuf_ref even when the callback only releases a cloned skb reference. A backend reset can therefore wait for and free the vhost_net_ubuf_ref while another cloned skb still carries the same ubuf_info. A later completion then dereferences the freed ubufs pointer.
KASAN reports the stale completion as:
BUG: KASAN: slab-use-after-free in vhost_zerocopy_complete+0x1d7/0x1f0 BUG: KASAN: slab-use-after-free in vhost_zerocopy_complete+0x101/0x1f0 vhost_zerocopy_complete skb_copy_ubufs __dev_forward_skb2 veth_xmit
The freed object was allocated from vhost_net_ioctl() while setting the backend and freed through kfree_rcu()/kvfree_rcu_bulk after backend removal, while delayed skb completion still reached vhost_zerocopy_complete().
Honor the generic ubuf_info refcount before touching vhost state, and run the vhost descriptor completion only for the final ubuf reference. This matches the msg_zerocopy_complete() ownership rule for cloned zerocopy skbs.
Message-ID: <[email protected]>
--- drivers/vhost/net.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/net.c +11 -4
@@ -390,13 +390,20 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net,static void vhost_zerocopy_complete (struct sk_buff *skb,struct ubuf_info *ubuf_base,bool success) { -struct ubuf_info_msgzc *ubuf =uarg_to_msgzc (ubuf_base); -struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; -struct vhost_virtqueue *vq = ubufs->vq; +struct ubuf_info_msgzc *ubuf; +struct vhost_net_ubuf_ref *ubufs; +struct vhost_virtqueue *vq;int cnt; -rcu_read_lock_bh (); +/* Only the final cloned skb reference completes the vhost descriptor. */ +if (!refcount_dec_and_test (&ubuf_base->refcnt)) +return ; + + ubuf =uarg_to_msgzc (ubuf_base); + ubufs = ubuf->ctx; + vq = ubufs->vq; +rcu_read_lock_bh ();/* set len to mark this desc buffers done DMA */ vq->heads[ubuf->desc].len = success ?VHOST_DMA_DONE_LEN :VHOST_DMA_FAILED_LEN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/2077 tools/virtio: check mmap return value in vringh_test
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: longlong yan <[email protected]>
[ Upstream commit ec6177dfe98b9be1c3ede6c0dfe4394ea2a76959 ]
In parallel_test(), the return values of mmap() for both host_map and guest_map are not checked against MAP_FAILED. If mmap() fails, the subsequent code will dereference the invalid pointer, leading to a segmentation fault.
Add MAP_FAILED checks after both mmap() calls, using err() to report the error and exit, consistent with the existing error handling style in this file (e.g., the open() call on line 149).
Message-ID: <[email protected]>
--- tools/virtio/vringh_test.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/virtio/vringh_test.c +5 -0
@@ -159,7 +159,12 @@ static int parallel_test(u64 features,/* Parent and child use separate addresses, to check our mapping logic! */ host_map =mmap (NULL , mapsize,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 ); +if (host_map ==MAP_FAILED ) +err (1 ,"mmap host_map" ); + guest_map =mmap (NULL , mapsize,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 ); +if (guest_map ==MAP_FAILED ) +err (1 ,"mmap guest_map" ); pipe_ret =pipe (to_guest);assert (!pipe_ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/2077 vduse: fix compat handling for VDUSE_IOTLB_GET_FD/VDUSE_VQ_GET_INFO
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 455a2a1af92651764e9eb42cec0d95ac142afc28 ]
These two ioctls are incompatible on 32-bit x86 userspace, because the data structures are shorter than they are on 64-bit.
Add a proper .compat_ioctl handler for x86 that reads the structures with the smaller padding before calling the internal handlers. On all other architectures, CONFIG_COMPAT_FOR_U64_ALIGNMENT is disabled and no special handling is required.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 123 ++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_user/vduse_dev.c +122 -1
@@ -1624,6 +1624,127 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,return ret; } +#ifdef CONFIG_COMPAT_FOR_U64_ALIGNMENT +/* +* i386 has different alignment constraints than x86_64, +* so there are only 3 bytes of padding instead of 7. +*/ +struct compat_vduse_iotlb_entry { +compat_u64 offset; +compat_u64 start; +compat_u64 last; +__u8 perm; +__u8 padding[3 ]; +}; +#define COMPAT_VDUSE_IOTLB_GET_FD _IOWR(VDUSE_BASE, 0x10, struct compat_vduse_iotlb_entry) + +struct compat_vduse_vq_info { +__u32 index; +__u32 num; +compat_u64 desc_addr; +compat_u64 driver_addr; +compat_u64 device_addr; +union { +struct vduse_vq_state_split split; +struct vduse_vq_state_packed packed; + }; +__u8 ready; +__u8 padding[3 ]; +}; +#define COMPAT_VDUSE_VQ_GET_INFO _IOWR(VDUSE_BASE, 0x15, struct compat_vduse_vq_info) + +static long vduse_dev_compat_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct vduse_dev *dev = file->private_data; +void __user *argp = (void __user *)arg; +int ret; + +if (unlikely (dev->broken)) +return -EPERM ; + +switch (cmd) { +case COMPAT_VDUSE_IOTLB_GET_FD : { +struct vduse_iotlb_entry_v2 entry = {0 }; +struct file *f =NULL ; + + ret = -EFAULT ; +if (copy_from_user (&entry, argp,_IOC_SIZE (cmd))) +break ; + + ret =vduse_dev_iotlb_entry (dev, &entry, &f,NULL ); +if (ret) +break ; + + ret = -EINVAL ; +if (!f) +break ; + + ret =copy_to_user (argp, &entry,_IOC_SIZE (cmd)); +if (ret) { + ret = -EFAULT ; +fput (f); +break ; + } + ret =receive_fd (f,NULL ,perm_to_file_flags (entry.perm)); +fput (f); +break ; + } +case COMPAT_VDUSE_VQ_GET_INFO : { +struct vduse_vq_info vq_info = {}; +struct vduse_virtqueue *vq; +u32 index; + + ret = -EFAULT ; +if (copy_from_user (&vq_info, argp, +sizeof (struct compat_vduse_vq_info ))) +break ; + + ret = -EINVAL ; +if (vq_info.index >= dev->vq_num) +break ; + + index =array_index_nospec (vq_info.index, dev->vq_num); + vq = dev->vqs[index]; + vq_info.desc_addr = vq->desc_addr; + vq_info.driver_addr = vq->driver_addr; + vq_info.device_addr = vq->device_addr; + vq_info.num = vq->num; + +if (dev->driver_features &BIT_ULL (VIRTIO_F_RING_PACKED )) { + vq_info.packed.last_avail_counter = + vq->state.packed.last_avail_counter; + vq_info.packed.last_avail_idx = + vq->state.packed.last_avail_idx; + vq_info.packed.last_used_counter = + vq->state.packed.last_used_counter; + vq_info.packed.last_used_idx = + vq->state.packed.last_used_idx; + }else + vq_info.split.avail_index = + vq->state.split.avail_index; + + vq_info.ready = vq->ready; + + ret = -EFAULT ; +if (copy_to_user (argp, &vq_info, +sizeof (struct compat_vduse_vq_info ))) +break ; + + ret =0 ; +break ; + } +default : + ret = -ENOIOCTLCMD ; +break ; + } + +return vduse_dev_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); +} +#else +#define vduse_dev_compat_ioctl compat_ptr_ioctl +#endif +static int vduse_dev_release (struct inode *inode,struct file *file) {struct vduse_dev *dev = file->private_data;
@@ -1677,7 +1798,7 @@ static const struct file_operations vduse_dev_fops = { .write_iter = vduse_dev_write_iter, .poll = vduse_dev_poll, .unlocked_ioctl = vduse_dev_ioctl, - .compat_ioctl = compat_ptr_ioctl, + .compat_ioctl = vduse_dev_compat_ioctl, .llseek = noop_llseek, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/2077 vdpa/octeon_ep: Fix PF->VF mailbox data address calculation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srujana Challa <[email protected]>
[ Upstream commit 74dc530f4c505d61f0f3620e59fe56c325ae3437 ]
The mailbox address was computed assuming 1 ring per VF. Read the actual rings-per-VF from OCTEP_EPF_RINFO and use it when calculating OCTEP_PF_MBOX_DATA offsets, fixing VF initialization when rings per VF > 1.
Message-ID: <[email protected]>
--- drivers/vdpa/octeon_ep/octep_vdpa_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/vdpa/octeon_ep/octep_vdpa_main.c +6 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright (C) 2024 Marvell. */ +#include <linux/bitfield.h> #include <linux/interrupt.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/module.h>
@@ -722,6 +723,8 @@ static int octep_sriov_enable(struct pci_dev *pdev, int num_vfs)bool done = false;int index =0 ;int ret, i; +u8 rpvf; +u64 val; ret =pci_enable_sriov (pdev, num_vfs);if (ret)
@@ -741,9 +744,11 @@ static int octep_sriov_enable(struct pci_dev *pdev, int num_vfs) } } + val =readq (addr +OCTEP_EPF_RINFO (0 )); + rpvf =FIELD_GET (GENMASK_ULL (35 ,32 ), val);if (done) {for (i =0 ; i < pf->enabled_vfs; i++) -writeq (OCTEP_DEV_READY_SIGNATURE , addr +OCTEP_PF_MBOX_DATA (i)); +writeq (OCTEP_DEV_READY_SIGNATURE , addr +OCTEP_PF_MBOX_DATA (i * rpvf)); }return num_vfs;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/2077 vdpa/octeon_ep: fix IRQ-to-ring mapping in interrupt handler
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srujana Challa <[email protected]>
[ Upstream commit 0d21a1d6375a05274291e32c1ab7cd57dbb69513 ]
Look up the IRQ index in oct_hw->irqs instead of assuming irq - irqs[0]. This supports non-contiguous IRQ numbers and avoids incorrect ring indexing when irqs[0] is not the base.
Message-ID: <[email protected]>
--- drivers/vdpa/octeon_ep/octep_vdpa_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/vdpa/octeon_ep/octep_vdpa_main.c +11 -2
@@ -48,7 +48,7 @@ static struct octep_hw *vdpa_to_octep_hw(struct vdpa_device *vdpa_dev)static irqreturn_t octep_vdpa_intr_handler (int irq,void *data) {struct octep_hw *oct_hw = data; -int i; +int i, start_ring_idx =-1 ;/* Each device has multiple interrupts (nb_irqs) shared among rings * (nr_vring). Device interrupts are mapped to the rings in a
@@ -61,7 +61,16 @@ static irqreturn_t octep_vdpa_intr_handler(int irq, void *data)* 7 -> 7, 15, 23, 31, 39, 47, 55, 63; */ -for (i = irq - oct_hw->irqs[0 ]; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) { +for (i =0 ; i < oct_hw->nb_irqs; i++) { +if (oct_hw->irqs[i] == irq) { + start_ring_idx = i; +break ; + } + } +if (start_ring_idx ==-1 ) +return IRQ_NONE ; + +for (i = start_ring_idx; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) {if (ioread8 (oct_hw->vqs[i].cb_notify_addr)) {/* Acknowledge the per ring notification to the device */ iowrite8 (0 , oct_hw->vqs[i].cb_notify_addr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/2077 iomap: pass the correct len to fserror_report_io in __iomap_write_begin
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit de654d66ff30e75d9308fd4d4f1627addef7923e ]
len is size of the (larger) write request, plen is the range for which the read failed here.
--- fs/iomap/buffered-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/iomap/buffered-io.c +1 -1
@@ -850,7 +850,7 @@ static int __iomap_write_begin(const struct iomap_iter *iter,if (status <0 )fserror_report_io (iter->inode,FSERR_BUFFERED_READ , pos, - len, status,GFP_NOFS ); + plen, status,GFP_NOFS );if (status)return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/2077 ASoC: cs35l56: Fix missing calls to wm_adsp2_remove()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 85f7bf03632bfcdd6cedfb3945b7e387d9487d73 ]
Call wm_adsp2_remove() in cs35l56_remove() and the error path of cs35l56_common_probe().
Depends on commit 7d3fb78b5503 ("ASoC: wm_adsp: Fix NULL dereference when removing firmware controls").
The call to wm_halo_init() during driver probe should be paired with a call to wm_adsp2_remove() but this was missing. The consequence would be a memory leak of the control lists in the cs_dsp driver.
--- sound/soc/codecs/cs35l56.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +6 -1
@@ -1964,11 +1964,14 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56) cs35l56_dai, ARRAY_SIZE(cs35l56_dai));if (ret <0 ) {dev_err_probe (cs35l56->base.dev, ret,"Register codec failed\n" ); - goto err; + goto err_remove_wm_adsp; }return 0 ; +err_remove_wm_adsp: +wm_adsp2_remove (&cs35l56->dsp); + err:gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 );regulator_bulk_disable (ARRAY_SIZE (cs35l56->supplies), cs35l56->supplies);
@@ -2076,6 +2079,8 @@ void cs35l56_remove(struct cs35l56_private *cs35l56)destroy_workqueue (cs35l56->dsp_wq); +wm_adsp2_remove (&cs35l56->dsp); +pm_runtime_dont_use_autosuspend (cs35l56->base.dev);pm_runtime_suspend (cs35l56->base.dev);pm_runtime_disable (cs35l56->base.dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/2077 ASoC: cs35l56: Prevent double-free of debugfs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 344a12ca7ba6e10f9779476780afe9d977d47322 ]
Invalidate the debugfs pointer after debugfs_remove_recursive() in cs35l56_remove_cal_debugfs(). This prevents a double-free situation when a future commit adds proper failure cleanup in cs35l56_component_probe().
As described by Sashiko (including the future cs35l56_component_probe() cleanup commit):
During a normal component unbind, cs35l56_component_remove() calls cs35l56_remove_cal_debugfs() which removes the directory but leaves a dangling pointer.
If the component is later bound again, but _cs35l56_component_probe() fails early (for example, if the init_completion times out), this new error path will call cs35l56_component_remove(). This causes cs35l56_remove_cal_debugfs() to be called again with the dangling cs35l56_base->debugfs pointer from the previous lifecycle, resulting in a use-after-free in debugfs_remove_recursive().
--- sound/soc/codecs/cs35l56-shared.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/cs35l56-shared.c +1 -0
@@ -1293,6 +1293,7 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_create_cal_debugfs, "SND_SOC_CS35L56_SHARED");void cs35l56_remove_cal_debugfs (struct cs35l56_base *cs35l56_base) {debugfs_remove_recursive (cs35l56_base->debugfs); + cs35l56_base->debugfs =ERR_PTR (-ENOENT ); }EXPORT_SYMBOL_NS_GPL (cs35l56_remove_cal_debugfs,"SND_SOC_CS35L56_SHARED" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/2077 ASoC: cs35l56: Cleanup if component_probe fails
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit a0df7522dfb098d56b42560247082d6f5a8581dd ]
If cs35l56_component_probe() fails, call cs35l56_component_remove() to clean up.
All the cleanup in cs35l56_component_remove() is the same cleanup that would need to be done (at least partially) if cs35l56_component_probe() fails. So calling cs35l56_component_remove() avoids convoluted cleanup gotos and duplicated code in cs35l56_component_probe().
The only action in cs35l56_component_remove() that is nominally dependent on having completed the component_probe() action is the call to wm_adsp2_component_remove(). Though it is currently safe to call that even if wm_adsp2_component_probe() was not called. However, wm_adsp2_component_probe() has been trivially updated to check itself whether it needs to cleanup.
--- sound/soc/codecs/cs35l56.c | 13 ++++++++++++- sound/soc/codecs/wm_adsp.c | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +12 -1
@@ -1326,7 +1326,7 @@ VISIBLE_IF_KUNIT int cs35l56_set_fw_name(struct snd_soc_component *component) }EXPORT_SYMBOL_IF_KUNIT (cs35l56_set_fw_name); -static int cs35l56_component_probe (struct snd_soc_component *component) +static int _cs35l56_component_probe (struct snd_soc_component *component) {struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component);struct cs35l56_private *cs35l56 =snd_soc_component_get_drvdata (component);
@@ -1426,6 +1426,17 @@ static void cs35l56_component_remove(struct snd_soc_component *component) cs35l56->component =NULL ; } +static int cs35l56_component_probe (struct snd_soc_component *component) +{ +int ret; + + ret =_cs35l56_component_probe (component); +if (ret <0 ) +cs35l56_component_remove (component); + +return ret; +} +static int cs35l56_set_bias_level (struct snd_soc_component *component,enum snd_soc_bias_level level) {
sound/soc/codecs/wm_adsp.c +7 -0
@@ -1170,7 +1170,14 @@ EXPORT_SYMBOL_GPL(wm_adsp2_component_probe);int wm_adsp2_component_remove (struct wm_adsp *dsp,struct snd_soc_component *component) { +if (!dsp) +return 0 ; + +if (!dsp->component) +return 0 ; +cs_dsp_cleanup_debugfs (&dsp->cs_dsp); + dsp->component =NULL ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/2077 ASoC: cs35l56: Dont leave parent IRQ disabled if system_suspend fails
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 53cebeb017164254cde5e31c94d8deef9e4fff97 ]
In cs35l56_system_suspend() re-enable the parent IRQ if the call to pm_runtime_force_suspend() returns an error.
--- sound/soc/codecs/cs35l56.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +6 -1
@@ -1491,6 +1491,7 @@ static int __maybe_unused cs35l56_runtime_resume_i2c_spi(struct device *dev)int cs35l56_system_suspend (struct device *dev) {struct cs35l56_private *cs35l56 =dev_get_drvdata (dev); +int ret;dev_dbg (dev,"system_suspend\n" );
@@ -1506,7 +1507,11 @@ int cs35l56_system_suspend(struct device *dev)if (cs35l56->base.irq)disable_irq (cs35l56->base.irq); -return pm_runtime_force_suspend (dev); + ret =pm_runtime_force_suspend (dev); +if ((ret <0 ) && cs35l56->base.irq) +enable_irq (cs35l56->base.irq); + +return ret; }EXPORT_SYMBOL_GPL (cs35l56_system_suspend);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/2077 hwmon: (gpd-fan): drop global driver data and use per-device allocation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 03b4addf8282fa2b63f2d7448d1a9bce9be3f556 ]
replace the global state gpd_driver_priv with per-device private data (struct gpd_fan_data) allocated in probe. This allows the driver to support multiple instances in the future and aligns with kernel best practices.
No functional change intended.
Stable-dep-of: 1fb4397509bd ("hwmon: (gpd-fan): fix race condition between device removal and sysfs access")
--- drivers/hwmon/gpd-fan.c | 209 ++++++++++++++++++++++------------------ 1 file changed, 115 insertions(+), 94 deletions(-)
drivers/hwmon/gpd-fan.c +115 -94
@@ -40,12 +40,11 @@ enum FAN_PWM_ENABLE { AUTOMATIC = 2, }; -static struct { +struct gpd_fan_data {enum FAN_PWM_ENABLE pwm_enable;u8 pwm_value; -const struct gpd_fan_drvdata *drvdata; -} gpd_driver_priv; +};struct gpd_fan_drvdata {const char *board_name;// Board name for module param comparison
@@ -249,10 +248,10 @@ static const struct gpd_fan_drvdata *gpd_module_drvdata[] = { };// Helper functions to handle EC read/write -static void gpd_ecram_read (u16 offset,u8 *val) +static void gpd_ecram_read (const struct gpd_fan_drvdata *drvdata,u16 offset,u8 *val) { -u16 addr_port = gpd_driver_priv.drvdata->addr_port; -u16 data_port = gpd_driver_priv.drvdata->data_port; +u16 addr_port = drvdata->addr_port; +u16 data_port = drvdata->data_port;outb (0x2E , addr_port);outb (0x11 , data_port);
@@ -270,10 +269,10 @@ static void gpd_ecram_read(u16 offset, u8 *val) *val =inb (data_port); } -static void gpd_ecram_write (u16 offset,u8 value) +static void gpd_ecram_write (const struct gpd_fan_drvdata *drvdata,u16 offset,u8 value) { -u16 addr_port = gpd_driver_priv.drvdata->addr_port; -u16 data_port = gpd_driver_priv.drvdata->data_port; +u16 addr_port = drvdata->addr_port; +u16 data_port = drvdata->data_port;outb (0x2E , addr_port);outb (0x11 , data_port);
@@ -291,198 +290,198 @@ static void gpd_ecram_write(u16 offset, u8 value)outb (value, data_port); } -static int gpd_generic_read_rpm (void ) +static int gpd_generic_read_rpm (struct gpd_fan_data *data) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; +const struct gpd_fan_drvdata *drvdata = data->drvdata;u8 high, low; -gpd_ecram_read (drvdata->rpm_read, &high); -gpd_ecram_read (drvdata->rpm_read +1 , &low); +gpd_ecram_read (drvdata, drvdata->rpm_read, &high); +gpd_ecram_read (drvdata, drvdata->rpm_read +1 , &low);return (u16 )high <<8 | low; } -static int gpd_wm2_read_rpm (void ) +static int gpd_wm2_read_rpm (struct gpd_fan_data *data) { +const struct gpd_fan_drvdata *drvdata = data->drvdata; +for (u16 pwm_ctr_offset =GPD_PWM_CTR_OFFSET ; pwm_ctr_offset <=GPD_PWM_CTR_OFFSET +2 ; pwm_ctr_offset++) {u8 PWMCTR ; -gpd_ecram_read (pwm_ctr_offset, &PWMCTR ); +gpd_ecram_read (drvdata, pwm_ctr_offset, &PWMCTR );if (PWMCTR !=0xB8 ) -gpd_ecram_write (pwm_ctr_offset,0xB8 ); +gpd_ecram_write (drvdata, pwm_ctr_offset,0xB8 ); } -return gpd_generic_read_rpm (); +return gpd_generic_read_rpm (data); }// Read value for fan1_input -static int gpd_read_rpm (void ) +static int gpd_read_rpm (struct gpd_fan_data *data) { -switch (gpd_driver_priv.drvdata->board) { +switch (data->drvdata->board) {case win4_6800u:case win_mini:case duo:case mpc2: -return gpd_generic_read_rpm (); +return gpd_generic_read_rpm (data);case win_max_2: -return gpd_wm2_read_rpm (); +return gpd_wm2_read_rpm (data); }return 0 ; } -static int gpd_wm2_read_pwm (void ) +static int gpd_wm2_read_pwm (struct gpd_fan_data *data) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; +const struct gpd_fan_drvdata *drvdata = data->drvdata;u8 var; -gpd_ecram_read (drvdata->pwm_write, &var); +gpd_ecram_read (drvdata, drvdata->pwm_write, &var);// Match gpd_generic_write_pwm(u8) below return DIV_ROUND_CLOSEST ((var -1 ) *255 , (drvdata->pwm_max -1 )); }// Read value for pwm1 -static int gpd_read_pwm (void ) +static int gpd_read_pwm (struct gpd_fan_data *data) { -switch (gpd_driver_priv.drvdata->board) { +switch (data->drvdata->board) {case win_mini:case duo:case win4_6800u:case mpc2: -switch (gpd_driver_priv.pwm_enable) { +switch (data->pwm_enable) {case DISABLE :return 255 ;case MANUAL : -return gpd_driver_priv.pwm_value; +return data->pwm_value;case AUTOMATIC :return -EOPNOTSUPP ; }break ;case win_max_2: -return gpd_wm2_read_pwm (); +return gpd_wm2_read_pwm (data); }return 0 ; }// PWM value's range in EC is 1 - pwm_max, cast 0 - 255 to it. -static inline u8 gpd_cast_pwm_range (u8 val) +static inline u8 gpd_cast_pwm_range (const struct gpd_fan_drvdata *drvdata,u8 val) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; -return DIV_ROUND_CLOSEST (val * (drvdata->pwm_max -1 ),255 ) +1 ; } -static void gpd_generic_write_pwm (u8 val) +static void gpd_generic_write_pwm (struct gpd_fan_data *data,u8 val) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; +const struct gpd_fan_drvdata *drvdata = data->drvdata;u8 pwm_reg; - pwm_reg =gpd_cast_pwm_range (val); -gpd_ecram_write (drvdata->pwm_write, pwm_reg); + pwm_reg =gpd_cast_pwm_range (drvdata, val); +gpd_ecram_write (drvdata, drvdata->pwm_write, pwm_reg); } -static void gpd_duo_write_pwm (u8 val) +static void gpd_duo_write_pwm (struct gpd_fan_data *data,u8 val) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; +const struct gpd_fan_drvdata *drvdata = data->drvdata;u8 pwm_reg; - pwm_reg =gpd_cast_pwm_range (val); -gpd_ecram_write (drvdata->pwm_write, pwm_reg); -gpd_ecram_write (drvdata->pwm_write +1 , pwm_reg); + pwm_reg =gpd_cast_pwm_range (drvdata, val); +gpd_ecram_write (drvdata, drvdata->pwm_write, pwm_reg); +gpd_ecram_write (drvdata, drvdata->pwm_write +1 , pwm_reg); }// Write value for pwm1 -static int gpd_write_pwm (u8 val) +static int gpd_write_pwm (struct gpd_fan_data *data,u8 val) { -if (gpd_driver_priv.pwm_enable !=MANUAL ) +if (data->pwm_enable !=MANUAL )return -EPERM ; -switch (gpd_driver_priv.drvdata->board) { +switch (data->drvdata->board) {case duo: -gpd_duo_write_pwm (val); +gpd_duo_write_pwm (data, val);break ;case win_mini:case win4_6800u:case win_max_2:case mpc2: -gpd_generic_write_pwm (val); +gpd_generic_write_pwm (data, val);break ; }return 0 ; } -static void gpd_win_mini_set_pwm_enable (enum FAN_PWM_ENABLE pwm_enable) +static void gpd_win_mini_set_pwm_enable (struct gpd_fan_data *data,enum FAN_PWM_ENABLE pwm_enable) {switch (pwm_enable) {case DISABLE : -gpd_generic_write_pwm (255 ); +gpd_generic_write_pwm (data,255 );break ;case MANUAL : -gpd_generic_write_pwm (gpd_driver_priv.pwm_value); +gpd_generic_write_pwm (data, data->pwm_value);break ;case AUTOMATIC : -gpd_ecram_write (gpd_driver_priv.drvdata->pwm_write,0 ); +gpd_ecram_write (data->drvdata, data->drvdata->pwm_write,0 );break ; } } -static void gpd_duo_set_pwm_enable (enum FAN_PWM_ENABLE pwm_enable) +static void gpd_duo_set_pwm_enable (struct gpd_fan_data *data,enum FAN_PWM_ENABLE pwm_enable) {switch (pwm_enable) {case DISABLE : -gpd_duo_write_pwm (255 ); +gpd_duo_write_pwm (data,255 );break ;case MANUAL : -gpd_duo_write_pwm (gpd_driver_priv.pwm_value); +gpd_duo_write_pwm (data, data->pwm_value);break ;case AUTOMATIC : -gpd_ecram_write (gpd_driver_priv.drvdata->pwm_write,0 ); +gpd_ecram_write (data->drvdata, data->drvdata->pwm_write,0 );break ; } } -static void gpd_wm2_set_pwm_enable (enum FAN_PWM_ENABLE enable) +static void gpd_wm2_set_pwm_enable (struct gpd_fan_data *data,enum FAN_PWM_ENABLE enable) { -const struct gpd_fan_drvdata *const drvdata = gpd_driver_priv.drvdata; +const struct gpd_fan_drvdata *drvdata = data->drvdata;switch (enable) {case DISABLE : -gpd_generic_write_pwm (255 ); -gpd_ecram_write (drvdata->manual_control_enable,1 ); +gpd_generic_write_pwm (data,255 ); +gpd_ecram_write (drvdata, drvdata->manual_control_enable,1 );break ;case MANUAL : -gpd_generic_write_pwm (gpd_driver_priv.pwm_value); -gpd_ecram_write (drvdata->manual_control_enable,1 ); +gpd_generic_write_pwm (data, data->pwm_value); +gpd_ecram_write (drvdata, drvdata->manual_control_enable,1 );break ;case AUTOMATIC : -gpd_ecram_write (drvdata->manual_control_enable,0 ); +gpd_ecram_write (drvdata, drvdata->manual_control_enable,0 );break ; } }// Write value for pwm1_enable -static void gpd_set_pwm_enable (enum FAN_PWM_ENABLE enable) +static void gpd_set_pwm_enable (struct gpd_fan_data *data,enum FAN_PWM_ENABLE enable) {if (enable ==MANUAL )// Set pwm_value to max firstly when switching to manual mode, in // consideration of device safety. - gpd_driver_priv.pwm_value =255 ; + data->pwm_value =255 ; -switch (gpd_driver_priv.drvdata->board) { +switch (data->drvdata->board) {case win_mini:case win4_6800u:case mpc2: -gpd_win_mini_set_pwm_enable (enable); +gpd_win_mini_set_pwm_enable (data, enable);break ;case duo: -gpd_duo_set_pwm_enable (enable); +gpd_duo_set_pwm_enable (data, enable);break ;case win_max_2: -gpd_wm2_set_pwm_enable (enable); +gpd_wm2_set_pwm_enable (data, enable);break ; } }
@@ -505,15 +504,16 @@ static umode_t gpd_fan_hwmon_is_visible(__always_unused const void *drvdata,return 0 ; } -static int gpd_fan_hwmon_read (__always_unused struct device *dev, +static int gpd_fan_hwmon_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,__always_unused int channel,long *val) { +struct gpd_fan_data *data =dev_get_drvdata (dev);int ret;if (type == hwmon_fan) {if (attr == hwmon_fan_input) { - ret =gpd_read_rpm (); + ret =gpd_read_rpm (data);if (ret <0 )return ret;
@@ -524,10 +524,10 @@ static int gpd_fan_hwmon_read(__always_unused struct device *dev, }else if (type == hwmon_pwm) {switch (attr) {case hwmon_pwm_enable: - *val = gpd_driver_priv.pwm_enable; + *val = data->pwm_enable;return 0 ;case hwmon_pwm_input: - ret =gpd_read_pwm (); + ret =gpd_read_pwm (data);if (ret <0 )return ret;
@@ -540,27 +540,29 @@ static int gpd_fan_hwmon_read(__always_unused struct device *dev,return -EOPNOTSUPP ; } -static int gpd_fan_hwmon_write (__always_unused struct device *dev, +static int gpd_fan_hwmon_write (struct device *dev,enum hwmon_sensor_types type,u32 attr,__always_unused int channel,long val) { +struct gpd_fan_data *data =dev_get_drvdata (dev); +if (type == hwmon_pwm) {switch (attr) {case hwmon_pwm_enable:if (!in_range (val,0 ,3 ))return -EINVAL ; - gpd_driver_priv.pwm_enable = val; + data->pwm_enable = val; -gpd_set_pwm_enable (gpd_driver_priv.pwm_enable); +gpd_set_pwm_enable (data, data->pwm_enable);return 0 ;case hwmon_pwm_input:if (!in_range (val,0 ,256 ))return -EINVAL ; - gpd_driver_priv.pwm_value = val; + data->pwm_value = val; -return gpd_write_pwm (val); +return gpd_write_pwm (data, val); } }
@@ -584,26 +586,27 @@ static struct hwmon_chip_info gpd_fan_chip_info = { .info = gpd_fan_hwmon_channel_info }; -static void gpd_win4_init_ec (void ) +static void gpd_win4_init_ec (struct gpd_fan_data *data) { +const struct gpd_fan_drvdata *drvdata = data->drvdata;u8 chip_id, chip_ver; -gpd_ecram_read (0x2000 , &chip_id); +gpd_ecram_read (drvdata,0x2000 , &chip_id);if (chip_id ==0x55 ) { -gpd_ecram_read (0x1060 , &chip_ver); -gpd_ecram_write (0x1060 , chip_ver |0x80 ); +gpd_ecram_read (drvdata,0x1060 , &chip_ver); +gpd_ecram_write (drvdata,0x1060 , chip_ver |0x80 ); } } -static void gpd_init_ec (void ) +static void gpd_init_ec (struct gpd_fan_data *data) {// The buggy firmware won't initialize EC properly on boot. // Before its initialization, reading RPM will always return 0, // and writing PWM will have no effect. // Initialize it manually on driver load. -if (gpd_driver_priv.drvdata->board == win4_6800u) -gpd_win4_init_ec (); +if (data->drvdata->board == win4_6800u) +gpd_win4_init_ec (data); }static int gpd_fan_probe (struct platform_device *pdev)
@@ -611,7 +614,9 @@ static int gpd_fan_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;const struct resource *region;const struct resource *res; -const struct device *hwdev; +struct device *hwdev; +struct gpd_fan_data *data; +const struct gpd_fan_drvdata *match; res =platform_get_resource (pdev,IORESOURCE_IO ,0 );if (!res)
@@ -624,24 +629,42 @@ static int gpd_fan_probe(struct platform_device *pdev)return dev_err_probe (dev, -EBUSY ,"Failed to request region\n" ); + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + match =dev_get_platdata (dev); +if (!match) +return -EINVAL ; + + data->drvdata = match; + data->pwm_enable =AUTOMATIC ; + data->pwm_value =255 ; + +dev_set_drvdata (dev, data); + hwdev =devm_hwmon_device_register_with_info (dev,DRIVER_NAME , -NULL , + data, &gpd_fan_chip_info,NULL );if (IS_ERR (hwdev))return dev_err_probe (dev,PTR_ERR (hwdev),"Failed to register hwmon device\n" ); -gpd_init_ec (); +gpd_init_ec (data);return 0 ; } -static void gpd_fan_remove (__always_unused struct platform_device *pdev) +static void gpd_fan_remove (struct platform_device *pdev) { - gpd_driver_priv.pwm_enable =AUTOMATIC ; -gpd_set_pwm_enable (AUTOMATIC ); +struct gpd_fan_data *data =dev_get_drvdata (&pdev->dev); + +if (data) { + data->pwm_enable =AUTOMATIC ; +gpd_set_pwm_enable (data,AUTOMATIC ); + } }static struct platform_driver gpd_fan_driver = {
@@ -668,6 +691,7 @@ static int __init gpd_fan_init(void)if (!match) {const struct dmi_system_id *dmi_match =dmi_first_match (dmi_table); +if (dmi_match) match = dmi_match->driver_data; }
@@ -675,10 +699,6 @@ static int __init gpd_fan_init(void)if (!match)return -ENODEV ; - gpd_driver_priv.pwm_enable =AUTOMATIC ; - gpd_driver_priv.pwm_value =255 ; - gpd_driver_priv.drvdata = match; -struct resource gpd_fan_resources[] = { { .start = match->addr_port,
@@ -690,7 +710,8 @@ static int __init gpd_fan_init(void) gpd_fan_platform_device =platform_create_bundle (&gpd_fan_driver, gpd_fan_probe, gpd_fan_resources, -1 ,NULL ,0 ); +1 , + match,sizeof (*match));if (IS_ERR (gpd_fan_platform_device)) {pr_warn ("Failed to create platform device\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/2077 hwmon: (gpd-fan): Initialize EC before registering hwmon device
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit a8a444917fe5d30a9787f41cc179f55fc5f559d3 ]
Move the gpd_init_ec() call to before devm_hwmon_device_register_with_info in the probe function. With the previous ordering the hwmon device was registered and exposed to userspace before the EC initialization completes, creating a window where sysfs reads could return invalid values.
Some buggy firmware won't initialize EC properly on boot. Before its initialization, reading RPM will always return 0, and writing PWM will have no effect. So move gpd_init_ec to before hwmon device register.
Stable-dep-of: 1fb4397509bd ("hwmon: (gpd-fan): fix race condition between device removal and sysfs access")
--- drivers/hwmon/gpd-fan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hwmon/gpd-fan.c +1 -3
@@ -643,6 +643,7 @@ static int gpd_fan_probe(struct platform_device *pdev)dev_set_drvdata (dev, data); +gpd_init_ec (data); hwdev = devm_hwmon_device_register_with_info(dev, DRIVER_NAME, data,
@@ -651,9 +652,6 @@ static int gpd_fan_probe(struct platform_device *pdev)if (IS_ERR (hwdev))return dev_err_probe (dev,PTR_ERR (hwdev),"Failed to register hwmon device\n" ); - -gpd_init_ec (data); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/2077 hwmon: (gpd-fan): fix race condition between device removal and sysfs access
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 1fb4397509bd8701d323e81ac9a97c2e24ed49eb ]
Replace the manual gpd_fan_remove() callback with a devres-managed action using devm_add_action_or_reset(). The original remove hook resets the fan to AUTOMATIC mode, but the hwmon sysfs interface (registered with devm_hwmon_device_register_with_info()) remains active until after the remove callback completes. This creates a race window where a concurrent userspace sysfs access can interleave with the EC I/O sequence, potentially corrupting EC registers.
Using devm_add_action_or_reset() registers the reset function as a devres action. Due to the LIFO release order of devres, the hwmon device is unregistered (sysfs removed) before the reset action executes, eliminating the race condition.
--- drivers/hwmon/gpd-fan.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/hwmon/gpd-fan.c +16 -11
@@ -609,6 +609,16 @@ static void gpd_init_ec(struct gpd_fan_data *data)gpd_win4_init_ec (data); } +static void gpd_fan_reset_hardware (void *pdata) +{ +struct gpd_fan_data *data = pdata; + +if (data) { + data->pwm_enable =AUTOMATIC ; +gpd_set_pwm_enable (data,AUTOMATIC ); + } +} +static int gpd_fan_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -617,6 +627,7 @@ static int gpd_fan_probe(struct platform_device *pdev)struct device *hwdev;struct gpd_fan_data *data;const struct gpd_fan_drvdata *match; +int ret; res =platform_get_resource (pdev,IORESOURCE_IO ,0 );if (!res)
@@ -644,6 +655,11 @@ static int gpd_fan_probe(struct platform_device *pdev)dev_set_drvdata (dev, data);gpd_init_ec (data); + + ret =devm_add_action_or_reset (dev, gpd_fan_reset_hardware, data); +if (ret) +return ret; + hwdev = devm_hwmon_device_register_with_info(dev, DRIVER_NAME, data,
@@ -655,19 +671,8 @@ static int gpd_fan_probe(struct platform_device *pdev)return 0 ; } -static void gpd_fan_remove (struct platform_device *pdev) -{ -struct gpd_fan_data *data =dev_get_drvdata (&pdev->dev); - -if (data) { - data->pwm_enable =AUTOMATIC ; -gpd_set_pwm_enable (data,AUTOMATIC ); - } -} -static struct platform_driver gpd_fan_driver = { .probe = gpd_fan_probe, - .remove = gpd_fan_remove, .driver = { .name =KBUILD_MODNAME , },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/2077 ext4: fix ERR_PTR(0) in ext4_mkdir()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 8e1c43af7cf5091d99db38b7c8129e394d7f45b5 ]
When mkdir succeeds, ext4_mkdir() returns ERR_PTR(0) which is incorrect. It should return NULL instead for success and ERR_PTR() only with negative error codes for failure.
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/namei.c +1 -1
@@ -3054,7 +3054,7 @@ static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, out_retry:if (err == -ENOSPC &&ext4_should_retry_alloc (dir->i_sb, &retries)) goto retry; -return ERR_PTR (err); +return err ?ERR_PTR (err) :NULL ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/2077 tools: missed broadcast_neigh if_link uapi header
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 0134432215f0e0d4526544ac63dabe20e8a6951e ]
Add missing IFLA_BOND_BROADCAST_NEIGH in if_link uapi header.
Stable-dep-of: 32b0b8953343 ("bonding: 3ad: add lacp_strict configuration knob")
--- tools/include/uapi/linux/if_link.h | 1 + 1 file changed, 1 insertion(+)
tools/include/uapi/linux/if_link.h +1 -0
@@ -1526,6 +1526,7 @@ enum {IFLA_BOND_MISSED_MAX ,IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL , +IFLA_BOND_BROADCAST_NEIGH , __IFLA_BOND_MAX, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/2077 netlink: specs: rt-link: missed broadcast-neigh
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 363037983cc503eb0b5a5c0ab80bf1434cfd168a ]
Add missed broadcast-neigh.
Stable-dep-of: 32b0b8953343 ("bonding: 3ad: add lacp_strict configuration knob")
--- Documentation/netlink/specs/rt-link.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
@@ -1351,6 +1351,9 @@ attribute-sets: - name: coupled-control type: u8 + - + name: broadcast-neigh + type: u8 - name: bond-ad-info-attrs name-prefix: ifla-bond-ad-info-
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/2077 bonding: 3ad: add lacp_strict configuration knob
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 32b0b8953343eaceaa816a9ead3b6bb66355c64e ]
When an 802.3ad (LACP) bonding interface has no slaves in the collecting/distributing state, the bonding master still reports carrier as up as long as at least 'min_links' slaves have carrier.
In this situation, only one slave is effectively used for TX/RX, while traffic received on other slaves is dropped. Upper-layer daemons therefore consider the interface operational, even though traffic may be blackholed if the lack of LACP negotiation means the partner is not ready to deal with traffic.
Introduce a configuration knob to control this behavior. It allows the bonding master to assert carrier only when at least 'min_links' slaves are in Collecting_Distributing state.
The default mode preserves the existing behavior. This patch only introduces the knob; its behavior is implemented in the subsequent commit.
--- Documentation/netlink/specs/rt-link.yaml | 3 +++ Documentation/networking/bonding.rst | 23 +++++++++++++++++++++ drivers/net/bonding/bond_main.c | 1 + drivers/net/bonding/bond_netlink.c | 16 +++++++++++++++ drivers/net/bonding/bond_options.c | 26 ++++++++++++++++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 1 + include/uapi/linux/if_link.h | 1 + tools/include/uapi/linux/if_link.h | 1 + 9 files changed, 73 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
@@ -1354,6 +1354,9 @@ attribute-sets: - name: broadcast-neigh type: u8 + - + name: lacp-strict + type: u8 - name: bond-ad-info-attrs name-prefix: ifla-bond-ad-info-
Documentation/networking/bonding.rst +23 -0
@@ -619,6 +619,29 @@ min_links aggregator cannot be active without at least one available link, setting this option to 0 or to 1 has the exact same effect. +lacp_strict + + Specifies the fallback behavior of a bonding when LACP negotiation + fails on all slave links, i.e. when no slave is in the + Collecting_Distributing state, while at least `min_links` link still + reports carrier up. + + This option is only applicable to 802.3ad mode (mode 4). + + Valid values are: + + off or 0 + One interface of the bond is selected to be active, in order to + facilitate communication with peer devices that do not implement + LACP. + + on or 1 + Interfaces are only permitted to be made active if they have an + active LACP partner and have successfully reached + Collecting_Distributing state. + + The default value is 0 (off). + mode Specifies one of the bonding policies. The default is
drivers/net/bonding/bond_main.c +1 -0
@@ -6446,6 +6446,7 @@ static int __init bond_check_params(struct bond_params *params) params->ad_user_port_key = ad_user_port_key; params->coupled_control =1 ; params->broadcast_neighbor =0 ; + params->lacp_strict =0 ;if (packets_per_slave >0 ) { params->reciprocal_packets_per_slave =reciprocal_value (packets_per_slave);
drivers/net/bonding/bond_netlink.c +16 -0
@@ -143,6 +143,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED }, [IFLA_BOND_COUPLED_CONTROL] = { .type = NLA_U8 }, [IFLA_BOND_BROADCAST_NEIGH] = { .type = NLA_U8 }, + [IFLA_BOND_LACP_STRICT] = { .type = NLA_U8 }, };static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX +1 ] = {
@@ -599,6 +600,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],return err; } +if (data[IFLA_BOND_LACP_STRICT ]) { +int fallback_mode =nla_get_u8 (data[IFLA_BOND_LACP_STRICT ]); + +bond_opt_initval (&newval, fallback_mode); + err =__bond_opt_set (bond,BOND_OPT_LACP_STRICT , &newval, + data[IFLA_BOND_LACP_STRICT ], extack); +if (err) +return err; + } +return 0 ; }
@@ -671,6 +682,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)nla_total_size (sizeof (struct in6_addr )) *BOND_MAX_NS_TARGETS +nla_total_size (sizeof (u8)) +/* IFLA_BOND_COUPLED_CONTROL */ nla_total_size (sizeof (u8)) +/* IFLA_BOND_BROADCAST_NEIGH */ +nla_total_size (sizeof (u8)) +/* IFLA_BOND_LACP_STRICT */ 0 ; }
@@ -838,6 +850,10 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.broadcast_neighbor)) goto nla_put_failure; +if (nla_put_u8 (skb,IFLA_BOND_LACP_STRICT , + bond->params.lacp_strict)) + goto nla_put_failure; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info;
drivers/net/bonding/bond_options.c +26 -0
@@ -68,6 +68,8 @@ static int bond_option_lacp_active_set(struct bonding *bond, const struct bond_opt_value *newval);static int bond_option_lacp_rate_set (struct bonding *bond,const struct bond_opt_value *newval); +static int bond_option_lacp_strict_set (struct bonding *bond, +const struct bond_opt_value *newval);static int bond_option_ad_select_set (struct bonding *bond,const struct bond_opt_value *newval); static int bond_option_queue_id_set(struct bonding *bond,
@@ -162,6 +164,12 @@ static const struct bond_opt_value bond_lacp_rate_tbl[] = { { NULL, -1, 0}, }; +static const struct bond_opt_value bond_lacp_strict_tbl[] = { + {"off" ,0 ,BOND_VALFLAG_DEFAULT }, + {"on" ,1 ,0 }, + {NULL ,-1 ,0 } +}; +static const struct bond_opt_value bond_ad_select_tbl[] = { {"stable" ,BOND_AD_STABLE ,BOND_VALFLAG_DEFAULT }, { "bandwidth", BOND_AD_BANDWIDTH, 0},
@@ -363,6 +371,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .values = bond_lacp_rate_tbl, .set = bond_option_lacp_rate_set }, + [BOND_OPT_LACP_STRICT] = { + .id = BOND_OPT_LACP_STRICT, + .name = "lacp_strict", + .desc = "Define the LACP fallback mode when no slaves have negotiated", + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), + .values = bond_lacp_strict_tbl, + .set = bond_option_lacp_strict_set + }, [BOND_OPT_MINLINKS] = { .id = BOND_OPT_MINLINKS, .name = "min_links",
@@ -1684,6 +1700,16 @@ static int bond_option_lacp_rate_set(struct bonding *bond,return 0 ; } +static int bond_option_lacp_strict_set (struct bonding *bond, +const struct bond_opt_value *newval) +{ +netdev_dbg (bond->dev,"Setting LACP fallback to %s (%llu)\n" , + newval->string, newval->value); + bond->params.lacp_strict = newval->value; + +return 0 ; +} +static int bond_option_ad_select_set (struct bonding *bond,const struct bond_opt_value *newval) {
include/net/bond_options.h +1 -0
@@ -79,6 +79,7 @@ enum {BOND_OPT_COUPLED_CONTROL ,BOND_OPT_BROADCAST_NEIGH ,BOND_OPT_ACTOR_PORT_PRIO , +BOND_OPT_LACP_STRICT , BOND_OPT_LAST };
include/net/bonding.h +1 -0
@@ -129,6 +129,7 @@ struct bond_params {int peer_notif_delay;int lacp_active;int lacp_fast; +int lacp_strict;unsigned int min_links;int ad_select;char primary[IFNAMSIZ ];
include/uapi/linux/if_link.h +1 -0
@@ -1584,6 +1584,7 @@ enum {IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL ,IFLA_BOND_BROADCAST_NEIGH , +IFLA_BOND_LACP_STRICT , __IFLA_BOND_MAX, };
tools/include/uapi/linux/if_link.h +1 -0
@@ -1527,6 +1527,7 @@ enum {IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL ,IFLA_BOND_BROADCAST_NEIGH , +IFLA_BOND_LACP_STRICT , __IFLA_BOND_MAX, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 650/2077 bonding: 3ad: fix carrier when no usable slaves
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 0bd695db23c6262e9cb980017a6273925172ec5b ]
Apply the "lacp_strict" configuration from the previous commit.
"lacp_strict" mode "on" asserts that the bonding master carrier is up only when at least 'min_links' slaves are in the Collecting_Distributing state.
--- drivers/net/bonding/bond_3ad.c | 26 +++++++++++++++++++++++--- drivers/net/bonding/bond_options.c | 1 + 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_3ad.c +23 -3
@@ -745,6 +745,21 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val) } } +static int __agg_usable_ports (struct aggregator *agg) +{ +struct port *port; +int valid =0 ; + +for (port = agg->lag_ports; port; + port = port->next_port_in_aggregator) { +if (port->actor_oper_port_state &LACP_STATE_COLLECTING && + port->actor_oper_port_state &LACP_STATE_DISTRIBUTING ) + valid++; + } + +return valid; +} +static int __agg_active_ports (struct aggregator *agg) {struct port *port;
@@ -1179,10 +1194,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)switch (port->sm_mux_state) {case AD_MUX_DETACHED : port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION ; -ad_disable_collecting_distributing (port, - update_slave_arr); port->actor_oper_port_state &= ~LACP_STATE_COLLECTING ; port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING ; +ad_disable_collecting_distributing (port, + update_slave_arr); port->ntt = true;break ;case AD_MUX_WAITING :
@@ -2107,6 +2122,7 @@ static void ad_disable_distributing(struct port *port, bool *update_slave_arr) port->actor_port_number, aggregator->aggregator_identifier);__disable_distributing_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs an update */ *update_slave_arr = true; }
@@ -2130,6 +2146,7 @@ static void ad_enable_collecting_distributing(struct port *port, port->actor_port_number, aggregator->aggregator_identifier);__enable_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs update */ *update_slave_arr = true;/* Should notify peers if possible */
@@ -2153,6 +2170,7 @@ static void ad_disable_collecting_distributing(struct port *port, port->actor_port_number, aggregator->aggregator_identifier);__disable_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs an update */ *update_slave_arr = true; }
@@ -2832,7 +2850,9 @@ int bond_3ad_set_carrier(struct bonding *bond) active =__get_active_agg (&(SLAVE_AD_INFO (first_slave)->aggregator));if (active) {/* are enough slaves available to consider link up? */ -if (__agg_active_ports (active) < bond->params.min_links) { +if ((bond->params.lacp_strict ?__agg_usable_ports (active) + :__agg_active_ports (active)) < + bond->params.min_links) {if (netif_carrier_ok (bond->dev)) {netif_carrier_off (bond->dev); goto out;
drivers/net/bonding/bond_options.c +1 -0
@@ -1706,6 +1706,7 @@ static int bond_option_lacp_strict_set(struct bonding *bond,netdev_dbg (bond->dev,"Setting LACP fallback to %s (%llu)\n" , newval->string, newval->value); bond->params.lacp_strict = newval->value; +bond_3ad_set_carrier (bond);return 0 ; }
Signature · 1 line
2.53.0