From e4e00eae8409a08e0de7d5fd66976edffe8b502b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 27 Jan 2024 14:23:26 -0800 Subject: [PATCH] 5.4-stable patches added patches: btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch rbd-don-t-move-requests-to-the-running-list-on-errors.patch --- ...ags-of-btrfs_ioctl_defrag_range_args.patch | 54 +++++++++++++ ...scard-range-is-not-aligned-to-sector.patch | 37 +++++++++ ...-ref-cache-before-clearing-mount-opt.patch | 57 ++++++++++++++ ...ix-inline-ref-size-in-error-messages.patch | 35 +++++++++ ...nore-touchpad-wakeup-on-gpd-g1619-04.patch | 46 +++++++++++ ...reject-queue-drop-verdict-parameters.patch | 69 +++++++++++++++++ ...quests-to-the-running-list-on-errors.patch | 77 +++++++++++++++++++ queue-5.4/series | 7 ++ 8 files changed, 382 insertions(+) create mode 100644 queue-5.4/btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch create mode 100644 queue-5.4/btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch create mode 100644 queue-5.4/btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch create mode 100644 queue-5.4/btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch create mode 100644 queue-5.4/gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch create mode 100644 queue-5.4/netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch create mode 100644 queue-5.4/rbd-don-t-move-requests-to-the-running-list-on-errors.patch diff --git a/queue-5.4/btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch b/queue-5.4/btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch new file mode 100644 index 00000000000..97ae4a78d1c --- /dev/null +++ b/queue-5.4/btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch @@ -0,0 +1,54 @@ +From 173431b274a9a54fc10b273b46e67f46bcf62d2e Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Wed, 10 Jan 2024 08:58:26 +1030 +Subject: btrfs: defrag: reject unknown flags of btrfs_ioctl_defrag_range_args + +From: Qu Wenruo + +commit 173431b274a9a54fc10b273b46e67f46bcf62d2e upstream. + +Add extra sanity check for btrfs_ioctl_defrag_range_args::flags. + +This is not really to enhance fuzzing tests, but as a preparation for +future expansion on btrfs_ioctl_defrag_range_args. + +In the future we're going to add new members, allowing more fine tuning +for btrfs defrag. Without the -ENONOTSUPP error, there would be no way +to detect if the kernel supports those new defrag features. + +CC: stable@vger.kernel.org # 4.14+ +Reviewed-by: Filipe Manana +Signed-off-by: Qu Wenruo +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/ioctl.c | 4 ++++ + include/uapi/linux/btrfs.h | 3 +++ + 2 files changed, 7 insertions(+) + +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -3102,6 +3102,10 @@ static int btrfs_ioctl_defrag(struct fil + kfree(range); + goto out; + } ++ if (range->flags & ~BTRFS_DEFRAG_RANGE_FLAGS_SUPP) { ++ ret = -EOPNOTSUPP; ++ goto out; ++ } + /* compression requires us to start the IO */ + if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) { + range->flags |= BTRFS_DEFRAG_RANGE_START_IO; +--- a/include/uapi/linux/btrfs.h ++++ b/include/uapi/linux/btrfs.h +@@ -539,6 +539,9 @@ struct btrfs_ioctl_clone_range_args { + */ + #define BTRFS_DEFRAG_RANGE_COMPRESS 1 + #define BTRFS_DEFRAG_RANGE_START_IO 2 ++#define BTRFS_DEFRAG_RANGE_FLAGS_SUPP (BTRFS_DEFRAG_RANGE_COMPRESS | \ ++ BTRFS_DEFRAG_RANGE_START_IO) ++ + struct btrfs_ioctl_defrag_range_args { + /* start of the defrag operation */ + __u64 start; diff --git a/queue-5.4/btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch b/queue-5.4/btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch new file mode 100644 index 00000000000..86c3666e6ba --- /dev/null +++ b/queue-5.4/btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch @@ -0,0 +1,37 @@ +From a208b3f132b48e1f94f620024e66fea635925877 Mon Sep 17 00:00:00 2001 +From: David Sterba +Date: Mon, 15 Jan 2024 20:30:26 +0100 +Subject: btrfs: don't warn if discard range is not aligned to sector + +From: David Sterba + +commit a208b3f132b48e1f94f620024e66fea635925877 upstream. + +There's a warning in btrfs_issue_discard() when the range is not aligned +to 512 bytes, originally added in 4d89d377bbb0 ("btrfs: +btrfs_issue_discard ensure offset/length are aligned to sector +boundaries"). We can't do sub-sector writes anyway so the adjustment is +the only thing that we can do and the warning is unnecessary. + +CC: stable@vger.kernel.org # 4.19+ +Reported-by: syzbot+4a4f1eba14eb5c3417d1@syzkaller.appspotmail.com +Reviewed-by: Johannes Thumshirn +Reviewed-by: Anand Jain +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/extent-tree.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -1243,7 +1243,8 @@ static int btrfs_issue_discard(struct bl + u64 bytes_left, end; + u64 aligned_start = ALIGN(start, 1 << 9); + +- if (WARN_ON(start != aligned_start)) { ++ /* Adjust the range to be aligned to 512B sectors if necessary. */ ++ if (start != aligned_start) { + len -= aligned_start - start; + len = round_down(len, 1 << 9); + start = aligned_start; diff --git a/queue-5.4/btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch b/queue-5.4/btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch new file mode 100644 index 00000000000..82684cce09f --- /dev/null +++ b/queue-5.4/btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch @@ -0,0 +1,57 @@ +From f03e274a8b29d1d1c1bbd7f764766cb5ca537ab7 Mon Sep 17 00:00:00 2001 +From: Fedor Pchelkin +Date: Wed, 3 Jan 2024 13:31:27 +0300 +Subject: btrfs: ref-verify: free ref cache before clearing mount opt + +From: Fedor Pchelkin + +commit f03e274a8b29d1d1c1bbd7f764766cb5ca537ab7 upstream. + +As clearing REF_VERIFY mount option indicates there were some errors in a +ref-verify process, a ref cache is not relevant anymore and should be +freed. + +btrfs_free_ref_cache() requires REF_VERIFY option being set so call +it just before clearing the mount option. + +Found by Linux Verification Center (linuxtesting.org) with Syzkaller. + +Reported-by: syzbot+be14ed7728594dc8bd42@syzkaller.appspotmail.com +Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool") +CC: stable@vger.kernel.org # 5.4+ +Closes: https://lore.kernel.org/lkml/000000000000e5a65c05ee832054@google.com/ +Reported-by: syzbot+c563a3c79927971f950f@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/lkml/0000000000007fe09705fdc6086c@google.com/ +Reviewed-by: Anand Jain +Signed-off-by: Fedor Pchelkin +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/ref-verify.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/fs/btrfs/ref-verify.c ++++ b/fs/btrfs/ref-verify.c +@@ -888,8 +888,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_i + out_unlock: + spin_unlock(&fs_info->ref_verify_lock); + out: +- if (ret) ++ if (ret) { ++ btrfs_free_ref_cache(fs_info); + btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY); ++ } + return ret; + } + +@@ -1018,8 +1020,8 @@ int btrfs_build_ref_tree(struct btrfs_fs + } + } + if (ret) { +- btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY); + btrfs_free_ref_cache(fs_info); ++ btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY); + } + btrfs_free_path(path); + return ret; diff --git a/queue-5.4/btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch b/queue-5.4/btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch new file mode 100644 index 00000000000..3875b21033c --- /dev/null +++ b/queue-5.4/btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch @@ -0,0 +1,35 @@ +From f398e70dd69e6ceea71463a5380e6118f219197e Mon Sep 17 00:00:00 2001 +From: Chung-Chiang Cheng +Date: Fri, 12 Jan 2024 15:41:05 +0800 +Subject: btrfs: tree-checker: fix inline ref size in error messages + +From: Chung-Chiang Cheng + +commit f398e70dd69e6ceea71463a5380e6118f219197e upstream. + +The error message should accurately reflect the size rather than the +type. + +Fixes: f82d1c7ca8ae ("btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check") +CC: stable@vger.kernel.org # 5.4+ +Reviewed-by: Filipe Manana +Reviewed-by: Qu Wenruo +Signed-off-by: Chung-Chiang Cheng +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/tree-checker.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/btrfs/tree-checker.c ++++ b/fs/btrfs/tree-checker.c +@@ -1165,7 +1165,7 @@ static int check_extent_item(struct exte + if (ptr + btrfs_extent_inline_ref_size(inline_type) > end) { + extent_err(leaf, slot, + "inline ref item overflows extent item, ptr %lu iref size %u end %lu", +- ptr, inline_type, end); ++ ptr, btrfs_extent_inline_ref_size(inline_type), end); + return -EUCLEAN; + } + diff --git a/queue-5.4/gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch b/queue-5.4/gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch new file mode 100644 index 00000000000..2596436f673 --- /dev/null +++ b/queue-5.4/gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch @@ -0,0 +1,46 @@ +From 805c74eac8cb306dc69b87b6b066ab4da77ceaf1 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +Date: Wed, 17 Jan 2024 08:29:42 -0600 +Subject: gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-04 + +From: Mario Limonciello + +commit 805c74eac8cb306dc69b87b6b066ab4da77ceaf1 upstream. + +Spurious wakeups are reported on the GPD G1619-04 which +can be absolved by programming the GPIO to ignore wakeups. + +Cc: stable@vger.kernel.org +Reported-and-tested-by: George Melikov +Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3073 +Signed-off-by: Mario Limonciello +Reviewed-by: Andy Shevchenko +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpio/gpiolib-acpi.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/drivers/gpio/gpiolib-acpi.c ++++ b/drivers/gpio/gpiolib-acpi.c +@@ -1466,6 +1466,20 @@ static const struct dmi_system_id gpioli + .ignore_wake = "INT33FF:01@0", + }, + }, ++ { ++ /* ++ * Spurious wakeups from TP_ATTN# pin ++ * Found in BIOS 0.35 ++ * https://gitlab.freedesktop.org/drm/amd/-/issues/3073 ++ */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "GPD"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "G1619-04"), ++ }, ++ .driver_data = &(struct acpi_gpiolib_dmi_quirk) { ++ .ignore_wake = "PNP0C50:00@8", ++ }, ++ }, + {} /* Terminating entry */ + }; + diff --git a/queue-5.4/netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch b/queue-5.4/netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch new file mode 100644 index 00000000000..3d92d83d2c4 --- /dev/null +++ b/queue-5.4/netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch @@ -0,0 +1,69 @@ +From f342de4e2f33e0e39165d8639387aa6c19dff660 Mon Sep 17 00:00:00 2001 +From: Florian Westphal +Date: Sat, 20 Jan 2024 22:50:04 +0100 +Subject: netfilter: nf_tables: reject QUEUE/DROP verdict parameters + +From: Florian Westphal + +commit f342de4e2f33e0e39165d8639387aa6c19dff660 upstream. + +This reverts commit e0abdadcc6e1. + +core.c:nf_hook_slow assumes that the upper 16 bits of NF_DROP +verdicts contain a valid errno, i.e. -EPERM, -EHOSTUNREACH or similar, +or 0. + +Due to the reverted commit, its possible to provide a positive +value, e.g. NF_ACCEPT (1), which results in use-after-free. + +Its not clear to me why this commit was made. + +NF_QUEUE is not used by nftables; "queue" rules in nftables +will result in use of "nft_queue" expression. + +If we later need to allow specifiying errno values from userspace +(do not know why), this has to call NF_DROP_GETERR and check that +"err <= 0" holds true. + +Fixes: e0abdadcc6e1 ("netfilter: nf_tables: accept QUEUE/DROP verdict parameters") +Cc: stable@vger.kernel.org +Reported-by: Notselwyn +Signed-off-by: Florian Westphal +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Greg Kroah-Hartman +--- + net/netfilter/nf_tables_api.c | 16 ++++++---------- + 1 file changed, 6 insertions(+), 10 deletions(-) + +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -8058,16 +8058,10 @@ static int nft_verdict_init(const struct + data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE])); + + switch (data->verdict.code) { +- default: +- switch (data->verdict.code & NF_VERDICT_MASK) { +- case NF_ACCEPT: +- case NF_DROP: +- case NF_QUEUE: +- break; +- default: +- return -EINVAL; +- } +- /* fall through */ ++ case NF_ACCEPT: ++ case NF_DROP: ++ case NF_QUEUE: ++ break; + case NFT_CONTINUE: + case NFT_BREAK: + case NFT_RETURN: +@@ -8087,6 +8081,8 @@ static int nft_verdict_init(const struct + + data->verdict.chain = chain; + break; ++ default: ++ return -EINVAL; + } + + desc->len = sizeof(data->verdict); diff --git a/queue-5.4/rbd-don-t-move-requests-to-the-running-list-on-errors.patch b/queue-5.4/rbd-don-t-move-requests-to-the-running-list-on-errors.patch new file mode 100644 index 00000000000..971b81a4ed9 --- /dev/null +++ b/queue-5.4/rbd-don-t-move-requests-to-the-running-list-on-errors.patch @@ -0,0 +1,77 @@ +From ded080c86b3f99683774af0441a58fc2e3d60cae Mon Sep 17 00:00:00 2001 +From: Ilya Dryomov +Date: Wed, 17 Jan 2024 18:59:44 +0100 +Subject: rbd: don't move requests to the running list on errors + +From: Ilya Dryomov + +commit ded080c86b3f99683774af0441a58fc2e3d60cae upstream. + +The running list is supposed to contain requests that are pinning the +exclusive lock, i.e. those that must be flushed before exclusive lock +is released. When wake_lock_waiters() is called to handle an error, +requests on the acquiring list are failed with that error and no +flushing takes place. Briefly moving them to the running list is not +only pointless but also harmful: if exclusive lock gets acquired +before all of their state machines are scheduled and go through +rbd_lock_del_request(), we trigger + + rbd_assert(list_empty(&rbd_dev->running_list)); + +in rbd_try_acquire_lock(). + +Cc: stable@vger.kernel.org +Fixes: 637cd060537d ("rbd: new exclusive lock wait/wake code") +Signed-off-by: Ilya Dryomov +Reviewed-by: Dongsheng Yang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/block/rbd.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +--- a/drivers/block/rbd.c ++++ b/drivers/block/rbd.c +@@ -3603,14 +3603,15 @@ static bool rbd_lock_add_request(struct + static void rbd_lock_del_request(struct rbd_img_request *img_req) + { + struct rbd_device *rbd_dev = img_req->rbd_dev; +- bool need_wakeup; ++ bool need_wakeup = false; + + lockdep_assert_held(&rbd_dev->lock_rwsem); + spin_lock(&rbd_dev->lock_lists_lock); +- rbd_assert(!list_empty(&img_req->lock_item)); +- list_del_init(&img_req->lock_item); +- need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING && +- list_empty(&rbd_dev->running_list)); ++ if (!list_empty(&img_req->lock_item)) { ++ list_del_init(&img_req->lock_item); ++ need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING && ++ list_empty(&rbd_dev->running_list)); ++ } + spin_unlock(&rbd_dev->lock_lists_lock); + if (need_wakeup) + complete(&rbd_dev->releasing_wait); +@@ -3997,14 +3998,19 @@ static void wake_lock_waiters(struct rbd + return; + } + +- list_for_each_entry(img_req, &rbd_dev->acquiring_list, lock_item) { ++ while (!list_empty(&rbd_dev->acquiring_list)) { ++ img_req = list_first_entry(&rbd_dev->acquiring_list, ++ struct rbd_img_request, lock_item); + mutex_lock(&img_req->state_mutex); + rbd_assert(img_req->state == RBD_IMG_EXCLUSIVE_LOCK); ++ if (!result) ++ list_move_tail(&img_req->lock_item, ++ &rbd_dev->running_list); ++ else ++ list_del_init(&img_req->lock_item); + rbd_img_schedule(img_req, result); + mutex_unlock(&img_req->state_mutex); + } +- +- list_splice_tail_init(&rbd_dev->acquiring_list, &rbd_dev->running_list); + } + + static int get_lock_owner_info(struct rbd_device *rbd_dev, diff --git a/queue-5.4/series b/queue-5.4/series index 9eb69ef060e..57936db86b1 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -41,3 +41,10 @@ netfilter-nf_tables-restrict-anonymous-set-and-map-n.patch netfilter-nf_tables-validate-nfproto_-family.patch fjes-fix-memleaks-in-fjes_hw_setup.patch net-fec-fix-the-unhandled-context-fault-from-smmu.patch +btrfs-ref-verify-free-ref-cache-before-clearing-mount-opt.patch +btrfs-tree-checker-fix-inline-ref-size-in-error-messages.patch +btrfs-don-t-warn-if-discard-range-is-not-aligned-to-sector.patch +btrfs-defrag-reject-unknown-flags-of-btrfs_ioctl_defrag_range_args.patch +rbd-don-t-move-requests-to-the-running-list-on-errors.patch +netfilter-nf_tables-reject-queue-drop-verdict-parameters.patch +gpiolib-acpi-ignore-touchpad-wakeup-on-gpd-g1619-04.patch -- 2.47.3