From: Greg Kroah-Hartman Date: Mon, 20 Dec 2021 12:33:39 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.4.296~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d0b700ebe0a201265ea10cbe5b83cb7662b0be5;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: fuse-annotate-lock-in-fuse_reverse_inval_entry.patch ovl-fix-warning-in-ovl_create_real.patch scsi-scsi_debug-sanity-check-block-descriptor-length-in-resp_mode_select.patch --- diff --git a/queue-4.19/fuse-annotate-lock-in-fuse_reverse_inval_entry.patch b/queue-4.19/fuse-annotate-lock-in-fuse_reverse_inval_entry.patch new file mode 100644 index 00000000000..c6f9f52e92e --- /dev/null +++ b/queue-4.19/fuse-annotate-lock-in-fuse_reverse_inval_entry.patch @@ -0,0 +1,29 @@ +From bda9a71980e083699a0360963c0135657b73f47a Mon Sep 17 00:00:00 2001 +From: Miklos Szeredi +Date: Fri, 22 Oct 2021 17:03:01 +0200 +Subject: fuse: annotate lock in fuse_reverse_inval_entry() + +From: Miklos Szeredi + +commit bda9a71980e083699a0360963c0135657b73f47a upstream. + +Add missing inode lock annotatation; found by syzbot. + +Reported-and-tested-by: syzbot+9f747458f5990eaa8d43@syzkaller.appspotmail.com +Signed-off-by: Miklos Szeredi +Signed-off-by: Greg Kroah-Hartman +--- + fs/fuse/dir.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/fuse/dir.c ++++ b/fs/fuse/dir.c +@@ -984,7 +984,7 @@ int fuse_reverse_inval_entry(struct supe + if (!parent) + return -ENOENT; + +- inode_lock(parent); ++ inode_lock_nested(parent, I_MUTEX_PARENT); + if (!S_ISDIR(parent->i_mode)) + goto unlock; + diff --git a/queue-4.19/ovl-fix-warning-in-ovl_create_real.patch b/queue-4.19/ovl-fix-warning-in-ovl_create_real.patch new file mode 100644 index 00000000000..9f541ed3cc7 --- /dev/null +++ b/queue-4.19/ovl-fix-warning-in-ovl_create_real.patch @@ -0,0 +1,73 @@ +From 1f5573cfe7a7056e80a92c7a037a3e69f3a13d1c Mon Sep 17 00:00:00 2001 +From: Miklos Szeredi +Date: Thu, 4 Nov 2021 10:55:34 +0100 +Subject: ovl: fix warning in ovl_create_real() + +From: Miklos Szeredi + +commit 1f5573cfe7a7056e80a92c7a037a3e69f3a13d1c upstream. + +Syzbot triggered the following warning in ovl_workdir_create() -> +ovl_create_real(): + + if (!err && WARN_ON(!newdentry->d_inode)) { + +The reason is that the cgroup2 filesystem returns from mkdir without +instantiating the new dentry. + +Weird filesystems such as this will be rejected by overlayfs at a later +stage during setup, but to prevent such a warning, call ovl_mkdir_real() +directly from ovl_workdir_create() and reject this case early. + +Reported-and-tested-by: syzbot+75eab84fd0af9e8bf66b@syzkaller.appspotmail.com +Signed-off-by: Miklos Szeredi +Signed-off-by: Greg Kroah-Hartman +--- + fs/overlayfs/dir.c | 3 +-- + fs/overlayfs/overlayfs.h | 1 + + fs/overlayfs/super.c | 12 ++++++++---- + 3 files changed, 10 insertions(+), 6 deletions(-) + +--- a/fs/overlayfs/dir.c ++++ b/fs/overlayfs/dir.c +@@ -116,8 +116,7 @@ kill_whiteout: + goto out; + } + +-static int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, +- umode_t mode) ++int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode) + { + int err; + struct dentry *d, *dentry = *newdentry; +--- a/fs/overlayfs/overlayfs.h ++++ b/fs/overlayfs/overlayfs.h +@@ -402,6 +402,7 @@ struct ovl_cattr { + + #define OVL_CATTR(m) (&(struct ovl_cattr) { .mode = (m) }) + ++int ovl_mkdir_real(struct inode *dir, struct dentry **newdentry, umode_t mode); + struct dentry *ovl_create_real(struct inode *dir, struct dentry *newdentry, + struct ovl_cattr *attr); + int ovl_cleanup(struct inode *dir, struct dentry *dentry); +--- a/fs/overlayfs/super.c ++++ b/fs/overlayfs/super.c +@@ -654,10 +654,14 @@ retry: + goto retry; + } + +- work = ovl_create_real(dir, work, OVL_CATTR(attr.ia_mode)); +- err = PTR_ERR(work); +- if (IS_ERR(work)) +- goto out_err; ++ err = ovl_mkdir_real(dir, &work, attr.ia_mode); ++ if (err) ++ goto out_dput; ++ ++ /* Weird filesystem returning with hashed negative (kernfs)? */ ++ err = -EINVAL; ++ if (d_really_is_negative(work)) ++ goto out_dput; + + /* + * Try to remove POSIX ACL xattrs from workdir. We are good if: diff --git a/queue-4.19/scsi-scsi_debug-sanity-check-block-descriptor-length-in-resp_mode_select.patch b/queue-4.19/scsi-scsi_debug-sanity-check-block-descriptor-length-in-resp_mode_select.patch new file mode 100644 index 00000000000..0131a1f4c31 --- /dev/null +++ b/queue-4.19/scsi-scsi_debug-sanity-check-block-descriptor-length-in-resp_mode_select.patch @@ -0,0 +1,68 @@ +From e0a2c28da11e2c2b963fc01d50acbf03045ac732 Mon Sep 17 00:00:00 2001 +From: George Kennedy +Date: Thu, 18 Nov 2021 14:03:28 -0500 +Subject: scsi: scsi_debug: Sanity check block descriptor length in resp_mode_select() + +From: George Kennedy + +commit e0a2c28da11e2c2b963fc01d50acbf03045ac732 upstream. + +In resp_mode_select() sanity check the block descriptor len to avoid UAF. + +BUG: KASAN: use-after-free in resp_mode_select+0xa4c/0xb40 drivers/scsi/scsi_debug.c:2509 +Read of size 1 at addr ffff888026670f50 by task scsicmd/15032 + +CPU: 1 PID: 15032 Comm: scsicmd Not tainted 5.15.0-01d0625 #15 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS +Call Trace: + + dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:107 + print_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:257 + kasan_report.cold.14+0x7d/0x117 mm/kasan/report.c:443 + __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:306 + resp_mode_select+0xa4c/0xb40 drivers/scsi/scsi_debug.c:2509 + schedule_resp+0x4af/0x1a10 drivers/scsi/scsi_debug.c:5483 + scsi_debug_queuecommand+0x8c9/0x1e70 drivers/scsi/scsi_debug.c:7537 + scsi_queue_rq+0x16b4/0x2d10 drivers/scsi/scsi_lib.c:1521 + blk_mq_dispatch_rq_list+0xb9b/0x2700 block/blk-mq.c:1640 + __blk_mq_sched_dispatch_requests+0x28f/0x590 block/blk-mq-sched.c:325 + blk_mq_sched_dispatch_requests+0x105/0x190 block/blk-mq-sched.c:358 + __blk_mq_run_hw_queue+0xe5/0x150 block/blk-mq.c:1762 + __blk_mq_delay_run_hw_queue+0x4f8/0x5c0 block/blk-mq.c:1839 + blk_mq_run_hw_queue+0x18d/0x350 block/blk-mq.c:1891 + blk_mq_sched_insert_request+0x3db/0x4e0 block/blk-mq-sched.c:474 + blk_execute_rq_nowait+0x16b/0x1c0 block/blk-exec.c:63 + sg_common_write.isra.18+0xeb3/0x2000 drivers/scsi/sg.c:837 + sg_new_write.isra.19+0x570/0x8c0 drivers/scsi/sg.c:775 + sg_ioctl_common+0x14d6/0x2710 drivers/scsi/sg.c:941 + sg_ioctl+0xa2/0x180 drivers/scsi/sg.c:1166 + __x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:52 + do_syscall_64+0x3a/0x80 arch/x86/entry/common.c:50 + entry_SYSCALL_64_after_hwframe+0x44/0xae arch/x86/entry/entry_64.S:113 + +Link: https://lore.kernel.org/r/1637262208-28850-1-git-send-email-george.kennedy@oracle.com +Reported-by: syzkaller +Acked-by: Douglas Gilbert +Signed-off-by: George Kennedy +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/scsi_debug.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/scsi/scsi_debug.c ++++ b/drivers/scsi/scsi_debug.c +@@ -2300,11 +2300,11 @@ static int resp_mode_select(struct scsi_ + __func__, param_len, res); + md_len = mselect6 ? (arr[0] + 1) : (get_unaligned_be16(arr + 0) + 2); + bd_len = mselect6 ? arr[3] : get_unaligned_be16(arr + 6); +- if (md_len > 2) { ++ off = bd_len + (mselect6 ? 4 : 8); ++ if (md_len > 2 || off >= res) { + mk_sense_invalid_fld(scp, SDEB_IN_DATA, 0, -1); + return check_condition_result; + } +- off = bd_len + (mselect6 ? 4 : 8); + mpage = arr[off] & 0x3f; + ps = !!(arr[off] & 0x80); + if (ps) { diff --git a/queue-4.19/series b/queue-4.19/series index 64fc5f0d2b6..318830e79a7 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -46,3 +46,6 @@ input-touchscreen-avoid-bitwise-vs-logical-or-warning.patch firmware-arm_scpi-fix-string-overflow-in-scpi-genpd-driver.patch arm-dts-imx6ull-pinfunc-fix-csi_data07__esai_tx0-pad-name.patch media-mxl111sf-change-mutex_init-location.patch +fuse-annotate-lock-in-fuse_reverse_inval_entry.patch +ovl-fix-warning-in-ovl_create_real.patch +scsi-scsi_debug-sanity-check-block-descriptor-length-in-resp_mode_select.patch