6.1.178-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 595/1067 netfilter: ipset: Fix data race between add and dump in all hash types
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jozsef Kadlecsik <[email protected]>
[ Upstream commit 2358f7427ccd6ec8867a48205d8fcec973683a3f ]
When adding a new entry to the next position in the existing hash bucket, the position index was incremented too early and parallel dump could read it before the entry was populated with the value. Move the setting of the position index after populating the entry.
v2: Position counting fixed, noticed by Florian Westphal.
Stable-dep-of: e4b4984e28c1 ("netfilter: ipset: Don't use test_bit() in lockless RCU readers in hash types")
--- net/netfilter/ipset/ip_set_hash_gen.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/netfilter/ipset/ip_set_hash_gen.h +5 -2
@@ -831,7 +831,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,const struct mtype_elem *d = value;struct mtype_elem *data;struct hbucket *n, *old =ERR_PTR (-ENOENT ); -int i, j =-1 , ret; +int i, j =-1 , npos =0 , ret;bool flag_exist = flags &IPSET_FLAG_EXIST ;bool deleted = false, forceadd = false, reuse = false;u32 r, key, multi =0 , elements, maxelem;
@@ -876,6 +876,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,ext_size (AHASH_INIT_SIZE , set->dsize); goto copy_elem; } + npos = n->pos;for (i =0 ; i < n->pos; i++) {if (!test_bit (i, n->used)) {/* Reuse first deleted entry */
@@ -949,7 +950,8 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext, } copy_elem: - j = n->pos++; + j = npos; + npos = n->pos +1 ; data =ahash_data (n, j, set->dsize); copy_data: t->hregion[r].elements++;
@@ -972,6 +974,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (SET_WITH_TIMEOUT (set))ip_set_timeout_set (ext_timeout (data, set), ext->timeout);smp_mb__before_atomic (); + n->pos = npos;set_bit (j, n->used);if (old !=ERR_PTR (-ENOENT )) {rcu_assign_pointer (hbucket (t, key), n);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/1067 netfilter: ipset: annotate "pos" for concurrent readers/writers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jozsef Kadlecsik <[email protected]>
[ Upstream commit 7f7445840b7771338618930e45ee641104b38ed8 ]
The "pos" structure member of struct hbucket stores the first free slot in the hash bucket of a hash type of set and there are concurrent readers/writers. Annotate accesses properly.
Stable-dep-of: e4b4984e28c1 ("netfilter: ipset: Don't use test_bit() in lockless RCU readers in hash types")
--- net/netfilter/ipset/ip_set_hash_gen.h | 62 ++++++++++++++++----------- 1 file changed, 38 insertions(+), 24 deletions(-)
net/netfilter/ipset/ip_set_hash_gen.h +38 -24
@@ -373,8 +373,9 @@ static void mtype_ext_cleanup(struct ip_set *set, struct hbucket *n) { int i; +u8 pos =smp_load_acquire (&n->pos); -for (i =0 ; i < n->pos; i++) +for (i =0 ; i < pos; i++)if (test_bit (i, n->used))ip_set_ext_destroy (set,ahash_data (n, i, set->dsize)); }
@@ -477,7 +478,7 @@ mtype_gc_do(struct ip_set *set, struct htype *h, struct htable *t, u32 r)#ifdef IP_SET_HASH_WITH_NETS u8 k;#endif -u8 htable_bits = t->htable_bits; +u8 pos, htable_bits = t->htable_bits;spin_lock_bh (&t->hregion[r].lock); for (i = ahash_bucket_start(r, htable_bits);
@@ -485,7 +486,8 @@ mtype_gc_do(struct ip_set *set, struct htype *h, struct htable *t, u32 r) n =__ipset_dereference (hbucket (t, i));if (!n)continue ; -for (j =0 , d =0 ; j < n->pos; j++) { + pos =smp_load_acquire (&n->pos); +for (j =0 , d =0 ; j < pos; j++) {if (!test_bit (j, n->used)) { d++;continue ;
@@ -521,7 +523,7 @@ mtype_gc_do(struct ip_set *set, struct htype *h, struct htable *t, u32 r)/* Still try to delete expired elements. */ continue ; tmp->size = n->size -AHASH_INIT_SIZE ; -for (j =0 , d =0 ; j < n->pos; j++) { +for (j =0 , d =0 ; j < pos; j++) {if (!test_bit (j, n->used))continue ; data =ahash_data (n, j, dsize);
@@ -610,7 +612,7 @@ mtype_resize(struct ip_set *set, bool retried) {struct htype *h = set->data;struct htable *t, *orig; -u8 htable_bits; +u8 pos, htable_bits;size_t hsize, dsize = set->dsize;#ifdef IP_SET_HASH_WITH_NETS u8 flags;
@@ -672,7 +674,8 @@ mtype_resize(struct ip_set *set, bool retried) n =__ipset_dereference (hbucket (orig, i));if (!n)continue ; -for (j =0 ; j < n->pos; j++) { + pos =smp_load_acquire (&n->pos); +for (j =0 ; j < pos; j++) {if (!test_bit (j, n->used))continue ; data =ahash_data (n, j, dsize);
@@ -796,9 +799,10 @@ mtype_ext_size(struct ip_set *set, u32 *elements, size_t *ext_size) {struct htype *h = set->data;const struct htable *t; -u32 i, j, r;struct hbucket *n;struct mtype_elem *data; +u32 i, j, r; +u8 pos; t =rcu_dereference_bh (h->table);for (r =0 ; r <ahash_numof_locks (t->htable_bits); r++) {
@@ -807,7 +811,8 @@ mtype_ext_size(struct ip_set *set, u32 *elements, size_t *ext_size) n =rcu_dereference_bh (hbucket (t, i));if (!n)continue ; -for (j =0 ; j < n->pos; j++) { + pos =smp_load_acquire (&n->pos); +for (j =0 ; j < pos; j++) {if (!test_bit (j, n->used))continue ; data =ahash_data (n, j, set->dsize);
@@ -831,10 +836,11 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,const struct mtype_elem *d = value;struct mtype_elem *data;struct hbucket *n, *old =ERR_PTR (-ENOENT ); -int i, j =-1 , npos =0 , ret; +int i, j =-1 , ret;bool flag_exist = flags &IPSET_FLAG_EXIST ;bool deleted = false, forceadd = false, reuse = false;u32 r, key, multi =0 , elements, maxelem; +u8 npos =0 ;rcu_read_lock_bh (); t =rcu_dereference_bh (h->table);
@@ -876,8 +882,8 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,ext_size (AHASH_INIT_SIZE , set->dsize); goto copy_elem; } - npos = n->pos; -for (i =0 ; i < n->pos; i++) { + npos =smp_load_acquire (&n->pos); +for (i =0 ; i < npos; i++) {if (!test_bit (i, n->used)) {/* Reuse first deleted entry */ if (j ==-1 ) {
@@ -921,7 +927,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (elements >= maxelem) goto set_full;/* Create a new slot */ -if (n->pos >= n->size) { +if (npos >= n->size) {#ifdef IP_SET_HASH_WITH_MULTI if (h->bucketsize >=AHASH_MAX_TUNED ) goto set_full;
@@ -950,8 +956,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext, } copy_elem: - j = npos; - npos = n->pos +1 ; + j = npos++; data =ahash_data (n, j, set->dsize); copy_data: t->hregion[r].elements++;
@@ -974,7 +979,8 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (SET_WITH_TIMEOUT (set))ip_set_timeout_set (ext_timeout (data, set), ext->timeout);smp_mb__before_atomic (); - n->pos = npos; +/* Ensure all data writes are visible before updating position */ +smp_store_release (&n->pos, npos);set_bit (j, n->used);if (old !=ERR_PTR (-ENOENT )) {rcu_assign_pointer (hbucket (t, key), n);
@@ -1033,6 +1039,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,int i, j, k, r, ret = -IPSET_ERR_EXIST ;u32 key, multi =0 ;size_t dsize = set->dsize; +u8 pos;/* Userspace add and resize is excluded by the mutex. * Kernespace add does not trigger resize.
@@ -1048,7 +1055,8 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext, n =rcu_dereference_bh (hbucket (t, key));if (!n) goto out; -for (i =0 , k =0 ; i < n->pos; i++) { + pos =smp_load_acquire (&n->pos); +for (i =0 , k =0 ; i < pos; i++) {if (!test_bit (i, n->used)) { k++;continue ;
@@ -1062,8 +1070,8 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext, ret =0 ;clear_bit (i, n->used);smp_mb__after_atomic (); -if (i +1 == n->pos) - n->pos--; +if (i +1 == pos) +smp_store_release (&n->pos, --pos); t->hregion[r].elements--;#ifdef IP_SET_HASH_WITH_NETS for (j =0 ; j <IPSET_NET_COUNT ; j++)
@@ -1085,11 +1093,11 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext, x->flags = flags; } } -for (; i < n->pos; i++) { +for (; i < pos; i++) {if (!test_bit (i, n->used)) k++; } -if (k == n->pos) { +if (k == pos) { t->hregion[r].ext_size -=ext_size (n->size, dsize);rcu_assign_pointer (hbucket (t, key),NULL );kfree_rcu (n, rcu);
@@ -1100,7 +1108,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (!tmp) goto out; tmp->size = n->size -AHASH_INIT_SIZE ; -for (j =0 , k =0 ; j < n->pos; j++) { +for (j =0 , k =0 ; j < pos; j++) {if (!test_bit (j, n->used))continue ; data =ahash_data (n, j, dsize);
@@ -1161,6 +1169,7 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d,int ret, i, j =0 ;#endif u32 key, multi =0 ; +u8 pos;pr_debug ("test by nets\n" );for (; j <NLEN && h->nets[j].cidr[0 ] && !multi; j++) {
@@ -1178,7 +1187,8 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d, n =rcu_dereference_bh (hbucket (t, key));if (!n)continue ; -for (i =0 ; i < n->pos; i++) { + pos =smp_load_acquire (&n->pos); +for (i =0 ; i < pos; i++) {if (!test_bit (i, n->used))continue ; data =ahash_data (n, i, set->dsize);
@@ -1212,6 +1222,7 @@ mtype_test(struct ip_set *set, void *value, const struct ip_set_ext *ext,struct mtype_elem *data;int i, ret =0 ;u32 key, multi =0 ; +u8 pos;rcu_read_lock_bh (); t =rcu_dereference_bh (h->table);
@@ -1234,7 +1245,8 @@ mtype_test(struct ip_set *set, void *value, const struct ip_set_ext *ext, ret =0 ; goto out; } -for (i =0 ; i < n->pos; i++) { + pos =smp_load_acquire (&n->pos); +for (i =0 ; i < pos; i++) {if (!test_bit (i, n->used))continue ; data =ahash_data (n, i, set->dsize);
@@ -1339,6 +1351,7 @@ mtype_list(const struct ip_set *set,/* We assume that one hash bucket fills into one page */ void *incomplete;int i, ret =0 ; +u8 pos; atd =nla_nest_start (skb,IPSET_ATTR_ADT );if (!atd)
@@ -1357,7 +1370,8 @@ mtype_list(const struct ip_set *set, cb->args[IPSET_CB_ARG0], t, n);if (!n)continue ; -for (i =0 ; i < n->pos; i++) { + pos =smp_load_acquire (&n->pos); +for (i =0 ; i < pos; i++) {if (!test_bit (i, n->used))continue ; e =ahash_data (n, i, set->dsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/1067 netfilter: ipset: Dont use test_bit() in lockless RCU readers in hash types
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jozsef Kadlecsik <[email protected]>
[ Upstream commit e4b4984e28c16406ecb318444dea4a8bf47def3e ]
Sashiko pointed out that there are a few lockless RCU readers using test_bit() which is a relaxed atomic operation and provides no memory barrier guarantees. Use test_bit_acquire() instead where the operation may run parallel with add/del/gc, i.e. is not one from the next cases
- protected by region lock
- in a set destroy phase
- in a new/temporary set creation phase
--- net/netfilter/ipset/ip_set_hash_gen.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/ipset/ip_set_hash_gen.h +5 -5
@@ -676,7 +676,7 @@ mtype_resize(struct ip_set *set, bool retried)continue ; pos =smp_load_acquire (&n->pos);for (j =0 ; j < pos; j++) { -if (!test_bit (j, n->used)) +if (!test_bit_acquire (j, n->used))continue ; data =ahash_data (n, j, dsize);if (SET_ELEM_EXPIRED (set, data))
@@ -813,7 +813,7 @@ mtype_ext_size(struct ip_set *set, u32 *elements, size_t *ext_size)continue ; pos =smp_load_acquire (&n->pos);for (j =0 ; j < pos; j++) { -if (!test_bit (j, n->used)) +if (!test_bit_acquire (j, n->used))continue ; data =ahash_data (n, j, set->dsize);if (!SET_ELEM_EXPIRED (set, data))
@@ -1189,7 +1189,7 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d,continue ; pos =smp_load_acquire (&n->pos);for (i =0 ; i < pos; i++) { -if (!test_bit (i, n->used)) +if (!test_bit_acquire (i, n->used))continue ; data =ahash_data (n, i, set->dsize);if (!mtype_data_equal (data, d, &multi))
@@ -1247,7 +1247,7 @@ mtype_test(struct ip_set *set, void *value, const struct ip_set_ext *ext, } pos =smp_load_acquire (&n->pos);for (i =0 ; i < pos; i++) { -if (!test_bit (i, n->used)) +if (!test_bit_acquire (i, n->used))continue ; data =ahash_data (n, i, set->dsize);if (!mtype_data_equal (data, d, &multi))
@@ -1372,7 +1372,7 @@ mtype_list(const struct ip_set *set,continue ; pos =smp_load_acquire (&n->pos);for (i =0 ; i < pos; i++) { -if (!test_bit (i, n->used)) +if (!test_bit_acquire (i, n->used))continue ; e =ahash_data (n, i, set->dsize);if (SET_ELEM_EXPIRED (set, e))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/1067 netfilter: ipset: fix order of kfree_rcu() and rcu_assign_pointer()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jozsef Kadlecsik <[email protected]>
[ Upstream commit 3ca9982a8882470aa0ac4e8bb9a552b181d1efcd ]
Sashiko pointed out that kfree_rcu() was called before rcu_assign_pointer() in handling the comment extension. Fix the order so that rcu_assign_pointer() called first.
--- net/netfilter/ipset/ip_set_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipset/ip_set_core.c +2 -2
@@ -351,8 +351,8 @@ ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment,if (unlikely (c)) { set->ext_size -=sizeof (*c) +strlen (c->str) +1 ; -kfree_rcu (c, rcu);rcu_assign_pointer (comment->c,NULL ); +kfree_rcu (c, rcu); }if (!len)return ;
@@ -393,8 +393,8 @@ ip_set_comment_free(struct ip_set *set, void *ptr)if (unlikely (!c))return ; set->ext_size -=sizeof (*c) +strlen (c->str) +1 ; -kfree_rcu (c, rcu);rcu_assign_pointer (comment->c,NULL ); +kfree_rcu (c, rcu); }typedef void (*destroyer )(struct ip_set *,void *);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/1067 netfilter: nf_reject: skip iphdr options when looking for icmp header
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit af8d6ae09c0a5f8b8a0d5680203c74b3c1daa85b ]
Not a big deal but this hould have used the real ip header length and not the base header size. As-is, if there are options then nf_skb_is_icmp_unreach() result will be random.
--- net/ipv4/netfilter/nf_reject_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/netfilter/nf_reject_ipv4.c +1 -1
@@ -80,7 +80,7 @@ static bool nf_skb_is_icmp_unreach(const struct sk_buff *skb)if (iph->protocol !=IPPROTO_ICMP )return false; - thoff =skb_network_offset (skb) +sizeof (*iph); + thoff =skb_network_offset (skb) +ip_hdrlen (skb); tp = skb_header_pointer(skb, thoff + offsetof(struct icmphdr, type),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/1067 netfilter: nft_meta_bridge: fix NFT_META_BRI_IIFPVID stack leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 27dd2997746d54ebc079bb13161cc1bdd401d4a6 ]
This needs to test for nonzero retval.
--- net/bridge/netfilter/nft_meta_bridge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bridge/netfilter/nft_meta_bridge.c +3 -1
@@ -41,7 +41,9 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr,if (!br_dev || !br_vlan_enabled (br_dev)) goto err; -br_vlan_get_pvid_rcu (in, &p_pvid); +if (br_vlan_get_pvid_rcu (in, &p_pvid)) + goto err; +nft_reg_store16 (dest, p_pvid);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/1067 perf bpf: Bounds-check array offsets in bpil_offs_to_addr()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 033e85edfbf271f92979d2a39aeaf40f8472a795 ]
bpil_offs_to_addr() converts offsets stored in perf.data's bpf_prog_info_linear structure into heap pointers by adding the offset to the data allocation base. The offsets come from untrusted file input and are not validated against data_len.
If an offset exceeds data_len, the computed address points outside the allocated data buffer. Callers like synthesize_bpf_prog_name() then dereference prog_tags[sub_id] or func_info pointers, reading arbitrary heap memory.
Add a bounds check: when an offset exceeds data_len, zero the field and skip the conversion. This prevents out-of-bounds pointer construction from crafted perf.data files.
--- tools/perf/util/bpf-utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/perf/util/bpf-utils.c +16 -0
@@ -246,6 +246,7 @@ void bpil_offs_to_addr(struct perf_bpil *info_linear)for (i =PERF_BPIL_FIRST_ARRAY ; i <PERF_BPIL_LAST_ARRAY ; ++i) {struct bpil_array_desc *desc;__u64 addr, offs; +__u32 count, size;if ((info_linear->arrays & (1UL << i)) ==0 )continue ;
@@ -253,6 +254,21 @@ void bpil_offs_to_addr(struct perf_bpil *info_linear) desc = bpil_array_desc + i; offs =bpf_prog_info_read_offset_u64 (&info_linear->info, desc->array_offset); + count =bpf_prog_info_read_offset_u32 (&info_linear->info, + desc->count_offset); + size =bpf_prog_info_read_offset_u32 (&info_linear->info, + desc->size_offset); +/* offset and extent from perf.data are untrusted — keep within data[] */ +if (offs >= info_linear->data_len || + (u64 )count * size > info_linear->data_len - offs) { +bpf_prog_info_set_offset_u64 (&info_linear->info, + desc->array_offset,0 ); +bpf_prog_info_set_offset_u32 (&info_linear->info, + desc->count_offset,0 ); +/* clear the bit so bpil_addr_to_offs() won't reverse a zeroed address */ + info_linear->arrays &= ~(1UL << i); +continue ; + } addr = offs +ptr_to_u64 (info_linear->data);bpf_prog_info_set_offset_u64 (&info_linear->info, desc->array_offset, addr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/1067 irqchip/crossbar: Fix parent domain resource leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bhargav Joshi <[email protected]>
[ Upstream commit a1074dd62faa6572921d387e8a21589ccea00efc ]
irq_domain_alloc_irqs_parent() is called in allocate_gic_irq() but irq_domain_free_irqs_parent() is never called which causes a resource leak.
Fix this by calling irq_domain_free_irqs_parent() in crossbar_domain_free().
--- drivers/irqchip/irq-crossbar.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-crossbar.c +1 -0
@@ -163,6 +163,7 @@ static void crossbar_domain_free(struct irq_domain *domain, unsigned int virq, cb->write (d->hwirq, cb->safe_map); }raw_spin_unlock (&cb->lock); +irq_domain_free_irqs_parent (domain, virq, nr_irqs); } static int crossbar_domain_translate(struct irq_domain *d,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/1067 selftests/mm: clarify alternate unmapping in compaction_test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sayali Patil <[email protected]>
[ Upstream commit 69ba1d76d93ab818245333cf400928477ba72053 ]
Add a comment explaining that every other entry in the list is unmapped to intentionally create fragmentation with locked pages before invoking check_compaction().
--- tools/testing/selftests/vm/compaction_test.c | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/vm/compaction_test.c +3 -0
@@ -234,6 +234,9 @@ int main(int argc, char **argv) mem_fragmentable_MB -=MAP_SIZE_MB ; } +/* Unmap every other entry in the list to create fragmentation with +* locked pages before invoking check_compaction(). +*/ for (entry = list; entry !=NULL ; entry = entry->next) {munmap (entry->map,MAP_SIZE );if (!entry->next)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/1067 selftests/mm: allow PUD-level entries in compound testcase of hmm tests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sayali Patil <[email protected]>
[ Upstream commit 224ed0e019b122d08580362abe57574a78f2b5fa ]
Patch series "selftests/mm: assorted fixes for hmm-tests", v3.
This series fixes a few issues in hmm-tests that show up when page-size and huge-page configuration differ from the hardcoded assumptions the tests were written for (PMD/THP sizing, default hugepage size, and related cases).
It also includes a fix to exclusive_cow: the test ignored the return value of fork(), so both parent and child ran the same teardown path.
This patch (of 3):
The HMM compound testcase currently assumes only PMD-level mappings and fails on systems where default_hugepagesz=1G is set, because the region is then reported by the device at PUD level.
Determine the mapping level (PMD or PUD) the device reports for the first page of the range and require every page to match that level exactly via ASSERT_EQ(). This accepts PUD-level mappings while preserving the expected/observed protection values printed on failure, and rejects a fragmented mapping that mixes PMD- and PUD-level entries within the same range (which a per-page OR check would have let pass).
--- tools/testing/selftests/vm/hmm-tests.c | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-)
tools/testing/selftests/vm/hmm-tests.c +24 -8
@@ -1607,8 +1607,8 @@ TEST_F(hmm2, snapshot) }/* -* Test the hmm_range_fault() HMM_PFN_PMD flag for large pages that -* should be mapped by a large page table entry. +* Test the hmm_range_fault() handling of large pages (PMD or PUD) +* that should be mapped by a large page table entry. */ TEST_F(hmm, compound) {
@@ -1618,6 +1618,7 @@ TEST_F(hmm, compound)unsigned long default_hsize;int *ptr;unsigned char *m; +unsigned char prot;int ret;unsigned long i;
@@ -1656,11 +1657,20 @@ TEST_F(hmm, compound)ASSERT_EQ (ret,0 );ASSERT_EQ (buffer->cpages, npages); -/* Check what the device saw. */ +/* +* Check what the device saw. The region is backed by a single huge +* page that the device reports either at PMD or at PUD level depending +* on the configured default hugepage size. Determine that level from +* the first page and require every page in the range to match it +* exactly, so that a fragmented mapping mixing levels (or a missing +* large-page bit) is still caught and reported with its actual value. +*/ m = buffer->mirror; + prot =HMM_DMIRROR_PROT_WRITE | + ((m[0 ] &HMM_DMIRROR_PROT_PUD ) ?HMM_DMIRROR_PROT_PUD : +HMM_DMIRROR_PROT_PMD );for (i =0 ; i < npages; ++i) -ASSERT_EQ (m[i],HMM_DMIRROR_PROT_WRITE | -HMM_DMIRROR_PROT_PMD ); +ASSERT_EQ (m[i], prot);/* Make the region read-only. */ ret =mprotect (buffer->ptr, size,PROT_READ );
@@ -1671,11 +1681,17 @@ TEST_F(hmm, compound)ASSERT_EQ (ret,0 );ASSERT_EQ (buffer->cpages, npages); -/* Check what the device saw. */ +/* +* Check what the device saw after mprotect(PROT_READ). Same +* approach as above: determine the mapping level from the first +* page and require every page to match it exactly. +*/ m = buffer->mirror; + prot =HMM_DMIRROR_PROT_READ | + ((m[0 ] &HMM_DMIRROR_PROT_PUD ) ?HMM_DMIRROR_PROT_PUD : +HMM_DMIRROR_PROT_PMD );for (i =0 ; i < npages; ++i) -ASSERT_EQ (m[i],HMM_DMIRROR_PROT_READ | -HMM_DMIRROR_PROT_PMD ); +ASSERT_EQ (m[i], prot);munmap (buffer->ptr, buffer->size); buffer->ptr =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/1067 selftests/mm: fix exclusive_cow test fork() handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aboorva Devarajan <[email protected]>
[ Upstream commit cea5702144615878600d3a39b5d8b3cc34719012 ]
The test ignores the return value of fork(), so both the parent and the (newly created) child run the COW verification loops and then call hmm_buffer_free() before returning into the kselftest harness, which _exit()s each side. This duplicated teardown sequence has been observed to manifest as a SIGSEGV in the test child, e.g.:
hmm-tests[360141]: segfault (11) at 0 nip 10006964 lr 1000ac3c code 1 in hmm-tests[6964,10000000+30000]
Fix this by adopting the same fork()-then-wait pattern already used by the nearby anon_write_child / anon_write_child_shared tests in this file: the child performs the COW verification and then _exit(0)s so it does not run the test teardown, while the parent independently verifies COW, waits for the child, and only then frees the buffer.
--- tools/testing/selftests/vm/hmm-tests.c | 31 +++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
tools/testing/selftests/vm/hmm-tests.c +28 -3
@@ -1891,6 +1891,8 @@ TEST_F(hmm, exclusive_cow)unsigned long i;int *ptr;int ret; +pid_t pid; +int status; npages =ALIGN (HMM_BUFFER_SIZE , self->page_size) >> self->page_shift;ASSERT_NE (npages,0 );
@@ -1919,14 +1921,37 @@ TEST_F(hmm, exclusive_cow)ASSERT_EQ (ret,0 );ASSERT_EQ (buffer->cpages, npages); -fork (); + pid =fork (); +if (pid ==-1 ) +ASSERT_EQ (pid,0 ); -/* Fault pages back to system memory and check them. */ +if (pid ==0 ) { +/* +* Child verifies COW independently, then _exit(0)s so it does +* not run the test teardown. A failed ASSERT_* here makes the +* harness abort() the child, so the parent sees +* !WIFEXITED(status) below and fails in turn. +*/ +for (i =0 , ptr = buffer->ptr; i < size /sizeof (*ptr); ++i) +ASSERT_EQ (ptr[i]++, i); + +for (i =0 , ptr = buffer->ptr; i < size /sizeof (*ptr); ++i) +ASSERT_EQ (ptr[i], i +1 ); + +_exit (0 ); + } + +/* Parent: also increment to verify COW works for both processes. */ for (i =0 , ptr = buffer->ptr; i < size /sizeof (*ptr); ++i)ASSERT_EQ (ptr[i]++, i);for (i =0 , ptr = buffer->ptr; i < size /sizeof (*ptr); ++i) -ASSERT_EQ (ptr[i], i+1 ); +ASSERT_EQ (ptr[i], i +1 ); + +/* Parent: wait for child and then free the buffer. */ +ASSERT_EQ (waitpid (pid, &status,0 ), pid); +ASSERT_TRUE (WIFEXITED (status)); +ASSERT_EQ (WEXITSTATUS (status),0 );hmm_buffer_free (buffer); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/1067 net: marvell: prestera: initialize err in prestera_port_sfp_bind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 62b01f72d93c7bc8fde3b2e5b5f783eca5f53324 ]
prestera_port_sfp_bind() returns err after walking the ports node. If no child node matches the port's front-panel id, err is never assigned.
Initialize err to 0 because absence of a matching optional port device tree node is not an error. In that case no phylink is created and port creation should continue with port->phy_link left NULL. Errors from malformed matched nodes and phylink_create() still propagate.
--- drivers/net/ethernet/marvell/prestera/prestera_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/prestera/prestera_main.c +1 -1
@@ -379,7 +379,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)struct device_node *ports, *node;struct fwnode_handle *fwnode;struct phylink *phy_link; -int err; +int err =0 ;if (!sw->np)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/1067 octeontx2-af: mcs: Fix unsupported secy stats read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geetha sowjanya <[email protected]>
[ Upstream commit d4b7440f7316e76f013f57d8b6da069a1b9c34e7 ]
Secy control stats counter doesn't exist for CNF10KB platform. Skip reading this respective register for CNF10KB silicon while fetching secy stats.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 6 +++--- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +3 -3
@@ -120,13 +120,13 @@ void mcs_get_rx_secy_stats(struct mcs *mcs, struct mcs_secy_stats *stats, int id reg =MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYUNTAGGEDX (id); stats->pkt_untaged_cnt =mcs_reg_read (mcs, reg); - reg =MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYCTLX (id); - stats->pkt_ctl_cnt =mcs_reg_read (mcs, reg); -if (mcs->hw->mcs_blks >1 ) { reg =MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYNOTAGX (id); stats->pkt_notag_cnt =mcs_reg_read (mcs, reg); +return ; } + reg =MCSX_CSE_RX_MEM_SLAVE_INPKTSSECYCTLX (id); + stats->pkt_ctl_cnt =mcs_reg_read (mcs, reg); } void mcs_get_flowid_stats(struct mcs *mcs, struct mcs_flowid_stats *stats,
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +2 -1
@@ -505,10 +505,11 @@ static int rvu_dbg_mcs_rx_secy_stats_display(struct seq_file *filp, void *unusedseq_printf (filp,"secy%d: Tagged ctrl pkts: %lld\n" , secy_id, stats.pkt_tagged_ctl_cnt);seq_printf (filp,"secy%d: Untaged pkts: %lld\n" , secy_id, stats.pkt_untaged_cnt); -seq_printf (filp,"secy%d: Ctrl pkts: %lld\n" , secy_id, stats.pkt_ctl_cnt);if (mcs->hw->mcs_blks >1 )seq_printf (filp,"secy%d: pkts notag: %lld\n" , secy_id, stats.pkt_notag_cnt); +else +seq_printf (filp,"secy%d: Ctrl pkts: %lld\n" , secy_id, stats.pkt_ctl_cnt); }mutex_unlock (&mcs->stats_lock);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/1067 spi: dw: fix wrong BAUDR setting after resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
[ Upstream commit 66b6605bcea7af7aca3d1d858b9c5f14903f9f9a ]
After resuming from suspend to ram, spi transfer stops working. Further debugging shows that the BAUDR register isn't correctly set, this is due to dws->current_freq doesn't match the HW BAUDR setting, specifically, the dws->current_freq equals to speed_hz, but BAUDR is 0. so the dw_spi_set_clk() in below code won't be called:
if (dws->current_freq != speed_hz) {
dw_spi_set_clk(dws, clk_div);
dws->current_freq = speed_hz;
}The mismatch comes from dw_spi_shutdown_chip() when suspending. Fix this mismatch by setting dws->current_freq to 0 as well when clearing BAUDR reg in dw_spi_shutdown_chip().
--- drivers/spi/spi-dw.h | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-dw.h +1 -0
@@ -281,6 +281,7 @@ static inline void dw_spi_shutdown_chip(struct dw_spi *dws) {dw_spi_enable_chip (dws,0 );dw_spi_set_clk (dws,0 ); + dws->current_freq =0 ; }extern void dw_spi_set_cs (struct spi_device *spi,bool enable);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/1067 xfrm: add new packet offload flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit d14f28b8c1de668bab863bf5892a49c824cb110d ]
In the next patches, the xfrm core code will be extended to support new type of offload - packet offload. In that mode, both policy and state should be specially configured in order to perform whole offloaded data path.
Full offload takes care of encryption, decryption, encapsulation and other operations with headers.
As this mode is new for XFRM policy flow, we can "start fresh" with flag bits and release first and second bit for future use.
Stable-dep-of: 68de007d5ac9 ("xfrm: annotate data-races around xfrm_policy_count[] and xfrm_policy_default[]")
--- include/net/xfrm.h | 7 +++++++ include/uapi/linux/xfrm.h | 6 ++++++ net/xfrm/xfrm_device.c | 3 +++ net/xfrm/xfrm_user.c | 2 ++ 4 files changed, 18 insertions(+)
include/net/xfrm.h +7 -0
@@ -131,12 +131,19 @@ enum { XFRM_DEV_OFFLOAD_OUT, }; +enum { +XFRM_DEV_OFFLOAD_UNSPECIFIED , +XFRM_DEV_OFFLOAD_CRYPTO , +XFRM_DEV_OFFLOAD_PACKET , +}; +struct xfrm_dev_offload {struct net_device *dev;netdevice_tracker dev_tracker;struct net_device *real_dev;unsigned long offload_handle;u8 dir :2 ; +u8 type :2 ; };struct xfrm_mode {
include/uapi/linux/xfrm.h +6 -0
@@ -519,6 +519,12 @@ struct xfrm_user_offload {*/ #define XFRM_OFFLOAD_IPV6 1#define XFRM_OFFLOAD_INBOUND 2 +/* Two bits above are relevant for state path only, while +* offload is used for both policy and state flows. +* +* In policy offload mode, they are free and can be safely reused. +*/ +#define XFRM_OFFLOAD_PACKET 4struct xfrm_userpolicy_default {#define XFRM_USERPOLICY_UNSPEC 0
net/xfrm/xfrm_device.c +3 -0
@@ -296,12 +296,15 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,else xso->dir =XFRM_DEV_OFFLOAD_OUT ; + xso->type =XFRM_DEV_OFFLOAD_CRYPTO ; + err = dev->xfrmdev_ops->xdo_dev_state_add (x);if (err) { xso->dev =NULL ; xso->dir =0 ; xso->real_dev =NULL ;netdev_put (dev, &xso->dev_tracker); + xso->type =XFRM_DEV_OFFLOAD_UNSPECIFIED ;if (err != -EOPNOTSUPP ) {NL_SET_ERR_MSG (extack,"Device failed to offload this state" );
net/xfrm/xfrm_user.c +2 -0
@@ -947,6 +947,8 @@ static int copy_user_offload(struct xfrm_dev_offload *xso, struct sk_buff *skb) xuo->ifindex = xso->dev->ifindex;if (xso->dir ==XFRM_DEV_OFFLOAD_IN ) xuo->flags =XFRM_OFFLOAD_INBOUND ; +if (xso->type ==XFRM_DEV_OFFLOAD_PACKET ) + xuo->flags |=XFRM_OFFLOAD_PACKET ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/1067 xfrm: Use the XFRM_GRO to indicate a GRO call on input
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steffen Klassert <[email protected]>
[ Upstream commit b439475a0dba2b50fb39a6356069969780e45fd4 ]
This is needed to support GRO for ESP in UDP encapsulation.
Stable-dep-of: 68de007d5ac9 ("xfrm: annotate data-races around xfrm_policy_count[] and xfrm_policy_default[]")
--- net/ipv4/esp4_offload.c | 2 +- net/ipv6/esp6_offload.c | 2 +- net/xfrm/xfrm_input.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-)
net/ipv4/esp4_offload.c +1 -1
@@ -76,7 +76,7 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head,/* We don't need to handle errors from xfrm_input, it does all * the error handling and frees the resources on error. */ -xfrm_input (skb,IPPROTO_ESP , spi,-2 ); +xfrm_input (skb,IPPROTO_ESP , spi,0 );return ERR_PTR (-EINPROGRESS ); out_reset:
net/ipv6/esp6_offload.c +1 -1
@@ -104,7 +104,7 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head,/* We don't need to handle errors from xfrm_input, it does all * the error handling and frees the resources on error. */ -xfrm_input (skb,IPPROTO_ESP , spi,-2 ); +xfrm_input (skb,IPPROTO_ESP , spi,0 );return ERR_PTR (-EINPROGRESS ); out_reset:
net/xfrm/xfrm_input.c +2 -4
@@ -470,7 +470,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)struct xfrm_offload *xo =xfrm_offload (skb);struct sec_path *sp; -if (encap_type <0 ) { +if (encap_type <0 || (xo && xo->flags &XFRM_GRO )) { x =xfrm_input_state (skb);if (unlikely (x->km.state !=XFRM_STATE_VALID )) {
@@ -493,9 +493,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) seq =XFRM_SKB_CB (skb)->seq.input.low; goto resume; } - -/* encap_type < -1 indicates a GRO call. */ - encap_type =0 ; +/* GRO call */ seq =XFRM_SPI_SKB_CB (skb)->seq;if (xo && (xo->flags &CRYPTO_DONE )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/1067 xfrm: Support crypto offload for inbound IPv6 ESP packets not in GRO path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Yu <[email protected]>
[ Upstream commit f7e8542d71e908706855a9f3e9e7844fea1feea0 ]
IPsec crypt offload supports outbound IPv6 ESP packets, but it doesn't support inbound IPv6 ESP packets.
This change enables the crypto offload for inbound IPv6 ESP packets that are not handled through GRO code path. If HW drivers add the offload information to the skb, the packet will be handled in the crypto offload rx code path.
Apart from the change in crypto offload rx code path, the change in xfrm_policy_check is also needed.
Exampe of RX data path:
+-----------+ +-------+
| HW Driver |-->| wlan0 |--------+
+-----------+ +-------+ |
v
+---------------+ +------+
+------>| Network Stack |-->| Apps |
| +---------------+ +------+
| |
| v
+--------+ +------------+
| ipsec1 |<--| XFRM Stack |
+--------+ +------------+Test: Enabled both in/out IPsec crypto offload, and verified IPv6
ESP packets on Android device on both wifi/cellular network
Stable-dep-of: 68de007d5ac9 ("xfrm: annotate data-races around xfrm_policy_count[] and xfrm_policy_default[]")
--- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_policy.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
net/xfrm/xfrm_input.c +1 -1
@@ -470,7 +470,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)struct xfrm_offload *xo =xfrm_offload (skb);struct sec_path *sp; -if (encap_type <0 || (xo && xo->flags &XFRM_GRO )) { +if (encap_type <0 || (xo && (xo->flags &XFRM_GRO || encap_type ==0 ))) { x =xfrm_input_state (skb);if (unlikely (x->km.state !=XFRM_STATE_VALID )) {
net/xfrm/xfrm_policy.c +4 -1
@@ -3604,12 +3604,15 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, }if (!pol) { +const bool is_crypto_offload = sp && + (xfrm_input_state (skb)->xso.type ==XFRM_DEV_OFFLOAD_CRYPTO ); +if (net->xfrm.policy_default[dir] ==XFRM_USERPOLICY_BLOCK ) {XFRM_INC_STATS (net,LINUX_MIB_XFRMINNOPOLS );return 0 ; } -if (sp &&secpath_has_nontransport (sp,0 , &xerr_idx)) { +if (sp &&secpath_has_nontransport (sp,0 , &xerr_idx) && !is_crypto_offload) {xfrm_secpath_reject (xerr_idx, skb, &fl);XFRM_INC_STATS (net,LINUX_MIB_XFRMINNOPOLS );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/1067 xfrm: annotate data-races around xfrm_policy_count[] and xfrm_policy_default[]
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 68de007d5ac9df0e3f4f187a179c5c842bb5a2be ]
KCSAN reported a data race involving net->xfrm.policy_count access.
Add missing READ_ONCE()/WRITE_ONCE() annotations on xfrm_policy_count and xfrm_policy_default.
--- include/net/xfrm.h | 8 ++++---- net/xfrm/xfrm_policy.c | 24 ++++++++++++------------ net/xfrm/xfrm_user.c | 18 +++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-)
include/net/xfrm.h +4 -4
@@ -1109,8 +1109,8 @@ int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb,static inline bool __xfrm_check_nopolicy (struct net *net,struct sk_buff *skb,int dir) { -if (!net->xfrm.policy_count[dir] && !secpath_exists (skb)) -return net->xfrm.policy_default[dir] ==XFRM_USERPOLICY_ACCEPT ; +if (!READ_ONCE (net->xfrm.policy_count[dir]) && !secpath_exists (skb)) +return READ_ONCE (net->xfrm.policy_default[dir]) ==XFRM_USERPOLICY_ACCEPT ;return false; }
@@ -1191,8 +1191,8 @@ static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) {struct net *net =dev_net (skb->dev); -if (!net->xfrm.policy_count[XFRM_POLICY_OUT ] && - net->xfrm.policy_default[XFRM_POLICY_OUT ] ==XFRM_USERPOLICY_ACCEPT ) +if (!READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_OUT ]) && +READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_OUT ]) ==XFRM_USERPOLICY_ACCEPT )return true; return (skb_dst(skb)->flags & DST_NOXFRM) ||
net/xfrm/xfrm_policy.c +12 -12
@@ -653,7 +653,7 @@ static void xfrm_byidx_resize(struct net *net, int total)static inline int xfrm_bydst_should_resize (struct net *net,int dir,int *total) { -unsigned int cnt = net->xfrm.policy_count[dir]; +unsigned int cnt =READ_ONCE (net->xfrm.policy_count[dir]);unsigned int hmask = net->xfrm.policy_bydst[dir].hmask;if (total)
@@ -679,12 +679,12 @@ static inline int xfrm_byidx_should_resize(struct net *net, int total)void xfrm_spd_getinfo (struct net *net,struct xfrmk_spdinfo *si) { - si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN ]; - si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT ]; - si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD ]; - si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN +XFRM_POLICY_MAX ]; - si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT +XFRM_POLICY_MAX ]; - si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD +XFRM_POLICY_MAX ]; + si->incnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_IN ]); + si->outcnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_OUT ]); + si->fwdcnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_FWD ]); + si->inscnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_IN +XFRM_POLICY_MAX ]); + si->outscnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_OUT +XFRM_POLICY_MAX ]); + si->fwdscnt =READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_FWD +XFRM_POLICY_MAX ]); si->spdhcnt = net->xfrm.policy_idx_hmask; si->spdhmcnt = xfrm_policy_hashmax; }
@@ -2220,7 +2220,7 @@ static void __xfrm_policy_link(struct xfrm_policy *pol, int dir)struct net *net =xp_net (pol);list_add (&pol->walk.all, &net->xfrm.policy_all); - net->xfrm.policy_count[dir]++; +WRITE_ONCE (net->xfrm.policy_count[dir], net->xfrm.policy_count[dir] +1 );xfrm_pol_hold (pol); }
@@ -2240,7 +2240,7 @@ static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol, }list_del_init (&pol->walk.all); - net->xfrm.policy_count[dir]--; +WRITE_ONCE (net->xfrm.policy_count[dir], net->xfrm.policy_count[dir] -1 );return pol; }
@@ -3113,7 +3113,7 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net,/* To accelerate a bit... */ if (!if_id && ((dst_orig->flags &DST_NOXFRM ) || - !net->xfrm.policy_count[XFRM_POLICY_OUT ])) + !READ_ONCE (net->xfrm.policy_count[XFRM_POLICY_OUT ]))) goto nopol; xdst =xfrm_bundle_lookup (net, fl, family, dir, &xflo, if_id);
@@ -3185,7 +3185,7 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net, nopol:if ((!dst_orig->dev || !(dst_orig->dev->flags &IFF_LOOPBACK )) && - net->xfrm.policy_default[dir] ==XFRM_USERPOLICY_BLOCK ) { +READ_ONCE (net->xfrm.policy_default[dir]) ==XFRM_USERPOLICY_BLOCK ) { err = -EPERM ; goto error; }
@@ -3607,7 +3607,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,const bool is_crypto_offload = sp && (xfrm_input_state (skb)->xso.type ==XFRM_DEV_OFFLOAD_CRYPTO ); -if (net->xfrm.policy_default[dir] ==XFRM_USERPOLICY_BLOCK ) { +if (READ_ONCE (net->xfrm.policy_default[dir]) ==XFRM_USERPOLICY_BLOCK ) {XFRM_INC_STATS (net,LINUX_MIB_XFRMINNOPOLS );return 0 ; }
net/xfrm/xfrm_user.c +9 -9
@@ -2179,9 +2179,9 @@ static int xfrm_notify_userpolicy(struct net *net) } up =nlmsg_data (nlh); - up->in = net->xfrm.policy_default[XFRM_POLICY_IN ]; - up->fwd = net->xfrm.policy_default[XFRM_POLICY_FWD ]; - up->out = net->xfrm.policy_default[XFRM_POLICY_OUT ]; + up->in =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_IN ]); + up->fwd =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_FWD ]); + up->out =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_OUT ]);nlmsg_end (skb, nlh);
@@ -2205,13 +2205,13 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,struct xfrm_userpolicy_default *up =nlmsg_data (nlh);if (xfrm_userpolicy_is_valid (up->in)) - net->xfrm.policy_default[XFRM_POLICY_IN ] = up->in; +WRITE_ONCE (net->xfrm.policy_default[XFRM_POLICY_IN ], up->in);if (xfrm_userpolicy_is_valid (up->fwd)) - net->xfrm.policy_default[XFRM_POLICY_FWD ] = up->fwd; +WRITE_ONCE (net->xfrm.policy_default[XFRM_POLICY_FWD ], up->fwd);if (xfrm_userpolicy_is_valid (up->out)) - net->xfrm.policy_default[XFRM_POLICY_OUT ] = up->out; +WRITE_ONCE (net->xfrm.policy_default[XFRM_POLICY_OUT ], up->out);rt_genid_bump_all (net);
@@ -2241,9 +2241,9 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, } r_up =nlmsg_data (r_nlh); - r_up->in = net->xfrm.policy_default[XFRM_POLICY_IN ]; - r_up->fwd = net->xfrm.policy_default[XFRM_POLICY_FWD ]; - r_up->out = net->xfrm.policy_default[XFRM_POLICY_OUT ]; + r_up->in =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_IN ]); + r_up->fwd =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_FWD ]); + r_up->out =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_OUT ]);nlmsg_end (r_skb, r_nlh);return nlmsg_unicast (net->xfrm.nlsk, r_skb, portid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/1067 sparc: led: avoid trimming a newline from empty writes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 7eb475e8a738ee6fd1260aa59ddccb610fdd4300 ]
led_proc_write() duplicates up to LED_MAX_LENGTH bytes with memdup_user_nul() and then unconditionally inspects buf[count - 1] to strip a trailing newline. A zero-length write therefore reads one byte before the duplicated buffer.
The previous version rejected empty writes, but empty input already falls through to the existing default case and turns the LED off like any other unrecognized string. Preserve that behavior and only skip the newline trim when there is no input byte to inspect.
--- arch/sparc/kernel/led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/led.c +1 -1
@@ -78,7 +78,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer,return PTR_ERR (buf);/* work around \n when echo'ing into proc */ -if (buf[count -1 ] =='\n' ) +if (count >0 && buf[count -1 ] =='\n' ) buf[count -1 ] ='\0' ;/* before we change anything we want to stop any running timers,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/1067 octeontx2-pf: mcs: Fix mcs resources free on PF shutdown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geetha sowjanya <[email protected]>
[ Upstream commit 450d0e90b10393bd9f50c127875a9fdd4cc81c30 ]
On PF shutdown, the current driver free mcs hardware resources though mcs resources are not allocated to it. This patch checks the mcs resources status and if resources are allocated then only sends mailbox message to free them.
--- .../net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c +7 -2
@@ -1685,11 +1685,16 @@ int cn10k_mcs_init(struct otx2_nic *pfvf)void cn10k_mcs_free (struct otx2_nic *pfvf) { +struct cn10k_mcs_cfg *cfg = pfvf->macsec_cfg; +if (!test_bit (CN10K_HW_MACSEC , &pfvf->hw.cap_flag))return ; -cn10k_mcs_free_rsrc (pfvf,MCS_TX ,MCS_RSRC_TYPE_SECY ,0 , true); -cn10k_mcs_free_rsrc (pfvf,MCS_RX ,MCS_RSRC_TYPE_SECY ,0 , true); +if (!list_empty (&cfg->txsc_list)) { +cn10k_mcs_free_rsrc (pfvf,MCS_TX ,MCS_RSRC_TYPE_SECY ,0 , true); +cn10k_mcs_free_rsrc (pfvf,MCS_RX ,MCS_RSRC_TYPE_SECY ,0 , true); + } +kfree (pfvf->macsec_cfg); pfvf->macsec_cfg =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/1067 ice: fix AQ error code comparison in ice_set_pauseparam()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukasz Czapnik <[email protected]>
[ Upstream commit 2bf7744bc3221a63b95c76c94eab1dad832fa401 ]
Fix unreachable code: the conditionals in ice_set_pauseparam() used the bitwise-AND operator suggesting aq_failures is a bitmap, but it is actually an enum, making the third condition logically unreachable.
Replace the if-else ladder with a switch statement. Also move the aq_failures initialization to the variable declaration and remove the redundant zeroing from ice_set_fc().
--- drivers/net/ethernet/intel/ice/ice_common.c | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +0 -1
@@ -3347,7 +3347,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)if (!pi || !aq_failures)return -EINVAL ; - *aq_failures =0 ; hw = pi->hw; pcaps =devm_kzalloc (ice_hw_to_dev (hw),sizeof (*pcaps),GFP_KERNEL );
drivers/net/ethernet/intel/ice/ice_ethtool.c +8 -4
@@ -3059,7 +3059,7 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)struct ice_vsi *vsi = np->vsi;struct ice_hw *hw = &pf->hw;struct ice_port_info *pi; -u8 aq_failures; +u8 aq_failures =0 ;bool link_up;u32 is_an;int err;
@@ -3130,18 +3130,22 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)/* Set the FC mode and only restart AN if link is up */ err =ice_set_fc (pi, &aq_failures, link_up); -if (aq_failures &ICE_SET_FC_AQ_FAIL_GET ) { +switch (aq_failures) { +case ICE_SET_FC_AQ_FAIL_GET :netdev_info (netdev,"Set fc failed on the get_phy_capabilities call with err %d aq_err %s\n" , err,ice_aq_str (hw->adminq.sq_last_status)); err = -EAGAIN ; - }else if (aq_failures &ICE_SET_FC_AQ_FAIL_SET ) { +break ; +case ICE_SET_FC_AQ_FAIL_SET :netdev_info (netdev,"Set fc failed on the set_phy_config call with err %d aq_err %s\n" , err,ice_aq_str (hw->adminq.sq_last_status)); err = -EAGAIN ; - }else if (aq_failures &ICE_SET_FC_AQ_FAIL_UPDATE ) { +break ; +case ICE_SET_FC_AQ_FAIL_UPDATE :netdev_info (netdev,"Set fc failed on the get_link_info call with err %d aq_err %s\n" , err,ice_aq_str (hw->adminq.sq_last_status)); err = -EAGAIN ; +break ; }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/1067 rtc: msc313: fix NULL deref in shared IRQ handler at probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stepan Ionichev <[email protected]>
[ Upstream commit a369f48be8de426a7d2bca18dbd46c2ad1138803 ]
msc313_rtc_probe() calls devm_request_irq() with IRQF_SHARED and &pdev->dev as the cookie, but platform_set_drvdata() is only called later after the clock setup. With a shared IRQ line, another device on the same line can trigger the handler in that window. The handler does dev_get_drvdata() on the cookie, gets NULL, and dereferences priv->rtc_base in interrupt context.
Pass priv as the cookie directly so the handler reads it from dev_id without the lookup, removing the dependency on probe order.
--- drivers/rtc/rtc-msc313.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-msc313.c +2 -2
@@ -160,7 +160,7 @@ static const struct rtc_class_ops msc313_rtc_ops = {static irqreturn_t msc313_rtc_interrupt (s32 irq,void *dev_id) { -struct msc313_rtc *priv =dev_get_drvdata (dev_id); +struct msc313_rtc *priv = dev_id;u16 reg; reg =readw (priv->rtc_base +REG_RTC_STATUS_INT );
@@ -206,7 +206,7 @@ static int msc313_rtc_probe(struct platform_device *pdev) priv->rtc_dev->range_max =U32_MAX ; ret =devm_request_irq (dev, irq, msc313_rtc_interrupt,IRQF_SHARED , -dev_name (&pdev->dev), &pdev->dev); +dev_name (&pdev->dev), priv);if (ret) {dev_err (dev,"Could not request IRQ\n" );return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/1067 ksmbd: fix use-after-free of conn->preauth_info in concurrent SMB2 NEGOTIATE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gil Portnoy <[email protected]>
[ Upstream commit 0c054227479ed7e36ebccb3a558bc0ef698264f6 ]
conn->preauth_info is shared connection state (struct preauth_integrity_info, kmalloc-96) that is allocated and freed by the SMB2 NEGOTIATE handler and read by the response send path.
smb2_handle_negotiate() allocates conn->preauth_info, and on a deassemble_neg_contexts() failure kfrees it and sets it to NULL. Both the allocation and the free/NULL happen under ksmbd_conn_lock(conn) (the connection srv_mutex), which is held across the whole handler body.
The response send path smb3_preauth_hash_rsp(), called from the send:
block of __handle_ksmbd_work(), reads conn->preauth_info and dereferences conn->preauth_info->Preauth_HashValue (via ksmbd_gen_preauth_integrity_hash()) without taking conn_lock. When a client drives two SMB2 NEGOTIATE requests on the same connection, one worker can free conn->preauth_info on the failing-negotiate path while a concurrent send-path worker is reading it, producing a slab use-after-free read (KASAN-confirmed).
The send-path read tested conn->preauth_info for NULL but raced with the free that occurs between the NULL check and the dereference, so the NULL guard alone does not close the window.
Serialize the NEGOTIATE-branch read in smb3_preauth_hash_rsp() under ksmbd_conn_lock(conn) and re-check conn->preauth_info inside the lock. Because the negotiate handler holds conn_lock across its kfree + NULL assignment, a reader that also takes conn_lock either runs fully before the allocation or fully after the NULL store, and can never observe the freed-but-not-yet-NULLed pointer. ksmbd_gen_preauth_integrity_hash() takes no locks itself (it only computes a SHA-512 over the buffer), so no lock-ordering inversion is introduced, and conn_lock is a sleepable mutex which is safe on this send path (it already performs network I/O).
--- fs/smb/server/smb2pdu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +7 -4
@@ -8677,10 +8677,13 @@ void smb3_preauth_hash_rsp(struct ksmbd_work *work)WORK_BUFFERS (work, req, rsp); -if (le16_to_cpu (req->Command) ==SMB2_NEGOTIATE_HE && - conn->preauth_info) -ksmbd_gen_preauth_integrity_hash (conn, work->response_buf, - conn->preauth_info->Preauth_HashValue); +if (le16_to_cpu (req->Command) ==SMB2_NEGOTIATE_HE ) { +ksmbd_conn_lock (conn); +if (conn->preauth_info) +ksmbd_gen_preauth_integrity_hash (conn, work->response_buf, + conn->preauth_info->Preauth_HashValue); +ksmbd_conn_unlock (conn); + }if (le16_to_cpu (rsp->Command) ==SMB2_SESSION_SETUP_HE && sess) {__u8 *hash_value;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/1067 ipv6: Fix null-ptr-deref in fib6_nh_mtu_change().
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 46c3b8191aad3d032776bf3bebf03efdf5f4b905 ]
fib6_nh_mtu_change() re-fetches idev via __in6_dev_get(arg->dev) and dereferences idev->cnf.mtu6 without a NULL check. addrconf_ifdown() clears dev->ip6_ptr with RCU_INIT_POINTER() after rt6_disable_ip() has released tb6_lock, so the RA-driven MTU walk can observe a NULL idev and oops. The caller rt6_mtu_change_route() guards its own __in6_dev_get(), but this re-fetch is unguarded; nexthop-backed routes survive addrconf_ifdown()'s flush, so the walk still reaches it after ip6_ptr is nulled.
Return 0 when idev is NULL, matching rt6_mtu_change_route() and the fib6_mtu() fix in commit 5ad509c1fdad ("ipv6: Fix null-ptr-deref in fib6_mtu().").
Oops: general protection fault, ... KASAN: null-ptr-deref in range
[0x00000000000002a8-0x00000000000002af]
RIP: 0010:fib6_nh_mtu_change+0x203/0x990
rt6_mtu_change_route+0x141/0x1d0
__fib6_clean_all+0xd0/0x160
rt6_mtu_change+0xb4/0x100
ndisc_router_discovery+0x24b5/0x2cb0
icmpv6_rcv+0x12e9/0x1710
ipv6_rcv+0x39b/0x410--- net/ipv6/route.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/route.c +3 -0
@@ -4973,6 +4973,9 @@ static int fib6_nh_mtu_change(struct fib6_nh *nh, void *_arg)struct inet6_dev *idev =__in6_dev_get (arg->dev);u32 mtu = f6i->fib6_pmtu; +if (!idev) +return 0 ; +if (mtu >= arg->mtu || (mtu < arg->mtu && mtu == idev->cnf.mtu6))fib6_metric_set (f6i,RTAX_MTU , arg->mtu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/1067 ipv4: fib: Dont ignore error route in local/main tables.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit b72f0db64205d9ce462038ba995d5d31eff32dc1 ]
When CONFIG_IP_MULTIPLE_TABLES is enabled but no rule is added, fib_lookup() performs route lookup directly on two tables.
Since the first lookup does not properly bail out, the result of an error route in the merged local/main table could be overwritten by another route in the default table:
# unshare -n
# ip link set lo up
# ip route add 192.168.0.0/24 dev lo table 253
# ip route add unreachable 192.168.0.0/24
# ip route get 192.168.0.1
192.168.0.1 dev lo table default uid 0
cache <local>Once a random rule is added, the error route is respected:
# ip rule add table 0 # ip rule del table 0 # ip route get 192.168.0.1 RTNETLINK answers: No route to host
Let's fix the inconsistent behaviour.
--- include/net/ip_fib.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
include/net/ip_fib.h +3 -4
@@ -370,7 +370,7 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res, unsigned int flags) {struct fib_table *tb; -int err = -ENETUNREACH ; +int err = -EAGAIN ; flags |=FIB_LOOKUP_NOREF ;if (net->ipv4.fib_has_custom_rules)
@@ -384,17 +384,16 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,if (tb) err =fib_table_lookup (tb, flp, res, flags); -if (!err) +if (err != -EAGAIN ) goto out; tb =rcu_dereference_rtnl (net->ipv4.fib_default);if (tb) err =fib_table_lookup (tb, flp, res, flags); -out:if (err == -EAGAIN ) err = -ENETUNREACH ; - +out:rcu_read_unlock ();return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/1067 bpf, lsm: Add disabled BPF LSM hook list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Kuohai <[email protected]>
[ Upstream commit 21c7063f6d08ab9afa088584939791bee0c177e5 ]
Add a disabled hooks list for BPF LSM. progs being attached to the listed hooks will be rejected by the verifier.
Stable-dep-of: 12091470c6b4 ("bpf: Disable xfrm_decode_session hook attachment")
--- kernel/bpf/bpf_lsm.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
kernel/bpf/bpf_lsm.c +29 -2
@@ -36,6 +36,24 @@ BTF_SET_START(bpf_lsm_hooks)#undef LSM_HOOK BTF_SET_END(bpf_lsm_hooks) +BTF_SET_START(bpf_lsm_disabled_hooks) +BTF_ID(func, bpf_lsm_vm_enough_memory) +BTF_ID(func, bpf_lsm_inode_need_killpriv) +BTF_ID(func, bpf_lsm_inode_getsecurity) +BTF_ID(func, bpf_lsm_inode_listsecurity) +BTF_ID(func, bpf_lsm_inode_copy_up_xattr) +BTF_ID(func, bpf_lsm_getselfattr) +BTF_ID(func, bpf_lsm_getprocattr) +BTF_ID(func, bpf_lsm_setprocattr) +#ifdef CONFIG_KEYS +BTF_ID(func, bpf_lsm_key_getsecurity) +#endif +#ifdef CONFIG_AUDIT +BTF_ID(func, bpf_lsm_audit_rule_match) +#endif +BTF_ID(func, bpf_lsm_ismaclabel) +BTF_SET_END(bpf_lsm_disabled_hooks) +/* List of LSM hooks that should operate on 'current' cgroup regardless * of function signature. */
@@ -97,15 +115,24 @@ void bpf_lsm_find_cgroup_shim(const struct bpf_prog *prog,int bpf_lsm_verify_prog (struct bpf_verifier_log *vlog,const struct bpf_prog *prog) { +u32 btf_id = prog->aux->attach_btf_id; +const char *func_name = prog->aux->attach_func_name; +if (!prog->gpl_compatible) {bpf_log (vlog,"LSM programs must have a GPL compatible license\n" );return -EINVAL ; } -if (!btf_id_set_contains (&bpf_lsm_hooks, prog->aux->attach_btf_id)) { +if (btf_id_set_contains (&bpf_lsm_disabled_hooks, btf_id)) { +bpf_log (vlog,"attach_btf_id %u points to disabled hook %s\n" , + btf_id, func_name); +return -EINVAL ; + } + +if (!btf_id_set_contains (&bpf_lsm_hooks, btf_id)) {bpf_log (vlog,"attach_btf_id %u points to wrong type name %s\n" , - prog->aux->attach_btf_id, prog->aux->attach_func_name); + btf_id, func_name);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/1067 bpf: Disable xfrm_decode_session hook attachment
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit 12091470c6b4c1c14b2de12dcbae2ada6cb6d20b ]
BPF LSM programs can currently attach to xfrm_decode_session(). That hook may return an error, but security_skb_classify_flow() calls it from a void path and triggers BUG_ON() if an error is returned.
Disable BPF attachment to the hook to prevent a BPF LSM program from turning packet classification into a full panic.
--- kernel/bpf/bpf_lsm.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/bpf_lsm.c +3 -0
@@ -51,6 +51,9 @@ BTF_ID(func, bpf_lsm_key_getsecurity)#ifdef CONFIG_AUDIT BTF_ID(func, bpf_lsm_audit_rule_match)#endif +#ifdef CONFIG_SECURITY_NETWORK_XFRM +BTF_ID(func, bpf_lsm_xfrm_decode_session) +#endif BTF_ID(func, bpf_lsm_ismaclabel)BTF_SET_END (bpf_lsm_disabled_hooks)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/1067 netfilter: nf_nat: avoid invalid nat_net pointer use on failed nf_nat_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
[ Upstream commit 069cfe3de2a5e16069485893cd04665ab769c1d8 ]
We ran into below KASAN splat, which is mostly uninteresting, beside for having nf_nat_register_fn() in the call chain as a cause for the offending access:
==================================================================
BUG: KASAN: slab-out-of-bounds in nf_nat_register_fn+0x5f9/0x640 Read of size 8 at addr ffff890031e54c20 by task iptables/9510 CPU: 0 UID: 0 PID: 9510 Comm: iptables Not tainted 6.18.18-grsec-full-20260320181326 #1 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> […] dump_stack_lvl+0xee/0x160 ffff88004117eeb8 […] print_report+0x6e/0x640 ffff88004117eee0 […] ? __phys_addr+0x8e/0x140 ffff88004117eef0 […] ? kasan_addr_to_slab+0x51/0xe0 ffff88004117ef08 […] ? complete_report_info+0xec/0x1c0 ffff88004117ef20 […] ? nf_nat_register_fn+0x5f9/0x640 ffff88004117ef48 […] kasan_report+0xbc/0x140 ffff88004117ef50 […] ? nf_nat_register_fn+0x5f9/0x640 ffff88004117ef90 […] nf_nat_register_fn+0x5f9/0x640 ffff88004117eff8 […] ? nf_nat_icmp_reply_translation+0x6e0/0x6e0 ffff88004117f070 […] nf_tables_register_hook.part.0+0xa0/0x220 ffff88004117f080 […] nf_tables_addchain.constprop.0+0x1054/0x1fc0 ffff88004117f0b8 […] ? nft_chain_lookup.part.0+0x4ce/0xac0 ffff88004117f130 […] ? nf_tables_abort+0x3d80/0x3d80 ffff88004117f190 […] ? nf_tables_dumpreset_obj+0x100/0x100 ffff88004117f1c8 […] ? nft_table_lookup.part.0+0x255/0x300 ffff88004117f310 […] ? nf_tables_newchain+0x21a4/0x2fa0 ffff88004117f358 […] nf_tables_newchain+0x21a4/0x2fa0 ffff88004117f360 […] ? nf_tables_addchain.constprop.0+0x1fc0/0x1fc0 ffff88004117f458 […] ? nla_get_range_signed+0x4a0/0x4a0 ffff88004117f488 […] ? lock_acquire+0x16f/0x320 ffff88004117f490 […] ? find_held_lock+0x3b/0xe0 ffff88004117f4b0 […] ? __nla_parse+0x45/0x80 ffff88004117f500 […] nfnetlink_rcv_batch+0xbca/0x19a0 ffff88004117f550 […] ? nfnetlink_net_exit_batch+0x120/0x120 ffff88004117f618 […] ? __sanitizer_cov_trace_switch+0x63/0xe0 ffff88004117f720 […] ? gr_acl_handle_mmap+0x1c4/0x320 ffff88004117f7c0 […] ? nla_get_range_signed+0x4a0/0x4a0 ffff88004117f7e8 […] ? gr_is_capable+0x6f/0xe0 ffff88004117f830 […] ? __nla_parse+0x45/0x80 ffff88004117f860 […] ? skb_pull+0x103/0x1a0 ffff88004117f880 […] nfnetlink_rcv+0x3db/0x4a0 ffff88004117f8b0 […] ? nfnetlink_rcv_batch+0x19a0/0x19a0 ffff88004117f8d8 […] ? netlink_lookup+0xe2/0x240 ffff88004117f900 […] netlink_unicast+0x74b/0xb00 ffff88004117f930 […] ? netlink_attachskb+0xb20/0xb20 ffff88004117f980 […] ? __check_object_size+0x3e/0xaa0 ffff88004117f998 […] ? security_netlink_send+0x51/0x160 ffff88004117f9c8 […] netlink_sendmsg+0xa03/0x1200 ffff88004117f9f8 […] ? netlink_unicast+0xb00/0xb00 ffff88004117fa70 […] ? netlink_unicast+0xb00/0xb00 ffff88004117fac8 […] ? ____sys_sendmsg+0xe2a/0x1040 ffff88004117faf8 […] ____sys_sendmsg+0xe2a/0x1040 ffff88004117fb00 […] ? kernel_recvmsg+0x300/0x300 ffff88004117fb60 […] ? reacquire_held_locks+0xe9/0x260 ffff88004117fbc8 […] ___sys_sendmsg+0x138/0x200 ffff88004117fbf8 […] ? do_recvmmsg+0x7e0/0x7e0 ffff88004117fc30 […] ? lockdep_hardirqs_on_prepare+0x101/0x1e0 ffff88004117fc50 […] ? lock_acquire+0x16f/0x320 ffff88004117fd20 […] ? lock_acquire+0x16f/0x320 ffff88004117fd58 […] ? find_held_lock+0x3b/0xe0 ffff88004117fd70 […] __sys_sendmsg+0x17a/0x260 ffff88004117fdc8 […] ? __sys_sendmsg_sock+0x80/0x80 ffff88004117fdf0 […] ? syscall_trace_enter+0x15e/0x2c0 ffff88004117fe98 […] do_syscall_64+0x7d/0x400 ffff88004117fec8 […] entry_SYSCALL_64_safe_stack+0x4a/0x60 ffff88004117fef8 </TASK> ==================================================================
The out-of-bounds report, though, is a red herring as it is for an access that shouldn't have happened in the first place.
When nf_nat_init() fails to register its BPF kfuncs, it'll unwind and, among others, call unregister_pernet_subsys() to deregister its per-net ops. This makes the previously allocated net id available for reuse by the next caller of register_pernet_subsys(), in our case, synproxy. However, 'nat_net_id' will still hold the previously allocated value.
If nf_nat.o gets build as a module, all this doesn't matter. A failed initialization routine makes the module fail to load and any dependent module won't be able to load either. However, if nf_nat.o is built-in, a failing init won't /completely/ make its functionality unavailable to dependent modules, namely the code and static data is still there, free to be called by modules like nft_chain_nat.ko.
Case in point, nft_chain_nat registers hooks that'll call into nf_nat which, in our case, failed to initialize and therefore won't have a valid net id nor related net_nat object any more.
Code in nf_nat, namely nf_nat_register_fn() and nf_nat_unregister_fn(), still making use of the reallocated net id, lead to a type confusion as the call to net_generic() will no longer return memory belonging to an object suited to fit 'struct nat_net' but 'struct synproxy_net' instead. The latter is only 24 bytes on 64-bit systems, much smaller than struct nat_net which is 176 bytes, perfectly explaining the OOB KASAN report.
Detect and handle a failed nf_nat_init() by testing the 'nf_nat_hook' pointer which will be reset to NULL on initialization errors to prevent the usage of an invalid nat_net pointer.
As this check is only needed when nf_nat.o is built-in, guard it by '#ifndef MODULE...'.
--- net/netfilter/nf_nat_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/netfilter/nf_nat_core.c +10 -0
@@ -998,6 +998,16 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,struct nf_hook_ops *nat_ops;int i, ret; +#ifndef MODULE +/* If nf_nat_core is built-in and nf_nat_init() fails, dependent +* modules like nft_chain_nat.ko may still call this function. +* However, nat_net would be invalid, likely pointing to some other +* per-net structure. +*/ +if (WARN_ON_ONCE (!nf_nat_hook)) +return -EOPNOTSUPP ; +#endif +if (WARN_ON_ONCE (pf >=ARRAY_SIZE (nat_net->nat_proto_net)))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/1067 netfilter: nf_conncount: prevent connlimit drops for early confirmed ct
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit c8b6f36f766991e3ebebec6596daee4b04dcbc49 ]
Commit 69894e5b4c5e ("netfilter: nft_connlimit: update the count if add was skipped") introduced a regression where packets for valid connections are dropped when using connlimit for soft-limiting scenarios.
The issue occurs when a new connection reuses a socket currently in the TIME_WAIT state. In this scenario, the connection tracking entry is evaluated as already confirmed. Previously, __nf_conncount_add() assumed that if a connection was confirmed and did not originate from the loopback interface, it should skip the addition and return -EEXIST.
Skipping the addition triggers a garbage collection run that cleans up the TIME_WAIT connection. Consequently, the active connection count drops to 0, which xt_connlimit mishandles, leading to the false rejection of the perfectly valid new connection.
Fix this by replacing the interface check with protocol-agnostic state checks. We now skip the tree insertion and preserve the lockless garbage collection optimization only if the connection is IPS_ASSURED. This allows early-confirmed setup packets (such as reused TIME_WAIT sockets or locally generated SYN-ACKs) to be properly evaluated and counted without falsely dropping. The goto check_connections path is maintained to ensure these setup packets are deduplicated correctly.
This has been tested with slowhttptest and HTTP server configured locally to ensure we are not breaking soft-limiting scenarios for local or external connections. In addition, it was tested with a OVS zone limit too.
--- net/netfilter/nf_conncount.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/netfilter/nf_conncount.c +5 -6
@@ -179,17 +179,16 @@ static int __nf_conncount_add(struct net *net,return -ENOENT ;if (ct &&nf_ct_is_confirmed (ct)) { -/* local connections are confirmed in postrouting so confirmation -* might have happened before hitting connlimit +/* Connection is confirmed but might still be in the setup phase. +* Only skip the tracking if it is fully assured. This guarantees +* that setup packets or retransmissions are properly counted and +* deduplicated. */ -if (skb->skb_iif !=LOOPBACK_IFINDEX ) { +if (test_bit (IPS_ASSURED_BIT , &ct->status)) { err = -EEXIST ; goto out_put; } -/* this is likely a local connection, skip optimization to avoid -* adding duplicates from a 'packet train' -*/ goto check_connections; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/1067 netfilter: nft_synproxy: stop bypassing the priv->info snapshot
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 11d4bc4e26fb66040a5b5d95e9abf37deac2b1fc ]
nft_synproxy_eval_v4() and nft_synproxy_eval_v6() already take a whole-object READ_ONCE() snapshot of the shared priv->info state before building the SYNACK reply, but nft_synproxy_tcp_options() still masks opts->options with priv->info.options from the live shared object.
When a named synproxy object is updated concurrently with SYN traffic, the eval path can then mix mss and timestamp handling from the local snapshot with an options mask taken from a newer configuration, so one SYNACK no longer reflects a coherent synproxy configuration.
Use info->options so nft_synproxy_tcp_options() stays on the same local snapshot that the eval path already copied from priv->info.
--- net/netfilter/nft_synproxy.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/netfilter/nft_synproxy.c +4 -5
@@ -23,14 +23,13 @@ static const struct nla_policy nft_synproxy_policy[NFTA_SYNPROXY_MAX + 1] = {static void nft_synproxy_tcp_options (struct synproxy_options *opts,const struct tcphdr *tcp,struct synproxy_net *snet, -struct nf_synproxy_info *info, -const struct nft_synproxy *priv) +struct nf_synproxy_info *info) {this_cpu_inc (snet->stats->syn_received);if (tcp->ece && tcp->cwr) opts->options |=NF_SYNPROXY_OPT_ECN ; - opts->options &= priv->info.options; + opts->options &= info->options; opts->mss_encode = opts->mss_option; opts->mss_option = info->mss;if (opts->options &NF_SYNPROXY_OPT_TIMESTAMP )
@@ -55,7 +54,7 @@ static void nft_synproxy_eval_v4(const struct nft_synproxy *priv,if (tcp->syn) {/* Initial SYN from client */ -nft_synproxy_tcp_options (opts, tcp, snet, &info, priv); +nft_synproxy_tcp_options (opts, tcp, snet, &info);synproxy_send_client_synack (net, skb, tcp, opts);consume_skb (skb); regs->verdict.code =NF_STOLEN ;
@@ -86,7 +85,7 @@ static void nft_synproxy_eval_v6(const struct nft_synproxy *priv,if (tcp->syn) {/* Initial SYN from client */ -nft_synproxy_tcp_options (opts, tcp, snet, &info, priv); +nft_synproxy_tcp_options (opts, tcp, snet, &info);synproxy_send_client_synack_ipv6 (net, skb, tcp, opts);consume_skb (skb); regs->verdict.code =NF_STOLEN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/1067 rtc: abx80x: fix the RTC_VL_CLR clearing all status flags
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 419719c514252a2dbb2e2976f564c83417dd6d0a ]
The RTC_VL_CLR ioctl intends to clear only the battery low flag (BLF), however the current implementation writes 0 to the status register, clearing all status bits.
Fix this by writing back the masked status value so that only BLF is cleared, preserving other status flags.
--- drivers/rtc/rtc-abx80x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-abx80x.c +2 -1
@@ -533,7 +533,8 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) status &= ~ABX8XX_STATUS_BLF ; - tmp =i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS ,0 ); + tmp =i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS , + status);if (tmp <0 )return tmp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/1067 NTB: epf: Make db_valid_mask cover only real doorbell bits
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 6eb7e28f1f24a28234add38755687a7ed8bc2654 ]
ndev->db_count includes an unused doorbell slot due to the legacy extra offset in the peer doorbell path. db_valid_mask must cover only the real doorbell bits and exclude the unused slot.
Set db_valid_mask to BIT_ULL(db_count - 1) - 1.
--- drivers/ntb/hw/epf/ntb_hw_epf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ntb/hw/epf/ntb_hw_epf.c +5 -1
@@ -560,7 +560,11 @@ static int ntb_epf_init_dev(struct ntb_epf_dev *ndev)return ret; } - ndev->db_valid_mask =BIT_ULL (ndev->db_count) -1 ; +/* +* ndev->db_count includes an extra skipped slot due to the legacy +* doorbell layout, hence -1. +*/ + ndev->db_valid_mask =BIT_ULL (ndev->db_count -1 ) -1 ; ndev->mw_count =readl (ndev->ctrl_reg +NTB_EPF_MW_COUNT ); ndev->spad_count =readl (ndev->ctrl_reg +NTB_EPF_SPAD_COUNT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/1067 NTB: epf: Report 0-based doorbell vector via ntb_db_event()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 3147f0964cecca15e349cbfbdd6a28eb6d50379d ]
ntb_db_event() expects the vector number to be relative to the first doorbell vector starting at 0.
Vector 0 is reserved for link events in the EPF driver, so doorbells start at vector 1. However, both supported peers (ntb_hw_epf with pci-epf-ntb, and pci-epf-vntb) have historically skipped vector 1 and started doorbells at vector 2.
Pass (irq_no - 2) to ntb_db_event() so doorbells are reported as 0..N-1. If irq_no == 1 is ever observed, warn and ignore it, since the slot is reserved in the legacy layout and reporting it as DB#0 would collide with the real DB#0 slot.
--- drivers/ntb/hw/epf/ntb_hw_epf.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/ntb/hw/epf/ntb_hw_epf.c +13 -3
@@ -69,6 +69,12 @@ enum epf_ntb_bar { NTB_BAR_NUM, }; +enum epf_irq_slot { +EPF_IRQ_LINK =0 , +EPF_IRQ_RESERVED_DB ,/* Historically skipped slot */ +EPF_IRQ_DB_START , +}; +#define NTB_EPF_MAX_MW_COUNT (NTB_BAR_NUM - BAR_MW1)struct ntb_epf_dev {
@@ -322,10 +328,14 @@ static irqreturn_t ntb_epf_vec_isr(int irq, void *dev) irq_no = irq - ndev->irq_base; ndev->db_val = irq_no +1 ; -if (irq_no ==0 ) +if (irq_no ==EPF_IRQ_LINK ) {ntb_link_event (&ndev->ntb); -else -ntb_db_event (&ndev->ntb, irq_no); + }else if (irq_no ==EPF_IRQ_RESERVED_DB ) { +dev_warn_ratelimited (ndev->dev, +"Unexpected reserved doorbell slot IRQ received\n" ); + }else { +ntb_db_event (&ndev->ntb, irq_no -EPF_IRQ_DB_START ); + }return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/1067 NTB: epf: Fix doorbell bitmask and IRQ vector handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit 4fdea8dbb62d746429498e07385a3ba0b0f6d1ab ]
The EPF driver currently stores the incoming doorbell as a vector number (irq_no + 1) in db_val and db_clear() clears all bits unconditionally. This breaks db_read()/db_clear() semantics when multiple doorbells are used.
Store doorbells as a bitmask (BIT_ULL(vector)) and make db_clear(db_bits) clear only the specified bits. Use atomic64 operations as db_val is updated from interrupt context.
Once db_val is stored as a bitmask, the ISR's doorbell vector is used not only for ntb_db_event(), but also as the bit index for BIT_ULL(). The existing ISR derives that vector by subtracting pci_irq_vector(pdev,
0) from the Linux IRQ number passed to the handler, but Linux IRQ numbers are not guaranteed to be contiguous.
Pass per-vector context as request_irq() dev_id instead, so the ISR gets the device vector directly.
Validate the doorbell vector before updating db_val or calling ntb_db_event(), so an unexpected vector cannot create an invalid shift or be reported to NTB clients.
While at it, read and validate mw_count before requesting interrupt vectors. An unsupported memory-window count does not need IRQs, and failing before ntb_epf_init_isr() keeps the probe error path simple.
--- drivers/ntb/hw/epf/ntb_hw_epf.c | 61 +++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-)
drivers/ntb/hw/epf/ntb_hw_epf.c +39 -22
@@ -6,6 +6,7 @@* Author: Kishon Vijay Abraham I <[email protected]> */ +#include <linux/atomic.h> #include <linux/delay.h> #include <linux/module.h> #include <linux/pci.h>
@@ -77,6 +78,13 @@ enum epf_irq_slot {#define NTB_EPF_MAX_MW_COUNT (NTB_BAR_NUM - BAR_MW1) +struct ntb_epf_dev ; + +struct ntb_epf_irq_ctx { +struct ntb_epf_dev *ndev; +unsigned int irq_no; +}; +struct ntb_epf_dev {struct ntb_dev ntb;struct device *dev;
@@ -96,9 +104,9 @@ struct ntb_epf_dev {unsigned int self_spad;unsigned int peer_spad; -int db_val; +atomic64_t db_val;u64 db_valid_mask; -int irq_base; +struct ntb_epf_irq_ctx irq_ctx[NTB_EPF_MAX_DB_COUNT +1 ]; };#define ntb_ndev (__ntb) container_of(__ntb, struct ntb_epf_dev, ntb)
@@ -322,11 +330,10 @@ static int ntb_epf_link_disable(struct ntb_dev *ntb)static irqreturn_t ntb_epf_vec_isr (int irq,void *dev) { -struct ntb_epf_dev *ndev = dev; -int irq_no; - - irq_no = irq - ndev->irq_base; - ndev->db_val = irq_no +1 ; +struct ntb_epf_irq_ctx *ctx = dev; +struct ntb_epf_dev *ndev = ctx->ndev; +unsigned int db_vector; +unsigned int irq_no = ctx->irq_no;if (irq_no ==EPF_IRQ_LINK ) {ntb_link_event (&ndev->ntb);
@@ -334,7 +341,17 @@ static irqreturn_t ntb_epf_vec_isr(int irq, void *dev)dev_warn_ratelimited (ndev->dev,"Unexpected reserved doorbell slot IRQ received\n" ); }else { -ntb_db_event (&ndev->ntb, irq_no -EPF_IRQ_DB_START ); + db_vector = irq_no -EPF_IRQ_DB_START ; +if (ndev->db_count <NTB_EPF_MIN_DB_COUNT || + db_vector >= ndev->db_count -1 ) { +dev_warn_ratelimited (ndev->dev, +"Unexpected doorbell vector %u (db_count %u)\n" , + db_vector, ndev->db_count); +return IRQ_HANDLED ; + } + +atomic64_or (BIT_ULL (db_vector), &ndev->db_val); +ntb_db_event (&ndev->ntb, db_vector); }return IRQ_HANDLED ;
@@ -361,18 +378,18 @@ static int ntb_epf_init_isr(struct ntb_epf_dev *ndev, int msi_min, int msi_max) argument &= ~MSIX_ENABLE ; } - ndev->irq_base =pci_irq_vector (pdev,0 ); + ndev->db_count = irq -1 ;for (i =0 ; i < irq; i++) { + ndev->irq_ctx[i].ndev = ndev; + ndev->irq_ctx[i].irq_no = i; ret =request_irq (pci_irq_vector (pdev, i), ntb_epf_vec_isr, -0 ,"ntb_epf" , ndev); +0 ,"ntb_epf" , &ndev->irq_ctx[i]);if (ret) {dev_err (dev,"Failed to request irq\n" ); goto err_free_irq; } } - ndev->db_count = irq -1 ; - ret =ntb_epf_send_command (ndev,CMD_CONFIGURE_DOORBELL , argument | irq);if (ret) {
@@ -384,7 +401,7 @@ static int ntb_epf_init_isr(struct ntb_epf_dev *ndev, int msi_min, int msi_max) err_free_irq:while (i--) -free_irq (pci_irq_vector (pdev, i), ndev); +free_irq (pci_irq_vector (pdev, i), &ndev->irq_ctx[i]);pci_free_irq_vectors (pdev);return ret;
@@ -509,7 +526,7 @@ static u64 ntb_epf_db_read(struct ntb_dev *ntb) {struct ntb_epf_dev *ndev =ntb_ndev (ntb); -return ndev->db_val; +return atomic64_read (&ndev->db_val); }static int ntb_epf_db_clear_mask (struct ntb_dev *ntb,u64 db_bits)
@@ -521,7 +538,7 @@ static int ntb_epf_db_clear(struct ntb_dev *ntb, u64 db_bits) {struct ntb_epf_dev *ndev =ntb_ndev (ntb); - ndev->db_val =0 ; +atomic64_and (~db_bits, &ndev->db_val);return 0 ; }
@@ -562,6 +579,12 @@ static int ntb_epf_init_dev(struct ntb_epf_dev *ndev)struct device *dev = ndev->dev;int ret; + ndev->mw_count =readl (ndev->ctrl_reg +NTB_EPF_MW_COUNT ); +if (ndev->mw_count >NTB_EPF_MAX_MW_COUNT ) { +dev_err (dev,"Unsupported MW count: %u\n" , ndev->mw_count); +return -EINVAL ; + } +/* One Link interrupt and rest doorbell interrupt */ ret =ntb_epf_init_isr (ndev,NTB_EPF_MIN_DB_COUNT +1 ,NTB_EPF_MAX_DB_COUNT +1 );
@@ -575,14 +598,8 @@ static int ntb_epf_init_dev(struct ntb_epf_dev *ndev)* doorbell layout, hence -1. */ ndev->db_valid_mask =BIT_ULL (ndev->db_count -1 ) -1 ; - ndev->mw_count =readl (ndev->ctrl_reg +NTB_EPF_MW_COUNT ); ndev->spad_count =readl (ndev->ctrl_reg +NTB_EPF_SPAD_COUNT ); -if (ndev->mw_count >NTB_EPF_MAX_MW_COUNT ) { -dev_err (dev,"Unsupported MW count: %u\n" , ndev->mw_count); -return -EINVAL ; - } -return 0 ; }
@@ -681,7 +698,7 @@ static void ntb_epf_cleanup_isr(struct ntb_epf_dev *ndev)ntb_epf_send_command (ndev,CMD_TEARDOWN_DOORBELL , ndev->db_count +1 );for (i =0 ; i < ndev->db_count +1 ; i++) -free_irq (pci_irq_vector (pdev, i), ndev); +free_irq (pci_irq_vector (pdev, i), &ndev->irq_ctx[i]);pci_free_irq_vectors (pdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/1067 alpha/PCI: Add security_locked_down() check to pci_mmap_resource()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 78a228f0aa0e9eba31955950c8a40a9945e2c8bb ]
Currently, Alpha's pci_mmap_resource() does not check security_locked_down(LOCKDOWN_PCI_ACCESS) before allowing userspace to mmap PCI BARs.
The generic version has had this check since commit eb627e17727e ("PCI:
Lock down BAR access when the kernel is locked down") to prevent DMA attacks when the kernel is locked down.
Add the same check to Alpha's pci_mmap_resource().
--- arch/alpha/kernel/pci-sysfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/alpha/kernel/pci-sysfs.c +6 -1
@@ -11,6 +11,7 @@*/ #include <linux/sched.h> +#include <linux/security.h> #include <linux/stat.h> #include <linux/slab.h> #include <linux/pci.h>
@@ -71,7 +72,11 @@ static int pci_mmap_resource(struct kobject *kobj,struct resource *res = attr->private;enum pci_mmap_state mmap_type;struct pci_bus_region bar; -int i; +int i, ret; + + ret =security_locked_down (LOCKDOWN_PCI_ACCESS ); +if (ret) +return ret;for (i =0 ; i <PCI_STD_NUM_BARS ; i++)if (res == &pdev->resource[i])
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/1067 alpha/PCI: Fix __pci_mmap_fits() overflow for zero-length BARs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 802a3b3f470b9bc1148f26e01fc9cbfeb4dfcb57 ]
Currently, __pci_mmap_fits() computes the BAR size using "pci_resource_len() - 1", which wraps to a large value when the BAR length is zero, causing the bounds check to incorrectly succeed.
Add an early return for empty resources.
--- arch/alpha/kernel/pci-sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/alpha/kernel/pci-sysfs.c +5 -1
@@ -37,12 +37,16 @@ static int hose_mmap_page_range(struct pci_controller *hose,static int __pci_mmap_fits (struct pci_dev *pdev,int num,struct vm_area_struct *vma,int sparse) { +resource_size_t len =pci_resource_len (pdev, num);unsigned long nr, start, size;int shift = sparse ?5 :0 ; +if (!len) +return 0 ; + nr =vma_pages (vma); start = vma->vm_pgoff; - size = ((pci_resource_len (pdev, num) -1 ) >> (PAGE_SHIFT - shift)) +1 ; + size = ((len -1 ) >> (PAGE_SHIFT - shift)) +1 ;if (start < size && size - start >= nr)return 1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/1067 net, bpf: check master for NULL in xdp_master_redirect()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit e82d8cc4321c373dc46e741cd2dfdaa7921fddb7 ]
xdp_master_redirect() dereferences the result of netdev_master_upper_dev_get_rcu() without a NULL check, but that helper returns NULL when the receiving device has no upper-master adjacency.
The reach guard only checks netif_is_bond_slave(). On bond slave release bond_upper_dev_unlink() drops the upper-master adjacency before clearing IFF_SLAVE, so an XDP_TX reaching xdp_master_redirect() in that window still passes netif_is_bond_slave() while master is already NULL, and faults on master->flags at offset 0xb0:
BUG: kernel NULL pointer dereference, address: 00000000000000b0 RIP: 0010:xdp_master_redirect (net/core/filter.c:4432) Call Trace: xdp_master_redirect (net/core/filter.c:4432) bpf_prog_run_generic_xdp (include/net/xdp.h:700) do_xdp_generic (net/core/dev.c:5608) __netif_receive_skb_one_core (net/core/dev.c:6204) process_backlog (net/core/dev.c:6319) __napi_poll (net/core/dev.c:7729) net_rx_action (net/core/dev.c:7792) handle_softirqs (kernel/softirq.c:622) __dev_queue_xmit (include/linux/bottom_half.h:33) packet_sendmsg (net/packet/af_packet.c:3082) __sys_sendto (net/socket.c:2252) Kernel panic - not syncing: Fatal exception in interrupt
The missing check dates back to the original code; commit 1921f91298d1 ("net, bpf: fix null-ptr-deref in xdp_master_redirect() for down master") later added the master->flags read where the fault now lands but kept the unconditional deref. Check master for NULL before use; a NULL master is treated the same as one that is not up.
--- net/core/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/filter.c +1 -1
@@ -4307,7 +4307,7 @@ u32 xdp_master_redirect(struct xdp_buff *xdp)struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info); master =netdev_master_upper_dev_get_rcu (xdp->rxq->dev); -if (unlikely (!(master->flags &IFF_UP ))) +if (unlikely (!master || !(master->flags &IFF_UP )))return XDP_ABORTED ; slave = master->netdev_ops->ndo_xdp_get_xmit_slave (master, xdp);if (slave && slave != xdp->rxq->dev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/1067 net: dsa: sja1105: round up PTP perout pin duration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrova Alyona <[email protected]>
[ Upstream commit aee5836273b07b439fb245fb43930664d8b78518 ]
pin_duration is converted from the user-provided period to SJA1105 clock ticks and is later passed as the cycle_time argument to future_base_time().
Very small period values may become zero after the conversion, which can lead to a division by zero in future_base_time().
Round zero pin_duration up to 1 tick so that the smallest unsupported periods use the minimum non-zero hardware duration instead of passing zero to future_base_time().
--- drivers/net/dsa/sja1105/sja1105_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/sja1105/sja1105_ptp.c +1 -1
@@ -755,7 +755,7 @@ static int sja1105_per_out_enable(struct sja1105_private *priv,* 2 edges on PTP_CLK. So check for truncation which happens * at periods larger than around 68.7 seconds. */ - pin_duration =ns_to_sja1105_ticks (pin_duration /2 ); + pin_duration =max_t (u64,ns_to_sja1105_ticks (pin_duration /2 ),1 );if (pin_duration >U32_MAX ) { rc = -ERANGE ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/1067 veth: fix NAPI leak in XDP enable error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 6739027cb72da26890edd424c77080d187b2a92e ]
During XDP enablement in veth, if xdp_rxq_info_reg() or xdp_rxq_info_reg_mem_model() fails, the driver rolls back the changes.
However, the rollback loop:
for (i--; i >= start; i--) {decrements the loop index 'i' before the first iteration. This correctly skips unregistering the rxq for the failed index 'i' (as registration failed or was already cleaned up), but it also erroneously skips calling netif_napi_deli() for rq[i].xdp_napi.
Since netif_napi_add() was already called for index 'i', this leaves a dangling napi_struct in the device's napi_list. When the veth device is later destroyed, the freed queue memory (which contains the leaked NAPI structure) can be reused.
The subsequent device teardown iterates the NAPI list and corrupts the reallocated memory, leading to UAF.
Fix this by explicitly deleting the NAPI association for the failed index 'i' before rolling back the successfully configured queues.
--- drivers/net/veth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/veth.c +2 -0
@@ -1082,6 +1082,8 @@ static int veth_enable_xdp_range(struct net_device *dev, int start, int end, err_reg_mem:xdp_rxq_info_unreg (&priv->rq[i].xdp_rxq); err_rxq_reg: +if (!napi_already_on) +netif_napi_del (&priv->rq[i].xdp_napi);for (i--; i >= start; i--) {struct veth_rq *rq = &priv->rq[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/1067 net/sched: cls_api: Handle TC_ACT_CONSUMED in tcf_qevent_handle
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit a8a02897f2b479127db261de05cbf0c28b98d159 ]
tcf_classify() can return TC_ACT_CONSUMED while the skb is held by the defragmentation engine (e.g. act_ct on out-of-order fragments). When that happens the skb is no longer owned by the caller and must not be touched again.
tcf_qevent_handle() did not handle TC_ACT_CONSUMED: it fell through the switch and returned the skb to the caller as if classification had passed. The only qdisc that wires up qevents today is RED, via three call sites (qe_mark on RED_PROB_MARK/HARD_MARK, qe_early_drop on congestion_drop) red_enqueue() was continuing to operate on an skb it no longer owns in this case -- enqueueing it, dropping it, or updating statistics. Resulting in a UAF.
tc qdisc add dev eth0 root handle 1: red ... qevent early_drop block 10 tc filter add block 10 ... action ct
(with ct defrag enabled and traffic that produces out-of-order fragments, e.g. a fragmented UDP stream)
Handle TC_ACT_CONSUMED in tcf_qevent_handle() the same way the ingress and egress fast paths do: treat it as stolen and return NULL without touching the skb. Unlike the TC_ACT_STOLEN case, the skb must not be dropped/freed here, as it is no longer owned by us.
--- net/sched/cls_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/cls_api.c +3 -0
@@ -3758,6 +3758,9 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struskb_do_redirect (skb); *ret = __NET_XMIT_STOLEN;return NULL ; +case TC_ACT_CONSUMED : + *ret = __NET_XMIT_STOLEN; +return NULL ; }return skb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/1067 ipv6: fix error handling in disable_ipv6 sysctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit c779441e5070e2268bdfe77f6e2e0de926c431e3 ]
When writing to the disable_ipv6 sysctl, if proc_dointvec() fails to parse the input, it returns a negative error code. The current implementation is overwriting that error for write operations.
This results in a silent failure, it returns a successful write although the configuration was not modified at all. When modifying the "all" variant it can also modify the configuration of existing interfaces to the wrong value.
Fix this by checking the return value of proc_dointvec() and returning early on failure.
--- net/ipv6/addrconf.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/addrconf.c +2 -0
@@ -6376,6 +6376,8 @@ static int addrconf_sysctl_disable(struct ctl_table *ctl, int write, lctl.data = &val; ret =proc_dointvec (&lctl, write, buffer, lenp, ppos); +if (ret) +return ret;if (write) ret =addrconf_disable_ipv6 (ctl, valp, val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/1067 rtc: ds1307: handle oscillator stop flag for ds1337/ds1339/ds3231
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ronan Dalton <[email protected]>
[ Upstream commit a091e1ba3b68cabc9caedafc6f81d9fe9b3b2200 ]
Prior to commit 48458654659c ("rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe"), the oscillator stop flag (OSF) bit was checked during device probe for the ds1337, ds1339, ds1341, and ds3231 chips; if it was set, it would be cleared and a warning would be logged saying "SET TIME!". Since that commit, the OSF bit is no longer cleared, but the warning is still printed.
Directly following that commit, there was no way to get rid of this warning because nothing cleared the OSF bit on these chips.
The commit associated with the previous commit, 523923cfd5d6 ("rtc:
ds1307: handle oscillator stop flag (OSF) for ds1341"), made proper use of the OSF when getting and setting the time in the RTC. However, the other RTC variants ds1337, ds1339 and ds3231 didn't have a corresponding change made.
Given that the OSF bit is no longer cleared at probe time when it is set, the remaining three chips should have the same handling as the ds1341 chip has for the OSF bit.
Fix the issue on the ds1337, ds1339 and ds3231 chips by applying the same logic as the ds1341 has to these chips.
Note that any devices brought up between the first referenced commit and this one may begin mistrusting the time reported by the RTC until it is set again, if the bit was never explicitly cleared.
Note that only the ds1339 was tested with this change, but the datasheets for the other chips contain essentially identical descriptions of the OSF bit so the same change should work.
--- drivers/rtc/rtc-ds1307.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/rtc/rtc-ds1307.c +17 -11
@@ -263,6 +263,16 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)if (tmp &DS1338_BIT_OSF )return -EINVAL ;break ; +case ds_1337: +case ds_1339: +case ds_1341: +case ds_3231: + ret =regmap_read (ds1307->regmap,DS1337_REG_STATUS , &tmp); +if (ret) +return ret; +if (tmp &DS1337_BIT_OSF ) +return -EINVAL ; +break ;case ds_1340:if (tmp & DS1340_BIT_nEOSC)return -EINVAL ;
@@ -273,13 +283,6 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)if (tmp &DS1340_BIT_OSF )return -EINVAL ;break ; -case ds_1341: - ret =regmap_read (ds1307->regmap,DS1337_REG_STATUS , &tmp); -if (ret) -return ret; -if (tmp &DS1337_BIT_OSF ) -return -EINVAL ; -break ;case ds_1388: ret =regmap_read (ds1307->regmap,DS1388_REG_FLAG , &tmp);if (ret)
@@ -374,14 +377,17 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)regmap_update_bits (ds1307->regmap,DS1307_REG_CONTROL ,DS1338_BIT_OSF ,0 );break ; -case ds_1340: -regmap_update_bits (ds1307->regmap,DS1340_REG_FLAG , -DS1340_BIT_OSF ,0 ); -break ; +case ds_1337: +case ds_1339:case ds_1341: +case ds_3231:regmap_update_bits (ds1307->regmap,DS1337_REG_STATUS ,DS1337_BIT_OSF ,0 );break ; +case ds_1340: +regmap_update_bits (ds1307->regmap,DS1340_REG_FLAG , +DS1340_BIT_OSF ,0 ); +break ;case ds_1388:regmap_update_bits (ds1307->regmap,DS1388_REG_FLAG ,DS1388_BIT_OSF ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/1067 ipv6: fix error handling in ignore_routes_with_linkdown sysctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit cf4f2b14401f29ccac56393ca9e4b42a2505f540 ]
When writing to the ignore_routes_with_linkdown sysctl, if proc_dointvec() fails to parse the input, it returns a negative error code. The current implementation is overwriting that error for write operations.
This results in a silent failure, it returns a successful write although the configuration was not modified at all. When modifying the "all" variant it can also modify the configuration of existing interfaces to the wrong value.
Fix this by checking the return value of proc_dointvec() and returning early on failure.
--- net/ipv6/addrconf.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/addrconf.c +2 -0
@@ -6574,6 +6574,8 @@ int addrconf_sysctl_ignore_routes_with_linkdown(struct ctl_table *ctl, lctl.data = &val; ret =proc_dointvec (&lctl, write, buffer, lenp, ppos); +if (ret) +return ret;if (write) ret =addrconf_fixup_linkdown (ctl, valp, val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/1067 ipv6: fix error handling in forwarding sysctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 058b9b19f9639fe1e1225a17c540f61b65bee6ad ]
When writing to the forwarding sysctl, if proc_dointvec() fails to parse the input, it returns a negative error code. The current implementation is overwriting that error for write operations.
This results in a silent failure, it returns a successful write although the configuration was not modified at all. When modifying the "all" variant it can also modify the configuration of existing interfaces to the wrong value.
Fix this by checking the return value of proc_dointvec() and returning early on failure. In addition, adjust return code of addrconf_fixup_forwarding() for successful operation.
--- net/ipv6/addrconf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/addrconf.c +3 -1
@@ -916,7 +916,7 @@ static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)if (newf)rt6_purge_dflt_routers (net); -return 1 ; +return 0 ; }static void addrconf_linkdown_change (struct net *net,__s32 newf)
@@ -6279,6 +6279,8 @@ static int addrconf_sysctl_forward(struct ctl_table *ctl, int write, lctl.data = &val; ret =proc_dointvec (&lctl, write, buffer, lenp, ppos); +if (ret) +return ret;if (write) ret =addrconf_fixup_forwarding (ctl, valp, val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/1067 ipv6: fix error handling in disable_policy sysctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 3e0e51c0ee1d08cc9d48dc17f3248d5b31cf8066 ]
When writing to the disable_policy sysctl, if proc_dointvec() fails to parse the input, it returns a negative error code. The current implementation is resetting the position argument even if an error occurred during proc_dointvec() and not only during sysctl restart.
Fix this by checking the return value of proc_dointvec() and returning early on failure.
--- net/ipv6/addrconf.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/addrconf.c +2 -0
@@ -6673,6 +6673,8 @@ static int addrconf_sysctl_disable_policy(struct ctl_table *ctl, int write, lctl = *ctl; lctl.data = &val; ret =proc_dointvec (&lctl, write, buffer, lenp, ppos); +if (ret) +return ret;if (write && (*valp != val)) ret =addrconf_disable_policy (ctl, valp, val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/1067 smb/client: preserve errors from smb2_set_sparse()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huiwen He <[email protected]>
[ Upstream commit 2a4b3d2db5c6fcdba889baf7b2ae5661b0beac89 ]
smb2_set_sparse() converts every FSCTL_SET_SPARSE failure to false and marks sparse support as broken for the share. Callers therefore report EOPNOTSUPP even for errors such as ENOSPC or EACCES, and later sparse operations remain disabled until the share is unmounted.
Return the SMB2 ioctl error directly. Set broken_sparse_sup only for EOPNOTSUPP, which indicates that the server does not support the request.
Update smb3_punch_hole() to propagate the error returned by smb2_set_sparse().
--- fs/smb/client/smb2ops.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
fs/smb/client/smb2ops.c +15 -15
@@ -1924,8 +1924,9 @@ smb2_sync_write(const unsigned int xid, struct cifs_fid *pfid, }/* Set or clear the SPARSE_FILE attribute based on value passed in setsparse */ -static bool smb2_set_sparse (const unsigned int xid,struct cifs_tcon *tcon, -struct cifsFileInfo *cfile,struct inode *inode,__u8 setsparse) +static int smb2_set_sparse (const unsigned int xid,struct cifs_tcon *tcon, +struct cifsFileInfo *cfile,struct inode *inode, +__u8 setsparse) {struct cifsInodeInfo *cifsi;int rc;
@@ -1934,31 +1935,31 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,/* if file already sparse don't bother setting sparse again */ if ((cifsi->cifsAttrs &FILE_ATTRIBUTE_SPARSE_FILE ) && setsparse) -return true;/* already sparse */ +return 0 ;/* already sparse */ if (!(cifsi->cifsAttrs &FILE_ATTRIBUTE_SPARSE_FILE ) && !setsparse) -return true;/* already not sparse */ +return 0 ;/* already not sparse */ /* * Can't check for sparse support on share the usual way via the * FS attribute info (FILE_SUPPORTS_SPARSE_FILES) on the share * since Samba server doesn't set the flag on the share, yet * supports the set sparse FSCTL and returns sparse correctly -* in the file attributes. If we fail setting sparse though we -* mark that server does not support sparse files for this share -* to avoid repeatedly sending the unsupported fsctl to server -* if the file is repeatedly extended. +* in the file attributes. If the server returns EOPNOTSUPP, mark +* that sparse files are not supported on this share to avoid +* repeatedly sending the unsupported FSCTL. */ if (tcon->broken_sparse_sup) -return false; +return -EOPNOTSUPP ; rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid,FSCTL_SET_SPARSE , &setsparse,1 , CIFSMaxBufSize,NULL ,NULL );if (rc) { - tcon->broken_sparse_sup = true; +if (rc == -EOPNOTSUPP ) + tcon->broken_sparse_sup = true;cifs_dbg (FYI ,"set sparse rc = %d\n" , rc); -return false; +return rc; }if (setsparse)
@@ -1966,7 +1967,7 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,else cifsi->cifsAttrs &= (~FILE_ATTRIBUTE_SPARSE_FILE ); -return true; +return 0 ; } static int
@@ -3576,10 +3577,9 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,inode_lock (inode);/* Need to make file sparse, if not already, before freeing range. */ /* Consider adding equivalent for compressed since it could also work */ -if (!smb2_set_sparse (xid, tcon, cfile, inode, set_sparse)) { - rc = -EOPNOTSUPP ; + rc =smb2_set_sparse (xid, tcon, cfile, inode, set_sparse); +if (rc) goto out; - }filemap_invalidate_lock (inode->i_mapping);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/1067 rtc: ds1307: Fix off-by-one issue with wday for rx8130
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fredrik M Olsson <[email protected]>
[ Upstream commit 6882aab3c66112b33b251be95c09c8ead3e8d580 ]
The RTC represent each weekday with a individual bit set in the WDAY register, where the 0th bit represent the first day of the week and the 6th bit represents the last day of the week. For each passed day the chip performs a rotary-left-shift by one to advance the weekday by one.
The tm_wday field represent weekdays by a value in the range of 0-6.
The fls() function return the bit index of the last bit set. To handle when there are no bits set it will return 0, and if the 0th bit is set it will return 1, and if the 1st bit is set it will return 2, and so on.
In order to make the result of the fls() function fall into the expected range of 0-6 (instead of 1-7) this patch subtracts one from the result (which matches how the value is written in ds1307_set_time()).
--- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1307.c +1 -1
@@ -305,7 +305,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) t->tm_hour =bcd2bin (tmp);/* rx8130 is bit position, not BCD */ if (ds1307->type == rx_8130) - t->tm_wday =fls (regs[DS1307_REG_WDAY ] &0x7f ); + t->tm_wday =fls (regs[DS1307_REG_WDAY ] &0x7f ) -1 ;else t->tm_wday =bcd2bin (regs[DS1307_REG_WDAY ] &0x07 ) -1 ; t->tm_mday =bcd2bin (regs[DS1307_REG_MDAY ] &0x3f );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/1067 rtc: cmos: unregister HPET IRQ handler on probe failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit a5bb580df018b5d1c5668f05f7979044fb19e23a ]
cmos_do_probe() registers cmos_interrupt() as the HPET RTC IRQ handler before requesting the RTC IRQ and registering the RTC device. If either request_irq() or devm_rtc_register_device() fails afterwards, the error path leaves the HPET RTC IRQ handler installed. This leaves a stale handler behind and make a later hpet_register_irq_handler() fail with -EBUSY.
Track whether the HPET handler was registered successfully and undo the registration on the probe error path. Also mask the HPET RTC IRQ bits to match the normal shutdown cleanup.
--- drivers/rtc/rtc-cmos.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/rtc/rtc-cmos.c +6 -0
@@ -928,6 +928,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)unsigned char rtc_control;unsigned address_space;u32 flags =0 ; +bool hpet_registered = false;struct nvmem_config nvmem_cfg = { .name ="cmos_nvram" , .word_size =1 ,
@@ -1078,6 +1079,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) " failed in rtc_init()."); goto cleanup1; } + hpet_registered = true; }else rtc_cmos_int_handler = cmos_interrupt;
@@ -1127,6 +1129,10 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)if (is_valid_irq (rtc_irq))free_irq (rtc_irq, cmos_rtc.rtc); cleanup1: +if (hpet_registered) { +hpet_mask_rtc_irq_bit (RTC_IRQMASK ); +hpet_unregister_irq_handler (cmos_interrupt); + } cmos_rtc.dev =NULL ; cleanup0:if (RTC_IOMAPPED )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/1067 net: mvneta: re-enable percpu interrupt on resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit fd398d6480987e4c84fff0aaab6b9d6642a93343 ]
On Marvell MPIC platforms (Armada 370/XP/38x), mvneta uses a percpu IRQ disable/enable scheme for NAPI: the ISR (mvneta_percpu_isr) calls disable_percpu_irq() to mask the MPIC per-CPU interrupt and schedules NAPI poll, which calls enable_percpu_irq() on completion to unmask.
If suspend occurs while NAPI poll is pending (between disable_percpu_irq in the ISR and enable_percpu_irq in poll completion), the interrupt is never re-enabled:
1. mvneta_percpu_isr: disable_percpu_irq() + napi_schedule() => MPIC masked, percpu_enabled cpumask bit cleared
2. NAPI poll does not complete before suspend proceeds (on PREEMPT_RT this is highly likely since softirqs run in ksoftirqd which gets frozen; on non-RT it can happen when softirq processing is deferred to ksoftirqd)
3. mvneta_stop_dev => napi_disable(): cancels the pending poll without executing the completion path
4. suspend_device_irqs => IRQCHIP_MASK_ON_SUSPEND: masks MPIC (already masked, but records IRQS_SUSPENDED)
5. Resume: mpic_resume checks irq_percpu_is_enabled() => false (bit was cleared in step 1) => skips unmask
6. mvneta_start_dev only restores device-level INTR_NEW_MASK, does not touch the MPIC per-CPU mask
Result: MPIC per-CPU interrupt stays masked permanently. The NIC generates interrupts (INTR_NEW_CAUSE != 0) but the CPU never receives them, causing complete loss of network connectivity.
Fix by calling on_each_cpu(mvneta_percpu_enable) in the resume path to unconditionally unmask the MPIC per-CPU interrupt regardless of pre-suspend state.
--- drivers/net/ethernet/marvell/mvneta.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +3 -0
@@ -5799,6 +5799,9 @@ static int mvneta_resume(struct device *device)rtnl_unlock ();mvneta_set_rx_mode (dev); +if (!pp->neta_armada3700) +on_each_cpu (mvneta_percpu_enable, pp, true); + return 0; }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/1067 net: sungem: fix probe error cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 36dea2f639249460d13f6ca66b2a9064187cd34d ]
gem_init_one() calls gem_remove_one() when register_netdev() fails. gem_remove_one() unregisters and frees resources owned by the net_device, including the DMA block, MMIO mapping, PCI regions, and the net_device itself. gem_init_one() then falls through to its own cleanup labels and frees the same resources again.
Keep the register_netdev() error path in gem_init_one(): clear drvdata so PM/remove paths do not see a half-registered device, remove the NAPI instance added during probe, and let the existing cleanup labels release the resources once.
The issue was found by a local static-analysis checker for probe error paths. The reported path was manually inspected before sending this fix.
Compile-tested with CONFIG_SUNGEM=y. Runtime testing was not performed because no sungem hardware is available.
--- drivers/net/ethernet/sun/sungem.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/sun/sungem.c +9 -4
@@ -2985,10 +2985,10 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->max_mtu =GEM_MAX_MTU ;/* Register with kernel */ -if (register_netdev (dev)) { + err =register_netdev (dev); +if (err) {pr_err ("Cannot register net device, aborting\n" ); - err = -ENOMEM ; - goto err_out_free_consistent; + goto err_out_clear_drvdata; }/* Undo the get_cell with appropriate locking (we could use
@@ -3002,8 +3002,13 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->dev_addr);return 0 ; +err_out_clear_drvdata: +pci_set_drvdata (pdev,NULL ); +netif_napi_del (&gp->napi); + err_out_free_consistent: -gem_remove_one (pdev); +dma_free_coherent (&pdev->dev,sizeof (struct gem_init_block ), + gp->init_block, gp->gblock_dvma); err_out_iounmap:gem_put_cell (gp);iounmap (gp->regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/1067 ASoC: fsl_asrc_dma: fix eDMA maxburst misalignment with channel count
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit cf6f56990ea21172e085f0588e5bbf2089ce8f58 ]
The back-end consumes data in units of the number of channels. When the maxburst value is not evenly divisible by the channel count, the DMA transfer length does not align with the FIFO frame boundary, causing wrong data to be copied and audible noise at the end of the stream.
This is specific to eDMA: eDMA only responds to DMA requests from the back-end, whereas SDMA handles requests from both the front-end and the back-end and is not affected.
For eDMA, when the back-end maxburst is not evenly divisible by the channel count, align it to the nearest valid boundary:
- If maxburst >= channel count, override to the channel count so each transfer corresponds to exactly one audio frame.
- If maxburst < channel count, override to 1 to avoid partial-frame transfers.
Retain the original maxburst for SDMA or when it already aligns with the channel count.
--- sound/soc/fsl/fsl_asrc_dma.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/soc/fsl/fsl_asrc_dma.c +20 -0
@@ -275,6 +275,26 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, config_be.dst_addr_width = buswidth; config_be.dst_maxburst = dma_params_be->maxburst; +/* +* For eDMA, the back-end may report a maxburst size that is not evenly +* divisible by the channel count. This causes the DMA transfer length +* to misalign with the FIFO boundary, resulting in wrong data and +* audible noise. Align maxburst to the nearest valid boundary: +* - If maxburst >= channel count, override to the channel count so +* each transfer equals exactly one audio frame. +* - If maxburst < channel count, override to 1 to avoid partial-frame +* transfers. +*/ +if (asrc->use_edma && (dma_params_be->maxburst %params_channels (params))) { +if (dma_params_be->maxburst >=params_channels (params)) { + config_be.src_maxburst =params_channels (params); + config_be.dst_maxburst =params_channels (params); + }else { + config_be.src_maxburst =1 ; + config_be.dst_maxburst =1 ; + } + } +memset (&audio_config,0 ,sizeof (audio_config)); config_be.peripheral_config = &audio_config; config_be.peripheral_size =sizeof (audio_config);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/1067 dt-bindings: net: renesas,ether: Drop example "ethernet-phy-ieee802.3-c22" fallback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <[email protected]>
[ Upstream commit 14eb1d2c03b38ce3427f299967f7a4d97ebff4c2 ]
Fix the Micrel PHY in the example which shouldn't have the fallback "ethernet-phy-ieee802.3-c22" compatible:
Documentation/devicetree/bindings/net/renesas,ether.example.dtb: ethernet-phy@1 \
(ethernet-phy-id0022.1537): compatible: ['ethernet-phy-id0022.1537', 'ethernet-phy-ieee802.3-c22'] is too long
from schema $id: http://devicetree.org/schemas/net/micrel.yaml
--- Documentation/devicetree/bindings/net/renesas,ether.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/devicetree/bindings/net/renesas,ether.yaml +1 -2
@@ -119,8 +119,7 @@ examples: #size-cells = <0>; phy1: ethernet-phy@1 { - compatible = "ethernet-phy-id0022.1537", - "ethernet-phy-ieee802.3-c22"; + compatible = "ethernet-phy-id0022.1537"; reg = <1>; interrupt-parent = <&irqc0>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/1067 bpf: Fix stack slot index in nospec checks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuoqi Gui <[email protected]>
[ Upstream commit d1d53aa30ab3b5ae89161c9cc840b3f7489ad386 ]
check_stack_write_fixed_off() computes the byte slot for a fixed-offset stack write as -off - 1, and records each written byte in slot_type[] with (slot - i) % BPF_REG_SIZE.
The Spectre v4 sanitization pre-check uses slot_type[i] instead. For a 4-byte write at fp-8 after the lower half of fp-8 has been zeroed, the pre-check scans bytes 0..3 and sees STACK_ZERO while the actual write updates bytes 7..4. That can leave the second half-slot write without nospec_result even though the bytes being overwritten still require sanitization.
Use the same slot index in the sanitization pre-check that the write path uses when updating slot_type[].
--- kernel/bpf/verifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +2 -1
@@ -3234,7 +3234,8 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env,bool sanitize = reg &&is_spillable_regtype (reg->type);for (i =0 ; i < size; i++) { -u8 type = state->stack[spi].slot_type[i]; +u8 type = state->stack[spi].slot_type[(slot - i) % +BPF_REG_SIZE ];if (type !=STACK_MISC && type !=STACK_ZERO ) { sanitize = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/1067 tracing: probes: fix typo in a log message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaiser <[email protected]>
[ Upstream commit 72c8646956ffc8050bb8be5988a0f28fc37e1ac4 ]
Fix a typo ("Invalid $-variable") in a log message.
--- kernel/trace/trace_probe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_probe.h +1 -1
@@ -423,7 +423,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,C (RETVAL_ON_PROBE ,"$retval is not available on probe" ), \C (BAD_STACK_NUM ,"Invalid stack number" ), \C (BAD_ARG_NUM ,"Invalid argument number" ), \ -C (BAD_VAR ,"Invalid $-valiable specified" ), \ +C (BAD_VAR ,"Invalid $-variable specified" ), \C (BAD_REG_NAME ,"Invalid register name" ), \C (BAD_MEM_ADDR ,"Invalid memory address" ), \ C(BAD_IMM, "Invalid immediate value"), \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/1067 spi: sh-msiof: abort transfers when reset times out
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 6dbaa4d288432c697cea47028480481b8b29bd6a ]
sh_msiof_spi_reset_regs() asserts TX/RX reset and polls until the reset bits clear, but the poll result is ignored. sh_msiof_transfer_one() can therefore continue programming a transfer after the controller did not leave reset.
Return the reset poll result from the helper and abort the transfer on timeout, matching the existing transfer path's error-return style.
--- drivers/spi/spi-sh-msiof.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/spi/spi-sh-msiof.c +6 -4
@@ -243,7 +243,7 @@ static irqreturn_t sh_msiof_spi_irq(int irq, void *data)return IRQ_HANDLED ; } -static void sh_msiof_spi_reset_regs (struct sh_msiof_spi_priv *p) +static int sh_msiof_spi_reset_regs (struct sh_msiof_spi_priv *p) {u32 mask =SICTR_TXRST |SICTR_RXRST ;u32 data;
@@ -252,8 +252,8 @@ static void sh_msiof_spi_reset_regs(struct sh_msiof_spi_priv *p) data |= mask;sh_msiof_write (p,SICTR , data); -readl_poll_timeout_atomic (p->mapbase +SICTR , data, !(data & mask),1 , -100 ); +return readl_poll_timeout_atomic (p->mapbase +SICTR , data, + !(data & mask),1 ,100 ); }static const u32 sh_msiof_spi_div_array[] = {
@@ -927,7 +927,9 @@ static int sh_msiof_transfer_one(struct spi_controller *ctlr,int ret;/* reset registers */ -sh_msiof_spi_reset_regs (p); + ret =sh_msiof_spi_reset_regs (p); +if (ret) +return ret;/* setup clocks (clock already enabled in chipselect()) */ if (!spi_controller_is_slave (p->ctlr))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/1067 gpio: mvebu: fail probe if gpiochip registration fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 479e91fc92416a4d54d2b3150aa1e4550d9cc759 ]
mvebu_gpio_probe() registers the GPIO chip with devm_gpiochip_add_data() but ignores the return value. If registration fails, probe continues and leaves later code operating on a GPIO chip that was never published to gpiolib.
Return the registration error so the device fails probe cleanly.
--- drivers/gpio/gpio-mvebu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mvebu.c +4 -1
@@ -1232,7 +1232,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)BUG (); } -devm_gpiochip_add_data (&pdev->dev, &mvchip->chip, mvchip); + err =devm_gpiochip_add_data (&pdev->dev, &mvchip->chip, mvchip); +if (err) +return dev_err_probe (&pdev->dev, err, +"failed to register gpiochip\n" );/* Some MVEBU SoCs have simple PWM support for GPIO lines */ if (IS_ENABLED (CONFIG_PWM )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 650/1067 gpio: htc-egpio: use managed gpiochip registration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 17326db5f0ab4ec1901e75d052b5ebef486b467f ]
egpio_probe() registers each nested gpio_chip with gpiochip_add_data() but ignores the return value. If one registration fails, probe still returns success even though one of the chips was not published to gpiolib.
Use devm_gpiochip_add_data() and fail probe if any chip registration fails. This lets devres unwind already registered chips and prevents the driver from publishing a partially initialized device.
--- drivers/gpio/gpio-htc-egpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpio/gpio-htc-egpio.c +5 -1
@@ -268,6 +268,7 @@ static int __init egpio_probe(struct platform_device *pdev)struct gpio_chip *chip;unsigned int irq, irq_end;int i; +int ret;/* Initialize ei data structure. */ ei =devm_kzalloc (&pdev->dev,sizeof (*ei),GFP_KERNEL );
@@ -331,7 +332,10 @@ static int __init egpio_probe(struct platform_device *pdev) chip->base = pdata->chip[i].gpio_base; chip->ngpio = pdata->chip[i].num_gpios; -gpiochip_add_data (chip, &ei->chip[i]); + ret =devm_gpiochip_add_data (&pdev->dev, chip, &ei->chip[i]); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"failed to register gpiochip %d\n" , i); }/* Set initial pin values */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 651/1067 seg6: validate SRH length before reading fixed fields
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuoqi Gui <[email protected]>
[ Upstream commit a75d99f46bf21b45965ce39c5cfb3b8bb5ffb1aa ]
seg6_validate_srh() reads fixed SRH fields such as srh->type and srh->hdrlen before checking that the supplied length covers the fixed struct ipv6_sr_hdr fields.
The BPF SEG6 encap path reaches this with a BPF program-supplied pointer and length: bpf_lwt_push_encap() and the SEG6 local BPF END_B6 and END_B6_ENCAP actions call bpf_push_seg6_encap(), which forwards the length to seg6_validate_srh() with no minimum-size guard. A 2-byte SEG6 encap header can therefore make the validator read srh->type at offset 2 beyond the caller-supplied buffer.
Reject lengths shorter than the fixed SRH at the top of seg6_validate_srh(), before any field is read. This fixes the BPF helper path and keeps the common validator robust.
--- net/ipv6/seg6.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/seg6.c +3 -0
@@ -31,6 +31,9 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len, bool reduced)int max_last_entry;int trailing; +if (len <sizeof (*srh)) +return false; +if (srh->type !=IPV6_SRCRT_TYPE_4 )return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 652/1067 qede: fix out-of-bounds check for cqe->len_list[]
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matvey Kovalev <[email protected]>
[ Upstream commit f9ba47fce5932c15891c89c60e76dfaca919cb8d ]
Move index check before element access.
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_fp.c +2 -2
@@ -961,7 +961,7 @@ static inline void qede_tpa_cont(struct qede_dev *edev, {int i; -for (i =0 ; cqe->len_list[i] && i <ARRAY_SIZE (cqe->len_list); i++) +for (i =0 ; i <ARRAY_SIZE (cqe->len_list) && cqe->len_list[i]; i++)qede_fill_frag_skb (edev, rxq, cqe->tpa_agg_index,le16_to_cpu (cqe->len_list[i]));
@@ -986,7 +986,7 @@ static int qede_tpa_end(struct qede_dev *edev,dma_unmap_page (rxq->dev, tpa_info->buffer.mapping,PAGE_SIZE , rxq->data_direction); -for (i =0 ; cqe->len_list[i] && i <ARRAY_SIZE (cqe->len_list); i++) +for (i =0 ; i <ARRAY_SIZE (cqe->len_list) && cqe->len_list[i]; i++)qede_fill_frag_skb (edev, rxq, cqe->tpa_agg_index,le16_to_cpu (cqe->len_list[i]));if (unlikely (i >1 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/1067 bpf: zero-initialize the fib lookup flow struct
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avinash Duduskar <[email protected]>
[ Upstream commit 0dfcb68a6a5ac517b22dff6a1f01cb4f126dfc57 ]
bpf_ipv4_fib_lookup() and bpf_ipv6_fib_lookup() build the flow key on the stack with a bare "struct flowi4 fl4;" / "struct flowi6 fl6;" and fill it field by field, but never set flowi4_l3mdev / flowi6_l3mdev.
On the non-DIRECT path the lookup goes through the fib rules whenever the netns has custom rules, which a VRF installs:
bpf_ipv4_fib_lookup() -> fib_lookup() -> __fib_lookup() -> l3mdev_update_flow() reads !fl->flowi_l3mdev -> fib_rules_lookup() -> fib_rule_match() -> l3mdev_fib_rule_match() uses fl->flowi_l3mdev
l3mdev_update_flow() resolves the l3mdev master from the ingress device only while the field is still zero. Left at a nonzero stack value the resolution is skipped, and l3mdev_fib_rule_match() then tests that value as an ifindex, so the VRF master is not resolved and the rule fails to
match: an ingress enslaved to a VRF can fail to select its table. FIB rules matching on an L3 master device (l3mdev_fib_rule_iif_match()/ _oif_match()) read the same value, so an "ip rule iif/oif <vrf>" mismatches the same way.
Zero-initialize the whole flow struct rather than adding one more field assignment, so any flowi field added later is covered too. ip_route_input_slow() likewise zeroes the field before its input lookup.
CONFIG_INIT_STACK_ALL_ZERO masks this by default, but it depends on compiler support (CC_HAS_AUTO_VAR_INIT_ZERO), so INIT_STACK_NONE builds, including older toolchains that fall back to it, are exposed. Built with INIT_STACK_ALL_PATTERN, a plain bpf_fib_lookup (no VLAN, no DIRECT) over a VRF slave whose destination is routed only in the VRF table returns BPF_FIB_LKUP_RET_NOT_FWDED, and resolves with this patch. On the default config the lookup succeeds either way, so ordinary testing does not catch the bug.
--- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/filter.c +2 -2
@@ -5865,7 +5865,7 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params,struct neighbour *neigh;struct net_device *dev;struct fib_result res; -struct flowi4 fl4; +struct flowi4 fl4 = {};u32 mtu =0 ;int err;
@@ -6002,7 +6002,7 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,struct neighbour *neigh;struct net_device *dev;struct inet6_dev *idev; -struct flowi6 fl6; +struct flowi6 fl6 = {};int strict =0 ;int oif, err;u32 mtu =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/1067 drm/edid: fix OOB read in drm_parse_tiled_block()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit faaa1e1155833e7d4ce7e3cfaf64c0d636b190db ]
drm_parse_tiled_block() casts the DisplayID block to a struct displayid_tiled_block and reads the full fixed layout up to tile->topology_id[7] without checking block->num_bytes. The DisplayID iterator only validates the declared payload length, so a crafted EDID can advertise a tiled-display block (tag DATA_BLOCK_TILED_DISPLAY, or DATA_BLOCK_2_TILED_DISPLAY_TOPOLOGY for v2.0) with a small num_bytes at the end of a DisplayID extension. The read then runs past the end of the exact-sized kmemdup()'d EDID allocation, a heap out-of-bounds read.
Reject blocks shorter than the spec's 22-byte tiled payload before reading the fixed struct, as drm_parse_vesa_mso_data() already does.
BUG: KASAN: slab-out-of-bounds in drm_edid_connector_update Read of size 2 at addr ffff888010077700 by task exploit/147 dump_stack_lvl (lib/dump_stack.c:94 ...) print_report (mm/kasan/report.c:378 ...) kasan_report (mm/kasan/report.c:595) drm_edid_connector_update (drivers/gpu/drm/drm_edid.c:7581) bochs_connector_helper_get_modes (drivers/gpu/drm/tiny/bochs.c:574) drm_helper_probe_single_connector_modes (drivers/gpu/drm/drm_probe_helper.c:426) status_store (drivers/gpu/drm/drm_sysfs.c:219) ... vfs_write (fs/read_write.c:595 fs/read_write.c:688) ksys_write (fs/read_write.c:740)
--- drivers/gpu/drm/drm_edid.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/drm_edid.c +8 -0
@@ -6953,6 +6953,14 @@ static void drm_parse_tiled_block(struct drm_connector *connector,u8 num_v_tile, num_h_tile;struct drm_tile_group *tg; +/* tiled block payload per spec: cap 1 + topo 3 + size 4 + bezel 5 + id 9 = 22 */ +if (block->num_bytes <22 ) { +drm_dbg_kms (connector->dev, +"[CONNECTOR:%d:%s] Unexpected tiled block size %u\n" , + connector->base.id, connector->name, block->num_bytes); +return ; + } + w = tile->tile_size[0 ] | tile->tile_size[1 ] <<8 ; h = tile->tile_size[2 ] | tile->tile_size[3 ] <<8 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/1067 PCI: endpoint: pci-epf-vntb: Add check to detect db_count value of 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 33bd1ea748bc897c4d13437284e08c658e8d1340 ]
epf_ntb->db_count value should be within 1 to MAX_DB_COUNT. Current code only checks for the upper bound, while the lower bound is unchecked. This can cause a lot of issues in the driver if the user passes 'db_count' as 0.
Add a check for 0 also. While at it, remove the redundant 'db_count' assignment.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +3 -6
@@ -487,7 +487,6 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) {const struct pci_epc_features *epc_features;struct device *dev; -u32 db_count;int ret; dev = &ntb->epf->dev;
@@ -499,14 +498,12 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb)return -EINVAL ; } - db_count = ntb->db_count; -if (db_count >MAX_DB_COUNT ) { -dev_err (dev,"DB count cannot be more than %d\n" ,MAX_DB_COUNT ); +if (!ntb->db_count || ntb->db_count >MAX_DB_COUNT ) { +dev_err (dev,"DB count %d out of range (1 - %d)\n" , + ntb->db_count,MAX_DB_COUNT );return -EINVAL ; } - ntb->db_count = db_count; -if (epc_features->msi_capable) { ret = pci_epc_set_msi(ntb->epf->epc, ntb->epf->func_no,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/1067 PCI: endpoint: pci-epf-ntb: Add check to detect db_count value of 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit d1db6d7c2485ee475a04d8354fbb5b26ea10d978 ]
epf_ntb->db_count value should be within 1 to MAX_DB_COUNT. Current code only checks for the upper bound, while the lower bound is unchecked. This can cause a lot of issues in the driver if the user passes 'db_count' as 0.
Add a check for 0 also. While at it, remove the redundant 'db_count' variable from epf_ntb_configure_interrupt().
--- drivers/pci/endpoint/functions/pci-epf-ntb.c | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/pci/endpoint/functions/pci-epf-ntb.c +11 -10
@@ -559,12 +559,15 @@ static int epf_ntb_configure_db(struct epf_ntb *ntb,struct pci_epc *epc;int ret; -if (db_count >MAX_DB_COUNT ) -return -EINVAL ; - ntb_epc = ntb->epc[type]; epc = ntb_epc->epc; +if (!db_count || db_count >MAX_DB_COUNT ) { +dev_err (&epc->dev,"DB count %d out of range (1 - %d)\n" , + db_count,MAX_DB_COUNT ); +return -EINVAL ; + } +if (msix) ret =epf_ntb_configure_msix (ntb, type, db_count);else
@@ -1278,7 +1281,6 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb,u8 func_no, vfunc_no;struct pci_epc *epc;struct device *dev; -u32 db_count;int ret; ntb_epc = ntb->epc[type];
@@ -1296,17 +1298,16 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb, func_no = ntb_epc->func_no; vfunc_no = ntb_epc->vfunc_no; - db_count = ntb->db_count; -if (db_count >MAX_DB_COUNT ) { -dev_err (dev,"DB count cannot be more than %d\n" ,MAX_DB_COUNT ); +if (!ntb->db_count || ntb->db_count >MAX_DB_COUNT ) { +dev_err (dev,"DB count %d out of range (1 - %d)\n" , + ntb->db_count,MAX_DB_COUNT );return -EINVAL ; } - ntb->db_count = db_count; epc = ntb_epc->epc;if (msi_capable) { - ret =pci_epc_set_msi (epc, func_no, vfunc_no, db_count); + ret =pci_epc_set_msi (epc, func_no, vfunc_no, ntb->db_count);if (ret) {dev_err (dev,"%s intf: MSI configuration failed\n" ,pci_epc_interface_string (type));
@@ -1315,7 +1316,7 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb, }if (msix_capable) { - ret =pci_epc_set_msix (epc, func_no, vfunc_no, db_count, + ret =pci_epc_set_msix (epc, func_no, vfunc_no, ntb->db_count, ntb_epc->msix_bar, ntb_epc->msix_table_offset);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/1067 ice: fix FDIR CTRL VSI resource leak in ice_reset_all_vfs()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dawid Osuchowski <[email protected]>
[ Upstream commit ebbe8868cf473f698e0fbaf436d2618b2bcda806 ]
Resetting all VFs causes resource leak on VFs with FDIR filters enabled as CTRL VSIs are only invalidated and not freed. Fix by using ice_vf_ctrl_vsi_release() instead of ice_vf_ctrl_invalidate_vsi() which aligns behavior with the ice_reset_vf() function.
Reproduction:
echo 1 > /sys/class/net/$pf/device/sriov_numvfs ethtool -N $vf flow-type ether proto 0x9000 action 0 echo 1 > /sys/class/net/$pf/device/reset
--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +1 -1
@@ -506,7 +506,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)* setup only when VF creates its first FDIR rule. */ if (vf->ctrl_vsi_idx !=ICE_NO_VSI ) -ice_vf_ctrl_invalidate_vsi (vf); +ice_vf_ctrl_vsi_release (vf);ice_vf_pre_vsi_rebuild (vf);if (ice_vf_rebuild_vsi (vf)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/1067 octeontx2-pf: Clear stats of all resources when freeing resources
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Subbaraya Sundeep <[email protected]>
[ Upstream commit fd4460721fb4062ef470ecdfdaedadfe7e415c09 ]
When all MCS resources mapped to a PF are being freed then clear stats of all those resources too.
--- drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c +1 -0
@@ -163,6 +163,7 @@ static void cn10k_mcs_free_rsrc(struct otx2_nic *pfvf, enum mcs_direction dir, clear_req->id = hw_rsrc_id; clear_req->type = type; clear_req->dir = dir; + clear_req->all = all; req =otx2_mbox_alloc_msg_mcs_free_resources (mbox);if (!req)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/1067 hwmon: adm1275: Prevent reading uninitialized stack
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 553f9517813912a5ab661af5504485d96824a61c ]
While adding support for the ROHM BD127X0 hot-swap controllers, sashiko reported an error in device-name comparison, which can lead to reading uninitialized stack memory.
Quoting Sashiko:
This is a pre-existing issue, but I noticed that just before this block in adm1275_probe(), there might be an out-of-bounds stack read:
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, block_buffer);
if (ret < 0) { ... }
for (mid = adm1275_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}Since i2c_smbus_read_block_data() reads up to 32 bytes into the uninitialized stack array block_buffer without appending a null terminator, strncasecmp() could read past the valid bytes returned in ret.
For example, if the device returns a shorter string like "adm12", checking it against "adm1275" up to the length of "adm1275" will continue reading into uninitialized stack bounds.
Prevent reading uninitialized memory by zeroing the stack array.
--- drivers/hwmon/pmbus/adm1275.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1275.c +1 -1
@@ -484,7 +484,7 @@ static int adm1275_enable_vout_temp(struct i2c_client *client, int config)static int adm1275_probe (struct i2c_client *client) {s32 (*config_read_fn)(const struct i2c_client *client,u8 reg); -u8 block_buffer[I2C_SMBUS_BLOCK_MAX +1 ]; +u8 block_buffer[I2C_SMBUS_BLOCK_MAX +1 ] = {0 };int config, device_config;int ret;struct pmbus_driver_info *info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/1067 irqchip/ts4800: Fix missing chained handler cleanup on remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingshuang Fu <[email protected]>
[ Upstream commit 98bf7e54cec07d514b3575c11896a8b12d50ecc4 ]
The driver installs a chained handler for the parent interrupt during probe using irq_set_chained_handler_and_data(), but the remove function does not clear this handler. This leaves a dangling handler that may be called when the parent interrupt fires after the driver has been removed, potentially accessing freed memory and causing a kernel crash.
Additionally, the parent_irq obtained via irq_of_parse_and_map() is not stored, making it inaccessible in the remove function. Moreover, interrupt mappings created during probe are not properly disposed.
Fix this by:
- Saving parent_irq in probe
- Clearing the chained handler with NULL in ts4800_ic_remove()
- Disposing all IRQ mappings before domain removal to prevent resource leaks
--- drivers/irqchip/irq-ts4800.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/irqchip/irq-ts4800.c +10 -0
@@ -28,6 +28,7 @@ struct ts4800_irq_data {void __iomem *base;struct platform_device *pdev;struct irq_domain *domain; +unsigned int parent_irq; };static void ts4800_irq_mask (struct irq_data *d)
@@ -134,6 +135,7 @@ static int ts4800_ic_probe(struct platform_device *pdev)irq_set_chained_handler_and_data (parent_irq, ts4800_ic_chained_handle_irq, data); + data->parent_irq = parent_irq;platform_set_drvdata (pdev, data);return 0 ;
@@ -142,6 +144,14 @@ static int ts4800_ic_probe(struct platform_device *pdev)static int ts4800_ic_remove (struct platform_device *pdev) {struct ts4800_irq_data *data =platform_get_drvdata (pdev); +unsigned int hwirq; + +irq_set_chained_handler_and_data (data->parent_irq,NULL ,NULL ); + +for (hwirq =0 ; hwirq <8 ; hwirq++) +irq_dispose_mapping (irq_find_mapping (data->domain, hwirq)); + +irq_dispose_mapping (data->parent_irq);irq_domain_remove (data->domain);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 664/1067 virtio_net: disable cb when NAPI is busy-polled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longjun Tang <[email protected]>
[ Upstream commit 1eb8fc67ca41db71c90866ff76c990d85247daef ]
When busy-poll is active, napi_schedule_prep() returns false in virtqueue_napi_schedule(), so virtqueue_disable_cb() is skipped. The device may keep firing irqs until reaches virtqueue_napi_complete(). Under load (received == budget), it will lead to a large number of spurious interrupts.
Fix it by disabling the callback at the virtnet_poll() entry. This keeps the callback off while we poll and it is re-enabled by virtqueue_napi_complete() when going idle.
--- drivers/net/virtio_net.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/virtio_net.c +3 -0
@@ -1709,6 +1709,9 @@ static int virtnet_poll(struct napi_struct *napi, int budget)unsigned int received;unsigned int xdp_xmit =0 ; +if (budget) +virtqueue_disable_cb (rq->vq); +virtnet_poll_cleantx (rq, budget); received =virtnet_receive (rq, budget, &xdp_xmit);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 665/1067 cxgb4: Fix decode strings dump for T6 adapters
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gleb Markov <[email protected]>
[ Upstream commit 5d6dc22d62682d93f5f55f145ad792f2891de911 ]
Depending on the value of chip_version, the correct decode set is selected. However, the subsequent matching with the t4 encoding type in the if-else block results in a reassignment, which leads to the loss of support for t6_decode as well as reinitializing of values t4_decode and t5_decode.
The component history shows that the if-else block previously used for this purpose, as well as the execution order, was not affected by the change.
Furthermore, it is suggested by the execution order that the scenario with overwriting and loss of support will be implemented.
Delete the if-else block.
--- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -8
@@ -6737,14 +6737,6 @@ void t4_sge_decode_idma_state(struct adapter *adapter, int state)return ; } -if (is_t4 (adapter->params.chip)) { - sge_idma_decode = (const char **)t4_decode; - sge_idma_decode_nstates =ARRAY_SIZE (t4_decode); - }else { - sge_idma_decode = (const char **)t5_decode; - sge_idma_decode_nstates =ARRAY_SIZE (t5_decode); - } -if (state < sge_idma_decode_nstates)CH_WARN (adapter,"idma state %s\n" , sge_idma_decode[state]);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 666/1067 net/sched: act_bpf: use rcu_dereference_bh() to read the filter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit adc49c7ba690c9b33b8392ec27397456b65d0893 ]
tcf_bpf_act() can run from the tc egress path, which holds only rcu_read_lock_bh(), but reads prog->filter with rcu_dereference() and trips lockdep:
WARNING: suspicious RCU usage
net/sched/act_bpf.c:47 suspicious rcu_dereference_check() usage! 1 lock held by syz.2.1588/12756:
#0: (rcu_read_lock_bh){....}-{1:3}, at: __dev_queue_xmit net/core/dev.c:4792
tcf_bpf_act+0x6ae/0x940 net/sched/act_bpf.c:47 tcf_classify+0x6e4/0x1080 net/sched/cls_api.c:1860 sch_handle_egress net/core/dev.c:4545 [inline] __dev_queue_xmit+0x2185/0x2c00 net/core/dev.c:4808 packet_sendmsg+0x3dfa/0x5120 net/packet/af_packet.c:3114
The other tc actions and cls_bpf already use rcu_dereference_bh() here. Do the same.
--- net/sched/act_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_bpf.c +1 -1
@@ -42,7 +42,7 @@ static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act,tcf_lastuse_update (&prog->tcf_tm);bstats_update (this_cpu_ptr (prog->common.cpu_bstats), skb); - filter =rcu_dereference (prog->filter); + filter =rcu_dereference_bh (prog->filter);if (at_ingress) {__skb_push (skb, skb->mac_len); filter_res =bpf_prog_run_data_pointers (filter, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 667/1067 gpio: timberdale: Return -ENOMEM on dynamic memory allocation in probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 8d7e62d5e9b2d2ff146f472a9215d7e29c7e2307 ]
Out of memory situation on driver's probe is expected to be reported to the driver's framework with a proper -ENOMEM error code.
--- drivers/gpio/gpio-timberdale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-timberdale.c +1 -1
@@ -228,7 +228,7 @@ static int timbgpio_probe(struct platform_device *pdev) tgpio =devm_kzalloc (dev,sizeof (*tgpio),GFP_KERNEL );if (!tgpio) -return -EINVAL ; +return -ENOMEM ; tgpio->irq_base = pdata->irq_base;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 668/1067 pinctrl: meson: restore non-sleeping GPIO access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Bocharov <[email protected]>
[ Upstream commit 9777530157e7b82fd994327ff878c4245dadc931 ]
Commit 28f240683871 ("pinctrl: meson: mark the GPIO controller as sleeping") set gpio_chip.can_sleep = true to work around gpio-shared-proxy holding a spinlock across a sleeping pinctrl config path. That locking bug is now fixed in the shared-proxy itself ("gpio:
shared-proxy: always serialize with a sleeping mutex"), so the controller-wide workaround is no longer needed; the meson GPIO controller does not sleep.
meson_gpio_get/set/direction_* access MMIO through regmap. The regmap_mmio bus uses fast I/O (spinlock) locking, so these value callbacks do not contain sleeping operations. Since gpio_chip.can_sleep describes the get/set value path, restore can_sleep = false.
Marking the controller sleeping also broke atomic value consumers such as w1-gpio (1-Wire bitbang): w1_io.c runs its read time slot under local_irq_save() and uses the non-cansleep gpiod_set_value() / gpiod_get_value(), which with can_sleep=true trigger WARN_ON(can_sleep) in gpiolib on every transferred bit (from w1_gpio_write_bit() / w1_gpio_read_bit() via w1_reset_bus() and w1_search()). The printk and stack dump inside the IRQs-off, microsecond-scale time slot destroy the bit timing, so reset/presence detection and ROM search fail: the bus master registers but w1_master_slave_count stays at 0 and no devices are found. Verified on an Amlogic A113X board (DS18B20 on GPIOA_14):
with can_sleep restored to false the warnings are gone and the sensor is detected and read again.
This must not be applied or backported without the shared-proxy locking fix above; otherwise the original Khadas VIM3 splat returns on boards that genuinely share a meson GPIO.
--- drivers/pinctrl/meson/pinctrl-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/meson/pinctrl-meson.c +1 -1
@@ -619,7 +619,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc) pc->chip.set = meson_gpio_set; pc->chip.base =-1 ; pc->chip.ngpio = pc->data->num_pins; - pc->chip.can_sleep = true; + pc->chip.can_sleep = false; ret =gpiochip_add_data (&pc->chip, pc);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 669/1067 net/sched: hhf: clear heavy-hitter state on reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit a225f8c20712713406ae47024b8df42deacddd4a ]
HHF reset does not clear the classifier state used to identify heavy hitters. Packets after reset can therefore be scheduled using flow history from before the reset.
The reset operation should return the qdisc to an empty state.
Clear the heavy-hitter classifier tables when HHF is reset.
--- net/sched/sch_hhf.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/sched/sch_hhf.c +27 -0
@@ -461,12 +461,39 @@ static struct sk_buff *hhf_dequeue(struct Qdisc *sch)return skb; } +static void hhf_reset_classifier (struct hhf_sched_data *q) +{ +int i; + +if (!q->hh_flows) +return ; + +for (i =0 ; i <HH_FLOWS_CNT ; i++) { +struct hh_flow_state *flow, *next; +struct list_head *head = &q->hh_flows[i]; + +list_for_each_entry_safe (flow, next, head, flowchain) { +list_del (&flow->flowchain); +kfree (flow); + } + } +WRITE_ONCE (q->hh_flows_current_cnt,0 ); + +for (i =0 ; i <HHF_ARRAYS_CNT ; i++) { +if (q->hhf_valid_bits[i]) +bitmap_zero (q->hhf_valid_bits[i],HHF_ARRAYS_LEN ); + } + q->hhf_arrays_reset_timestamp =hhf_time_stamp (); +} +static void hhf_reset (struct Qdisc *sch) { +struct hhf_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;while ((skb =hhf_dequeue (sch)) !=NULL )rtnl_kfree_skbs (skb, skb); +hhf_reset_classifier (q); }static void hhf_destroy (struct Qdisc *sch)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/1067 afs: Fix error code in afs_extract_vl_addrs()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 4897cb71d4ab1f7e1a214adb1e4b80176702368d ]
The error codes on these paths are only set on the first iteration through the loop. Set the correct error code on every iteration.
--- fs/afs/vl_list.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/afs/vl_list.c +3 -1
@@ -88,7 +88,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end, {struct afs_addr_list *alist;const u8 *b = *_b; -int ret = -EINVAL ; +int ret; alist =afs_alloc_addrlist (nr_addrs,VL_SERVICE , port);if (!alist)
@@ -106,6 +106,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end,case DNS_ADDRESS_IS_IPV4 :if (end - b <4 ) {_leave (" = -EINVAL [short inet]" ); + ret = -EINVAL ; goto error; }memcpy (x, b,4 );
@@ -116,6 +117,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(const u8 **_b, const u8 *end,case DNS_ADDRESS_IS_IPV6 :if (end - b <16 ) {_leave (" = -EINVAL [short inet6]" ); + ret = -EINVAL ; goto error; }memcpy (x, b,16 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/1067 afs: use kvfree() to free memory allocated by kvcalloc()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit cb39654926f8e7a08ecc1dcb3941628855275940 ]
op->more_files is allocated with kvcalloc() but released via afs_put_operation(), which uses kfree() internally. This mismach prevents the resource from being released properly and may lead to undefined behavior.
Fix this by using kvfree() to free op->more_files to match its allocation method.
--- fs/afs/fs_operation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/fs_operation.c +1 -1
@@ -240,7 +240,7 @@ int afs_put_operation(struct afs_operation *op)for (i =0 ; i < op->nr_files -2 ; i++)if (op->more_files[i].put_vnode)iput (&op->more_files[i].vnode->netfs.inode); -kfree (op->more_files); +kvfree (op->more_files); }afs_end_cursor (&op->ac);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/1067 afs: Fix callback service message parsers to pass through -EAGAIN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 0f36469d7ce98b362934113c550d08bb0c784231 ]
The AFS filesystem client uses an rxrpc server to listen for callback notifications. Each callback call type handler has a delivery function that parses the incoming request stream, and this should return -EAGAIN the last packet hasn't yet been seen, but all currently queued received data is consumed. afs_extract_data() does this, but the -EAGAIN return is switched to 0 inadvertantly
Fix callback service message parsers to pass through -EAGAIN
--- fs/afs/cmservice.c | 2 -- 1 file changed, 2 deletions(-)
fs/afs/cmservice.c +0 -2
@@ -388,7 +388,6 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call) ret =afs_extract_data (call, false);switch (ret) {case 0 :break ; -case -EAGAIN :return 0 ;default :return ret; }
@@ -501,7 +500,6 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call) ret =afs_extract_data (call, false);switch (ret) {case 0 :break ; -case -EAGAIN :return 0 ;default :return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 655/1067 usbnet: gl620a: fix out-of-bounds read in genelink_rx_fixup()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 8ff7f2a6da4fccaa5cc9be7251a24e71e29fbd1a ]
genelink_rx_fixup() splits an aggregated RX frame into its individual packets, using a per-packet length taken from device-supplied data. That length is only bounded by GL_MAX_PACKET_LEN (1514); it is never compared against how many bytes were actually received.
A malicious GeneLink (GL620A) device can therefore send a short URB whose header claims packet_count > 1 and a first packet of up to 1514 bytes.
skb_put_data(gl_skb, packet->packet_data, size);
then copies past the end of the receive buffer and hands the adjacent slab contents up the network stack, an out-of-bounds read that leaks kernel heap. No privilege is required: the path runs in the usbnet RX softirq as soon as the interface is up.
BUG: KASAN: slab-out-of-bounds in genelink_rx_fixup (drivers/net/usb/gl620a.c:112)
Read of size 1514 at addr ffff888011309708 by task ksoftirqd/0/14
Call Trace:
...
__asan_memcpy (mm/kasan/shadow.c:105)
genelink_rx_fixup (include/linux/skbuff.h:2814 drivers/net/usb/gl620a.c:112)
usbnet_bh (drivers/net/usb/usbnet.c:572 drivers/net/usb/usbnet.c:1589)
process_one_work (kernel/workqueue.c:3322)
bh_worker (kernel/workqueue.c:3405)
tasklet_action (kernel/softirq.c:965)
handle_softirqs (kernel/softirq.c:622)
run_ksoftirqd (kernel/softirq.c:1076)
...skb_pull() already verifies that the requested length fits the buffer and returns NULL otherwise. Move it ahead of the copy and check its result, so a packet that overruns the received data is rejected before it is read. Well-formed frames, whose packets are fully present, are unaffected.
--- drivers/net/usb/gl620a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/gl620a.c +3 -3
@@ -104,6 +104,9 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)return 0 ; } +if (!skb_pull (skb, size +4 )) +return 0 ; +// allocate the skb for the individual packet gl_skb =alloc_skb (size,GFP_ATOMIC );if (gl_skb) {
@@ -116,9 +119,6 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)// advance to the next packet packet = (struct gl_packet *)&packet->packet_data[size]; count--; - -// shift the data pointer to the next gl_packet -skb_pull (skb, size +4 ); }// skip the packet length field 4 bytes
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/1067 afs: Fix vllist leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit fc10c0ecf06f2981af5d04357612b00051e03e9e ]
Fix a leak of the new vllist in afs_update_cell() in the event that it is an empty list (nr_servers == 0), in which case the old list isn't displaced unless the old list is also empty.
--- fs/afs/cell.c | 2 ++ 1 file changed, 2 insertions(+)
fs/afs/cell.c +2 -0
@@ -474,6 +474,8 @@ static int afs_update_cell(struct afs_cell *cell)rcu_assign_pointer (cell->vl_servers, vllist); cell->dns_source = vllist->source; old = p; + }else { + old = vllist; }write_unlock (&cell->vl_servers_lock);afs_put_vlserverlist (cell->net, old);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/1067 afs: Fix the volume AFS_VOLUME_RM_TREE is set on
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 56b4e4b26f84411d880f968a539207b0a8889c8c ]
Fix afs_insert_volume_into_cell() to set AFS_VOLUME_RM_TREE on the volume replaced, not the new volume, as it's now removed from the cell's volume tree. This will cause the old volume to be removed from the tree twice and the new volume never to be removed.
--- fs/afs/volume.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/volume.c +1 -1
@@ -37,7 +37,7 @@ static struct afs_volume *afs_insert_volume_into_cell(struct afs_cell *cell, goto found; } -set_bit (AFS_VOLUME_RM_TREE , &volume->flags); +set_bit (AFS_VOLUME_RM_TREE , &p->flags);rb_replace_node_rcu (&p->cell_node, &volume->cell_node, &cell->volumes); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/1067 afs: Fix unchecked-length string display in debug statement
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 903d37c97228258da71e092f8b4ab260ce81497d ]
Fix afs_extract_vlserver_list() to limit the length of the displayed string in a debug statement().
--- fs/afs/vl_list.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/afs/vl_list.c +5 -1
@@ -192,6 +192,8 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, b +=sizeof (*hdr);while (end - b >=sizeof (bs)) { +int nlen; + bs.name_len =afs_extract_le16 (&b); bs.priority =afs_extract_le16 (&b); bs.weight =afs_extract_le16 (&b);
@@ -201,10 +203,12 @@ struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *cell, bs.protocol = *b++; bs.nr_addrs = *b++; + nlen =min3 (bs.name_len, end - b,255 ); +_debug ("extract %u %u %u %u %u %u %*.*s" , bs.name_len, bs.priority, bs.weight, bs.port, bs.protocol, bs.nr_addrs, - bs.name_len, bs.name_len, b); + bs.name_len, nlen, b);if (end - b < bs.name_len)break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/1067 ata: sata_gemini: unwind clocks on IDE pinctrl errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit c0ace4130e813acbabdfaa28d4e94a849c2ffdd7 ]
gemini_sata_bridge_init() prepares and enables both SATA PCLKs, then disables them again while keeping the clocks prepared for later bridge start and stop operations. If gemini_setup_ide_pins() fails after that, gemini_sata_probe() returns directly and skips the existing out_unprep_clk unwind path.
Route the IDE pinctrl failure through out_unprep_clk so the clocks prepared by gemini_sata_bridge_init() are unprepared before probe fails.
--- drivers/ata/sata_gemini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/sata_gemini.c +1 -1
@@ -386,7 +386,7 @@ static int gemini_sata_probe(struct platform_device *pdev)if (sg->ide_pins) { ret =gemini_setup_ide_pins (dev);if (ret) -return ret; + goto out_unprep_clk; }dev_info (dev,"set up the Gemini IDE/SATA nexus\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/1067 HID: picolcd: prevent NULL pointer dereference in picolcd_send_and_wait()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Georgiy Osokin <[email protected]>
[ Upstream commit 0021eb09041f021c079be1022934a280f7f176c0 ]
In picolcd_send_and_wait(), an integer overflow of the signed loop counter 'k' can theoretically lead to a NULL pointer dereference of 'raw_data'. If the loop executes more than INT_MAX times, 'k' becomes negative, making the condition 'k < size' true even when 'size' is 0.
Change the type of 'k' to 'unsigned int' to prevent the overflow and eliminate the out-of-bounds access.
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/hid/hid-picolcd_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-picolcd_core.c +2 -1
@@ -72,7 +72,8 @@ struct picolcd_pending *picolcd_send_and_wait(struct hid_device *hdev,struct picolcd_pending *work;struct hid_report *report =picolcd_out_report (report_id, hdev);unsigned long flags; -int i, j, k; +int i, j; +unsigned int k;if (!report || !data)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/1067 HID: core: Fix OOB read in hid_get_report for numbered reports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit af1a9b65ebe8a948eda805c14b78d4d0767cb1b5 ]
When a caller passes a size of 0 to hid_report_raw_event() for a numbered report, the function originally called hid_get_report() before performing any size validation.
Inside hid_get_report(), if the report is numbered (report_enum->numbered is true), it unconditionally dereferences data[0] to extract the report ID. With a size of 0, this results in an out-of-bounds read or kernel panic.
Fix this by moving the numbered report size validation check before the call to hid_get_report(), ensuring that size is at least 1 before dereferencing the data pointer.
--- drivers/hid/hid-core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hid/hid-core.c +7 -0
@@ -2001,6 +2001,13 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *u8 *cdata = data;int ret =0 ; +if (report_enum->numbered && (size <1 || bufsize <1 )) { +hid_warn_ratelimited (hid, +"Event data for numbered report is too short (%d vs %zu)\n" , + size, bufsize); +return -EINVAL ; + } + report =hid_get_report (report_enum, data);if (!report)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/1067 arm64/mm: convert ptep_clear() to ptep_get_and_clear()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Roberts <[email protected]>
[ Upstream commit cbb0294fdd72a5f63ec59fad5c0a98d63bd572fc ]
ptep_clear() is a generic wrapper around the arch-implemented ptep_get_and_clear(). We are about to convert ptep_get_and_clear() into a public version and private version (__ptep_get_and_clear()) to support the transparent contpte work. We won't have a private version of ptep_clear() so let's convert it to directly call ptep_get_and_clear().
Stable-dep-of: ff4c5a0de1f2 ("arm64/mm: Optimize TLB flush in unmap_hotplug_[pmd|pud]_range()")
--- arch/arm64/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/hugetlbpage.c +1 -1
@@ -236,7 +236,7 @@ static void clear_flush(struct mm_struct *mm,unsigned long i, saddr = addr;for (i =0 ; i < ncontig; i++, addr += pgsize, ptep++) -ptep_clear (mm, addr, ptep); +ptep_get_and_clear (mm, addr, ptep);flush_tlb_range (&vma, saddr, addr); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 680/1067 arm64/mm: Optimize TLB flush in unmap_hotplug_[pmd|pud]_range()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anshuman Khandual <[email protected]>
[ Upstream commit ff4c5a0de1f2ef7737a8688a86e19301e567020d ]
Commit 48478b9f7913 ("arm64/mm: Enable batched TLB flush in unmap_hotplug_range") inadvertently introduced redundant TLB invalidation when clearing a block entry, resulting in unnecessary broadcast invalidation on CPUs without support for range-based invalidation.
Re-introduce the old behaviour, along with some expanded comments to help people working in this area next time around.
--- arch/arm64/mm/mmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm64/mm/mmu.c +9 -2
@@ -956,7 +956,13 @@ static void unmap_hotplug_pmd_range(pud_t *pudp, unsigned long addr,if (free_mapped) {/* CONT blocks are not supported in the vmemmap */ WARN_ON (pmd_cont (pmd)); -flush_tlb_kernel_range (addr, addr +PMD_SIZE ); +/* +* Invalidating a block entry requires just +* a single overlapping TLB invalidation, +* so limit the range of the flush to a single +* page. +*/ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );free_hotplug_page_range (pmd_page (pmd),PMD_SIZE , altmap); }
@@ -986,7 +992,8 @@ static void unmap_hotplug_pud_range(p4d_t *p4dp, unsigned long addr,if (pud_sect (pud)) {pud_clear (pudp);if (free_mapped) { -flush_tlb_kernel_range (addr, addr +PUD_SIZE ); +/* See comment in unmap_hotplug_pmd_range(). */ +flush_tlb_kernel_range (addr, addr +PAGE_SIZE );free_hotplug_page_range (pud_page (pud),PUD_SIZE , altmap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/1067 net: usb: net1080: validate packet_len before pad-byte access in rx_fixup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 03f384bc0cb8d4a1301d4f5b0baef2d980258383 ]
For an even packet_len, net1080_rx_fixup() reads the pad byte at skb->data[packet_len] before the skb->len != packet_len check further down, and packet_len is only bounded against NC_MAX_PACKET. A malicious NetChip 1080 device can send a short frame advertising a large even packet_len (e.g. 0x4000), so the pad-byte read lands past the end of the skb:
BUG: KASAN: slab-out-of-bounds in net1080_rx_fixup Read of size 1 at addr ffff8880106c83c6 by task ksoftirqd/0/14 ... net1080_rx_fixup (drivers/net/usb/net1080.c:384) usbnet_bh (drivers/net/usb/usbnet.c:1589) process_one_work (kernel/workqueue.c:3322) bh_worker (kernel/workqueue.c:3708) tasklet_action (kernel/softirq.c:965) handle_softirqs (kernel/softirq.c:622) ...
Reject the frame when packet_len >= skb->len before reading.
--- drivers/net/usb/net1080.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/net1080.c +1 -1
@@ -381,7 +381,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)skb_trim (skb, skb->len -sizeof *trailer);if ((packet_len &0x01 ) ==0 ) { -if (skb->data [packet_len] !=PAD_BYTE ) { +if (packet_len >= skb->len || skb->data[packet_len] !=PAD_BYTE ) { dev->net->stats.rx_frame_errors++;netdev_dbg (dev->net,"bad pad\n" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/1067 gue: validate REMCSUM private option length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang <[email protected]>
[ Upstream commit d335dcc6f521571d57117b8deeebc940836e5450 ]
GUE private flags can indicate that remote checksum offload metadata is present. The private flags field itself is accounted for by guehdr_flags_len(), but guehdr_priv_flags_len() currently returns 0 even when GUE_PFLAG_REMCSUM is set.
This lets a packet with only the private flags field pass validate_gue_flags(), after which gue_remcsum() and gue_gro_remcsum() read the missing REMCSUM start/offset fields from the following bytes.
Account for GUE_PLEN_REMCSUM when GUE_PFLAG_REMCSUM is present so that malformed packets are rejected during option validation.
--- include/net/gue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/gue.h +1 -1
@@ -80,7 +80,7 @@ static inline size_t guehdr_flags_len(__be16 flags)static inline size_t guehdr_priv_flags_len (__be32 flags) { -return 0 ; +return (flags &GUE_PFLAG_REMCSUM ) ?GUE_PLEN_REMCSUM :0 ; }/* Validate standard and private flags. Returns non-zero (meaning invalid)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 656/1067 net: phy: sfp: free mii_bus in sfp_i2c_mdiobus_destroy
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Wozniak <[email protected]>
[ Upstream commit 8f31efff9206f9f0adb853cad6916086aac4d5ef ]
sfp_i2c_mdiobus_create() allocates the I2C MDIO bus with mdio_i2c_alloc(), a plain (non-devm) allocation, and registers it. sfp_i2c_mdiobus_destroy() only unregisters the bus and clears sfp->i2c_mii without calling mdiobus_free(). As the only reference to the bus is then cleared, the struct mii_bus is leaked.
This is hit whenever a copper/RollBall SFP module that instantiated an MDIO bus is removed: sfp_sm_main() takes the global teardown path and calls sfp_i2c_mdiobus_destroy(). sfp_cleanup(), on driver unbind, frees sfp->i2c_mii directly, which is why the leak only triggered on module hot-removal and not on unbind.
Free the bus in sfp_i2c_mdiobus_destroy() to match the allocation done in sfp_i2c_mdiobus_create().
--- drivers/net/phy/sfp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/sfp.c +1 -0
@@ -607,6 +607,7 @@ static int sfp_i2c_mdiobus_create(struct sfp *sfp)static void sfp_i2c_mdiobus_destroy (struct sfp *sfp) {mdiobus_unregister (sfp->i2c_mii); +mdiobus_free (sfp->i2c_mii); sfp->i2c_mii =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/1067 netfilter: xt_u32: reject invalid shift counts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
[ Upstream commit 64cdf7d30ac18e43df6c48004435febb965809a8 ]
u32_match_it() executes rule-supplied shift operands on a 32-bit value. A malformed u32 rule can provide a shift count of 32 or more, triggering an undefined shift out-of-bounds during packet evaluation.
Validate XT_U32_LEFTSH and XT_U32_RIGHTSH operands in u32_mt_checkentry() and reject malformed rules before they reach the packet path.
--- net/netfilter/xt_u32.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/netfilter/xt_u32.c +11 -1
@@ -100,7 +100,7 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par) {const struct xt_u32 *data = par->matchinfo;const struct xt_u32_test *ct; -unsigned int i; +unsigned int i, j;if (data->ntests >ARRAY_SIZE (data->tests))return -EINVAL ;
@@ -111,6 +111,16 @@ static int u32_mt_checkentry(const struct xt_mtchk_param *par)if (ct->nnums >ARRAY_SIZE (ct->location) || ct->nvalues >ARRAY_SIZE (ct->value))return -EINVAL ; + +for (j =1 ; j < ct->nnums; ++j) { +switch (ct->location[j].nextop) { +case XT_U32_LEFTSH : +case XT_U32_RIGHTSH : +if (ct->location[j].number >=32 ) +return -EINVAL ; +break ; + } + } }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/1067 netfilter: xt_rateest: fix u64 truncation in xt_rateest_mt()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Wu <[email protected]>
[ Upstream commit 444853cd438201007da5359821adcc2995655ab1 ]
On links faster than ~34 Gbps, where byte rate may exceed 2^32-1 (~ 4.3 GBps), the comparison result becomes incorrect because the truncated value no longer reflects the actual estimator rate.
Fix by changing the local variables to u64.
--- net/netfilter/xt_rateest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_rateest.c +1 -1
@@ -16,7 +16,7 @@ xt_rateest_mt(const struct sk_buff *skb, struct xt_action_param *par) {const struct xt_rateest_match_info *info = par->matchinfo;struct gnet_stats_rate_est64 sample = {0 }; -u_int32_t bps1, bps2, pps1, pps2; +u64 bps1, bps2, pps1, pps2;bool ret = true;gen_estimator_read (&info->est1->rate_est, &sample);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/1067 netfilter: ip6tables: mark malformed IPv6 extension headers for hotdrop
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhixing Chen <[email protected]>
[ Upstream commit 43ccc20b5a733226417832cf16ef45322e594990 ]
The ah, hbh and rt matches check that the fixed extension header is present, then use the header length field to derive the advertised extension header length for matching.
For the ah match, add the missing advertised-length check. For hbh and rt, update the existing advertised-length checks. In all three cases, set hotdrop to true before returning false when the advertised extension header length exceeds the available skb data.
Returning false treats the packet as a rule mismatch. Set hotdrop to true and drop malformed packets so they cannot bypass rules intended to drop packets with these IPv6 extension headers.
--- net/ipv6/netfilter/ip6t_ah.c | 5 +++++ net/ipv6/netfilter/ip6t_hbh.c | 1 + net/ipv6/netfilter/ip6t_rt.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-)
net/ipv6/netfilter/ip6t_ah.c +5 -0
@@ -56,6 +56,11 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par) } hdrlen =ipv6_authlen (ah); +if (skb->len - ptr < hdrlen) { +/* Packet smaller than its length field */ + par->hotdrop = true; +return false; + }pr_debug ("IPv6 AH LEN %u %u " , hdrlen, ah->hdrlen);pr_debug ("RES %04X " , ah->reserved);
net/ipv6/netfilter/ip6t_hbh.c +1 -0
@@ -75,6 +75,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par) hdrlen =ipv6_optlen (oh);if (skb->len - ptr < hdrlen) {/* Packet smaller than it's length field */ + par->hotdrop = true;return false; }
net/ipv6/netfilter/ip6t_rt.c +2 -1
@@ -56,7 +56,8 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par) hdrlen =ipv6_optlen (rh);if (skb->len - ptr < hdrlen) { -/* Pcket smaller than its length field */ +/* Packet smaller than its length field */ + par->hotdrop = true;return false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/1067 netfilter: xt_connmark: reject invalid shift parameters
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
[ Upstream commit 1b47026fb4b35bac850ad6e8a4ad7fc018e09ebc ]
Revision 2 of the CONNMARK target accepts user-controlled shift parameters and applies them to 32-bit mark values in connmark_tg_shift().
A shift_bits value of 32 or more triggers an undefined-shift bug when the rule is evaluated. Invalid shift_dir values are also accepted and silently fall back to the left-shift path.
Reject invalid revision-2 shift parameters in connmark_tg_check() so malformed rules fail at installation time, before they can reach the packet path.
--- net/netfilter/xt_connmark.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/netfilter/xt_connmark.c +12 -2
@@ -112,6 +112,16 @@ static int connmark_tg_check(const struct xt_tgchk_param *par)return ret; } +static int connmark_tg_check_v2 (const struct xt_tgchk_param *par) +{ +const struct xt_connmark_tginfo2 *info = par->targinfo; + +if (info->shift_dir >D_SHIFT_RIGHT || info->shift_bits >=32 ) +return -EINVAL ; + +return connmark_tg_check (par); +} +static void connmark_tg_destroy (const struct xt_tgdtor_param *par) {nf_ct_netns_put (par->net, par->family);
@@ -162,7 +172,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { .name = "CONNMARK", .revision = 2, .family = NFPROTO_IPV4, - .checkentry = connmark_tg_check, + .checkentry = connmark_tg_check_v2, .target = connmark_tg_v2, .targetsize = sizeof(struct xt_connmark_tginfo2), .destroy = connmark_tg_destroy,
@@ -183,7 +193,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { .name = "CONNMARK", .revision = 2, .family = NFPROTO_IPV6, - .checkentry = connmark_tg_check, + .checkentry = connmark_tg_check_v2, .target = connmark_tg_v2, .targetsize = sizeof(struct xt_connmark_tginfo2), .destroy = connmark_tg_destroy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 687/1067 net/mlx5e: Fix HV VHCA stats zero-sized buffer allocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 25f6b929c7e379cbea7cb8caa67b49b2d1efae17 ]
mlx5e_hv_vhca_stats_create() is called from mlx5e_nic_enable(), before mlx5e_open(). At that point priv->stats_nch is still zero, because it is only ever incremented in mlx5e_channel_stats_alloc(), which is reached only from mlx5e_open_channel().
mlx5e_hv_vhca_stats_buf_size() therefore returns 0, and kvzalloc(0, GFP_KERNEL) returns ZERO_SIZE_PTR ((void *)16) rather than NULL. The "if (!buf)" guard does not catch this, and mlx5e_hv_vhca_stats_create() completes "successfully" with priv->stats_agent.buf set to ZERO_SIZE_PTR.
Once channels are opened (priv->stats_nch > 0) and the hypervisor enables stats reporting, mlx5e_hv_vhca_stats_work() recomputes buf_len using the new non-zero stats_nch and calls memset(buf, 0, buf_len) on ZERO_SIZE_PTR, faulting at address 0x10.
Allocate the buffer based on priv->max_nch, which is set in mlx5e_priv_init() and is the upper bound on stats_nch:
- Add a separate helper mlx5e_hv_vhca_stats_buf_max_size() that returns sizeof(per_ring_stats) * max(max_nch, stats_nch), and use it for the kvzalloc() in mlx5e_hv_vhca_stats_create().
- Keep mlx5e_hv_vhca_stats_buf_size() (which returns based on stats_nch) for the worker's active payload size, so the wire format (block->rings = stats_nch) and the amount of data filled by mlx5e_hv_vhca_fill_stats() are unchanged.
The max(max_nch, stats_nch) guard handles the rare case where mlx5e_attach_netdev() recomputes max_nch downward across a detach/resume cycle while priv->stats_nch persists (mlx5e_detach_netdev does not call mlx5e_priv_cleanup, so stats_nch is only reset when the netdev is destroyed). Without the guard, the worker could compute buf_len from stats_nch and overrun the smaller buffer allocated based on the reduced max_nch.
Allocating a non-zero buffer also makes the kvzalloc() failure path in mlx5e_hv_vhca_stats_create() reachable for the first time: it returns early without (re)creating the agent. Clear priv->stats_agent.{agent,buf} in mlx5e_hv_vhca_stats_destroy() after freeing them, so that if a later create() bails out on this path, a subsequent teardown does not double-free the stale agent/buffer left from a previous enable/disable cycle.
This mirrors the existing mlx5e pattern of preallocating arrays of size max_nch (e.g. priv->channel_stats) and lazily populating entries up to stats_nch on demand.
--- .../net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +9 -1
@@ -54,6 +54,12 @@ static int mlx5e_hv_vhca_stats_buf_size(struct mlx5e_priv *priv) priv->stats_nch); } +static int mlx5e_hv_vhca_stats_buf_max_size (struct mlx5e_priv *priv) +{ +return (sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * +max (priv->max_nch, priv->stats_nch)); +} +static void mlx5e_hv_vhca_stats_work (struct work_struct *work) {struct mlx5e_hv_vhca_stats_agent *sagent;
@@ -122,7 +128,7 @@ static void mlx5e_hv_vhca_stats_cleanup(struct mlx5_hv_vhca_agent *agent)void mlx5e_hv_vhca_stats_create (struct mlx5e_priv *priv) { -int buf_len =mlx5e_hv_vhca_stats_buf_size (priv); +int buf_len =mlx5e_hv_vhca_stats_buf_max_size (priv);struct mlx5_hv_vhca_agent *agent; priv->stats_agent.buf =kvzalloc (buf_len,GFP_KERNEL );
@@ -155,5 +161,7 @@ void mlx5e_hv_vhca_stats_destroy(struct mlx5e_priv *priv)return ;mlx5_hv_vhca_agent_destroy (priv->stats_agent.agent); + priv->stats_agent.agent =NULL ;kvfree (priv->stats_agent.buf); + priv->stats_agent.buf =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 688/1067 net/mlx5e: Fix HV VHCA stats agent registration race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 89b25b5f46f488ea3b29b3444864c76944c9075b ]
mlx5e_hv_vhca_stats_create() registers the stats agent through mlx5_hv_vhca_agent_create(). The helper publishes the agent in hv_vhca->agents[type] under agents_lock and immediately schedules an asynchronous control invalidation on the HV VHCA workqueue before returning to mlx5e.
The asynchronous invalidation invokes the control agent's invalidate callback, which reads the hypervisor control block and forwards the command to mlx5e_hv_vhca_stats_control(). That callback may either:
- call cancel_delayed_work_sync(&priv->stats_agent.work), or
- call queue_delayed_work(priv->wq, &sagent->work, sagent->delay).
However, the delayed_work and priv->stats_agent.agent are only initialized after mlx5_hv_vhca_agent_create() returns to mlx5e:
agent = mlx5_hv_vhca_agent_create(...); /* publish + invalidate */
...
priv->stats_agent.agent = agent; /* too late */
INIT_DELAYED_WORK(&priv->stats_agent.work, ...); /* too late */If the asynchronous control path runs before the two assignments above, it can:
- Operate on an uninitialized delayed_work whose timer.function is NULL. queue_delayed_work() calls add_timer() unconditionally, so when the timer expires the timer softirq invokes a NULL function pointer.
- Re-initialize the timer later through INIT_DELAYED_WORK() while the timer is already enqueued in the timer wheel, corrupting the hlist (entry.pprev cleared while the previous bucket node still points at this entry).
- When the worker eventually runs, mlx5e_hv_vhca_stats_work() reads
sagent->agent (NULL) and dereferences it inside
mlx5_hv_vhca_agent_write().Fix this by:
- Initializing priv->stats_agent.work before invoking mlx5_hv_vhca_agent_create(), so the work is always in a valid state when the control callback observes it.
- Adding a struct mlx5_hv_vhca_agent **ctx_update out-parameter to mlx5_hv_vhca_agent_create(). The helper writes the agent pointer to *ctx_update before publishing into hv_vhca->agents[] and triggering the agents_update flow, so any callback subsequently invoked from that flow already sees a valid priv->stats_agent.agent. This avoids having the control callback participate in agent initialization.
While at it, access priv->stats_agent.agent with READ_ONCE()/WRITE_ONCE() for the cross-CPU access with the worker, and clear priv->stats_agent.buf on the agent_create() failure path.
--- .../mellanox/mlx5/core/en/hv_vhca_stats.c | 21 +++++++++++-------- .../ethernet/mellanox/mlx5/core/lib/hv_vhca.c | 8 +++++-- .../ethernet/mellanox/mlx5/core/lib/hv_vhca.h | 6 ++++-- 3 files changed, 22 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +12 -9
@@ -73,7 +73,7 @@ static void mlx5e_hv_vhca_stats_work(struct work_struct *work) sagent = container_of(dwork, struct mlx5e_hv_vhca_stats_agent, work); priv = container_of(sagent, struct mlx5e_priv, stats_agent); buf_len =mlx5e_hv_vhca_stats_buf_size (priv); - agent = sagent->agent; + agent =READ_ONCE (sagent->agent); buf = sagent->buf;memset (buf,0 , buf_len);
@@ -135,11 +135,14 @@ void mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv)if (!priv->stats_agent.buf)return ; +INIT_DELAYED_WORK (&priv->stats_agent.work, mlx5e_hv_vhca_stats_work); + agent =mlx5_hv_vhca_agent_create (priv->mdev->hv_vhca,MLX5_HV_VHCA_AGENT_STATS , mlx5e_hv_vhca_stats_control,NULL , mlx5e_hv_vhca_stats_cleanup, - priv); + priv, + &priv->stats_agent.agent);if (IS_ERR_OR_NULL (agent)) {if (IS_ERR (agent))
@@ -148,20 +151,20 @@ void mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv) PTR_ERR(agent));kvfree (priv->stats_agent.buf); -return ; + priv->stats_agent.buf =NULL ; } - - priv->stats_agent.agent = agent; -INIT_DELAYED_WORK (&priv->stats_agent.work, mlx5e_hv_vhca_stats_work); }void mlx5e_hv_vhca_stats_destroy (struct mlx5e_priv *priv) { -if (IS_ERR_OR_NULL (priv->stats_agent.agent)) +struct mlx5_hv_vhca_agent *agent; + + agent =READ_ONCE (priv->stats_agent.agent); +if (IS_ERR_OR_NULL (agent))return ; -mlx5_hv_vhca_agent_destroy (priv->stats_agent.agent); - priv->stats_agent.agent =NULL ; +mlx5_hv_vhca_agent_destroy (agent); +WRITE_ONCE (priv->stats_agent.agent,NULL );kvfree (priv->stats_agent.buf); priv->stats_agent.buf =NULL ; }
drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c +6 -2
@@ -190,7 +190,7 @@ mlx5_hv_vhca_control_agent_create(struct mlx5_hv_vhca *hv_vhca)return mlx5_hv_vhca_agent_create (hv_vhca,MLX5_HV_VHCA_AGENT_CONTROL ,NULL , mlx5_hv_vhca_control_agent_invalidate, -NULL ,NULL ); +NULL ,NULL ,NULL ); }static void mlx5_hv_vhca_control_agent_destroy (struct mlx5_hv_vhca_agent *agent)
@@ -256,7 +256,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleaup)(struct mlx5_hv_vhca_agent *agent), - void *priv) + void *priv, + struct mlx5_hv_vhca_agent **ctx_update) { struct mlx5_hv_vhca_agent *agent;
@@ -284,6 +285,9 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca, agent->invalidate = invalidate; agent->cleanup = cleaup; +if (ctx_update) +WRITE_ONCE (*ctx_update, agent); +mutex_lock (&hv_vhca->agents_lock); hv_vhca->agents[type] = agent;mutex_unlock (&hv_vhca->agents_lock);
drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.h +4 -2
@@ -43,7 +43,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleanup)(struct mlx5_hv_vhca_agent *agent), - void *context); + void *context, + struct mlx5_hv_vhca_agent **ctx_update);void mlx5_hv_vhca_agent_destroy (struct mlx5_hv_vhca_agent *agent); int mlx5_hv_vhca_agent_write(struct mlx5_hv_vhca_agent *agent,
@@ -84,7 +85,8 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,void (*invalidate)(struct mlx5_hv_vhca_agent *,u64 block_mask), void (*cleanup)(struct mlx5_hv_vhca_agent *agent), - void *context) + void *context, + struct mlx5_hv_vhca_agent **ctx_update) { return NULL; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 689/1067 qede: fix off-by-one in BD ring consumption on build_skb failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
[ Upstream commit a0a558ca7e75b49e71f8c545c30e8c005e6e4e2f ]
qede_rx_build_skb() and qede_tpa_rx_build_skb() do not check for a NULL return from qede_build_skb(). When it returns NULL under memory pressure, the functions still consume a BD from the ring before returning NULL. The callers then recycle additional BDs, resulting in one extra BD being consumed (off-by-one). This desynchronizes the BD ring, which can corrupt DMA page reference counts and lead to SLUB freelist corruption.
Commit 4e910dbe3650 ("qede: confirm skb is allocated before using") added a NULL check inside qede_build_skb() to prevent a NULL pointer dereference, but did not address the missing NULL checks in the callers, making this off-by-one reachable.
Fix this by adding NULL checks for the return value of qede_build_skb() in both qede_rx_build_skb() and qede_tpa_rx_build_skb(), returning NULL immediately before any BD ring manipulation.
--- drivers/net/ethernet/qlogic/qede/qede_fp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/qlogic/qede/qede_fp.c +5 -0
@@ -765,6 +765,9 @@ qede_tpa_rx_build_skb(struct qede_dev *edev,struct sk_buff *skb; skb =qede_build_skb (rxq, bd, len, pad); +if (unlikely (!skb)) +return NULL ; + bd->page_offset += rxq->rx_buf_seg_size;if (bd->page_offset ==PAGE_SIZE ) {
@@ -812,6 +815,8 @@ qede_rx_build_skb(struct qede_dev *edev, } skb =qede_build_skb (rxq, bd, len, pad); +if (unlikely (!skb)) +return NULL ;if (unlikely (qede_realloc_rx_buffer (rxq, bd))) {/* Incr page ref count to reuse on allocation failure so
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 690/1067 net: qualcomm: rmnet: add tx packets aggregation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
[ Upstream commit 64b5d1f8f2d1b3f039cfb0dd8035892015543e58 ]
Add tx packets aggregation.
Bidirectional TCP throughput tests through iperf with low-cat Thread-x based modems revelead performance issues both in tx and rx.
The Windows driver does not show this issue: inspecting USB packets revealed that the only notable change is the driver enabling tx packets aggregation.
Tx packets aggregation is by default disabled and can be enabled by increasing the value of ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES.
The maximum aggregated size is by default set to a reasonably low value in order to support the majority of modems.
This implementation is based on patches available in Code Aurora repositories (msm kernel) whose main authors are
Subash Abhinov Kasiviswanathan <[email protected]> Sean Tranchetti <[email protected]>
Stable-dep-of: f0f1887a9e30 ("net: qualcomm: rmnet: validate MAP frame length before ingress parsing")
--- .../ethernet/qualcomm/rmnet/rmnet_config.c | 5 + .../ethernet/qualcomm/rmnet/rmnet_config.h | 20 ++ .../ethernet/qualcomm/rmnet/rmnet_handlers.c | 18 +- .../net/ethernet/qualcomm/rmnet/rmnet_map.h | 6 + .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 191 ++++++++++++++++++ .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 9 +- .../net/ethernet/qualcomm/rmnet/rmnet_vnd.h | 1 + 7 files changed, 246 insertions(+), 4 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +5 -0
@@ -12,6 +12,7 @@#include "rmnet_handlers.h" #include "rmnet_vnd.h" #include "rmnet_private.h" +#include "rmnet_map.h" /* Local Definitions and Declarations */
@@ -39,6 +40,8 @@ static int rmnet_unregister_real_device(struct net_device *real_dev)if (port->nr_rmnet_devs)return -EINVAL ; +rmnet_map_tx_aggregate_exit (port); +netdev_rx_handler_unregister (real_dev);kfree (port);
@@ -79,6 +82,8 @@ static int rmnet_register_real_device(struct net_device *real_dev,for (entry =0 ; entry <RMNET_MAX_LOGICAL_EP ; entry++)INIT_HLIST_HEAD (&port->muxed_ep[entry]); +rmnet_map_tx_aggregate_init (port); +netdev_dbg (real_dev,"registered with rmnet\n" );return 0 ; }
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +20 -0
@@ -6,6 +6,7 @@*/ #include <linux/skbuff.h> +#include <linux/time.h> #include <net/gro_cells.h> #ifndef _RMNET_CONFIG_H_
@@ -20,6 +21,12 @@ struct rmnet_endpoint {struct rcu_head rcu; }; +struct rmnet_egress_agg_params { +u32 bytes; +u32 count; +u64 time_nsec; +}; +/* One instance of this structure is instantiated for each real_dev associated * with rmnet. */
@@ -31,6 +38,19 @@ struct rmnet_port {struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP ];struct net_device *bridge_ep;struct net_device *rmnet_dev; + +/* Egress aggregation information */ +struct rmnet_egress_agg_params egress_agg_params; +/* Protect aggregation related elements */ +spinlock_t agg_lock; +struct sk_buff *skbagg_head; +struct sk_buff *skbagg_tail; +int agg_state; +u8 agg_count; +struct timespec64 agg_time; +struct timespec64 agg_last; +struct hrtimer hrtimer; +struct work_struct agg_wq; };extern struct rtnl_link_ops rmnet_link_ops;
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +16 -2
@@ -164,8 +164,18 @@ static int rmnet_map_egress_handler(struct sk_buff *skb, map_header->mux_id = mux_id; - skb->protocol =htons (ETH_P_MAP ); +if (READ_ONCE (port->egress_agg_params.count) >1 ) { +unsigned int len; + + len =rmnet_map_tx_aggregate (skb, port, orig_dev); +if (likely (len)) { +rmnet_vnd_tx_fixup_len (len, orig_dev); +return -EINPROGRESS ; + } +return -ENOMEM ; + } + skb->protocol =htons (ETH_P_MAP );return 0 ; }
@@ -235,6 +245,7 @@ void rmnet_egress_handler(struct sk_buff *skb)struct rmnet_port *port;struct rmnet_priv *priv;u8 mux_id; +int err;sk_pacing_shift_update (skb->sk,8 );
@@ -247,8 +258,11 @@ void rmnet_egress_handler(struct sk_buff *skb)if (!port) goto drop; -if (rmnet_map_egress_handler (skb, port, mux_id, orig_dev)) + err =rmnet_map_egress_handler (skb, port, mux_id, orig_dev); +if (err == -ENOMEM ) goto drop; +else if (err == -EINPROGRESS ) +return ;rmnet_vnd_tx_fixup (skb, orig_dev);
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +6 -0
@@ -53,5 +53,11 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,struct net_device *orig_dev, int csum_type);int rmnet_map_process_next_hdr_packet (struct sk_buff *skb,u16 len); +unsigned int rmnet_map_tx_aggregate (struct sk_buff *skb,struct rmnet_port *port, +struct net_device *orig_dev); +void rmnet_map_tx_aggregate_init (struct rmnet_port *port); +void rmnet_map_tx_aggregate_exit (struct rmnet_port *port); +void rmnet_map_update_ul_agg_config (struct rmnet_port *port,u32 size, +u32 count,u32 time);#endif /* _RMNET_MAP_H_ */
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +191 -0
200 lines not on this page · raw message
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +7 -2
@@ -29,7 +29,7 @@ void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev)u64_stats_update_end (&pcpu_ptr->syncp); } -void rmnet_vnd_tx_fixup (struct sk_buff *skb,struct net_device *dev) +void rmnet_vnd_tx_fixup_len (unsigned int len,struct net_device *dev) {struct rmnet_priv *priv =netdev_priv (dev);struct rmnet_pcpu_stats *pcpu_ptr;
@@ -38,10 +38,15 @@ void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev)u64_stats_update_begin (&pcpu_ptr->syncp); pcpu_ptr->stats.tx_pkts++; - pcpu_ptr->stats.tx_bytes += skb->len; + pcpu_ptr->stats.tx_bytes += len;u64_stats_update_end (&pcpu_ptr->syncp); } +void rmnet_vnd_tx_fixup (struct sk_buff *skb,struct net_device *dev) +{ +rmnet_vnd_tx_fixup_len (skb->len, dev); +} +/* Network Device Operations */ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h +1 -0
@@ -16,6 +16,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,int rmnet_vnd_dellink (u8 id,struct rmnet_port *port,struct rmnet_endpoint *ep);void rmnet_vnd_rx_fixup (struct sk_buff *skb,struct net_device *dev); +void rmnet_vnd_tx_fixup_len (unsigned int len,struct net_device *dev);void rmnet_vnd_tx_fixup (struct sk_buff *skb,struct net_device *dev);void rmnet_vnd_setup (struct net_device *dev);int rmnet_vnd_validate_real_dev_mtu (struct net_device *real_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 691/1067 net: qualcomm: rmnet: validate MAP frame length before ingress parsing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit f0f1887a9e30712a1df03e152dce6fb91344b1f3 ]
When ingress deaggregation is disabled, rmnet_map_ingress_handler() passes the skb straight to __rmnet_map_ingress_handler(), skipping the length validation that rmnet_map_deaggregate() performs on the aggregated path. The parser then dereferences the MAP header and csum header/trailer based on the on-wire pkt_len without checking skb->len, so a short frame is read out of bounds:
BUG: KASAN: slab-out-of-bounds in rmnet_map_checksum_downlink_packet Read of size 1 at addr ffff88801118ed00 by task exploit/147 Call Trace: ... rmnet_map_checksum_downlink_packet (drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:413) __rmnet_map_ingress_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:96) rmnet_rx_handler (drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:129) __netif_receive_skb_core.constprop.0 (net/core/dev.c:6089) netif_receive_skb (net/core/dev.c:6460) tun_get_user (drivers/net/tun.c:1955) tun_chr_write_iter (drivers/net/tun.c:2001) vfs_write (fs/read_write.c:688) ksys_write (fs/read_write.c:740) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ...
Factor that validation out of rmnet_map_deaggregate() into rmnet_map_validate_packet_len() and run it on the no-aggregation path too. The MAP header is bounds-checked first, since this path can receive a frame shorter than the header.
--- .../ethernet/qualcomm/rmnet/rmnet_handlers.c | 5 +- .../net/ethernet/qualcomm/rmnet/rmnet_map.h | 1 + .../ethernet/qualcomm/rmnet/rmnet_map_data.c | 72 ++++++++++--------- 3 files changed, 45 insertions(+), 33 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +4 -1
@@ -126,7 +126,10 @@ rmnet_map_ingress_handler(struct sk_buff *skb,consume_skb (skb); }else { -__rmnet_map_ingress_handler (skb, port); +if (rmnet_map_validate_packet_len (skb, port)) +__rmnet_map_ingress_handler (skb, port); +else +kfree_skb (skb); } }
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +1 -0
@@ -59,5 +59,6 @@ void rmnet_map_tx_aggregate_init(struct rmnet_port *port);void rmnet_map_tx_aggregate_exit (struct rmnet_port *port);void rmnet_map_update_ul_agg_config (struct rmnet_port *port,u32 size,u32 count,u32 time); +u32 rmnet_map_validate_packet_len (struct sk_buff *skb,struct rmnet_port *port);#endif /* _RMNET_MAP_H_ */
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +40 -32
94 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 692/1067 net/smc: fix UAF in smc_cdc_rx_handler() by pinning the socket
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 9d160b35cc34a2ba8229d07651468a7848325135 ]
smc_cdc_rx_handler() looks up the connection by token under the link group's conns_lock, drops the lock, and then dereferences conn and the smc_sock derived from it, ending in sock_hold(&smc->sk) inside smc_cdc_msg_recv(). No reference is held across the lock release.
The only reference pinning the socket while the connection is discoverable in the link group is taken in smc_lgr_register_conn() (sock_hold) and dropped in __smc_lgr_unregister_conn() (sock_put), both under conns_lock. Once the handler drops conns_lock, a concurrent close() -> smc_release() -> smc_conn_free() -> smc_lgr_unregister_conn() can drop that reference and free the smc_sock, so the handler's later sock_hold() runs on freed memory:
WARNING: lib/refcount.c:25 at refcount_warn_saturate Workqueue: rxe_wq do_work refcount_warn_saturate (lib/refcount.c:25) smc_cdc_msg_recv (net/smc/smc_cdc.c:430) smc_cdc_rx_handler (net/smc/smc_cdc.c:502) smc_wr_rx_tasklet_fn (net/smc/smc_wr.c:445) tasklet_action_common (kernel/softirq.c:938) handle_softirqs (kernel/softirq.c:622) Kernel panic - not syncing: panic_on_warn set
Only SMC-R is affected. The SMC-D receive tasklet is stopped by tasklet_kill(&conn->rx_tsklet) in smc_conn_free() before the connection is unregistered, so it cannot run concurrently with the free.
Take the socket reference while still holding conns_lock, so the registration reference can no longer be the last one, and drop it once the handler is done.
--- net/smc/smc_cdc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/smc/smc_cdc.c +10 -5
@@ -438,9 +438,9 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf) {struct smc_link *link = (struct smc_link *)wc->qp->qp_context;struct smc_cdc_msg *cdc = buf; +struct smc_sock *smc =NULL ;struct smc_connection *conn;struct smc_link_group *lgr; -struct smc_sock *smc;if (wc->byte_len < offsetof(struct smc_cdc_msg , reserved))return ;/* short message */
@@ -451,21 +451,26 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf) lgr =smc_get_lgr (link);read_lock_bh (&lgr->conns_lock); conn =smc_lgr_find_conn (ntohl (cdc->token), lgr); -read_unlock_bh (&lgr->conns_lock); -if (!conn || conn->out_of_sync) +if (!conn || conn->out_of_sync) { +read_unlock_bh (&lgr->conns_lock);return ; + } smc = container_of(conn, struct smc_sock, conn); +sock_hold (&smc->sk); +read_unlock_bh (&lgr->conns_lock);if (cdc->prod_flags.failover_validation) {smc_cdc_msg_validate (smc, cdc, link); -return ; + goto out; }if (smc_cdc_before (ntohs (cdc->seqno), conn->local_rx_ctrl.seqno))/* received seqno is old */ -return ; + goto out;smc_cdc_msg_recv (smc, cdc); +out: +sock_put (&smc->sk); }static struct smc_wr_rx_handler smc_cdc_rx_handlers[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 657/1067 net: gianfar: dispose irq mappings on probe failure and device removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit dbf803bc4a8b0522c9a12560c20905a5952d1cb9 ]
irq_of_parse_and_map() creates irqdomain mappings that should be balanced with irq_dispose_mapping(). The driver never called irq_dispose_mapping(), leaking mappings on probe failure and device removal.
Fix by adding irq_dispose_mapping() in free_gfar_dev() and expanding its loop from priv->num_grps to MAXGROUPS so the error path also catches partially-initialized groups. All irqinfo pointers are pre-initialized to NULL in gfar_of_init(), making the NULL-guarded walk in free_gfar_dev() safe for every scenario.
gfar_parse_group() itself is left as a simple parse function with no resource management; cleanup is centralized in the caller's error path.
--- drivers/net/ethernet/freescale/gianfar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +11 -5
@@ -470,10 +470,13 @@ static void free_gfar_dev(struct gfar_private *priv) {int i, j; -for (i =0 ; i < priv->num_grps; i++) +for (i =0 ; i <MAXGROUPS ; i++)for (j =0 ; j <GFAR_NUM_IRQS ; j++) { -kfree (priv->gfargrp[i].irqinfo[j]); - priv->gfargrp[i].irqinfo[j] =NULL ; +if (priv->gfargrp[i].irqinfo[j]) { +irq_dispose_mapping (priv->gfargrp[i].irqinfo[j]->irq); +kfree (priv->gfargrp[i].irqinfo[j]); + priv->gfargrp[i].irqinfo[j] =NULL ; + } }free_netdev (priv->ndev);
@@ -630,7 +633,7 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)static int gfar_of_init (struct platform_device *ofdev,struct net_device **pdev) {const char *model; -int err =0 , i; +int err =0 , i, j;phy_interface_t interface;struct net_device *dev =NULL ;struct gfar_private *priv =NULL ;
@@ -714,8 +717,11 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->rx_list.count =0 ;mutex_init (&priv->rx_queue_access); -for (i =0 ; i <MAXGROUPS ; i++) +for (i =0 ; i <MAXGROUPS ; i++) { priv->gfargrp[i].regs =NULL ; +for (j =0 ; j <GFAR_NUM_IRQS ; j++) + priv->gfargrp[i].irqinfo[j] =NULL ; + }/* Parse and initialize group specific information */ if (priv->mode ==MQ_MG_MODE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 693/1067 amt: fix size calculation in amt_get_size()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9e05e91a9a847ed57926414bd7c2c5e54d6c56c6 ]
amt_get_size() incorrectly used sizeof(struct iphdr) for the sizes of IFLA_AMT_DISCOVERY_IP, IFLA_AMT_REMOTE_IP, and IFLA_AMT_LOCAL_IP. These attributes contain IPv4 addresses (__be32), not full IP headers.
Replace sizeof(struct iphdr) with sizeof(__be32) to avoid over-allocating netlink message space.
--- drivers/net/amt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/amt.c +3 -3
@@ -3303,9 +3303,9 @@ static size_t amt_get_size(const struct net_device *dev)nla_total_size (sizeof (__u16)) +/* IFLA_AMT_GATEWAY_PORT */ nla_total_size (sizeof (__u32)) +/* IFLA_AMT_LINK */ nla_total_size (sizeof (__u32)) +/* IFLA_MAX_TUNNELS */ -nla_total_size (sizeof (struct iphdr )) +/* IFLA_AMT_DISCOVERY_IP */ -nla_total_size (sizeof (struct iphdr )) +/* IFLA_AMT_REMOTE_IP */ -nla_total_size (sizeof (struct iphdr ));/* IFLA_AMT_LOCAL_IP */ +nla_total_size (sizeof (__be32)) +/* IFLA_AMT_DISCOVERY_IP */ +nla_total_size (sizeof (__be32)) +/* IFLA_AMT_REMOTE_IP */ +nla_total_size (sizeof (__be32));/* IFLA_AMT_LOCAL_IP */ }static int amt_fill_info (struct sk_buff *skb,const struct net_device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 694/1067 Bluetooth: MGMT: Fix adv monitor add failure cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 384a4b2fef9ffe5e270ee5558975c0504881c5fb ]
hci_add_adv_monitor() publishes a new adv_monitor in hdev->adv_monitors_idr before the powered MSFT setup step. The MSFT offload add path can then fail either locally before the controller add command completes, or in the MSFT add callback. In the current queued management add flow, hci_cmd_sync_work() still invokes mgmt_add_adv_patterns_monitor_complete() with the original pending command after msft_add_monitor_pattern() returns.
The buggy scenario involves two paths, with each column showing the order within that path:
MSFT add handling MGMT completion 1. insert monitor and handle 1. receive sync error 2. send MSFT add command 2. call add-monitor completion 3. callback sees bad response 3. load cmd->user_data 4. callback frees monitor 4. read monitor->handle
Local MSFT setup failures have the other half of the same ownership bug:
they return an error after the IDR insertion, but no later code removes the failed monitor from the IDR.
Keep ownership with the pending management command until its completion. For normal management adds, the MSFT add callback now records successful controller state and returns errors to its caller. The management completion frees the monitor on non-success after copying the response handle, while resume/reregister callback-error cleanup remains in the MSFT callback. The success path keeps the existing bookkeeping.
Validation reproduced this kernel report:
BUG: KASAN: slab-use-after-free in mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] Call Trace: <TASK> dump_stack_lvl+0x66/0xa0 print_report+0xce/0x5f0 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 ? __virt_addr_valid+0x19f/0x330 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] kasan_report+0xe0/0x110 ? mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] mgmt_add_adv_patterns_monitor_complete+0xfb/0x260 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 ? 0xffffffffc00d00da ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] ? hci_cmd_sync_work+0x1ab/0x210 [bluetooth] hci_cmd_sync_work+0x1c0/0x210 [bluetooth] ? __pfx_mgmt_add_adv_patterns_monitor_complete+0x10/0x10 [bluetooth] process_one_work+0x4fd/0xbc0 ? __pfx_process_one_work+0x10/0x10 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? __list_add_valid_or_report+0x37/0xf0 ? __pfx_hci_cmd_sync_work+0x10/0x10 [bluetooth] ? srso_alias_return_thunk+0x5/0xfbef5 worker_thread+0x2d8/0x570 ? __pfx_worker_thread+0x10/0x10 kthread+0x1ad/0x1f0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c9/0x540 ? __pfx_ret_from_fork+0x10/0x10 ? srso_alias_return_thunk+0x5/0xfbef5 ? __switch_to+0x2e9/0x730 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 471 on cpu 3 at 285.205389s: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 __kasan_kmalloc+0xaa/0xb0 add_adv_patterns_monitor_rssi+0xd5/0x230 [bluetooth] hci_sock_sendmsg+0x96b/0xf80 [bluetooth] __sys_sendto+0x2bc/0x2d0 __x64_sys_sendto+0x76/0x90 do_syscall_64+0x115/0x6a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 454 on cpu 2 at 285.217112s: kasan_save_stack+0x33/0x60 kasan_save_track+0x17/0x60 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x5f/0x80 kfree+0x313/0x590 msft_add_monitor_sync+0x54a/0x570 [bluetooth] hci_add_adv_monitor+0x133/0x180 [bluetooth] hci_cmd_sync_work+0x187/0x210 [bluetooth] process_one_work+0x4fd/0xbc0 worker_thread+0x2d8/0x570 kthread+0x1ad/0x1f0 ret_from_fork+0x3c9/0x540 ret_from_fork_asm+0x1a/0x30
--- net/bluetooth/mgmt.c | 2 ++ net/bluetooth/msft.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/mgmt.c +2 -0
@@ -5343,6 +5343,8 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev,if (monitor->state ==ADV_MONITOR_STATE_NOT_REGISTERED ) monitor->state =ADV_MONITOR_STATE_REGISTERED ;hci_update_passive_scan (hdev); + }else { +hci_free_adv_monitor (hdev, monitor); } mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode,
net/bluetooth/msft.c +1 -1
@@ -246,7 +246,7 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode, monitor->state =ADV_MONITOR_STATE_OFFLOADED ; unlock: -if (status) +if (status && msft->resuming)hci_free_adv_monitor (hdev, monitor);hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 695/1067 Bluetooth: ISO: exclude RFU bits from ISO_SDU_Length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit fd076d8deeab6f9f18ef13400f89e1f550df665b ]
slen contains ISO_SDU_Length (12 bits), RFU (2 bits), Packet_Status_Flags (2 bits).
Exclude the RFU bits from hci_iso_data_len. Also add masks to the pack macro.
--- include/net/bluetooth/hci.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/net/bluetooth/hci.h +3 -2
@@ -2969,8 +2969,9 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)#define hci_iso_flags_pack (pb, ts) ((pb & 0x03) | ((ts & 0x01) << 2))/* ISO data length and flags pack/unpack */ -#define hci_iso_data_len_pack (h, f) ((__u16) ((h) | ((f) << 14))) -#define hci_iso_data_len (h) ((h) & 0x3fff) +#define hci_iso_data_len_pack (h, f) ((__u16) (((h) & 0x0fff) | \ + (((f) & 0x3) << 14))) +#define hci_iso_data_len (h) ((h) & 0x0fff)#define hci_iso_data_flags (h) ((h) >> 14)/* codec transport types */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 696/1067 Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit dd068ef044128db655f48323a4acfd5907e04903 ]
bpa10x_setup() sends the vendor command 0xfc0e and passes the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length:
bt_dev_info(hdev, "%s", (char *)(skb->data + 1)); hci_set_fw_info(hdev, "%s", skb->data + 1);
A device that returns a one-byte response (status only) leaves skb->data + 1 past the end of the data, and the %s walk reads adjacent slab memory until it meets a NUL. The same happens when the payload is not NUL-terminated within skb->len. The out-of-bounds bytes end up in the kernel log and the firmware-info debugfs file.
Print the revision string with a bounded "%.*s" limited to skb->len - 1 instead. This keeps the string readable for well-behaved devices while never reading past the received data, and does not fail setup, so a device returning a short or unterminated response keeps working.
--- drivers/bluetooth/bpa10x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/bpa10x.c +6 -2
@@ -254,9 +254,13 @@ static int bpa10x_setup(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the device controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 697/1067 ring-buffer: Fix event length with forced 8-byte alignment
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
[ Upstream commit c37e0a4b79a6bbb96ce5ffe279d7c001e20529e0 ]
When RB_FORCE_8BYTE_ALIGNMENT is true, rb_calculate_event_length() reserves the space of event->array[0] for placing the data length and rb_update_event() stores the data length in event->array[0] accordingly. As a result the whole event length will add extra 4 bytes for sizeof(event.array[0]) unconditionally.
But ring_buffer_event_length() only subtracts the sizeof(event->array[0]) for events larger than RB_MAX_SMALL_DATA + sizeof(event->array[0]). As a result, small events on architectures with RB_FORCE_8BYTE_ALIGNMENT=true report a data length that is 4 bytes larger than expected.
To fix it, add the RB_FORCE_8BYTE_ALIGNMENT as a condition to subtract the size of that length field whenever RB_FORCE_8BYTE_ALIGNMENT is true.
This issue is observed in a riscv64 kernel with CONFIG_HAVE_64BIT_ALIGNED_ACCESS set to y, when we run ftrace selftest trace_marker_raw.tc, we get the weird log: for cases where the id is 1..100, the number of data field is 8*N, but once id exceeds 100, the number of data field becomes 8*N+4:
# 1 buf: 58 00 00 00 80 5e d1 63 (number of data field is 8*1)
...
# a buf: 58 ... (number of data field is 8*2) ... # 64 buf: 58 ... (number of data field is 8*13) # 65 buf: 58 ... (number of data field is 8*13+4)
After applying this change, the number of data field keeps being 8*N+4 consistently.
--- kernel/trace/ring_buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +2 -1
@@ -255,7 +255,8 @@ unsigned ring_buffer_event_length(struct ring_buffer_event *event)if (event->type_len >RINGBUF_TYPE_DATA_TYPE_LEN_MAX )return length; length -=RB_EVNT_HDR_SIZE ; -if (length >RB_MAX_SMALL_DATA +sizeof (event->array[0 ])) +if (length >RB_MAX_SMALL_DATA +sizeof (event->array[0 ]) || +RB_FORCE_8BYTE_ALIGNMENT ) length -=sizeof (event->array[0 ]);return length; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 698/1067 net: usb: lan78xx: move functions to avoid forward definitions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit 39aa1d620d10cdd276f4728da50f136dbe939643 ]
Move following functions to avoid forward declarations in the code:
- lan78xx_start_hw()
- lan78xx_stop_hw()
- lan78xx_flush_fifo()
- lan78xx_start_tx_path()
- lan78xx_stop_tx_path()
- lan78xx_flush_tx_fifo()
- lan78xx_start_rx_path()
- lan78xx_stop_rx_path()
- lan78xx_flush_rx_fifo()
These functions will be used in an upcoming PHYlink migration patch.
No modifications to the functionality of the code are made.
Stable-dep-of: 60444706aa17 ("net: usb: lan78xx: disable VLAN filter in promiscuous mode")
--- drivers/net/usb/lan78xx.c | 300 +++++++++++++++++++------------------- 1 file changed, 150 insertions(+), 150 deletions(-)
drivers/net/usb/lan78xx.c +150 -150
@@ -817,6 +817,156 @@ static void lan78xx_update_stats(struct lan78xx_net *dev)usb_autopm_put_interface (dev->intf); } +static int lan78xx_start_hw (struct lan78xx_net *dev,u32 reg,u32 hw_enable) +{ +return lan78xx_update_reg (dev, reg, hw_enable, hw_enable); +} + +static int lan78xx_stop_hw (struct lan78xx_net *dev,u32 reg,u32 hw_enabled, +u32 hw_disabled) +{ +unsigned long timeout; +bool stopped = true; +int ret; +u32 buf; + +/* Stop the h/w block (if not already stopped) */ + + ret =lan78xx_read_reg (dev, reg, &buf); +if (ret <0 ) +return ret; + +if (buf & hw_enabled) { + buf &= ~hw_enabled; + + ret =lan78xx_write_reg (dev, reg, buf); +if (ret <0 ) +return ret; + + stopped = false; + timeout = jiffies +HW_DISABLE_TIMEOUT ; +do { + ret =lan78xx_read_reg (dev, reg, &buf); +if (ret <0 ) +return ret; + +if (buf & hw_disabled) + stopped = true; +else +msleep (HW_DISABLE_DELAY_MS ); + }while (!stopped && !time_after (jiffies, timeout)); + } + + ret = stopped ?0 : -ETIME ; + +return ret; +} + +static int lan78xx_flush_fifo (struct lan78xx_net *dev,u32 reg,u32 fifo_flush) +{ +return lan78xx_update_reg (dev, reg, fifo_flush, fifo_flush); +} + +static int lan78xx_start_tx_path (struct lan78xx_net *dev) +{ +int ret; + +netif_dbg (dev, drv, dev->net,"start tx path" ); + +/* Start the MAC transmitter */ + + ret =lan78xx_start_hw (dev,MAC_TX ,MAC_TX_TXEN_ ); +if (ret <0 ) +return ret; + +/* Start the Tx FIFO */ + + ret =lan78xx_start_hw (dev,FCT_TX_CTL ,FCT_TX_CTL_EN_ ); +if (ret <0 ) +return ret; + +return 0 ; +} + +static int lan78xx_stop_tx_path (struct lan78xx_net *dev) +{ +int ret; + +netif_dbg (dev, drv, dev->net,"stop tx path" ); + +/* Stop the Tx FIFO */ + + ret =lan78xx_stop_hw (dev,FCT_TX_CTL ,FCT_TX_CTL_EN_ ,FCT_TX_CTL_DIS_ ); +if (ret <0 ) +return ret; + +/* Stop the MAC transmitter */ + + ret =lan78xx_stop_hw (dev,MAC_TX ,MAC_TX_TXEN_ ,MAC_TX_TXD_ ); +if (ret <0 ) +return ret; + +return 0 ; +} + +/* The caller must ensure the Tx path is stopped before calling +* lan78xx_flush_tx_fifo(). +*/ +static int lan78xx_flush_tx_fifo (struct lan78xx_net *dev) +{ +return lan78xx_flush_fifo (dev,FCT_TX_CTL ,FCT_TX_CTL_RST_ ); +} + +static int lan78xx_start_rx_path (struct lan78xx_net *dev) +{ +int ret; + +netif_dbg (dev, drv, dev->net,"start rx path" ); + +/* Start the Rx FIFO */ + + ret =lan78xx_start_hw (dev,FCT_RX_CTL ,FCT_RX_CTL_EN_ ); +if (ret <0 ) +return ret; + +/* Start the MAC receiver*/ + + ret =lan78xx_start_hw (dev,MAC_RX ,MAC_RX_RXEN_ ); +if (ret <0 ) +return ret; + +return 0 ; +} + +static int lan78xx_stop_rx_path (struct lan78xx_net *dev) +{ +int ret; + +netif_dbg (dev, drv, dev->net,"stop rx path" ); + +/* Stop the MAC receiver */ + + ret =lan78xx_stop_hw (dev,MAC_RX ,MAC_RX_RXEN_ ,MAC_RX_RXD_ ); +if (ret <0 ) +return ret; + +/* Stop the Rx FIFO */ + + ret =lan78xx_stop_hw (dev,FCT_RX_CTL ,FCT_RX_CTL_EN_ ,FCT_RX_CTL_DIS_ ); +if (ret <0 ) +return ret; + +return 0 ; +} + +/* The caller must ensure the Rx path is stopped before calling +* lan78xx_flush_rx_fifo(). +*/ +static int lan78xx_flush_rx_fifo (struct lan78xx_net *dev) +{ +return lan78xx_flush_fifo (dev,FCT_RX_CTL ,FCT_RX_CTL_RST_ ); +} +/* Loop until the read is completed with timeout called with phy_mutex held */ static int lan78xx_phy_wait_not_busy (struct lan78xx_net *dev) {
@@ -2747,156 +2897,6 @@ static int lan78xx_urb_config_init(struct lan78xx_net *dev)return result; } -static int lan78xx_start_hw (struct lan78xx_net *dev,u32 reg,u32 hw_enable) -{ -return lan78xx_update_reg (dev, reg, hw_enable, hw_enable); -} - -static int lan78xx_stop_hw (struct lan78xx_net *dev,u32 reg,u32 hw_enabled, -u32 hw_disabled) -{ -unsigned long timeout; -bool stopped = true; -int ret; -u32 buf; - -/* Stop the h/w block (if not already stopped) */ - - ret =lan78xx_read_reg (dev, reg, &buf); -if (ret <0 ) -return ret; - -if (buf & hw_enabled) { - buf &= ~hw_enabled; - - ret =lan78xx_write_reg (dev, reg, buf); -if (ret <0 ) -return ret; - - stopped = false; - timeout = jiffies +HW_DISABLE_TIMEOUT ; -do { - ret =lan78xx_read_reg (dev, reg, &buf); -if (ret <0 ) -return ret; - -if (buf & hw_disabled) - stopped = true; -else -msleep (HW_DISABLE_DELAY_MS ); - }while (!stopped && !time_after (jiffies, timeout)); - } - - ret = stopped ?0 : -ETIME ; - -return ret; -} - -static int lan78xx_flush_fifo (struct lan78xx_net *dev,u32 reg,u32 fifo_flush) -{ -return lan78xx_update_reg (dev, reg, fifo_flush, fifo_flush); -} - -static int lan78xx_start_tx_path (struct lan78xx_net *dev) -{ -int ret; - -netif_dbg (dev, drv, dev->net,"start tx path" ); - -/* Start the MAC transmitter */ - - ret =lan78xx_start_hw (dev,MAC_TX ,MAC_TX_TXEN_ ); -if (ret <0 ) -return ret; - -/* Start the Tx FIFO */ - - ret =lan78xx_start_hw (dev,FCT_TX_CTL ,FCT_TX_CTL_EN_ ); -if (ret <0 ) -return ret; - -return 0 ; -} - -static int lan78xx_stop_tx_path (struct lan78xx_net *dev) -{ -int ret; - -netif_dbg (dev, drv, dev->net,"stop tx path" ); - -/* Stop the Tx FIFO */ - - ret =lan78xx_stop_hw (dev,FCT_TX_CTL ,FCT_TX_CTL_EN_ ,FCT_TX_CTL_DIS_ ); -if (ret <0 ) -return ret; - -/* Stop the MAC transmitter */ - - ret =lan78xx_stop_hw (dev,MAC_TX ,MAC_TX_TXEN_ ,MAC_TX_TXD_ ); -if (ret <0 ) -return ret; - -return 0 ; -} - -/* The caller must ensure the Tx path is stopped before calling -* lan78xx_flush_tx_fifo(). -*/ -static int lan78xx_flush_tx_fifo (struct lan78xx_net *dev) -{ -return lan78xx_flush_fifo (dev,FCT_TX_CTL ,FCT_TX_CTL_RST_ ); -} - -static int lan78xx_start_rx_path (struct lan78xx_net *dev) -{ -int ret; - -netif_dbg (dev, drv, dev->net,"start rx path" ); - -/* Start the Rx FIFO */ - - ret =lan78xx_start_hw (dev,FCT_RX_CTL ,FCT_RX_CTL_EN_ ); -if (ret <0 ) -return ret; - -/* Start the MAC receiver*/ - - ret =lan78xx_start_hw (dev,MAC_RX ,MAC_RX_RXEN_ ); -if (ret <0 ) -return ret; - -return 0 ; -} - -static int lan78xx_stop_rx_path (struct lan78xx_net *dev) -{ -int ret; - -netif_dbg (dev, drv, dev->net,"stop rx path" ); - -/* Stop the MAC receiver */ - - ret =lan78xx_stop_hw (dev,MAC_RX ,MAC_RX_RXEN_ ,MAC_RX_RXD_ ); -if (ret <0 ) -return ret; - -/* Stop the Rx FIFO */ - - ret =lan78xx_stop_hw (dev,FCT_RX_CTL ,FCT_RX_CTL_EN_ ,FCT_RX_CTL_DIS_ ); -if (ret <0 ) -return ret; - -return 0 ; -} - -/* The caller must ensure the Rx path is stopped before calling -* lan78xx_flush_rx_fifo(). -*/ -static int lan78xx_flush_rx_fifo (struct lan78xx_net *dev) -{ -return lan78xx_flush_fifo (dev,FCT_RX_CTL ,FCT_RX_CTL_RST_ ); -} -static int lan78xx_reset (struct lan78xx_net *dev) {struct lan78xx_priv *pdata = (struct lan78xx_priv *)(dev->data[0 ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 658/1067 net/sched: sch_teql: Introduce slaves_lock to avoid race condition and UAF
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit e5b811fe793166aecc59b085c1b7c31262ef2316 ]
The teql master->slaves singly linked list is not protected against multiple writes. It can be mod'ed concurently from teql_master_xmit(), teql_dequeue(), teql_init() and teql_destroy() without holding any list lock or RCU protection.
[email protected] has demonstrated that the qdisc is freed after an RCU grace period, but teql_master_xmit() running on another CPU can still hold a stale pointer into the list, resulting in a slab-use-after-free:
BUG: KASAN: slab-use-after-free in teql_master_xmit+0xf0f/0x16b0 Read of size 8 at addr ffff888013fb0440 by task poc/332
Freed 512-byte region [ffff888013fb0400, ffff888013fb0600) (kmalloc-512)
The fix?
Add a per-master slaves_lock spinlock that serializes all mutations of master->slaves and the NEXT_SLAVE() links in teql_destroy() and teql_qdisc_init(). teql_master_xmit() also takes the same slaves_lock around those updates.
Annotate master->slaves and the per-slave ->next pointer with __rcu and use the appropriate RCU accessors everywhere they are touched:rcu_assign_pointer() on the writer side (under slaves_lock), rcu_dereference_protected() for the writer-side loads (also under slaves_lock), rcu_dereference_bh() for the loads in teql_master_xmit() and rtnl_dereference() for the loads in teql_master_open()/teql_master_mtu(), which run under RTNL.
Pair this with rcu_read_lock_bh()/rcu_read_unlock_bh() around the list traversal in teql_master_xmit(), so that readers either observe a fully linked list or are deferred until the in-flight mutation completes. The two early-return paths in teql_master_xmit() are updated to release the RCU-bh read-side critical section before returning, since leaving it held would disable BH on that CPU for good.
--- net/sched/sch_teql.c | 125 +++++++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 39 deletions(-)
net/sched/sch_teql.c +86 -39
@@ -52,7 +52,8 @@struct teql_master {struct Qdisc_ops qops;struct net_device *dev; -struct Qdisc *slaves; +struct Qdisc __rcu *slaves; +spinlock_t slaves_lock;/* serializes writes to ->slaves */ struct list_head master_list;unsigned long tx_bytes;unsigned long tx_packets;
@@ -61,7 +62,7 @@ struct teql_master { };struct teql_sched_data { -struct Qdisc *next; +struct Qdisc __rcu *next;struct teql_master *m;struct sk_buff_head q; };
@@ -101,7 +102,9 @@ teql_dequeue(struct Qdisc *sch)if (skb ==NULL ) {struct net_device *m =qdisc_dev (q);if (m) { - dat->m->slaves = sch; +spin_lock_bh (&dat->m->slaves_lock); +rcu_assign_pointer (dat->m->slaves, sch); +spin_unlock_bh (&dat->m->slaves_lock);netif_wake_queue (m); } }else {
@@ -132,34 +135,49 @@ teql_destroy(struct Qdisc *sch)struct Qdisc *q, *prev;struct teql_sched_data *dat =qdisc_priv (sch);struct teql_master *master = dat->m; +struct netdev_queue *txq =NULL ; +bool reset_master_queue = false;if (!master)return ; - prev = master->slaves; +spin_lock_bh (&master->slaves_lock); + prev =rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock));if (prev) {do { - q =NEXT_SLAVE (prev); -if (q == sch) { -NEXT_SLAVE (prev) =NEXT_SLAVE (q); -if (q == master->slaves) { - master->slaves =NEXT_SLAVE (q); -if (q == master->slaves) { -struct netdev_queue *txq; - - txq =netdev_get_tx_queue (master->dev,0 ); - master->slaves =NULL ; - -dev_reset_queue (master->dev, - txq,NULL ); - } - } -skb_queue_purge (&dat->q); -break ; +struct Qdisc *head, *next; + + q =rcu_dereference_protected (NEXT_SLAVE (prev), +lockdep_is_held (&master->slaves_lock)); +if (q != sch) { + prev = q; +continue ; } - }while ((prev = q) != master->slaves); + next =rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock)); +rcu_assign_pointer (NEXT_SLAVE (prev), next); + + head =rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)); +if (q == head) { +rcu_assign_pointer (master->slaves, next); +if (q == next) { + txq =netdev_get_tx_queue (master->dev,0 ); +rcu_assign_pointer (master->slaves,NULL ); + reset_master_queue = true; + } + } +skb_queue_purge (&dat->q); +break ; + }while (prev !=rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock))); } +spin_unlock_bh (&master->slaves_lock); + +if (reset_master_queue) +dev_reset_queue (master->dev, txq,NULL ); } static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,
@@ -168,6 +186,7 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,struct net_device *dev =qdisc_dev (sch);struct teql_master *m = (struct teql_master *)sch->ops;struct teql_sched_data *q =qdisc_priv (sch); +struct Qdisc *first;if (dev->hard_header_len > m->dev->hard_header_len)return -EINVAL ;
@@ -184,7 +203,9 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,skb_queue_head_init (&q->q); -if (m->slaves) { +spin_lock_bh (&m->slaves_lock); + first =rcu_dereference_protected (m->slaves,lockdep_is_held (&m->slaves_lock)); +if (first) {if (m->dev->flags &IFF_UP ) { if ((m->dev->flags & IFF_POINTOPOINT && !(dev->flags & IFF_POINTOPOINT)) ||
@@ -192,8 +213,10 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, !(dev->flags & IFF_BROADCAST)) || (m->dev->flags & IFF_MULTICAST && !(dev->flags & IFF_MULTICAST)) || - dev->mtu < m->dev->mtu) + dev->mtu < m->dev->mtu) { +spin_unlock_bh (&m->slaves_lock);return -EINVAL ; + } }else {if (!(dev->flags&IFF_POINTOPOINT )) m->dev->flags &= ~IFF_POINTOPOINT ;
@@ -204,14 +227,17 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,if (dev->mtu < m->dev->mtu) m->dev->mtu = dev->mtu; } - q->next =NEXT_SLAVE (m->slaves); -NEXT_SLAVE (m->slaves) = sch; +rcu_assign_pointer (q->next, +rcu_dereference_protected (NEXT_SLAVE (first), +lockdep_is_held (&m->slaves_lock))); +rcu_assign_pointer (NEXT_SLAVE (first), sch); }else { - q->next = sch; - m->slaves = sch; +rcu_assign_pointer (q->next, sch); +rcu_assign_pointer (m->slaves, sch); m->dev->mtu = dev->mtu; m->dev->flags = (m->dev->flags&~FMASK )|(dev->flags&FMASK ); } +spin_unlock_bh (&m->slaves_lock);return 0 ; }
@@ -285,7 +311,9 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)int subq =skb_get_queue_mapping (skb);struct sk_buff *skb_res =NULL ; - start = master->slaves; +rcu_read_lock_bh (); + + start =rcu_dereference_bh (master->slaves); restart: nores =0 ;
@@ -317,10 +345,17 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) netdev_start_xmit(skb, slave, slave_txq, false) == NETDEV_TX_OK) {__netif_tx_unlock (slave_txq); - master->slaves =NEXT_SLAVE (q); +spin_lock_bh (&master->slaves_lock); +if (rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)) == q) +rcu_assign_pointer (master->slaves, +rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock))); +spin_unlock_bh (&master->slaves_lock);netif_wake_queue (dev); master->tx_packets++; master->tx_bytes += length; +rcu_read_unlock_bh ();return NETDEV_TX_OK ; }__netif_tx_unlock (slave_txq);
@@ -329,14 +364,21 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) busy =1 ;break ;case 1 : - master->slaves =NEXT_SLAVE (q); +spin_lock_bh (&master->slaves_lock); +if (rcu_dereference_protected (master->slaves, +lockdep_is_held (&master->slaves_lock)) == q) +rcu_assign_pointer (master->slaves, +rcu_dereference_protected (NEXT_SLAVE (q), +lockdep_is_held (&master->slaves_lock))); +spin_unlock_bh (&master->slaves_lock); +rcu_read_unlock_bh ();return NETDEV_TX_OK ;default : nores =1 ;break ; }__skb_pull (skb,skb_network_offset (skb)); - }while ((q =NEXT_SLAVE (q)) != start); + }while ((q =rcu_dereference_bh (NEXT_SLAVE (q))) != start);if (nores && skb_res ==NULL ) { skb_res = skb;
@@ -345,29 +387,32 @@ static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)if (busy) {netif_stop_queue (dev); +rcu_read_unlock_bh ();return NETDEV_TX_BUSY ; } master->tx_errors++; drop: master->tx_dropped++; +rcu_read_unlock_bh ();dev_kfree_skb (skb);return NETDEV_TX_OK ; }static int teql_master_open (struct net_device *dev) { -struct Qdisc *q; +struct Qdisc *q, *first;struct teql_master *m =netdev_priv (dev);int mtu =0xFFFE ;unsigned int flags =IFF_NOARP |IFF_MULTICAST ; -if (m->slaves ==NULL ) + first =rtnl_dereference (m->slaves); +if (!first)return -EUNATCH ; flags =FMASK ; - q = m->slaves; + q = first; do { struct net_device *slave = qdisc_dev(q);
@@ -389,7 +434,7 @@ static int teql_master_open(struct net_device *dev) flags &= ~IFF_BROADCAST ;if (!(slave->flags&IFF_MULTICAST )) flags &= ~IFF_MULTICAST ; - }while ((q =NEXT_SLAVE (q)) != m->slaves); + }while ((q =rtnl_dereference (NEXT_SLAVE (q))) != first); m->dev->mtu = mtu; m->dev->flags = (m->dev->flags&~FMASK ) | flags;
@@ -417,14 +462,15 @@ static void teql_master_stats64(struct net_device *dev,static int teql_master_mtu (struct net_device *dev,int new_mtu) {struct teql_master *m =netdev_priv (dev); -struct Qdisc *q; +struct Qdisc *q, *first; - q = m->slaves; + first =rtnl_dereference (m->slaves); + q = first;if (q) {do {if (new_mtu >qdisc_dev (q)->mtu)return -EINVAL ; - }while ((q =NEXT_SLAVE (q)) != m->slaves); + }while ((q =rtnl_dereference (NEXT_SLAVE (q))) != first); } dev->mtu = new_mtu;
@@ -444,6 +490,7 @@ static __init void teql_master_setup(struct net_device *dev)struct teql_master *master =netdev_priv (dev);struct Qdisc_ops *ops = &master->qops; +spin_lock_init (&master->slaves_lock); master->dev = dev; ops->priv_size =sizeof (struct teql_sched_data );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 659/1067 bridge: stp: Fix a potential use-after-free when deleting a bridge
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 2a00517db8de4be7df3d483b215c5544fb30a191 ]
The three STP timers are not supposed to be armed while the bridge is administratively down. They are synchronously deactivated when the bridge is put administratively down and the various call sites check for 'IFF_UP' before arming them.
This check is missing from br_topology_change_detection() and it is possible to engineer a situation in which the topology change timer is armed while the bridge is administratively down, resulting in a use-after-free [1] when the bridge is deleted.
Fix by adding the missing check and for good measures synchronously shutdown the three timers when the bridge is deleted.
[1]
ODEBUG: free active (active state 0) object: ffff88811662b9b0 object type: timer_list hint: br_topology_change_timer_expired (net/bridge/br_stp_timer.c:120)
WARNING: lib/debugobjects.c:629 at debug_print_object+0x1bc/0x450, CPU#9: ip/359
--- net/bridge/br_if.c | 3 +++ net/bridge/br_stp.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
net/bridge/br_if.c +3 -0
@@ -391,6 +391,9 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)br_fdb_delete_by_port (br,NULL ,0 ,1 ); +timer_shutdown_sync (&br->hello_timer); +timer_shutdown_sync (&br->topology_change_timer); +timer_shutdown_sync (&br->tcn_timer);cancel_delayed_work_sync (&br->gc_work);br_sysfs_delbr (br->dev);
net/bridge/br_stp.c +2 -1
@@ -371,7 +371,8 @@ void br_topology_change_detection(struct net_bridge *br) {int isroot =br_is_root_bridge (br); -if (br->stp_enabled !=BR_KERNEL_STP ) +if (br->stp_enabled !=BR_KERNEL_STP || + !(br->dev->flags &IFF_UP ))return ; br_info(br, "topology change detected, %s\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 660/1067 tracing/events: Fix to check the simple_tsk_fn creation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit cda1fbfc5313bb90daa271d45eea4a8d317a8544 ]
Sashiko pointed that this sample code does not correctly handle the failure of thread creation because kthread_run() can return -errno.
Check the simple_tsk_fn is correctly initialized (created) or not.
--- samples/trace_events/trace-events-sample.c | 4 ++++ 1 file changed, 4 insertions(+)
samples/trace_events/trace-events-sample.c +4 -0
@@ -107,6 +107,10 @@ int foo_bar_reg(void)* for consistency sake, we still take the thread_mutex. */ simple_tsk_fn =kthread_run (simple_thread_fn,NULL ,"event-sample-fn" ); +if (IS_ERR_OR_NULL (simple_tsk_fn)) { +pr_err ("Failed to create simple_thread_fn\n" ); + simple_tsk_fn =NULL ; + } out:mutex_unlock (&thread_mutex);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 661/1067 tracing: eprobe: read the complete FILTER_PTR_STRING pointer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaiser <[email protected]>
[ Upstream commit 206b25c09080cc20fd4c2bea12d59df4b7ba2121 ]
For a char * element in an event, the FILTER_PTR_STRING filter type is used. When the event occurs, a pointer is stored in the ringbuffer.
If an eprobe references such a char * element of a "base event", the stored pointer is truncated when it's read from the ringbuffer.
$ cd /sys/kernel/tracing $ echo 'e rcu.rcu_utilization $s:x64 $s:string' > dynamic_events $ echo 1 > tracing_on $ echo 1 > events/eprobes/enable $ sleep 1 $ echo 0 > events/eprobes/enable $ cat trace <idle>-0 ...: (rcu.rcu_utilization) arg1=0x4f arg2=(fault) <idle>-0 ...: (rcu.rcu_utilization) arg1=0x2 arg2=(fault)
The problem is in get_event_field
val = (unsigned long)(*(char *)addr);
addr points to the position in the ringbuffer where the pointer was stored. The assignment reads only the lowest byte of the pointer.
Fix the cast to read the whole pointer. The output of the test above is now
<idle>-0 ... arg1=0xffffffff81c7d3f3 arg2="Start scheduler-tick" <idle>-0 ... arg1=0xffffffff81c57340 arg2="End scheduler-tick"
--- kernel/trace/trace_eprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_eprobe.c +1 -1
@@ -340,7 +340,7 @@ static unsigned long get_event_field(struct fetch_insn *code, void *rec) val = (unsigned long )addr;break ;case FILTER_PTR_STRING : - val = (unsigned long )(*(char *)addr); + val = *(unsigned long *)addr;break ;default :WARN_ON_ONCE (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/1067 irqchip/gic-v3-its: Fix OF node reference leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 2e1368a9d61bdf5502ddade004f223a5831c5b8c ]
of_get_cpu_node() returns a referenced device node. In its_cpu_init_collection(), the Cavium 23144 workaround only uses the node to compare the CPU NUMA node, but the reference is never dropped.
Use the device_node cleanup helper for the CPU node reference so it is released when leaving the workaround block, including the NUMA mismatch return path.
--- drivers/irqchip/irq-gic-v3-its.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +2 -4
@@ -3198,11 +3198,9 @@ static void its_cpu_init_collection(struct its_node *its)/* avoid cross node collections and its mapping */ if (its->flags &ITS_FLAGS_WORKAROUND_CAVIUM_23144 ) { -struct device_node *cpu_node; + struct device_node *cpu_node __free(device_node) = of_get_cpu_node(cpu, NULL); - cpu_node =of_get_cpu_node (cpu,NULL ); -if (its->numa_node !=NUMA_NO_NODE && - its->numa_node !=of_node_to_nid (cpu_node)) +if (its->numa_node !=NUMA_NO_NODE && its->numa_node !=of_node_to_nid (cpu_node))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 653/1067 net: enetc: check the number of BDs needed for xdp_frame
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit 555c5475e787802eeae0d2b91c2f66c330db2767 ]
The size of xdp_redirect_arr array is ENETC_MAX_SKB_FRAGS. However, the number of fragments contained in xdp_frame may be greater than or equal to ENETC_MAX_SKB_FRAGS, which will cause the access to xdp_redirect_arr to be out of bounds.
--- drivers/net/ethernet/freescale/enetc/enetc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc.c +7 -0
@@ -1400,6 +1400,7 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, {struct enetc_tx_swbd xdp_redirect_arr[ENETC_MAX_SKB_FRAGS ] = {0 };struct enetc_ndev_priv *priv =netdev_priv (ndev); +struct skb_shared_info *shinfo;struct enetc_bdr *tx_ring;int xdp_tx_bd_cnt, i, k;int xdp_tx_frm_cnt =0 ;
@@ -1411,6 +1412,12 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,prefetchw (ENETC_TXBD (*tx_ring, tx_ring->next_to_use));for (k =0 ; k < num_frames; k++) { +if (xdp_frame_has_frags (frames[k])) { + shinfo =xdp_get_shared_info_from_frame (frames[k]); +if (unlikely ((shinfo->nr_frags +1 ) >ENETC_MAX_SKB_FRAGS )) +break ; + } + xdp_tx_bd_cnt =enetc_xdp_frame_to_xdp_tx_swbd (tx_ring, xdp_redirect_arr, frames[k]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 700/1067 net/sched: cake: reject overhead values that underflow length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit b7f97cae7ec1b6c3c32843c42be218690d310467 ]
CAKE accepts signed overhead values and stores them in an s16, but the adjusted packet length calculation uses unsigned arithmetic. A negative effective length can therefore wrap to a large value.
Such configurations make rate accounting depend on integer wraparound rather than on the packet size userspace intended to model. A static netlink lower bound is not enough because packets reaching CAKE can be smaller than any reasonable manual-overhead allowance.
Fold the signed overhead adjustment into the existing datapath MPU clamp so negative adjusted lengths are clamped before link-layer framing adjustments.
--- net/sched/sch_cake.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/sched/sch_cake.c +1 -4
@@ -1381,10 +1381,7 @@ static u32 cake_calc_overhead(struct cake_sched_data *q, u32 len, u32 off)if (q->min_netlen > len) q->min_netlen = len; - len += q->rate_overhead; - -if (len < q->rate_mpu) - len = q->rate_mpu; + len =max ((s32 )len + q->rate_overhead, (s32 )q->rate_mpu);if (q->atm_mode ==CAKE_ATM_ATM ) { len +=47 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 709/1067 dm era: fix NULL pointer dereference in metadata_open()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 9ae672606c17891d90b282e3490b817620549599 ]
metadata_open() returns NULL when kzalloc_obj() fails, but the caller era_ctr() only checks IS_ERR(md). Since IS_ERR(NULL) returns false, the NULL pointer is treated as a valid result and later assigned to era->md, leading to a NULL pointer dereference when the metadata is accessed.
Fix this by returning ERR_PTR(-ENOMEM) on allocation failure, consistent with dm-cache-metadata.c, dm-thin-metadata.c, and dm-clone-metadata.c which all use ERR_PTR(-ENOMEM) for the same pattern.
--- drivers/md/dm-era-target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-era-target.c +4 -2
@@ -795,8 +795,10 @@ static struct era_metadata *metadata_open(struct block_device *bdev,int r;struct era_metadata *md =kzalloc (sizeof (*md),GFP_KERNEL ); -if (!md) -return NULL ; +if (!md) { +DMERR ("could not allocate metadata struct" ); +return ERR_PTR (-ENOMEM ); + } md->bdev = bdev; md->block_size = block_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 710/1067 regulator: core: Make regulator_lock_two() logic easier to follow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit 37473397b852f556d8b9428ccbfd51886037842d ]
The regulator_lock_two() function could be made clearer in the case of lock contention by having a local variable for each of the held and contended locks. Let's do that. At the same time, let's use the swap() function instead of open coding it.
This change is expected to be a no-op and simply improves code clarity.
Stable-dep-of: d38f8bd771c4 ("regulator: core: regulator_lock_two() should test for EDEADLK not EDEADLOCK")
--- drivers/regulator/core.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/regulator/core.c +12 -19
@@ -219,7 +219,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1,struct regulator_dev *rdev2, struct ww_acquire_ctx *ww_ctx) { - struct regulator_dev *tmp; + struct regulator_dev *held, *contended;int ret;ww_acquire_init (ww_ctx, ®ulator_ww_class);
@@ -233,25 +233,18 @@ static void regulator_lock_two(struct regulator_dev *rdev1, goto exit; } + held = rdev1; + contended = rdev2;while (true) { -/* -* Start of loop: rdev1 was locked and rdev2 was contended. -* Need to unlock rdev1, slowly lock rdev2, then try rdev1 -* again. -*/ -regulator_unlock (rdev1); - -ww_mutex_lock_slow (&rdev2->mutex, ww_ctx); - rdev2->ref_cnt++; - rdev2->mutex_owner = current; - ret =regulator_lock_nested (rdev1, ww_ctx); - -if (ret == -EDEADLOCK ) { -/* More contention; swap which needs to be slow */ - tmp = rdev1; - rdev1 = rdev2; - rdev2 = tmp; - }else { +regulator_unlock (held); + +ww_mutex_lock_slow (&contended->mutex, ww_ctx); + contended->ref_cnt++; + contended->mutex_owner = current; +swap (held, contended); + ret =regulator_lock_nested (contended, ww_ctx); + +if (ret != -EDEADLOCK ) {WARN_ON (ret);break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 711/1067 regulator: core: regulator_lock_two() should test for EDEADLK not EDEADLOCK
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Tabi <[email protected]>
[ Upstream commit d38f8bd771c4999b797d7074b348cf201414bd34 ]
Compare against -EDEADLK, which is what ww_mutex_lock() actually returns and what every other deadlock check in this file already uses.
Function regulator_lock_two() acquires two regulators via regulator_lock_nested() -> ww_mutex_lock(). On contention, ww_mutex_lock() returns -EDEADLK, which is the caller's signal to drop the lock it holds and retry the acquisition in the canonical order.
However, regulator_lock_two() tests the return value against -EDEADLOCK rather than -EDEADLK. On most architectures, EDEADLK and EDEADLOCK are the same value, so the comparison happens to be correct and the bug is invisible. But on MIPS, SPARC, and PowerPC, those two errors have different values. The test is wrong: a genuine -EDEADLK backoff no longer matches -EDEADLOCK, so instead of unlocking and retrying, the code falls into WARN_ON(ret) and returns with only one of the two regulators locked.
In practice, this is a bug only on MIPS, because the regulator core is not built or used on the other two platforms.
In general, EDEADLK is preferred over EDEADLOCK for new code.
--- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
@@ -228,7 +228,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1, ret =regulator_lock_nested (rdev1, ww_ctx);WARN_ON (ret); ret =regulator_lock_nested (rdev2, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret); goto exit; }
@@ -244,7 +244,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1,swap (held, contended); ret =regulator_lock_nested (contended, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret);break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 712/1067 net/mlx5: Fix L3 tunnel entropy refcount leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit c914307e1d41c2cb7bcdcbfde4cd2f214f6aa027 ]
mlx5_tun_entropy_refcount_inc() counts both VXLAN and L2-to-L3 tunnel reformat entries as entropy-enabling users. The matching decrement path only handled VXLAN, leaving L2-to-L3 tunnel entries counted after release.
Handle MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL in mlx5_tun_entropy_refcount_dec() as well so the enabling entry refcount remains balanced.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c +2 -1
@@ -176,7 +176,8 @@ void mlx5_tun_entropy_refcount_dec(struct mlx5_tun_entropy *tun_entropy, int reformat_type) {mutex_lock (&tun_entropy->lock); -if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN ) +if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN || + reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL ) tun_entropy->num_enabling_entries--;else if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_NVGRE && --tun_entropy->num_disabling_entries ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 713/1067 octeontx2-af: fix VF bringup affecting PF promiscuous state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harman Kalra <[email protected]>
[ Upstream commit fabb881df322da25442f98d23f5fa371e3c78ec4 ]
Mbox handling of nix_set_rx_mode for a VF with promiscuous and all_multi flags set to false causes deletion of the PF's promiscuous and allmulti MCAM rules. This occurs because the APIs that enable/disable these rules operate only on the PF, even when the mbox request is made via a VF interface.
Guard both rvu_npc_enable_allmulti_entry() and rvu_npc_enable_promisc_entry() disable paths with an is_vf() check so that a VF bringing up or tearing down its interface cannot inadvertently clear the PF's MCAM rules.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 -2
@@ -4084,7 +4084,7 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,rvu_npc_install_allmulti_entry (rvu, pcifunc, nixlf, pfvf->rx_chan_base); }else { -if (!nix_rx_multicast) +if (!nix_rx_multicast && !is_vf (pcifunc))rvu_npc_enable_allmulti_entry (rvu, pcifunc, nixlf, false); }
@@ -4094,7 +4094,7 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req, pfvf->rx_chan_base, pfvf->rx_chan_cnt); else - if (!nix_rx_multicast) + if (!nix_rx_multicast && !is_vf(pcifunc))rvu_npc_enable_promisc_entry (rvu, pcifunc, nixlf, false);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 714/1067 smb: client: fix overflow in passthrough ioctl bounds check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a4f27ad055392fa164f5649e89a3637b033c5fcc ]
smb2_ioctl_query_info() validates the PASSTHRU_FSCTL response payload before copying it to userspace.
The payload offset and length both come from 32-bit fields. The bounds check currently adds OutputOffset and qi.input_buffer_length directly, so the addition can wrap in 32-bit arithmetic before the result is compared against the response buffer length.
A malicious server can use a large OutputOffset and a small OutputCount to make the wrapped sum pass the bounds check. The later copy_to_user() then reads from io_rsp + OutputOffset, outside the response buffer.
Use size_add() for the offset plus length check so overflow is treated as out of bounds.
--- fs/smb/client/smb2ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +2 -2
@@ -1690,8 +1690,8 @@ smb2_ioctl_query_info(const unsigned int xid,if (le32_to_cpu (io_rsp->OutputCount) < qi.input_buffer_length) qi.input_buffer_length =le32_to_cpu (io_rsp->OutputCount);if (qi.input_buffer_length >0 && -le32_to_cpu (io_rsp->OutputOffset) + qi.input_buffer_length - > rsp_iov[1 ].iov_len) { +size_add (le32_to_cpu (io_rsp->OutputOffset), + qi.input_buffer_length) > rsp_iov[1 ].iov_len) { rc = -EFAULT ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 715/1067 mlxsw: fix refcount leak in mlxsw_sp_vrs_lpm_tree_replace()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 21cf8dc478a49e8de039c2739b1646a774cb1944 upstream.
When mlxsw_sp_vrs_lpm_tree_replace() fails after replacing some VRs, the error rollback loop does not correctly revert the preceding replacements. The loop decrements the index but fails to update the vr pointer, which still points to the VR that caused the failure. As a result, the condition and the rollback call always operate on the same VR, potentially calling mlxsw_sp_vr_lpm_tree_replace() multiple times on it while never rolling back the earlier VRs. Those VRs continue to hold a reference to new_tree acquired via mlxsw_sp_lpm_tree_hold(), leaking the reference count of new_tree.
Fix by reinitializing vr inside the error loop with the updated index:
vr = &mlxsw_sp->router->vrs[i];
so that the loop correctly iterates over all VRs that were actually replaced.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -0
@@ -986,6 +986,7 @@ static int mlxsw_sp_vrs_lpm_tree_replace err_tree_replace:for (i--; i >=0 ; i--) { + vr = &mlxsw_sp->router->vrs[i];if (!mlxsw_sp_vr_lpm_tree_should_replace (vr, proto, new_id))continue ; mlxsw_sp_vr_lpm_tree_replace(mlxsw_sp,
Greg Kroah-Hartman
maintainerPATCH 716/1067 vduse: Fix race in vduse_dev_msg_sync and vduse_dev_read_iter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Tianci <[email protected]>
commit ae9c13b6fd79087cc5a216ee1649b6f012c2a238 upstream.
There is one race case in vduse_dev_msg_sync and vduse_dev_read_iter:
vduse_dev_read_iter():
lock(msg_lock);
dequeue_msg(send_list);
unlock(msg_lock);
vduse_dev_msg_sync():
wait_timeout() finish
lock(msg_lock);
check msg->complete is false
list_del(msg); <- double list_del() crash!To fix this case, we shall ensure vduse_msg is on send_list or recv_list outside the msg_lock critical section.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +27 -10
@@ -319,6 +319,7 @@ static ssize_t vduse_dev_read_iter(strucstruct file *file = iocb->ki_filp;struct vduse_dev *dev = file->private_data;struct vduse_dev_msg *msg; +struct vduse_dev_request req;int size =sizeof (struct vduse_dev_request );ssize_t ret;
@@ -330,12 +331,11 @@ static ssize_t vduse_dev_read_iter(struc msg =vduse_dequeue_msg (&dev->send_list);if (msg)break ; +spin_unlock (&dev->msg_lock); - ret = -EAGAIN ;if (file->f_flags &O_NONBLOCK ) - goto unlock; +return -EAGAIN ; -spin_unlock (&dev->msg_lock); ret =wait_event_interruptible_exclusive (dev->waitq, !list_empty (&dev->send_list));if (ret)
@@ -343,17 +343,34 @@ static ssize_t vduse_dev_read_iter(strucspin_lock (&dev->msg_lock); } + +memcpy (&req, &msg->req,sizeof (req)); +/* +* We must ensure vduse_msg is on send_list or recv_list before unlock +* dev->msg_lock. Because vduse_dev_msg_sync() may be timeout when we +* copy data to userspace, and will call list_del() for this msg. +*/ +vduse_enqueue_msg (&dev->recv_list, msg);spin_unlock (&dev->msg_lock); - ret =copy_to_iter (&msg->req, size, to); -spin_lock (&dev->msg_lock); + + ret =copy_to_iter (&req, size, to);if (ret != size) { +/* +* Roll back: move msg back to send_list if still pending. +* +* NOTE: +* vduse_find_msg() must use req.request_id instead of `msg`. +* A malicious userspace may reply to this request, and wake up +* the caller, after which `msg` will have already been freed. +* And here vduse_find_msg() will return NULL then do nothing. +*/ +spin_lock (&dev->msg_lock); + msg =vduse_find_msg (&dev->recv_list, req.request_id); +if (msg) +vduse_enqueue_msg_head (&dev->send_list, msg); +spin_unlock (&dev->msg_lock); ret = -EFAULT ; -vduse_enqueue_msg_head (&dev->send_list, msg); - goto unlock; } -vduse_enqueue_msg (&dev->recv_list, msg); -unlock: -spin_unlock (&dev->msg_lock);return ret; }
Greg Kroah-Hartman
maintainerPATCH 717/1067 ASoC: SOF: ipc3-control: Use overflow checks in control_update size calc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 8791977d7289f6e9d2b014f60a5455f053a7bc04 upstream.
In sof_ipc3_control_update(), the expected_size calculation uses firmware-provided cdata->num_elems in arithmetic that could overflow on 32-bit platforms, wrapping to a small value. This would allow the cdata->rhdr.hdr.size comparison to pass with mismatched sizes, potentially leading to out-of-bounds access in snd_sof_update_control.
Use check_mul_overflow() and check_add_overflow() to detect and reject overflowed size calculations.
--- sound/soc/sof/ipc3-control.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
sound/soc/sof/ipc3-control.c +16 -4
@@ -604,16 +604,28 @@ static void sof_ipc3_control_update(strureturn ; } - expected_size =sizeof (struct sof_ipc_ctrl_data );switch (cdata->type) {case SOF_CTRL_TYPE_VALUE_CHAN_GET :case SOF_CTRL_TYPE_VALUE_CHAN_SET : - expected_size += cdata->num_elems * -sizeof (struct sof_ipc_ctrl_value_chan ); +if (check_mul_overflow ((size_t )cdata->num_elems, +sizeof (struct sof_ipc_ctrl_value_chan ), + &expected_size)) +return ; +if (check_add_overflow (expected_size, +sizeof (struct sof_ipc_ctrl_data ), + &expected_size)) +return ;break ;case SOF_CTRL_TYPE_DATA_GET :case SOF_CTRL_TYPE_DATA_SET : - expected_size += cdata->num_elems +sizeof (struct sof_abi_hdr ); +if (check_add_overflow ((size_t )cdata->num_elems, +sizeof (struct sof_abi_hdr ), + &expected_size)) +return ; +if (check_add_overflow (expected_size, +sizeof (struct sof_ipc_ctrl_data ), + &expected_size)) +return ;break ;default :return ;
Greg Kroah-Hartman
maintainerPATCH 718/1067 ASoC: SOF: ipc3-control: Fix TOCTOU in bytes_put and bytes_get
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 1f97760417b5faa60e9642fd0ed61eb17d0b1b39 upstream.
In sof_ipc3_bytes_put(), the size used for the memcpy is derived from the old data->size already in the buffer, not the incoming new data's size field. If the new data has a different size, the copy length is
wrong: it may truncate valid data or copy stale bytes.
Similarly, sof_ipc3_bytes_get() checks data->size against max_size without accounting for the sizeof(struct sof_ipc_ctrl_data) offset of the flex array within the allocation.
Fix bytes_put to validate and use the incoming data's sof_abi_hdr.size from ucontrol before copying. Fix bytes_get to subtract sizeof(*cdata) from the bounds check to match the actual available space.
--- sound/soc/sof/ipc3-control.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
sound/soc/sof/ipc3-control.c +16 -7
@@ -281,10 +281,13 @@ static int sof_ipc3_bytes_get(struct snd }/* be->max has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (data->size > scontrol->max_size -sizeof (*data)) { +if (data->size > scontrol->max_size -sizeof (*cdata) - +sizeof (*data)) {dev_err_ratelimited (scomp->dev,"%u bytes of control data is invalid, max is %zu\n" , - data->size, scontrol->max_size -sizeof (*data)); + data->size, + scontrol->max_size -sizeof (*cdata) - +sizeof (*data));return -EINVAL ; }
@@ -302,6 +305,8 @@ static int sof_ipc3_bytes_put(struct sndstruct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;struct snd_soc_component *scomp = scontrol->scomp;struct sof_abi_hdr *data = cdata->data; +const struct sof_abi_hdr *new_hdr = + (const struct sof_abi_hdr *)ucontrol->value.bytes.data;size_t size;if (scontrol->max_size >sizeof (ucontrol->value.bytes.data)) {
@@ -310,14 +315,18 @@ static int sof_ipc3_bytes_put(struct sndreturn -EINVAL ; } -/* scontrol->max_size has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (data->size > scontrol->max_size -sizeof (*data)) { -dev_err_ratelimited (scomp->dev,"data size too big %u bytes max is %zu\n" , - data->size, scontrol->max_size -sizeof (*data)); +/* Validate the new data's size, not the old one */ +if (new_hdr->size > scontrol->max_size -sizeof (*cdata) - +sizeof (*new_hdr)) { +dev_err_ratelimited (scomp->dev, +"data size too big %u bytes max is %zu\n" , + new_hdr->size, + scontrol->max_size -sizeof (*cdata) - +sizeof (*new_hdr));return -EINVAL ; } - size = data->size +sizeof (*data); + size = new_hdr->size +sizeof (*new_hdr);/* copy from kcontrol */ memcpy (data, ucontrol->value.bytes.data, size);
Greg Kroah-Hartman
maintainerPATCH 701/1067 octeontx2-pf: check DMAC extraction support before filtering
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit 235acadd310533ba386ae61ad155b72bee381559 ]
Currently, configuring a VF MAC address via the PF (e.g., 'ip link set <pf> vf 0 mac <mac>') blindly attempts to install a DMAC-based hardware filter. However, the hardware parser profile might not support DMAC extraction.
Check if the hardware parsing profile supports DMAC extraction before adding the filter. Additionally, emit a warning message to inform the operator if the MAC filter installation fails due to missing DMAC extraction support. Update config->mac only after hardware programming succeeds in otx2_set_vf_mac().
--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +37 -6
@@ -2296,10 +2296,42 @@ EXPORT_SYMBOL(otx2_ioctl);static int otx2_do_set_vf_mac (struct otx2_nic *pf,int vf,const u8 *mac) { +struct npc_get_field_status_req *freq; +struct npc_get_field_status_rsp *frsp;struct npc_install_flow_req *req;int err;mutex_lock (&pf->mbox.lock); + +/* Skip installing the DMAC filter if the hardware parser profile +* does not support DMAC extraction. +*/ + freq =otx2_mbox_alloc_msg_npc_get_field_status (&pf->mbox); +if (!freq) { + err = -ENOMEM ; + goto out; + } + + freq->field =NPC_DMAC ; + err =otx2_sync_mbox_msg (&pf->mbox); +if (err) + goto out; + + frsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp + (&pf->mbox.mbox,0 , &freq->hdr); +if (IS_ERR (frsp)) { + err =PTR_ERR (frsp); + goto out; + } + +if (!frsp->enable) { +netdev_warn (pf->netdev, +"VF %d MAC filter not installed: DMAC extraction not supported by parser profile\n" , + vf); + err = -EOPNOTSUPP ; + goto out; + } + req =otx2_mbox_alloc_msg_npc_install_flow (&pf->mbox);if (!req) { err = -ENOMEM ;
@@ -2338,13 +2370,12 @@ static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)if (!is_valid_ether_addr (mac))return -EINVAL ; - config = &pf->vf_configs[vf]; -ether_addr_copy (config->mac, mac); - ret =otx2_do_set_vf_mac (pf, vf, mac); -if (ret ==0 ) -dev_info (&pdev->dev, -"Load/Reload VF driver\n" ); +if (ret ==0 ) { + config = &pf->vf_configs[vf]; +ether_addr_copy (config->mac, mac); +dev_info (&pdev->dev,"Load/Reload VF driver\n" ); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 719/1067 net: qrtr: fix 32-bit integer overflow in qrtr_endpoint_post()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 20054869770c7df060c5ecee3e8bbf9029c47191 upstream.
qrtr_endpoint_post() validates an incoming packet with
if (!size || len != ALIGN(size, 4) + hdrlen) goto err;
where size comes from the wire. On 32-bit, size_t is 32 bits and ALIGN(size, 4) wraps to 0 for size >= 0xfffffffd, so the check passes and skb_put_data(skb, data + hdrlen, size) writes past the hdrlen-sized skb and oopses the kernel. 64-bit is unaffected.
This is the 32-bit residual of ad9d24c9429e2 ("net: qrtr: fix OOB Read in qrtr_endpoint_post"), which fixed only the 64-bit case.
Reject any size that cannot fit the buffer before the ALIGN.
--- net/qrtr/af_qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/qrtr/af_qrtr.c +1 -1
@@ -491,7 +491,7 @@ int qrtr_endpoint_post(struct qrtr_endpo goto err; } -if (!size || len !=ALIGN (size,4 ) + hdrlen) +if (!size || size > len || len !=ALIGN (size,4 ) + hdrlen) goto err; if ((cb->type == QRTR_TYPE_NEW_SERVER ||
Greg Kroah-Hartman
maintainerPATCH 720/1067 net: atm: reject out-of-range traffic classes in QoS validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
commit cdf19f380e46192e7084be559638aab1f6ed86a2 upstream.
Reject ATM traffic classes above ATM_ANYCLASS in check_tp(). SO_ATMQOS stores the supplied QoS after check_qos() succeeds, so accepting larger values leaves invalid traffic_class values in vcc->qos.
That bad state later reaches pvc_info(), which indexes class_name[] with vcc->qos.{rx,tp}.traffic_class. Values above ATM_ANYCLASS cause an out-of-bounds read when /proc/net/atm/pvc is read.
Tighten the existing QoS validation so invalid traffic_class values are rejected at the point where user supplied QoS is accepted.
--- net/atm/common.c | 2 ++ 1 file changed, 2 insertions(+)
net/atm/common.c +2 -0
@@ -720,6 +720,8 @@ static int atm_change_qos(struct atm_vccstatic int check_tp (const struct atm_trafprm *tp) {/* @@@ Should be merged with adjust_tp */ +if (tp->traffic_class >ATM_ANYCLASS ) +return -EINVAL ;if (!tp->traffic_class || tp->traffic_class ==ATM_ANYCLASS )return 0 ; if (tp->traffic_class != ATM_UBR && !tp->min_pcr && !tp->pcr &&
Greg Kroah-Hartman
maintainerPATCH 721/1067 net: ife: require ETH_HLEN to be pullable in ife_decode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yong Wang <[email protected]>
commit 9406f6012b7343661efb516a11c62d4db2b62f75 upstream.
ife decode may return after making only the outer IFE header and metadata pullable. The caller then passes the decapsulated packet to eth_type_trans(), which expects the inner Ethernet header to be accessible from the linear data area.
With a malformed IFE frame, the inner Ethernet header may still be shorter than ETH_HLEN in the linear area, which can lead to a crash in the original code.
Fix this by extending the pull check in ife_decode() so that the inner Ethernet header is also guaranteed to be pullable before returning.
--- net/ife/ife.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ife/ife.c +1 -1
@@ -79,7 +79,7 @@ void *ife_decode(struct sk_buff *skb, u1if (unlikely (ifehdrln <2 ))return NULL ; -if (unlikely (!pskb_may_pull (skb, total_pull))) +if (unlikely (!pskb_may_pull (skb, total_pull +ETH_HLEN )))return NULL ; ifehdr = (struct ifeheadr *)(skb->data + skb->dev->hard_header_len);
Greg Kroah-Hartman
maintainerPATCH 722/1067 arm64: fpsimd: Fix type mismatch in sve_{save,load}_state()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit ae24f6b06e90681ec36b9c21c3f5c09618350f5a upstream.
The sve_save_state() and sve_load_state() functions take a 32-bit int argument that describes whether to save/restore the FFR. Their assembly implementations consume the entire 64-bit register containing this 32-bit value, and will attempt to save/restore the FFR if any bit of that 64-bit register is non-zero.
Per the AAPCS64 parameter passing rules, the callee is responsible for any necessary widening, and the upper 32-bits are permitted to contain arbitrary values. If the upper 32 bits are non-zero, this could result in an unexpected attempt to save/restore the FFR, and consequently could lead to unexpected traps/undefs/faults.
In practice compilers are very unlikely to generate code where the upper 32-bits would be non-zero, but they are permitted to do so.
Fix this by only consuming the low 32 bits of the register, and update comments accordingly.
The hyp code __sve_save_state() and __sve_restore_state() functions don't have the same latent bug as they override the full 64-bit register containing the argument.
--- arch/arm64/kernel/entry-fpsimd.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kernel/entry-fpsimd.S +4 -4
@@ -38,10 +38,10 @@ SYM_FUNC_END(fpsimd_load_state) * * x0 - pointer to buffer for state * x1 - pointer to storage for FPSR - * x2 - Save FFR if non-zero + * w2 - Save FFR if non-zero */ SYM_FUNC_START(sve_save_state) - sve_save 0, x1, x2, 3 + sve_save 0, x1, w2, 3 ret SYM_FUNC_END(sve_save_state)
@@ -50,10 +50,10 @@ SYM_FUNC_END(sve_save_state) * * x0 - pointer to buffer for state * x1 - pointer to storage for FPSR - * x2 - Restore FFR if non-zero + * w2 - Restore FFR if non-zero */ SYM_FUNC_START(sve_load_state) - sve_load 0, x1, x2, 4 + sve_load 0, x1, w2, 4 ret SYM_FUNC_END(sve_load_state)
Greg Kroah-Hartman
maintainerPATCH 723/1067 arm64: dts: qcom: sdm630: describe adsp_mem region properly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolay Goppen <[email protected]>
commit ce414263e9ebe5080381a50cbdf9065c29816202 upstream.
Downstream [1] this region is marked as shared, reusable and dynamic so describe it that way.
--- arch/arm64/boot/dts/qcom/sdm630.dtsi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/qcom/sdm630.dtsi +6 -3
@@ -402,9 +402,12 @@ no-map; }; - adsp_mem: adsp-region@f6000000 { - reg = <0x0 0xf6000000 0x0 0x800000>; - no-map; + adsp_mem: adsp-region { + compatible = "shared-dma-pool"; + alloc-ranges = <0x0 0x80000000 0x0 0x80000000>; + alignment = <0x0 0x400000>; + size = <0x0 0x800000>; + reusable; }; qseecom_mem: qseecom-region@f6800000 {
Greg Kroah-Hartman
maintainerPATCH 724/1067 KVM: s390: pci: Fix GISC refcount leak on AIF enable failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 7b69729046a4c58f4cb457184e5ac4aaa179bff4 upstream.
kvm_s390_gisc_register() registers the guest ISC before pinning the guest interrupt forwarding pages and allocating the AISB bit. If any of the later setup steps fails, the function unwinds the pinned pages and other local state, but does not unregister the GISC reference. Add the missing kvm_s390_gisc_unregister() to the error unwind path.
Message-ID: <[email protected]>
--- arch/s390/kvm/pci.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kvm/pci.c +1 -0
@@ -330,6 +330,7 @@ unpin2: unpin1:unpin_user_page (aibv_page); out: +kvm_s390_gisc_unregister (kvm, fib->fmt0.isc);return rc; }
Greg Kroah-Hartman
maintainerPATCH 725/1067 KVM: arm64: vgic: Check the interrupt is still ours before migrating it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
commit 0074b82cdfcb5fd13710a0ac308ade68ac6f6fbe upstream.
vgic_prune_ap_list() drops both ap_list_lock and irq_lock while migrating an interrupt to another vCPU. After reacquiring the locks it only checks that the affinity is unchanged (target_vcpu == vgic_target_oracle(irq)) before moving the interrupt, which assumes that an interrupt whose affinity is preserved is still queued on this vCPU's ap_list.
That assumption no longer holds if the interrupt is taken off the ap_list while the locks are dropped. vgic_flush_pending_lpis() removes the interrupt from the list and sets irq->vcpu to NULL, but leaves enabled/pending/target_vcpu untouched. As the interrupt is still enabled and pending, vgic_target_oracle() returns the same target_vcpu, so the affinity check passes and list_del() is run a second time on an entry that has already been removed.
Also check that the interrupt is still assigned to this vCPU (irq->vcpu == vcpu) before moving it.
--- arch/arm64/kvm/vgic/vgic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm64/kvm/vgic/vgic.c +6 -5
@@ -686,15 +686,16 @@ retry:raw_spin_lock (&irq->irq_lock);/* -* If the affinity has been preserved, move the -* interrupt around. Otherwise, it means things have -* changed while the interrupt was unlocked, and we -* need to replay this. +* If the interrupt is still ours and its affinity has +* been preserved, move it around. Otherwise, it means +* things have changed while the interrupt was unlocked +* (it may even have been taken off the list with its +* affinity left untouched), and we need to replay this. * * In all cases, we cannot trust the list not to have * changed, so we restart from the beginning. */ -if (target_vcpu ==vgic_target_oracle (irq)) { +if (irq->vcpu == vcpu && target_vcpu ==vgic_target_oracle (irq)) {struct vgic_cpu *new_cpu = &target_vcpu->arch.vgic_cpu;list_del (&irq->ap_list);
Greg Kroah-Hartman
maintainerPATCH 726/1067 KVM: s390: pci: Fix handling of AIF enable without AISB
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Rosato <[email protected]>
commit 3e3aa6da87d30a0064a17b836685cd43c90a3572 upstream.
When a guest seeks to register IRQs without a summary bit specified, ensure that the associated GAITE then stores 0 for the guest AISB location instead of virt_to_phys(page_address(NULL)).
--- arch/s390/kvm/pci.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/s390/kvm/pci.c +8 -3
@@ -302,9 +302,14 @@ static int kvm_s390_pci_aif_enable(struc gaite->gisc = fib->fmt0.isc; gaite->count++; - gaite->aisbo = fib->fmt0.aisbo; - gaite->aisb =virt_to_phys (page_address (aisb_page) + (fib->fmt0.aisb & - ~PAGE_MASK )); +if (fib->fmt0.sum ==1 ) { + gaite->aisbo = fib->fmt0.aisbo; + gaite->aisb =virt_to_phys (page_address (aisb_page) + + (fib->fmt0.aisb & ~PAGE_MASK )); + }else { + gaite->aisbo =0 ; + gaite->aisb =0 ; + } aift->kzdev[zdev->aisb] = zdev->kzdev;spin_unlock_irq (&aift->gait_lock);
Greg Kroah-Hartman
maintainerPATCH 727/1067 KVM: x86: Ignore pending PV EOI if the vCPU has since disabled PV EOIs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 9285e4070df2c40585c3d7ec9571faa7a2b97e17 upstream.
Ignore KVM's internal "service pending PV EOI" request if the vCPU has disabled PV EOIs since the request was made. Asserting that PV EOIs are enabled can fail if reading guest memory in pv_eoi_get_user() fails, i.e. if pv_eoi_test_and_clr_pending() bails early, *and* the vCPU also disables PV EOIs.
kernel BUG at arch/x86/kvm/lapic.c:3338!
Oops: invalid opcode: 0000 [#1] SMP CPU: 4 UID: 1000 PID: 890 Comm: pv_eoi_test Not tainted 7.0.0-d585aa5894d8-vm #337 PREEMPT Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:kvm_lapic_sync_from_vapic+0x12b/0x140 [kvm] Call Trace: <TASK> kvm_arch_vcpu_ioctl_run+0x1075/0x1c30 [kvm] kvm_vcpu_ioctl+0x2d5/0x980 [kvm] __x64_sys_ioctl+0x8a/0xd0 do_syscall_64+0xb5/0xb40 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK> Modules linked in: kvm_intel kvm irqbypass ---[ end trace 0000000000000000 ]---
--- arch/x86/kvm/lapic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kvm/lapic.c +6 -2
@@ -2913,6 +2913,12 @@ static void apic_sync_pv_eoi_from_guest( struct kvm_lapic *apic) {int vector; + +if (unlikely (!pv_eoi_enabled (vcpu))) { +__clear_bit (KVM_APIC_PV_EOI_PENDING , &vcpu->arch.apic_attention); +return ; + } +/* * PV EOI state is derived from KVM_APIC_PV_EOI_PENDING in host * and KVM_PV_EOI_ENABLED in guest memory as follows:
@@ -2924,8 +2930,6 @@ static void apic_sync_pv_eoi_from_guest(* KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is unset: * -> host enabled PV EOI, guest executed EOI. */ -BUG_ON (!pv_eoi_enabled (vcpu)); -if (pv_eoi_test_and_clr_pending (vcpu))return ; vector =apic_set_eoi (apic);
Greg Kroah-Hartman
maintainerPATCH 728/1067 fbdev: metronomefb: fix potential memory leak in metronomefb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 894632b862a39b3fe1cb5de06fbae86225ea64de upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/metronomefb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/metronomefb.c +6 -2
@@ -703,12 +703,14 @@ static int metronomefb_probe(struct plat info->flags =FBINFO_FLAG_DEFAULT |FBINFO_VIRTFB ; info->fbdefio = &metronomefb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_free_irq; retval =fb_alloc_cmap (&info->cmap,8 ,0 );if (retval <0 ) {dev_err (&dev->dev,"Failed to allocate colormap\n" ); - goto err_free_irq; + goto err_fbdefio; }/* set cmap */
@@ -731,6 +733,8 @@ static int metronomefb_probe(struct plat err_cmap:fb_dealloc_cmap (&info->cmap); +err_fbdefio: +fb_deferred_io_cleanup (info); err_free_irq: board->cleanup (par); err_csum_table:
Greg Kroah-Hartman
maintainerPATCH 702/1067 ipv6: mcast: Replace locking comments with lockdep annotations.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 818ae1a5ecb41d82ad180a99c39111f051894d90 ]
Commit 63ed8de4be81 ("mld: add mc_lock for protecting per-interface mld data") added the same comments regarding locking to many functions.
Let's replace the comments with lockdep annotation, which is more helpful.
Note that we just remove the comment for mld_clear_zeros() and mld_send_cr(), where mc_dereference() is used in the entry of the function.
While at it, a comment for __ipv6_sock_mc_join() is moved back to the correct place.
Stable-dep-of: 9b26518b6896 ("ipv6: mcast: Fix potential UAF in MLD delayed work")
--- net/ipv6/mcast.c | 125 +++++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 54 deletions(-)
net/ipv6/mcast.c +71 -54
@@ -105,9 +105,9 @@ static int __ipv6_dev_mc_inc(struct net_device *dev,int sysctl_mld_max_msf__read_mostly =IPV6_MLD_MAX_MSF ;int sysctl_mld_qrv__read_mostly =MLD_QRV_DEFAULT ; -/* -* socket join on multicast group -*/ +#define mc_assert_locked (idev) \ + lockdep_assert_held(&(idev)->mc_lock) +#define mc_dereference (e, idev) \ rcu_dereference_protected(e, lockdep_is_held(&(idev)->mc_lock))
@@ -166,6 +166,9 @@ static int unsolicited_report_interval(struct inet6_dev *idev)return iv >0 ? iv :1 ; } +/* +* socket join on multicast group +*/ static int __ipv6_sock_mc_join (struct sock *sk,int ifindex,const struct in6_addr *addr,unsigned int mode) {
@@ -664,12 +667,13 @@ bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,return rv; } -/* called with mc_lock */ static void igmp6_group_added (struct ifmcaddr6 *mc) {struct net_device *dev = mc->idev->dev;char buf[MAX_ADDR_LEN ]; +mc_assert_locked (mc->idev); +if (IPV6_ADDR_MC_SCOPE (&mc->mca_addr) <IPV6_ADDR_SCOPE_LINKLOCAL )return ;
@@ -699,12 +703,13 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)mld_ifc_event (mc->idev); } -/* called with mc_lock */ static void igmp6_group_dropped (struct ifmcaddr6 *mc) {struct net_device *dev = mc->idev->dev;char buf[MAX_ADDR_LEN ]; +mc_assert_locked (mc->idev); +if (IPV6_ADDR_MC_SCOPE (&mc->mca_addr) <IPV6_ADDR_SCOPE_LINKLOCAL )return ;
@@ -725,14 +730,13 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)refcount_dec (&mc->mca_refcnt); } -/* -* deleted ifmcaddr6 manipulation -* called with mc_lock -*/ +/* deleted ifmcaddr6 manipulation */ static void mld_add_delrec (struct inet6_dev *idev,struct ifmcaddr6 *im) {struct ifmcaddr6 *pmc; +mc_assert_locked (idev); +/* this is an "ifmcaddr6" for convenience; only the fields below * are actually used. In particular, the refcnt and users are not * used for management of the delete list. Using the same structure
@@ -766,13 +770,14 @@ static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)rcu_assign_pointer (idev->mc_tomb, pmc); } -/* called with mc_lock */ static void mld_del_delrec (struct inet6_dev *idev,struct ifmcaddr6 *im) {struct ip6_sf_list *psf, *sources, *tomb;struct in6_addr *pmca = &im->mca_addr;struct ifmcaddr6 *pmc, *pmc_prev; +mc_assert_locked (idev); + pmc_prev =NULL ;for_each_mc_tomb (idev, pmc) {if (ipv6_addr_equal (&pmc->mca_addr, pmca))
@@ -809,11 +814,12 @@ static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im) } } -/* called with mc_lock */ static void mld_clear_delrec (struct inet6_dev *idev) {struct ifmcaddr6 *pmc, *nextpmc; +mc_assert_locked (idev); + pmc =mc_dereference (idev->mc_tomb, idev);RCU_INIT_POINTER (idev->mc_tomb,NULL );
@@ -870,13 +876,14 @@ static void ma_put(struct ifmcaddr6 *mc) } } -/* called with mc_lock */ static struct ifmcaddr6 *mca_alloc (struct inet6_dev *idev,const struct in6_addr *addr,unsigned int mode) {struct ifmcaddr6 *mc; +mc_assert_locked (idev); + mc =kzalloc (sizeof (*mc),GFP_KERNEL );if (!mc)return NULL ;
@@ -1046,46 +1053,51 @@ bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,return rv; } -/* called with mc_lock */ static void mld_gq_start_work (struct inet6_dev *idev) {unsigned long tv =prandom_u32_max (idev->mc_maxdelay); +mc_assert_locked (idev); + idev->mc_gq_running =1 ;if (!mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 ))in6_dev_hold (idev); } -/* called with mc_lock */ static void mld_gq_stop_work (struct inet6_dev *idev) { +mc_assert_locked (idev); + idev->mc_gq_running =0 ;if (cancel_delayed_work (&idev->mc_gq_work))__in6_dev_put (idev); } -/* called with mc_lock */ static void mld_ifc_start_work (struct inet6_dev *idev,unsigned long delay) {unsigned long tv =prandom_u32_max (delay); +mc_assert_locked (idev); +if (!mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 ))in6_dev_hold (idev); } -/* called with mc_lock */ static void mld_ifc_stop_work (struct inet6_dev *idev) { +mc_assert_locked (idev); + idev->mc_ifc_count =0 ;if (cancel_delayed_work (&idev->mc_ifc_work))__in6_dev_put (idev); } -/* called with mc_lock */ static void mld_dad_start_work (struct inet6_dev *idev,unsigned long delay) {unsigned long tv =prandom_u32_max (delay); +mc_assert_locked (idev); +if (!mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 ))in6_dev_hold (idev); }
@@ -1110,14 +1122,13 @@ static void mld_report_stop_work(struct inet6_dev *idev)__in6_dev_put (idev); } -/* -* IGMP handling (alias multicast ICMPv6 messages) -* called with mc_lock -*/ +/* IGMP handling (alias multicast ICMPv6 messages) */ static void igmp6_group_queried (struct ifmcaddr6 *ma,unsigned long resptime) {unsigned long delay = resptime; +mc_assert_locked (ma->idev); +/* Do not start work for these addresses */ if (ipv6_addr_is_ll_all_nodes (&ma->mca_addr) ||IPV6_ADDR_MC_SCOPE (&ma->mca_addr) <IPV6_ADDR_SCOPE_LINKLOCAL )
@@ -1136,15 +1147,15 @@ static void igmp6_group_queried(struct ifmcaddr6 *ma, unsigned long resptime) ma->mca_flags |=MAF_TIMER_RUNNING ; } -/* mark EXCLUDE-mode sources -* called with mc_lock -*/ +/* mark EXCLUDE-mode sources */ static bool mld_xmarksources (struct ifmcaddr6 *pmc,int nsrcs,const struct in6_addr *srcs) {struct ip6_sf_list *psf;int i, scount; +mc_assert_locked (pmc->idev); + scount =0 ;for_each_psf_mclock (pmc, psf) {if (scount == nsrcs)
@@ -1167,13 +1178,14 @@ static bool mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,return true; } -/* called with mc_lock */ static bool mld_marksources (struct ifmcaddr6 *pmc,int nsrcs,const struct in6_addr *srcs) {struct ip6_sf_list *psf;int i, scount; +mc_assert_locked (pmc->idev); +if (pmc->mca_sfmode ==MCAST_EXCLUDE )return mld_xmarksources (pmc, nsrcs, srcs);
@@ -1870,7 +1882,6 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,#define AVAILABLE (skb) ((skb) ? skb_availroom(skb) : 0) -/* called with mc_lock */ static struct sk_buff *add_grec (struct sk_buff *skb,struct ifmcaddr6 *pmc,int type,int gdeleted,int sdeleted,int crsend)
@@ -1884,6 +1895,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,struct mld2_report *pmr;unsigned int mtu; +mc_assert_locked (idev); +if (pmc->mca_flags &MAF_NOREPORT )return skb;
@@ -2002,12 +2015,13 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,return skb; } -/* called with mc_lock */ static void mld_send_report (struct inet6_dev *idev,struct ifmcaddr6 *pmc) {struct sk_buff *skb =NULL ;int type; +mc_assert_locked (idev); +if (!pmc) {for_each_mc_mclock (idev, pmc) {if (pmc->mca_flags &MAF_NOREPORT )
@@ -2029,10 +2043,7 @@ static void mld_send_report(struct inet6_dev *idev, struct ifmcaddr6 *pmc)mld_sendpack (skb); } -/* -* remove zero-count source records from a source filter list -* called with mc_lock -*/ +/* remove zero-count source records from a source filter list */ static void mld_clear_zeros (struct ip6_sf_list __rcu **ppsf,struct inet6_dev *idev) {struct ip6_sf_list *psf_prev, *psf_next, *psf;
@@ -2056,7 +2067,6 @@ static void mld_clear_zeros(struct ip6_sf_list __rcu **ppsf, struct inet6_dev *i } } -/* called with mc_lock */ static void mld_send_cr (struct inet6_dev *idev) {struct ifmcaddr6 *pmc, *pmc_prev, *pmc_next;
@@ -2222,13 +2232,14 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) goto out; } -/* called with mc_lock */ static void mld_send_initial_cr (struct inet6_dev *idev) { -struct sk_buff *skb;struct ifmcaddr6 *pmc; +struct sk_buff *skb;int type; +mc_assert_locked (idev); +if (mld_in_v1_mode (idev))return ;
@@ -2275,13 +2286,14 @@ static void mld_dad_work(struct work_struct *work)in6_dev_put (idev); } -/* called with mc_lock */ static int ip6_mc_del1_src (struct ifmcaddr6 *pmc,int sfmode, -const struct in6_addr *psfsrc) +const struct in6_addr *psfsrc) {struct ip6_sf_list *psf, *psf_prev;int rv =0 ; +mc_assert_locked (pmc->idev); + psf_prev =NULL ;for_each_psf_mclock (pmc, psf) {if (ipv6_addr_equal (&psf->sf_addr, psfsrc))
@@ -2318,7 +2330,6 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,return rv; } -/* called with mc_lock */ static int ip6_mc_del_src (struct inet6_dev *idev,const struct in6_addr *pmca,int sfmode,int sfcount,const struct in6_addr *psfsrc,int delta)
@@ -2330,6 +2341,8 @@ static int ip6_mc_del_src(struct inet6_dev *idev, const struct in6_addr *pmca,if (!idev)return -ENODEV ; +mc_assert_locked (idev); +for_each_mc_mclock (idev, pmc) {if (ipv6_addr_equal (pmca, &pmc->mca_addr))break ;
@@ -2371,15 +2384,14 @@ static int ip6_mc_del_src(struct inet6_dev *idev, const struct in6_addr *pmca,return err; } -/* -* Add multicast single-source filter to the interface list -* called with mc_lock -*/ +/* Add multicast single-source filter to the interface list */ static int ip6_mc_add1_src (struct ifmcaddr6 *pmc,int sfmode, -const struct in6_addr *psfsrc) +const struct in6_addr *psfsrc) {struct ip6_sf_list *psf, *psf_prev; +mc_assert_locked (pmc->idev); + psf_prev =NULL ;for_each_psf_mclock (pmc, psf) {if (ipv6_addr_equal (&psf->sf_addr, psfsrc))
@@ -2402,11 +2414,12 @@ static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode,return 0 ; } -/* called with mc_lock */ static void sf_markstate (struct ifmcaddr6 *pmc) { -struct ip6_sf_list *psf;int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE ]; +struct ip6_sf_list *psf; + +mc_assert_locked (pmc->idev);for_each_psf_mclock (pmc, psf) {if (pmc->mca_sfcount[MCAST_EXCLUDE ]) {
@@ -2419,14 +2432,15 @@ static void sf_markstate(struct ifmcaddr6 *pmc) } } -/* called with mc_lock */ static int sf_setstate (struct ifmcaddr6 *pmc) { -struct ip6_sf_list *psf, *dpsf;int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE ]; +struct ip6_sf_list *psf, *dpsf;int qrv = pmc->idev->mc_qrv;int new_in, rv; +mc_assert_locked (pmc->idev); + rv =0 ;for_each_psf_mclock (pmc, psf) {if (pmc->mca_sfcount[MCAST_EXCLUDE ]) {
@@ -2485,10 +2499,7 @@ static int sf_setstate(struct ifmcaddr6 *pmc)return rv; } -/* -* Add multicast source filter list to the interface list -* called with mc_lock -*/ +/* Add multicast source filter list to the interface list */ static int ip6_mc_add_src (struct inet6_dev *idev,const struct in6_addr *pmca,int sfmode,int sfcount,const struct in6_addr *psfsrc,int delta)
@@ -2500,6 +2511,8 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,if (!idev)return -ENODEV ; +mc_assert_locked (idev); +for_each_mc_mclock (idev, pmc) {if (ipv6_addr_equal (pmca, &pmc->mca_addr))break ;
@@ -2545,11 +2558,12 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,return err; } -/* called with mc_lock */ static void ip6_mc_clear_src (struct ifmcaddr6 *pmc) {struct ip6_sf_list *psf, *nextpsf; +mc_assert_locked (pmc->idev); +for (psf =mc_dereference (pmc->mca_tomb, pmc->idev); psf; psf = nextpsf) {
@@ -2569,11 +2583,12 @@ static void ip6_mc_clear_src(struct ifmcaddr6 *pmc) pmc->mca_sfcount[MCAST_EXCLUDE ] =1 ; } -/* called with mc_lock */ static void igmp6_join_group (struct ifmcaddr6 *ma) {unsigned long delay; +mc_assert_locked (ma->idev); +if (ma->mca_flags &MAF_NOREPORT )return ;
@@ -2620,9 +2635,10 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,return err; } -/* called with mc_lock */ static void igmp6_leave_group (struct ifmcaddr6 *ma) { +mc_assert_locked (ma->idev); +if (mld_in_v1_mode (ma->idev)) {if (ma->mca_flags &MAF_LAST_REPORTER ) { igmp6_send(&ma->mca_addr, ma->idev->dev,
@@ -2667,9 +2683,10 @@ static void mld_ifc_work(struct work_struct *work)in6_dev_put (idev); } -/* called with mc_lock */ static void mld_ifc_event (struct inet6_dev *idev) { +mc_assert_locked (idev); +if (mld_in_v1_mode (idev))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 729/1067 fbdev: broadsheetfb: fix potential memory leak in broadsheetfb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 9d18a4e4234fd3ee0d0eed8ccbbb50cb76b2232c upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/broadsheetfb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/broadsheetfb.c +6 -2
@@ -1134,12 +1134,14 @@ static int broadsheetfb_probe(struct pla info->flags =FBINFO_FLAG_DEFAULT |FBINFO_VIRTFB ; info->fbdefio = &broadsheetfb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_vfree; retval =fb_alloc_cmap (&info->cmap,16 ,0 );if (retval <0 ) {dev_err (&dev->dev,"Failed to allocate colormap\n" ); - goto err_vfree; + goto err_fbdefio; }/* set cmap */
@@ -1183,6 +1185,8 @@ err_free_irq: board->cleanup (par); err_cmap:fb_dealloc_cmap (&info->cmap); +err_fbdefio: +fb_deferred_io_cleanup (info); err_vfree:vfree (videomemory); err_fb_rel:
Greg Kroah-Hartman
maintainerPATCH 730/1067 fbdev: hecubafb: fix potential memory leak in hecubafb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit cbef2a305a8a72969b86f96b7c07b86edde61aff upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/hecubafb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/video/fbdev/hecubafb.c +5 -1
@@ -254,7 +254,9 @@ static int hecubafb_probe(struct platfor info->flags =FBINFO_FLAG_DEFAULT |FBINFO_VIRTFB ; info->fbdefio = &hecubafb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_fbdefio; retval =register_framebuffer (info);if (retval <0 )
@@ -271,6 +273,8 @@ static int hecubafb_probe(struct platforreturn 0 ; err_fbreg: +fb_deferred_io_cleanup (info); +err_fbdefio:framebuffer_release (info); err_fballoc:vfree (videomemory);
Greg Kroah-Hartman
maintainerPATCH 731/1067 fbdev: sm712: Fix operator precedence in big_swap macro
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
commit 5dbe5b65df0b0c0ec77492427c274b7b5011890e upstream.
The big_swap(p) macro was intended to swap bytes within 16-bit halves of a 32-bit value. However, because the bitwise shift operators (<<, >>) have higher precedence than the bitwise AND operator (&), the original code failed to perform any shifting on the masked bits.
For example, 'p & 0xff00ff00 >> 8' was evaluated as 'p & (0xff00ff00 >> 8)', effectively neutralizing the intended swap.
Fix this by adding parentheses to ensure the bitwise AND is performed before the shift, correctly implementing the byte swap logic.
--- drivers/video/fbdev/sm712.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/sm712.h +1 -1
@@ -101,7 +101,7 @@ struct modeinit {#define mmio_addr 0x00800000#define seqw17 () smtc_seqw(0x17, 0x30)#define big_pixel_depth (p, d) {if (p == 24) {p = 32; d = 32; } } -#define big_swap (p) ((p & 0xff00ff00 >> 8) | (p & 0x00ff00ff << 8)) +#define big_swap (p) (((p & 0xff00ff00) >> 8) | ((p & 0x00ff00ff) << 8))#else #define pal_rgb (r, g, b, val) val#define big_addr 0
Greg Kroah-Hartman
maintainerPATCH 732/1067 fbdev: radeon: fix potential memory leak in radeonfb_pci_register()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit df8c1101c9a08859da612b5d0a08d55d475522c6 upstream.
The function radeonfb_pci_register() allocates memory for modelist (by calling radeon_check_modes() which calls fb_add_videomode()). The memory is appended to info->modelist, but is not freed in subsequent error paths. Fix this by calling fb_destroy_modelist().
--- drivers/video/fbdev/aty/radeon_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/aty/radeon_base.c +1 -0
@@ -2475,6 +2475,7 @@ static int radeonfb_pci_register(structreturn 0 ; err_unmap_fb:iounmap (rinfo->fb_base); +fb_destroy_modelist (&info->modelist); err_unmap_rom:kfree (rinfo->mon1_EDID);kfree (rinfo->mon2_EDID);
Greg Kroah-Hartman
maintainerPATCH 733/1067 fbdev: i740fb: fix potential memory leak in i740fb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 5936063409af230a2c88b8700c47b89a19fd70b5 upstream.
In i740fb_probe(), the memory allocated in fb_videomode_to_modelist() for modelist is not freed in the error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/i740fb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/i740fb.c +1 -0
@@ -1155,6 +1155,7 @@ err_reg_framebuffer:fb_dealloc_cmap (&info->cmap); err_alloc_cmap: err_find_mode: +fb_destroy_modelist (&info->modelist);if (par->ddc_registered)i2c_del_adapter (&par->ddc_adapter);pci_iounmap (dev, par->regs);
Greg Kroah-Hartman
maintainerPATCH 734/1067 fbdev: s3fb: fix potential memory leak in s3_pci_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 3b0ed04bc852887a9164e1bbf521652e8ef3eb92 upstream.
In s3_pci_probe(), the memory allocated for modelist using fb_videomode_to_modelist() is not freed in subsequent error paths. Fix that by calling fb_destroy_modelist()
--- drivers/video/fbdev/s3fb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/s3fb.c +1 -0
@@ -1374,6 +1374,7 @@ err_reg_fb: err_alloc_cmap: err_find_mode:#ifdef CONFIG_FB_S3_DDC +fb_destroy_modelist (&info->modelist);if (par->ddc_registered)i2c_del_adapter (&par->ddc_adapter);if (par->mmio)
Greg Kroah-Hartman
maintainerPATCH 735/1067 fbdev: uvesafb: fix potential memory leak in uvesafb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 033e56fed09047ee63072e9f58789f40c1c7079d upstream.
Due to an incorrect goto label, memory allocated for modedb and modelist in uvesafb_vbe_init() is not freed in some error paths. Fix this by updating the goto label.
--- drivers/video/fbdev/uvesafb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/uvesafb.c +2 -2
@@ -1700,14 +1700,14 @@ static int uvesafb_probe(struct platform i =uvesafb_vbe_init_mode (info);if (i <0 ) { err = -EINVAL ; - goto out; + goto out_mode; }else { mode = &par->vbe_modes[i]; }if (fb_alloc_cmap (&info->cmap,256 ,0 ) <0 ) { err = -ENXIO ; - goto out; + goto out_mode; }uvesafb_init_info (info, mode);
Greg Kroah-Hartman
maintainerPATCH 736/1067 fbdev: tdfxfb: fix potential memory leak in tdfxfb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit bb019d755366cc3e777a12d4bf457ff289837370 upstream.
In tdfxfb_probe(), the memory allocated for modelist using fb_videomode_to_modelist() when CONFIG_FB_3DFX_I2C is defined, is not freed in the subsequent error paths.
Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/tdfxfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/tdfxfb.c +1 -0
@@ -1551,6 +1551,7 @@ static int tdfxfb_probe(struct pci_dev * out_err_iobase:#ifdef CONFIG_FB_3DFX_I2C +fb_destroy_modelist (&info->modelist);tdfxfb_delete_i2c_busses (default_par);#endif arch_phys_wc_del (default_par->wc_cookie);
Greg Kroah-Hartman
maintainerPATCH 737/1067 fbdev: carminefb: fix potential memory leak in alloc_carmine_fb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 6fcca16a2b19c37f60693c56cbc0c923364ff3ef upstream.
The memory allocated for modelist in fb_videomode_to_modelist() is not freed in the subsequent error path.
Fix that by calling fb_destroy_modelist()
--- drivers/video/fbdev/carminefb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/carminefb.c +1 -0
@@ -593,6 +593,7 @@ static int alloc_carmine_fb(void __iomemreturn 0 ; err_dealloc_cmap: +fb_destroy_modelist (&info->modelist);fb_dealloc_cmap (&info->cmap); err_free_fb:framebuffer_release (info);
Greg Kroah-Hartman
maintainerPATCH 738/1067 fbdev: nvidia: fix potential memory leak in nvidiafb_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 85f5e38c162bdf9dbbe197275d416402712f3707 upstream.
In nvidiafb_probe(), the memory allocated for modelist in nvidia_set_fbinfo() is not freed in the subsequent error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/nvidia/nvidia.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/nvidia/nvidia.c +1 -0
@@ -1418,6 +1418,7 @@ static int nvidiafb_probe(struct pci_dev err_out_iounmap_fb:iounmap (info->screen_base); +fb_destroy_modelist (&info->modelist); err_out_free_base1:fb_destroy_modedb (info->monspecs.modedb);nvidia_delete_i2c_busses (par);
Greg Kroah-Hartman
maintainerPATCH 703/1067 ipv6: mcast: Fix potential UAF in MLD delayed work
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9b26518b6896a16b809b1e42986f4ebac7bccc1e ]
A race condition exists between device teardown and incoming MLD query processing, leading to a Use-After-Free in the MLD delayed work.
During device destruction, the primary reference to inet6_dev is dropped, which can drop its refcount to 0. The actual freeing of inet6_dev memory is deferred via RCU.
Concurrently, the packet receive path runs under RCU read lock and obtains the inet6_dev pointer. Because the memory is RCU-protected, CPU-0 can safely dereference inet6_dev even if its refcount has hit 0.
However, if CPU-0 calls igmp6_event_query() and schedules delayed work, it attempts to acquire a reference using in6_dev_hold(). This increments the refcount from 0 to 1, triggering a "refcount_t: addition on 0" warning. Since the inet6_dev memory is still scheduled to be freed after the RCU grace period, the device is freed while the work is still scheduled. When the work runs, it accesses the freed memory, causing a kernel panic.
Fix this by using refcount_inc_not_zero() (via a new helper in6_dev_hold_safe()) to prevent acquiring a reference if the device is already being destroyed. If the refcount is 0, we do not schedule the work.
--- include/net/addrconf.h | 5 +++++ net/ipv6/mcast.c | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-)
include/net/addrconf.h +5 -0
@@ -411,6 +411,11 @@ static inline void in6_dev_hold(struct inet6_dev *idev)refcount_inc (&idev->refcnt); } +static inline bool in6_dev_hold_safe (struct inet6_dev *idev) +{ +return refcount_inc_not_zero (&idev->refcnt); +} +/* called with rcu_read_lock held */ static inline bool ip6_ignore_linkdown (const struct net_device *dev) {
net/ipv6/mcast.c +28 -12
@@ -1060,8 +1060,10 @@ static void mld_gq_start_work(struct inet6_dev *idev)mc_assert_locked (idev); idev->mc_gq_running =1 ; -if (!mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_gq_stop_work (struct inet6_dev *idev)
@@ -1079,8 +1081,10 @@ static void mld_ifc_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_ifc_stop_work (struct inet6_dev *idev)
@@ -1098,8 +1102,10 @@ static void mld_dad_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_dad_stop_work (struct inet6_dev *idev)
@@ -1385,18 +1391,23 @@ static void mld_process_v2(struct inet6_dev *idev, struct mld2_query *mld,void igmp6_event_query (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_query_lock); -if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_query_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_query_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
@@ -1553,18 +1564,23 @@ static void mld_query_work(struct work_struct *work)void igmp6_event_report (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_report_lock); -if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_report_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_report_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 739/1067 fbdev: tridentfb: fix potential memory leak in trident_pci_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 7a35ec619d9af8ee128320975c1252b8ad65f1e8 upstream.
In trident_pci_probe(), the memory allocated for modelist using fb_videomode_to_modelist() is not freed in subsequent error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/tridentfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/tridentfb.c +1 -0
@@ -1705,6 +1705,7 @@ static int trident_pci_probe(struct pci_return 0 ; out_unmap2: +fb_destroy_modelist (&info->modelist);if (default_par->ddc_registered)i2c_del_adapter (&default_par->ddc_adapter);kfree (info->pixmap.addr);
Greg Kroah-Hartman
maintainerPATCH 740/1067 ASoC: SOF: ipc3-control: Validate size in snd_sof_update_control
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 390aa4c9339bb0ec0bc8d554e830faf93ca9d49e upstream.
In snd_sof_update_control(), firmware-provided cdata->num_elems is checked against local_cdata->data->size but never against the actual allocation size. If local_cdata->data->size was previously set to an inconsistent value, the memcpy could write past the allocated buffer.
Add a bounds check to ensure num_elems fits within the available space in the ipc_control_data allocation before copying.
--- sound/soc/sof/ipc3-control.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/sof/ipc3-control.c +9 -0
@@ -522,6 +522,15 @@ static void snd_sof_update_control(strucreturn ; } +/* Verify the size fits within the allocation */ +if (cdata->num_elems > scontrol->max_size -sizeof (*local_cdata) - +sizeof (*local_cdata->data)) { +dev_err (scomp->dev, +"cdata binary size %u exceeds buffer\n" , + cdata->num_elems); +return ; + } +/* copy the new binary data */ memcpy (local_cdata->data, cdata->data, cdata->num_elems); }else if (cdata->num_elems != scontrol->num_channels) {
Greg Kroah-Hartman
maintainerPATCH 741/1067 ASoC: qcom: q6apm: fix NULL pointer dereference in graph_callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 2e9261761b35f0b67b7487688cd1365f535be0b3 upstream.
When q6apm_free_fragments() is called it frees rx_data.buf/tx_data.buf and sets them to NULL under graph->lock. A late DSP buffer-done response can race with this: graph_callback() passes the !graph->ar_graph guard (not yet NULL), acquires the lock, but then dereferences a now-NULL buf pointer to read buf[token].phys, crashing at virtual address 0x10.
Add a NULL check for buf inside the mutex-protected section in both the write-done (DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2) and read-done (DATA_CMD_RSP_RD_SH_MEM_EP_DATA_BUFFER_V2) handlers and bail out cleanly if buffers have already been freed.
This problem is only shown up recently while apr bus was updated to process the commands per service rather from single global queue.
--- sound/soc/qcom/qdsp6/q6apm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/qcom/qdsp6/q6apm.c +8 -0
@@ -524,6 +524,10 @@ static int graph_callback(struct gpr_res token = hdr->token &APM_WRITE_TOKEN_MASK ; done = data->payload; +if (!graph->rx_data.buf) { +mutex_unlock (&graph->lock); +break ; + } phys = graph->rx_data.buf[token].phys;mutex_unlock (&graph->lock);
@@ -557,6 +561,10 @@ static int graph_callback(struct gpr_res client_event =APM_CLIENT_EVENT_DATA_READ_DONE ;mutex_lock (&graph->lock); rd_done = data->payload; +if (!graph->tx_data.buf) { +mutex_unlock (&graph->lock); +break ; + } phys = graph->tx_data.buf[hdr->token].phys;mutex_unlock (&graph->lock);
Greg Kroah-Hartman
maintainerPATCH 742/1067 netfilter: nf_conntrack_irc: fix parse_dcc() off-by-one OOB read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
commit ef6400ca25a13fd6dedbe8ef4a1d0979bbbfe88a upstream.
parse_dcc() treats data_end as an inclusive end pointer, but its only caller passes data_limit = ib_ptr + datalen, which points one past the last valid byte.
The newline search loop iterates while tmp <= data_end, so when no newline is present, *tmp is read at tmp == data_end, one byte beyond the region filled by skb_header_pointer().
irc_buffer is kmalloc'd as MAX_SEARCH_SIZE + 1 bytes and datalen is capped at MAX_SEARCH_SIZE, so the stray read does not fault. The byte is uninitialized or stale; if it contains an ASCII digit, simple_strtoul will consume it and produce a wrong DCC IP or port in the conntrack expectation. The extra allocation byte is also a fragile guard: if the cap or allocation size changes, this becomes a real out-of-bounds read.
Change the loop and its post-loop check to use strict less-than, consistent with the caller's exclusive-end convention. Update the function comment accordingly.
--- net/netfilter/nf_conntrack_irc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_irc.c +3 -3
@@ -64,7 +64,7 @@ static const char *const dccprotos[] = {/* tries to get the ip_addr and port out of a dcc command * return value: -1 on failure, 0 on success * data pointer to first byte of DCC command data -* data_end pointer to last byte of dcc command data +* data_end one past end of data * ip returns parsed ip of dcc command * port returns parsed port of dcc command * ad_beg_p returns pointer to first byte of addr data
@@ -82,10 +82,10 @@ static int parse_dcc(char *data, const c/* Make sure we have a newline character within the packet boundaries * because simple_strtoul parses until the first invalid character. */ -for (tmp = data; tmp <= data_end; tmp++) +for (tmp = data; tmp < data_end; tmp++)if (*tmp =='\n' )break ; -if (tmp > data_end || *tmp !='\n' ) +if (tmp >= data_end || *tmp !='\n' )return -1 ; *ad_beg_p = data;
Greg Kroah-Hartman
maintainerPATCH 743/1067 netfilter: nfnl_cthelper: apply per-class values when updating policies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
commit d738feccb98cb224ebabecb703e98f5008276bff upstream.
When a userspace conntrack helper with multiple expectation classes is updated via nfnetlink, every class ends up with the first class's max_expected and timeout values.
nfnl_cthelper_update_policy_all() validates each new policy into the corresponding slot of the temporary new_policy array, but the second loop that commits the values into the live helper dereferences new_policy as a pointer instead of indexing it, so every iteration reads new_policy[0] regardless of i. An update that changes per-class values is silently collapsed onto class 0's values with no error returned to userspace.
Index the temporary array by i in the commit loop so each class gets its own validated values.
--- net/netfilter/nfnetlink_cthelper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nfnetlink_cthelper.c +2 -2
@@ -348,8 +348,8 @@ static int nfnl_cthelper_update_policy_afor (i =0 ; i < helper->expect_class_max +1 ; i++) { policy = (struct nf_conntrack_expect_policy *) &helper->expect_policy[i]; - policy->max_expected = new_policy->max_expected; - policy->timeout = new_policy->timeout; + policy->max_expected = new_policy[i].max_expected; + policy->timeout = new_policy[i].timeout; } err:
Greg Kroah-Hartman
maintainerPATCH 744/1067 netfilter: xt_cluster: reject template conntracks in hash match
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
commit 5feba91006ec92da57acc1cc2e34df623b98541e upstream.
xt_cluster_mt() treats any non-NULL nf_ct_get() result as a fully initialized conntrack and passes it to xt_cluster_hash().
This causes a state confusion bug when the raw table CT target attaches a template conntrack to skb->_nfct before normal conntrack processing. Templates carry IPS_TEMPLATE status but do not have a valid tuple for hashing yet, so xt_cluster_hash() can hit its WARN_ON() path on the zeroed l3num field.
Reject template conntracks before hashing them. This matches existing netfilter handling for template objects and avoids hashing incomplete conntrack state.
--- net/netfilter/xt_cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_cluster.c +1 -1
@@ -107,7 +107,7 @@ xt_cluster_mt(const struct sk_buff *skb, } ct =nf_ct_get (skb, &ctinfo); -if (ct ==NULL ) +if (!ct ||nf_ct_is_template (ct))return false;if (ct->master)
Greg Kroah-Hartman
maintainerPATCH 704/1067 ipvs: pass parsed transport offset to state handlers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit bae7ce7bafb59e42dc0e0e2999fdd9d1cffe3866 ]
IPVS callers already parse the packet into struct ip_vs_iphdr before updating connection state. For IPv6 this records the real transport-header offset after extension headers in iph.len.
Pass this parsed transport offset through ip_vs_set_state() and the protocol state_transition() callback so protocol handlers can use the same packet context as scheduling and NAT handling. This patch only changes the common callback plumbing and adapts the protocol callback signatures; TCP and SCTP start using the value in follow-up patches.
Stable-dep-of: 2500fa3958b1 ("ipvs: use parsed transport offset in TCP state lookup")
--- include/net/ip_vs.h | 3 ++- net/netfilter/ipvs/ip_vs_core.c | 10 +++++----- net/netfilter/ipvs/ip_vs_proto_sctp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_tcp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_udp.c | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-)
include/net/ip_vs.h +2 -1
@@ -455,7 +455,8 @@ struct ip_vs_protocol {void (*state_transition)(struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd); +struct ip_vs_proto_data *pd, +unsigned int iph_len);int (*register_app)(struct netns_ipvs *ipvs,struct ip_vs_app *inc);
net/netfilter/ipvs/ip_vs_core.c +5 -5
@@ -220,10 +220,10 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)static inline void ip_vs_set_state (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd,unsigned int iph_len) {if (likely (pd->pp->state_transition)) - pd->pp->state_transition (cp, direction, skb, pd); + pd->pp->state_transition (cp, direction, skb, pd, iph_len); } static inline int
@@ -625,7 +625,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,ip_vs_in_stats (cp, skb);/* set state */ -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph->len);/* transmit the first SYN packet */ ret = cp->packet_xmit (skb, cp, pd->pp, iph);
@@ -1308,7 +1308,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, after_nat:ip_vs_out_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd, iph->len); skb->ipvs_property =1 ;if (!(cp->flags &IP_VS_CONN_F_NFCT ))ip_vs_notrack (skb);
@@ -2060,7 +2060,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stateIP_VS_DBG_PKT (11 , af, pp, skb, iph.off,"Incoming packet" );ip_vs_in_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph.len);if (cp->packet_xmit) ret = cp->packet_xmit (skb, cp, pp, &iph);/* do not touch skb anymore */
net/netfilter/ipvs/ip_vs_proto_sctp.c +2 -1
@@ -468,7 +468,8 @@ set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void sctp_state_transition (struct ip_vs_conn *cp,int direction, -const struct sk_buff *skb,struct ip_vs_proto_data *pd) +const struct sk_buff *skb,struct ip_vs_proto_data *pd, +unsigned int iph_len) {spin_lock_bh (&cp->lock);set_sctp_state (pd, cp, direction, skb);
net/netfilter/ipvs/ip_vs_proto_tcp.c +2 -1
@@ -580,7 +580,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void tcp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {struct tcphdr _tcph, *th;
net/netfilter/ipvs/ip_vs_proto_udp.c +2 -1
@@ -445,7 +445,8 @@ static const char * udp_state_name(int state)static void udp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {if (unlikely (!pd)) {pr_err ("UDP no ns data\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 705/1067 ipvs: use parsed transport offset in TCP state lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit 2500fa3958b1ba51c2b065e39db1b04dfa7e23a2 ]
TCP state handling reparses the skb to find the TCP header. For IPv6 it uses sizeof(struct ipv6hdr), while the surrounding IPVS code already parsed the packet with ip_vs_fill_iph_skb() and has the real transport-header offset in iph.len.
This makes TCP state handling look at the wrong bytes when an IPv6 packet carries extension headers. Use the parsed transport offset passed down from ip_vs_set_state() when reading the TCP header.
For IPv4 and for IPv6 packets without extension headers, the passed offset matches the previous value.
--- net/netfilter/ipvs/ip_vs_proto_tcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/netfilter/ipvs/ip_vs_proto_tcp.c +1 -7
@@ -585,13 +585,7 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction, {struct tcphdr _tcph, *th; -#ifdef CONFIG_IP_VS_IPV6 -int ihl = cp->af ==AF_INET ?ip_hdrlen (skb) :sizeof (struct ipv6hdr ); -#else -int ihl =ip_hdrlen (skb); -#endif - - th =skb_header_pointer (skb, ihl,sizeof (_tcph), &_tcph); + th =skb_header_pointer (skb, iph_len,sizeof (_tcph), &_tcph);if (th ==NULL )return ;
Signature · 1 line
2.53.0