7.1.5-rc1 review
Subsystems (15)
Greg Kroah-Hartman
maintainerPATCH 397/2077 md/raid1,raid10: fix deadlock in read error recovery path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 7b15c24f805339a585cfe7d72f446b7e88b9bcc0 ]
raid1d and raid10d may resubmit a split md cloned bio while handling a read error. In this case, resubmitting the bio can lead to a deadlock if the array is suspended before md_handle_request() acquires an active_io reference via percpu_ref_tryget_live().
Since the cloned bio already holds an active_io reference, trying to acquire another reference via percpu_ref_tryget_live() can lead to a deadlock while the array is suspended.
Fix this by using percpu_ref_get() for md cloned bios.
--- drivers/md/md.c | 25 ++++++++++++++++--------- drivers/md/md.h | 5 +++++ 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/md/md.c +16 -9
@@ -395,17 +395,24 @@ static bool is_suspended(struct mddev *mddev, struct bio *bio)bool md_handle_request (struct mddev *mddev,struct bio *bio) { check_suspended: -if (is_suspended (mddev, bio)) { -/* Bail out if REQ_NOWAIT is set for the bio */ -if (bio->bi_opf &REQ_NOWAIT ) { -bio_wouldblock_error (bio); -return true; +if (unlikely (md_cloned_bio (mddev, bio))) { +/* +* This bio is an MD cloned bio and already holds an +* active_io reference, so percpu_ref_get() is safe here. +*/ +percpu_ref_get (&mddev->active_io); + }else { +if (is_suspended (mddev, bio)) { +/* Bail out if REQ_NOWAIT is set for the bio */ +if (bio->bi_opf &REQ_NOWAIT ) { +bio_wouldblock_error (bio); +return true; + } +wait_event (mddev->sb_wait, !is_suspended (mddev, bio)); } -wait_event (mddev->sb_wait, !is_suspended (mddev, bio)); +if (!percpu_ref_tryget_live (&mddev->active_io)) + goto check_suspended; } -if (!percpu_ref_tryget_live (&mddev->active_io)) - goto check_suspended; -if (!mddev->pers->make_request (mddev, bio)) {percpu_ref_put (&mddev->active_io);if (mddev_is_dm (mddev) && mddev->pers->prepare_suspend)
drivers/md/md.h +5 -0
@@ -1042,6 +1042,11 @@ void mddev_update_io_opt(struct mddev *mddev, unsigned int nr_stripes);extern const struct block_device_operations md_fops; +static inline bool md_cloned_bio (struct mddev *mddev,struct bio *bio) +{ +return bio->bi_pool == &mddev->io_clone_set; +} +/* * MD devices can be used undeneath by DM, in which case ->gendisk is NULL. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/2077 md/raid1,raid10: fix error-path detection with md_cloned_bio()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 811545e0926d02a6a0b1a1258bb5544777c164d4 ]
Detect the error path using md_cloned_bio() instead of relying on r1_bio in raid1 or r10_bio->read_slot in raid10, which may be NULL or -1 after splitting and resubmitting a failed bio.
As a result, the error path may not be recognized and memory allocations can incorrectly use GFP_NOIO instead of (GFP_NOIO | __GFP_HIGH), which can lead to a deadlock under memory pressure.
--- drivers/md/raid1.c | 13 ++++++++++--- drivers/md/raid10.c | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-)
drivers/md/raid1.c +10 -3
@@ -1343,11 +1343,18 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,bool r1bio_existed = !!r1_bio;/* -* If r1_bio is set, we are blocking the raid1d thread -* so there is a tiny risk of deadlock. So ask for +* An md cloned bio indicates we are in the error path. +* This is more reliable than checking r1_bio, which might +* be NULL even in the error path if a failed bio was split. +*/ +bool err_path =md_cloned_bio (mddev, bio); + +/* +* If we are in the error path, we are blocking the raid1d +* thread so there is a tiny risk of deadlock. So ask for * emergency memory if needed. */ -gfp_t gfp = r1_bio ? (GFP_NOIO | __GFP_HIGH) :GFP_NOIO ; +gfp_t gfp = err_path ? (GFP_NOIO | __GFP_HIGH) :GFP_NOIO ;/* * Still need barrier for READ in case that whole
drivers/md/raid10.c +14 -6
@@ -1155,7 +1155,20 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,char b[BDEVNAME_SIZE ];int slot = r10_bio->read_slot;struct md_rdev *err_rdev =NULL ; -gfp_t gfp =GFP_NOIO ; + +/* +* An md cloned bio indicates we are in the error path. +* This is more reliable than checking slot, which might +* be -1 even in the error path if a failed bio was split. +*/ +bool err_path =md_cloned_bio (mddev, bio); + +/* +* If we are in the error path, we are blocking the raid10d +* thread so there is a tiny risk of deadlock. So ask for +* emergency memory if needed. +*/ +gfp_t gfp = err_path ? (GFP_NOIO | __GFP_HIGH) :GFP_NOIO ;if (slot >=0 && r10_bio->devs[slot].rdev) {/*
@@ -1166,11 +1179,6 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,* we lose the device name in error messages. */ int disk; -/* -* As we are blocking raid10, it is a little safer to -* use __GFP_HIGH. -*/ - gfp =GFP_NOIO | __GFP_HIGH; disk = r10_bio->devs[slot].devnum; err_rdev = conf->mirrors[disk].rdev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/2077 md/raid1,raid10: fix bio accounting for split md cloned bios
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit ba976e3501111d11c550848b3b7341a73035f582 ]
Use md_cloned_bio() to control bio accounting instead of relying on r1bio_existed in raid1 or the io_accounting flag in raid10.
The previous logic does not reliably reflect whether a bio is an md cloned bio. When a failed bio is split and resubmitted via bio_submit_split_bioset() on the error path, this can lead to either double accounting for md cloned bios, or missing accounting for bios returned from bio_submit_split_bioset()
Fix this by using md_cloned_bio() to detect md cloned bios and skip accounting accordingly.
--- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/md/raid1.c +1 -1
@@ -1418,7 +1418,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, } r1_bio->read_disk = rdisk; -if (!r1bio_existed) { +if (likely (!md_cloned_bio (mddev, bio))) {md_account_bio (mddev, &bio); r1_bio->master_bio = bio; }
drivers/md/raid10.c +4 -4
@@ -1146,7 +1146,7 @@ static bool regular_request_wait(struct mddev *mddev, struct r10conf *conf, }static void raid10_read_request (struct mddev *mddev,struct bio *bio, -struct r10bio *r10_bio,bool io_accounting) +struct r10bio *r10_bio) {struct r10conf *conf = mddev->private;struct bio *read_bio;
@@ -1226,7 +1226,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, } slot = r10_bio->read_slot; -if (io_accounting) { +if (likely (!md_cloned_bio (mddev, bio))) {md_account_bio (mddev, &bio); r10_bio->master_bio = bio; }
@@ -1552,7 +1552,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors) conf->geo.raid_disks);if (bio_data_dir (bio) ==READ ) -raid10_read_request (mddev, bio, r10_bio, true); +raid10_read_request (mddev, bio, r10_bio);else raid10_write_request (mddev, bio, r10_bio); }
@@ -2867,7 +2867,7 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)rdev_dec_pending (rdev, mddev); r10_bio->state =0 ; -raid10_read_request (mddev, r10_bio->master_bio, r10_bio, false); +raid10_read_request (mddev, r10_bio->master_bio, r10_bio);/* * allow_barrier after re-submit to ensure no sync io * can be issued while regular io pending.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/2077 raid1: fix nr_pending leak in REQ_ATOMIC bad-block error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abd-Alrhman Masalkhi <[email protected]>
[ Upstream commit 909d9dc3b5730c8ed7b764c68bc788342df2a07b ]
In raid1_write_request(), each per-mirror loop iteration begins by incrementing rdev->nr_pending. If a REQ_ATOMIC write encounters a badblock within the requested range, the code jumps to err_handle without dropping the reference taken for the current mirror.
err_handle's cleanup loop will only decrements for k < i and r1_bio->bios[k] is non-NULL. The current slot is therefore skipped, leaving its nr_pending reference leaked permanently. The reference prevents the rdev from ever being removed, since raid1_remove_conf() refuses to remove an rdev with nr_pending > 0.
Fix this by calling rdev_dec_pending() before jumping to err_handle.
--- drivers/md/raid1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid1.c +3 -1
@@ -1603,8 +1603,10 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,* complexity of supporting that is not worth * the benefit. */ -if (bio->bi_opf &REQ_ATOMIC ) +if (bio->bi_opf &REQ_ATOMIC ) { +rdev_dec_pending (rdev, mddev); goto err_handle; + } good_sectors = first_bad - r1_bio->sector;if (good_sectors < max_sectors)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/2077 bpf: fix BPF_PROG_QUERY OOB write and cgroup backward compat
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 21c4b99b27f3f85b89256e81b3e997dec0a460d0 ]
BPF_PROG_QUERY writes back the 'query.revision' field unconditionally to userspace. If userspace passes a smaller 'bpf_attr' structure (e.g. 40 bytes, which was the layout before the addition of 'query.revision'), the kernel performs an out-of-bounds write.
Fix this by propagating the user-provided attribute size 'uattr_size' down to the cgroup query handlers, and conditionally skipping writing the revision field to userspace when the provided buffer size is insufficient.
query.revision in bpf_mprog_query is structurally identical to the cgroup case: a late tail field, written unconditionally.
But the backward-compat hazard is not the same.
The min-historical-size test is per command, and bpf_mprog_query only serves attach types that were born with revision in the struct:
- tcx_prog_query -> BPF_TCX_INGRESS/EGRESS
- netkit_prog_query -> BPF_NETKIT_PRIMARY/PEER
tcx, netkit, the revision field, and bpf_mprog_query itself all landed in the same v6.6 merge window (053c8e1f235d added the mprog query API + revision; tcx in e420bed02507, netkit in 35dfaad7188c). There has never been a tcx/netkit BPF_PROG_QUERY userspace that doesn't know about revision. So for these commands the minimum legitimate struct already covers offset 56-64 — no old binary can be broken here.
Contrast with cgroup: BPF_PROG_QUERY on cgroup attach types shipped in 2017; revision write-back was bolted on years later (120933984460). That path has a real population of pre-revision callers.
--- include/linux/bpf-cgroup.h | 5 +++-- kernel/bpf/cgroup.c | 13 +++++++------ kernel/bpf/syscall.c | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-)
include/linux/bpf-cgroup.h +3 -2
@@ -421,7 +421,7 @@ int cgroup_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);int cgroup_bpf_link_attach (const union bpf_attr *attr,struct bpf_prog *prog);int cgroup_bpf_prog_query (const union bpf_attr *attr, -union bpf_attr __user *uattr); +union bpf_attr __user *uattr,u32 uattr_size);const struct bpf_func_proto *cgroup_common_func_proto (enum bpf_func_id func_id,const struct bpf_prog *prog);
@@ -452,7 +452,8 @@ static inline int cgroup_bpf_link_attach(const union bpf_attr *attr, }static inline int cgroup_bpf_prog_query (const union bpf_attr *attr, -union bpf_attr __user *uattr) +union bpf_attr __user *uattr, +u32 uattr_size) {return -EINVAL ; }
kernel/bpf/cgroup.c +7 -6
@@ -1208,7 +1208,7 @@ static int cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,/* Must be called with cgroup_mutex held to avoid races. */ static int __cgroup_bpf_query (struct cgroup *cgrp,const union bpf_attr *attr, -union bpf_attr __user *uattr) +union bpf_attr __user *uattr,u32 uattr_size) {__u32 __user *prog_attach_flags =u64_to_user_ptr (attr->query.prog_attach_flags);bool effective_query = attr->query.query_flags &BPF_F_QUERY_EFFECTIVE ;
@@ -1259,7 +1259,8 @@ static int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr,return -EFAULT ;if (!effective_query && from_atype == to_atype) revision = cgrp->bpf.revisions[from_atype]; -if (copy_to_user (&uattr->query.revision, &revision,sizeof (revision))) + if (uattr_size >= offsetofend(union bpf_attr, query.revision) && +copy_to_user (&uattr->query.revision, &revision,sizeof (revision)))return -EFAULT ;if (attr->query.prog_cnt ==0 || !prog_ids || !total_cnt)/* return early if user requested only program count + flags */
@@ -1312,12 +1313,12 @@ static int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr, }static int cgroup_bpf_query (struct cgroup *cgrp,const union bpf_attr *attr, -union bpf_attr __user *uattr) +union bpf_attr __user *uattr,u32 uattr_size) {int ret;cgroup_lock (); - ret =__cgroup_bpf_query (cgrp, attr, uattr); + ret =__cgroup_bpf_query (cgrp, attr, uattr, uattr_size);cgroup_unlock ();return ret; }
@@ -1520,7 +1521,7 @@ int cgroup_bpf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog) }int cgroup_bpf_prog_query (const union bpf_attr *attr, -union bpf_attr __user *uattr) +union bpf_attr __user *uattr,u32 uattr_size) {struct cgroup *cgrp;int ret;
@@ -1529,7 +1530,7 @@ int cgroup_bpf_prog_query(const union bpf_attr *attr,if (IS_ERR (cgrp))return PTR_ERR (cgrp); - ret =cgroup_bpf_query (cgrp, attr, uattr); + ret =cgroup_bpf_query (cgrp, attr, uattr, uattr_size);cgroup_put (cgrp);return ret;
kernel/bpf/syscall.c +3 -3
@@ -4654,7 +4654,7 @@ static int bpf_prog_detach(const union bpf_attr *attr)#define BPF_PROG_QUERY_LAST_FIELD query.revisionstatic int bpf_prog_query (const union bpf_attr *attr, -union bpf_attr __user *uattr) +union bpf_attr __user *uattr,u32 uattr_size) {if (!bpf_net_capable ())return -EPERM ;
@@ -4693,7 +4693,7 @@ static int bpf_prog_query(const union bpf_attr *attr,case BPF_CGROUP_GETSOCKOPT :case BPF_CGROUP_SETSOCKOPT :case BPF_LSM_CGROUP : -return cgroup_bpf_prog_query (attr, uattr); +return cgroup_bpf_prog_query (attr, uattr, uattr_size);case BPF_LIRC_MODE2 :return lirc_prog_query (attr, uattr);case BPF_FLOW_DISSECTOR :
@@ -6286,7 +6286,7 @@ static int __sys_bpf(enum bpf_cmd cmd, bpfptr_t uattr, unsigned int size) err =bpf_prog_detach (&attr);break ;case BPF_PROG_QUERY : - err =bpf_prog_query (&attr, uattr.user); + err =bpf_prog_query (&attr, uattr.user, size);break ;case BPF_PROG_TEST_RUN : err =bpf_prog_test_run (&attr, uattr.user);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/2077 selftests/bpf: add verification for BPF_PROG_QUERY attr size boundaries
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 5add3a4ad1a3bc15404e8bd338813ed0a636f5c9 ]
Add a new selftest to verify that the BPF syscall (specifically BPF_PROG_QUERY) correctly handles different user-declared attribute sizes.
Specifically, verify that:
- For cgroup queries, a query with a size that covers 'prog_cnt' but is smaller than 'revision' (OLD_QUERY_SIZE) succeeds, but does not write to 'revision' (verifying backward compatibility).
- A query with full size (FULL_QUERY_SIZE) succeeds and writes both 'prog_cnt' and 'revision'.
--- .../selftests/bpf/prog_tests/bpf_attr_size.c | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_attr_size.c
tools/testing/selftests/bpf/prog_tests/bpf_attr_size.c new file +69 -0
@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2026 Google LLC */ +#include <linux/bpf.h> +#include <unistd.h> +#include <sys/syscall.h> +#include <test_progs.h> +#include <cgroup_helpers.h> +#include "cgroup_skb_direct_packet_access.skel.h" + +#define OLD_QUERY_SIZE offsetofend(union bpf_attr, query.prog_cnt) +#define FULL_QUERY_SIZE offsetofend(union bpf_attr, query.revision) + +static void test_query_size_boundaries (void ) +{ +struct cgroup_skb_direct_packet_access *skel; +struct bpf_link *link =NULL ; +union bpf_attr attr; +int cg_fd =-1 ; +int err; + + skel =cgroup_skb_direct_packet_access__open_and_load (); +if (!ASSERT_OK_PTR (skel,"skel_load" )) +return ; + + cg_fd =test__join_cgroup ("/attr_size_cg" ); +if (!ASSERT_GE (cg_fd,0 ,"join_cgroup" )) + goto cleanup; + + link =bpf_program__attach_cgroup (skel->progs.direct_packet_access, + cg_fd); +if (!ASSERT_OK_PTR (link,"cg_attach" )) + goto cleanup; + +memset (&attr,0 ,sizeof (attr)); + attr.query.target_fd = cg_fd; + attr.query.attach_type =BPF_CGROUP_INET_INGRESS ; + attr.query.revision =0xdeadbeefdeadbeefULL ; + + err =syscall (__NR_bpf,BPF_PROG_QUERY , &attr,OLD_QUERY_SIZE ); +if (ASSERT_OK (err,"query_old_size" )) { +ASSERT_EQ (attr.query.prog_cnt,1 ,"prog_cnt_written_old" ); +ASSERT_EQ (attr.query.revision,0xdeadbeefdeadbeefULL , +"revision_not_written_old" ); + } + +memset (&attr,0 ,sizeof (attr)); + attr.query.target_fd = cg_fd; + attr.query.attach_type =BPF_CGROUP_INET_INGRESS ; + + err =syscall (__NR_bpf,BPF_PROG_QUERY , &attr,FULL_QUERY_SIZE ); +if (!ASSERT_OK (err,"query_full_size" )) + goto cleanup; + +ASSERT_EQ (attr.query.prog_cnt,1 ,"prog_cnt_written" ); +ASSERT_GT (attr.query.revision,0 ,"revision_written" ); + +cleanup: +if (link) +bpf_link__destroy (link); +if (cg_fd >=0 ) +close (cg_fd); +cgroup_skb_direct_packet_access__destroy (skel); +} + +void test_bpf_attr_size (void ) +{ +if (test__start_subtest ("query_size_boundaries" )) +test_query_size_boundaries (); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/2077 liveupdate: Use refcount_t for FLB reference counts
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit d2850ff2f8c5acda4c1097aa53c006a75b091f2c ]
Use refcount_t instead of a raw integer to keep track of references on incoming and outgoing FLBs. Using refcount_t provides protection from overflow, underflow, and other issues.
--- include/linux/liveupdate.h | 3 ++- kernel/liveupdate/luo_flb.c | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-)
include/linux/liveupdate.h +2 -1
@@ -12,6 +12,7 @@#include <linux/kho/abi/luo.h> #include <linux/list.h> #include <linux/mutex.h> +#include <linux/refcount.h> #include <linux/rwsem.h> #include <linux/types.h> #include <uapi/linux/liveupdate.h>
@@ -175,7 +176,7 @@ struct liveupdate_flb_ops {* @retrieved: True once the FLB's retrieve() callback has run. */ struct luo_flb_private_state { -long count; +refcount_t count;u64 data;void *obj;struct mutex lock;
kernel/liveupdate/luo_flb.c +10 -12
@@ -111,7 +111,7 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb)struct luo_flb_private *private =luo_flb_get_private (flb); scoped_guard(mutex, &private->outgoing.lock) { -if (!private->outgoing.count) { +if (!refcount_read (&private->outgoing.count)) {struct liveupdate_flb_op_args args = {0 };int err;
@@ -126,8 +126,10 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb) } private->outgoing.data = args.data; private->outgoing.obj = args.obj; +refcount_set (&private->outgoing.count,1 ); + }else { +refcount_inc (&private->outgoing.count); } - private->outgoing.count++; }return 0 ;
@@ -138,8 +140,7 @@ static void luo_flb_file_unpreserve_one(struct liveupdate_flb *flb)struct luo_flb_private *private =luo_flb_get_private (flb); scoped_guard(mutex, &private->outgoing.lock) { - private->outgoing.count--; -if (!private->outgoing.count) { +if (refcount_dec_and_test (&private->outgoing.count)) {struct liveupdate_flb_op_args args = {0 }; args.flb = flb;
@@ -178,7 +179,7 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb)for (int i =0 ; i < fh->header_ser->count; i++) {if (!strcmp (fh->ser[i].name, flb->compatible)) { private->incoming.data = fh->ser[i].data; - private->incoming.count = fh->ser[i].count; +refcount_set (&private->incoming.count, fh->ser[i].count); found = true;break ; }
@@ -208,12 +209,8 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb)static void luo_flb_file_finish_one (struct liveupdate_flb *flb) {struct luo_flb_private *private =luo_flb_get_private (flb); -u64 count; -scoped_guard (mutex, &private->incoming.lock) - count = --private->incoming.count; - -if (!count) { +if (refcount_dec_and_test (&private->incoming.count)) {struct liveupdate_flb_op_args args = {0 };if (!private->incoming.retrieved) {
@@ -652,12 +649,13 @@ void luo_flb_serialize(void)guard (rwsem_read)(&luo_register_rwlock);list_private_for_each_entry (gflb, &luo_flb_global.list, private.list) {struct luo_flb_private *private =luo_flb_get_private (gflb); +long count =refcount_read (&private->outgoing.count); -if (private->outgoing.count >0 ) { +if (count >0 ) {strscpy (fh->ser[i].name, gflb->compatible,sizeof (fh->ser[i].name)); fh->ser[i].data = private->outgoing.data; - fh->ser[i].count = private->outgoing.count; + fh->ser[i].count = count; i++; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/2077 liveupdate: Reference count incoming FLB data
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit d8e47bd066d7e626f9f45d416182d585b7e18b9b ]
Increment the incoming FLB refcount in liveupdate_flb_get_incoming() so that the FLB structure cannot be freed while the caller is actively using it. Add an additional liveupdate_flb_put_incoming() function so the caller can explicitly indicate when it is done using the FLB data.
During a Live Update, a subsystem might need to hold onto the incoming File-Lifecycle-Bound (FLB) data for an extended period, such as during device enumeration. Incrementing the reference count guarantees that the data remains valid and accessible until the subsystem releases it, preventing future use-after-free bugs.
--- include/linux/liveupdate.h | 6 ++++++ kernel/liveupdate/luo_flb.c | 32 +++++++++++++++++--------------- lib/tests/liveupdate.c | 3 +++ 3 files changed, 26 insertions(+), 15 deletions(-)
include/linux/liveupdate.h +6 -0
@@ -240,6 +240,8 @@ void liveupdate_unregister_flb(struct liveupdate_file_handler *fh, struct liveupdate_flb *flb);int liveupdate_flb_get_incoming (struct liveupdate_flb *flb,void **objp); +void liveupdate_flb_put_incoming (struct liveupdate_flb *flb); +int liveupdate_flb_get_outgoing (struct liveupdate_flb *flb,void **objp);#else /* CONFIG_LIVEUPDATE */
@@ -280,6 +282,10 @@ static inline int liveupdate_flb_get_incoming(struct liveupdate_flb *flb,return -EOPNOTSUPP ; } +static inline void liveupdate_flb_put_incoming (struct liveupdate_flb *flb) +{ +} +static inline int liveupdate_flb_get_outgoing (struct liveupdate_flb *flb,void **objp) {
kernel/liveupdate/luo_flb.c +17 -15
@@ -165,7 +165,7 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb)bool found = false;int err; -guard (mutex)(&private->incoming.lock); +lockdep_assert_held (&private->incoming.lock);if (private->incoming.finished)return -ENODATA ;
@@ -206,12 +206,14 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb)return 0 ; } -static void luo_flb_file_finish_one (struct liveupdate_flb *flb) +void liveupdate_flb_put_incoming (struct liveupdate_flb *flb) {struct luo_flb_private *private =luo_flb_get_private (flb); +struct liveupdate_flb_op_args args = {0 }; -if (refcount_dec_and_test (&private->incoming.count)) { -struct liveupdate_flb_op_args args = {0 }; + scoped_guard(mutex, &private->incoming.lock) { +if (!refcount_dec_and_test (&private->incoming.count)) +return ;if (!private->incoming.retrieved) {int err =luo_flb_retrieve_one (flb);
@@ -220,16 +222,14 @@ static void luo_flb_file_finish_one(struct liveupdate_flb *flb)return ; } - scoped_guard(mutex, &private->incoming.lock) { - args.flb = flb; - args.obj = private->incoming.obj; - flb->ops->finish (&args); + args.flb = flb; + args.obj = private->incoming.obj; + flb->ops->finish (&args); - private->incoming.data =0 ; - private->incoming.obj =NULL ; - private->incoming.finished = true; -module_put (flb->ops->owner); - } + private->incoming.data =0 ; + private->incoming.obj =NULL ; + private->incoming.finished = true; +module_put (flb->ops->owner); } }
@@ -312,7 +312,7 @@ void luo_flb_file_finish(struct liveupdate_file_handler *fh)guard (rwsem_read)(&luo_register_rwlock);list_for_each_entry_reverse (iter, flb_list, list) -luo_flb_file_finish_one (iter->flb); +liveupdate_flb_put_incoming (iter->flb); } static void luo_flb_unregister_one(struct liveupdate_file_handler *fh,
@@ -509,6 +509,8 @@ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp)if (!liveupdate_enabled ())return -EOPNOTSUPP ; +guard (mutex)(&private->incoming.lock); +if (!private->incoming.obj) {int err =luo_flb_retrieve_one (flb);
@@ -516,7 +518,7 @@ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp)return err; } -guard (mutex)(&private->incoming.lock); +refcount_inc (&private->incoming.count); *objp = private->incoming.obj;return 0 ;
lib/tests/liveupdate.c +3 -0
@@ -105,6 +105,9 @@ static void liveupdate_test_init(void)pr_err ("liveupdate_flb_get_incoming for %s failed: %pe\n" , flb->compatible,ERR_PTR (err)); } + +if (!err) +liveupdate_flb_put_incoming (flb); } initialized = true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/2077 libbpf: Skip hash computation when loader generation failed
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 3c5e2f1a85844abbb65df4694f5ebad0a13e219c ]
bpf_gen__finish() calls compute_sha_update_offsets() gated only on the gen_hash option, without first consulting gen->error. On a failed generation this is buggy: a failed realloc_data_buf() sets gen->data_start to NULL (leaving gen->data_cur dangling), so compute_sha_update_offsets() runs libbpf_sha256() over a NULL buffer with a bogus length; a failed realloc_insn_buf() likewise sets gen->insn_start to NULL and the hash immediates get patched through that NULL base.
The computed program is discarded in either case, since the following "if (!gen->error)" block does not publish opts->insns once an error is set. Thus, skip the hash pass when generation has already failed.
--- tools/lib/bpf/gen_loader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/lib/bpf/gen_loader.c +4 -4
@@ -398,13 +398,12 @@ int bpf_gen__finish(struct bpf_gen *gen, int nr_progs, int nr_maps) blob_fd_array_off(gen, i));emit (gen,BPF_MOV64_IMM (BPF_REG_0 ,0 ));emit (gen,BPF_EXIT_INSN ()); -if (OPTS_GET (gen->opts, gen_hash, false)) -compute_sha_update_offsets (gen); - -pr_debug ("gen: finish %s\n" ,errstr (gen->error));if (!gen->error) {struct gen_loader_opts *opts = gen->opts; +if (OPTS_GET (opts, gen_hash, false)) +compute_sha_update_offsets (gen); + opts->insns = gen->insn_start; opts->insns_sz = gen->insn_cur - gen->insn_start; opts->data = gen->data_start;
@@ -419,6 +418,7 @@ int bpf_gen__finish(struct bpf_gen *gen, int nr_progs, int nr_maps)bpf_insn_bswap (insn++); } } +pr_debug ("gen: finish %s\n" ,errstr (gen->error));return gen->error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/2077 libbpf: Skip endianness swap when loader generation failed
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 41300d032a1b1d91a3ed996ad21905463e344beb ]
bpf_gen__prog_load() byte-swaps the program insns and the {func,line}_info and CO-RE relo blobs in place for cross-endian targets. The blob offsets come from add_data(), which returns 0 on failure: realloc_data_buf() either frees and NULLs gen->data_start (realloc OOM) or returns early on an already-latched gen->error, leaving a stale, possibly too-small buffer.
Neither bswap site checked for this. With gen->swapped_endian set and a failed generation, "gen->data_start + off" becomes NULL + 0. Guard the same way via !gen->error so they are skipped once generation has failed.
--- tools/lib/bpf/gen_loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/gen_loader.c +2 -2
@@ -1053,7 +1053,7 @@ void bpf_gen__prog_load(struct bpf_gen *gen, prog_idx, prog_type, insns_off, insn_cnt, license_off);/* convert blob insns to target endianness */ -if (gen->swapped_endian) { +if (gen->swapped_endian && !gen->error) {struct bpf_insn *insn = gen->data_start + insns_off;int i;
@@ -1091,7 +1091,7 @@ void bpf_gen__prog_load(struct bpf_gen *gen, sizeof(struct bpf_core_relo));/* convert all info blobs to target endianness */ -if (gen->swapped_endian) +if (gen->swapped_endian && !gen->error)info_blob_bswap (gen, func_info, line_info, core_relos, load_attr);libbpf_strlcpy (attr.prog_name, prog_name,sizeof (attr.prog_name));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/2077 liveupdate: skip serialization for context-preserving kexec
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pasha Tatashin <[email protected]>
[ Upstream commit 5eff62b051fbdb686e885c1468301d964f2e3d66 ]
A preserve_context kexec returns to the current kernel, which is unrelated to live update where the state is passed to the next kernel. Skip liveupdate_reboot() in this case to avoid serialization and prevent sessions from being left in a frozen state upon return.
--- kernel/kexec_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/kexec_core.c +5 -3
@@ -1146,9 +1146,11 @@ int kernel_kexec(void) goto Unlock; } - error =liveupdate_reboot (); -if (error) - goto Unlock; +if (!kexec_image->preserve_context) { + error =liveupdate_reboot (); +if (error) + goto Unlock; + }#ifdef CONFIG_KEXEC_JUMP if (kexec_image->preserve_context) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/2077 liveupdate: fix TOCTOU race in luo_session_retrieve()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pasha Tatashin <[email protected]>
[ Upstream commit d3ae9e7fddb4036f50003d7fa1ef52801fdb961b ]
Extend the scope of the rwsem_read lock in luo_session_retrieve() to overlap with the acquisition of the session mutex. This prevents a concurrent thread from releasing and freeing the session between the lookup and the mutex lock.
--- kernel/liveupdate/luo_session.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/liveupdate/luo_session.c +5 -6
@@ -419,12 +419,11 @@ int luo_session_retrieve(const char *name, struct file **filep)struct luo_session *it;int err; - scoped_guard(rwsem_read, &sh->rwsem) { -list_for_each_entry (it, &sh->list, list) { -if (!strncmp (it->name, name,sizeof (it->name))) { - session = it; -break ; - } +guard (rwsem_read)(&sh->rwsem); +list_for_each_entry (it, &sh->list, list) { +if (!strncmp (it->name, name,sizeof (it->name))) { + session = it; +break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/2077 liveupdate: block session mutations during reboot
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pasha Tatashin <[email protected]>
[ Upstream commit bb1328be35bf43c88288c5c31ceb45181b574c0c ]
During the reboot() syscall, user processes may still be running concurrently and attempting to mutate sessions (e.g., creating, retrieving, or releasing sessions). To prevent this, introduce luo_session_serialize_rwsem to synchronize mutations with the serialization process.
All session mutation operations (create, retrieve, release, ioctl) take the read lock. The serialization process (luo_session_serialize) takes the write lock and holds it indefinitely on success. This effectively freezes the LUO session subsystem during the transition to the new kernel. If serialization fails, the lock is released to allow recovery.
--- kernel/liveupdate/luo_session.c | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-)
kernel/liveupdate/luo_session.c +48 -3
@@ -46,6 +46,38 @@* 4. Retrieval: A userspace agent in the new kernel can then call * `luo_session_retrieve()` with a session name to get a new file * descriptor and access the preserved state. +* +* Locking: +* +* The LUO session subsystem uses a three-tier locking hierarchy to ensure thread +* safety and prevent deadlocks during concurrent session mutations and kexec +* serialization: +* +* 1. `luo_session_serialize_rwsem` (global rwsem): +* Protects session mutations (creation, retrieval, release, and ioctls) +* against the serialization process during reboot. +* +* - Readers: Taken by any path modifying or accessing session state (e.g., +* `luo_session_create()`, `luo_session_retrieve()`, `luo_session_release()`, +* and `luo_session_ioctl()`). +* - Writer: Taken by the serialization process (`luo_session_serialize()`) +* during reboot. On success, the write lock is held indefinitely to freeze +* the subsystem. On failure, it is released to allow recovery. +* +* 2. `luo_session_header->rwsem` (per-list rwsem): +* Synchronizes list-level operations for the incoming and outgoing session headers. +* +* - Writer: Taken during list mutation operations (inserting or removing a +* session from the list). +* - Reader: Taken when traversing the list (e.g., retrieving a session by name). +* +* 3. `luo_session->mutex` (per-session mutex): +* Protects the internal state and file sets of an individual session. It is +* acquired during per-session operations such as preserving, retrieving, +* or freezing files. +* +* Lock Hierarchy: +* `luo_session_serialize_rwsem` -> `luo_session_header->rwsem` -> `luo_session->mutex` */ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt
@@ -75,6 +107,8 @@ sizeof(struct luo_session_header_ser)) / \ sizeof(struct luo_session_ser)) +static DECLARE_RWSEM (luo_session_serialize_rwsem); +/** * struct luo_session_header - Header struct for managing LUO sessions. * @count: The number of sessions currently tracked in the @list.
@@ -205,6 +239,7 @@ static int luo_session_release(struct inode *inodep, struct file *filep)struct luo_session *session = filep->private_data;struct luo_session_header *sh; +guard (rwsem_read)(&luo_session_serialize_rwsem);/* If retrieved is set, it means this session is from incoming list */ if (session->retrieved) {int err =luo_session_finish_one (session);
@@ -354,6 +389,7 @@ static long luo_session_ioctl(struct file *filep, unsigned int cmd,if (ret)return ret; +guard (rwsem_read)(&luo_session_serialize_rwsem);return op->execute (session, &ucmd); }
@@ -393,14 +429,17 @@ int luo_session_create(const char *name, struct file **filep)if (IS_ERR (session))return PTR_ERR (session); +down_read (&luo_session_serialize_rwsem); err =luo_session_insert (&luo_session_global.outgoing, session);if (err) goto err_free; -scoped_guard (mutex, &session->mutex) - err = luo_session_getfile(session, filep); +mutex_lock (&session->mutex); + err =luo_session_getfile (session, filep); +mutex_unlock (&session->mutex);if (err) goto err_remove; +up_read (&luo_session_serialize_rwsem);return 0 ;
@@ -408,6 +447,7 @@ int luo_session_create(const char *name, struct file **filep)luo_session_remove (&luo_session_global.outgoing, session); err_free:luo_session_free (session); +up_read (&luo_session_serialize_rwsem);return err; }
@@ -419,6 +459,7 @@ int luo_session_retrieve(const char *name, struct file **filep)struct luo_session *it;int err; +guard (rwsem_read)(&luo_session_serialize_rwsem);guard (rwsem_read)(&sh->rwsem);list_for_each_entry (it, &sh->list, list) {if (!strncmp (it->name, name,sizeof (it->name))) {
@@ -591,7 +632,8 @@ int luo_session_serialize(void)int i =0 ;int err; -guard (rwsem_write)(&sh->rwsem); +down_write (&luo_session_serialize_rwsem); +down_write (&sh->rwsem);list_for_each_entry (session, &sh->list, list) { err =luo_session_freeze_one (session, &sh->ser[i]);if (err)
@@ -602,6 +644,7 @@ int luo_session_serialize(void) i++; } sh->header_ser->count = sh->count; +up_write (&sh->rwsem);return 0 ;
@@ -611,6 +654,8 @@ int luo_session_serialize(void)luo_session_unfreeze_one (session, &sh->ser[i]);memset (sh->ser[i].name,0 ,sizeof (sh->ser[i].name)); } +up_write (&sh->rwsem); +up_write (&luo_session_serialize_rwsem);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/2077 liveupdate: fix u-a-f in luo_file_unpreserve_files() and luo_file_finish()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pasha Tatashin <[email protected]>
[ Upstream commit 291dcd37c8c8f8f8e1bccc92228f44bf371762a8 ]
In luo_file_unpreserve_files() and luo_file_finish(), reorder module_put() and xa_erase() to ensure the file handler module remains pinned while its operations are being accessed.
Specifically, luo_get_id() dereferences fh->ops->get_id, so the module reference must be held until after xa_erase() (which calls luo_get_id) completes.
For luo_file_finish(), this requires moving the module_put() call out of the luo_file_finish_one() helper and into the main loop of luo_file_finish() itself.
--- kernel/liveupdate/luo_file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/liveupdate/luo_file.c +3 -2
@@ -385,10 +385,11 @@ void luo_file_unpreserve_files(struct luo_file_set *file_set) args.private_data = luo_file->private_data; luo_file->fh->ops->unpreserve (&args);luo_flb_file_unpreserve (luo_file->fh); -module_put (luo_file->fh->ops->owner);xa_erase (&luo_preserved_files,luo_get_id (luo_file->fh, luo_file->file)); +module_put (luo_file->fh->ops->owner); +list_del (&luo_file->list); file_set->count--;
@@ -677,7 +678,6 @@ static void luo_file_finish_one(struct luo_file_set *file_set, luo_file->fh->ops->finish (&args);luo_flb_file_finish (luo_file->fh); -module_put (luo_file->fh->ops->owner); }/**
@@ -738,6 +738,7 @@ int luo_file_finish(struct luo_file_set *file_set) luo_get_id(luo_file->fh, luo_file->file));fput (luo_file->file); } +module_put (luo_file->fh->ops->owner);list_del (&luo_file->list); file_set->count--;mutex_destroy (&luo_file->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/2077 ext4: fix LOGFLUSH shutdown ordering to allow ordered-mode data writeback
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit d99748ef1695ce17eaf51c64b7a06952fa7cddab ]
In EXT4_GOING_FLAGS_LOGFLUSH mode, the EXT4_FLAGS_SHUTDOWN flag was set before calling ext4_force_commit(). This caused ordered-mode data writeback (triggered by journal commit) to fail with -EIO, since ext4_do_writepages() checks for the shutdown flag. The journal would then be aborted prematurely before the commit could succeed.
Fix this by calling ext4_force_commit() first, then setting the shutdown flag, so that pending data can be written back correctly.
Note that moving ext4_force_commit() before setting the shutdown flag creates a small window in which new writes may occur and generate new journal transactions. When the journal is subsequently aborted, the new transactions will not be able to write to disk. This is intentional because LOGFLUSH's semantics are to flush pre-existing journal entries before shutdown, not to guarantee atomicity for writes that race with the ioctl.
--- fs/ext4/ioctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ext4/ioctl.c +9 -3
@@ -830,11 +830,17 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)bdev_thaw (sb->s_bdev);break ;case EXT4_GOING_FLAGS_LOGFLUSH : +/* +* Call ext4_force_commit() before setting EXT4_FLAGS_SHUTDOWN. +* This is because in data=ordered mode, journal commit +* triggers data writeback which fails if shutdown is already +* set, causing the journal to be aborted prematurely before +* the commit succeeds. +*/ + (void )ext4_force_commit (sb);set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags); -if (sbi->s_journal && !is_journal_aborted (sbi->s_journal)) { - (void )ext4_force_commit (sb); +if (sbi->s_journal && !is_journal_aborted (sbi->s_journal))jbd2_journal_abort (sbi->s_journal, -ESHUTDOWN ); - }break ;case EXT4_GOING_FLAGS_NOLOGFLUSH :set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/2077 spi: atmel: fix DMA channel and bounce buffer leaks
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 bd7e9843ec95bffe2643c901dd625f0bab32e639 ]
The original code set use_dma to false when dma_alloc_coherent() for bounce buffers failed, but DMA channels acquired earlier via atmel_spi_configure_dma() were never freed.
When devm_request_irq() or clk_prepare_enable() failed later in probe, the driver also did not release DMA channels or bounce buffers already allocated.
The out_free_dma error path released DMA channels but did not free the bounce buffers.
Fix by moving bounce buffer allocation into atmel_spi_configure_dma() and registering the devres cleanup for DMA channels and bounce buffers.
--- drivers/spi/spi-atmel.c | 133 ++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 65 deletions(-)
drivers/spi/spi-atmel.c +68 -65
@@ -559,6 +559,38 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as, u8 bits_per_word)return err; } +static void atmel_spi_release_dma (void *data) +{ +struct spi_controller *host = data; +struct atmel_spi *as =spi_controller_get_devdata (host); +struct device *dev = &as->pdev->dev; + +if (host->dma_tx) { +dma_release_channel (host->dma_tx); + host->dma_tx =NULL ; + } + +if (host->dma_rx) { +dma_release_channel (host->dma_rx); + host->dma_rx =NULL ; + } + +if (IS_ENABLED (CONFIG_SOC_SAM_V4_V5 )) { +if (as->addr_tx_bbuf) { +dma_free_coherent (dev,SPI_MAX_DMA_XFER , + as->addr_tx_bbuf, + as->dma_addr_tx_bbuf); + as->addr_tx_bbuf =NULL ; + } +if (as->addr_rx_bbuf) { +dma_free_coherent (dev,SPI_MAX_DMA_XFER , + as->addr_rx_bbuf, + as->dma_addr_rx_bbuf); + as->addr_rx_bbuf =NULL ; + } + } +} +static int atmel_spi_configure_dma (struct spi_controller *host,struct atmel_spi *as) {
@@ -569,7 +601,8 @@ static int atmel_spi_configure_dma(struct spi_controller *host,if (IS_ERR (host->dma_tx)) { err =PTR_ERR (host->dma_tx);dev_dbg (dev,"No TX DMA channel, DMA is disabled\n" ); - goto error_clear; + host->dma_tx =NULL ; +return err; } host->dma_rx =dma_request_chan (dev,"rx" );
@@ -580,26 +613,45 @@ static int atmel_spi_configure_dma(struct spi_controller *host,* requested tx channel. */ dev_dbg (dev,"No RX DMA channel, DMA is disabled\n" ); - goto error; + host->dma_rx =NULL ; + goto err_release_dma; } err =atmel_spi_dma_slave_config (as,8 );if (err) - goto error; + goto err_release_dma; + +if (IS_ENABLED (CONFIG_SOC_SAM_V4_V5 )) { + as->addr_tx_bbuf =dma_alloc_coherent (dev,SPI_MAX_DMA_XFER , + &as->dma_addr_tx_bbuf, +GFP_KERNEL |GFP_DMA ); +if (!as->addr_tx_bbuf) { + err = -ENOMEM ; + goto err_release_dma; + } + + as->addr_rx_bbuf =dma_alloc_coherent (dev,SPI_MAX_DMA_XFER , + &as->dma_addr_rx_bbuf, +GFP_KERNEL |GFP_DMA ); +if (!as->addr_rx_bbuf) { + err = -ENOMEM ; + goto err_release_dma; + } + } + + err =devm_add_action_or_reset (dev, atmel_spi_release_dma, host); +if (err) +return err;dev_info (&as->pdev->dev, -"Using %s (tx) and %s (rx) for DMA transfers\n" , -dma_chan_name (host->dma_tx), -dma_chan_name (host->dma_rx)); +"Using %s (tx) and %s (rx) for DMA transfers\n" , +dma_chan_name (host->dma_tx),dma_chan_name (host->dma_rx));return 0 ; -error: -if (!IS_ERR (host->dma_rx)) -dma_release_channel (host->dma_rx); -if (!IS_ERR (host->dma_tx)) -dma_release_channel (host->dma_tx); -error_clear: - host->dma_tx = host->dma_rx =NULL ; + +err_release_dma: +atmel_spi_release_dma (host); +return err; }
@@ -611,18 +663,6 @@ static void atmel_spi_stop_dma(struct spi_controller *host)dmaengine_terminate_all (host->dma_tx); } -static void atmel_spi_release_dma (struct spi_controller *host) -{ -if (host->dma_rx) { -dma_release_channel (host->dma_rx); - host->dma_rx =NULL ; - } -if (host->dma_tx) { -dma_release_channel (host->dma_tx); - host->dma_tx =NULL ; - } -} -/* This function is called by the DMA driver from tasklet context */ static void dma_callback (void *data) {
@@ -1585,30 +1625,6 @@ static int atmel_spi_probe(struct platform_device *pdev) as->use_pdc = true; } -if (IS_ENABLED (CONFIG_SOC_SAM_V4_V5 )) { - as->addr_rx_bbuf =dma_alloc_coherent (&pdev->dev, -SPI_MAX_DMA_XFER , - &as->dma_addr_rx_bbuf, -GFP_KERNEL |GFP_DMA ); -if (!as->addr_rx_bbuf) { - as->use_dma = false; - }else { - as->addr_tx_bbuf =dma_alloc_coherent (&pdev->dev, -SPI_MAX_DMA_XFER , - &as->dma_addr_tx_bbuf, -GFP_KERNEL |GFP_DMA ); -if (!as->addr_tx_bbuf) { - as->use_dma = false; -dma_free_coherent (&pdev->dev,SPI_MAX_DMA_XFER , - as->addr_rx_bbuf, - as->dma_addr_rx_bbuf); - } - } -if (!as->use_dma) -dev_info (host->dev.parent, -" can not allocate dma coherent memory\n" ); - } -if (as->caps.has_dma_support && !as->use_dma)dev_info (&pdev->dev,"Atmel SPI Controller using PIO only\n" );
@@ -1668,13 +1684,10 @@ static int atmel_spi_probe(struct platform_device *pdev) out_free_dma:pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev); - -if (as->use_dma) -atmel_spi_release_dma (host); -spi_writel (as,CR ,SPI_BIT (SWRST ));spi_writel (as,CR ,SPI_BIT (SWRST ));/* AT91SAM9263 Rev B workaround */ -clk_disable_unprepare (as->gclk); +if (as->gclk) +clk_disable_unprepare (as->gclk); out_disable_clk:clk_disable_unprepare (clk); out_free_irq:
@@ -1695,18 +1708,8 @@ static void atmel_spi_remove(struct platform_device *pdev)spi_unregister_controller (host);/* reset the hardware and block queue progress */ -if (as->use_dma) { +if (as->use_dma)atmel_spi_stop_dma (host); -atmel_spi_release_dma (host); -if (IS_ENABLED (CONFIG_SOC_SAM_V4_V5 )) { -dma_free_coherent (&pdev->dev,SPI_MAX_DMA_XFER , - as->addr_tx_bbuf, - as->dma_addr_tx_bbuf); -dma_free_coherent (&pdev->dev,SPI_MAX_DMA_XFER , - as->addr_rx_bbuf, - as->dma_addr_rx_bbuf); - } - }spin_lock_irq (&as->lock);spi_writel (as,CR ,SPI_BIT (SWRST ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/2077 spi: imx: replace dmaengine_terminate_all() with dmaengine_terminate_sync()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Song <[email protected]>
[ Upstream commit 4503b2fe761c2bfd33ed043d9b9deec0d1eb40e0 ]
dmaengine_terminate_all() has been deprecated, so replace it with dmaengine_terminate_sync().
--- drivers/spi/spi-imx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/spi/spi-imx.c +8 -8
@@ -1774,8 +1774,8 @@ static int spi_imx_dma_submit(struct spi_imx_data *spi_imx, transfer_timeout);if (!time_left) {dev_err (spi_imx->dev,"I/O Error in DMA TX\n" ); -dmaengine_terminate_all (controller->dma_tx); -dmaengine_terminate_all (controller->dma_rx); +dmaengine_terminate_sync (controller->dma_tx); +dmaengine_terminate_sync (controller->dma_rx);return -ETIMEDOUT ; }
@@ -1784,7 +1784,7 @@ static int spi_imx_dma_submit(struct spi_imx_data *spi_imx,if (!time_left) {dev_err (&controller->dev,"I/O Error in DMA RX\n" ); spi_imx->devtype_data->reset (spi_imx); -dmaengine_terminate_all (controller->dma_rx); +dmaengine_terminate_sync (controller->dma_rx);return -ETIMEDOUT ; } }else {
@@ -1793,15 +1793,15 @@ static int spi_imx_dma_submit(struct spi_imx_data *spi_imx,if (wait_for_completion_interruptible (&spi_imx->dma_tx_completion) ||READ_ONCE (spi_imx->target_aborted)) {dev_dbg (spi_imx->dev,"I/O Error in DMA TX interrupted\n" ); -dmaengine_terminate_all (controller->dma_tx); -dmaengine_terminate_all (controller->dma_rx); +dmaengine_terminate_sync (controller->dma_tx); +dmaengine_terminate_sync (controller->dma_rx);return -EINTR ; }if (wait_for_completion_interruptible (&spi_imx->dma_rx_completion) ||READ_ONCE (spi_imx->target_aborted)) {dev_dbg (spi_imx->dev,"I/O Error in DMA RX interrupted\n" ); -dmaengine_terminate_all (controller->dma_rx); +dmaengine_terminate_sync (controller->dma_rx);return -EINTR ; }
@@ -1818,9 +1818,9 @@ static int spi_imx_dma_submit(struct spi_imx_data *spi_imx,return 0 ; dmaengine_terminate_tx: -dmaengine_terminate_all (controller->dma_tx); +dmaengine_terminate_sync (controller->dma_tx); dmaengine_terminate_rx: -dmaengine_terminate_all (controller->dma_rx); +dmaengine_terminate_sync (controller->dma_rx);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/2077 ASoC: rsnd: Fix RSND_SOC_MASK width to single nibble
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Madieu <[email protected]>
[ Upstream commit c0758279367e9d82eb7d7b4959718d7d32e96b7d ]
RSND_SOC_MASK was defined as (0xFF << 4), spanning bits 4-11. This is wider than needed since only nibble B (bits 7:4) is used for SoC identifiers. Narrow it to (0xF << 4) to match the intended single-nibble allocation and prevent overlap with bits 8-11 which will be used by upcoming RZ series flags.
No functional change, since the only current user (RSND_SOC_E) fits within a single nibble.
--- sound/soc/renesas/rcar/rsnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/renesas/rcar/rsnd.h +1 -1
@@ -624,7 +624,7 @@ struct rsnd_priv {#define RSND_GEN2 (2 << 0)#define RSND_GEN3 (3 << 0)#define RSND_GEN4 (4 << 0) -#define RSND_SOC_MASK (0xFF << 4) +#define RSND_SOC_MASK (0xF << 4)#define RSND_SOC_E (1 << 4)/* E1/E2/E3 */ /*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/2077 NFSD: Fix delegation reference leak in nfsd4_revoke_states
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 625981c8f3da0cc2d236d7b46c39dd75554b8276 ]
When revoking delegation state, nfsd4_revoke_states() takes an extra reference on the stid before calling unhash_delegation_locked(). If unhash_delegation_locked() returns false (the delegation was already unhashed by a concurrent path), dp is set to NULL and revoke_delegation() is skipped, but the extra reference is never released. Each occurrence permanently pins the stid in memory. The leaked reference also prevents nfs4_put_stid() from decrementing cl_admin_revoked, leaving the counter permanently inflated.
Drop the extra reference in the failure path.
--- fs/nfsd/nfs4state.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +8 -1
@@ -1376,7 +1376,8 @@ static void destroy_delegation(struct nfs4_delegation *dp)* stateid or it's called from a laundromat thread (nfsd4_landromat()) that * determined that this specific state has expired and needs to be revoked * (both mark state with the appropriate stid sc_status mode). It is also -* assumed that a reference was taken on the @dp state. +* assumed that a reference was taken on the @dp state. This function +* consumes that reference. * * If this function finds that the @dp state is SC_STATUS_FREED it means * that a FREE_STATEID operation for this stateid has been processed and
@@ -1839,6 +1840,10 @@ void nfsd4_revoke_states(struct nfsd_net *nn, struct super_block *sb)mutex_unlock (&stp->st_mutex);break ;case SC_TYPE_DELEG : +/* Extra reference guards against concurrent +* FREE_STATEID; revoke_delegation() consumes +* it, otherwise release it directly. +*/ refcount_inc (&stid->sc_count); dp =delegstateid (stid);spin_lock (&nn->deleg_lock);
@@ -1848,6 +1853,8 @@ void nfsd4_revoke_states(struct nfsd_net *nn, struct super_block *sb)spin_unlock (&nn->deleg_lock);if (dp)revoke_delegation (dp); +else +nfs4_put_stid (stid);break ;case SC_TYPE_LAYOUT : ls =layoutstateid (stid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/2077 ARM: imx3: Fix CCM node reference leak
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 36d46348eb5fc4bc505cd2290ddd70c25fbe6bb3 ]
of_find_compatible_node() returns a referenced device node. The i.MX31 and i.MX35 early init paths use the node to map the CCM registers with of_iomap(), but never drop the node reference.
Release the node after the mapping is created.
--- arch/arm/mach-imx/mm-imx3.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-imx/mm-imx3.c +2 -0
@@ -106,6 +106,7 @@ void __init imx31_init_early(void) arm_pm_idle = imx31_idle; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx31-ccm" ); mx3_ccm_base =of_iomap (np,0 ); +of_node_put (np); BUG_ON(!mx3_ccm_base); }#endif /* ifdef CONFIG_SOC_IMX31 */
@@ -143,6 +144,7 @@ void __init imx35_init_early(void) arch_ioremap_caller = imx3_ioremap_caller; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx35-ccm" ); mx3_ccm_base =of_iomap (np,0 ); +of_node_put (np); BUG_ON(!mx3_ccm_base); }#endif /* ifdef CONFIG_SOC_IMX35 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/2077 HID: wiimote: Fix table layout and whitespace errors
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: J. Neuschäfer <[email protected]>
[ Upstream commit 12b7731995ca577d86e02196e99ba9c126f47282 ]
Some tab characters snuck into the data layout table for turntable extensions, which resulted in the table only looking right at a tabstop of 4, which is uncommon in the kernel. Change them to the equivalent amount of spaces, which should look correct in any editor.
While at it, also fix the other whitespace errors (trailing spaces at end of line) introduced in the same commit.
--- drivers/hid/hid-wiimote-modules.c | 58 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/hid/hid-wiimote-modules.c +29 -29
@@ -2403,7 +2403,7 @@ static const struct wiimod_ops wiimod_guitar = { .in_ext = wiimod_guitar_in_ext, }; -/* +/* * Turntable * DJ Hero came with a Turntable Controller that was plugged in * as an extension.
@@ -2439,15 +2439,15 @@ static const __u16 wiimod_turntable_map[] = {static void wiimod_turntable_in_ext (struct wiimote_data *wdata,const __u8 *ext) {__u8 be, cs, sx, sy, ed, rtt, rbg, rbr, rbb, ltt, lbg, lbr, lbb, bp, bm; -/* +/* * Byte | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | *------+------+-----+-----+-----+-----+------+------+--------+ -* 0 | RTT<4:3> | SX <5:0> | -* 1 | RTT<2:1> | SY <5:0> | +* 0 | RTT<4:3> | SX <5:0> | +* 1 | RTT<2:1> | SY <5:0> | *------+------+-----+-----+-----+-----+------+------+--------+ * 2 |RTT<0>| ED<4:3> | CS<3:0> | RTT<5> | *------+------+-----+-----+-----+-----+------+------+--------+ -* 3 | ED<2:0> | LTT<4:0> | +* 3 | ED<2:0> | LTT<4:0> | *------+------+-----+-----+-----+-----+------+------+--------+ * 4 | 0 | 0 | LBR | B- | 0 | B+ | RBR | LTT<5> | *------+------+-----+-----+-----+-----+------+------+--------+
@@ -2458,20 +2458,20 @@ static void wiimod_turntable_in_ext(struct wiimote_data *wdata, const __u8 *ext)* With Motion+ enabled, it will look like this: * Byte | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | *------+------+-----+-----+-----+-----+------+------+--------+ -* 1 | RTT<4:3> | SX <5:1> | 0 | -* 2 | RTT<2:1> | SY <5:1> | 0 | +* 1 | RTT<4:3> | SX <5:1> | 0 | +* 2 | RTT<2:1> | SY <5:1> | 0 | *------+------+-----+-----+-----+-----+------+------+--------+ * 3 |RTT<0>| ED<4:3> | CS<3:0> | RTT<5> | *------+------+-----+-----+-----+-----+------+------+--------+ -* 4 | ED<2:0> | LTT<4:0> | +* 4 | ED<2:0> | LTT<4:0> | *------+------+-----+-----+-----+-----+------+------+--------+ * 5 | 0 | 0 | LBR | B- | 0 | B+ | RBR | XXXX | *------+------+-----+-----+-----+-----+------+------+--------+ * 6 | LBB | 0 | RBG | BE | LBG | RBB | XXXX | XXXX | *------+------+-----+-----+-----+-----+------+------+--------+ */ - - be = !(ext[5 ] &0x10 ); + + be = !(ext[5 ] &0x10 ); cs = ((ext[2 ] &0x1e )); sx = ext[0 ] &0x3f ; sy = ext[1 ] &0x3f ;
@@ -2499,32 +2499,32 @@ static void wiimod_turntable_in_ext(struct wiimote_data *wdata, const __u8 *ext)input_report_abs (wdata->extension.input,ABS_HAT1X , ltt);input_report_abs (wdata->extension.input,ABS_HAT2X , cs);input_report_abs (wdata->extension.input,ABS_HAT3X , ed); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_G_RIGHT ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_G_RIGHT ], rbg);input_report_key (wdata->extension.input, wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_R_RIGHT ], rbr); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_B_RIGHT ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_B_RIGHT ], rbb); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_G_LEFT ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_G_LEFT ], lbg); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_R_LEFT ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_R_LEFT ], lbr); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_B_LEFT ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_B_LEFT ], lbb); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_EUPHORIA ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_EUPHORIA ], be); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_PLUS ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_PLUS ], bp); -input_report_key (wdata->extension.input, - wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_MINUS ], +input_report_key (wdata->extension.input, + wiimod_turntable_map[WIIMOD_TURNTABLE_KEY_MINUS ], bm);input_sync (wdata->extension.input);
@@ -2557,7 +2557,7 @@ static void wiimod_turntable_close(struct input_dev *dev)static int wiimod_turntable_probe (const struct wiimod_ops *ops,struct wiimote_data *wdata) { -int ret, i; +int ret, i; wdata->extension.input =input_allocate_device ();if (!wdata->extension.input)
@@ -2594,9 +2594,9 @@ static int wiimod_turntable_probe(const struct wiimod_ops *ops,input_set_abs_params (wdata->extension.input,ABS_HAT1X ,-8 ,8 ,0 ,0 );input_set_abs_params (wdata->extension.input, -ABS_HAT2X ,0 ,31 ,1 ,1 ); +ABS_HAT2X ,0 ,31 ,1 ,1 );input_set_abs_params (wdata->extension.input, -ABS_HAT3X ,0 ,7 ,0 ,0 ); +ABS_HAT3X ,0 ,7 ,0 ,0 ); ret =input_register_device (wdata->extension.input);if (ret) goto err_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/2077 wifi: ath12k: fix incorrect HT/VHT/HE/EHT MCS reporting in monitor mode
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kwan Lai Chee Hou <[email protected]>
[ Upstream commit 10085a654a4c2331d5f0cdc20bfc839a49fbb886 ]
In monitor mode, the driver incorrectly assigns the legacy rate to the rate_idx field of the radiotap header for HT/VHT/HE/EHT frames, ignoring the actual MCS value parsed from the hardware.
This causes packet analyzers (like Wireshark) to display incorrect MCS values (e.g., legacy base rates instead of the true MCS).
Fix this by assigning ppdu_info->mcs as the default rate_mcs in ath12k_dp_mon_fill_rx_rate(), and remove rate_idx assignments in ath12k_dp_mon_update_radiotap() to preserve
the previously calculated MCS values (including the HT NSS offset).
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ
--- drivers/net/wireless/ath/ath12k/dp_mon.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/dp_mon.c +2 -4
@@ -115,13 +115,14 @@ ath12k_dp_mon_fill_rx_rate(struct ath12k_pdev_dp *dp_pdev,bool is_cck; pkt_type = ppdu_info->preamble_type; - rate_mcs = ppdu_info->rate; + rate_mcs = ppdu_info->mcs; nss = ppdu_info->nss; sgi = ppdu_info->gi;switch (pkt_type) {case RX_MSDU_START_PKT_TYPE_11A :case RX_MSDU_START_PKT_TYPE_11B : + rate_mcs = ppdu_info->rate; is_cck = (pkt_type ==RX_MSDU_START_PKT_TYPE_11B );if (rx_status->band <NUM_NL80211_BANDS ) {struct ath12k *ar =ath12k_pdev_dp_to_ar (dp_pdev);
@@ -471,13 +472,10 @@ void ath12k_dp_mon_update_radiotap(struct ath12k_pdev_dp *dp_pdev, rxs->encoding =RX_ENC_HE ; ptr =skb_push (mon_skb,sizeof (struct ieee80211_radiotap_he ));ath12k_dp_mon_rx_update_radiotap_he (ppduinfo, ptr); - rxs->rate_idx = ppduinfo->rate; }else if (ppduinfo->vht_flags) { rxs->encoding =RX_ENC_VHT ; - rxs->rate_idx = ppduinfo->rate; }else if (ppduinfo->ht_flags) { rxs->encoding =RX_ENC_HT ; - rxs->rate_idx = ppduinfo->rate; }else {struct ath12k *ar;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/2077 wifi: ath12k: fix memory leak in ath12k_wifi7_dp_rx_h_verify_tkip_mic()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqing Pan <[email protected]>
[ Upstream commit 98d4f92ab6a1af2ea2ab590d7e2801b203110981 ]
In ath12k_wifi7_dp_rx_h_verify_tkip_mic(), the call to ath12k_dp_rx_check_nwifi_hdr_len_valid() may return false when the NWIFI header length is invalid, causing the function to abort early with -EINVAL.
When this happens, the error propagates to ath12k_wifi7_dp_rx_h_defrag(), which clears first_frag by setting it to NULL. As a result, the corresponding MSDU is no longer referenced by the defragmentation path and is never freed.
This leads to a memory leak for the affected MSDU on this error path. Proper cleanup is required to ensure the MSDU is released when header validation fails during TKIP MIC verification.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3
--- drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c +3 -1
@@ -1028,8 +1028,10 @@ static int ath12k_wifi7_dp_rx_h_verify_tkip_mic(struct ath12k_pdev_dp *dp_pdev,skb_pull (msdu, hal_rx_desc_sz);if (unlikely (!ath12k_dp_rx_check_nwifi_hdr_len_valid (dp, msdu, - rx_info))) + rx_info))) { +dev_kfree_skb_any (msdu);return -EINVAL ; + }ath12k_dp_rx_h_ppdu (dp_pdev, rx_info); ath12k_dp_rx_h_undecap(dp_pdev, msdu, HAL_ENCRYPT_TYPE_TKIP_MIC, true,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/2077 wifi: ath12k: fix inconsistent arvif state in vdev_create error paths
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Zhang <[email protected]>
[ Upstream commit c972636efc63f0f43d725b59805dd1ae5bc4b31e ]
ath12k_mac_vdev_create() has three error path issues that leave arvif in an inconsistent state:
1. When ath12k_wmi_vdev_create() fails, the function returns directly without clearing arvif->ar, which was already set before the WMI call. Subsequent code checking arvif->ar to determine vdev readiness will see a non-NULL value despite no vdev existing in firmware.
2. When ath12k_wmi_send_peer_delete_cmd() fails in err_peer_del, the code jumped to err: skipping the DP peer cleanup and vdev rollback, leaving num_created_vdevs, vdev maps and arvif list membership live.
3. When ath12k_wait_for_peer_delete_done() fails, the code jumped to
err_vdev_del: skipping the DP peer cleanup.
Fix by changing the ath12k_wmi_vdev_create() failure to goto err instead of returning directly, routing both err_peer_del failure paths througherr_dp_peer_del: for proper DP peer and vdev rollback, and consolidating the arvif state cleanup at err:.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3
--- drivers/net/wireless/ath/ath12k/mac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +4 -5
@@ -10293,7 +10293,7 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)if (ret) {ath12k_warn (ab,"failed to create WMI vdev %d: %d\n" , arvif->vdev_id, ret); -return ret; + goto err; } ar->num_created_vdevs++;
@@ -10440,13 +10440,13 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)if (ret) {ath12k_warn (ar->ab,"failed to delete peer vdev_id %d addr %pM\n" , arvif->vdev_id, arvif->bssid); - goto err; + goto err_dp_peer_del; } ret =ath12k_wait_for_peer_delete_done (ar, arvif->vdev_id, arvif->bssid);if (ret) - goto err_vdev_del; + goto err_dp_peer_del; ar->num_peers--; }
@@ -10463,8 +10463,6 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)ath12k_wmi_vdev_delete (ar, arvif->vdev_id); ar->num_created_vdevs--; - arvif->is_created = false; - arvif->ar =NULL ; ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); ab->free_vdev_map |=1LL << arvif->vdev_id; ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id);
@@ -10473,6 +10471,7 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)spin_unlock_bh (&ar->data_lock); err: + arvif->is_created = false; arvif->ar =NULL ;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/2077 wifi: ath12k: fix NULL deref in change_sta_links for unready link
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Zhang <[email protected]>
[ Upstream commit 47809a7c8348bc4a332ccc26a37c7145a5f609f8 ]
_ieee80211_set_active_links() calls _ieee80211_link_use_channel() for each newly-added link and WARN_ON_ONCE()s if it fails. The call uses assign_on_failure=true, which allows mac80211 to continue despite driver failures, but when a mac80211-level channel validation fails (e.g., combinations check, DFS, or no available radio), drv_assign_vif_chanctx() is never reached. Since ath12k_mac_vdev_create() is only called from that path, arvif->is_created remains false and arvif->ar remains NULL for the failed link.
The subsequent drv_change_sta_links() call reaches ath12k_mac_op_change_sta_links(), which allocates an arsta and sets ahsta->links_map |= BIT(link_id) for the broken link before checking whether the link is ready. When the vdev was never created, only station_add() is skipped, but the link remains in links_map.
Any subsequent operation iterating links_map and dereferencing arvif->ar without a NULL check will crash. Two observed examples are NULL deref in ath12k_mac_ml_station_remove() on disconnect and in ath12k_mac_op_set_key() when wpa_supplicant installs PTK keys.
BUG: Unable to handle kernel NULL pointer dereference at 0x00000000 pc : ath12k_mac_station_post_remove+0x40/0xe8 [ath12k] Call trace: ath12k_mac_station_post_remove+0x40/0xe8 [ath12k] ath12k_mac_op_sta_state+0xb60/0x1720 [ath12k] drv_sta_state+0x100/0xbd8 [mac80211] __sta_info_destroy_part2+0x148/0x178 [mac80211] ieee80211_set_disassoc+0x500/0x678 [mac80211] BUG: Unable to handle kernel NULL pointer dereference at 0x00000000 pc : ath12k_mac_op_set_key+0x1f8/0x2c0 [ath12k] Call trace: ath12k_mac_op_set_key+0x1f8/0x2c0 [ath12k] drv_set_key+0x70/0x100 [mac80211] ieee80211_key_enable_hw_accel+0x78/0x260 [mac80211] ieee80211_add_key+0x16c/0x2ac [mac80211] nl80211_new_key+0x138/0x280 [cfg80211]
Fix this by checking arvif->is_created before calling ath12k_mac_alloc_assign_link_sta(). This prevents the broken link from entering links_map, so all subsequent operations iterating the bitmap are protected. The reliability of arvif->is_created across all error paths is ensured by the preceding patch.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3
--- drivers/net/wireless/ath/ath12k/mac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +4 -4
@@ -8054,16 +8054,16 @@ int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,continue ; arvif =wiphy_dereference (hw->wiphy, ahvif->link[link_id]); - arsta =ath12k_mac_alloc_assign_link_sta (ah, ahsta, ahvif, link_id); +if (!arvif || !arvif->is_created) +continue ; -if (!arvif || !arsta) { + arsta =ath12k_mac_alloc_assign_link_sta (ah, ahsta, ahvif, link_id); +if (!arsta) {ath12k_hw_warn (ah,"Failed to alloc/assign link sta" );continue ; } ar = arvif->ar; -if (!ar) -continue ; ret =ath12k_mac_station_add (ar, arvif, arsta);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/2077 ata: libata: Fix ata_exec_internal()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit aa0ae1c35f7b3e9afed2324bed5f5c87ad55b92c ]
Some but not all ata_exec_internal() calls happen from the context of the ATA error handler. Commit c0c362b60e25 ("libata: implement cross-port EH exclusion") added ata_eh_release() and ata_eh_acquire() calls in ata_exec_internal(). Calling these functions is necessary if the caller holds the eh_mutex but is not allowed if the caller doesn't hold that mutex. Fix this by only calling ata_eh_release() and ata_eh_acquire() if the caller holds the eh_mutex. An example of an indirect caller of ata_exec_internal() that does not hold the eh_mutex is ata_host_register().
--- drivers/ata/libata-core.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +17 -2
@@ -1540,6 +1540,7 @@ unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf, {struct ata_link *link = dev->link;struct ata_port *ap = link->ap; +const bool owns_eh_mutex = ap->host->eh_owner == current;u8 command = tf->command;struct ata_queued_cmd *qc;struct scatterlist sgl;
@@ -1617,11 +1618,25 @@ unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf, } } -ata_eh_release (ap); +if (owns_eh_mutex) { +/* +* To prevent that the compiler complains about the +* ata_eh_release() call below. +*/ +__acquire (&ap->host->eh_mutex); +ata_eh_release (ap); + } rc =wait_for_completion_timeout (&wait,msecs_to_jiffies (timeout)); -ata_eh_acquire (ap); +if (owns_eh_mutex) { +ata_eh_acquire (ap); +/* +* To prevent that the compiler complains about the above +* ata_eh_acquire() call. +*/ +__release (&ap->host->eh_mutex); + }ata_sff_flush_pio_task (ap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/2077 ACPI: button: Fix lid_device value leak past driver removal
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit f8600e0d1ac60e6eac34bc9c7e8cf78f7a4c368f ]
Static variable lid_device is set when the ACPI button driver probes the last lid device (under the assumptions that there will be only one lid device in the system) and never cleared, but in principle it should be reset when the driver unbinds from the lid device pointed to by it.
Address that and add locking that is needed to clear and set that variable safely.
--- drivers/acpi/button.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/acpi/button.c +24 -2
@@ -182,7 +182,6 @@ struct acpi_button {bool gpe_enabled; }; -static struct acpi_device *lid_device;static long lid_init_state =-1 ;static unsigned long lid_report_interval__read_mostly =500 ;
@@ -378,9 +377,29 @@ static int acpi_button_remove_fs(struct acpi_button *button)return 0 ; } +static struct acpi_device *lid_device; +static DEFINE_MUTEX (acpi_lid_lock); + +static void acpi_lid_save (struct acpi_device *adev) +{ +guard (mutex)(&acpi_lid_lock); + + lid_device = adev; +} + +static void acpi_lid_forget (struct acpi_device *adev) +{ +guard (mutex)(&acpi_lid_lock); + +if (lid_device == adev) + lid_device =NULL ; +} +/* Driver Interface */ int acpi_lid_open (void ) { +guard (mutex)(&acpi_lid_lock); +if (!lid_device)return -ENODEV ;
@@ -674,7 +693,7 @@ static int acpi_button_probe(struct platform_device *pdev)* This assumes there's only one lid device, or if there are * more we only care about the last one... */ - lid_device = device; +acpi_lid_save (device); }pr_info ("%s [%s]\n" , name,acpi_device_bid (device));
@@ -696,6 +715,9 @@ static void acpi_button_remove(struct platform_device *pdev)struct acpi_button *button =platform_get_drvdata (pdev);struct acpi_device *adev = button->adev; +if (button->type ==ACPI_BUTTON_TYPE_LID ) +acpi_lid_forget (adev); +switch (adev->device_type) {case ACPI_BUS_TYPE_POWER_BUTTON : acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/2077 ARM: imx31: Fix IIM mapping leak in revision check
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 ccb4b54b8ecf1ebafef96d538cd6c5c8455bb390 ]
mx31_read_cpu_rev() maps the IIM registers with of_iomap() to read the silicon revision, but returns without unmapping the MMIO mapping.
Keep the normalized revision value in a local variable and route the return path through iounmap() after the revision register has been read.
--- arch/arm/mach-imx/cpu-imx31.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-imx/cpu-imx31.c +7 -2
@@ -36,6 +36,7 @@ static int mx31_read_cpu_rev(void)void __iomem *iim_base;struct device_node *np;u32 i, srev; +int rev =IMX_CHIP_REVISION_UNKNOWN ; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx31-iim" ); iim_base =of_iomap (np,0 );
@@ -48,13 +49,17 @@ static int mx31_read_cpu_rev(void)for (i =0 ; i <ARRAY_SIZE (mx31_cpu_type); i++)if (srev == mx31_cpu_type[i].srev) { + rev = mx31_cpu_type[i].rev;imx_print_silicon_rev (mx31_cpu_type[i].name, mx31_cpu_type[i].rev); -return mx31_cpu_type[i].rev; + goto out; }imx_print_silicon_rev ("i.MX31" ,IMX_CHIP_REVISION_UNKNOWN ); -return IMX_CHIP_REVISION_UNKNOWN ; + +out: +iounmap (iim_base); +return rev; }int mx31_revision (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/2077 x86/cpu: Keep the PROCESSOR_SELECT menu together
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 1df61a8b2d01c560822a0421f2a76af7fda34c1f ]
Having a stray kconfig symbol in the middle of the PROCESSOR_SELECT menu (this symbol plus its dependent symbols) causes the menu dependencies not to be displayed correctly in "make {menu,n,g,x}config".
Move the BROADCAST_TLB_FLUSH symbol away from the PROCESSOR_SELECT menu so that the list of processors is displayed correctly.
--- arch/x86/Kconfig.cpu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/Kconfig.cpu +4 -4
@@ -334,10 +334,6 @@ menuconfig PROCESSOR_SELECT This lets you choose what x86 vendor support code your kernel will include. -config BROADCAST_TLB_FLUSH - def_bool y - depends on CPU_SUP_AMD && 64BIT - config CPU_SUP_INTEL default y bool "Support Intel processors" if PROCESSOR_SELECT
@@ -458,3 +454,7 @@ config CPU_SUP_VORTEX_32 makes the kernel a tiny bit smaller. If unsure, say N. + +config BROADCAST_TLB_FLUSH + def_bool y + depends on CPU_SUP_AMD && 64BIT
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/2077 nvdimm/btt: Handle preemption in BTT lane acquisition
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 8d4b989d9c9afe5f185aa5853b666fc4617afe9e ]
BTT lanes serialize access to per-lane metadata and workspace state during BTT I/O. The btt-check unit test reports data mismatches during BTT writes due to a race in lane acquisition that can lead to silent data corruption.
The existing lane model uses a spinlock together with a per-CPU recursion count. That recursion model stopped being valid after BTT lanes became preemptible: another task can run on the same CPU, observe a non-zero recursion count, bypass locking, and use the same lane concurrently.
BTT lanes are also held across arena_write_bytes() calls. That path reaches nsio_rw_bytes(), which flushes writes with nvdimm_flush(). Some provider flush callbacks can sleep, making a spinlock the wrong primitive for the lane lifetime.
Replace the spinlock-based recursion model with a dynamically allocated per-lane mutex array and take the lane lock unconditionally.
Add might_sleep() to catch any future atomic-context caller.
Found with the ndctl unit test btt-check.sh.
--- Documentation/driver-api/nvdimm/btt.rst | 5 +- drivers/nvdimm/nd.h | 11 ++--- drivers/nvdimm/region_devs.c | 66 +++++++++---------------- 3 files changed, 29 insertions(+), 53 deletions(-)
Documentation/driver-api/nvdimm/btt.rst +2 -3
@@ -161,9 +161,8 @@ process:: nlanes = min(nfree, num_cpus) A lane number is obtained at the start of any IO, and is used for indexing into -all the on-disk and in-memory data structures for the duration of the IO. If -there are more CPUs than the max number of available lanes, than lanes are -protected by spinlocks. +all the on-disk and in-memory data structures for the duration of the IO. Lanes +are protected by mutexes. d. In-memory data structure: Read Tracking Table (RTT)
drivers/nvdimm/nd.h +5 -6
@@ -365,11 +365,6 @@ unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd);for (res = (ndd)->dpa.child, next = res ? res->sibling :NULL ; \ res; res = next, next = next ? next->sibling :NULL ) -struct nd_percpu_lane { -int count; -spinlock_t lock; -}; - enum nd_label_flags { ND_LABEL_REAP, };
@@ -400,6 +395,10 @@ struct nd_mapping {struct nvdimm_drvdata *ndd; }; +struct nd_lane { +struct mutex lock;/* serialize lane access */ +}____cacheline_aligned_in_smp ; +struct nd_region {struct device dev;struct ida ns_ida;
@@ -420,7 +419,7 @@ struct nd_region {struct kernfs_node *bb_state;struct badblocks bb;struct nd_interleave_set *nd_set; -struct nd_percpu_lane __percpu *lane; +struct nd_lane *lane;int (*flush)(struct nd_region *nd_region,struct bio *bio); struct nd_mapping mapping[] __counted_by(ndr_mappings); };
drivers/nvdimm/region_devs.c +22 -44
105 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/2077 tcp_bbr: fix SPDX-License-Identifier to be GPL-2.0 OR BSD-3-Clause
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neal Cardwell <[email protected]>
[ Upstream commit 4490516d2109e105daf732681435c5c075b5d61b ]
Since TCP BBR congestion control was introduced in commit 0f8782ea1497 ("tcp_bbr: add BBR congestion control") it has always been offered as "Dual BSD/GPL":
MODULE_LICENSE("Dual BSD/GPL");A GPL-2.0-only SPDX header was erroneously added in the recent commit 2ed4b46b4fc7 ("net: Add SPDX ids to some source files").
This commit revises the tcp_bbr.c SPDX-License-Identifier to note that this file is licensed as "GPL-2.0 OR BSD-3-Clause".
--- net/ipv4/tcp_bbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_bbr.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* Bottleneck Bandwidth and RTT (BBR) congestion control * * BBR congestion control computes the sending rate based on the delivery
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/2077 scsi: Revert "scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans"
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Wilck <[email protected]>
[ Upstream commit 8c292e89bd831c8a13e92f3429ef66bbe0b83677 ]
This reverts commit 37c4e72b0651e7697eb338cd1fb09feef472cc1a.
Said commit causes excessive resource usage and even system freeze with some controllers, e.g. smartpqi and hisi_sas. The justification provided by the patch authors [1] was supporting a special mode of the mpi3mr and mpt3sas, so-called "Tri-mode", in which NVMe drives are exposed as SCSI devices on a separate channel. While that's useful for these drivers, it seems wrong to cause major breakage for other drivers for the sake of this feature.
--- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_sas.c | 60 +++++++------------------------ 2 files changed, 13 insertions(+), 49 deletions(-)
drivers/scsi/scsi_scan.c +1 -1
@@ -1910,7 +1910,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,return 0 ; } -EXPORT_SYMBOL (scsi_scan_host_selected); +static void scsi_sysfs_add_devices (struct Scsi_Host *shost) {struct scsi_device *sdev;
drivers/scsi/scsi_transport_sas.c +12 -48
83 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/2077 bpf: Reject exclusive maps as inner maps in map-in-map
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 9a3c3c49c333760c8944dadacbe114c1884546ef ]
An exclusive map (created with excl_prog_hash) is bound to a single program by hash: check_map_prog_compatibility() refuses to load any program whose digest does not match map->excl_prog_sha. That check only runs for maps a program references directly, i.e. its used_maps. A map reached at runtime through a map-of-maps is never in used_maps, and bpf_map_meta_equal() does not consider excl_prog_sha, so an exclusive map can be inserted into a non-exclusive outer map and then looked up and mutated by an unrelated program, bypassing the exclusivity guarantee.
For the signed loader this defeats the metadata map exclusivity check added in the signed loader: the cached map->sha[] is validated against the signed hash while another program on a hostile host rewrites the frozen map's contents through the outer map.
--- kernel/bpf/map_in_map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/bpf/map_in_map.c +4 -1
@@ -20,7 +20,8 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)/* Does not support >1 level map-in-map */ if (inner_map->inner_map_meta)return ERR_PTR (-EINVAL ); - +if (inner_map->excl_prog_sha) +return ERR_PTR (-ENOTSUPP );if (!inner_map->ops->map_meta_equal)return ERR_PTR (-ENOTSUPP );
@@ -101,6 +102,8 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map, inner_map =__bpf_map_get (f);if (IS_ERR (inner_map))return inner_map; +if (inner_map->excl_prog_sha) +return ERR_PTR (-ENOTSUPP ); inner_map_meta = map->inner_map_meta;if (inner_map_meta->ops->map_meta_equal (inner_map_meta, inner_map))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/2077 libbpf: Reject non-exclusive metadata maps in the signed loader
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: KP Singh <[email protected]>
[ Upstream commit 0fb6c9ed6493b4af01be8bb0a384574eba7df636 ]
The loader verifies map->sha against the metadata hash in its instructions. map->sha is calculated when BPF_OBJ_GET_INFO_BY_FD is called on the frozen map.
While the map is frozen, the /signed loader/ must also ensure the map is exclusive, as, without exclusivity (which a hostile host could just omit when loading the loader), another BPF program with map access can mutate the contents afterwards, so the check passes on stale data.
With the extra check as part of the signed loader, it now refuses to move on with map->sha validation if the host set it up wrongly.
--- include/linux/bpf.h | 1 + kernel/bpf/syscall.c | 7 +++++++ tools/lib/bpf/gen_loader.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+)
include/linux/bpf.h +1 -0
@@ -295,6 +295,7 @@ struct bpf_map_owner {struct bpf_map {u8 sha[SHA256_DIGEST_SIZE ]; +u32 excl;const struct bpf_map_ops *ops;struct bpf_map *inner_map_meta;#ifdef CONFIG_SECURITY
kernel/bpf/syscall.c +7 -0
@@ -1572,6 +1572,13 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr) err = -EFAULT ; goto free_map; } + +/* See libbpf: emit_signature_match() */ +BUILD_BUG_ON (offsetof(struct bpf_map , excl) !=SHA256_DIGEST_SIZE ); +BUILD_BUG_ON (!__same_type (map->excl, u32)); +BUILD_BUG_ON (offsetof(struct bpf_map , sha) !=0 ); +BUILD_BUG_ON (!__same_type (map->sha, u8[SHA256_DIGEST_SIZE ])); + map->excl =1 ; }else if (attr->excl_prog_hash_size) { err = -EINVAL ; goto free_map;
tools/lib/bpf/gen_loader.c +17 -0
@@ -585,6 +585,23 @@ static void emit_signature_match(struct bpf_gen *gen)__s64 off;int i; +/* +* Reject if the metadata map is not exclusive. Without exclusivity +* the cached map->sha[] verified above can be stale: another BPF +* program with map access could have mutated the contents between +* BPF_OBJ_GET_INFO_BY_FD and loader execution. +*/ +emit2 (gen,BPF_LD_IMM64_RAW_FULL (BPF_REG_1 ,BPF_PSEUDO_MAP_IDX , +0 ,0 ,0 ,0 )); +emit (gen,BPF_LDX_MEM (BPF_W ,BPF_REG_2 ,BPF_REG_1 ,SHA256_DIGEST_LENGTH )); + off = -(gen->insn_cur - gen->insn_start - gen->cleanup_label) /8 -2 ; +if (is_simm16 (off)) { +emit (gen,BPF_MOV64_IMM (BPF_REG_7 , -EINVAL )); +emit (gen,BPF_JMP_IMM (BPF_JNE ,BPF_REG_2 ,1 , off)); + }else { + gen->error = -ERANGE ; + } +for (i =0 ; i <SHA256_DWORD_SIZE ; i++) {emit2 (gen,BPF_LD_IMM64_RAW_FULL (BPF_REG_1 ,BPF_PSEUDO_MAP_IDX ,0 ,0 ,0 ,0 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/2077 libbpf: Skip initial_value override on signed loaders
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 61e084152328867fe2279cc790573aae39959cd5 ]
bpf_gen__map_update_elem() emits code that, when the host-supplied loader ctx provides a non-NULL map_desc[idx].initial_value, overwrites the blob value with bytes read from the host (bpf_copy_from_user / bpf_probe_read_kernel) before the BPF_MAP_UPDATE_ELEM that populates the program's .data/.rodata/.bss maps.
This override runs after emit_signature_match() has validated map->sha[], and initial_value is part of neither the signed loader instructions nor the hashed data blob. For a signed loader this lets an untrusted host substitute global-variable contents into a program whose code carries a valid signature, thus weakening what the signature attests to.
The blob already contains the signer-provided value (added via add_data() and covered by the embedded, signed hash), so simply skip emitting the override for signed loaders (gen_hash). Runtime initialization stays available for the unsigned light-skeleton path as before. The jump offsets within the override block are internal to it, so guarding the whole block leaves them unchanged.
--- tools/lib/bpf/gen_loader.c | 39 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
tools/lib/bpf/gen_loader.c +24 -15
@@ -1186,27 +1186,36 @@ void bpf_gen__map_update_elem(struct bpf_gen *gen, int map_idx, void *pvalue, value =add_data (gen, pvalue, value_size); key =add_data (gen, &zero,sizeof (zero)); -/* if (map_desc[map_idx].initial_value) { +/* +* if (map_desc[map_idx].initial_value) { * if (ctx->flags & BPF_SKEL_KERNEL) * bpf_probe_read_kernel(value, value_size, initial_value); * else * bpf_copy_from_user(value, value_size, initial_value); * } +* +* The runtime initial_value comes from the host-supplied loader +* ctx and would overwrite the blob value after emit_signature_match() +* has already validated map->sha[]. For a signed loader (gen_hash) +* the attested blob value must be authoritative, so skip the override +* and leave the hashed value in place. */ -emit (gen,BPF_LDX_MEM (BPF_DW ,BPF_REG_3 ,BPF_REG_6 , -sizeof (struct bpf_loader_ctx ) + -sizeof (struct bpf_map_desc ) * map_idx + - offsetof(struct bpf_map_desc , initial_value))); -emit (gen,BPF_JMP_IMM (BPF_JEQ ,BPF_REG_3 ,0 ,8 )); -emit2 (gen,BPF_LD_IMM64_RAW_FULL (BPF_REG_1 ,BPF_PSEUDO_MAP_IDX_VALUE , -0 ,0 ,0 , value)); -emit (gen,BPF_MOV64_IMM (BPF_REG_2 , value_size)); -emit (gen,BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_6 , - offsetof(struct bpf_loader_ctx , flags))); -emit (gen,BPF_JMP_IMM (BPF_JSET ,BPF_REG_0 ,BPF_SKEL_KERNEL ,2 )); -emit (gen,BPF_EMIT_CALL (BPF_FUNC_copy_from_user)); -emit (gen,BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 )); -emit (gen,BPF_EMIT_CALL (BPF_FUNC_probe_read_kernel)); +if (!OPTS_GET (gen->opts, gen_hash, false)) { +emit (gen,BPF_LDX_MEM (BPF_DW ,BPF_REG_3 ,BPF_REG_6 , +sizeof (struct bpf_loader_ctx ) + +sizeof (struct bpf_map_desc ) * map_idx + + offsetof(struct bpf_map_desc , initial_value))); +emit (gen,BPF_JMP_IMM (BPF_JEQ ,BPF_REG_3 ,0 ,8 )); +emit2 (gen,BPF_LD_IMM64_RAW_FULL (BPF_REG_1 ,BPF_PSEUDO_MAP_IDX_VALUE , +0 ,0 ,0 , value)); +emit (gen,BPF_MOV64_IMM (BPF_REG_2 , value_size)); +emit (gen,BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_6 , + offsetof(struct bpf_loader_ctx , flags))); +emit (gen,BPF_JMP_IMM (BPF_JSET ,BPF_REG_0 ,BPF_SKEL_KERNEL ,2 )); +emit (gen,BPF_EMIT_CALL (BPF_FUNC_copy_from_user)); +emit (gen,BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 )); +emit (gen,BPF_EMIT_CALL (BPF_FUNC_probe_read_kernel)); + } map_update_attr =add_data (gen, &attr, attr_size); pr_debug("gen: map_update_elem: idx %d, value: off %d size %d, attr: off %d size %d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/2077 libbpf: Skip max_entries override on signed loaders
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 60214435b365ecdd40b2f96d4e54564b5c927645 ]
bpf_gen__map_create() lets the host-supplied loader ctx override a map's max_entries at runtime (map_desc[idx].max_entries, when non-zero). This is how the light skeleton sizes maps to the target machine, but it happens after emit_signature_match() and is covered by neither the signed loader instructions nor the hashed blob.
For a signed loader this means an untrusted host can re-dimension the program's maps, outside what the signature attests to. Gate the override on gen_hash so signed loaders use the signer-provided max_entries baked into the blob.
--- tools/lib/bpf/gen_loader.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/lib/bpf/gen_loader.c +11 -2
@@ -545,13 +545,22 @@ void bpf_gen__map_create(struct bpf_gen *gen,default :break ; } -/* conditionally update max_entries */ -if (map_idx >=0 ) + +/* +* Conditionally update max_entries from the host-supplied loader +* ctx. This sizes the map at runtime, but for a signed loader +* (gen_hash) it would let an untrusted host re-dimension the +* program's maps after emit_signature_match(), outside what the +* signature attests to. Keep the signer-provided max_entries +* baked into the blob in that case. +*/ +if (map_idx >=0 && !OPTS_GET (gen->opts, gen_hash, false))move_ctx2blob (gen,attr_field (map_create_attr, max_entries),4 ,sizeof (struct bpf_loader_ctx ) +sizeof (struct bpf_map_desc ) * map_idx + offsetof(struct bpf_map_desc , max_entries), true/* check that max_entries != 0 */ ); +/* emit MAP_CREATE command */ emit_sys_bpf (gen,BPF_MAP_CREATE , map_create_attr, attr_size); debug_ret(gen, "map_create %s idx %d type %d value_size %d value_btf_id %d",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/2077 scsi: pm8001: Fix error code in non_fatal_log_show()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 1b6f03b7ae9ee27054c55bb55a69d05555a78516 ]
The non_fatal_log_show() function is supposed to return negative error codes on failure. But because the error codes are saved in a u32 and then cast to signed long, they end up being high positive values instead of negative. Remove the intermediary u32 variable to fix this bug.
--- drivers/scsi/pm8001/pm8001_ctl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_ctl.c +1 -4
@@ -588,10 +588,7 @@ static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL);static ssize_t non_fatal_log_show (struct device *cdev,struct device_attribute *attr,char *buf) { -u32 count; - - count =pm80xx_get_non_fatal_dump (cdev, attr, buf); -return count; +return pm80xx_get_non_fatal_dump (cdev, attr, buf); }static DEVICE_ATTR_RO (non_fatal_log);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/2077 scsi: ufs: Fix wrong value printed in unexpected UPIU response case
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chanwoo Lee <[email protected]>
[ Upstream commit 2483ae0a56231a915c706411421c6c002a2bf83e ]
In ufshcd_transfer_rsp_status(), the default case of the inner switch statement prints the UPIU response code when an unexpected response is received. However, the code was printing 'result' variable which is always 0 at that point, making the error message useless for debugging.
Fix this by printing the actual UPIU response code returned by ufshcd_get_req_rsp().
--- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +1 -1
@@ -5634,7 +5634,7 @@ static inline int ufshcd_transfer_rsp_status(struct ufs_hba *hba,default :dev_err (hba->dev,"Unexpected request response code = %x\n" , - result); +ufshcd_get_req_rsp (lrbp->ucd_rsp_ptr)); result =DID_ERROR <<16 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/2077 bpf: fix UAF by restoring RCU-delayed inode freeing in bpffs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit b93c55b4932dd7e32dca8cf34a3443cc87a02906 ]
commit 4f375ade6aa9 ("bpf: Avoid RCU context warning when unpinning htab with internal structs") moved inode cleanup from ->free_inode() into ->destroy_inode() to avoid sleeping in RCU context when calling bpf_any_put(). However this removed the RCU delay on freeing the inode itself and the cached symlink body (i_link), both of which can be accessed by RCU pathwalk (pick_link, may_lookup etc.).
This causes a use-after-free when a concurrent unlinkat() drops the last inode reference and destroy_inode() frees the inode immediately, while another task is still walking the path in RCU mode and reads inode->i_opflags (offset +2) inside current_time() -> is_mgtime().
KASAN reports:
BUG: KASAN: slab-use-after-free in is_mgtime include/linux/fs.h:2313 Read of size 2 at addr ffff8880407e4282 (offset +2 = i_opflags)
The rules (per Al Viro):
->destroy_inode() called immediately, can sleep, use for blocking
cleanup e.g. bpf_any_put()
->free_inode() called after RCU grace period, use for freeing
inode and anything RCU-accessible e.g. i_link
Fix: split the two concerns properly:
- keep bpf_any_put() in bpf_destroy_inode() since it is blocking and needs to run promptly
- introduce bpf_free_inode() to handle kfree(i_link) and free_inode_nonrcu() with proper RCU delay, preventing the UAF
--- kernel/bpf/inode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
kernel/bpf/inode.c +11 -2
@@ -766,10 +766,18 @@ static void bpf_destroy_inode(struct inode *inode) {enum bpf_type type; -if (S_ISLNK (inode->i_mode)) -kfree (inode->i_link);if (!bpf_inode_type (inode, &type))bpf_any_put (inode->i_private, type); +} + +/* +* Called after RCU grace period - safe to free inode and anything +* that might be accessed by RCU pathwalk (inode fields, i_link). +*/ +static void bpf_free_inode (struct inode *inode) +{ +if (S_ISLNK (inode->i_mode)) +kfree (inode->i_link);free_inode_nonrcu (inode); }
@@ -778,6 +786,7 @@ const struct super_operations bpf_super_ops = { .drop_inode = inode_just_drop, .show_options = bpf_show_options, .destroy_inode = bpf_destroy_inode, + .free_inode = bpf_free_inode, };enum {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/2077 mm/fake-numa: fix under-allocation detection in uniform split
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Heon Jeon <[email protected]>
[ Upstream commit 3a3fc1dfd6a958615ebaab8fb251e89fc2b3f2f2 ]
When splitting NUMA node uniformly, split_nodes_size_interleave_uniform() returns the next absolute node ID, not the number of nodes created.
The existing under-allocation detection logic compares next absolute node ID (ret) and request count (n), which only works when nid starts at 0.
For example, on a system with 2 physical NUMA nodes (node 0: 2GB, node 1: 128MB) and numa=fake=8U, 8 fake nodes are successfully created from node 0 and split_nodes_size_interleave_uniform() returns 8. For node 1, fake node nid starts at 8, but only 4 fake nodes are created due to current FAKE_NODE_MIN_SIZE being 32MB, and split_nodes_size_interleave_uniform() returns 12. By existing under-allocation detection logic, "ret < n" (12 < 8) is false, so the under-allocation will not be detected.
Fix under-allocation detection logic to compare the number of actually created nodes (ret - nid) against the request count (n). Also skip under-allocation detection logic for memoryless physical nodes where no fake nodes are created.
Also, fix the outdated comment describing split_nodes_size_interleave_uniform() to match the actual return value.
--- mm/numa_emulation.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
mm/numa_emulation.c +13 -4
@@ -214,7 +214,7 @@ static u64 uniform_size(u64 max_addr, u64 base, u64 hole, int nr_nodes)* Sets up fake nodes of `size' interleaved over physical nodes ranging from * `addr' to `max_addr'. * -* Returns zero on success or negative on error. +* Returns node ID of the next node on success or negative error code. */ static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei, struct numa_meminfo *pi,
@@ -398,7 +398,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)*/ if (strchr (emu_cmdline,'U' )) {unsigned long n; -int nid =0 ; +int nid =0 , nr_created; n =simple_strtoul (emu_cmdline, &emu_cmdline,0 ); ret =-1 ;
@@ -416,9 +416,18 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) n, &pi.blk[0], nid);if (ret <0 )break ; -if (ret < n) { + +/* +* If no memory was found for this physical node, +* skip the under-allocation check. +*/ +if (ret == nid) +continue ; + + nr_created = ret - nid; +if (nr_created < n) {pr_info ("%s: phys: %d only got %d of %ld nodes, failing\n" , - __func__, i, ret, n); + __func__, i, nr_created, n); ret =-1 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/2077 ext2: fix ignored return value of generic_write_sync()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit a4659be0bc7cb1856ffb15b67f903229ae8891ec ]
Fix ext2_dio_write_iter() to propagate the error returned by generic_write_sync() instead of silently discarding it, which could cause write(2) to return success to userspace on O_SYNC/O_DSYNC files even when the sync failed.
The correct pattern, already used in ext2_dax_write_iter() in the same file and in ext4, xfs, f2fs among others, is:
if (ret > 0)
ret = generic_write_sync(iocb, ret);Found by Linux Verification Center (linuxtesting.org) with SVACE.
[JK: Reflect also filemap_write_and_wait() return value]
--- fs/ext2/file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ext2/file.c +6 -3
@@ -267,12 +267,15 @@ static ssize_t ext2_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) endbyte = pos + status -1 ; ret2 =filemap_write_and_wait_range (inode->i_mapping, pos, endbyte); -if (!ret2) +if (!ret2) {invalidate_mapping_pages (inode->i_mapping, pos >>PAGE_SHIFT , endbyte >>PAGE_SHIFT ); -if (ret >0 ) -generic_write_sync (iocb, ret); +if (ret >0 ) + ret =generic_write_sync (iocb, ret); + }else { + ret = ret2; + } } out_unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/2077 sched: restore timer_slack_ns when resetting RT policy on fork
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanyou.Chen <[email protected]>
[ Upstream commit 63c1a12bc0e09af7dee919c4fb4a300a719d5125 ]
Commit ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values for realtime tasks") sets timer_slack_ns to 0 for RT tasks in __setscheduler_params(). However, when an RT task with SCHED_RESET_ON_FORK creates child threads, the children inherit timer_slack_ns=0 from the parent. sched_fork() resets the child's policy to SCHED_NORMAL but does not restore timer_slack_ns, leaving the child permanently running with zero slack.
Fix this by restoring timer_slack_ns from default_timer_slack_ns in sched_fork() when resetting from RT/DL to NORMAL policy, matching the existing behavior in __setscheduler_params().
Note: this fix alone requires a correct default_timer_slack_ns to be effective. See the following patch for that fix.
--- kernel/sched/core.c | 1 + 1 file changed, 1 insertion(+)
kernel/sched/core.c +1 -0
@@ -4710,6 +4710,7 @@ int sched_fork(u64 clone_flags, struct task_struct *p) p->policy =SCHED_NORMAL ; p->static_prio =NICE_TO_PRIO (0 ); p->rt_priority =0 ; + p->timer_slack_ns = p->default_timer_slack_ns; }else if (PRIO_TO_NICE (p->static_prio) <0 ) p->static_prio =NICE_TO_PRIO (0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/2077 nvme: fix FDP fdpcidx bounds check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: liuxixin <[email protected]>
[ Upstream commit 0967074f6830718fd2597404ef119bddd0dbfd00 ]
The fdpcidx bounds check sets n = NUMFDPC + 1 but used > instead of >=, incorrectly accepting fdp_idx when it equals n (i.e. NUMFDPC + 1).
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -2263,7 +2263,7 @@ static int nvme_query_fdp_granularity(struct nvme_ctrl *ctrl, } n =le16_to_cpu (h->numfdpc) +1 ; -if (fdp_idx > n) { +if (fdp_idx >= n) {dev_warn (ctrl->device,"FDP index:%d out of range:%d\n" , fdp_idx, n);/* Proceed without registering FDP streams */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/2077 driver core: Use system_percpu_wq instead of system_wq
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit fda8355f13ea3c0f9499acdeff3024995b474948 ]
Commit 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work") added a use of system_wq, which is deprecated in favor of system_percpu_wq added by commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq"). An upcoming warning in the workqueue tree flags this with:
workqueue: work func deferred_probe_timeout_work_func enqueued on deprecated workqueue. Use system_{percpu|dfl}_wq instead.
Switch to system_percpu_wq to clear up the warning.
--- drivers/base/dd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/dd.c +1 -1
@@ -324,7 +324,7 @@ void deferred_probe_extend_timeout(void)* start a new one. */ if (delayed_work_pending (&deferred_probe_timeout_work) && -mod_delayed_work (system_wq, &deferred_probe_timeout_work, +mod_delayed_work (system_percpu_wq, &deferred_probe_timeout_work,secs_to_jiffies (driver_deferred_probe_timeout)))pr_debug ("Extended deferred probe timeout by %d secs\n" , driver_deferred_probe_timeout);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/2077 bpf: Reject exclusive maps for bpf_map_elem iterators
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 3c56ee343f9412d81918635c3e25e22a5dd6d87e ]
Exclusive maps (aka excl_prog_hash) are meant to be reachable only from the single program whose hash matches. This is enforced by check_map_prog_compatibility() when the map is referenced from a program such as signed BPF loaders.
A bpf_map_elem iterator, however, binds its target map at attach time in bpf_iter_attach_map() instead of referencing it from the program, so the exclusivity check is never reached. On top of that, the iterator exposes the map value as a writable buffer.
--- kernel/bpf/map_iter.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/bpf/map_iter.c +4 -0
@@ -112,6 +112,10 @@ static int bpf_iter_attach_map(struct bpf_prog *prog, map =bpf_map_get_with_uref (linfo->map.map_fd);if (IS_ERR (map))return PTR_ERR (map); +if (map->excl_prog_sha) { + err = -EPERM ; + goto put_map; + } if (map->map_type == BPF_MAP_TYPE_PERCPU_HASH || map->map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/2077 tick/sched: Fix TOCTOU in nohz idle time fetch
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
[ Upstream commit 86db4084b4b5d1a074bcc66c108a4c9d266812d4 ]
When the nohz idle time is fetched, the current clock timestamp is taken outside the seqcount, which can result in a race as reported by Sashiko:
get_cpu_sleep_time_us() tick_nohz_start_idle()
----------------------- ---------------------
now = ktime_get()
write_seqcount_begin(idle_sleeptime_seq);
idle_entrytime = ktime_get()
tick_sched_flag_set(ts, TS_FLAG_IDLE_ACTIVE);
write_seqcount_end(&ts->idle_sleeptime_seq);
read_seqcount_begin(idle_sleeptime_seq)
delta = now - idle_entrytime);
//!! But now < idle_entrytime
idle = *sleeptime + delta;
read_seqcount_retry(&ts->idle_sleeptime_seq, seq)Here the read side fetches the timestamp before the write side and its update. As a result the time delta computed on the read side is negative (ktime_t is signed) and breaks the cputime monotonicity guarantee.
This could possibly be fixed with reading the current clock timestamp inside the seqcount but the reader overhead might then increase. Also simply checking that the current timestamp is above the idle entry time is enough to prevent any issue of the like.
--- kernel/time/tick-sched.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/time/tick-sched.c +6 -5
@@ -797,15 +797,16 @@ static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime, *last_update_time =ktime_to_us (now);do { +ktime_t delta =0 ; + seq =read_seqcount_begin (&ts->idle_sleeptime_seq);if (tick_sched_flag_test (ts,TS_FLAG_IDLE_ACTIVE ) && compute_delta) { -ktime_t delta =ktime_sub (now, ts->idle_entrytime); - - idle =ktime_add (*sleeptime, delta); - }else { - idle = *sleeptime; +if (now > ts->idle_entrytime) + delta =ktime_sub (now, ts->idle_entrytime); } + + idle =ktime_add (*sleeptime, delta); }while (read_seqcount_retry (&ts->idle_sleeptime_seq, seq));return ktime_to_us (idle);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/2077 lib/test_meminit: use && for bools
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Potapenko <[email protected]>
[ Upstream commit 8e0c2085c978ed6d9764d79fc785920360096f21 ]
As pointed out by Dan Carpenter, test_kmemcache() was using a bitwise AND on two bools instead of a boolean AND. Fix this for the sake of code cleanliness.
--- lib/test_meminit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_meminit.c +1 -1
@@ -387,7 +387,7 @@ static int __init test_kmemcache(int *total_failures) ctor = flags &1 ; rcu = flags &2 ; zero = flags &4 ; -if (ctor & zero) +if (ctor && zero)continue ; num_tests +=do_kmem_cache_size (size, ctor, rcu, zero, &failures);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/2077 riscv: dts: sophgo: sg2044: use hex for CPU unit address
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit 207cbc477406a72952e27ace2eadbae55164f129 ]
Previous the CPU unit address cpu of sg2044 use decimal, it is not following the general convention for unit addresses of the OF. Convent the unit address to hex to resolve this problem.
The introduces a small change for the CPU node name, but it should nothing since there is no direct full-path reference to these CPU nodes.
--- arch/riscv/boot/dts/sophgo/sg2044-cpus.dtsi | 236 ++++++++++---------- 1 file changed, 118 insertions(+), 118 deletions(-)
arch/riscv/boot/dts/sophgo/sg2044-cpus.dtsi +118 -118
@@ -14,7 +14,7 @@ cpus { cpu0: cpu@0 { compatible = "thead,c920", "riscv"; - reg = <0>; + reg = <0x0>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -50,7 +50,7 @@ cpu0_intc: interrupt-controller { cpu1: cpu@1 { compatible = "thead,c920", "riscv"; - reg = <1>; + reg = <0x1>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -86,7 +86,7 @@ cpu1_intc: interrupt-controller { cpu2: cpu@2 { compatible = "thead,c920", "riscv"; - reg = <2>; + reg = <0x2>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -122,7 +122,7 @@ cpu2_intc: interrupt-controller { cpu3: cpu@3 { compatible = "thead,c920", "riscv"; - reg = <3>; + reg = <0x3>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -158,7 +158,7 @@ cpu3_intc: interrupt-controller { cpu4: cpu@4 { compatible = "thead,c920", "riscv"; - reg = <4>; + reg = <0x4>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -194,7 +194,7 @@ cpu4_intc: interrupt-controller { cpu5: cpu@5 { compatible = "thead,c920", "riscv"; - reg = <5>; + reg = <0x5>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -230,7 +230,7 @@ cpu5_intc: interrupt-controller { cpu6: cpu@6 { compatible = "thead,c920", "riscv"; - reg = <6>; + reg = <0x6>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -266,7 +266,7 @@ cpu6_intc: interrupt-controller { cpu7: cpu@7 { compatible = "thead,c920", "riscv"; - reg = <7>; + reg = <0x7>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -302,7 +302,7 @@ cpu7_intc: interrupt-controller { cpu8: cpu@8 { compatible = "thead,c920", "riscv"; - reg = <8>; + reg = <0x8>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -338,7 +338,7 @@ cpu8_intc: interrupt-controller { cpu9: cpu@9 { compatible = "thead,c920", "riscv"; - reg = <9>; + reg = <0x9>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -372,9 +372,9 @@ cpu9_intc: interrupt-controller { }; }; - cpu10: cpu@10 { + cpu10: cpu@a { compatible = "thead,c920", "riscv"; - reg = <10>; + reg = <0xa>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -408,9 +408,9 @@ cpu10_intc: interrupt-controller { }; }; - cpu11: cpu@11 { + cpu11: cpu@b { compatible = "thead,c920", "riscv"; - reg = <11>; + reg = <0xb>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -444,9 +444,9 @@ cpu11_intc: interrupt-controller { }; }; - cpu12: cpu@12 { + cpu12: cpu@c { compatible = "thead,c920", "riscv"; - reg = <12>; + reg = <0xc>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -480,9 +480,9 @@ cpu12_intc: interrupt-controller { }; }; - cpu13: cpu@13 { + cpu13: cpu@d { compatible = "thead,c920", "riscv"; - reg = <13>; + reg = <0xd>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -516,9 +516,9 @@ cpu13_intc: interrupt-controller { }; }; - cpu14: cpu@14 { + cpu14: cpu@e { compatible = "thead,c920", "riscv"; - reg = <14>; + reg = <0xe>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -552,9 +552,9 @@ cpu14_intc: interrupt-controller { }; }; - cpu15: cpu@15 { + cpu15: cpu@f { compatible = "thead,c920", "riscv"; - reg = <15>; + reg = <0xf>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -588,9 +588,9 @@ cpu15_intc: interrupt-controller { }; }; - cpu16: cpu@16 { + cpu16: cpu@10 { compatible = "thead,c920", "riscv"; - reg = <16>; + reg = <0x10>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -624,9 +624,9 @@ cpu16_intc: interrupt-controller { }; }; - cpu17: cpu@17 { + cpu17: cpu@11 { compatible = "thead,c920", "riscv"; - reg = <17>; + reg = <0x11>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -660,9 +660,9 @@ cpu17_intc: interrupt-controller { }; }; - cpu18: cpu@18 { + cpu18: cpu@12 { compatible = "thead,c920", "riscv"; - reg = <18>; + reg = <0x12>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -696,9 +696,9 @@ cpu18_intc: interrupt-controller { }; }; - cpu19: cpu@19 { + cpu19: cpu@13 { compatible = "thead,c920", "riscv"; - reg = <19>; + reg = <0x13>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -732,9 +732,9 @@ cpu19_intc: interrupt-controller { }; }; - cpu20: cpu@20 { + cpu20: cpu@14 { compatible = "thead,c920", "riscv"; - reg = <20>; + reg = <0x14>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -768,9 +768,9 @@ cpu20_intc: interrupt-controller { }; }; - cpu21: cpu@21 { + cpu21: cpu@15 { compatible = "thead,c920", "riscv"; - reg = <21>; + reg = <0x15>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -804,9 +804,9 @@ cpu21_intc: interrupt-controller { }; }; - cpu22: cpu@22 { + cpu22: cpu@16 { compatible = "thead,c920", "riscv"; - reg = <22>; + reg = <0x16>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -840,9 +840,9 @@ cpu22_intc: interrupt-controller { }; }; - cpu23: cpu@23 { + cpu23: cpu@17 { compatible = "thead,c920", "riscv"; - reg = <23>; + reg = <0x17>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -876,9 +876,9 @@ cpu23_intc: interrupt-controller { }; }; - cpu24: cpu@24 { + cpu24: cpu@18 { compatible = "thead,c920", "riscv"; - reg = <24>; + reg = <0x18>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -912,9 +912,9 @@ cpu24_intc: interrupt-controller { }; }; - cpu25: cpu@25 { + cpu25: cpu@19 { compatible = "thead,c920", "riscv"; - reg = <25>; + reg = <0x19>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -948,9 +948,9 @@ cpu25_intc: interrupt-controller { }; }; - cpu26: cpu@26 { + cpu26: cpu@1a { compatible = "thead,c920", "riscv"; - reg = <26>; + reg = <0x1a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -984,9 +984,9 @@ cpu26_intc: interrupt-controller { }; }; - cpu27: cpu@27 { + cpu27: cpu@1b { compatible = "thead,c920", "riscv"; - reg = <27>; + reg = <0x1b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1020,9 +1020,9 @@ cpu27_intc: interrupt-controller { }; }; - cpu28: cpu@28 { + cpu28: cpu@1c { compatible = "thead,c920", "riscv"; - reg = <28>; + reg = <0x1c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1056,9 +1056,9 @@ cpu28_intc: interrupt-controller { }; }; - cpu29: cpu@29 { + cpu29: cpu@1d { compatible = "thead,c920", "riscv"; - reg = <29>; + reg = <0x1d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1092,9 +1092,9 @@ cpu29_intc: interrupt-controller { }; }; - cpu30: cpu@30 { + cpu30: cpu@1e { compatible = "thead,c920", "riscv"; - reg = <30>; + reg = <0x1e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1128,9 +1128,9 @@ cpu30_intc: interrupt-controller { }; }; - cpu31: cpu@31 { + cpu31: cpu@1f { compatible = "thead,c920", "riscv"; - reg = <31>; + reg = <0x1f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1164,9 +1164,9 @@ cpu31_intc: interrupt-controller { }; }; - cpu32: cpu@32 { + cpu32: cpu@20 { compatible = "thead,c920", "riscv"; - reg = <32>; + reg = <0x20>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1200,9 +1200,9 @@ cpu32_intc: interrupt-controller { }; }; - cpu33: cpu@33 { + cpu33: cpu@21 { compatible = "thead,c920", "riscv"; - reg = <33>; + reg = <0x21>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1236,9 +1236,9 @@ cpu33_intc: interrupt-controller { }; }; - cpu34: cpu@34 { + cpu34: cpu@22 { compatible = "thead,c920", "riscv"; - reg = <34>; + reg = <0x22>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1272,9 +1272,9 @@ cpu34_intc: interrupt-controller { }; }; - cpu35: cpu@35 { + cpu35: cpu@23 { compatible = "thead,c920", "riscv"; - reg = <35>; + reg = <0x23>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1308,9 +1308,9 @@ cpu35_intc: interrupt-controller { }; }; - cpu36: cpu@36 { + cpu36: cpu@24 { compatible = "thead,c920", "riscv"; - reg = <36>; + reg = <0x24>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1344,9 +1344,9 @@ cpu36_intc: interrupt-controller { }; }; - cpu37: cpu@37 { + cpu37: cpu@25 { compatible = "thead,c920", "riscv"; - reg = <37>; + reg = <0x25>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1380,9 +1380,9 @@ cpu37_intc: interrupt-controller { }; }; - cpu38: cpu@38 { + cpu38: cpu@26 { compatible = "thead,c920", "riscv"; - reg = <38>; + reg = <0x26>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1416,9 +1416,9 @@ cpu38_intc: interrupt-controller { }; }; - cpu39: cpu@39 { + cpu39: cpu@27 { compatible = "thead,c920", "riscv"; - reg = <39>; + reg = <0x27>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1452,9 +1452,9 @@ cpu39_intc: interrupt-controller { }; }; - cpu40: cpu@40 { + cpu40: cpu@28 { compatible = "thead,c920", "riscv"; - reg = <40>; + reg = <0x28>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1488,9 +1488,9 @@ cpu40_intc: interrupt-controller { }; }; - cpu41: cpu@41 { + cpu41: cpu@29 { compatible = "thead,c920", "riscv"; - reg = <41>; + reg = <0x29>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1524,9 +1524,9 @@ cpu41_intc: interrupt-controller { }; }; - cpu42: cpu@42 { + cpu42: cpu@2a { compatible = "thead,c920", "riscv"; - reg = <42>; + reg = <0x2a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1560,9 +1560,9 @@ cpu42_intc: interrupt-controller { }; }; - cpu43: cpu@43 { + cpu43: cpu@2b { compatible = "thead,c920", "riscv"; - reg = <43>; + reg = <0x2b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1596,9 +1596,9 @@ cpu43_intc: interrupt-controller { }; }; - cpu44: cpu@44 { + cpu44: cpu@2c { compatible = "thead,c920", "riscv"; - reg = <44>; + reg = <0x2c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1632,9 +1632,9 @@ cpu44_intc: interrupt-controller { }; }; - cpu45: cpu@45 { + cpu45: cpu@2d { compatible = "thead,c920", "riscv"; - reg = <45>; + reg = <0x2d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1668,9 +1668,9 @@ cpu45_intc: interrupt-controller { }; }; - cpu46: cpu@46 { + cpu46: cpu@2e { compatible = "thead,c920", "riscv"; - reg = <46>; + reg = <0x2e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1704,9 +1704,9 @@ cpu46_intc: interrupt-controller { }; }; - cpu47: cpu@47 { + cpu47: cpu@2f { compatible = "thead,c920", "riscv"; - reg = <47>; + reg = <0x2f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1740,9 +1740,9 @@ cpu47_intc: interrupt-controller { }; }; - cpu48: cpu@48 { + cpu48: cpu@30 { compatible = "thead,c920", "riscv"; - reg = <48>; + reg = <0x30>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1776,9 +1776,9 @@ cpu48_intc: interrupt-controller { }; }; - cpu49: cpu@49 { + cpu49: cpu@31 { compatible = "thead,c920", "riscv"; - reg = <49>; + reg = <0x31>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1812,9 +1812,9 @@ cpu49_intc: interrupt-controller { }; }; - cpu50: cpu@50 { + cpu50: cpu@32 { compatible = "thead,c920", "riscv"; - reg = <50>; + reg = <0x32>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1848,9 +1848,9 @@ cpu50_intc: interrupt-controller { }; }; - cpu51: cpu@51 { + cpu51: cpu@33 { compatible = "thead,c920", "riscv"; - reg = <51>; + reg = <0x33>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1884,9 +1884,9 @@ cpu51_intc: interrupt-controller { }; }; - cpu52: cpu@52 { + cpu52: cpu@34 { compatible = "thead,c920", "riscv"; - reg = <52>; + reg = <0x34>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1920,9 +1920,9 @@ cpu52_intc: interrupt-controller { }; }; - cpu53: cpu@53 { + cpu53: cpu@35 { compatible = "thead,c920", "riscv"; - reg = <53>; + reg = <0x35>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1956,9 +1956,9 @@ cpu53_intc: interrupt-controller { }; }; - cpu54: cpu@54 { + cpu54: cpu@36 { compatible = "thead,c920", "riscv"; - reg = <54>; + reg = <0x36>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1992,9 +1992,9 @@ cpu54_intc: interrupt-controller { }; }; - cpu55: cpu@55 { + cpu55: cpu@37 { compatible = "thead,c920", "riscv"; - reg = <55>; + reg = <0x37>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2028,9 +2028,9 @@ cpu55_intc: interrupt-controller { }; }; - cpu56: cpu@56 { + cpu56: cpu@38 { compatible = "thead,c920", "riscv"; - reg = <56>; + reg = <0x38>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2064,9 +2064,9 @@ cpu56_intc: interrupt-controller { }; }; - cpu57: cpu@57 { + cpu57: cpu@39 { compatible = "thead,c920", "riscv"; - reg = <57>; + reg = <0x39>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2100,9 +2100,9 @@ cpu57_intc: interrupt-controller { }; }; - cpu58: cpu@58 { + cpu58: cpu@3a { compatible = "thead,c920", "riscv"; - reg = <58>; + reg = <0x3a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2136,9 +2136,9 @@ cpu58_intc: interrupt-controller { }; }; - cpu59: cpu@59 { + cpu59: cpu@3b { compatible = "thead,c920", "riscv"; - reg = <59>; + reg = <0x3b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2172,9 +2172,9 @@ cpu59_intc: interrupt-controller { }; }; - cpu60: cpu@60 { + cpu60: cpu@3c { compatible = "thead,c920", "riscv"; - reg = <60>; + reg = <0x3c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2208,9 +2208,9 @@ cpu60_intc: interrupt-controller { }; }; - cpu61: cpu@61 { + cpu61: cpu@3d { compatible = "thead,c920", "riscv"; - reg = <61>; + reg = <0x3d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2244,9 +2244,9 @@ cpu61_intc: interrupt-controller { }; }; - cpu62: cpu@62 { + cpu62: cpu@3e { compatible = "thead,c920", "riscv"; - reg = <62>; + reg = <0x3e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2280,9 +2280,9 @@ cpu62_intc: interrupt-controller { }; }; - cpu63: cpu@63 { + cpu63: cpu@3f { compatible = "thead,c920", "riscv"; - reg = <63>; + reg = <0x3f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/2077 riscv: dts: sophgo: sg2042: use hex for CPU unit address
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Inochi Amaoto <[email protected]>
[ Upstream commit a7e658907686528fe06a11828b04a3e42df9ef18 ]
Previous the CPU unit address cpu of sg2042 use decimal, it is not following the general convention for unit addresses of the OF. Convent the unit address to hex to resolve this problem.
The introduces a small change for the CPU node name, but it should affect nothing since there is no direct full-path reference to these CPU nodes.
--- arch/riscv/boot/dts/sophgo/sg2042-cpus.dtsi | 236 ++++++++++---------- 1 file changed, 118 insertions(+), 118 deletions(-)
arch/riscv/boot/dts/sophgo/sg2042-cpus.dtsi +118 -118
@@ -263,7 +263,7 @@ cpu0: cpu@0 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <0>; + reg = <0x0>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -291,7 +291,7 @@ cpu1: cpu@1 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <1>; + reg = <0x1>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -319,7 +319,7 @@ cpu2: cpu@2 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <2>; + reg = <0x2>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -347,7 +347,7 @@ cpu3: cpu@3 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <3>; + reg = <0x3>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -375,7 +375,7 @@ cpu4: cpu@4 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <4>; + reg = <0x4>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -403,7 +403,7 @@ cpu5: cpu@5 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <5>; + reg = <0x5>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -431,7 +431,7 @@ cpu6: cpu@6 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <6>; + reg = <0x6>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -459,7 +459,7 @@ cpu7: cpu@7 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <7>; + reg = <0x7>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -487,7 +487,7 @@ cpu8: cpu@8 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <8>; + reg = <0x8>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -515,7 +515,7 @@ cpu9: cpu@9 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <9>; + reg = <0x9>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -533,7 +533,7 @@ cpu9_intc: interrupt-controller { }; }; - cpu10: cpu@10 { + cpu10: cpu@a { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -543,7 +543,7 @@ cpu10: cpu@10 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <10>; + reg = <0xa>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -561,7 +561,7 @@ cpu10_intc: interrupt-controller { }; }; - cpu11: cpu@11 { + cpu11: cpu@b { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -571,7 +571,7 @@ cpu11: cpu@11 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <11>; + reg = <0xb>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -589,7 +589,7 @@ cpu11_intc: interrupt-controller { }; }; - cpu12: cpu@12 { + cpu12: cpu@c { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -599,7 +599,7 @@ cpu12: cpu@12 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <12>; + reg = <0xc>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -617,7 +617,7 @@ cpu12_intc: interrupt-controller { }; }; - cpu13: cpu@13 { + cpu13: cpu@d { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -627,7 +627,7 @@ cpu13: cpu@13 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <13>; + reg = <0xd>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -645,7 +645,7 @@ cpu13_intc: interrupt-controller { }; }; - cpu14: cpu@14 { + cpu14: cpu@e { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -655,7 +655,7 @@ cpu14: cpu@14 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <14>; + reg = <0xe>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -673,7 +673,7 @@ cpu14_intc: interrupt-controller { }; }; - cpu15: cpu@15 { + cpu15: cpu@f { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -683,7 +683,7 @@ cpu15: cpu@15 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <15>; + reg = <0xf>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -701,7 +701,7 @@ cpu15_intc: interrupt-controller { }; }; - cpu16: cpu@16 { + cpu16: cpu@10 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -711,7 +711,7 @@ cpu16: cpu@16 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <16>; + reg = <0x10>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -729,7 +729,7 @@ cpu16_intc: interrupt-controller { }; }; - cpu17: cpu@17 { + cpu17: cpu@11 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -739,7 +739,7 @@ cpu17: cpu@17 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <17>; + reg = <0x11>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -757,7 +757,7 @@ cpu17_intc: interrupt-controller { }; }; - cpu18: cpu@18 { + cpu18: cpu@12 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -767,7 +767,7 @@ cpu18: cpu@18 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <18>; + reg = <0x12>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -785,7 +785,7 @@ cpu18_intc: interrupt-controller { }; }; - cpu19: cpu@19 { + cpu19: cpu@13 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -795,7 +795,7 @@ cpu19: cpu@19 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <19>; + reg = <0x13>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -813,7 +813,7 @@ cpu19_intc: interrupt-controller { }; }; - cpu20: cpu@20 { + cpu20: cpu@14 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -823,7 +823,7 @@ cpu20: cpu@20 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <20>; + reg = <0x14>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -841,7 +841,7 @@ cpu20_intc: interrupt-controller { }; }; - cpu21: cpu@21 { + cpu21: cpu@15 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -851,7 +851,7 @@ cpu21: cpu@21 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <21>; + reg = <0x15>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -869,7 +869,7 @@ cpu21_intc: interrupt-controller { }; }; - cpu22: cpu@22 { + cpu22: cpu@16 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -879,7 +879,7 @@ cpu22: cpu@22 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <22>; + reg = <0x16>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -897,7 +897,7 @@ cpu22_intc: interrupt-controller { }; }; - cpu23: cpu@23 { + cpu23: cpu@17 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -907,7 +907,7 @@ cpu23: cpu@23 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <23>; + reg = <0x17>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -925,7 +925,7 @@ cpu23_intc: interrupt-controller { }; }; - cpu24: cpu@24 { + cpu24: cpu@18 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -935,7 +935,7 @@ cpu24: cpu@24 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <24>; + reg = <0x18>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -953,7 +953,7 @@ cpu24_intc: interrupt-controller { }; }; - cpu25: cpu@25 { + cpu25: cpu@19 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -963,7 +963,7 @@ cpu25: cpu@25 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <25>; + reg = <0x19>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -981,7 +981,7 @@ cpu25_intc: interrupt-controller { }; }; - cpu26: cpu@26 { + cpu26: cpu@1a { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -991,7 +991,7 @@ cpu26: cpu@26 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <26>; + reg = <0x1a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1009,7 +1009,7 @@ cpu26_intc: interrupt-controller { }; }; - cpu27: cpu@27 { + cpu27: cpu@1b { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1019,7 +1019,7 @@ cpu27: cpu@27 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <27>; + reg = <0x1b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1037,7 +1037,7 @@ cpu27_intc: interrupt-controller { }; }; - cpu28: cpu@28 { + cpu28: cpu@1c { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1047,7 +1047,7 @@ cpu28: cpu@28 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <28>; + reg = <0x1c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1065,7 +1065,7 @@ cpu28_intc: interrupt-controller { }; }; - cpu29: cpu@29 { + cpu29: cpu@1d { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1075,7 +1075,7 @@ cpu29: cpu@29 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <29>; + reg = <0x1d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1093,7 +1093,7 @@ cpu29_intc: interrupt-controller { }; }; - cpu30: cpu@30 { + cpu30: cpu@1e { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1103,7 +1103,7 @@ cpu30: cpu@30 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <30>; + reg = <0x1e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1121,7 +1121,7 @@ cpu30_intc: interrupt-controller { }; }; - cpu31: cpu@31 { + cpu31: cpu@1f { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1131,7 +1131,7 @@ cpu31: cpu@31 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <31>; + reg = <0x1f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1149,7 +1149,7 @@ cpu31_intc: interrupt-controller { }; }; - cpu32: cpu@32 { + cpu32: cpu@20 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1159,7 +1159,7 @@ cpu32: cpu@32 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <32>; + reg = <0x20>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1177,7 +1177,7 @@ cpu32_intc: interrupt-controller { }; }; - cpu33: cpu@33 { + cpu33: cpu@21 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1187,7 +1187,7 @@ cpu33: cpu@33 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <33>; + reg = <0x21>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1205,7 +1205,7 @@ cpu33_intc: interrupt-controller { }; }; - cpu34: cpu@34 { + cpu34: cpu@22 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1215,7 +1215,7 @@ cpu34: cpu@34 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <34>; + reg = <0x22>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1233,7 +1233,7 @@ cpu34_intc: interrupt-controller { }; }; - cpu35: cpu@35 { + cpu35: cpu@23 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1243,7 +1243,7 @@ cpu35: cpu@35 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <35>; + reg = <0x23>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1261,7 +1261,7 @@ cpu35_intc: interrupt-controller { }; }; - cpu36: cpu@36 { + cpu36: cpu@24 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1271,7 +1271,7 @@ cpu36: cpu@36 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <36>; + reg = <0x24>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1289,7 +1289,7 @@ cpu36_intc: interrupt-controller { }; }; - cpu37: cpu@37 { + cpu37: cpu@25 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1299,7 +1299,7 @@ cpu37: cpu@37 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <37>; + reg = <0x25>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1317,7 +1317,7 @@ cpu37_intc: interrupt-controller { }; }; - cpu38: cpu@38 { + cpu38: cpu@26 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1327,7 +1327,7 @@ cpu38: cpu@38 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <38>; + reg = <0x26>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1345,7 +1345,7 @@ cpu38_intc: interrupt-controller { }; }; - cpu39: cpu@39 { + cpu39: cpu@27 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1355,7 +1355,7 @@ cpu39: cpu@39 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <39>; + reg = <0x27>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1373,7 +1373,7 @@ cpu39_intc: interrupt-controller { }; }; - cpu40: cpu@40 { + cpu40: cpu@28 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1383,7 +1383,7 @@ cpu40: cpu@40 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <40>; + reg = <0x28>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1401,7 +1401,7 @@ cpu40_intc: interrupt-controller { }; }; - cpu41: cpu@41 { + cpu41: cpu@29 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1411,7 +1411,7 @@ cpu41: cpu@41 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <41>; + reg = <0x29>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1429,7 +1429,7 @@ cpu41_intc: interrupt-controller { }; }; - cpu42: cpu@42 { + cpu42: cpu@2a { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1439,7 +1439,7 @@ cpu42: cpu@42 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <42>; + reg = <0x2a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1457,7 +1457,7 @@ cpu42_intc: interrupt-controller { }; }; - cpu43: cpu@43 { + cpu43: cpu@2b { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1467,7 +1467,7 @@ cpu43: cpu@43 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <43>; + reg = <0x2b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1485,7 +1485,7 @@ cpu43_intc: interrupt-controller { }; }; - cpu44: cpu@44 { + cpu44: cpu@2c { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1495,7 +1495,7 @@ cpu44: cpu@44 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <44>; + reg = <0x2c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1513,7 +1513,7 @@ cpu44_intc: interrupt-controller { }; }; - cpu45: cpu@45 { + cpu45: cpu@2d { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1523,7 +1523,7 @@ cpu45: cpu@45 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <45>; + reg = <0x2d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1541,7 +1541,7 @@ cpu45_intc: interrupt-controller { }; }; - cpu46: cpu@46 { + cpu46: cpu@2e { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1551,7 +1551,7 @@ cpu46: cpu@46 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <46>; + reg = <0x2e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1569,7 +1569,7 @@ cpu46_intc: interrupt-controller { }; }; - cpu47: cpu@47 { + cpu47: cpu@2f { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1579,7 +1579,7 @@ cpu47: cpu@47 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <47>; + reg = <0x2f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1597,7 +1597,7 @@ cpu47_intc: interrupt-controller { }; }; - cpu48: cpu@48 { + cpu48: cpu@30 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1607,7 +1607,7 @@ cpu48: cpu@48 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <48>; + reg = <0x30>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1625,7 +1625,7 @@ cpu48_intc: interrupt-controller { }; }; - cpu49: cpu@49 { + cpu49: cpu@31 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1635,7 +1635,7 @@ cpu49: cpu@49 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <49>; + reg = <0x31>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1653,7 +1653,7 @@ cpu49_intc: interrupt-controller { }; }; - cpu50: cpu@50 { + cpu50: cpu@32 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1663,7 +1663,7 @@ cpu50: cpu@50 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <50>; + reg = <0x32>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1681,7 +1681,7 @@ cpu50_intc: interrupt-controller { }; }; - cpu51: cpu@51 { + cpu51: cpu@33 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1691,7 +1691,7 @@ cpu51: cpu@51 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <51>; + reg = <0x33>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1709,7 +1709,7 @@ cpu51_intc: interrupt-controller { }; }; - cpu52: cpu@52 { + cpu52: cpu@34 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1719,7 +1719,7 @@ cpu52: cpu@52 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <52>; + reg = <0x34>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1737,7 +1737,7 @@ cpu52_intc: interrupt-controller { }; }; - cpu53: cpu@53 { + cpu53: cpu@35 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1747,7 +1747,7 @@ cpu53: cpu@53 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <53>; + reg = <0x35>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1765,7 +1765,7 @@ cpu53_intc: interrupt-controller { }; }; - cpu54: cpu@54 { + cpu54: cpu@36 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1775,7 +1775,7 @@ cpu54: cpu@54 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <54>; + reg = <0x36>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1793,7 +1793,7 @@ cpu54_intc: interrupt-controller { }; }; - cpu55: cpu@55 { + cpu55: cpu@37 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1803,7 +1803,7 @@ cpu55: cpu@55 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <55>; + reg = <0x37>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1821,7 +1821,7 @@ cpu55_intc: interrupt-controller { }; }; - cpu56: cpu@56 { + cpu56: cpu@38 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1831,7 +1831,7 @@ cpu56: cpu@56 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <56>; + reg = <0x38>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1849,7 +1849,7 @@ cpu56_intc: interrupt-controller { }; }; - cpu57: cpu@57 { + cpu57: cpu@39 { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1859,7 +1859,7 @@ cpu57: cpu@57 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <57>; + reg = <0x39>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1877,7 +1877,7 @@ cpu57_intc: interrupt-controller { }; }; - cpu58: cpu@58 { + cpu58: cpu@3a { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1887,7 +1887,7 @@ cpu58: cpu@58 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <58>; + reg = <0x3a>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1905,7 +1905,7 @@ cpu58_intc: interrupt-controller { }; }; - cpu59: cpu@59 { + cpu59: cpu@3b { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1915,7 +1915,7 @@ cpu59: cpu@59 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <59>; + reg = <0x3b>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1933,7 +1933,7 @@ cpu59_intc: interrupt-controller { }; }; - cpu60: cpu@60 { + cpu60: cpu@3c { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1943,7 +1943,7 @@ cpu60: cpu@60 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <60>; + reg = <0x3c>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1961,7 +1961,7 @@ cpu60_intc: interrupt-controller { }; }; - cpu61: cpu@61 { + cpu61: cpu@3d { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1971,7 +1971,7 @@ cpu61: cpu@61 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <61>; + reg = <0x3d>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -1989,7 +1989,7 @@ cpu61_intc: interrupt-controller { }; }; - cpu62: cpu@62 { + cpu62: cpu@3e { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -1999,7 +1999,7 @@ cpu62: cpu@62 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <62>; + reg = <0x3e>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
@@ -2017,7 +2017,7 @@ cpu62_intc: interrupt-controller { }; }; - cpu63: cpu@63 { + cpu63: cpu@3f { compatible = "thead,c920", "riscv"; device_type = "cpu"; riscv,isa = "rv64imafdc";
@@ -2027,7 +2027,7 @@ cpu63: cpu@63 { "zifencei", "zihpm", "zfh", "xtheadvector"; thead,vlenb = <16>; - reg = <63>; + reg = <0x3f>; i-cache-block-size = <64>; i-cache-size = <65536>; i-cache-sets = <512>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/2077 configfs_lookup(): dont leave ->s_dentry dangling on failure
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 10da12d352b7b2bb330a8609fdda9a58bf0e9856 ]
Normally ->s_dentry is cleared when dentry it's pointing to becomes negative (on eviction, realistically). However, that only happens if dentry gets to be positive in the first place; in case of inode allocation failure dentry never becomes positive, so ->d_iput() is not called at all.
We do part of what normally would've been done by configfs_d_iput() (dropping the reference to configfs_dirent) manually, but we do not clear ->s_dentry there. Sloppy as it is, it does not matter in case of configfs_create_{dir,link}() - there configfs_dirent does not survive dropping the sole reference to it.
However, for configfs_lookup() it *does* survive, with a dangling pointer to soon to be freed dentry sitting it its ->s_dentry.
Subsequent getdents(2) in that directory will end up dereferencing that pointer in order to pick the inode number. Use after free...
This is the minimal fix; the right approach is to set the linkage between dentry and configfs_dirent only after we know that we have an inode, but that takes more surgery and the bug had been there since 2006, so...
--- fs/configfs/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/configfs/dir.c +3 -0
@@ -486,6 +486,9 @@ static struct dentry * configfs_lookup(struct inode *dir, inode =configfs_create (dentry, mode);if (IS_ERR (inode)) { +spin_lock (&configfs_dirent_lock); + sd->s_dentry =NULL ; +spin_unlock (&configfs_dirent_lock);configfs_put (sd);return ERR_CAST (inode); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/2077 lockdep/selftests: Restore migrate_disable() state on PREEMPT_RT
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit d8c897b20bf4d4cbb1e935a8ceb666bcc0f82580 ]
The lockdep selftests deliberately run unbalanced locking patterns. dotest() restores the task state they leave behind before running the next testcase.
On PREEMPT_RT, spin_lock() uses migrate_disable() instead of disabling preemption. dotest() cleans up the resulting migration-disabled state, but that cleanup is still guarded by CONFIG_SMP.
That used to match the scheduler data model, where migration_disabled was also CONFIG_SMP-only. The commit referenced below made SMP scheduler state unconditional, so CONFIG_SMP=n PREEMPT_RT kernels with CONFIG_DEBUG_LOCKING_API_SELFTESTS=y report success from the selftests and then trip over stale current->migration_disabled state:
releasing a pinned lock
bad: scheduling from the idle thread!
Kernel panic - not syncing: Fatal exception
Save and restore current->migration_disabled for every PREEMPT_RT build.
--- lib/locking-selftest.c | 4 ---- 1 file changed, 4 deletions(-)
lib/locking-selftest.c +0 -4
@@ -1431,9 +1431,7 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) {int saved_preempt_count =preempt_count ();#ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP int saved_mgd_count = current->migration_disabled; -#endif int saved_rcu_count = current->rcu_read_lock_nesting;#endif
@@ -1471,10 +1469,8 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)preempt_count_set (saved_preempt_count);#ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP while (current->migration_disabled > saved_mgd_count)migrate_enable (); -#endif while (current->rcu_read_lock_nesting > saved_rcu_count)rcu_read_unlock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/2077 lockdep/selftests: Restore sched_rt_mutex state on PREEMPT_RT
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 06961d60a0e410bf8df69ccff7eb1bd824912b8f ]
The WW-mutex selftests deliberately exercise failing lock paths. On PREEMPT_RT, some of those paths enter the RT-mutex scheduler helpers.
The change referenced by the Fixes tag made those helpers track RT-mutex scheduling state in current->sched_rt_mutex. The bit is normally cleared by the matching post-schedule helper, but some WW-mutex selftests disable the runtime debug_locks flag before that happens. With debug_locks cleared, lockdep_assert() does not evaluate the expression that clears the bit, leaving stale state for the next testcase.
With CONFIG_PREEMPT_RT=y and CONFIG_DEBUG_LOCKING_API_SELFTESTS=y, that stale state produces warnings such as:
WARNING: kernel/sched/core.c:7557 at rt_mutex_pre_schedule+0x26/0x2d RIP: 0010:rt_mutex_pre_schedule+0x26/0x2d
Save and restore current->sched_rt_mutex around each testcase, matching the existing PREEMPT_RT cleanup for task-local migration and RCU state.
--- lib/locking-selftest.c | 3 +++ 1 file changed, 3 insertions(+)
lib/locking-selftest.c +3 -0
@@ -1433,6 +1433,7 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)#ifdef CONFIG_PREEMPT_RT int saved_mgd_count = current->migration_disabled;int saved_rcu_count = current->rcu_read_lock_nesting; +int saved_sched_rt_mutex = current->sched_rt_mutex;#endif WARN_ON (irqs_disabled ());
@@ -1469,6 +1470,8 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)preempt_count_set (saved_preempt_count);#ifdef CONFIG_PREEMPT_RT + current->sched_rt_mutex = saved_sched_rt_mutex; +while (current->migration_disabled > saved_mgd_count)migrate_enable ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/2077 ext4: fix fast commit wait/wake bit mapping on 64-bit
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Chen <[email protected]>
[ Upstream commit 8b3bc93fee6771775243665a0cf31857d6659775 ]
On 64-bit, ext4 dynamic inode states live in the upper half of i_flags, and ext4_test_inode_state() applies the corresponding +32 offset.
The fast-commit wait and wake paths open-coded the wait key with the raw EXT4_STATE_* value. Add small helpers for the state wait word and bit, and use them for the FC_COMMITTING and FC_FLUSHING_DATA waits so the wait key follows the same mapping as the state helpers.
--- fs/ext4/ext4.h | 20 +++++++++++++++++ fs/ext4/fast_commit.c | 50 ++++++++++++++++--------------------------- 2 files changed, 38 insertions(+), 32 deletions(-)
fs/ext4/ext4.h +20 -0
@@ -2000,6 +2000,8 @@ EXT4_INODE_BIT_FNS(flag, flags, 0)static inline int ext4_test_inode_state (struct inode *inode,int bit);static inline void ext4_set_inode_state (struct inode *inode,int bit);static inline void ext4_clear_inode_state (struct inode *inode,int bit); +static inline unsigned long *ext4_inode_state_wait_word (struct inode *inode); +static inline int ext4_inode_state_wait_bit (int bit);#if (BITS_PER_LONG <64 )EXT4_INODE_BIT_FNS (state, state_flags,0 )
@@ -2015,6 +2017,24 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) /* We depend on the fact that callers will set i_flags */ }#endif + +static inline unsigned long *ext4_inode_state_wait_word (struct inode *inode) +{ +#if (BITS_PER_LONG <64 ) +return &EXT4_I (inode)->i_state_flags; +#else +return &EXT4_I (inode)->i_flags; +#endif +} + +static inline int ext4_inode_state_wait_bit (int bit) +{ +#if (BITS_PER_LONG <64 ) +return bit; +#else +return bit +32 ; +#endif +}#else /* Assume that user mode programs are passing in an ext4fs superblock, not * a kernel struct super_block. This will allow us to call the feature-test
fs/ext4/fast_commit.c +18 -32
98 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/2077 irqchip/exynos-combiner: Remove useless spinlock
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 6fe450074626eaab3def4b3e8c1819d46d2d682c ]
irq_controller_lock doesn't protect anything, it is a leftover from early development or copy/paste. Remove it completely.
--- drivers/irqchip/exynos-combiner.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/irqchip/exynos-combiner.c +0 -4
@@ -24,8 +24,6 @@#define IRQ_IN_COMBINER 8 -static DEFINE_RAW_SPINLOCK (irq_controller_lock); -struct combiner_chip_data {unsigned int hwirq_offset;unsigned int irq_mask;
@@ -72,9 +70,7 @@ static void combiner_handle_cascade_irq(struct irq_desc *desc)chained_irq_enter (chip, desc); -raw_spin_lock (&irq_controller_lock); status =readl_relaxed (chip_data->base +COMBINER_INT_STATUS ); -raw_spin_unlock (&irq_controller_lock); status &= chip_data->irq_mask;if (status ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/2077 drm/amdgpu: fix KASAN slab-out-of-bounds in amdgpu_coredump ring dump
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Prosyak <[email protected]>
[ Upstream commit 08ac3a7879d300302a1927ce2038629539a37f8b ]
The ring content dump in amdgpu_coredump() uses two separate loops over adev->rings[]: the first counts rings with unsignalled fences to size the allocation, and the second copies ring data into the allocated buffers.
Both loops use the same condition to skip rings:
atomic_read(&ring->fence_drv.last_seq) == ring->fence_drv.sync_seq
Because last_seq is an atomic that is updated concurrently by the fence signalling path, additional rings may appear unsignalled in the second loop that were signalled during the first. When this happens, idx exceeds the allocated ring_count and the store to coredump->rings[idx] writes past the end of the kcalloc-ed buffer.
This was found during IGT stressful test amd_queue_reset which triggers random GPU resets. The OVERSIZE subtest (CMD_STREAM_EXEC_INVALID_PACKET_LENGTH_OVERSIZE on GFX ring) provokes a ring timeout and subsequent coredump, which hits the race between the counting and copying loops. The failure is non-deterministic and depends on fence signalling timing during the reset.
KASAN log:
BUG: KASAN: slab-out-of-bounds in amdgpu_coredump+0x1274/0x12f0 [amdgpu] Write of size 4 at addr ffff888106154258 by task kworker/u128:5/23625 CPU: 16 UID: 0 PID: 23625 Comm: kworker/u128:5 Not tainted 6.19.0+ #35 Workqueue: amdgpu-reset-dev drm_sched_job_timedout [gpu_sched] Call Trace: <TASK> dump_stack_lvl+0xa5/0x110 print_report+0xd1/0x660 kasan_report+0xf3/0x130 __asan_report_store4_noabort+0x17/0x30 amdgpu_coredump+0x1274/0x12f0 [amdgpu] amdgpu_job_timedout+0xef0/0x16c0 [amdgpu] drm_sched_job_timedout+0x194/0x5c0 [gpu_sched] process_one_work+0x84b/0x1990 worker_thread+0x6b8/0x11b0 </TASK> Allocated by task 23625: kasan_save_stack+0x39/0x70 __kasan_kmalloc+0xc3/0xd0 __kmalloc_noprof+0x2ec/0x910 amdgpu_coredump+0x5c5/0x12f0 [amdgpu] amdgpu_job_timedout+0xef0/0x16c0 [amdgpu] The buggy address belongs to the object at ffff888106154200 which belongs to the cache kmalloc-rnd-09-96 of size 96 The buggy address is located 16 bytes to the right of allocated 72-byte region [ffff888106154200, ffff888106154248)
72 bytes = 3 * sizeof(struct amdgpu_coredump_ring), so ring_count was 3 but idx reached 3+, writing ring_index (at struct offset 16) 16 bytes past the allocation.
Fix by adding an idx < ring_count guard to the copy loop so it cannot exceed the allocated count even when the fence state changes between the two passes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +1 -1
@@ -553,7 +553,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, coredump->rings_dw =kzalloc (total_ring_size,GFP_NOWAIT ); coredump->rings =kcalloc (ring_count,sizeof (struct amdgpu_coredump_ring ),GFP_NOWAIT );if (coredump->rings && coredump->rings_dw) { -for (i =0 , off =0 , idx =0 ; i < adev->num_rings; i++) { +for (i =0 , off =0 , idx =0 ; i < adev->num_rings && idx < ring_count; i++) { ring = adev->rings[i]; if (atomic_read(&ring->fence_drv.last_seq) == ring->fence_drv.sync_seq &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/2077 drm/amd/pm: Add empty string validation to sysfs store functions
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Prosyak <[email protected]>
[ Upstream commit c872fc05380c4eb2761ab289ce6a215c9bfa9576 ]
Discovery: Fuzzing for secure supply chain requirements
Tool: amd_fuzzing_sysfs (IGT test)
The AMDGPU power management sysfs store functions accept whitespace-only strings when they should reject them with -EINVAL. This was discovered via systematic fuzzing of sysfs interfaces crossing the user/kernel trust boundary.
Affected functions:
- amdgpu_set_power_dpm_force_performance_level (power_dpm_force_performance_level)
- amdgpu_set_power_dpm_state (power_dpm_state)
- amdgpu_set_pp_power_profile_mode (pp_power_profile_mode)
- amdgpu_read_mask (used by pp_dpm_sclk/mclk/fclk/socclk/pcie)
- amdgpu_set_pp_features (pp_features)
Impact:
- Whitespace-only writes (e.g., "\n", " ") can cause unexpected behavior
- Better input validation at user/kernel trust boundary
- Defense-in-depth improvement
Root Cause:
The sysfs_streq() function matches whitespace-only strings against empty string, allowing invalid input to be processed.
Fix:
Add explicit validation at the start of each affected store function:
if (count == 0 || sysfs_streq(buf, ""))
return -EINVAL;This rejects whitespace-only inputs before they are processed. Note that write() calls with count=0 (truly empty strings) are handled by the VFS layer before reaching the sysfs .store() callback - the VFS returns 0 (success) without calling the kernel function. This is POSIX-compliant behavior and cannot be changed at the kernel driver level.
What This Patch Fixes:
- Whitespace-only strings: "\n", " ", " ", etc. are now rejected
- Defense-in-depth: Explicit validation at trust boundary
- Code clarity: Intent to reject invalid input is explicit
What This Patch Cannot Fix:
- write(fd, "", 0) returning success - this is VFS layer behavior
- Fuzzer tests for empty strings (count=0) will still report "accepted" because the VFS handles this before the kernel callback
Test Results After Fix:
- Whitespace strings ("\n", " ") now properly rejected
- Empty string tests (count=0) still show as "accepted" due to VFS behavior
- Overall improvement in input validation robustness
- No impact on valid inputs
This is a defense-in-depth improvement that hardens input validation even though VFS layer behavior prevents catching all edge cases.
Tested: amd_fuzzing_sysfs IGT test
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +20 -0
@@ -244,6 +244,10 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,enum amd_pm_state_type state;int ret; +/* Reject empty/whitespace strings - fuzzing found this is not validated */ +if (count ==0 ||sysfs_streq (buf,"" )) +return -EINVAL ; +if (sysfs_streq (buf,"battery" )) state =POWER_STATE_TYPE_BATTERY ;else if (sysfs_streq (buf,"balanced" ))
@@ -364,6 +368,10 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,enum amd_dpm_forced_level level;int ret =0 ; +/* Reject empty/whitespace strings - fuzzing found this is not validated */ +if (count ==0 ||sysfs_streq (buf,"" )) +return -EINVAL ; +if (sysfs_streq (buf,"low" )) level =AMD_DPM_FORCED_LEVEL_LOW ;else if (sysfs_streq (buf,"high" ))
@@ -902,6 +910,10 @@ static ssize_t amdgpu_set_pp_features(struct device *dev,uint64_t featuremask;int ret; +/* Reject empty/whitespace strings - fuzzing found kstrtou64 accepts "" as 0 */ +if (count ==0 ||sysfs_streq (buf,"" )) +return -EINVAL ; + ret =kstrtou64 (buf,0 , &featuremask);if (ret)return -EINVAL ;
@@ -1027,6 +1039,10 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask) *mask =0 ; +/* Reject empty/whitespace strings - fuzzing found this is not validated */ +if (count ==0 ||sysfs_streq (buf,"" )) +return -EINVAL ; + bytes =min (count,sizeof (buf_cpy) -1 );memcpy (buf_cpy, buf, bytes); buf_cpy[bytes] ='\0' ;
@@ -1378,6 +1394,10 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,long int profile_mode =0 ;const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; +/* Reject empty/whitespace strings - fuzzing found this is not validated */ +if (count ==0 ||sysfs_streq (buf,"" )) +return -EINVAL ; + tmp[0 ] = *(buf); tmp[1 ] ='\0' ; ret =kstrtol (tmp,0 , &profile_mode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/2077 drm/amdgpu: set sub_block_index for mca ras sub-blocks
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunxiang Li <[email protected]>
[ Upstream commit baa286df5fb366e4aee5b747443dfc7194fdaa59 ]
The mca ras sub-blocks (mp0, mp1, mpio) all share the AMDGPU_RAS_BLOCK__MCA block id and are distinguished only by sub_block_index. The ras manager object for an mca block is selected with:
con->objs[AMDGPU_RAS_BLOCK__LAST + head->sub_block_index]
Since the rework in commit 7f544c5488cf ("drm/amdgpu: Rework mca ras sw_init") moved the ras_comm setup into amdgpu_mca_mp*_ras_sw_init() but left sub_block_index unset, mp0/mp1/mpio all default to index 0 and collide on the same object slot. mp0 grabs the slot and creates its sysfs node first; mp1 (and mpio) then find the slot already in use, so amdgpu_ras_block_late_init() -> amdgpu_ras_sysfs_create() returns -EINVAL:
amdgpu: mca.mp1 failed to execute ras_block_late_init_default! ret:-22
amdgpu: amdgpu_ras_late_init failed -22
amdgpu: amdgpu_device_ip_late_init failed
amdgpu: Fatal error during GPU init
The error is currently masked because amdgpu_ras_late_init() does not check the return value of amdgpu_ras_block_late_init_default(), but it already leaves mp1/mpio without their sysfs nodes and becomes a fatal init failure as soon as that return value is honored.
Restore the per-sub-block sub_block_index assignment so each mca sub-block maps to its own object slot.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c +3 -0
@@ -99,6 +99,7 @@ int amdgpu_mca_mp0_ras_sw_init(struct amdgpu_device *adev)strcpy (ras->ras_block.ras_comm.name,"mca.mp0" ); ras->ras_block.ras_comm.block =AMDGPU_RAS_BLOCK__MCA ; + ras->ras_block.ras_comm.sub_block_index =AMDGPU_RAS_MCA_BLOCK__MP0 ; ras->ras_block.ras_comm.type =AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE ; adev->mca.mp0.ras_if = &ras->ras_block.ras_comm;
@@ -123,6 +124,7 @@ int amdgpu_mca_mp1_ras_sw_init(struct amdgpu_device *adev)strcpy (ras->ras_block.ras_comm.name,"mca.mp1" ); ras->ras_block.ras_comm.block =AMDGPU_RAS_BLOCK__MCA ; + ras->ras_block.ras_comm.sub_block_index =AMDGPU_RAS_MCA_BLOCK__MP1 ; ras->ras_block.ras_comm.type =AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE ; adev->mca.mp1.ras_if = &ras->ras_block.ras_comm;
@@ -147,6 +149,7 @@ int amdgpu_mca_mpio_ras_sw_init(struct amdgpu_device *adev)strcpy (ras->ras_block.ras_comm.name,"mca.mpio" ); ras->ras_block.ras_comm.block =AMDGPU_RAS_BLOCK__MCA ; + ras->ras_block.ras_comm.sub_block_index =AMDGPU_RAS_MCA_BLOCK__MPIO ; ras->ras_block.ras_comm.type =AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE ; adev->mca.mpio.ras_if = &ras->ras_block.ras_comm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/2077 accel/amdxdna: Return errors for failed debug BO commands
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 62c1671f6454ceaa80e9ceff63f821aa36f35154 ]
The config and sync debug BO commands currently may report success even when the operation fails.
Capture the firmware return status and propagate the corresponding error to userspace.
--- drivers/accel/amdxdna/aie2_ctx.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +5 -8
@@ -270,17 +270,13 @@ aie2_sched_drvcmd_resp_handler(void *handle, void __iomem *data, size_t size)struct amdxdna_sched_job *job = handle;int ret =0 ; -if (unlikely (!data)) - goto out; - -if (unlikely (size !=sizeof (u32))) { +if (unlikely (!data || size !=sizeof (u32))) { + job->drv_cmd->result =U32_MAX ; ret = -EINVAL ; - goto out; + }else { + job->drv_cmd->result =readl (data); } - job->drv_cmd->result =readl (data); - -out:aie2_sched_notify (job);return ret; }
@@ -894,6 +890,7 @@ static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx *hwctx, u32 bo_hdl,aie2_cmd_wait (hwctx, seq);if (cmd.result) {XDNA_ERR (xdna,"Response failure 0x%x" , cmd.result); + ret = -EINVAL ; goto put_obj; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/2077 bpftool: Use libbpf error code for flow dissector query
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Woojin Ji <[email protected]>
[ Upstream commit 8a7f2bff2165e53595d1e91c160b340f978c0ab7 ]
bpf_prog_query() returns a negative errno on failure. query_flow_dissector() currently closes the namespace fd and then reads errno to decide whether -EINVAL means that the running kernel does not support flow dissector queries.
That errno check controls behavior, not just diagnostics: -EINVAL is handled as a non-fatal old-kernel case, while any other error makes bpftool net fail.
The namespace fd is opened read-only, so close() is not expected to commonly fail in normal use. Still, the BPF_PROG_QUERY error is already available in err, and reading errno after an intervening close() is fragile. If close() does change errno, the compatibility branch may be based on close()'s error instead of the BPF_PROG_QUERY result.
This was reproduced with an LD_PRELOAD fault injector that forced BPF_PROG_QUERY for BPF_FLOW_DISSECTOR to fail with EINVAL and then forced close() on the netns fd to fail with EIO. The unpatched bpftool reported "can't query prog: Input/output error". With this change, the same injected failure is handled as the intended non-fatal EINVAL compatibility case.
Use the libbpf-returned error code instead. Keep the existing errno reset in the non-fatal path to preserve batch mode behavior. The success path is unchanged.
--- tools/bpf/bpftool/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/bpf/bpftool/net.c +2 -2
@@ -603,14 +603,14 @@ static int query_flow_dissector(struct bpf_attach_info *attach_info) &attach_flags, prog_ids, &prog_cnt);close (fd);if (err) { -if (errno ==EINVAL ) { +if (err == -EINVAL ) {/* Older kernel's don't support querying * flow dissector programs. */ errno =0 ;return 0 ; } -p_err ("can't query prog: %s" ,strerror (errno)); +p_err ("can't query prog: %s" ,strerror (-err));return -1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/2077 vhost: fix vhost_get_avail_idx for a non empty ring
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <[email protected]>
[ Upstream commit 09861858a68342f851f71c669ac0f69865c32151 ]
vhost_get_avail_idx is supposed to report whether it has updated vq->avail_idx. Instead, it returns whether all entries have been consumed, which is usually the same. But not always - in drivers/vhost/net.c and when mergeable buffers have been enabled, the driver checks whether the combined entries are big enough to store an incoming packet. If not, the driver re-enables notifications with available entries still in the ring. The incorrect return value from vhost_get_avail_idx propagates through vhost_enable_notify and causes the host to livelock if the guest is not making progress, as vhost will immediately disable notifications and retry using the available entries.
This goes back to commit d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()") which changed vhost_enable_notify() to compare the freshly read avail index against vq->last_avail_idx instead of the previously cached vq->avail_idx. Commit 7ad472397667 ("vhost: move smp_rmb() into vhost_get_avail_idx()") then carried over the same comparison when refactoring vhost_enable_notify() to call the unified vhost_get_avail_idx().
The obvious fix is to make vhost_get_avail_idx do what the comment says it does and report whether new entries have been added.
Message-Id: <559b04ae6ce52973c535dc47e461638b7f4c3d63.1772441455.git.mst@redhat.com>
--- drivers/vhost/vhost.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/vhost/vhost.c +7 -4
@@ -1522,6 +1522,7 @@ static void vhost_dev_unlock_vqs(struct vhost_dev *d)static inline int vhost_get_avail_idx (struct vhost_virtqueue *vq) {__virtio16 idx; +u16 avail_idx;int r; r =vhost_get_avail (vq, idx, &vq->avail->idx);
@@ -1532,17 +1533,19 @@ static inline int vhost_get_avail_idx(struct vhost_virtqueue *vq) }/* Check it isn't doing very strange thing with available indexes */ - vq->avail_idx =vhost16_to_cpu (vq, idx); -if (unlikely ((u16)(vq->avail_idx - vq->last_avail_idx) > vq->num)) { + avail_idx =vhost16_to_cpu (vq, idx); +if (unlikely ((u16)(avail_idx - vq->last_avail_idx) > vq->num)) {vq_err (vq,"Invalid available index change from %u to %u" , - vq->last_avail_idx, vq->avail_idx); + vq->last_avail_idx, avail_idx);return -EINVAL ; }/* We're done if there is nothing new */ -if (vq->avail_idx == vq->last_avail_idx) +if (avail_idx == vq->avail_idx)return 0 ; + vq->avail_idx = avail_idx; +/* * We updated vq->avail_idx so we need a memory barrier between * the index read above and the caller reading avail ring entries.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/2077 iommu/vt-d: Fix RB-tree corruption in probe error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pranjal Shrivastava <[email protected]>
[ Upstream commit 43bd9e6d5513cb1edbafdeef146a1edc3aaced56 ]
The info->node RB-tree member is zero-initialized via kzalloc. If a device does not support ATS, the device_rbtree_insert() call is skipped. If a subsequent probe step fails, the error path jumps to device_rbtree_remove(), which misinterprets the zeroed node as a tree root and corrupts the device RB-tree.
Fix this by explicitly initializing the RB-node as empty using RB_CLEAR_NODE() during initialization and guarding the removal with RB_EMPTY_NODE().
--- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +5 -1
@@ -157,7 +157,10 @@ static void device_rbtree_remove(struct device_domain_info *info)unsigned long flags;spin_lock_irqsave (&iommu->device_rbtree_lock, flags); -rb_erase (&info->node, &iommu->device_rbtree); +if (!RB_EMPTY_NODE (&info->node)) { +rb_erase (&info->node, &iommu->device_rbtree); +RB_CLEAR_NODE (&info->node); + }spin_unlock_irqrestore (&iommu->device_rbtree_lock, flags); }
@@ -3254,6 +3257,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) info->dev = dev; info->iommu = iommu; +RB_CLEAR_NODE (&info->node);if (dev_is_pci (dev)) { if (ecap_dev_iotlb_support(iommu->ecap) && pci_ats_supported(pdev) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/2077 mm: preserve PG_dropbehind flag during folio split
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 0ad186cf167fdbeb6b29a8005c71973781036bd3 ]
__split_folio_to_order() copies page flags from the original folio to newly created sub-folios using an explicit allowlist, but PG_dropbehind is not included. When a large folio with PG_dropbehind set is split, only the head sub-folio retains the flag; all tail sub-folios silently lose it and will not be reclaimed eagerly after writeback completes.
Add PG_dropbehind to the flag copy mask so that the drop-behind hint is preserved across folio splits.
--- mm/huge_memory.c | 1 + 1 file changed, 1 insertion(+)
mm/huge_memory.c +1 -0
@@ -3644,6 +3644,7 @@ static void __split_folio_to_order(struct folio *folio, int old_order, (1L << PG_arch_3) | #endif (1L << PG_dirty) | + (1L << PG_dropbehind) | LRU_GEN_MASK | LRU_REFS_MASK)); if (handle_hwpoison &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/2077 eventpoll: rename attach_epitem() to ep_attach_file()
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 6a3f1a494bc91d7976cf0d2b200bb3f1a22eef64 ]
ep_remove_file() tears down the f_ep linkage that attach_epitem() establishes, so the pair should look like one. Rename to ep_attach_file() for the "ep_*" + subject symmetry and to match the naming used elsewhere in the file (ep_insert, ep_modify, ep_remove, ep_remove_file, ep_remove_epi, ep_unregister_pollwait).
Pure rename; no functional change.
Stable-dep-of: 0c4aefe3c2d0 ("eventpoll: Fix epoll_wait() report false negative")
--- fs/eventpoll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/eventpoll.c +2 -2
@@ -1526,7 +1526,7 @@ static noinline void ep_destroy_wakeup_source(struct epitem *epi)wakeup_source_unregister (ws); } -static int attach_epitem (struct file *file,struct epitem *epi) +static int ep_attach_file (struct file *file,struct epitem *epi) {struct epitems_head *to_free =NULL ;struct hlist_head *head =NULL ;
@@ -1597,7 +1597,7 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,if (tep)mutex_lock_nested (&tep->mtx,1 );/* Add the current item to the list of active epoll hook for this file */ -if (unlikely (attach_epitem (tfile, epi) <0 )) { +if (unlikely (ep_attach_file (tfile, epi) <0 )) {if (tep)mutex_unlock (&tep->mtx);kmem_cache_free (epi_cache, epi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/2077 eventpoll: split ep_insert() into alloc + register stages
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 e0e35f4cb983a55a36e79e9b2a20ca0e0688fae6 ]
ep_insert() was 130 lines and mixed four concerns in one body: user quota charge and epitem allocation, attach-into-file-hlist plus rbtree insert plus target-ep locking, reverse-path + EPOLLWAKEUP + poll-queue install with rollback, and ready-list publication. Factor the first two concerns into named helpers so the body reduces to orchestration.
ep_alloc_epitem() charges the user's epoll_watches quota, allocates a fresh epitem, and initializes its fields. On failure it returns ERR_PTR(-ENOSPC) or ERR_PTR(-ENOMEM); on success the epi is not yet linked into anything.
ep_register_epitem() installs @epi into @tfile's f_ep hlist and @ep's rbtree, optionally chains @tfile onto tfile_check_list for the path check, takes the tep->mtx nested lock for the epoll-watches- epoll case, and finally takes the ep_get() reference that pairs with ep_remove()'s ep_put() in ep_insert()'s error paths. On failure it frees the epi and decrements epoll_watches to match ep_alloc_epitem().
ep_insert()'s remaining body is the rollback-via-ep_remove() chain (reverse_path_check, EPOLLWAKEUP source creation, ep_ptable_queue_proc allocation) and the ready-list / wake publication. Remove a few stale comments that duplicated function-level documentation or described obvious code.
No functional change; rollback boundaries unchanged -- every error path after ep_register_epitem() still calls ep_remove(), preserving the ep->refcount invariant that keeps ep_remove()'s WARN_ON_ONCE safe.
Stable-dep-of: 0c4aefe3c2d0 ("eventpoll: Fix epoll_wait() report false negative")
--- fs/eventpoll.c | 111 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 37 deletions(-)
fs/eventpoll.c +74 -37
@@ -1561,68 +1561,112 @@ static int ep_attach_file(struct file *file, struct epitem *epi) }/* -* Must be called with "mtx" held. +* Charge the user's epoll_watches quota, allocate a fresh epitem for +* @tfile/@fd, and initialize its fields. The returned item is not yet +* linked into any data structure; the caller must install it via +* ep_register_epitem() (which takes over on success) or kmem_cache_free() +* it and decrement epoll_watches on its own. +* +* Returns ERR_PTR(-ENOSPC) if the quota is exceeded, ERR_PTR(-ENOMEM) +* if the slab allocation fails. */ -static int ep_insert (struct eventpoll *ep,const struct epoll_event *event, -struct file *tfile,int fd,int full_check) +static struct epitem *ep_alloc_epitem (struct eventpoll *ep, +const struct epoll_event *event, +struct file *tfile,int fd) { -int error, pwake =0 ; -__poll_t revents;struct epitem *epi; -struct ep_pqueue epq; -struct eventpoll *tep =NULL ; - -if (is_file_epoll (tfile)) - tep = tfile->private_data; - -lockdep_assert_irqs_enabled ();if (unlikely (percpu_counter_compare (&ep->user->epoll_watches, max_user_watches) >=0 )) -return -ENOSPC ; +return ERR_PTR (-ENOSPC );percpu_counter_inc (&ep->user->epoll_watches); -if (!(epi =kmem_cache_zalloc (epi_cache,GFP_KERNEL ))) { + epi =kmem_cache_zalloc (epi_cache,GFP_KERNEL ); +if (unlikely (!epi)) {percpu_counter_dec (&ep->user->epoll_watches); -return -ENOMEM ; +return ERR_PTR (-ENOMEM ); } -/* Item initialization follow here ... */ INIT_LIST_HEAD (&epi->rdllink); epi->ep = ep;ep_set_ffd (&epi->ffd, tfile, fd); epi->event = *event; epi->next =EP_UNACTIVE_PTR ; +return epi; +} + +/* +* Install @epi into its target file's f_ep hlist and into @ep's rbtree, +* taking one additional reference on @ep for the lifetime of the item. +* +* If @tep is non-NULL, the target file is itself an eventpoll; we hold +* tep->mtx at subclass 1 across the attach + rbtree insert to serialize +* with the target side. RB tree ops are protected by @ep->mtx, which +* the caller already holds. +* +* On failure the epi is freed and the epoll_watches counter decremented, +* matching ep_alloc_epitem()'s allocation. After this returns +* successfully, ep_insert()'s later error paths use ep_remove() for +* unwind; that cannot drop @ep's refcount to zero because the ep file +* itself still holds the original reference. +*/ +static int ep_register_epitem (struct eventpoll *ep,struct epitem *epi, +struct eventpoll *tep,int full_check) +{ +struct file *tfile = epi->ffd.file; +int error; +if (tep)mutex_lock_nested (&tep->mtx,1 ); -/* Add the current item to the list of active epoll hook for this file */ -if (unlikely (ep_attach_file (tfile, epi) <0 )) { + + error =ep_attach_file (tfile, epi); +if (unlikely (error)) {if (tep)mutex_unlock (&tep->mtx);kmem_cache_free (epi_cache, epi);percpu_counter_dec (&ep->user->epoll_watches); -return -ENOMEM ; +return error; }if (full_check && !tep)list_file (tfile); -/* -* Add the current item to the RB tree. All RB tree operations are -* protected by "mtx", and ep_insert() is called with "mtx" held. -*/ ep_rbtree_insert (ep, epi); +if (tep)mutex_unlock (&tep->mtx); -/* -* ep_remove() calls in the later error paths can't lead to -* ep_free() as the ep file itself still holds an ep reference. -*/ ep_get (ep); +return 0 ; +} + +/* +* Must be called with "mtx" held. +*/ +static int ep_insert (struct eventpoll *ep,const struct epoll_event *event, +struct file *tfile,int fd,int full_check) +{ +int error, pwake =0 ; +__poll_t revents; +struct epitem *epi; +struct ep_pqueue epq; +struct eventpoll *tep =NULL ; + +if (is_file_epoll (tfile)) + tep = tfile->private_data; + +lockdep_assert_irqs_enabled (); + + epi =ep_alloc_epitem (ep, event, tfile, fd); +if (IS_ERR (epi)) +return PTR_ERR (epi); -/* now check if we've created too many backpaths */ + error =ep_register_epitem (ep, epi, tep, full_check); +if (error) +return error; + +/* Reject the insert if the new link would create too many back-paths. */ if (unlikely (full_check &&reverse_path_check ())) {ep_remove (ep, epi);return -EINVAL ;
@@ -1649,28 +1693,21 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,*/ revents =ep_item_poll (epi, &epq.pt,1 ); -/* -* We have to check if something went wrong during the poll wait queue -* install process. Namely an allocation for a wait queue failed due -* high memory pressure. -*/ +/* ep_ptable_queue_proc() signals allocation failure by clearing epq.epi. */ if (unlikely (!epq.epi)) {ep_remove (ep, epi);return -ENOMEM ; } -/* We have to drop the new item inside our item list to keep track of it */ +/* Drop the new item onto the ready list if it is already ready. */ spin_lock_irq (&ep->lock); -/* record NAPI ID of new item if present */ ep_set_busy_poll_napi_id (epi); -/* If the file is already "ready" we drop it inside the ready list */ if (revents && !ep_is_linked (epi)) {list_add_tail (&epi->rdllink, &ep->rdllist);ep_pm_stay_awake (epi); -/* Notify waiting tasks that events are available */ if (waitqueue_active (&ep->wq))wake_up (&ep->wq);if (waitqueue_active (&ep->poll_wait))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/2077 eventpoll: extract ep_deliver_event() from ep_send_events()
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 499a5e7f4a57fa08a297c627d007a55069acac9a ]
ep_send_events()'s body covered two concerns: per-item work (PM wakeup-source bookkeeping, re-poll, copy_to_user, level-trigger re-queue, EPOLLONESHOT mask clear) and the scan-level accumulator (maxevents cap, EFAULT preservation, txlist/rdllist splice).
Extract the per-item work as ep_deliver_event(), which returns a tri-state int:
1 one event was delivered; caller advances the counter,
0 re-poll produced no caller-requested events (item drops
out of the ready list; a future callback will re-queue),
-EFAULT copy_to_user() faulted; item is already re-inserted at
the head of the txlist so ep_done_scan() splices it back to rdllist.
The per-item comments (PM ordering, the "sole writer to rdllist" invariant for the LT re-queue, the EFAULT semantics) move into ep_deliver_event(). ep_send_events() reduces to the fatal-signal short-circuit, scan bracket, and a short txlist walk that accumulates the deliveries and preserves the "first error wins" EFAULT contract (res = delivered only if no event was previously delivered; otherwise the success count is returned and -EFAULT is reported on the next call).
No functional change.
Stable-dep-of: 0c4aefe3c2d0 ("eventpoll: Fix epoll_wait() report false negative")
--- fs/eventpoll.c | 138 ++++++++++++++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 54 deletions(-)
fs/eventpoll.c +84 -54
@@ -1799,6 +1799,82 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,return 0 ; } +/* +* Attempt to deliver one event for @epi into @*uevents. +* +* Returns 1 if an event was delivered (with *uevents advanced to the +* next slot), 0 if the re-poll reported no caller-requested events +* (@epi drops out of the ready list; a future callback will re-add +* it), or -EFAULT if copy_to_user() faulted (in which case @epi is +* re-inserted at the head of @txlist so ep_done_scan() merges it +* back to rdllist for the next attempt). +* +* PM bookkeeping and level-triggered re-queue are handled here. +* Caller holds ep->mtx and the scan is active. +*/ +static int ep_deliver_event (struct eventpoll *ep,struct epitem *epi, +poll_table *pt, +struct epoll_event __user **uevents, +struct list_head *txlist) +{ +struct epoll_event __user *next; +struct wakeup_source *ws; +__poll_t revents; + +/* +* Activate ep->ws before deactivating epi->ws to prevent +* triggering auto-suspend here (in case we reactivate epi->ws +* below). Rearranging to delay the deactivation would let +* epi->ws drift out of sync with ep_is_linked(). +*/ + ws =ep_wakeup_source (epi); +if (ws) { +if (ws->active) +__pm_stay_awake (ep->ws); +__pm_relax (ws); + } + +list_del_init (&epi->rdllink); + +/* +* Re-poll under ep->mtx so userspace cannot change the item +* out from under us. If no caller-requested events remain, +* @epi stays off the ready list; the poll callback will +* re-queue it when events next appear. +*/ + revents =ep_item_poll (epi, pt,1 ); +if (!revents) +return 0 ; + + next =epoll_put_uevent (revents, epi->event.data, *uevents); +if (!next) { +/* +* copy_to_user() faulted: put the item back so +* ep_done_scan() splices it onto rdllist for the next +* attempt. +*/ +list_add (&epi->rdllink, txlist); +ep_pm_stay_awake (epi); +return -EFAULT ; + } + *uevents = next; + +if (epi->event.events &EPOLLONESHOT ) { + epi->event.events &=EP_PRIVATE_BITS ; + }else if (!(epi->event.events &EPOLLET )) { +/* +* Level-triggered: re-queue so the next epoll_wait() +* rechecks availability. We are the sole writer to +* rdllist here -- epoll_ctl() callers are locked out +* by ep->mtx, and the poll callback queues to ovflist +* during scans. +*/ +list_add_tail (&epi->rdllink, &ep->rdllist); +ep_pm_stay_awake (epi); + } +return 1 ; +} +static int ep_send_events (struct eventpoll *ep,struct epoll_event __user *events,int maxevents) {
@@ -1821,70 +1897,24 @@ static int ep_send_events(struct eventpoll *ep,ep_start_scan (ep, &txlist);/* -* We can loop without lock because we are passed a task private list. -* Items cannot vanish during the loop we are holding ep->mtx. +* We can loop without lock because we are passed a task-private +* txlist; items cannot vanish while we hold ep->mtx. */ list_for_each_entry_safe (epi, tmp, &txlist, rdllink) { -struct wakeup_source *ws; -__poll_t revents; +int delivered;if (res >= maxevents)break ; -/* -* Activate ep->ws before deactivating epi->ws to prevent -* triggering auto-suspend here (in case we reactive epi->ws -* below). -* -* This could be rearranged to delay the deactivation of epi->ws -* instead, but then epi->ws would temporarily be out of sync -* with ep_is_linked(). -*/ - ws =ep_wakeup_source (epi); -if (ws) { -if (ws->active) -__pm_stay_awake (ep->ws); -__pm_relax (ws); - } - -list_del_init (&epi->rdllink); - -/* -* If the event mask intersect the caller-requested one, -* deliver the event to userspace. Again, we are holding ep->mtx, -* so no operations coming from userspace can change the item. -*/ - revents =ep_item_poll (epi, &pt,1 ); -if (!revents) -continue ; - - events =epoll_put_uevent (revents, epi->event.data, events); -if (!events) { -list_add (&epi->rdllink, &txlist); -ep_pm_stay_awake (epi); + delivered =ep_deliver_event (ep, epi, &pt, &events, &txlist); +if (delivered <0 ) {if (!res) - res = -EFAULT ; + res = delivered;break ; } - res++; -if (epi->event.events &EPOLLONESHOT ) - epi->event.events &=EP_PRIVATE_BITS ; -else if (!(epi->event.events &EPOLLET )) { -/* -* If this file has been added with Level -* Trigger mode, we need to insert back inside -* the ready list, so that the next call to -* epoll_wait() will check again the events -* availability. At this point, no one can insert -* into ep->rdllist besides us. The epoll_ctl() -* callers are locked out by -* ep_send_events() holding "mtx" and the -* poll callback will queue them in ep->ovflist. -*/ -list_add_tail (&epi->rdllink, &ep->rdllist); -ep_pm_stay_awake (epi); - } + res += delivered; } +ep_done_scan (ep, &txlist);mutex_unlock (&ep->mtx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/2077 eventpoll: wrap EP_UNACTIVE_PTR in typed sentinel helpers
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 0dcb726466a556f273beaadfb76f12d1b0087dd7 ]
ep->ovflist and epi->next both use EP_UNACTIVE_PTR (a cast to (void *)-1) as a sentinel, with distinct meanings at each site:
ep->ovflist == EP_UNACTIVE_PTR no scan in progress
epi->next == EP_UNACTIVE_PTR epi not on ovflist
Call sites had to know the sentinel's value and, by convention, what it meant in each context. Hide both behind inline helpers:
ep_is_scanning(ep) predicate for "scan in progress" ep_enter_scan(ep) WRITE_ONCE flip to NULL (scan start) ep_exit_scan(ep) WRITE_ONCE flip to sentinel (scan end) epi_on_ovflist(epi) predicate for "epi is on ovflist" epi_clear_ovflist(epi) clear epi's ovflist link slot
Convert ep_events_available(), ep_start_scan(), ep_done_scan(), ep_poll_callback(), and ep_alloc_epitem() to use the wrappers. The ovflist state-machine transitions are now named, not encoded in sentinel comparisons, and the top-of-file "Ready-list state machine" section is the single place that spells out the sentinel's meaning.
ep_alloc() keeps the raw "ep->ovflist = EP_UNACTIVE_PTR" init (no concurrent access at that point) with an inline "not scanning" comment, and the tfile_check_list sentinel is left alone -- it will disappear entirely when the loop-check globals move into a stack-allocated ep_ctl_ctx in a later commit.
Also rework ep_done_scan()'s for-loop: the combined initializer + update clause that advanced nepi AND cleared epi->next in one step was clever but hard to read; splitting the update into two statements inside the body makes the epi_clear_ovflist() call visible.
No functional change.
Stable-dep-of: 0c4aefe3c2d0 ("eventpoll: Fix epoll_wait() report false negative")
--- fs/eventpoll.c | 73 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 21 deletions(-)
fs/eventpoll.c +52 -21
@@ -372,6 +372,43 @@ static inline struct epitem *ep_item_from_wait(wait_queue_entry_t *p) return container_of(p, struct eppoll_entry, wait)->base; } +/* +* Ready-list / ovflist state (see "Ready-list state machine" in the +* top-of-file banner for the full state machine). EP_UNACTIVE_PTR is +* the sentinel; these wrappers name each transition and each test so +* call sites do not need to know the sentinel's value. +*/ + +/* True iff @ep is between ep_enter_scan() and ep_exit_scan(). */ +static inline bool ep_is_scanning (struct eventpoll *ep) +{ +return READ_ONCE (ep->ovflist) !=EP_UNACTIVE_PTR ; +} + +/* Called by ep_start_scan(): divert ep_poll_callback() to ovflist. */ +static inline void ep_enter_scan (struct eventpoll *ep) +{ +WRITE_ONCE (ep->ovflist,NULL ); +} + +/* Called by ep_done_scan(): redirect ep_poll_callback() back to rdllist. */ +static inline void ep_exit_scan (struct eventpoll *ep) +{ +WRITE_ONCE (ep->ovflist,EP_UNACTIVE_PTR ); +} + +/* True iff @epi is currently linked on its ep's ovflist. */ +static inline bool epi_on_ovflist (const struct epitem *epi) +{ +return epi->next !=EP_UNACTIVE_PTR ; +} + +/* Mark @epi as not on any ovflist (init and post-drain). */ +static inline void epi_clear_ovflist (struct epitem *epi) +{ + epi->next =EP_UNACTIVE_PTR ; +} +/** * ep_events_available - Checks if ready events might be available. *
@@ -382,8 +419,7 @@ static inline struct epitem *ep_item_from_wait(wait_queue_entry_t *p)*/ static inline int ep_events_available (struct eventpoll *ep) { -return !list_empty_careful (&ep->rdllist) || -READ_ONCE (ep->ovflist) !=EP_UNACTIVE_PTR ; +return !list_empty_careful (&ep->rdllist) ||ep_is_scanning (ep); }#ifdef CONFIG_NET_RX_BUSY_POLL
@@ -736,7 +772,7 @@ static void ep_start_scan(struct eventpoll *ep, struct list_head *txlist)lockdep_assert_irqs_enabled ();spin_lock_irq (&ep->lock);list_splice_init (&ep->rdllist, txlist); -WRITE_ONCE (ep->ovflist,NULL ); +ep_enter_scan (ep);spin_unlock_irq (&ep->lock); }
@@ -751,29 +787,24 @@ static void ep_done_scan(struct eventpoll *ep,* other events might have been queued by the poll callback. * We re-insert them inside the main ready-list here. */ -for (nepi =READ_ONCE (ep->ovflist); (epi = nepi) !=NULL ; - nepi = epi->next, epi->next =EP_UNACTIVE_PTR ) { +for (nepi =READ_ONCE (ep->ovflist); (epi = nepi) !=NULL ; ) { + nepi = epi->next; +epi_clear_ovflist (epi);/* -* We need to check if the item is already in the list. -* During the "sproc" callback execution time, items are -* queued into ->ovflist but the "txlist" might already -* contain them, and the list_splice() below takes care of them. +* Skip items that the caller already returned via @txlist +* -- the list_splice() below takes care of those. */ if (!ep_is_linked (epi)) {/* -* ->ovflist is LIFO, so we have to reverse it in order -* to keep in FIFO. +* ovflist is LIFO; list_add() head-insert here +* reverses the iteration order into FIFO. */ list_add (&epi->rdllink, &ep->rdllist);ep_pm_stay_awake (epi); } } -/* -* We need to set back ep->ovflist to EP_UNACTIVE_PTR, so that after -* releasing the lock, events will be queued in the normal way inside -* ep->rdllist. -*/ -WRITE_ONCE (ep->ovflist,EP_UNACTIVE_PTR ); +/* Back out of scan mode; callbacks target ep->rdllist again. */ +ep_exit_scan (ep);/* * Quickly re-inject items left on "txlist".
@@ -1159,7 +1190,7 @@ static int ep_alloc(struct eventpoll **pep)init_waitqueue_head (&ep->poll_wait);INIT_LIST_HEAD (&ep->rdllist); ep->rbr =RB_ROOT_CACHED ; - ep->ovflist =EP_UNACTIVE_PTR ; + ep->ovflist =EP_UNACTIVE_PTR ;/* not scanning */ ep->user =get_current_user ();refcount_set (&ep->refcount,1 );
@@ -1283,8 +1314,8 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v* semantics). All the events that happen during that period of time are * chained in ep->ovflist and requeued later on. */ -if (READ_ONCE (ep->ovflist) !=EP_UNACTIVE_PTR ) { -if (epi->next ==EP_UNACTIVE_PTR ) { +if (ep_is_scanning (ep)) { +if (!epi_on_ovflist (epi)) { epi->next =READ_ONCE (ep->ovflist);WRITE_ONCE (ep->ovflist, epi);ep_pm_stay_awake_rcu (epi);
@@ -1591,7 +1622,7 @@ static struct epitem *ep_alloc_epitem(struct eventpoll *ep, epi->ep = ep;ep_set_ffd (&epi->ffd, tfile, fd); epi->event = *event; - epi->next =EP_UNACTIVE_PTR ; +epi_clear_ovflist (epi);return epi; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/2077 perf/x86/amd/core: Always use the NMI latency mitigation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 73a4c02f94a98d94480c3e5c81450215a4da05ba ]
Commit df4d29732fda ("perf/x86/amd: Change/fix NMI latency mitigation to use a timestamp") fixed handling of late-arriving NMIs but limited the mitigation to processors having X86_FEATURE_PERFCTR_CORE. However, it is unclear if processors without this feature are also affected. When Mediated vPMU is enabled on affected hardware, it is also possible to bypass the fix inside KVM guests if X86_FEATURE_PERFCTR_CORE is removed from the guest CPUID (e.g. using "-cpu host,-perfctr-core" with QEMU). Hence, use the mitigation at all times.
--- arch/x86/events/amd/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/amd/core.c +3 -3
@@ -1412,12 +1412,12 @@ static int __init amd_core_pmu_init(void)u64 even_ctr_mask =0ULL ;int i; -if (!boot_cpu_has (X86_FEATURE_PERFCTR_CORE )) -return 0 ; -/* Avoid calculating the value each time in the NMI handler */ perf_nmi_window =msecs_to_jiffies (100 ); +if (!boot_cpu_has (X86_FEATURE_PERFCTR_CORE )) +return 0 ; +/* * If core performance counter extensions exists, we must use * MSR_F15H_PERF_CTL/MSR_F15H_PERF_CTR msrs. See also
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/2077 perf/x86/intel/uncore: Fix discovery unit lookup for multi-die systems
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zide Chen <[email protected]>
[ Upstream commit 63f48abd55d0417996bca86022925c853a2b436b ]
In uncore_find_add_unit(), PMON units with the same unit ID may be added to the uncore discovery RB-tree for different dies. These units are distinguished by node->die.
However, intel_generic_uncore_box_ctl() uses a fixed die ID of -1 when looking up the discovery unit, which may retrieve the wrong node on multi-die systems.
Use box->dieid instead so the correct discovery unit is selected.
No functional issue has been observed so far because currently supported platforms happen to use the same unit control register for such units.
Remove WARN_ON_ONCE() because with the above change a NULL unit can be expected, e.g. when a CPU die is offline during uncore enumeration and the unit is not added to the RB-tree. In this case, intel_uncore_find_discovery_unit() returns NULL once the die becomes online, and it is expected that the PMU box is not functional for that die.
--- arch/x86/events/intel/uncore_discovery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/intel/uncore_discovery.c +2 -2
@@ -481,8 +481,8 @@ static u64 intel_generic_uncore_box_ctl(struct intel_uncore_box *box)struct intel_uncore_discovery_unit *unit; unit =intel_uncore_find_discovery_unit (box->pmu->type->boxes, --1 , box->pmu->pmu_idx); -if (WARN_ON_ONCE (!unit)) + box->dieid, box->pmu->pmu_idx); +if (!unit)return 0 ;return unit->addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/2077 perf/x86/intel/uncore: Fix PCI device refcount leak in UPI discovery
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zide Chen <[email protected]>
[ Upstream commit 81ec618f59415bdcf3e8989e2691c1f240be27fb ]
pci_get_domain_bus_and_slot() increments the reference count of the returned PCI device and therefore requires a matching pci_dev_put().
In skx_upi_topology_cb() and discover_upi_topology(), the lookup is performed inside a loop, but pci_dev_put() is only called once after the loop. As a result, references from all previous iterations are leaked.
Move pci_dev_put(dev) into the if (dev) block immediately after upi_fill_topology() returns.
Opportunistically, fix uninitialized variable in skx_upi_topology_cb().
--- arch/x86/events/intel/uncore_snbep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/intel/uncore_snbep.c +3 -3
@@ -4261,7 +4261,7 @@ static int upi_fill_topology(struct pci_dev *dev, struct intel_uncore_topology *static int skx_upi_topology_cb (struct intel_uncore_type *type,int segment,int die,u64 cpu_bus_msr) { -int idx, ret; +int idx, ret =0 ;struct intel_uncore_topology *upi;unsigned int devfn;struct pci_dev *dev =NULL ;
@@ -4274,12 +4274,12 @@ static int skx_upi_topology_cb(struct intel_uncore_type *type, int segment, dev =pci_get_domain_bus_and_slot (segment, bus, devfn);if (dev) { ret =upi_fill_topology (dev, upi, idx); +pci_dev_put (dev);if (ret)break ; } } -pci_dev_put (dev);return ret; }
@@ -5499,6 +5499,7 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i devfn);if (dev) { ret =upi_fill_topology (dev, upi, idx); +pci_dev_put (dev);if (ret) goto err; }
@@ -5506,7 +5507,6 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i } err:pci_dev_put (ubox); -pci_dev_put (dev);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/2077 perf/x86/amd/uncore: Use Node ID to identify DF and UMC domains
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 67d27727854def4a7e2b386429941f5c4741ccc4 ]
For DF and UMC PMUs, a single context is shared across all CPUs that are connected to the same Data Fabric (DF) instance. Currently, the Package ID, which also happens to be the Socket ID, is used to identify DF instances. This approach works for configurations having a single IO Die (IOD) but fails in the following cases.
* Older Zen 1 processors, where each chiplet has its own DF instance.
* Any configurations with multiple DF instances or multiple IODs in the same package.
The correct way to identify DF instances is through the Node ID (not to be confused with NUMA Node ID). This is available in ECX[7:0] of CPUID leaf 0x8000001e and returned via topology_amd_node_id(). Hence, replace usage of topology_logical_package_id() with topology_amd_node_id().
--- arch/x86/events/amd/uncore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/amd/uncore.c +3 -3
@@ -700,7 +700,7 @@ void amd_uncore_df_ctx_scan(struct amd_uncore *uncore, unsigned int cpu) info.split.aux_data =0 ; info.split.num_pmcs =NUM_COUNTERS_NB ; info.split.gid =0 ; - info.split.cid =topology_logical_package_id (cpu); + info.split.cid =topology_amd_node_id (cpu);if (pmu_version >=2 ) { ebx.full =cpuid_ebx (EXT_PERFMON_DEBUG_FEATURES );
@@ -999,8 +999,8 @@ void amd_uncore_umc_ctx_scan(struct amd_uncore *uncore, unsigned int cpu)cpuid (EXT_PERFMON_DEBUG_FEATURES , &eax, &ebx.full, &ecx, &edx); info.split.aux_data = ecx;/* stash active mask */ info.split.num_pmcs = ebx.split.num_umc_pmc; - info.split.gid =topology_logical_package_id (cpu); - info.split.cid =topology_logical_package_id (cpu); + info.split.gid =topology_amd_node_id (cpu); + info.split.cid =topology_amd_node_id (cpu); *per_cpu_ptr (uncore->info, cpu) = info; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/2077 xfrm: fix NAT-related field inheritance in SA migration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antony Antony <[email protected]>
[ Upstream commit 364e165e0b63e8142e76de83e96ae8e36c3b955a ]
During SA migration via xfrm_state_clone_and_setup(), nat_keepalive_interval was silently dropped and never copied to the new SA. mapping_maxage was unconditionally copied even when migrating to a non-encapsulated SA.
Both fields are only meaningful when UDP encapsulation (NAT-T) is in use. Move mapping_maxage and add nat_keepalive_interval inside the existing if (encap) block, so both are inherited when migrating with encapsulation and correctly absent when migrating without it.
--- net/xfrm/xfrm_state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/xfrm/xfrm_state.c +2 -1
@@ -2020,6 +2020,8 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig,if (!x->encap) goto error; + x->mapping_maxage = orig->mapping_maxage; + x->nat_keepalive_interval = orig->nat_keepalive_interval; }if (orig->security)
@@ -2054,7 +2056,6 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig, x->km.seq = orig->km.seq; x->replay = orig->replay; x->preplay = orig->preplay; - x->mapping_maxage = orig->mapping_maxage; x->lastused = orig->lastused; x->new_mapping =0 ; x->new_mapping_sport =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/2077 wifi: wlcore: enable the right set of ciphers
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
[ Upstream commit 7495adaa0e45e180f4b6b7436675c6266edff1ff ]
The firmware version number check for IGTK introduced in commit c34dbc5900b0 ("wifi: wlcore: Add support for IGTK key")
lets the amount of ciphers decrease on every boot of a too old firmware and that is practically happening. It also does not take into account other chips than the wl18xx. On some wl128x, the following can be observed when connecting via nm to a common ap:
[ 484.113311] wlcore: WARNING could not set keys [ 484.117828] wlcore: ERROR Could not add or replace key [ 484.123016] wlan0: failed to set key (5, ff:ff:ff:ff:ff:ff) to hardware (-5) [ 484.123046] wlcore: Hardware recovery in progress. FW ver: Rev 7.3.10.0.142 [ 484.139923] wlcore: pc: 0x0, hint_sts: 0x00000048 count: 1 [ 484.145721] wlcore: down [ 484.148986] ieee80211 phy0: Hardware restart was requested [ 484.610473] wlcore: firmware booted (Rev 7.3.10.0.142) [ 484.633758] wlcore: Association completed. [ 484.690490] wlcore: ERROR command execute failure 14 [ 484.690490] ------------[ cut here ]------------ [ 484.700195] WARNING: drivers/net/wireless/ti/wlcore/main.c:872 at wl12xx_queue_recovery_work+0x64/0x74 [wlcore], CPU#0: kworker/0:0/892
This repeats endlessly.
Always disable IGTK on wl12xx and fix the decrementing mess.
--- drivers/net/wireless/ti/wlcore/main.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +13 -10
@@ -32,6 +32,15 @@#define WL1271_BOOT_RETRIES 3#define WL1271_WAKEUP_TIMEOUT 500 +static const u32 cipher_suites[] = { +WLAN_CIPHER_SUITE_WEP40 , +WLAN_CIPHER_SUITE_WEP104 , +WLAN_CIPHER_SUITE_TKIP , +WLAN_CIPHER_SUITE_CCMP , +WL1271_CIPHER_SUITE_GEM , +WLAN_CIPHER_SUITE_AES_CMAC , +}; +static char *fwlog_param;static int fwlog_mem_blocks =-1 ;static int bug_on_recovery =-1 ;
@@ -2367,6 +2376,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif)static int wl12xx_init_fw (struct wl1271 *wl) { +struct wlcore_platdev_data *pdev_data =dev_get_platdata (&wl->pdev->dev);int retries =WL1271_BOOT_RETRIES ;bool booted = false;struct wiphy *wiphy = wl->hw->wiphy;
@@ -2421,8 +2431,9 @@ static int wl12xx_init_fw(struct wl1271 *wl)/* WLAN_CIPHER_SUITE_AES_CMAC must be last in cipher_suites; support only with firmware 8.9.1 and newer */ -if (wl->chip.fw_ver[FW_VER_MAJOR ] <1 ) - wl->hw->wiphy->n_cipher_suites--; +if (wl->chip.fw_ver[FW_VER_MAJOR ] <1 || + (!strncmp (pdev_data->family->name,"wl12" ,4 ))) + wl->hw->wiphy->n_cipher_suites =ARRAY_SIZE (cipher_suites) -1 ;/* * Now we know if 11a is supported (info from the NVS), so disable
@@ -6198,14 +6209,6 @@ static void wl1271_unregister_hw(struct wl1271 *wl)static int wl1271_init_ieee80211 (struct wl1271 *wl) {int i; -static const u32 cipher_suites[] = { -WLAN_CIPHER_SUITE_WEP40 , -WLAN_CIPHER_SUITE_WEP104 , -WLAN_CIPHER_SUITE_TKIP , -WLAN_CIPHER_SUITE_CCMP , -WL1271_CIPHER_SUITE_GEM , -WLAN_CIPHER_SUITE_AES_CMAC , - };/* The tx descriptor buffer */ wl->hw->extra_tx_headroom =sizeof (struct wl1271_tx_hw_descr );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/2077 cxl/fwctl: Fix __fortify_panic
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 6c9d2e87df40d606f1c85143e9acb1ecff463d5e ]
Fix a runtime assertion in cxlctl_get_supported_features(). Fortify complains that it is potentially overflowing the entries array per __counted_by_le(num_entries). Quiet the false positive by initializing @num_entries earlier.
memcpy: detected buffer overflow: 48 byte write of buffer size 0
WARNING: lib/string_helpers.c:1036 at __fortify_report+0x4d/0xa0, CPU#7: fwctl/1398 RIP: 0010:__fortify_report+0x50/0xa0 Call Trace: __fortify_panic+0xd/0xf cxlctl_get_supported_features.cold+0x23/0x35 [cxl_core]
--- drivers/cxl/core/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +1 -1
@@ -423,6 +423,7 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs, rpc_out->size =struct_size (feat_out, ents, requested); feat_out = &rpc_out->get_sup_feats_out; + feat_out->num_entries =cpu_to_le16 (requested);for (i = start, pos = &feat_out->ents[0 ]; i < cxlfs->entries->num_features; i++, pos++) {
@@ -444,7 +445,6 @@ static void *cxlctl_get_supported_features(struct cxl_features_state *cxlfs, } } - feat_out->num_entries =cpu_to_le16 (requested); feat_out->supported_feats =cpu_to_le16 (cxlfs->entries->num_features); rpc_out->retval =CXL_MBOX_CMD_RC_SUCCESS ; *out_len = out_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/2077 cxl/test: Fix __fortify_panic
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 08326b92c7a414a73b5b308d1daf0e91e0134dfc ]
Fix a runtime assertion in setup_xor_mapping(). Fortify complains that it is potentially overflowing the xormaps array per __counted_by(nr_maps). Quiet the false positive by initializing @nr_maps earlier.
memcpy: detected buffer overflow: 32 byte write of buffer size 0
WARNING: lib/string_helpers.c:1036 at __fortify_report+0x4d/0xa0, CPU#8: modprobe/2728 Call Trace: __fortify_panic+0xd/0xf setup_xor_mapping+0x6c/0xa0 [cxl_translate]
[ dj: Fixed up @nr_entries to @nr_maps in commit log. ]
--- tools/testing/cxl/test/cxl_translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/cxl/test/cxl_translate.c +1 -1
@@ -236,8 +236,8 @@ static int setup_xor_mapping(void)if (!cximsd)return -ENOMEM ; -memcpy (cximsd->xormaps, xormaps, nr_maps *sizeof (*cximsd->xormaps)); cximsd->nr_maps = nr_maps; +memcpy (cximsd->xormaps, xormaps, nr_maps *sizeof (*cximsd->xormaps));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/2077 bpf: Take mmap_lock in zap_pages()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit 80b89d0226a05e8b67969de99c31b51fcd54f76a ]
zap_vma_range() requires the owning mm's mmap_lock to be held.
Taking mmap_read_lock under arena->lock would AB-BA against arena_vm_close() and arena_map_mmap(), both of which run with mmap_write_lock held and then acquire arena->lock. Instead drop arena->lock, mmget_not_zero() the vma's mm, take mmap_read_lock, and re-resolve the vma via find_vma() since it may have been unmapped or replaced while waiting.
Track processed vmls with a per-call generation in vml->zap_gen and serialize zap_pages() callers with a new arena->zap_mutex so concurrent callers on different uaddr ranges do not mark each other's vmls processed before the zap is done.
--- kernel/bpf/arena.c | 61 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-)
kernel/bpf/arena.c +57 -4
@@ -59,6 +59,8 @@ struct bpf_arena {struct list_head vma_list;/* protects vma_list */ struct mutex lock; +u64 zap_gen; +struct mutex zap_mutex;struct irq_work free_irq;struct work_struct free_work;struct llist_head free_spans;
@@ -228,6 +230,7 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr) goto err; }mutex_init (&arena->lock); +mutex_init (&arena->zap_mutex);raw_res_spin_lock_init (&arena->spinlock); err =populate_pgtable_except_pte (arena);if (err) {
@@ -318,6 +321,7 @@ struct vma_list {struct vm_area_struct *vma;struct list_head head;refcount_t mmap_count; +u64 zap_gen; };static int remember_vma (struct bpf_arena *arena,struct vm_area_struct *vma)
@@ -330,6 +334,7 @@ static int remember_vma(struct bpf_arena *arena, struct vm_area_struct *vma)refcount_set (&vml->mmap_count,1 ); vma->vm_private_data = vml; vml->vma = vma; + vml->zap_gen =0 ;list_add (&vml->head, &arena->vma_list);return 0 ; }
@@ -668,12 +673,60 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt*/ static void zap_pages (struct bpf_arena *arena,long uaddr,long page_cnt) { +unsigned long size = (unsigned long )page_cnt <<PAGE_SHIFT ; +struct vm_area_struct *vma; +struct mm_struct *mm;struct vma_list *vml; +unsigned long vm_start; +u64 my_gen; -guard (mutex)(&arena->lock); -/* iterate link list under lock */ -list_for_each_entry (vml, &arena->vma_list, head) -zap_vma_range (vml->vma, uaddr,PAGE_SIZE * page_cnt); +/* +* Taking mmap_read_lock() under arena->lock would deadlock against +* arena_vm_close(), which runs with mmap_write_lock held and then +* acquires arena->lock. Drop arena->lock for mmap_read_lock(). +* +* Use per-call my_gen, recorded in vml->zap_gen, to remember which +* vmls this invocation has already processed across the lock drop. +* Hold zap_mutex around the whole walk so concurrent zap_pages() +* callers cannot overwrite each other's marks on shared vmls -- +* otherwise call B's mark would make call A skip a vml that A has +* not yet zapped for A's uaddr range. +*/ +mutex_lock (&arena->zap_mutex); +mutex_lock (&arena->lock); + my_gen = ++arena->zap_gen; +for (;;) { + mm =NULL ; +list_for_each_entry (vml, &arena->vma_list, head) { +if (vml->zap_gen >= my_gen) +continue ; + vml->zap_gen = my_gen; +if (!mmget_not_zero (vml->vma->vm_mm)) +continue ; + mm = vml->vma->vm_mm; + vm_start = vml->vma->vm_start; +break ; + } +if (!mm) +break ; +mutex_unlock (&arena->lock); + +mmap_read_lock (mm); +/* +* Re-resolve: while we waited the VMA could have been unmapped +* and a different mapping installed at the same address. +*/ + vma =find_vma (mm, vm_start); +if (vma && vma->vm_start == vm_start && + vma->vm_file && vma->vm_file->private_data == &arena->map) +zap_vma_range (vma, uaddr, size); +mmap_read_unlock (mm); +mmput (mm); + +mutex_lock (&arena->lock); + } +mutex_unlock (&arena->lock); +mutex_unlock (&arena->zap_mutex); }static void arena_free_pages (struct bpf_arena *arena,long uaddr,long page_cnt,bool sleepable)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/2077 drm/amdkfd: always resume_all after suspend_all
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 56ae73c92e200e630c2bdf1e98c88b86c8483b37 ]
Need to restore any good queues even if the suspend_all failed for some. Always run remove_queue as that will schedule a GPU reset is removing the queue fails.
v2: move resume_all after remove
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +6 -14
@@ -3095,32 +3095,24 @@ int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbellist_for_each_entry (q, &qpd->queues_list, list) {if (q->doorbell_id == doorbell_id && q->properties.is_active) { - ret =suspend_all_queues_mes (dqm); -if (ret) { -dev_err (dev,"Suspending all queues failed" ); - goto out; - } +/* suspend all queues will save any good queues and mark the rest as bad */ +suspend_all_queues_mes (dqm); q->properties.is_evicted = true; q->properties.is_active = false;decrement_queue_count (dqm, qpd, q); +/* this will remove the bad queue and sched a GPU reset if needed */ ret =remove_queue_mes (dqm, q, qpd); -if (ret) { -dev_err (dev,"Removing bad queue failed" ); - goto out; - } - - ret =resume_all_queues_mes (dqm);if (ret) -dev_err (dev,"Resuming all queues failed" ); - +dev_err (dev,"Removing bad queue failed" ); +/* resume the good queues */ +resume_all_queues_mes (dqm);break ; } } } -out:dqm_unlock (dqm);kfd_unref_process (p);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/2077 of: reserved_mem: avoid post-init UAF when alloc_reserved_mem_array() fails
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wandun Chen <[email protected]>
[ Upstream commit e1686ca81dbf3edbde589b7daf312b45cbf76e03 ]
The global pointer 'reserved_mem' continues to reference the reserved_mem_array which lives in __initdata if alloc_reserved_mem_array() fails. of_reserved_mem_lookup() is exported for post-init use, that would dereference freed memory and trigger a use-after-free.
So reset reserved_mem_count to 0 when alloc_reserved_mem_array() fails.
--- drivers/of/of_reserved_mem.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/of/of_reserved_mem.c +19 -9
@@ -69,29 +69,32 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,* the initial static array is copied over to this new array and * the new array is used from this point on. */ -static void __init alloc_reserved_mem_array (void ) +static int __init alloc_reserved_mem_array (void ) {struct reserved_mem *new_array;size_t alloc_size, copy_size, memset_size; +int ret; + +if (!total_reserved_mem_cnt) +return 0 ; alloc_size =array_size (total_reserved_mem_cnt,sizeof (*new_array));if (alloc_size ==SIZE_MAX ) { -pr_err ("Failed to allocate memory for reserved_mem array with err: %d" , -EOVERFLOW ); -return ; + ret = -EOVERFLOW ; + goto fail; } new_array =memblock_alloc (alloc_size,SMP_CACHE_BYTES );if (!new_array) { -pr_err ("Failed to allocate memory for reserved_mem array with err: %d" , -ENOMEM ); -return ; + ret = -ENOMEM ; + goto fail; } copy_size =array_size (reserved_mem_count,sizeof (*new_array));if (copy_size ==SIZE_MAX ) {memblock_free (new_array, alloc_size); - total_reserved_mem_cnt =MAX_RESERVED_REGIONS ; -pr_err ("Failed to allocate memory for reserved_mem array with err: %d" , -EOVERFLOW ); -return ; + ret = -EOVERFLOW ; + goto fail; } memset_size = alloc_size - copy_size;
@@ -100,6 +103,12 @@ static void __init alloc_reserved_mem_array(void)memset (new_array + reserved_mem_count,0 , memset_size); reserved_mem = new_array; +return 0 ; + +fail: +pr_err ("Failed to allocate memory for reserved_mem array with err: %d" , ret); + reserved_mem_count =0 ; +return ret; } static void fdt_init_reserved_mem_node(unsigned long node, const char *uname,
@@ -266,7 +275,8 @@ void __init fdt_scan_reserved_mem_late(void) }/* Attempt dynamic allocation of a new reserved_mem array */ -alloc_reserved_mem_array (); +if (alloc_reserved_mem_array ()) +return ;if (__reserved_mem_check_root (node)) {pr_err ("Reserved memory: unsupported node format, ignoring\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/2077 ocfs2: rebase copied fsdlm LVB pointers in locking_state
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
[ Upstream commit 93612d48fa42b3d1a637eb9279e15281c611c000 ]
The locking_state debugfs iterator snapshots struct ocfs2_lock_res by value under ocfs2_dlm_tracking_lock and later formats that copy in ocfs2_dlm_seq_show(). That is fine for the inline fields, but the userspace fsdlm stack stores the LVB through lksb_fsdlm.sb_lvbptr. Once the iterator drops the tracking lock, a copied non-NULL sb_lvbptr still points into the original lockres owner, so teardown can free that container before the debugfs dump walks the raw LVB bytes.
Rebase the copied sb_lvbptr to the copied l_lksb before dumping the raw LVB. The seq snapshot already carries the inline LVB storage reserved in struct ocfs2_dlm_lksb, so the debugfs reader can dump the copied bytes without borrowing the original lockres lifetime.
The buggy scenario involves two paths, with each column showing the order within that path:
locking_state reader: lockres teardown:
1. ocfs2_dlm_seq_start()/next() 1. file release or another owner
copies struct ocfs2_lock_res teardown reaches
2. ocfs2_dlm_seq_show() formats ocfs2_lock_res_free()
the copied row 2. the lockres is removed from the
3. ocfs2_dlm_lvb() follows the tracking list
copied sb_lvbptr 3. the owner frees the original
lockres container
Validation reproduced this kernel report:
KASAN slab-use-after-free in ocfs2_dlm_seq_show+0x1bd/0x430
RIP: 0033:0x7f8ec4b1e29d The buggy address belongs to the object at ffff88810a1e0800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 368 bytes inside of freed 1024-byte region [ffff88810a1e0800, ffff88810a1e0c00) Read of size 1 Call trace: dump_stack_lvl+0x66/0xa0 print_report+0xce/0x630 ocfs2_dlm_seq_show+0x1bd/0x430 (fs/ocfs2/dlmglue.c:3137) srso_alias_return_thunk+0x5/0xfbef5 __virt_addr_valid+0x19f/0x330 kasan_report+0xe0/0x110 seq_read_iter+0x29d/0x790 seq_read+0x20a/0x280 find_held_lock+0x2b/0x80 rcu_read_unlock+0x18/0x70 full_proxy_read+0x9e/0xd0 vfs_read+0x12c/0x590 ksys_read+0xd2/0x170 do_user_addr_fault+0x65a/0x890 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f Allocated by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 __kasan_kmalloc+0xaa/0xb0 ocfs2_file_open+0x13e/0x300 do_dentry_open+0x233/0x7f0 vfs_open+0x5a/0x1b0 path_openat+0x66d/0x1540 do_file_open+0x186/0x2b0 do_sys_openat2+0xce/0x150 __x64_sys_openat+0xd0/0x140 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task stack: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x5f/0x80 kfree+0x313/0x590 ocfs2_file_release+0x138/0x260 __fput+0x1df/0x4b0 fput_close_sync+0xd2/0x170 __x64_sys_close+0x55/0x90 do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- fs/ocfs2/dlmglue.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/ocfs2/dlmglue.c +17 -0
@@ -3134,6 +3134,22 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)* - Add last pr/ex unlock times and first lock wait time in usecs */ #define OCFS2_DLM_DEBUG_STR_VERSION 4 + +/* +* The debug iterator snapshots lockres by value, so a userspace-stack LVB +* pointer copied from the original lockres must be rebased to the copied +* lksb before the dump walks the raw bytes. +*/ +static void ocfs2_dlm_seq_rebase_lvb (struct ocfs2_lock_res *lockres) +{ +if (!ocfs2_stack_supports_plocks ()) +return ; + +if (lockres->l_lksb.lksb_fsdlm.sb_lvbptr) + lockres->l_lksb.lksb_fsdlm.sb_lvbptr = + (char *)&lockres->l_lksb +sizeof (struct dlm_lksb ); +} +static int ocfs2_dlm_seq_show (struct seq_file *m,void *v) {int i;
@@ -3191,6 +3207,7 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) lockres->l_blocking);/* Dump the raw LVB */ +ocfs2_dlm_seq_rebase_lvb (lockres); lvb =ocfs2_dlm_lvb (&lockres->l_lksb);for (i =0 ; i <DLM_LVB_LEN ; i++)seq_printf (m,"0x%x\t" , lvb[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/2077 lib: kunit_iov_iter: repeatedly call alloc_pages_bulk()
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 9ac9a08e4ac4bc063e56e1aff266c5e8aa5c6c03 ]
alloc_pages_bulk() is not guaranteed to return all requested pages in a single call.
Call it repeatedly until all pages have been allocated or no more progress is being made.
--- lib/tests/kunit_iov_iter.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
lib/tests/kunit_iov_iter.c +10 -2
@@ -53,7 +53,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test, size_t npages) {struct page **pages; -unsigned long got; +unsigned long got, last;void *buffer;unsigned int i;
@@ -61,7 +61,15 @@ static void *__init iov_kunit_create_buffer(struct kunit *test,KUNIT_ASSERT_NOT_ERR_OR_NULL (test, pages); *ppages = pages; - got =alloc_pages_bulk (GFP_KERNEL , npages, pages); + got =0 ; +while (true) { + last = got; + got =alloc_pages_bulk (GFP_KERNEL , npages, pages); + +if (last == got || got == npages) +break ; + } +if (got != npages) {release_pages (pages, got);kvfree (pages);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/2077 ocfs2: fix buffer head management in ocfs2_read_blocks()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Antipov <[email protected]>
[ Upstream commit 6371a07148ee979af22a9d6f4c277462953a9a4a ]
In ocfs2_read_blocks(), caller should't assume that buffer head returned by 'sb_getblk()' is exclusively owned and so 'put_bh()' always drops b_count from 1 to 0. If it is not so, buffer head remains on hold and likely to be returned by the next call to 'sb_getblk()' unchanged - that is, with BH_Uptodate bit set even if it has failed validation previously, thus allowing to insert that buffer head into OCFS2 metadata cache and submit it to upper layers. To avoid such a scenario, BH_Uptodate should be cleared immediately after 'validate()' callback has detected some data inconsistency.
--- fs/ocfs2/buffer_head_io.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ocfs2/buffer_head_io.c +4 -3
@@ -350,8 +350,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,wait_on_buffer (bh);put_bh (bh); bhs[i] =NULL ; - }else if (bh &&buffer_uptodate (bh)) { -clear_buffer_uptodate (bh); }continue ; }
@@ -380,8 +378,11 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,BUG_ON (buffer_jbd (bh));clear_buffer_needs_validate (bh); status =validate (sb, bh); -if (status) +if (status) { +if (buffer_uptodate (bh)) +clear_buffer_uptodate (bh); goto read_failure; + } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/2077 ocfs2: validate fast symlink target during inode read
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
[ Upstream commit e234973f286ed2e8961a24561ec91594ec3e3ff8 ]
ocfs2_validate_inode_block() already rejects several inconsistent self-contained dinodes before they are exposed to the rest of the filesystem. Fast symlinks need the same treatment.
A zero-cluster symlink is treated as a fast symlink and later read through page_get_link() and ocfs2_fast_symlink_read_folio(). That path uses strnlen() on the inline payload and then copies len + 1 bytes into the folio. If a corrupt dinode stores an i_size that does not fit the inline area or omits the terminating NUL at i_size, that copy reads past the end of the inode block buffer.
Reject zero-cluster symlink dinodes whose i_size exceeds the inline fast-symlink capacity or whose inline payload is not NUL-terminated exactly at i_size when the inode block is validated. This keeps malformed fast symlinks from reaching the read path.
Validation reproduced this kernel report:
KASAN use-after-free in ocfs2_fast_symlink_read_folio+0x12c/0x1f0
RIP: 0033:0x7f5c6d859aa7 Read of size 3905 Call trace: dump_stack_lvl+0x66/0xa0 (?:?) print_report+0xce/0x630 (?:?) ocfs2_fast_symlink_read_folio+0x12c/0x1f0 (fs/ocfs2/inode.c:?) srso_alias_return_thunk+0x5/0xfbef5 (?:?) __virt_addr_valid+0x19f/0x330 (?:?) kasan_report+0xe0/0x110 (?:?) kasan_check_range+0x105/0x1b0 (?:?) __asan_memcpy+0x23/0x60 (?:?) filemap_read_folio+0x27/0xe0 (?:?) filemap_read_folio+0x35/0xe0 (?:?) do_read_cache_folio+0x138/0x230 (?:?) __page_get_link+0x26/0x110 (?:?) page_get_link+0x2e/0x70 (?:?) vfs_readlink+0x15e/0x250 (?:?) touch_atime+0x4d/0x370 (?:?) do_readlinkat+0x186/0x200 (?:?) do_user_addr_fault+0x65a/0x890 (?:?) __x64_sys_readlink+0x46/0x60 (?:?) do_syscall_64+0x115/0x6a0 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f (?:?)
--- fs/ocfs2/inode.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
fs/ocfs2/inode.c +23 -0
@@ -1525,6 +1525,29 @@ int ocfs2_validate_inode_block(struct super_block *sb, } } +if (S_ISLNK (le16_to_cpu (di->i_mode)) && + !le32_to_cpu (di->i_clusters)) { +int max_inline =ocfs2_fast_symlink_chars (sb); +u64 i_size =le64_to_cpu (di->i_size); + +if (i_size >= max_inline) { + rc =ocfs2_error (sb, +"Invalid dinode #%llu: fast symlink i_size %llu exceeds max %d\n" , + (unsigned long long )bh->b_blocknr, + (unsigned long long )i_size, + max_inline -1 ); + goto bail; + } + +if (strnlen ((char *)di->id2.i_symlink, i_size +1 ) != i_size) { + rc =ocfs2_error (sb, +"Invalid dinode #%llu: fast symlink is not NUL-terminated at i_size %llu\n" , + (unsigned long long )bh->b_blocknr, + (unsigned long long )i_size); + goto bail; + } + } +if (le32_to_cpu (di->i_flags) &OCFS2_CHAIN_FL ) {struct ocfs2_chain_list *cl = &di->id2.i_chain; u16 bpc = 1 << (OCFS2_SB(sb)->s_clustersize_bits -
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/2077 ocfs2: reject FITRIM ranges shorter than a cluster
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
[ Upstream commit ca1afd88f5eaaff9168e1466e5401385edf59543 ]
ocfs2_trim_mainbm() trims the global bitmap in cluster units, but its too-short range validation only checks sb->s_blocksize.
On filesystems with a cluster size larger than the block size, a FITRIM range that is at least one block but shorter than one cluster is accepted and shifted down to len == 0. The later start + len - 1 and len -= ... arithmetic then underflows and can drive trimming past the requested range.
Reject ranges shorter than s_clustersize instead. That preserves the existing -EINVAL behavior for requests that cannot discard even one allocation unit and keeps zero-cluster trims out of the group walk.
--- fs/ocfs2/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/alloc.c +1 -1
@@ -7576,7 +7576,7 @@ int ocfs2_trim_mainbm(struct super_block *sb, struct fstrim_range *range) len = range->len >> osb->s_clustersize_bits; minlen = range->minlen >> osb->s_clustersize_bits; -if (minlen >= osb->bitmap_cpg || range->len < sb->s_blocksize) +if (minlen >= osb->bitmap_cpg || range->len < osb->s_clustersize)return -EINVAL ;trace_ocfs2_trim_mainbm (start, len, minlen);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/2077 ocfs2/dlm: require a ref for locking_state debugfs open
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
[ Upstream commit 03ad858ce8064861ea580021976dc19b7aabb549 ]
debug_lockres_open() copies inode->i_private into struct debug_lockres and debug_lockres_release() later drops that pointer with dlm_put(). That only works if open successfully pins the struct dlm_ctxt.
Today open calls dlm_grab(dlm) but ignores its return value. Once the last domain unregister has removed the context from dlm_domains, dlm_grab() returns NULL, yet open still stores the raw pointer and returns success. The later release path is outside the debugfs removal barrier, so it can call dlm_put() after dlm_free_ctxt_mem() has freed the context. KASAN reports this as a slab-use-after-free in dlm_put() called from debug_lockres_release().
Fail the open when dlm_grab() cannot acquire the reference and unwind the seq_file private state before returning. That keeps locking_state from handing out a file descriptor whose release path does not own the dlm_ctxt.
The buggy scenario involves two paths, with each column showing the order within that path:
locking_state debugfs open: last domain unregister:
1. debug_lockres_open() reads 1. dlm_unregister_domain() calls
inode->i_private. dlm_complete_dlm_shutdown().
2. debug_lockres_open() calls 2. shutdown removes the dlm_ctxt from
dlm_grab(dlm) and gets NULL. dlm_domains.
3. open still stores the raw dlm 3. final teardown reaches
pointer in dl->dl_ctxt and dlm_free_ctxt_mem() and frees it.
returns success.
4. debug_lockres_release() later
calls dlm_put(dl->dl_ctxt).
Validation reproduced this kernel report:
KASAN slab-use-after-free in dlm_put+0x82/0x200
RIP: 0033:0x7f4d349bc9e0 The buggy address belongs to the object at ffff888103a3c000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 816 bytes inside of freed 2048-byte region [ffff888103a3c000, ffff888103a3c800) Write of size 4 Call trace: dump_stack_lvl+0x66/0xa0 (?:?) print_report+0xd0/0x630 (?:?) dlm_put+0x82/0x200 (?:?) srso_alias_return_thunk+0x5/0xfbef5 (?:?) __virt_addr_valid+0x188/0x2f0 (?:?) kasan_report+0xe4/0x120 (?:?) kasan_check_range+0x105/0x1b0 (?:?) debug_lockres_release+0x53/0x80 (fs/ocfs2/dlm/dlmdebug.c:587) dlm_put+0x9/0x200 (?:?) debug_lockres_release+0x5c/0x80 (fs/ocfs2/dlm/dlmdebug.c:587) full_proxy_release+0x67/0x90 (?:?) __fput+0x1df/0x4b0 (?:?) do_raw_spin_lock+0x10f/0x1b0 (?:?) fput_close_sync+0xd2/0x170 (?:?) __x64_sys_close+0x55/0x90 (?:?) do_syscall_64+0x10c/0x640 (arch/x86/entry/syscall_64.c:87) irqentry_exit+0xac/0x6e0 (?:?) entry_SYSCALL_64_after_hwframe+0x77/0x7f (?:?) Freed by task stack: kasan_save_stack+0x33/0x60 (?:?) kasan_save_track+0x14/0x30 (?:?) kasan_save_free_info+0x3b/0x60 (?:?) __kasan_slab_free+0x5f/0x80 (?:?) kfree+0x30f/0x580 (?:?) dlm_put+0x1ce/0x200 (?:?) dlm_unregister_domain+0xf6/0xb30 (?:?) o2cb_cluster_disconnect+0x6b/0x90 (?:?) ocfs2_cluster_disconnect+0x41/0x70 (?:?) ocfs2_dlm_shutdown+0x1c4/0x220 (?:?) ocfs2_dismount_volume+0x38a/0x550 (?:?) generic_shutdown_super+0xc3/0x220 (?:?) kill_block_super+0x29/0x60 (?:?) deactivate_locked_super+0x66/0xe0 (?:?) cleanup_mnt+0x13d/0x210 (?:?) task_work_run+0xfa/0x170 (?:?) exit_to_user_mode_loop+0xd6/0x430 (?:?) do_syscall_64+0x3cb/0x640 (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe+0x77/0x7f (?:?)
--- fs/ocfs2/dlm/dlmdebug.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +12 -4
@@ -560,6 +560,7 @@ static int debug_lockres_open(struct inode *inode, struct file *file)struct dlm_ctxt *dlm = inode->i_private;struct debug_lockres *dl;void *buf; +int status = -ENOMEM ; buf =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!buf)
@@ -572,16 +573,23 @@ static int debug_lockres_open(struct inode *inode, struct file *file) dl->dl_len =PAGE_SIZE ; dl->dl_buf = buf; -dlm_grab (dlm); - dl->dl_ctxt = dlm; +/* ->release uses dl_ctxt after open, so it needs a real pin. */ + dl->dl_ctxt =dlm_grab (dlm); +if (!dl->dl_ctxt) { + status = -ENOENT ; + goto bailseq; + }return 0 ; +bailseq: +seq_release_private (inode, file); bailfree:kfree (buf); bail: -mlog_errno (-ENOMEM ); -return -ENOMEM ; +if (status != -ENOENT ) +mlog_errno (status); +return status; }static int debug_lockres_release (struct inode *inode,struct file *file)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/2077 ocfs2: fix race between ocfs2_control_install_private() and ocfs2_control_release()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 57dcfd9049d497c31151787a0696d59f0a98f8e6 ]
Move atomic_inc(&ocfs2_control_opened) and the handshake state update inside ocfs2_control_lock to close a race window where ocfs2_control_release() can observe ocfs2_control_opened dropping to zero (resetting ocfs2_control_this_node and running_proto) while ocfs2_control_install_private() is about to bump the counter and mark the connection valid.
--- fs/ocfs2/stack_user.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/ocfs2/stack_user.c +3 -7
@@ -327,18 +327,14 @@ static int ocfs2_control_install_private(struct file *file) ocfs2_control_this_node = p->op_this_node; running_proto.pv_major = p->op_proto.pv_major; running_proto.pv_minor = p->op_proto.pv_minor; - } - -out_unlock: -mutex_unlock (&ocfs2_control_lock); - -if (!rc && set_p) { -/* We set the global values successfully */ atomic_inc (&ocfs2_control_opened);ocfs2_control_set_handshake_state (file,OCFS2_CONTROL_HANDSHAKE_VALID ); } +out_unlock: +mutex_unlock (&ocfs2_control_lock); +return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/2077 ocfs2: fix out-of-bounds write in ocfs2_remove_refcount_extent
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 1ec3cca2d8b6b9ff6584ca626d4c8918bbf48d44 ]
[BUG]
Unlinking a refcounted file whose refcount tree has leaf blocks triggers a fortify panic due to an out-of-bounds write.
[CAUSE]
When the last leaf block is removed from a refcount tree, ocfs2_remove_refcount_extent() converts the root back to leaf mode with a bulk memset on &rb->rf_records. rf_records sits in an anonymous union with rf_list. rf_list.l_tree_depth aliases rf_records.rl_count, and is 0 for a single-level tree. With rl_count equal to 0, the memset writes past the 16-byte declared size of rf_records, which the fortify checker catches.
[FIX]
Replace the bulk memset on &rb->rf_records with a correctly-bounded memset on rl_recs[] alone, after setting rl_count to the correct value.
--- fs/ocfs2/refcounttree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/ocfs2/refcounttree.c +7 -2
@@ -2131,10 +2131,15 @@ static int ocfs2_remove_refcount_extent(handle_t *handle, rb->rf_flags =0 ; rb->rf_parent =0 ; rb->rf_cpos =0 ; -memset (&rb->rf_records,0 , sb->s_blocksize - - offsetof(struct ocfs2_refcount_block , rf_records)); + rb->rf_records.rl_used =0 ; + rb->rf_records.rl_reserved2 =0 ; + rb->rf_records.rl_reserved1 =0 ; +/* rl_count determines the memset size and fortify object size. */ rb->rf_records.rl_count =cpu_to_le16 (ocfs2_refcount_recs_per_rb (sb)); +memset (rb->rf_records.rl_recs,0 , +le16_to_cpu (rb->rf_records.rl_count) * +sizeof (*rb->rf_records.rl_recs)); }ocfs2_journal_dirty (handle, ref_root_bh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/2077 cxl/pci: Fix the incorrect check of pci_read_config_word() return
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 66782cfa0085369e2d8c861042f7c6d43431bdb3 ]
pci_read_config_word() returns PCIBIOS_* status on error which are positive values. The check should be for non-zero values to indicate error. Fix cxl_set_mem_enable() to check for non-zero return value instead of negative value.
While fixing this, also convert the error to negative errno value when returning on error path.
--- drivers/cxl/core/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cxl/core/pci.c +4 -4
@@ -187,8 +187,8 @@ static int cxl_set_mem_enable(struct cxl_dev_state *cxlds, u16 val)int rc; rc =pci_read_config_word (pdev, d +PCI_DVSEC_CXL_CTRL , &ctrl); -if (rc <0 ) -return rc; +if (rc) +return pcibios_err_to_errno (rc);if ((ctrl &PCI_DVSEC_CXL_MEM_ENABLE ) == val)return 1 ;
@@ -196,8 +196,8 @@ static int cxl_set_mem_enable(struct cxl_dev_state *cxlds, u16 val) ctrl |= val; rc =pci_write_config_word (pdev, d +PCI_DVSEC_CXL_CTRL , ctrl); -if (rc <0 ) -return rc; +if (rc) +return pcibios_err_to_errno (rc);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/2077 cxl/pci: Convert PCIBIOS errors to errno on DVSEC config accesses
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 26aa60e0276272ae61b843a05a91748dcb1130f9 ]
PCI config space accessors return positive PCIBIOS_* status codes on failure that are positive integers. Several DVSEC accesses in the CXL core propagated these raw values to callers that test for failure against less than 0. Thus silently misinterpret the return value as success.
Convert the positive error values to negative errno values so the checks are correct on error paths.
While the chances of a config access failure are low, fix for correctness and to avoid confusion in the future when more DVSEC accesses are added.
--- drivers/cxl/core/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/cxl/core/pci.c +9 -9
@@ -89,7 +89,7 @@ static int cxl_dvsec_mem_range_valid(struct cxl_dev_state *cxlds, int id) d +PCI_DVSEC_CXL_RANGE_SIZE_LOW (id), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); valid =FIELD_GET (PCI_DVSEC_CXL_MEM_INFO_VALID , temp);if (valid)
@@ -123,7 +123,7 @@ static int cxl_dvsec_mem_range_active(struct cxl_dev_state *cxlds, int id) rc =pci_read_config_dword ( pdev, d +PCI_DVSEC_CXL_RANGE_SIZE_LOW (id), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); active =FIELD_GET (PCI_DVSEC_CXL_MEM_ACTIVE , temp);if (active)
@@ -156,7 +156,7 @@ int cxl_await_media_ready(struct cxl_dev_state *cxlds) rc =pci_read_config_word (pdev, d +PCI_DVSEC_CXL_CAP , &cap);if (rc) -return rc; +return pcibios_err_to_errno (rc); hdm_count =FIELD_GET (PCI_DVSEC_CXL_HDM_COUNT , cap);for (i =0 ; i < hdm_count; i++) {
@@ -275,7 +275,7 @@ int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, rc =pci_read_config_word (pdev, d +PCI_DVSEC_CXL_CAP , &cap);if (rc) -return rc; +return pcibios_err_to_errno (rc);if (!(cap &PCI_DVSEC_CXL_MEM_CAPABLE )) {dev_dbg (dev,"Not MEM Capable\n" );
@@ -299,7 +299,7 @@ int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds,*/ rc =pci_read_config_word (pdev, d +PCI_DVSEC_CXL_CTRL , &ctrl);if (rc) -return rc; +return pcibios_err_to_errno (rc); info->mem_enabled =FIELD_GET (PCI_DVSEC_CXL_MEM_ENABLE , ctrl);if (!info->mem_enabled)
@@ -316,14 +316,14 @@ int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, rc =pci_read_config_dword ( pdev, d +PCI_DVSEC_CXL_RANGE_SIZE_HIGH (i), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); size = (u64 )temp <<32 ; rc =pci_read_config_dword ( pdev, d +PCI_DVSEC_CXL_RANGE_SIZE_LOW (i), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); size |= temp &PCI_DVSEC_CXL_MEM_SIZE_LOW ;if (!size) {
@@ -333,14 +333,14 @@ int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds, rc =pci_read_config_dword ( pdev, d +PCI_DVSEC_CXL_RANGE_BASE_HIGH (i), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); base = (u64 )temp <<32 ; rc =pci_read_config_dword ( pdev, d +PCI_DVSEC_CXL_RANGE_BASE_LOW (i), &temp);if (rc) -return rc; +return pcibios_err_to_errno (rc); base |= temp &PCI_DVSEC_CXL_MEM_BASE_LOW ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/2077 netfilter: nfnetlink_osf: fix mss parsing on big-endian architectures
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit a625c94144c9b66d32e1f374f909f38db46161c1 ]
The MSS calculation in nf_osf_match_one() manually shifts bytes to construct a 16-bit value before passing it to ntohs().
This works on little-endian hosts but it does not work on big-endian as the bytes are being always shifted and set in the same way for all architectures.
Use get_unaligned_be16() to fix this on big-endian systems. It also simplifies the code.
--- net/netfilter/nfnetlink_osf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/netfilter/nfnetlink_osf.c +1 -5
@@ -95,11 +95,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb,switch (*optp) {case OSFOPT_MSS : - mss = optp[3 ]; - mss <<=8 ; - mss |= optp[2 ]; - - mss =ntohs ((__force __be16 )mss); + mss =get_unaligned_be16 (&optp[2 ]);break ;case OSFOPT_TS :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/2077 netfilter: nfnetlink_cthelper: use {READ,WRITE}_ONCE for accessing helper flags
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit f8bf5edf7157984bb8e288c8b04fdb041223b80c ]
Conntrack helper flags are accessed from packet and netlink dump path. Concurrent update of userspace helper flags is not possible, because the nfnl_mutex in held on updates. These flags are only used by userspace helpers. Use {READ,WRITE}_ONCE() to access this flags from lockless paths.
--- net/netfilter/nf_conntrack_core.c | 4 +++- net/netfilter/nfnetlink_cthelper.c | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-)
net/netfilter/nf_conntrack_core.c +3 -1
@@ -2213,6 +2213,7 @@ static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct, {const struct nf_conntrack_helper *helper;const struct nf_conn_help *help; +unsigned int helper_flags;int protoff; help =nfct_help (ct);
@@ -2223,7 +2224,8 @@ static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct,if (!helper)return NF_ACCEPT ; -if (!(helper->flags &NF_CT_HELPER_F_USERSPACE )) + helper_flags =READ_ONCE (helper->flags); +if (!(helper_flags &NF_CT_HELPER_F_USERSPACE ))return NF_ACCEPT ;switch (nf_ct_l3num (ct)) {
net/netfilter/nfnetlink_cthelper.c +13 -7
@@ -41,8 +41,9 @@ static int nfnl_userspace_cthelper(struct sk_buff *skb, unsigned int protoff, struct nf_conn *ct, enum ip_conntrack_info ctinfo) { - const struct nf_conn_help *help; struct nf_conntrack_helper *helper; +const struct nf_conn_help *help; +unsigned int helper_flags; help =nfct_help (ct);if (help ==NULL )
@@ -53,8 +54,10 @@ nfnl_userspace_cthelper(struct sk_buff *skb, unsigned int protoff,if (helper ==NULL )return NF_DROP ; + helper_flags =READ_ONCE (helper->flags); +/* This is a user-space helper not yet configured, skip. */ -if ((helper->flags & +if ((helper_flags & (NF_CT_HELPER_F_USERSPACE |NF_CT_HELPER_F_CONFIGURED )) ==NF_CT_HELPER_F_USERSPACE )return NF_ACCEPT ;
@@ -404,10 +407,10 @@ nfnl_cthelper_update(const struct nlattr * const tb[],switch (status) {case NFCT_HELPER_STATUS_ENABLED : - helper->flags |=NF_CT_HELPER_F_CONFIGURED ; +WRITE_ONCE (helper->flags, helper->flags |NF_CT_HELPER_F_CONFIGURED );break ;case NFCT_HELPER_STATUS_DISABLED : - helper->flags &= ~NF_CT_HELPER_F_CONFIGURED ; +WRITE_ONCE (helper->flags, helper->flags & ~NF_CT_HELPER_F_CONFIGURED );break ; } }
@@ -529,8 +532,8 @@ static int nfnl_cthelper_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type, int event, struct nf_conntrack_helper *helper) { - struct nlmsghdr *nlh; unsigned int flags = portid ? NLM_F_MULTI : 0; +struct nlmsghdr *nlh;int status; event =nfnl_msg_type (NFNL_SUBSYS_CTHELPER , event);
@@ -554,7 +557,7 @@ nfnl_cthelper_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,if (nla_put_be32 (skb,NFCTH_PRIV_DATA_LEN ,htonl (helper->data_len))) goto nla_put_failure; -if (helper->flags &NF_CT_HELPER_F_CONFIGURED ) +if (READ_ONCE (helper->flags) &NF_CT_HELPER_F_CONFIGURED ) status =NFCT_HELPER_STATUS_ENABLED ;else status =NFCT_HELPER_STATUS_DISABLED ;
@@ -575,6 +578,7 @@ static int nfnl_cthelper_dump_table(struct sk_buff *skb, struct netlink_callback *cb) { struct nf_conntrack_helper *cur, *last; +unsigned int helper_flags;rcu_read_lock (); last = (struct nf_conntrack_helper *)cb->args[1 ];
@@ -583,8 +587,10 @@ nfnl_cthelper_dump_table(struct sk_buff *skb, struct netlink_callback *cb)hlist_for_each_entry_rcu (cur, &nf_ct_helper_hash[cb->args[0 ]], hnode) { + helper_flags =READ_ONCE (cur->flags); +/* skip non-userspace conntrack helpers. */ -if (!(cur->flags &NF_CT_HELPER_F_USERSPACE )) +if (!(helper_flags &NF_CT_HELPER_F_USERSPACE ))continue ;if (cb->args[1 ]) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/2077 netfilter: synproxy: drop packets if timestamp adjustment fails
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 63d29ee95c4ab5976d660182d2e4733bb4a091d8 ]
If a packet was malformed or if skb_ensure_writable() failed, the synproxy_tstamp_adjust() function returned 0 indicating an error but it was ignored on the callers.
Make the function return a boolean instead to clarify the result and drop the packet if synproxy_tstamp_adjust() failed due to ENOMEM from skb_ensure_writable(). In addition, if there are malformed options, skip the tstamp update but do not drop the packet as that should be done by the policy directly.
--- net/netfilter/nf_synproxy_core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
net/netfilter/nf_synproxy_core.c +13 -9
@@ -184,7 +184,7 @@ synproxy_check_timestamp_cookie(struct synproxy_options *opts) opts->options |= opts->tsecr & (1 <<5 ) ?NF_SYNPROXY_OPT_ECN :0 ; } -static unsigned int +static bool synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff, struct tcphdr *th, struct nf_conn *ct, enum ip_conntrack_info ctinfo,
@@ -194,13 +194,13 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,__be32 *ptr, old;if (synproxy->tsoff ==0 ) -return 1 ; +return true; optoff = protoff +sizeof (struct tcphdr ); optend = protoff + th->doff *4 ;if (skb_ensure_writable (skb, optend)) -return 0 ; +return false; th = (struct tcphdr *)(skb->data + protoff);
@@ -209,7 +209,7 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,switch (op[0 ]) {case TCPOPT_EOL : -return 1 ; +return true;case TCPOPT_NOP : optoff++;continue ;
@@ -217,7 +217,7 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,if (optoff +1 == optend || optoff + op[1 ] > optend || op[1 ] <2 ) -return 0 ; +return true;if (op[0 ] ==TCPOPT_TIMESTAMP && op[1 ] ==TCPOLEN_TIMESTAMP ) {if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) {
@@ -233,12 +233,12 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff, }inet_proto_csum_replace4 (&th->check, skb, old, *ptr, false); -return 1 ; +return true; } optoff += op[1 ]; } } -return 1 ; +return true; }#ifdef CONFIG_PROC_FS
@@ -749,7 +749,9 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,break ; } -synproxy_tstamp_adjust (skb, thoff, th, ct, ctinfo, synproxy); +if (!synproxy_tstamp_adjust (skb, thoff, th, ct, ctinfo, synproxy)) +return NF_DROP_REASON (skb,SKB_DROP_REASON_NETFILTER_DROP ,ENOMEM ); +return NF_ACCEPT ; }EXPORT_SYMBOL_GPL (ipv4_synproxy_hook);
@@ -1177,7 +1179,9 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,break ; } -synproxy_tstamp_adjust (skb, thoff, th, ct, ctinfo, synproxy); +if (!synproxy_tstamp_adjust (skb, thoff, th, ct, ctinfo, synproxy)) +return NF_DROP_REASON (skb,SKB_DROP_REASON_NETFILTER_DROP ,ENOMEM ); +return NF_ACCEPT ; }EXPORT_SYMBOL_GPL (ipv6_synproxy_hook);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/2077 netfilter: synproxy: adjust duplicate timestamp options
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 22bb132cfb9b94847d52d73614284b8c5ea8d36e ]
RFC 9293 does not mention anything about duplicated options and each networking stack handles it in their own way. Currently, Linux kernel is processing options sequentially and in case of duplicated timestamp options, the value from the latest one overrides the others.
As SYNPROXY is modifying only the first timestamp option found, a packet can reach the backend server and it might parse the wrong timestamp value. Let's just continue parsing the following options and in case a duplicated timestamp is found, adjust it too.
--- net/netfilter/nf_synproxy_core.c | 1 - 1 file changed, 1 deletion(-)
net/netfilter/nf_synproxy_core.c +0 -1
@@ -233,7 +233,6 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff, }inet_proto_csum_replace4 (&th->check, skb, old, *ptr, false); -return true; } optoff += op[1 ]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/2077 netfilter: synproxy: fix unaligned memory access in timestamp adjustment
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 992c20bc8a4aba220c8b95b467d049289778dad6 ]
Use get_unaligned_be32() and put_unaligned_be32() to safely read and write the timestamp fields. This prevents performance degradation due to unaligned memory access or even a crash on strict alignment architectures.
This follows the implementation of timestamp parsing in the networking stack at tcp_parse_options() and synproxy_parse_options().
--- net/netfilter/nf_synproxy_core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
net/netfilter/nf_synproxy_core.c +9 -10
@@ -191,7 +191,7 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff, const struct nf_conn_synproxy *synproxy) {unsigned int optoff, optend; -__be32 *ptr, old; +u32 new, old;if (synproxy->tsoff ==0 )return true;
@@ -221,18 +221,17 @@ synproxy_tstamp_adjust(struct sk_buff *skb, unsigned int protoff,if (op[0 ] ==TCPOPT_TIMESTAMP && op[1 ] ==TCPOLEN_TIMESTAMP ) {if (CTINFO2DIR (ctinfo) ==IP_CT_DIR_REPLY ) { - ptr = (__be32 *)&op[2 ]; - old = *ptr; - *ptr =htonl (ntohl (*ptr) - - synproxy->tsoff); + old =get_unaligned_be32 (&op[2 ]); + new = old - synproxy->tsoff; +put_unaligned_be32 (new, &op[2 ]); }else { - ptr = (__be32 *)&op[6 ]; - old = *ptr; - *ptr =htonl (ntohl (*ptr) + - synproxy->tsoff); + old =get_unaligned_be32 (&op[6 ]); + new = old + synproxy->tsoff; +put_unaligned_be32 (new, &op[6 ]); }inet_proto_csum_replace4 (&th->check, skb, - old, *ptr, false); +cpu_to_be32 (old), +cpu_to_be32 (new), false); } optoff += op[1 ]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/2077 netfilter: synproxy: protect nf_ct_seqadj_init() with conntrack lock
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 9e37388b8070afe73d4ab2d973b28593ed65f3ad ]
nf_ct_seqadj_init() is called without holding the ct lock. This can race with nf_ct_seq_adjust() when a connection is in CLOSE state due to an RST or connection reopening. In addition for SYN_RECV state, concurrent processing of packets can trigger nf_ct_seq_adjust() too. These situations create a read/write data race.
As synproxy is the only user of nf_ct_seqadj_init() at the moment, fix this by holding ct->lock inside nf_ct_seqadj_init() until all is done.
--- net/netfilter/nf_conntrack_seqadj.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_seqadj.c +2 -0
@@ -17,12 +17,14 @@ int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,if (off ==0 )return 0 ; +spin_lock_bh (&ct->lock);set_bit (IPS_SEQ_ADJUST_BIT , &ct->status); seqadj =nfct_seqadj (ct); this_way = &seqadj->seq[dir]; this_way->offset_before = off; this_way->offset_after = off; +spin_unlock_bh (&ct->lock);return 0 ; }EXPORT_SYMBOL_GPL (nf_ct_seqadj_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/2077 netfilter: cttimeout: detach dataplane timeout policy and repurpose refcount
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 7d6a9cdb8d3a51d9cfe546a09a518ab3d2671549 ]
Add a refcount for struct nf_ct_timeout which is used by ct extension to set the custom ct timeout policy, this tells us that the ct timeout is being used by a conntrack entry. When the last conntrack entry drops the refcount on the ct timeout, the ct timeout is released.
Remove the refcount for control plane which controls if the ruleset refers to the timeout policy. After this update, it is possible to remove the ct timeout policy from nfnetlink_cttimeout immediately. This is for simplicity not to handle two refcounts on a single object.
Remove nf_queue_nf_hook_drop(): a packet sitting in nfqueue will just hold a reference to the nf_ct_timeout object until packet is reinjected, since this is part of the ct extension, this will be released by the time the conntrack is freed.
nf_ct_untimeout() is still called to clean up in a best effort basis:
the ct timeout on existing entries gets removed when the ct timeout goes away, but as long as the iptables ruleset still refers to the ct timeout through a template, new conntracks may keep attaching it and extend its lifetime until the rule is removed.
nf_ct_untimeout() is not called anymore from module removal path, this is unlikely to find timeouts give module refcount is bumped, and the new refcount already tracks the ct timeout policy use so it is released when unused.
--- include/net/netfilter/nf_conntrack_timeout.h | 27 ++++- net/netfilter/nf_conntrack_core.c | 6 +- net/netfilter/nf_conntrack_timeout.c | 27 ++++- net/netfilter/nfnetlink_cttimeout.c | 112 +++++++++---------- net/netfilter/nft_ct.c | 7 +- net/netfilter/xt_CT.c | 2 +- 6 files changed, 107 insertions(+), 74 deletions(-)
include/net/netfilter/nf_conntrack_timeout.h +25 -2
@@ -12,6 +12,7 @@#define CTNL_TIMEOUT_NAME_MAX 32struct nf_ct_timeout { +refcount_t refcnt;__u16 l3num;const struct nf_conntrack_l4proto *l4proto;struct rcu_head rcu;
@@ -22,6 +23,22 @@ struct nf_conn_timeout {struct nf_ct_timeout __rcu *timeout; }; +static inline void nf_ct_timeout_put (const struct nf_conn *ct) +{ +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT +struct nf_conn_timeout *timeout_ext; +struct nf_ct_timeout *timeout; + + timeout_ext =nf_ct_ext_find (ct,NF_CT_EXT_TIMEOUT ); +if (!timeout_ext) +return ; + + timeout =rcu_dereference (timeout_ext->timeout); +if (timeout &&refcount_dec_and_test (&timeout->refcnt)) +kfree_rcu (timeout, rcu); +#endif +} +static inline unsigned int *nf_ct_timeout_data (const struct nf_conn_timeout *t) {
@@ -56,8 +73,14 @@ struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct,#ifdef CONFIG_NF_CONNTRACK_TIMEOUT struct nf_conn_timeout *timeout_ext; +if (!timeout) +return NULL ; + timeout_ext =nf_ct_ext_add (ct,NF_CT_EXT_TIMEOUT , gfp); -if (timeout_ext ==NULL ) +if (!timeout_ext || timeout_ext->timeout) +return NULL ; + +if (!refcount_inc_not_zero (&timeout->refcnt))return NULL ;rcu_assign_pointer (timeout_ext->timeout, timeout);
@@ -75,7 +98,7 @@ static inline unsigned int *nf_ct_timeout_lookup(const struct nf_conn *ct)struct nf_conn_timeout *timeout_ext; timeout_ext =nf_ct_timeout_find (ct); -if (timeout_ext) +if (timeout_ext &&rcu_access_pointer (timeout_ext->timeout)) timeouts =nf_ct_timeout_data (timeout_ext);#endif return timeouts;
net/netfilter/nf_conntrack_core.c +4 -2
@@ -1737,16 +1737,18 @@ void nf_conntrack_free(struct nf_conn *ct)*/ WARN_ON (refcount_read (&ct->ct_general.use) !=0 ); +rcu_read_lock ();if (ct->status &IPS_SRC_NAT_DONE ) {const struct nf_nat_hook *nat_hook; -rcu_read_lock (); nat_hook =rcu_dereference (nf_nat_hook);if (nat_hook) nat_hook->remove_nat_bysrc (ct); -rcu_read_unlock (); } +nf_ct_timeout_put (ct); +rcu_read_unlock (); +kfree (ct->ext);kmem_cache_free (nf_conntrack_cachep, ct); cnet =nf_ct_pernet (net);
net/netfilter/nf_conntrack_timeout.c +24 -3
@@ -25,17 +25,32 @@const struct nf_ct_timeout_hooks __rcu *nf_ct_timeout_hook__read_mostly ;EXPORT_SYMBOL_GPL (nf_ct_timeout_hook); +/* nf_ct_iterate_cleanup() holds the conntrack lock. */ static int untimeout (struct nf_conn *ct,void *timeout) {struct nf_conn_timeout *timeout_ext =nf_ct_timeout_find (ct);if (timeout_ext) { -const struct nf_ct_timeout *t; +struct nf_ct_timeout *t; - t =rcu_access_pointer (timeout_ext->timeout); +rcu_read_lock (); + t =rcu_dereference (timeout_ext->timeout); +if (!t) { +rcu_read_unlock (); +return 0 ; + } -if (!timeout || t == timeout) +if (!timeout || t == timeout) {RCU_INIT_POINTER (timeout_ext->timeout,NULL ); + +/* No race with nf_conntrack_free() which is called +* only after the conntrack has been removed from +* the hashes. +*/ +if (refcount_dec_and_test (&t->refcnt)) +kfree_rcu (t, rcu); + } +rcu_read_unlock (); }/* We are not intended to delete this conntrack. */
@@ -70,6 +85,8 @@ int nf_ct_set_timeout(struct net *net, struct nf_conn *ct,const char *errmsg =NULL ;int ret =0 ; +WARN_ON_ONCE (!nf_ct_is_template (ct)); +rcu_read_lock (); h =rcu_dereference (nf_ct_timeout_hook);if (!h) {
@@ -127,6 +144,8 @@ void nf_ct_destroy_timeout(struct nf_conn *ct)struct nf_conn_timeout *timeout_ext;const struct nf_ct_timeout_hooks *h; +WARN_ON_ONCE (!nf_ct_is_template (ct)); +rcu_read_lock (); h =rcu_dereference (nf_ct_timeout_hook);
@@ -139,6 +158,8 @@ void nf_ct_destroy_timeout(struct nf_conn *ct)if (t) h->timeout_put (t);RCU_INIT_POINTER (timeout_ext->timeout,NULL ); +if (t &&refcount_dec_and_test (&t->refcnt)) +kfree_rcu (t, rcu); } }rcu_read_unlock ();
net/netfilter/nfnetlink_cttimeout.c +50 -62
219 lines not on this page · raw message
net/netfilter/nft_ct.c +3 -4
@@ -897,8 +897,6 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj, } } -rcu_assign_pointer (timeout->timeout, priv->timeout); -/* adjust the timeout as per 'new' state. ct is unconfirmed, * so the current timestamp must not be added. */
@@ -949,6 +947,7 @@ static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx, timeout->l3num = l3num; timeout->l4proto = l4proto; +refcount_set (&timeout->refcnt,1 ); ret =nf_ct_netns_get (ctx->net, ctx->family);if (ret <0 )
@@ -969,10 +968,10 @@ static void nft_ct_timeout_obj_destroy(const struct nft_ctx *ctx,struct nft_ct_timeout_obj *priv =nft_obj_data (obj);struct nf_ct_timeout *timeout = priv->timeout; -nf_queue_nf_hook_drop (ctx->net);nf_ct_untimeout (ctx->net, timeout);nf_ct_netns_put (ctx->net, ctx->family); -kfree_rcu (priv->timeout, rcu); +if (refcount_dec_and_test (&timeout->refcnt)) +kfree_rcu (priv->timeout, rcu); } static int nft_ct_timeout_obj_dump(struct sk_buff *skb,
net/netfilter/xt_CT.c +1 -1
@@ -284,7 +284,7 @@ static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par,struct nf_conn_help *help;if (ct) { -if (info->helper[0 ] || info->timeout[0 ]) +if (info->helper[0 ])nf_queue_nf_hook_drop (par->net); help =nfct_help (ct);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/2077 ALSA: usb-audio: qcom: Initialize offload control return value
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 2b5632d72fca0841bea283da2e3a478d24118508 ]
snd_usb_offload_create_ctl() returns ret after walking the USB PCM list, but ret is only assigned after a playback stream passes the endpoint and PCM-index filters.
If all playback streams are skipped, for example because there is no playback endpoint or because all PCM indexes exceed the 0xff control range, the function returns an uninitialized stack value.
Initialize ret to 0 so the no-control-created path returns deterministic success, while preserving the existing negative error return when snd_ctl_add() fails.
--- sound/usb/qcom/mixer_usb_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/qcom/mixer_usb_offload.c +1 -1
@@ -113,7 +113,7 @@ int snd_usb_offload_create_ctl(struct snd_usb_audio *chip, struct device *bedev)struct snd_usb_substream *subs;struct snd_usb_stream *as;char ctl_name[48 ]; -int ret; +int ret =0 ;list_for_each_entry (as, &chip->pcm_list, list) { subs = &as->substream[SNDRV_PCM_STREAM_PLAYBACK ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/2077 mm/slub: preserve original size in _kmalloc_nolock_noprof retry path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengming Hu <[email protected]>
[ Upstream commit 19b206b9534a85266efa78febeb4ae185e75bccd ]
_kmalloc_nolock_noprof() retries from the next kmalloc bucket when the initial allocation fails. The retry currently reuses size as the bucket selector and overwrites it with s->object_size + 1.
That value is later passed as the original allocation size to __slab_alloc_node(), slab_post_alloc_hook() and kasan_kmalloc(). On a successful retry this makes KASAN/slub-debug observe the retry bucket selector rather than the caller requested size, potentially widening the valid kmalloc range and hiding overflows.
Keep the caller requested size separately as orig_size and pass it to the allocation/debug/KASAN paths. Continue using size as the retry cache selector.
--- mm/slub.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
mm/slub.c +4 -3
@@ -5325,6 +5325,7 @@ EXPORT_SYMBOL(__kmalloc_noprof);void *kmalloc_nolock_noprof (size_t size,gfp_t gfp_flags,int node) {gfp_t alloc_gfp = __GFP_NOWARN | __GFP_NOMEMALLOC | gfp_flags; +size_t orig_size = size;struct kmem_cache *s;bool can_retry = true;void *ret;
@@ -5373,7 +5374,7 @@ void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node)* kfence_alloc. Hence call __slab_alloc_node() (at most twice) * and slab_post_alloc_hook() directly. */ - ret =__slab_alloc_node (s, alloc_gfp, node, _RET_IP_, size); + ret =__slab_alloc_node (s, alloc_gfp, node, _RET_IP_, orig_size);/* * It's possible we failed due to trylock as we preempted someone with
@@ -5397,9 +5398,9 @@ void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node) success:maybe_wipe_obj_freeptr (s, ret);slab_post_alloc_hook (s,NULL , alloc_gfp,1 , &ret, -slab_want_init_on_alloc (alloc_gfp, s), size); +slab_want_init_on_alloc (alloc_gfp, s), orig_size); - ret =kasan_kmalloc (s, ret, size, alloc_gfp); + ret =kasan_kmalloc (s, ret, orig_size, alloc_gfp);return ret; }EXPORT_SYMBOL_GPL (kmalloc_nolock_noprof);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/2077 x86/cpu: Remove obsolete aperfmperf_get_khz() declaration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxiao Chang <[email protected]>
[ Upstream commit a5f28da54f36f1a8b289d9bdd3e780b2ede0da6f ]
aperfmperf_get_khz() was replaced by arch_freq_get_on_cpu(). The remaining declaration in the header file is no longer used and should be removed.
--- arch/x86/kernel/cpu/cpu.h | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/cpu.h +0 -1
@@ -75,7 +75,6 @@ static inline struct amd_northbridge *amd_init_l3_cache(int index) }#endif -unsigned int aperfmperf_get_khz (int cpu);void cpu_select_mitigations (void );extern void x86_spec_ctrl_setup_ap (void );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/2077 netfilter: conntrack: revert ct extension genid infrastructure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 35e21a4dccc5c255ba59ccfbfeb4629ed21da972 ]
This infrastructure is not used anymore after moving ct timeout and helper to use datapath refcount to track object use.
Revert commit c56716c69ce1 ("netfilter: extensions: introduce extension genid count") this patch disables all ct extensions (leading to NULL) for unconfirmed conntracks, when this is only targeted at ct helper and ct timeout. There is also codebase that dereferences the ct extension without checking for NULL which could lead to crash.
--- include/net/netfilter/nf_conntrack_extend.h | 12 ---- net/netfilter/nf_conntrack_core.c | 61 +-------------------- net/netfilter/nf_conntrack_extend.c | 32 +---------- 3 files changed, 2 insertions(+), 103 deletions(-)
include/net/netfilter/nf_conntrack_extend.h +0 -12
@@ -38,7 +38,6 @@ enum nf_ct_ext_id {struct nf_ct_ext {u8 offset[NF_CT_EXT_NUM ];u8 len; -unsigned int gen_id;char data[]__aligned(8) ; };
@@ -52,8 +51,6 @@ static inline bool nf_ct_ext_exist(const struct nf_conn *ct, u8 id)return (ct->ext &&__nf_ct_ext_exist (ct->ext, id)); } -void *__nf_ct_ext_find (const struct nf_ct_ext *ext,u8 id); -static inline void *nf_ct_ext_find (const struct nf_conn *ct,u8 id) {struct nf_ct_ext *ext = ct->ext;
@@ -61,19 +58,10 @@ static inline void *nf_ct_ext_find(const struct nf_conn *ct, u8 id)if (!ext || !__nf_ct_ext_exist (ext, id))return NULL ; -if (unlikely (ext->gen_id)) -return __nf_ct_ext_find (ext, id); - return (void *)ct->ext + ct->ext->offset[id]; }/* Add this type, returns pointer to data or NULL. */ void *nf_ct_ext_add (struct nf_conn *ct,enum nf_ct_ext_id id,gfp_t gfp); -/* ext genid. if ext->id != ext_genid, extensions cannot be used -* anymore unless conntrack has CONFIRMED bit set. -*/ -extern atomic_t nf_conntrack_ext_genid; -void nf_ct_ext_bump_genid (void ); -#endif /* _NF_CONNTRACK_EXTEND_H */
net/netfilter/nf_conntrack_core.c +1 -60
101 lines not on this page · raw message
net/netfilter/nf_conntrack_extend.c +1 -31
@@ -27,8 +27,6 @@#define NF_CT_EXT_PREALLOC 128u/* conntrack events are on by default */ -atomic_t nf_conntrack_ext_genid__read_mostly =ATOMIC_INIT (1 ); -static const u8 nf_ct_ext_type_len[NF_CT_EXT_NUM ] = { [NF_CT_EXT_HELPER ] =sizeof (struct nf_conn_help ), #if IS_ENABLED(CONFIG_NF_NAT)
@@ -118,10 +116,8 @@ void *nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)if (!new)return NULL ; -if (!ct->ext) { +if (!ct->ext)memset (new->offset,0 ,sizeof (new->offset)); - new->gen_id =atomic_read (&nf_conntrack_ext_genid); - } new->offset[id] = newoff; new->len = newlen;
@@ -131,29 +127,3 @@ void *nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)return (void *)new + newoff; }EXPORT_SYMBOL (nf_ct_ext_add); - -/* Use nf_ct_ext_find wrapper. This is only useful for unconfirmed entries. */ -void *__nf_ct_ext_find (const struct nf_ct_ext *ext,u8 id) -{ -unsigned int gen_id =atomic_read (&nf_conntrack_ext_genid); -unsigned int this_id =READ_ONCE (ext->gen_id); - -if (!__nf_ct_ext_exist (ext, id)) -return NULL ; - -if (this_id ==0 || ext->gen_id == gen_id) -return (void *)ext + ext->offset[id]; - -return NULL ; -} -EXPORT_SYMBOL (__nf_ct_ext_find); - -void nf_ct_ext_bump_genid (void ) -{ -unsigned int value =atomic_inc_return (&nf_conntrack_ext_genid); - -if (value ==UINT_MAX ) -atomic_set (&nf_conntrack_ext_genid,1 ); - -msleep (HZ ); -}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/2077 netfilter: conntrack: call nf_ct_gre_keymap_destroy() if master helper is pptp
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b0f02608fbcd607b5131cceb91fc0a035264e61c ]
For GRE flows, validate that the ct master helper (if any) is pptp before calling nf_ct_gre_keymap_destroy(), so the helper data area can be accessed safely. Note that only the pptp helper provides a .destroy callback.
--- net/netfilter/nf_conntrack_core.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_core.c +16 -2
@@ -562,9 +562,23 @@ static void destroy_gre_conntrack(struct nf_conn *ct) {#ifdef CONFIG_NF_CT_PROTO_GRE struct nf_conn *master = ct->master; +struct nf_conn_help *help; + +if (!master) +return ; + + help =nfct_help (master); +if (help) { +struct nf_conntrack_helper *helper; -if (master) -nf_ct_gre_keymap_destroy (master); +rcu_read_lock (); + helper =rcu_dereference (help->helper); +/* Only pptp helper has a destroy callback. */ +if (helper && helper->destroy) +nf_ct_gre_keymap_destroy (master); + +rcu_read_unlock (); + }#endif }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/2077 ntfs: free link name from ntfs_name_cache
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: DaeMyung Kang <[email protected]>
[ Upstream commit 8488c4d066e6a52937fa5d82ab131c7554ddc9d8 ]
ntfs_link() converts the new link name with ntfs_nlstoucs() using NTFS_MAX_NAME_LEN. In this case ntfs_nlstoucs() allocates the result from ntfs_name_cache, and its contract requires callers to release the buffer with kmem_cache_free(ntfs_name_cache, ...).
All other ntfs_nlstoucs() callers in namei.c do that, but ntfs_link() uses kfree(), which mismatches the allocator for successfully converted names.
The conversion failure path reaches the common out label with uname == NULL. That was harmless for kfree(), but kmem_cache_free() does not provide the same NULL contract. Return directly on conversion failure and free successful conversions with ntfs_name_cache.
--- fs/ntfs/namei.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ntfs/namei.c +2 -3
@@ -1532,8 +1532,7 @@ static int ntfs_link(struct dentry *old_dentry, struct inode *dir,if (uname_len <0 ) {if (uname_len != -ENAMETOOLONG )ntfs_error (sb,"Failed to convert name to unicode." ); - err = -ENOMEM ; - goto out; +return -ENOMEM ; }if (!(vol->vol_flags &VOLUME_IS_DIRTY ))
@@ -1563,7 +1562,7 @@ static int ntfs_link(struct dentry *old_dentry, struct inode *dir,mutex_unlock (&ni->mrec_lock); out: -kfree (uname); +kmem_cache_free (ntfs_name_cache, uname);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/2077 RDMA/hfi1: Open-code rvt_set_ibdev_name()
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 0ee8ac903e5aa100a70bef8d0afc19a336ffa775 ]
clang warns about a function missing a printf attribute:
include/rdma/rdma_vt.h:457:47: error: diagnostic behavior may be improved by adding the 'format(printf, 2, 3)' attribute to the declaration of 'rvt_set_ibdev_name' [-Werror,-Wmissing-format-attribute]
447 | static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi,
| __attribute__((format(printf, 2, 3)))
448 | const char *fmt, const char *name,
449 | const int unit)The helper was originally added as an abstraction for the hfi1 and qib drivers needing the same thing, but now qib is gone, and hfi1 is the only remaining user of rdma_vt.
Avoid the warning and allow the compiler to check the format string by open-coding the helper and directly assigning the device name.
--- drivers/infiniband/hw/hfi1/init.c | 13 ++++++++++++- include/rdma/rdma_vt.h | 20 -------------------- 2 files changed, 12 insertions(+), 21 deletions(-)
drivers/infiniband/hw/hfi1/init.c +12 -1
@@ -1206,6 +1206,7 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra) {struct hfi1_devdata *dd; +struct ib_device *ibdev;int ret, nports;/* extra is * number of ports */
@@ -1227,7 +1228,17 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, "Could not allocate unit ID: error %d\n", -ret); goto bail; } -rvt_set_ibdev_name (&dd->verbs_dev.rdi,"%s_%d" ,class_name (), dd->unit); + +/* +* FIXME: rvt and its users want to touch the ibdev before +* registration and have things like the name work. We don't have the +* infrastructure in the core to support this directly today, hack it +* to work by setting the name manually here. +*/ + ibdev = &dd->verbs_dev.rdi.ibdev; +dev_set_name (&ibdev->dev,"%s_%d" ,class_name (), dd->unit); +strscpy (ibdev->name,dev_name (&ibdev->dev),IB_DEVICE_NAME_MAX ); +/* * If the BIOS does not have the NUMA node information set, select * NUMA 0 so we get consistent performance.
include/rdma/rdma_vt.h +0 -20
@@ -438,26 +438,6 @@ struct rvt_dev_info {struct rvt_wss *wss; }; -/** -* rvt_set_ibdev_name - Craft an IB device name from client info -* @rdi: pointer to the client rvt_dev_info structure -* @name: client specific name -* @unit: client specific unit number. -*/ -static inline void rvt_set_ibdev_name (struct rvt_dev_info *rdi, -const char *fmt,const char *name, -const int unit) -{ -/* -* FIXME: rvt and its users want to touch the ibdev before -* registration and have things like the name work. We don't have the -* infrastructure in the core to support this directly today, hack it -* to work by setting the name manually here. -*/ -dev_set_name (&rdi->ibdev.dev, fmt, name, unit); -strscpy (rdi->ibdev.name,dev_name (&rdi->ibdev.dev),IB_DEVICE_NAME_MAX ); -} -/** * rvt_get_ibdev_name - return the IB name * @rdi: rdmavt device
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/2077 IB/cm: Fix av cm device leak on an error path in cm_init_av_by_path()
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 9b2207bc5cdb955bdae34b3eec80f04979e17081 ]
Codex pointed out that cm_init_av_by_path() can call cm_set_av_port() which takes a reference on the cm device, but then can immediately return error if ib_init_ah_attr_from_path() fails.
Since callers like ib_send_cm_req() put the av on the stack this leaks that cm device reference.
Re-order cm_init_av_by_path() so it doesn't touch the av until it has done all its failable work, and then update the av in one shot so it is either left alone or fully init'd.
Sashiko also pointed out that the cm_destroy_av() prior to cm_init_av_by_path() is harmful as it leaves the AV broken in the error case and thus the REJ won't send. Since cm_init_av_by_path() is now atomic it is safe to delete the cm_destroy_av(). On succees the av from cm_init_av_for_response() is cleaned up by cm_init_av_by_path(), on failure the 'goto rejected' guarentees the av is destroyed during ib_destroy_cm_id().
--- drivers/infiniband/core/cm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/infiniband/core/cm.c +8 -5
@@ -530,6 +530,7 @@ static int cm_init_av_by_path(struct sa_path_rec *path,struct rdma_ah_attr new_ah_attr;struct cm_device *cm_dev;struct cm_port *port; +u16 pkey_index;int ret; port =get_cm_port_from_path (path, sgid_attr);
@@ -538,12 +539,10 @@ static int cm_init_av_by_path(struct sa_path_rec *path, cm_dev = port->cm_dev; ret =ib_find_cached_pkey (cm_dev->ib_device, port->port_num, -be16_to_cpu (path->pkey), &av->pkey_index); +be16_to_cpu (path->pkey), &pkey_index);if (ret)return ret; -cm_set_av_port (av, port); -/* * av->ah_attr might be initialized based on wc or during * request processing time which might have reference to sgid_attr.
@@ -558,6 +557,8 @@ static int cm_init_av_by_path(struct sa_path_rec *path,if (ret)return ret; + av->pkey_index = pkey_index; +cm_set_av_port (av, port); av->timeout = path->packet_life_time +1 ;rdma_move_ah_attr (&av->ah_attr, &new_ah_attr);return 0 ;
@@ -2184,8 +2185,10 @@ static int cm_req_handler(struct cm_work *work) cm_id_priv->av.ah_attr.roce.dmac); work->path[0 ].hop_limit = grh->hop_limit; -/* This destroy call is needed to pair with cm_init_av_for_response */ -cm_destroy_av (&cm_id_priv->av); +/* +* cm_init_av_by_path() will internally pair with the above +* cm_init_av_for_response() if it succeeds. +*/ ret =cm_init_av_by_path (&work->path[0 ], gid_attr, &cm_id_priv->av);if (ret) {int err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/2077 ALSA: hda: fix Kconfig dependency of HD Audio PCI
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
[ Upstream commit 1516134cb65526aba5319bb446c296fc8a192f84 ]
With commit 2d9223d2d64c ("ALSA: hda: Move controller drivers into sound/hda/controllers directory") the HD Audio drivers have been moved from linux/sound/pci/hda to linux/sound/hda.
But the Kconfig dependency for SND_HDA_INTEL stayed on SND_PCI instead of depending on PCI directly. To make the "HD Audio PCI" configuration entry visible it is currently needed to enable "PCI sound devices" although no PCI device in the submenu needs to be selected.
Make SND_HDA_INTEL directly depending on hardware/architecture like the other entries in this Kconfig.
--- sound/hda/controllers/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/controllers/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config SND_HDA_INTEL tristate "HD Audio PCI" - depends on SND_PCI + depends on PCI select SND_HDA select SND_INTEL_DSP_CONFIG help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/2077 RDMA/irdma: Fix OOB read during CQ MR registration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 4385ddd654d90245eeb83b3cb539670ab5c85ba4 ]
Sashiko pointed out an unrelated bug during a previous patch:
https://sashiko.dev/#/patchset/20260512183852.614045-1-jmoroni%40google.com
This change fixes the bug by eliminating the cqmr->split field which was not being set properly and instead just checks the CQ resize feature flag directly.
The cqmr->split field essentially tracks whether IRDMA_FEATURE_CQ_RESIZE is set, but it was not being set until CQ creation time, which is _after_ CQ memory registration (the only other place where it is referenced).
As a result, it would always be false during MR registration and would therefore cause irdma_handle_q_mem to populate cqmr->shadow even for GEN_2 HW and beyond:
cqmr->shadow = (dma_addr_t)arr[req->cq_pages];
The issue is that for GEN_2 and beyond, req->cq_pages may be exactly equal to iwmr->page_cnt and therefore equal to the size of arr, which would cause an OOB read by one.
--- drivers/infiniband/hw/irdma/verbs.c | 4 ++-- drivers/infiniband/hw/irdma/verbs.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +2 -2
@@ -2572,7 +2572,6 @@ static int irdma_create_cq(struct ib_cq *ibcq, } cqmr_shadow = &iwpbl_shadow->cq_mr; info.shadow_area_pa = cqmr_shadow->cq_pbl.addr; - cqmr->split = true; }else { info.shadow_area_pa = cqmr->shadow; }
@@ -2980,7 +2979,8 @@ static int irdma_handle_q_mem(struct irdma_device *iwdev,case IRDMA_MEMREG_TYPE_CQ : hmc_p = &cqmr->cq_pbl; -if (!cqmr->split) +if (!(iwdev->rf->sc_dev.hw_attrs.uk_attrs.feature_flags & +IRDMA_FEATURE_CQ_RESIZE )) cqmr->shadow = (dma_addr_t )arr[req->cq_pages];if (lvl)
drivers/infiniband/hw/irdma/verbs.h +0 -1
@@ -65,7 +65,6 @@ struct irdma_hmc_pble {struct irdma_cq_mr {struct irdma_hmc_pble cq_pbl;dma_addr_t shadow; -bool split; };struct irdma_srq_mr {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/2077 RDMA/irdma: Initialize iwmr->access during MR registration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 1521d560b7a1a39e437d37fffd9b55435d329ad1 ]
Initialize iwmr->access during initial user mem registration so that it contains a valid value during a subsequent rereg_mr.
Otherwise, a rereg_mr that doesn't set IB_MR_REREG_ACCESS (for example, one that only changes the PD) ends up clearing the access flags in HW since iwmr->access is zero-initialized, which is not intended.
--- drivers/infiniband/hw/irdma/verbs.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/irdma/verbs.c +1 -0
@@ -3325,6 +3325,7 @@ static int irdma_reg_user_mr_type_mem(struct irdma_mr *iwmr, int access,int err; lvl = iwmr->page_cnt !=1 ?PBLE_LEVEL_1 |PBLE_LEVEL_2 :PBLE_LEVEL_0 ; + iwmr->access = access; err =irdma_setup_pbles (iwdev->rf, iwmr, lvl);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/2077 arm64: dts: imx8mp-kontron: Reduce EERAM SPI clock frequency
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frieder Schrempf <[email protected]>
[ Upstream commit 95f5bc1632ab8f243e517357b5da0dd28d1c6c92 ]
There is an onboard level shifter for the SPI signals that causes additional propagation delay and renders the SPI transmission unreliable at 20 MHz. Reduce the clock frequency to a safe value.
--- arch/arm64/boot/dts/freescale/imx8mp-kontron-bl-osm-s.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mp-kontron-bl-osm-s.dts +1 -1
@@ -63,7 +63,7 @@ &ecspi2 { eeram@0 { compatible = "microchip,48l640"; reg = <0>; - spi-max-frequency = <20000000>; + spi-max-frequency = <16000000>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/2077 arm64: dts: imx94: fix DDR PMU interrupt number
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Guo <[email protected]>
[ Upstream commit 2521addd5df7e8ab805622d4a0eff9735a45fa11 ]
The DDR Performance Monitor node was added with incorrect interrupt number 91, which actually belongs to the wdog4 watchdog. Fix it to the correct interrupt number 374.
--- arch/arm64/boot/dts/freescale/imx94.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx94.dtsi +1 -1
@@ -1481,7 +1481,7 @@ netc_emdio: mdio@18,0 { ddr-pmu@4e090dc0 { compatible = "fsl,imx94-ddr-pmu", "fsl,imx93-ddr-pmu"; reg = <0x0 0x4e090dc0 0x0 0x200>; - interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 374 IRQ_TYPE_LEVEL_HIGH>; }; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/2077 arm64: dts: imx95: Correct PCIe outbound address space configuration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
[ Upstream commit dbecf38e60d4ef08c59836b7bc16e8efca01fc47 ]
Fix the PCIe outbound memory ranges for both pcie0 and pcie1 controllers on i.MX95.
The memory window size was incorrectly set to 256MB during initial bring-up, but the hardware supports up to 4GB of outbound address space per controller.
Additionally, the ECAM region cannot be mapped as I/O space. Use a memory-mapped region for I/O space instead, and relocate the 1MB I/O region to immediately follow the memory region at offset 0xf0000000 within each window.
Update the outbound address space layout per controller as follows:
- 3.5GB 64-bit prefetchable memory - 256MB 32-bit non-prefetchable memory - 1MB I/O
--- arch/arm64/boot/dts/freescale/imx95.dtsi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/freescale/imx95.dtsi +6 -4
@@ -1852,8 +1852,9 @@ pcie0: pcie@4c300000 { <0 0x4c360000 0 0x10000>, <0 0x4c340000 0 0x4000>; reg-names = "dbi", "config", "atu", "app"; - ranges = <0x81000000 0x0 0x00000000 0x0 0x6ff00000 0 0x00100000>, - <0x82000000 0x0 0x10000000 0x9 0x10000000 0 0x10000000>; + ranges = <0x43000000 0x9 0x00000000 0x9 0x00000000 0x0 0xe0000000>, + <0x82000000 0x0 0xe0000000 0x9 0xe0000000 0x0 0x10000000>, + <0x81000000 0x0 0x00000000 0x9 0xf0000000 0x0 0x00100000>; #address-cells = <3>; #size-cells = <2>; device_type = "pci";
@@ -1927,8 +1928,9 @@ pcie1: pcie@4c380000 { <0 0x4c3e0000 0 0x10000>, <0 0x4c3c0000 0 0x4000>; reg-names = "dbi", "config", "atu", "app"; - ranges = <0x81000000 0 0x00000000 0x8 0x8ff00000 0 0x00100000>, - <0x82000000 0 0x10000000 0xa 0x10000000 0 0x10000000>; + ranges = <0x43000000 0xa 0x00000000 0xa 0x00000000 0x0 0xe0000000>, + <0x82000000 0x0 0xe0000000 0xa 0xe0000000 0x0 0x10000000>, + <0x81000000 0x0 0x00000000 0xa 0xf0000000 0x0 0x00100000>; #address-cells = <3>; #size-cells = <2>; device_type = "pci";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/2077 arm64: dts: lx2162a-clearfog: use rev2 SoC dtsi
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josua Mayer <[email protected]>
[ Upstream commit 13a37b30e464503515625ba891018aec0264c7d2 ]
LX2160A and LX2162A are different packages of the same silicon. While LX2160A had two revisions, LX2162A was released later based on LX2160A revision 2.
Commit a8fe6c8dfc40 ("arm64: dts: fsl-lx2160a: add rev2 support") has added a new soc dtsi for revision 2.
Update LX2162A Clearfog description to use revision 2 dtsi.
--- arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/fsl-lx2162a-clearfog.dts +1 -1
@@ -6,7 +6,7 @@ /dts-v1/; -#include "fsl-lx2160a.dtsi" +#include "fsl-lx2160a-rev2.dtsi" #include "fsl-lx2162a-sr-som.dtsi" / {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/2077 arm64: dts: tqma8mpql-mba8mpxl: configure sai clock in audio codec as well
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
[ Upstream commit 748835fcb2eb2120234aef9556d282272501b96b ]
With deferrable card binding the sound card driver tries to get the mclk configuration before it is setup in sai3 node. Fix this by setting the sai clock config for the audio codec as well.
--- arch/arm64/boot/dts/freescale/imx8mp-tqma8mpql-mba8mpxl.dts | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/freescale/imx8mp-tqma8mpql-mba8mpxl.dts +3 -0
@@ -609,6 +609,9 @@ tlv320aic3x04: audio-codec@18 { reset-gpios = <&gpio4 29 GPIO_ACTIVE_LOW>; iov-supply = <®_vcc_1v8>; ldoin-supply = <®_vcc_3v3>; + assigned-clocks = <&clk IMX8MP_CLK_SAI3>; + assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>; + assigned-clock-rates = <12288000>; }; se97_1c: temperature-sensor@1c {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/2077 arm64: dts: imx8mp-kontron: Fix GPIO for display power switch
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frieder Schrempf <[email protected]>
[ Upstream commit 5b19ca527471903920d713bc48518a036a95bf6b ]
The GPIO that controls the power supply for the LVDS display connector has changed between early prototypes and the current production design of the hardware. Reflect this change in the devicetree to properly switch on the panel supply.
This was working before even with the wrong GPIO due to the bidirectional level shifter used on the board which drives the EN signal high even when the input has a (weak) pull down configured as reset condition of the SoC pad. As a result the display was working but the supply was always on.
Tested on BL i.MX8MP to show the correct voltage level on the level shifter input.
--- .../boot/dts/freescale/imx8mp-kontron-bl-osm-s.dts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8mp-kontron-bl-osm-s.dts +10 -2
@@ -49,7 +49,9 @@ pwm-beeper { reg_vcc_panel: regulator-vcc-panel { compatible = "regulator-fixed"; - gpio = <&gpio4 3 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_reg_vcc_panel>; + gpio = <&gpio5 3 GPIO_ACTIVE_HIGH>; enable-active-high; regulator-max-microvolt = <3300000>; regulator-min-microvolt = <3300000>;
@@ -172,7 +174,7 @@ &gpio4 { &gpio5 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gpio5>; - gpio-line-names = "I2S_BITCLK", "I2S_A_DATA_OUT", "I2S_MCLK", "PWM_2", + gpio-line-names = "I2S_BITCLK", "I2S_A_DATA_OUT", "I2S_MCLK", "VCC_PANEL_EN", "PWM_1", "PWM_0", "SPI_A_SCK", "CAN_ADDR1", "CAN_ADDR0", "SPI_A_CS0", "SPI_B_SCK", "SPI_B_SDO", "SPI_B_SDI", "SPI_B_CS0", "I2C_A_SCL", "I2C_A_SDA",
@@ -329,4 +331,10 @@ MX8MP_IOMUXC_ECSPI1_MOSI__GPIO5_IO07 0x46 /* CAN_ADR0 */ MX8MP_IOMUXC_ECSPI1_MISO__GPIO5_IO08 0x46 /* CAN_ADR1 */ >; }; + + pinctrl_reg_vcc_panel: regvccpanelgrp { + fsl,pins = < + MX8MP_IOMUXC_SPDIF_TX__GPIO5_IO03 0x46 + >; + }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/2077 arm64: dts: freescale: fsl-ls1028a-tqmls1028a-mbls1028a: switch mmc aliases
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nora Schiffer <[email protected]>
[ Upstream commit 08886fa69c0f56f886b63d7835da0632ea4082f7 ]
All modern TQ-Systems boards follow the convention that mmc0 is the eMMC and mmc1 is the SD-card when both interfaces exist, reducing differences between boards for both documentation and U-Boot code (which uses the same Device Trees). Adjust the recently added MBLS1028A Device Tree accordingly.
--- .../boot/dts/freescale/fsl-ls1028a-tqmls1028a-mbls1028a.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/fsl-ls1028a-tqmls1028a-mbls1028a.dtsi +2 -2
@@ -17,8 +17,8 @@ aliases { gpio0 = &gpio1; gpio1 = &gpio2; gpio2 = &gpio3; - mmc0 = &esdhc; /* SD-Card */ - mmc1 = &esdhc1; /* eMMC */ + mmc0 = &esdhc1; /* eMMC */ + mmc1 = &esdhc; /* SD-Card */ serial0 = &duart0; serial1 = &duart1; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/2077 RDMA/siw: Fix endpoint/socket association handling
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bernard Metzler <[email protected]>
[ Upstream commit ea4f6f6c53577fb3f05dbd78b15e586772d49831 ]
Disassociating a socket from an endpoint via siw_socket_disassoc() may release the last reference on that endpoint and free it. Therefore, don't clear the endpoints socket pointer after calling that function, but within.
This fixes a:
BUG: KASAN: slab-use-after-free in siw_cm_work_handler (drivers/infiniband/sw/siw/siw_cm.c:1053 drivers/infiniband/sw/siw/siw_cm.c:1075)
which occurred after processing a malformed MPA request during connection establishment, causing the new endpoint to be closed.
--- drivers/infiniband/sw/siw/siw_cm.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +15 -15
@@ -138,6 +138,7 @@ static void siw_socket_disassoc(struct socket *s) cep =sk_to_cep (sk);if (cep) {siw_sk_restore_upcalls (sk, cep); + cep->sock =NULL ;siw_cep_put (cep); }else {pr_warn ("siw: cannot restore sk callbacks: no ep\n" );
@@ -418,10 +419,11 @@ static void siw_free_cm_id(struct siw_cep *cep)static void siw_destroy_cep_sock (struct siw_cep *cep) { -if (cep->sock) { -siw_socket_disassoc (cep->sock); -sock_release (cep->sock); - cep->sock =NULL ; +struct socket *s = cep->sock; + +if (s) { +siw_socket_disassoc (s); +sock_release (s); } }
@@ -1050,7 +1052,6 @@ static void siw_accept_newconn(struct siw_cep *cep)if (new_s) {siw_socket_disassoc (new_s);sock_release (new_s); - new_cep->sock =NULL ; }siw_dbg_cep (cep,"error %d\n" , rv); }
@@ -1202,6 +1203,8 @@ static void siw_cm_work_handler(struct work_struct *w)WARN (1 ,"Undefined CM work type: %d\n" , work->type); }if (release_cep) { +struct socket *s = cep->sock; + siw_dbg_cep(cep, "release: timer=%s, QP[%u]\n", cep->mpa_timer ? "y" : "n",
@@ -1227,10 +1230,9 @@ static void siw_cm_work_handler(struct work_struct *w) cep->qp =NULL ;siw_qp_put (qp); } -if (cep->sock) { -siw_socket_disassoc (cep->sock); -sock_release (cep->sock); - cep->sock =NULL ; +if (s) { +siw_socket_disassoc (s); +sock_release (s); }if (cep->cm_id) {siw_free_cm_id (cep);
@@ -1561,7 +1563,6 @@ int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params)if (cep) {siw_socket_disassoc (s);sock_release (s); - cep->sock =NULL ; cep->qp =NULL ;
@@ -1937,7 +1938,6 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)siw_cep_set_inuse (cep);siw_free_cm_id (cep); - cep->sock =NULL ;siw_socket_disassoc (s); cep->state =SIW_EPSTATE_CLOSED ;
@@ -1959,6 +1959,7 @@ static void siw_drop_listeners(struct iw_cm_id *id)*/ list_for_each_safe (p, tmp, (struct list_head *)id->provider_data) { struct siw_cep *cep = list_entry(p, struct siw_cep, listenq); +struct socket *s = cep->sock;list_del (p);
@@ -1967,10 +1968,9 @@ static void siw_drop_listeners(struct iw_cm_id *id)siw_cep_set_inuse (cep);siw_free_cm_id (cep); -if (cep->sock) { -siw_socket_disassoc (cep->sock); -sock_release (cep->sock); - cep->sock =NULL ; +if (s) { +siw_socket_disassoc (s); +sock_release (s); } cep->state =SIW_EPSTATE_CLOSED ;siw_cep_set_free_and_put (cep);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/2077 selftests/bpf: Fix flaky file_reader test
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 aa22d619ba22177f430693cf5e9495052d996644 ]
file_reader/on_open_expect_fault test expects page fault when reading pages from the test harness executable. It is not guaranteed that those are paged out, even after madvise(MADV_PAGEOUT).
Relax the condition in the test to succeed with both 0 and -EFAULT returned.
--- tools/testing/selftests/bpf/progs/file_reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/file_reader.c +1 -1
@@ -50,7 +50,7 @@ int on_open_expect_fault(void *c) goto out; local_err =bpf_dynptr_read (tmp_buf, user_buf_sz, &dynptr, user_buf_sz,0 ); -if (local_err == -EFAULT ) {/* Expect page fault */ +if (local_err == -EFAULT || local_err ==0 ) {/* Expect page fault or success */ local_err =0 ; run_success =1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/2077 bpf: Clear rb node linkage when freeing bpf_rb_root
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaitao Cheng <[email protected]>
[ Upstream commit 4a7910ee060d8ce55612f5b3cc267f3a265a3cec ]
bpf_rb_root_free() detaches the root by copying the current rb_root_cached and then replacing the live root with RB_ROOT_CACHED. It then walks the copied root and drops each object contained in the tree.
This leaves the rb node state intact while dropping the object. If the object is refcounted and survives the drop, its bpf_rb_node_kern still contains an owner pointer to the freed root and stale rb tree linkage. If a later bpf_rb_root allocation reuses the same address, bpf_rbtree_remove() can incorrectly pass the owner check and call rb_erase_cached() on a node whose rb pointers belong to the old tree.
Mirror the list draining behavior by marking nodes as busy while the root is being detached, then clear the rb node and release the owner before dropping the containing object. This makes surviving nodes unowned and safe to reject from remove or accept for a later add.
--- kernel/bpf/helpers.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/bpf/helpers.c +9 -2
@@ -2295,6 +2295,7 @@ void bpf_rb_root_free(const struct btf_field *field, void *rb_root, struct bpf_spin_lock *spin_lock) {struct rb_root_cached orig_root, *root = rb_root; +struct bpf_rb_node_kern *node;struct rb_node *pos, *n;void *obj;
@@ -2303,14 +2304,20 @@ void bpf_rb_root_free(const struct btf_field *field, void *rb_root,__bpf_spin_lock_irqsave (spin_lock); orig_root = *root; +bpf_rbtree_postorder_for_each_entry_safe (pos, n, &orig_root.rb_root) { + node = rb_entry(pos, struct bpf_rb_node_kern, rb_node); +WRITE_ONCE (node->owner,BPF_PTR_POISON ); + } *root =RB_ROOT_CACHED ;__bpf_spin_unlock_irqrestore (spin_lock);bpf_rbtree_postorder_for_each_entry_safe (pos, n, &orig_root.rb_root) { obj = pos; obj -= field->graph_root.node_offset; - - + node = rb_entry(pos, struct bpf_rb_node_kern, rb_node); +RB_CLEAR_NODE (pos); +/* Ensure __bpf_rbtree_add() sees the node as unlinked. */ +smp_store_release (&node->owner,NULL );__bpf_obj_drop_impl (obj, field->graph_root.value_rec, false); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/2077 bpf: Check tail zero of bpf_map_info
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit e2a49fdb1beed150125b4104c90eb2a96ec7f63a ]
Since there're 4 bytes padding at the end of struct bpf_map_info, they won't be checked by bpf_check_uarg_tail_zero().
pahole -C bpf_map_info ./vmlinux
struct bpf_map_info {
...
__u64 hash __attribute__((__aligned__(8))); /* 88 8 */
__u32 hash_size; /* 96 4 */
/* size: 104, cachelines: 2, members: 18 */
/* padding: 4 */
/* forced alignments: 1 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));If a future kernel extension adds a new 4-byte field, older userspace programs allocating this structure on the stack might inadvertently pass uninitialized stack garbage into the new field, permanently breaking backward compatibility. -- sashiko [1]
Fix it by changing sizeof(info) tooffsetofend(struct bpf_map_info, hash_size).
And, add "__u32 :32" to the tail of struct bpf_map_info.
[1] https://lore.kernel.org/bpf/[email protected]/
--- include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 5 +++-- tools/include/uapi/linux/bpf.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
include/uapi/linux/bpf.h +1 -0
@@ -6719,6 +6719,7 @@ struct bpf_map_info {__u64 map_extra;__aligned_u64 hash;__u32 hash_size; + __u32 :32 ; } __attribute__((aligned(8)));struct bpf_btf_info {
kernel/bpf/syscall.c +3 -2
@@ -5337,10 +5337,11 @@ static int bpf_map_get_info_by_fd(struct file *file, {struct bpf_map_info __user *uinfo =u64_to_user_ptr (attr->info.info);struct bpf_map_info info; -u32 info_len = attr->info.info_len; +u32 info_len = attr->info.info_len, len;int err; - err =bpf_check_uarg_tail_zero (USER_BPFPTR (uinfo),sizeof (info), info_len); + len = offsetofend(struct bpf_map_info, hash_size); + err =bpf_check_uarg_tail_zero (USER_BPFPTR (uinfo), len, info_len);if (err)return err; info_len =min_t (u32,sizeof (info), info_len);
tools/include/uapi/linux/bpf.h +1 -0
@@ -6719,6 +6719,7 @@ struct bpf_map_info {__u64 map_extra;__aligned_u64 hash;__u32 hash_size; + __u32 :32 ; } __attribute__((aligned(8)));struct bpf_btf_info {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/2077 bpf: Check tail zero of bpf_prog_info
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 786be2b05980a5828e67fc564ad7517e2adbe9bd ]
Since there're 4 bytes padding at the end of struct bpf_prog_info, they won't be checked by bpf_check_uarg_tail_zero().
pahole -C bpf_prog_info ./vmlinux
struct bpf_prog_info {
...
__u32 attach_btf_obj_id; /* 220 4 */
__u32 attach_btf_id; /* 224 4 */
/* size: 232, cachelines: 4, members: 38 */
/* sum members: 224 */
/* sum bitfield members: 1 bits, bit holes: 1, sum bit holes: 31 bits */
/* padding: 4 */
/* forced alignments: 9 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));If a future kernel extension adds a new 4-byte field, older userspace programs allocating this structure on the stack might inadvertently pass uninitialized stack garbage into the new field, permanently breaking backward compatibility. -- sashiko [1]
Fix it by changing sizeof(info) tooffsetofend(struct bpf_prog_info, attach_btf_id).
And, add "__u32 :32" to the tail of struct bpf_prog_info.
[1] https://lore.kernel.org/bpf/[email protected]/
--- include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 5 +++-- tools/include/uapi/linux/bpf.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
include/uapi/linux/bpf.h +1 -0
@@ -6698,6 +6698,7 @@ struct bpf_prog_info {__u32 verified_insns;__u32 attach_btf_obj_id;__u32 attach_btf_id; + __u32 :32 ; } __attribute__((aligned(8)));struct bpf_map_info {
kernel/bpf/syscall.c +3 -2
@@ -5052,10 +5052,11 @@ static int bpf_prog_get_info_by_fd(struct file *file,u32 info_len = attr->info.info_len;struct bpf_prog_kstats stats;char __user *uinsns; -u32 ulen; +u32 ulen, len;int err; - err =bpf_check_uarg_tail_zero (USER_BPFPTR (uinfo),sizeof (info), info_len); + len = offsetofend(struct bpf_prog_info, attach_btf_id); + err =bpf_check_uarg_tail_zero (USER_BPFPTR (uinfo), len, info_len);if (err)return err; info_len =min_t (u32,sizeof (info), info_len);
tools/include/uapi/linux/bpf.h +1 -0
@@ -6698,6 +6698,7 @@ struct bpf_prog_info {__u32 verified_insns;__u32 attach_btf_obj_id;__u32 attach_btf_id; + __u32 :32 ; } __attribute__((aligned(8)));struct bpf_map_info {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/2077 bpf: Update transport_header when encapsulating UDP tunnel in lwt
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 82d7d0adbc678064543e9d254864f6b4ea4a388c ]
Currently, bpf_lwt_push_ip_encap() does not update skb->transport_header. When a driver, e.g. ice, reuses the stale skb->transport_header to offload checksum computation to NIC hardware, VxLAN packets encapsulated by bpf_lwt_push_encap() helper may be dropped due to incorrect checksum.
Update skb->transport_header in bpf_lwt_push_ip_encap() whenever the encapsulated packet uses UDP, so checksum offload works correctly.
--- net/core/lwt_bpf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/core/lwt_bpf.c +12 -0
@@ -599,6 +599,7 @@ static int handle_gso_encap(struct sk_buff *skb, bool ipv4, int encap_len)int bpf_lwt_push_ip_encap (struct sk_buff *skb,void *hdr,u32 len,bool ingress) { +bool is_udp_tunnel;struct iphdr *iph;bool ipv4;int err;
@@ -612,10 +613,16 @@ int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress) ipv4 = true;if (unlikely (len < iph->ihl *4 ))return -EINVAL ; + is_udp_tunnel = iph->protocol ==IPPROTO_UDP ; +if (unlikely (is_udp_tunnel && len < iph->ihl *4 +sizeof (struct udphdr ))) +return -EINVAL ; }else if (iph->version ==6 ) { ipv4 = false;if (unlikely (len <sizeof (struct ipv6hdr )))return -EINVAL ; + is_udp_tunnel = ((struct ipv6hdr *)iph)->nexthdr ==NEXTHDR_UDP ; +if (unlikely (is_udp_tunnel && len <sizeof (struct ipv6hdr ) +sizeof (struct udphdr ))) +return -EINVAL ; }else {return -EINVAL ; }
@@ -637,6 +644,11 @@ int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress)if (ingress)skb_postpush_rcsum (skb, iph, len);skb_reset_network_header (skb); +if (is_udp_tunnel) { +size_t iph_sz = ipv4 ? iph->ihl *4 :sizeof (struct ipv6hdr ); + +skb_set_transport_header (skb,skb_network_offset (skb) + iph_sz); + }memcpy (skb_network_header (skb), hdr, len);bpf_compute_data_pointers (skb);skb_clear_hash (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/2077 kernfs: fix xattr race condition with multiple superblocks
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 6a07814ff643b5c8e1353d8c6229f52fde205cde ]
Multiple superblocks with different namespaces can share the same kernfs_node when kernfs_test_super() finds a matching root but different namespace. This means multiple inodes from different superblocks can reference the same kernfs_node->iattr->xattrs structure.
The VFS layer only holds per-inode locks during xattr operations, which is insufficient to serialize concurrent xattr modifications on the shared kernfs_node. This can lead to race conditions in simple_xattr_set() where the lookup->replace/remove sequence is not atomic with respect to operations from other superblocks.
Fix this by protecting xattr operations with the existing hashed kernfs_locks->open_file_mutex[] array, which is already used to protect per-node open file data. The hashed mutex array provides scalable per-node serialization (scaled by CPU count, up to 1024 locks on 32+ CPU systems) with zero memory overhead.
Changes:
- Rename open_file_mutex[] to node_mutex[] to reflect dual purpose
- Add kernfs_node_lock_ptr() and kernfs_node_lock() helpers
- Protect simple_xattr_set() calls in kernfs_xattr_set() and kernfs_vfs_user_xattr_set() with the hashed mutex
- Update file.c to use new helpers via compatibility wrappers
- Update documentation to explain the extended lock usage
--- fs/kernfs/file.c | 13 +++---------- fs/kernfs/inode.c | 12 ++++++++++++ fs/kernfs/kernfs-internal.h | 20 ++++++++++++++++++++ fs/kernfs/mount.c | 2 +- include/linux/kernfs.h | 11 ++++++++--- 5 files changed, 44 insertions(+), 14 deletions(-)
fs/kernfs/file.c +3 -10
@@ -40,22 +40,15 @@ struct kernfs_open_node {static DEFINE_SPINLOCK (kernfs_notify_lock);static struct kernfs_node *kernfs_notify_list =KERNFS_NOTIFY_EOL ; +/* Compatibility wrappers - use the common hashed node lock */ static inline struct mutex *kernfs_open_file_mutex_ptr (struct kernfs_node *kn) { -int idx =hash_ptr (kn,NR_KERNFS_LOCK_BITS ); - -return &kernfs_locks->open_file_mutex[idx]; +return kernfs_node_lock_ptr (kn); }static inline struct mutex *kernfs_open_file_mutex_lock (struct kernfs_node *kn) { -struct mutex *lock; - - lock =kernfs_open_file_mutex_ptr (kn); - -mutex_lock (lock); - -return lock; +return kernfs_node_lock (kn); }/**
fs/kernfs/inode.c +12 -0
@@ -320,6 +320,15 @@ int kernfs_xattr_set(struct kernfs_node *kn, const char *name,if (!attrs)return -ENOMEM ; +/* +* Protect xattr modifications with the hashed per-node mutex. +* Multiple superblocks (with different namespaces) can share the same +* kernfs_node, so inode locking alone is insufficient. The hashed mutex +* ensures serialization of concurrent xattr operations on the same node, +* including the lazy allocation of the xattrs structure itself. +*/ +CLASS (kernfs_node_lock, lock)(kn); + xattrs =simple_xattrs_lazy_alloc (&attrs->xattrs, value, flags);if (IS_ERR_OR_NULL (xattrs))return PTR_ERR (xattrs);
@@ -372,6 +381,9 @@ static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler,if (!attrs)return -ENOMEM ; +/* See comment in kernfs_xattr_set() about locking. */ +CLASS (kernfs_node_lock, lock)(kn); + xattrs =simple_xattrs_lazy_alloc (&attrs->xattrs, value, flags);if (IS_ERR_OR_NULL (xattrs))return PTR_ERR (xattrs);
fs/kernfs/kernfs-internal.h +20 -0
@@ -211,4 +211,24 @@ extern const struct inode_operations kernfs_symlink_iops;* kernfs locks */ extern struct kernfs_global_locks *kernfs_locks; + +/* Hashed mutex helpers - protect per-node data structures */ +static inline struct mutex *kernfs_node_lock_ptr (struct kernfs_node *kn) +{ +int idx =hash_ptr (kn,NR_KERNFS_LOCK_BITS ); + +return &kernfs_locks->node_mutex[idx]; +} + +static inline struct mutex *kernfs_node_lock (struct kernfs_node *kn) +{ +struct mutex *lock =kernfs_node_lock_ptr (kn); + +mutex_lock (lock); +return lock; +} + +DEFINE_CLASS(kernfs_node_lock, struct mutex *, + mutex_unlock(_T), kernfs_node_lock(kn), struct kernfs_node *kn) +#endif /* __KERNFS_INTERNAL_H */
fs/kernfs/mount.c +1 -1
@@ -446,7 +446,7 @@ static void __init kernfs_mutex_init(void)int count;for (count =0 ; count <NR_KERNFS_LOCKS ; count++) -mutex_init (&kernfs_locks->open_file_mutex[count]); +mutex_init (&kernfs_locks->node_mutex[count]); }static void __init kernfs_lock_init (void )
include/linux/kernfs.h +8 -3
@@ -76,20 +76,25 @@ struct kernfs_iattrs;* kernfs_open_file. * * kernfs_open_files are chained at kernfs_open_node->files, which is -* protected by kernfs_global_locks.open_file_mutex[i]. +* protected by kernfs_global_locks.node_mutex[i]. * * To reduce possible contention in sysfs access, arising due to single -* locks, use an array of locks (e.g. open_file_mutex) and use kernfs_node +* locks, use an array of locks (e.g. node_mutex) and use kernfs_node * object address as hash keys to get the index of these locks. * * Hashed mutexes are safe to use here because operations using these don't * rely on global exclusion. * +* The hashed mutex array protects per-node data: the kernfs_open_node for +* open file management, and kernfs_node xattr operations (necessary because +* multiple superblocks with different namespaces can share the same +* kernfs_node, making per-inode locking insufficient). +* * In future we intend to replace other global locks with hashed ones as well. * kernfs_global_locks acts as a holder for all such hash tables. */ struct kernfs_global_locks { -struct mutex open_file_mutex[NR_KERNFS_LOCKS ]; +struct mutex node_mutex[NR_KERNFS_LOCKS ]; };enum kernfs_node_type {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/2077 tmpfs: simplify constructing "security.foo" xattr names
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 832f4de4c8ba4f19e5df1d016a09917204b17834 ]
Use kasprintf() instead of doing it with kmalloc() + 2 x memcpy().
Stable-dep-of: 1e7cd8a53b72 ("simpe_xattr: use per-sb cache")
--- mm/shmem.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
mm/shmem.c +2 -9
@@ -4232,7 +4232,6 @@ static int shmem_initxattrs(struct inode *inode,struct shmem_sb_info *sbinfo =SHMEM_SB (inode->i_sb);const struct xattr *xattr;size_t ispace =0 ; -size_t len;CLASS (simple_xattrs, xattrs)();if (IS_ERR (xattrs))
@@ -4260,17 +4259,11 @@ static int shmem_initxattrs(struct inode *inode,if (IS_ERR (new_xattr))break ; - len =strlen (xattr->name) +1 ; - new_xattr->name =kmalloc (XATTR_SECURITY_PREFIX_LEN + len, -GFP_KERNEL_ACCOUNT ); + new_xattr->name =kasprintf (GFP_KERNEL_ACCOUNT , +XATTR_SECURITY_PREFIX "%s" , xattr->name);if (!new_xattr->name)break ; -memcpy (new_xattr->name,XATTR_SECURITY_PREFIX , -XATTR_SECURITY_PREFIX_LEN ); -memcpy (new_xattr->name +XATTR_SECURITY_PREFIX_LEN , - xattr->name, len); -if (simple_xattr_add (xattrs, new_xattr))break ;retain_and_null_ptr (new_xattr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/2077 simple_xattr: change interface to pass struct simple_xattrs **
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 076e5cef28e27febfc09b5f72544d2b857c75201 ]
Change the simple_xattr API to accept pointer-to-pointer (struct simple_xattrs **) instead of pointer. This allows the functions to handle lazy allocation internally without requiring callers to use simple_xattrs_lazy_alloc().
The simple_xattr_set(), simple_xattr_set_limited() and simple_xattr_add() functions now handle allocation when xattrs is NULL. simple_xattrs_free() now also frees the xattrs structure itself and sets the pointer to NULL.
This simplifies callers and removes the need for most callers to explicitly manage xattrs allocation and lifetime.
In shmem_initxattrs(), the total required space for all initial xattrs (ispace) is pre-calculated and deducted from sbinfo->free_ispace.
Since this patch modifies the function to add new xattrs directly to the inode's &info->xattrs list rather than using a local temporary variable, a failure means that the partially populated info->xattrs list remains attached to the inode.
When the VFS caller handles the -ENOMEM error, it drops the newly created inode via iput(), shmem_free_inode() adds freed to sbinfo->free_ispace a second time, permanently inflating the tmpfs free space quota.
Fix by substracting already added xattrs from ispace.
Stable-dep-of: 1e7cd8a53b72 ("simpe_xattr: use per-sb cache")
--- fs/kernfs/dir.c | 12 +++-------- fs/kernfs/inode.c | 24 ++++------------------ fs/pidfs.c | 37 ++++++---------------------------- fs/xattr.c | 46 ++++++++++++++++++++++++++++++++++--------- include/linux/xattr.h | 21 ++++++-------------- mm/shmem.c | 34 ++++++++++---------------------- net/socket.c | 24 +++++----------------- 7 files changed, 71 insertions(+), 127 deletions(-)
fs/kernfs/dir.c +3 -9
@@ -608,11 +608,8 @@ void kernfs_put(struct kernfs_node *kn)if (kernfs_type (kn) ==KERNFS_LINK )kernfs_put (kn->symlink.target_kn); -if (kn->iattr && kn->iattr->xattrs) { -simple_xattrs_free (kn->iattr->xattrs,NULL ); -kfree (kn->iattr->xattrs); - kn->iattr->xattrs =NULL ; - } +if (kn->iattr) +simple_xattrs_free (&kn->iattr->xattrs,NULL );spin_lock (&root->kernfs_idr_lock);idr_remove (&root->ino_idr, (u32 )kernfs_ino (kn));
@@ -712,10 +709,7 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, err_out4:if (kn->iattr) { -if (kn->iattr->xattrs) { -simple_xattrs_free (kn->iattr->xattrs,NULL ); -kfree (kn->iattr->xattrs); - } +simple_xattrs_free (&kn->iattr->xattrs,NULL );kmem_cache_free (kernfs_iattrs_cache, kn->iattr); } err_out3:
fs/kernfs/inode.c +4 -20
@@ -144,8 +144,7 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)if (!attrs)return -ENOMEM ; -return simple_xattr_list (d_inode (dentry),READ_ONCE (attrs->xattrs), - buf, size); +return simple_xattr_list (d_inode (dentry), &attrs->xattrs, buf, size); }static inline void set_default_inode_attr (struct inode *inode,umode_t mode)
@@ -297,23 +296,17 @@ 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_xattrs *xattrs;if (!attrs)return -ENODATA ; - xattrs =READ_ONCE (attrs->xattrs); -if (!xattrs) -return -ENODATA ; - -return simple_xattr_get (xattrs, name, value, size); +return simple_xattr_get (&attrs->xattrs, name, value, size); }int kernfs_xattr_set (struct kernfs_node *kn,const char *name,const void *value,size_t size,int flags) {struct simple_xattr *old_xattr; -struct simple_xattrs *xattrs;struct kernfs_iattrs *attrs; attrs =kernfs_iattrs (kn);
@@ -329,11 +322,7 @@ int kernfs_xattr_set(struct kernfs_node *kn, const char *name,*/ CLASS (kernfs_node_lock, lock)(kn); - xattrs =simple_xattrs_lazy_alloc (&attrs->xattrs, value, flags); -if (IS_ERR_OR_NULL (xattrs)) -return PTR_ERR (xattrs); - - old_xattr =simple_xattr_set (xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (&attrs->xattrs, name, value, size, flags);if (IS_ERR (old_xattr))return PTR_ERR (old_xattr);
@@ -371,7 +360,6 @@ static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler, {const char *full_name =xattr_full_name (handler, suffix);struct kernfs_node *kn = inode->i_private; -struct simple_xattrs *xattrs;struct kernfs_iattrs *attrs;if (!(kernfs_root (kn)->flags &KERNFS_ROOT_SUPPORT_USER_XATTR ))
@@ -384,11 +372,7 @@ 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); - xattrs =simple_xattrs_lazy_alloc (&attrs->xattrs, value, flags); -if (IS_ERR_OR_NULL (xattrs)) -return PTR_ERR (xattrs); - -return simple_xattr_set_limited (xattrs, &attrs->xattr_limits, +return simple_xattr_set_limited (&attrs->xattrs, &attrs->xattr_limits, full_name, value, size, flags); }
fs/pidfs.c +6 -31
@@ -196,12 +196,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) { -struct simple_xattrs *xattrs = attr->xattrs; - -if (xattrs) { -simple_xattrs_free (xattrs,NULL ); -kfree (xattrs); - } +simple_xattrs_free (&attr->xattrs,NULL );kfree (attr); } }
@@ -815,14 +810,8 @@ static ssize_t pidfs_listxattr(struct dentry *dentry, char *buf, size_t size) {struct inode *inode =d_inode (dentry);struct pid *pid = inode->i_private; -struct pidfs_attr *attr = pid->attr; -struct simple_xattrs *xattrs; - - xattrs =READ_ONCE (attr->xattrs); -if (!xattrs) -return 0 ; -return simple_xattr_list (inode, xattrs, buf, size); +return simple_xattr_list (inode, &pid->attr->xattrs, buf, size); }static const struct inode_operations pidfs_inode_operations = {
@@ -1057,16 +1046,9 @@ static int pidfs_xattr_get(const struct xattr_handler *handler, const char *suffix, void *value, size_t size) { struct pid *pid = inode->i_private; -struct pidfs_attr *attr = pid->attr; -const char *name; -struct simple_xattrs *xattrs; - - xattrs =READ_ONCE (attr->xattrs); -if (!xattrs) -return -ENODATA ; +const char *name =xattr_full_name (handler, suffix); - name =xattr_full_name (handler, suffix); -return simple_xattr_get (xattrs, name, value, size); +return simple_xattr_get (&pid->attr->xattrs, name, value, size); } static int pidfs_xattr_set(const struct xattr_handler *handler,
@@ -1075,20 +1057,13 @@ static int pidfs_xattr_set(const struct xattr_handler *handler, const void *value, size_t size, int flags) { struct pid *pid = inode->i_private; -struct pidfs_attr *attr = pid->attr; -const char *name; -struct simple_xattrs *xattrs; +const char *name =xattr_full_name (handler, suffix);struct simple_xattr *old_xattr;/* Ensure we're the only one to set @attr->xattrs. */ WARN_ON_ONCE (!inode_is_locked (inode)); - xattrs =simple_xattrs_lazy_alloc (&attr->xattrs, value, flags); -if (IS_ERR_OR_NULL (xattrs)) -return PTR_ERR (xattrs); - - name =xattr_full_name (handler, suffix); - old_xattr =simple_xattr_set (xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (&pid->attr->xattrs, name, value, size, flags);if (IS_ERR (old_xattr))return PTR_ERR (old_xattr);
fs/xattr.c +37 -9
127 lines not on this page · raw message
include/linux/xattr.h +6 -15
@@ -133,26 +133,23 @@ static inline void simple_xattr_limits_init(struct simple_xattr_limits *limits) }int simple_xattrs_init (struct simple_xattrs *xattrs); -struct simple_xattrs *simple_xattrs_alloc (void ); -struct simple_xattrs *simple_xattrs_lazy_alloc (struct simple_xattrs **xattrsp, -const void *value,int flags); -void simple_xattrs_free (struct simple_xattrs *xattrs,size_t *freed_space); +void simple_xattrs_free (struct simple_xattrs **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, +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, +struct simple_xattr *simple_xattr_set (struct simple_xattrs **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_xattrs **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 simple_xattrs **xattrs,char *buffer,size_t size); -int simple_xattr_add (struct simple_xattrs *xattrs, +int simple_xattr_add (struct simple_xattrs **xattrs,struct simple_xattr *new_xattr);int xattr_list_one (char **buffer,ssize_t *remaining_size,const char *name);
@@ -162,10 +159,4 @@ DEFINE_CLASS(simple_xattr, simple_xattr_alloc(value, size), const void *value, size_t size) -DEFINE_CLASS (simple_xattrs, - struct simple_xattrs *, - if (!IS_ERR_OR_NULL(_T)) { simple_xattrs_free(_T, NULL); kfree(_T); }, -simple_xattrs_alloc (), - void) -#endif /* _LINUX_XATTR_H */
mm/shmem.c +10 -24
@@ -1425,10 +1425,8 @@ static void shmem_evict_inode(struct inode *inode) } } -if (info->xattrs) { -simple_xattrs_free (info->xattrs, sbinfo->max_inodes ? &freed :NULL ); -kfree (info->xattrs); - } +simple_xattrs_free (&info->xattrs, sbinfo->max_inodes ? &freed :NULL ); +shmem_free_inode (inode->i_sb, freed);WARN_ON (inode->i_blocks);clear_inode (inode);
@@ -4233,10 +4231,6 @@ static int shmem_initxattrs(struct inode *inode,const struct xattr *xattr;size_t ispace =0 ; -CLASS (simple_xattrs, xattrs)(); -if (IS_ERR (xattrs)) -return PTR_ERR (xattrs); -if (sbinfo->max_inodes) {for (xattr = xattr_array; xattr->name !=NULL ; xattr++) { ispace += simple_xattr_space(xattr->name,
@@ -4264,8 +4258,11 @@ static int shmem_initxattrs(struct inode *inode,if (!new_xattr->name)break ; -if (simple_xattr_add (xattrs, new_xattr)) +if (simple_xattr_add (&info->xattrs, new_xattr))break ; + +if (sbinfo->max_inodes) + ispace -=simple_xattr_space (new_xattr->name, new_xattr->size);retain_and_null_ptr (new_xattr); }
@@ -4277,8 +4274,8 @@ static int shmem_initxattrs(struct inode *inode, }return -ENOMEM ; } +WARN_ON (ispace); -smp_store_release (&info->xattrs,no_free_ptr (xattrs));return 0 ; }
@@ -4287,14 +4284,9 @@ static int shmem_xattr_handler_get(const struct xattr_handler *handler, const char *name, void *buffer, size_t size) { struct shmem_inode_info *info = SHMEM_I(inode); -struct simple_xattrs *xattrs; - - xattrs =READ_ONCE (info->xattrs); -if (!xattrs) -return -ENODATA ; name =xattr_full_name (handler, name); -return simple_xattr_get (xattrs, name, buffer, size); +return simple_xattr_get (&info->xattrs, name, buffer, size); } static int shmem_xattr_handler_set(const struct xattr_handler *handler,
@@ -4305,16 +4297,11 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler, {struct shmem_inode_info *info =SHMEM_I (inode);struct shmem_sb_info *sbinfo =SHMEM_SB (inode->i_sb); -struct simple_xattrs *xattrs;struct simple_xattr *old_xattr;size_t ispace =0 ; name =xattr_full_name (handler, name); - xattrs =simple_xattrs_lazy_alloc (&info->xattrs, value, flags); -if (IS_ERR_OR_NULL (xattrs)) -return PTR_ERR (xattrs); -if (value && sbinfo->max_inodes) { ispace =simple_xattr_space (name, size);raw_spin_lock (&sbinfo->stat_lock);
@@ -4327,7 +4314,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,return -ENOSPC ; } - old_xattr =simple_xattr_set (xattrs, name, value, size, flags); + old_xattr =simple_xattr_set (&info->xattrs, name, value, size, flags);if (!IS_ERR (old_xattr)) { ispace =0 ;if (old_xattr && sbinfo->max_inodes)
@@ -4375,8 +4362,7 @@ static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size) {struct shmem_inode_info *info =SHMEM_I (d_inode (dentry)); -return simple_xattr_list (d_inode (dentry),READ_ONCE (info->xattrs), - buffer, size); +return simple_xattr_list (d_inode (dentry), &info->xattrs, buffer, size); }#endif /* CONFIG_TMPFS_XATTR */
net/socket.c +5 -19
@@ -347,12 +347,8 @@ static struct inode *sock_alloc_inode(struct super_block *sb)static void sock_evict_inode (struct inode *inode) {struct sockfs_inode *si =SOCKFS_I (inode); -struct simple_xattrs *xattrs = si->xattrs; -if (xattrs) { -simple_xattrs_free (xattrs,NULL ); -kfree (xattrs); - } +simple_xattrs_free (&si->xattrs,NULL );clear_inode (inode); }
@@ -443,13 +439,9 @@ static int sockfs_user_xattr_get(const struct xattr_handler *handler, const char *suffix, void *value, size_t size) { const char *name = xattr_full_name(handler, suffix); -struct simple_xattrs *xattrs; - - xattrs =READ_ONCE (SOCKFS_I (inode)->xattrs); -if (!xattrs) -return -ENODATA ; +struct sockfs_inode *si =SOCKFS_I (inode); -return simple_xattr_get (xattrs, name, value, size); +return simple_xattr_get (&si->xattrs, name, value, size); } static int sockfs_user_xattr_set(const struct xattr_handler *handler,
@@ -460,13 +452,8 @@ 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); -struct simple_xattrs *xattrs; - - xattrs =simple_xattrs_lazy_alloc (&si->xattrs, value, flags); -if (IS_ERR_OR_NULL (xattrs)) -return PTR_ERR (xattrs); -return simple_xattr_set_limited (xattrs, &si->xattr_limits, +return simple_xattr_set_limited (&si->xattrs, &si->xattr_limits, name, value, size, flags); }
@@ -635,8 +622,7 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,struct sockfs_inode *si =SOCKFS_I (d_inode (dentry));ssize_t len, used; - len =simple_xattr_list (d_inode (dentry),READ_ONCE (si->xattrs), - buffer, size); + len =simple_xattr_list (d_inode (dentry), &si->xattrs, buffer, size);if (len <0 )return len;
Signature · 1 line
2.53.0