From: Sasha Levin Date: Tue, 20 Aug 2024 11:58:54 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v6.1.107~105 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e3eab380669a92c077d07237f37ba846ac4a9a7;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/binfmt_misc-cleanup-on-filesystem-umount.patch b/queue-5.4/binfmt_misc-cleanup-on-filesystem-umount.patch new file mode 100644 index 00000000000..26e1a410c86 --- /dev/null +++ b/queue-5.4/binfmt_misc-cleanup-on-filesystem-umount.patch @@ -0,0 +1,442 @@ +From ce77628bbc117a0498dc611a715b7bb4b98df48f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Oct 2021 12:31:13 +0200 +Subject: binfmt_misc: cleanup on filesystem umount + +From: Christian Brauner + +[ Upstream commit 1c5976ef0f7ad76319df748ccb99a4c7ba2ba464 ] + +Currently, registering a new binary type pins the binfmt_misc +filesystem. Specifically, this means that as long as there is at least +one binary type registered the binfmt_misc filesystem survives all +umounts, i.e. the superblock is not destroyed. Meaning that a umount +followed by another mount will end up with the same superblock and the +same binary type handlers. This is a behavior we tend to discourage for +any new filesystems (apart from a few special filesystems such as e.g. +configfs or debugfs). A umount operation without the filesystem being +pinned - by e.g. someone holding a file descriptor to an open file - +should usually result in the destruction of the superblock and all +associated resources. This makes introspection easier and leads to +clearly defined, simple and clean semantics. An administrator can rely +on the fact that a umount will guarantee a clean slate making it +possible to reinitialize a filesystem. Right now all binary types would +need to be explicitly deleted before that can happen. + +This allows us to remove the heavy-handed calls to simple_pin_fs() and +simple_release_fs() when creating and deleting binary types. This in +turn allows us to replace the current brittle pinning mechanism abusing +dget() which has caused a range of bugs judging from prior fixes in [2] +and [3]. The additional dget() in load_misc_binary() pins the dentry but +only does so for the sake to prevent ->evict_inode() from freeing the +node when a user removes the binary type and kill_node() is run. Which +would mean ->interpreter and ->interp_file would be freed causing a UAF. + +This isn't really nicely documented nor is it very clean because it +relies on simple_pin_fs() pinning the filesystem as long as at least one +binary type exists. Otherwise it would cause load_misc_binary() to hold +on to a dentry belonging to a superblock that has been shutdown. +Replace that implicit pinning with a clean and simple per-node refcount +and get rid of the ugly dget() pinning. A similar mechanism exists for +e.g. binderfs (cf. [4]). All the cleanup work can now be done in +->evict_inode(). + +In a follow-up patch we will make it possible to use binfmt_misc in +sandboxes. We will use the cleaner semantics where a umount for the +filesystem will cause the superblock and all resources to be +deallocated. In preparation for this apply the same semantics to the +initial binfmt_misc mount. Note, that this is a user-visible change and +as such a uapi change but one that we can reasonably risk. We've +discussed this in earlier versions of this patchset (cf. [1]). + +The main user and provider of binfmt_misc is systemd. Systemd provides +binfmt_misc via autofs since it is configurable as a kernel module and +is used by a few exotic packages and users. As such a binfmt_misc mount +is triggered when /proc/sys/fs/binfmt_misc is accessed and is only +provided on demand. Other autofs on demand filesystems include EFI ESP +which systemd umounts if the mountpoint stays idle for a certain amount +of time. This doesn't apply to the binfmt_misc autofs mount which isn't +touched once it is mounted meaning this change can't accidently wipe +binary type handlers without someone having explicitly unmounted +binfmt_misc. After speaking to systemd folks they don't expect this +change to affect them. + +In line with our general policy, if we see a regression for systemd or +other users with this change we will switch back to the old behavior for +the initial binfmt_misc mount and have binary types pin the filesystem +again. But while we touch this code let's take the chance and let's +improve on the status quo. + +[1]: https://lore.kernel.org/r/20191216091220.465626-2-laurent@vivier.eu +[2]: commit 43a4f2619038 ("exec: binfmt_misc: fix race between load_misc_binary() and kill_node()" +[3]: commit 83f918274e4b ("exec: binfmt_misc: shift filp_close(interp_file) from kill_node() to bm_evict_inode()") +[4]: commit f0fe2c0f050d ("binder: prevent UAF for binderfs devices II") + +Link: https://lore.kernel.org/r/20211028103114.2849140-1-brauner@kernel.org (v1) +Cc: Sargun Dhillon +Cc: Serge Hallyn +Cc: Jann Horn +Cc: Henning Schild +Cc: Andrei Vagin +Cc: Al Viro +Cc: Laurent Vivier +Cc: linux-fsdevel@vger.kernel.org +Acked-by: Serge Hallyn +Signed-off-by: Christian Brauner +Signed-off-by: Christian Brauner +Signed-off-by: Kees Cook +--- +/* v2 */ +- Christian Brauner : + - Add more comments that explain what's going on. + - Rename functions while changing them to better reflect what they are + doing to make the code easier to understand. + - In the first version when a specific binary type handler was removed + either through a write to the entry's file or all binary type + handlers were removed by a write to the binfmt_misc mount's status + file all cleanup work happened during inode eviction. + That includes removal of the relevant entries from entry list. While + that works fine I disliked that model after thinking about it for a + bit. Because it means that there was a window were someone has + already removed a or all binary handlers but they could still be + safely reached from load_misc_binary() when it has managed to take + the read_lock() on the entries list while inode eviction was already + happening. Again, that perfectly benign but it's cleaner to remove + the binary handler from the list immediately meaning that ones the + write to then entry's file or the binfmt_misc status file returns + the binary type cannot be executed anymore. That gives stronger + guarantees to the user. +Signed-off-by: Sasha Levin +--- + fs/binfmt_misc.c | 216 ++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 168 insertions(+), 48 deletions(-) + +diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c +index 23b563ff0dd7a..7557fb429df5c 100644 +--- a/fs/binfmt_misc.c ++++ b/fs/binfmt_misc.c +@@ -60,12 +60,11 @@ typedef struct { + char *name; + struct dentry *dentry; + struct file *interp_file; ++ refcount_t users; /* sync removal with load_misc_binary() */ + } Node; + + static DEFINE_RWLOCK(entries_lock); + static struct file_system_type bm_fs_type; +-static struct vfsmount *bm_mnt; +-static int entry_count; + + /* + * Max length of the register string. Determined by: +@@ -82,19 +81,23 @@ static int entry_count; + */ + #define MAX_REGISTER_LENGTH 1920 + +-/* +- * Check if we support the binfmt +- * if we do, return the node, else NULL +- * locking is done in load_misc_binary ++/** ++ * search_binfmt_handler - search for a binary handler for @bprm ++ * @misc: handle to binfmt_misc instance ++ * @bprm: binary for which we are looking for a handler ++ * ++ * Search for a binary type handler for @bprm in the list of registered binary ++ * type handlers. ++ * ++ * Return: binary type list entry on success, NULL on failure + */ +-static Node *check_file(struct linux_binprm *bprm) ++static Node *search_binfmt_handler(struct linux_binprm *bprm) + { + char *p = strrchr(bprm->interp, '.'); +- struct list_head *l; ++ Node *e; + + /* Walk all the registered handlers. */ +- list_for_each(l, &entries) { +- Node *e = list_entry(l, Node, list); ++ list_for_each_entry(e, &entries, list) { + char *s; + int j; + +@@ -123,9 +126,49 @@ static Node *check_file(struct linux_binprm *bprm) + if (j == e->size) + return e; + } ++ + return NULL; + } + ++/** ++ * get_binfmt_handler - try to find a binary type handler ++ * @misc: handle to binfmt_misc instance ++ * @bprm: binary for which we are looking for a handler ++ * ++ * Try to find a binfmt handler for the binary type. If one is found take a ++ * reference to protect against removal via bm_{entry,status}_write(). ++ * ++ * Return: binary type list entry on success, NULL on failure ++ */ ++static Node *get_binfmt_handler(struct linux_binprm *bprm) ++{ ++ Node *e; ++ ++ read_lock(&entries_lock); ++ e = search_binfmt_handler(bprm); ++ if (e) ++ refcount_inc(&e->users); ++ read_unlock(&entries_lock); ++ return e; ++} ++ ++/** ++ * put_binfmt_handler - put binary handler node ++ * @e: node to put ++ * ++ * Free node syncing with load_misc_binary() and defer final free to ++ * load_misc_binary() in case it is using the binary type handler we were ++ * requested to remove. ++ */ ++static void put_binfmt_handler(Node *e) ++{ ++ if (refcount_dec_and_test(&e->users)) { ++ if (e->flags & MISC_FMT_OPEN_FILE) ++ filp_close(e->interp_file, NULL); ++ kfree(e); ++ } ++} ++ + /* + * the loader itself + */ +@@ -140,12 +183,7 @@ static int load_misc_binary(struct linux_binprm *bprm) + if (!enabled) + return retval; + +- /* to keep locking time low, we copy the interpreter string */ +- read_lock(&entries_lock); +- fmt = check_file(bprm); +- if (fmt) +- dget(fmt->dentry); +- read_unlock(&entries_lock); ++ fmt = get_binfmt_handler(bprm); + if (!fmt) + return retval; + +@@ -239,7 +277,16 @@ static int load_misc_binary(struct linux_binprm *bprm) + goto error; + + ret: +- dput(fmt->dentry); ++ ++ /* ++ * If we actually put the node here all concurrent calls to ++ * load_misc_binary() will have finished. We also know ++ * that for the refcount to be zero ->evict_inode() must have removed ++ * the node to be deleted from the list. All that is left for us is to ++ * close and free. ++ */ ++ put_binfmt_handler(fmt); ++ + return retval; + error: + if (fd_binary > 0) +@@ -600,30 +647,90 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode) + return inode; + } + ++/** ++ * bm_evict_inode - cleanup data associated with @inode ++ * @inode: inode to which the data is attached ++ * ++ * Cleanup the binary type handler data associated with @inode if a binary type ++ * entry is removed or the filesystem is unmounted and the super block is ++ * shutdown. ++ * ++ * If the ->evict call was not caused by a super block shutdown but by a write ++ * to remove the entry or all entries via bm_{entry,status}_write() the entry ++ * will have already been removed from the list. We keep the list_empty() check ++ * to make that explicit. ++*/ + static void bm_evict_inode(struct inode *inode) + { + Node *e = inode->i_private; + +- if (e && e->flags & MISC_FMT_OPEN_FILE) +- filp_close(e->interp_file, NULL); +- + clear_inode(inode); +- kfree(e); ++ ++ if (e) { ++ write_lock(&entries_lock); ++ if (!list_empty(&e->list)) ++ list_del_init(&e->list); ++ write_unlock(&entries_lock); ++ put_binfmt_handler(e); ++ } + } + +-static void kill_node(Node *e) ++/** ++ * unlink_binfmt_dentry - remove the dentry for the binary type handler ++ * @dentry: dentry associated with the binary type handler ++ * ++ * Do the actual filesystem work to remove a dentry for a registered binary ++ * type handler. Since binfmt_misc only allows simple files to be created ++ * directly under the root dentry of the filesystem we ensure that we are ++ * indeed passed a dentry directly beneath the root dentry, that the inode ++ * associated with the root dentry is locked, and that it is a regular file we ++ * are asked to remove. ++ */ ++static void unlink_binfmt_dentry(struct dentry *dentry) + { +- struct dentry *dentry; ++ struct dentry *parent = dentry->d_parent; ++ struct inode *inode, *parent_inode; ++ ++ /* All entries are immediate descendants of the root dentry. */ ++ if (WARN_ON_ONCE(dentry->d_sb->s_root != parent)) ++ return; + ++ /* We only expect to be called on regular files. */ ++ inode = d_inode(dentry); ++ if (WARN_ON_ONCE(!S_ISREG(inode->i_mode))) ++ return; ++ ++ /* The parent inode must be locked. */ ++ parent_inode = d_inode(parent); ++ if (WARN_ON_ONCE(!inode_is_locked(parent_inode))) ++ return; ++ ++ if (simple_positive(dentry)) { ++ dget(dentry); ++ simple_unlink(parent_inode, dentry); ++ d_delete(dentry); ++ dput(dentry); ++ } ++} ++ ++/** ++ * remove_binfmt_handler - remove a binary type handler ++ * @misc: handle to binfmt_misc instance ++ * @e: binary type handler to remove ++ * ++ * Remove a binary type handler from the list of binary type handlers and ++ * remove its associated dentry. This is called from ++ * binfmt_{entry,status}_write(). In the future, we might want to think about ++ * adding a proper ->unlink() method to binfmt_misc instead of forcing caller's ++ * to use writes to files in order to delete binary type handlers. But it has ++ * worked for so long that it's not a pressing issue. ++ */ ++static void remove_binfmt_handler(Node *e) ++{ + write_lock(&entries_lock); + list_del_init(&e->list); + write_unlock(&entries_lock); +- +- dentry = e->dentry; +- drop_nlink(d_inode(dentry)); +- d_drop(dentry); +- dput(dentry); +- simple_release_fs(&bm_mnt, &entry_count); ++ unlink_binfmt_dentry(e->dentry); + } + + /* / */ +@@ -650,8 +757,8 @@ bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) + static ssize_t bm_entry_write(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) + { +- struct dentry *root; +- Node *e = file_inode(file)->i_private; ++ struct inode *inode = file_inode(file); ++ Node *e = inode->i_private; + int res = parse_command(buffer, count); + + switch (res) { +@@ -665,13 +772,22 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer, + break; + case 3: + /* Delete this handler. */ +- root = file_inode(file)->i_sb->s_root; +- inode_lock(d_inode(root)); ++ inode = d_inode(inode->i_sb->s_root); ++ inode_lock(inode); + ++ /* ++ * In order to add new element or remove elements from the list ++ * via bm_{entry,register,status}_write() inode_lock() on the ++ * root inode must be held. ++ * The lock is exclusive ensuring that the list can't be ++ * modified. Only load_misc_binary() can access but does so ++ * read-only. So we only need to take the write lock when we ++ * actually remove the entry from the list. ++ */ + if (!list_empty(&e->list)) +- kill_node(e); ++ remove_binfmt_handler(e); + +- inode_unlock(d_inode(root)); ++ inode_unlock(inode); + break; + default: + return res; +@@ -730,13 +846,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, + if (!inode) + goto out2; + +- err = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count); +- if (err) { +- iput(inode); +- inode = NULL; +- goto out2; +- } +- ++ refcount_set(&e->users, 1); + e->dentry = dget(dentry); + inode->i_private = e; + inode->i_fop = &bm_entry_operations; +@@ -780,7 +890,8 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) + { + int res = parse_command(buffer, count); +- struct dentry *root; ++ Node *e, *next; ++ struct inode *inode; + + switch (res) { + case 1: +@@ -793,13 +904,22 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer, + break; + case 3: + /* Delete all handlers. */ +- root = file_inode(file)->i_sb->s_root; +- inode_lock(d_inode(root)); ++ inode = d_inode(file_inode(file)->i_sb->s_root); ++ inode_lock(inode); + +- while (!list_empty(&entries)) +- kill_node(list_first_entry(&entries, Node, list)); ++ /* ++ * In order to add new element or remove elements from the list ++ * via bm_{entry,register,status}_write() inode_lock() on the ++ * root inode must be held. ++ * The lock is exclusive ensuring that the list can't be ++ * modified. Only load_misc_binary() can access but does so ++ * read-only. So we only need to take the write lock when we ++ * actually remove the entry from the list. ++ */ ++ list_for_each_entry_safe(e, next, &entries, list) ++ remove_binfmt_handler(e); + +- inode_unlock(d_inode(root)); ++ inode_unlock(inode); + break; + default: + return res; +-- +2.43.0 + diff --git a/queue-5.4/gfs2-setattr_chown-add-missing-initialization.patch b/queue-5.4/gfs2-setattr_chown-add-missing-initialization.patch new file mode 100644 index 00000000000..2859f2f1a9e --- /dev/null +++ b/queue-5.4/gfs2-setattr_chown-add-missing-initialization.patch @@ -0,0 +1,34 @@ +From 3bb42877c81492f83a4bb8d2eabf9ecf03452e67 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 21 Oct 2023 20:51:13 +0200 +Subject: gfs2: setattr_chown: Add missing initialization + +From: Andreas Gruenbacher + +[ Upstream commit 2d8d7990619878a848b1d916c2f936d3012ee17d ] + +Add a missing initialization of variable ap in setattr_chown(). +Without, chown() may be able to bypass quotas. + +Signed-off-by: Andreas Gruenbacher +Signed-off-by: Sasha Levin +--- + fs/gfs2/inode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c +index 988bb7b17ed8f..4e0c933e08002 100644 +--- a/fs/gfs2/inode.c ++++ b/fs/gfs2/inode.c +@@ -1869,7 +1869,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) + kuid_t ouid, nuid; + kgid_t ogid, ngid; + int error; +- struct gfs2_alloc_parms ap; ++ struct gfs2_alloc_parms ap = {}; + + ouid = inode->i_uid; + ogid = inode->i_gid; +-- +2.43.0 + diff --git a/queue-5.4/i2c-riic-avoid-potential-division-by-zero.patch b/queue-5.4/i2c-riic-avoid-potential-division-by-zero.patch new file mode 100644 index 00000000000..08fa551837d --- /dev/null +++ b/queue-5.4/i2c-riic-avoid-potential-division-by-zero.patch @@ -0,0 +1,35 @@ +From 2aa99676f7e41c09f492041ece441385114c46a9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Sep 2023 22:00:23 +0200 +Subject: i2c: riic: avoid potential division by zero + +From: Wolfram Sang + +[ Upstream commit 7890fce6201aed46d3576e3d641f9ee5c1f0e16f ] + +Value comes from DT, so it could be 0. Unlikely, but could be. + +Signed-off-by: Wolfram Sang +Reviewed-by: Geert Uytterhoeven +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-riic.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c +index 800414886f6b5..588a3efb09c26 100644 +--- a/drivers/i2c/busses/i2c-riic.c ++++ b/drivers/i2c/busses/i2c-riic.c +@@ -312,7 +312,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t) + * frequency with only 62 clock ticks max (31 high, 31 low). + * Aim for a duty of 60% LOW, 40% HIGH. + */ +- total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz); ++ total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1); + + for (cks = 0; cks < 7; cks++) { + /* +-- +2.43.0 + diff --git a/queue-5.4/ib-hfi1-fix-potential-deadlock-on-irq_src_lock-and-d.patch b/queue-5.4/ib-hfi1-fix-potential-deadlock-on-irq_src_lock-and-d.patch new file mode 100644 index 00000000000..43051914ce5 --- /dev/null +++ b/queue-5.4/ib-hfi1-fix-potential-deadlock-on-irq_src_lock-and-d.patch @@ -0,0 +1,77 @@ +From 8665f66a553821a2a9f3406c883b1263de90984c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Sep 2023 10:11:16 +0000 +Subject: IB/hfi1: Fix potential deadlock on &irq_src_lock and &dd->uctxt_lock + +From: Chengfeng Ye + +[ Upstream commit 2f19c4b8395ccb6eb25ccafee883c8cfbe3fc193 ] + +handle_receive_interrupt_napi_sp() running inside interrupt handler +could introduce inverse lock ordering between &dd->irq_src_lock +and &dd->uctxt_lock, if read_mod_write() is preempted by the isr. + + [CPU0] | [CPU1] +hfi1_ipoib_dev_open() | +--> hfi1_netdev_enable_queues() | +--> enable_queues(rx) | +--> hfi1_rcvctrl() | +--> set_intr_bits() | +--> read_mod_write() | +--> spin_lock(&dd->irq_src_lock) | + | hfi1_poll() + | --> poll_next() + | --> spin_lock_irq(&dd->uctxt_lock) + | + | --> hfi1_rcvctrl() + | --> set_intr_bits() + | --> read_mod_write() + | --> spin_lock(&dd->irq_src_lock) + | + --> handle_receive_interrupt_napi_sp() | + --> set_all_fastpath() | + --> hfi1_rcd_get_by_index() | + --> spin_lock_irqsave(&dd->uctxt_lock) | + +This flaw was found by an experimental static analysis tool I am +developing for irq-related deadlock. + +To prevent the potential deadlock, the patch use spin_lock_irqsave() +on &dd->irq_src_lock inside read_mod_write() to prevent the possible +deadlock scenario. + +Signed-off-by: Chengfeng Ye +Link: https://lore.kernel.org/r/20230926101116.2797-1-dg573847474@gmail.com +Acked-by: Dennis Dalessandro +Signed-off-by: Leon Romanovsky +Signed-off-by: Sasha Levin +--- + drivers/infiniband/hw/hfi1/chip.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c +index 65d6bf34614c8..6cf87fcfc4eb5 100644 +--- a/drivers/infiniband/hw/hfi1/chip.c ++++ b/drivers/infiniband/hw/hfi1/chip.c +@@ -13067,15 +13067,16 @@ static void read_mod_write(struct hfi1_devdata *dd, u16 src, u64 bits, + { + u64 reg; + u16 idx = src / BITS_PER_REGISTER; ++ unsigned long flags; + +- spin_lock(&dd->irq_src_lock); ++ spin_lock_irqsave(&dd->irq_src_lock, flags); + reg = read_csr(dd, CCE_INT_MASK + (8 * idx)); + if (set) + reg |= bits; + else + reg &= ~bits; + write_csr(dd, CCE_INT_MASK + (8 * idx), reg); +- spin_unlock(&dd->irq_src_lock); ++ spin_unlock_irqrestore(&dd->irq_src_lock, flags); + } + + /** +-- +2.43.0 + diff --git a/queue-5.4/media-radio-isa-use-dev_name-to-fill-in-bus_info.patch b/queue-5.4/media-radio-isa-use-dev_name-to-fill-in-bus_info.patch new file mode 100644 index 00000000000..3276254a788 --- /dev/null +++ b/queue-5.4/media-radio-isa-use-dev_name-to-fill-in-bus_info.patch @@ -0,0 +1,41 @@ +From 4d1372aa34ca1af48cfbfa53460ffc76730e36aa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 23 Sep 2023 17:21:04 +0200 +Subject: media: radio-isa: use dev_name to fill in bus_info + +From: Hans Verkuil + +[ Upstream commit 8b7f3cf4eb9a95940eaabad3226caeaa0d9aa59d ] + +This fixes this warning: + +drivers/media/radio/radio-isa.c: In function 'radio_isa_querycap': +drivers/media/radio/radio-isa.c:39:57: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 28 [-Wformat-truncation=] + 39 | snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name); + | ^~ +drivers/media/radio/radio-isa.c:39:9: note: 'snprintf' output between 5 and 40 bytes into a destination of size 32 + 39 | snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Hans Verkuil +Signed-off-by: Sasha Levin +--- + drivers/media/radio/radio-isa.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/media/radio/radio-isa.c b/drivers/media/radio/radio-isa.c +index ad2ac16ff12dd..610d3e3269518 100644 +--- a/drivers/media/radio/radio-isa.c ++++ b/drivers/media/radio/radio-isa.c +@@ -36,7 +36,7 @@ static int radio_isa_querycap(struct file *file, void *priv, + + strscpy(v->driver, isa->drv->driver.driver.name, sizeof(v->driver)); + strscpy(v->card, isa->drv->card, sizeof(v->card)); +- snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name); ++ snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", dev_name(isa->v4l2_dev.dev)); + return 0; + } + +-- +2.43.0 + diff --git a/queue-5.4/scsi-spi-fix-sshdr-use.patch b/queue-5.4/scsi-spi-fix-sshdr-use.patch new file mode 100644 index 00000000000..589d07d1d65 --- /dev/null +++ b/queue-5.4/scsi-spi-fix-sshdr-use.patch @@ -0,0 +1,45 @@ +From fb43d9fff03cf15a68aca3372241110aaabdf8ca Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 16:00:07 -0500 +Subject: scsi: spi: Fix sshdr use + +From: Mike Christie + +[ Upstream commit 0b149cee836aa53989ea089af1cb9d90d7c6ac9e ] + +If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we +shouldn't access the sshdr. If it returns 0, then the cmd executed +successfully, so there is no need to check the sshdr. This has us access +the sshdr when we get a return value > 0. + +Signed-off-by: Mike Christie +Link: https://lore.kernel.org/r/20231004210013.5601-7-michael.christie@oracle.com +Reviewed-by: Christoph Hellwig +Reviewed-by: John Garry +Reviewed-by: Martin Wilck +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_transport_spi.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c +index c37dd15d16d24..83f2576ed2aa0 100644 +--- a/drivers/scsi/scsi_transport_spi.c ++++ b/drivers/scsi/scsi_transport_spi.c +@@ -677,10 +677,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, + for (r = 0; r < retries; r++) { + result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE, + buffer, len, &sshdr); +- if(result || !scsi_device_online(sdev)) { ++ if (result || !scsi_device_online(sdev)) { + + scsi_device_set_state(sdev, SDEV_QUIESCE); +- if (scsi_sense_valid(&sshdr) ++ if (result > 0 && scsi_sense_valid(&sshdr) + && sshdr.sense_key == ILLEGAL_REQUEST + /* INVALID FIELD IN CDB */ + && sshdr.asc == 0x24 && sshdr.ascq == 0x00) +-- +2.43.0 + diff --git a/queue-5.4/series b/queue-5.4/series index b5c7cd9d181..8af68a666c5 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -30,3 +30,13 @@ netfilter-nf_defrag_ipv6-use-net_generic-infra.patch netfilter-allow-ipv6-fragments-to-arrive-on-differen.patch net-hns3-fix-a-deadlock-problem-when-config-tc-durin.patch alsa-hda-realtek-fix-noise-from-speakers-on-lenovo-i.patch +ssb-fix-division-by-zero-issue-in-ssb_calc_clock_rat.patch +wifi-cw1200-avoid-processing-an-invalid-tim-ie.patch +i2c-riic-avoid-potential-division-by-zero.patch +media-radio-isa-use-dev_name-to-fill-in-bus_info.patch +staging-ks7010-disable-bh-on-tx_dev_lock.patch +binfmt_misc-cleanup-on-filesystem-umount.patch +scsi-spi-fix-sshdr-use.patch +gfs2-setattr_chown-add-missing-initialization.patch +wifi-iwlwifi-abort-scan-when-rfkill-on-but-device-en.patch +ib-hfi1-fix-potential-deadlock-on-irq_src_lock-and-d.patch diff --git a/queue-5.4/ssb-fix-division-by-zero-issue-in-ssb_calc_clock_rat.patch b/queue-5.4/ssb-fix-division-by-zero-issue-in-ssb_calc_clock_rat.patch new file mode 100644 index 00000000000..4179e1c4ddf --- /dev/null +++ b/queue-5.4/ssb-fix-division-by-zero-issue-in-ssb_calc_clock_rat.patch @@ -0,0 +1,49 @@ +From 28958ce4a983d97ac3762bd606a020e27957d568 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 5 Sep 2023 02:23:46 +0300 +Subject: ssb: Fix division by zero issue in ssb_calc_clock_rate +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rand Deeb + +[ Upstream commit e0b5127fa134fe0284d58877b6b3133939c8b3ce ] + +In ssb_calc_clock_rate(), there is a potential issue where the value of +m1 could be zero due to initialization using clkfactor_f6_resolv(). This +situation raised concerns about the possibility of a division by zero +error. + +We fixed it by following the suggestions provided by Larry Finger + and Michael Büsch . The fix +involves returning a value of 1 instead of 0 in clkfactor_f6_resolv(). +This modification ensures the proper functioning of the code and +eliminates the risk of division by zero errors. + +Signed-off-by: Rand Deeb +Acked-by: Larry Finger +Acked-by: Michael Büsch +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230904232346.34991-1-rand.sec96@gmail.com +Signed-off-by: Sasha Levin +--- + drivers/ssb/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c +index 0a26984acb2ca..9e54bc7eec663 100644 +--- a/drivers/ssb/main.c ++++ b/drivers/ssb/main.c +@@ -835,7 +835,7 @@ static u32 clkfactor_f6_resolve(u32 v) + case SSB_CHIPCO_CLK_F6_7: + return 7; + } +- return 0; ++ return 1; + } + + /* Calculate the speed the backplane would run at a given set of clockcontrol values */ +-- +2.43.0 + diff --git a/queue-5.4/staging-ks7010-disable-bh-on-tx_dev_lock.patch b/queue-5.4/staging-ks7010-disable-bh-on-tx_dev_lock.patch new file mode 100644 index 00000000000..bf88f431b3d --- /dev/null +++ b/queue-5.4/staging-ks7010-disable-bh-on-tx_dev_lock.patch @@ -0,0 +1,51 @@ +From 9986547f626c77d7c69da7914f29c830c3393edc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Sep 2023 16:13:23 +0000 +Subject: staging: ks7010: disable bh on tx_dev_lock + +From: Chengfeng Ye + +[ Upstream commit 058cbee52ccd7be77e373d31a4f14670cfd32018 ] + +As &priv->tx_dev.tx_dev_lock is also acquired by xmit callback which +could be call from timer under softirq context, use spin_lock_bh() +on it to prevent potential deadlock. + +hostif_sme_work() +--> hostif_sme_set_pmksa() +--> hostif_mib_set_request() +--> ks_wlan_hw_tx() +--> spin_lock(&priv->tx_dev.tx_dev_lock) + +ks_wlan_start_xmit() +--> hostif_data_request() +--> ks_wlan_hw_tx() +--> spin_lock(&priv->tx_dev.tx_dev_lock) + +Signed-off-by: Chengfeng Ye +Link: https://lore.kernel.org/r/20230926161323.41928-1-dg573847474@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/staging/ks7010/ks7010_sdio.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c +index 3fbe223d59b8e..28723db44a8ff 100644 +--- a/drivers/staging/ks7010/ks7010_sdio.c ++++ b/drivers/staging/ks7010/ks7010_sdio.c +@@ -395,9 +395,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, + priv->hostt.buff[priv->hostt.qtail] = le16_to_cpu(hdr->event); + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + +- spin_lock(&priv->tx_dev.tx_dev_lock); ++ spin_lock_bh(&priv->tx_dev.tx_dev_lock); + result = enqueue_txdev(priv, p, size, complete_handler, skb); +- spin_unlock(&priv->tx_dev.tx_dev_lock); ++ spin_unlock_bh(&priv->tx_dev.tx_dev_lock); + + if (txq_has_space(priv)) + queue_delayed_work(priv->wq, &priv->rw_dwork, 0); +-- +2.43.0 + diff --git a/queue-5.4/wifi-cw1200-avoid-processing-an-invalid-tim-ie.patch b/queue-5.4/wifi-cw1200-avoid-processing-an-invalid-tim-ie.patch new file mode 100644 index 00000000000..26c57b4497d --- /dev/null +++ b/queue-5.4/wifi-cw1200-avoid-processing-an-invalid-tim-ie.patch @@ -0,0 +1,39 @@ +From 5289731e2a7e5bc94a7146b846c9b4c5c327e16d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 31 Aug 2023 11:22:57 -0700 +Subject: wifi: cw1200: Avoid processing an invalid TIM IE + +From: Jeff Johnson + +[ Upstream commit b7bcea9c27b3d87b54075735c870500123582145 ] + +While converting struct ieee80211_tim_ie::virtual_map to be a flexible +array it was observed that the TIM IE processing in cw1200_rx_cb() +could potentially process a malformed IE in a manner that could result +in a buffer over-read. Add logic to verify that the TIM IE length is +large enough to hold a valid TIM payload before processing it. + +Signed-off-by: Jeff Johnson +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230831-ieee80211_tim_ie-v3-1-e10ff584ab5d@quicinc.com +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/st/cw1200/txrx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/st/cw1200/txrx.c b/drivers/net/wireless/st/cw1200/txrx.c +index 2dfcdb1459441..31f5b2d8f5191 100644 +--- a/drivers/net/wireless/st/cw1200/txrx.c ++++ b/drivers/net/wireless/st/cw1200/txrx.c +@@ -1170,7 +1170,7 @@ void cw1200_rx_cb(struct cw1200_common *priv, + size_t ies_len = skb->len - (ies - (u8 *)(skb->data)); + + tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); +- if (tim_ie) { ++ if (tim_ie && tim_ie[1] >= sizeof(struct ieee80211_tim_ie)) { + struct ieee80211_tim_ie *tim = + (struct ieee80211_tim_ie *)&tim_ie[2]; + +-- +2.43.0 + diff --git a/queue-5.4/wifi-iwlwifi-abort-scan-when-rfkill-on-but-device-en.patch b/queue-5.4/wifi-iwlwifi-abort-scan-when-rfkill-on-but-device-en.patch new file mode 100644 index 00000000000..8aee9f3e9ed --- /dev/null +++ b/queue-5.4/wifi-iwlwifi-abort-scan-when-rfkill-on-but-device-en.patch @@ -0,0 +1,47 @@ +From 770446dd0bb0367183171e67a592e570bcb67d90 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Oct 2023 12:36:28 +0300 +Subject: wifi: iwlwifi: abort scan when rfkill on but device enabled + +From: Miri Korenblit + +[ Upstream commit 3c6a0b1f0add72e7f522bc9145222b86d0a7712a ] + +In RFKILL we first set the RFKILL bit, then we abort scan +(if one exists) by waiting for the notification from FW +and notifying mac80211. And then we stop the device. +But in case we have a scan ongoing in the period of time between +rfkill on and before the device is stopped - we will not wait for the +FW notification because of the iwl_mvm_is_radio_killed() condition, +and then the scan_status and uid_status are misconfigured, +(scan_status is cleared but uid_status not) +and when the notification suddenly arrives (before stopping the device) +we will get into the assert about scan_status and uid_status mismatch. +Fix this by waiting for FW notif when rfkill is on but the device isn't +disabled yet. + +Signed-off-by: Miri Korenblit +Signed-off-by: Gregory Greenman +Link: https://lore.kernel.org/r/20231004123422.c43b69aa2c77.Icc7b5efb47974d6f499156ff7510b786e177993b@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c +index 3a58267d3d710..3bce3b59a12b1 100644 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c +@@ -2140,7 +2140,7 @@ int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify) + if (!(mvm->scan_status & type)) + return 0; + +- if (iwl_mvm_is_radio_killed(mvm)) { ++ if (!test_bit(STATUS_DEVICE_ENABLED, &mvm->trans->status)) { + ret = 0; + goto out; + } +-- +2.43.0 +