* [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source()
@ 2026-11-19 12:51 Binbin Deng
2026-11-22 14:44 ` Ido Schimmel
2026-11-23 13:13 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: Binbin Deng @ 2026-11-19 12:51 UTC (permalink / raw)
To: dsahern, idosch, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Binbin Deng
pmc->sflist is read locklessly under rcu_read_lock() by ip_mc_sf_allow()
during packet reception in the UDP and RAW multicast receive paths.
ip_mc_source() mutated psl->sl_addr and psl->sl_count in-place when adding
or removing a source filter. Additionally, when expanding the filter
buffer, newpsl was published via rcu_assign_pointer() before the new source
was written into the array.
The setsockopt writer holds RTNL and the socket lock, but neither excludes
ip_mc_sf_allow(), which traverses the filter inside an RCU read-side
critical section. During an expansion, the race looks like this:
CPU0 CPU1
ip_mc_source(add = true) ip_mc_sf_allow()
/* RTNL and socket lock held */
allocate newpsl
copy old sources into newpsl
newpsl->sl_count = old source count
rcu_assign_pointer(pmc->sflist, newpsl)
psl = newpsl
rcu_read_lock()
psl = rcu_dereference(pmc->sflist)
read psl->sl_count
shift psl->sl_addr[] for insertion
psl->sl_addr[i] = source
read psl->sl_addr[i]
psl->sl_count++
apply source-filter decision
rcu_read_unlock()
The in-place add and remove paths have the same problem after a reader has
obtained the old list: the writer shifts or appends source addresses and
updates sl_count while the reader iterates those fields. This is a data
race and can expose a mixed old/new filter state, with duplicated or missed
source entries. A multicast packet may consequently be accepted or dropped
contrary to the configured filter.
An ordinary UDP socket can trigger the race: one thread updates a source
membership while multicast traffic is received and filtered on another CPU.
No special hardware is required.
Found during a static-analysis-assisted audit: candidate sites were
surfaced by a Coccinelle rule, and the reader/writer paths were
confirmed by code inspection. The issue was not observed at runtime;
it is identified by code inspection only.
Fix this by allocating and fully populating the replacement filter before
publishing it with rcu_assign_pointer(), and by reclaiming the old filter
with kfree_rcu(). The socket source list is therefore never modified while
an RCU reader may still be traversing it.
Fixes: c85bb41e9318 ("igmp: fix ip_mc_sf_allow race [v5]")
Signed-off-by: Binbin Deng <18983559317@163.com>
---
net/ipv4/igmp.c | 103 +++++++++++++++++++++++++++++-------------------
1 file changed, 63 insertions(+), 40 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d56355aca797..fd067858dd3e 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2489,10 +2489,10 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
struct ip_mc_socklist *pmc;
struct in_device *in_dev = NULL;
struct inet_sock *inet = inet_sk(sk);
- struct ip_sf_socklist *psl;
+ struct ip_sf_socklist *newpsl, *psl;
struct net *net = sock_net(sk);
int leavegroup = 0;
- int i, j, rv;
+ int count, i, j, rv;
if (!ipv4_is_multicast(addr))
return -EINVAL;
@@ -2554,13 +2554,33 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
goto done;
}
+ atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
+ &sk->sk_omem_alloc);
+ if (psl->sl_count == 1) {
+ newpsl = NULL;
+ } else {
+ newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
+ psl->sl_count - 1), GFP_KERNEL);
+ if (!newpsl) {
+ atomic_add(struct_size(psl, sl_addr, psl->sl_max),
+ &sk->sk_omem_alloc);
+ err = -ENOBUFS;
+ goto done;
+ }
+ newpsl->sl_max = psl->sl_count - 1;
+ newpsl->sl_count = psl->sl_count - 1;
+ for (j = 0; j < i; j++)
+ newpsl->sl_addr[j] = psl->sl_addr[j];
+ for (j = i + 1; j < psl->sl_count; j++)
+ newpsl->sl_addr[j - 1] = psl->sl_addr[j];
+ }
+
/* update the interface filter */
ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
&mreqs->imr_sourceaddr, 1);
- for (j = i+1; j < psl->sl_count; j++)
- psl->sl_addr[j-1] = psl->sl_addr[j];
- psl->sl_count--;
+ rcu_assign_pointer(pmc->sflist, newpsl);
+ kfree_rcu(psl, rcu);
err = 0;
goto done;
}
@@ -2570,49 +2590,52 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
err = -ENOBUFS;
goto done;
}
- if (!psl || psl->sl_count == psl->sl_max) {
- struct ip_sf_socklist *newpsl;
- int count = IP_SFBLOCK;
- if (psl)
- count += psl->sl_max;
- newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
- GFP_KERNEL);
- if (!newpsl) {
- err = -ENOBUFS;
- goto done;
- }
- newpsl->sl_max = count;
- newpsl->sl_count = count - IP_SFBLOCK;
- if (psl) {
- for (i = 0; i < psl->sl_count; i++)
- newpsl->sl_addr[i] = psl->sl_addr[i];
- /* decrease mem now to avoid the memleak warning */
- atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
- &sk->sk_omem_alloc);
+ rv = 1;
+ if (psl) {
+ for (i = 0; i < psl->sl_count; i++) {
+ rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
+ sizeof(__be32));
+ if (rv == 0)
+ break;
}
- rcu_assign_pointer(pmc->sflist, newpsl);
- if (psl)
- kfree_rcu(psl, rcu);
- psl = newpsl;
- }
- rv = 1; /* > 0 for insert logic below if sl_count is 0 */
- for (i = 0; i < psl->sl_count; i++) {
- rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
- sizeof(__be32));
- if (rv == 0)
- break;
}
+
if (rv == 0) /* address already there is an error */
goto done;
- for (j = psl->sl_count-1; j >= i; j--)
- psl->sl_addr[j+1] = psl->sl_addr[j];
- psl->sl_addr[i] = mreqs->imr_sourceaddr;
- psl->sl_count++;
- err = 0;
+
+ i = psl ? psl->sl_count + 1 : 1;
+ count = IP_SFBLOCK;
+ if (psl)
+ count += psl->sl_max;
+ newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
+ GFP_KERNEL);
+ if (!newpsl) {
+ err = -ENOBUFS;
+ goto done;
+ }
+ newpsl->sl_max = count;
+ newpsl->sl_count = i;
+ if (psl) {
+ for (j = 0; j < psl->sl_count; j++)
+ newpsl->sl_addr[j] = psl->sl_addr[j];
+ }
+ newpsl->sl_addr[i - 1] = mreqs->imr_sourceaddr;
+
/* update the interface list */
ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
&mreqs->imr_sourceaddr, 1);
+
+ if (psl) {
+ /* decrease mem now to avoid the memleak warning */
+ atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
+ &sk->sk_omem_alloc);
+ }
+ rcu_assign_pointer(pmc->sflist, newpsl);
+ if (psl)
+ kfree_rcu(psl, rcu);
+ err = 0;
+
done:
if (leavegroup)
err = ip_mc_leave_group(sk, &imr);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source()
2026-11-19 12:51 [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source() Binbin Deng
@ 2026-11-22 14:44 ` Ido Schimmel
2026-11-23 13:13 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2026-11-22 14:44 UTC (permalink / raw)
To: Binbin Deng; +Cc: dsahern, davem, edumazet, kuba, pabeni, netdev, linux-kernel
On Thu, Nov 19, 2026 at 08:51:11PM +0800, Binbin Deng wrote:
> pmc->sflist is read locklessly under rcu_read_lock() by ip_mc_sf_allow()
> during packet reception in the UDP and RAW multicast receive paths.
>
> ip_mc_source() mutated psl->sl_addr and psl->sl_count in-place when adding
s/mutated/mutates/
Why use past tense? The commit message needs to explain the problem with
the existing code. Same in other places.
> or removing a source filter. Additionally, when expanding the filter
> buffer, newpsl was published via rcu_assign_pointer() before the new source
s/was/is/
> was written into the array.
>
> The setsockopt writer holds RTNL and the socket lock, but neither excludes
> ip_mc_sf_allow(), which traverses the filter inside an RCU read-side
> critical section. During an expansion, the race looks like this:
>
> CPU0 CPU1
> ip_mc_source(add = true) ip_mc_sf_allow()
> /* RTNL and socket lock held */
> allocate newpsl
> copy old sources into newpsl
> newpsl->sl_count = old source count
> rcu_assign_pointer(pmc->sflist, newpsl)
> psl = newpsl
> rcu_read_lock()
> psl = rcu_dereference(pmc->sflist)
> read psl->sl_count
> shift psl->sl_addr[] for insertion
> psl->sl_addr[i] = source
> read psl->sl_addr[i]
> psl->sl_count++
> apply source-filter decision
> rcu_read_unlock()
>
> The in-place add and remove paths have the same problem after a reader has
> obtained the old list: the writer shifts or appends source addresses and
> updates sl_count while the reader iterates those fields. This is a data
> race and can expose a mixed old/new filter state, with duplicated or missed
> source entries. A multicast packet may consequently be accepted or dropped
> contrary to the configured filter.
>
> An ordinary UDP socket can trigger the race: one thread updates a source
> membership while multicast traffic is received and filtered on another CPU.
> No special hardware is required.
>
> Found during a static-analysis-assisted audit: candidate sites were
> surfaced by a Coccinelle rule, and the reader/writer paths were
> confirmed by code inspection. The issue was not observed at runtime;
> it is identified by code inspection only.
>
> Fix this by allocating and fully populating the replacement filter before
> publishing it with rcu_assign_pointer(), and by reclaiming the old filter
> with kfree_rcu(). The socket source list is therefore never modified while
> an RCU reader may still be traversing it.
>
> Fixes: c85bb41e9318 ("igmp: fix ip_mc_sf_allow race [v5]")
Given that:
1. This is not a regression. Never worked.
2. Not particularly interesting (e.g., no memory corruption / security
aspect).
3. "The issue was not observed at runtime".
4. Not a small change.
Please strip the Fixes tag and target v3 at net-next. The AI bot will
most likely ask you to add a Fixes tag. Ignore it.
See more below and don't submit v3 until the AI review is posted
(tomorrow).
> Signed-off-by: Binbin Deng <18983559317@163.com>
> ---
> net/ipv4/igmp.c | 103 +++++++++++++++++++++++++++++-------------------
> 1 file changed, 63 insertions(+), 40 deletions(-)
>
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index d56355aca797..fd067858dd3e 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -2489,10 +2489,10 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
> struct ip_mc_socklist *pmc;
> struct in_device *in_dev = NULL;
> struct inet_sock *inet = inet_sk(sk);
> - struct ip_sf_socklist *psl;
> + struct ip_sf_socklist *newpsl, *psl;
> struct net *net = sock_net(sk);
> int leavegroup = 0;
> - int i, j, rv;
> + int count, i, j, rv;
>
> if (!ipv4_is_multicast(addr))
> return -EINVAL;
> @@ -2554,13 +2554,33 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
> goto done;
> }
>
> + atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
> + &sk->sk_omem_alloc);
Nit: Alignment is off.
> + if (psl->sl_count == 1) {
> + newpsl = NULL;
> + } else {
> + newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
> + psl->sl_count - 1), GFP_KERNEL);
Likewise.
> + if (!newpsl) {
> + atomic_add(struct_size(psl, sl_addr, psl->sl_max),
> + &sk->sk_omem_alloc);
Likewise. Did you run checkpatch???
> + err = -ENOBUFS;
> + goto done;
> + }
> + newpsl->sl_max = psl->sl_count - 1;
> + newpsl->sl_count = psl->sl_count - 1;
> + for (j = 0; j < i; j++)
> + newpsl->sl_addr[j] = psl->sl_addr[j];
> + for (j = i + 1; j < psl->sl_count; j++)
> + newpsl->sl_addr[j - 1] = psl->sl_addr[j];
> + }
> +
> /* update the interface filter */
> ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
> &mreqs->imr_sourceaddr, 1);
>
> - for (j = i+1; j < psl->sl_count; j++)
> - psl->sl_addr[j-1] = psl->sl_addr[j];
> - psl->sl_count--;
> + rcu_assign_pointer(pmc->sflist, newpsl);
> + kfree_rcu(psl, rcu);
> err = 0;
> goto done;
> }
> @@ -2570,49 +2590,52 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
> err = -ENOBUFS;
> goto done;
> }
> - if (!psl || psl->sl_count == psl->sl_max) {
> - struct ip_sf_socklist *newpsl;
> - int count = IP_SFBLOCK;
>
> - if (psl)
> - count += psl->sl_max;
> - newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
> - GFP_KERNEL);
> - if (!newpsl) {
> - err = -ENOBUFS;
> - goto done;
> - }
> - newpsl->sl_max = count;
> - newpsl->sl_count = count - IP_SFBLOCK;
> - if (psl) {
> - for (i = 0; i < psl->sl_count; i++)
> - newpsl->sl_addr[i] = psl->sl_addr[i];
> - /* decrease mem now to avoid the memleak warning */
> - atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
> - &sk->sk_omem_alloc);
> + rv = 1;
> + if (psl) {
> + for (i = 0; i < psl->sl_count; i++) {
> + rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
> + sizeof(__be32));
> + if (rv == 0)
> + break;
> }
> - rcu_assign_pointer(pmc->sflist, newpsl);
> - if (psl)
> - kfree_rcu(psl, rcu);
> - psl = newpsl;
> - }
> - rv = 1; /* > 0 for insert logic below if sl_count is 0 */
> - for (i = 0; i < psl->sl_count; i++) {
> - rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
> - sizeof(__be32));
> - if (rv == 0)
> - break;
> }
> +
> if (rv == 0) /* address already there is an error */
> goto done;
> - for (j = psl->sl_count-1; j >= i; j--)
> - psl->sl_addr[j+1] = psl->sl_addr[j];
> - psl->sl_addr[i] = mreqs->imr_sourceaddr;
> - psl->sl_count++;
> - err = 0;
> +
> + i = psl ? psl->sl_count + 1 : 1;
> + count = IP_SFBLOCK;
> + if (psl)
> + count += psl->sl_max;
> + newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
> + GFP_KERNEL);
No need for 'count'. Size the new list according to 'i', like
ip6_mc_source() and remove 'IP_SFBLOCK' in a similar fashion to commit
c073d1b070f1 ("ipv6: mcast: use copy-on-write RCU updates in
ip6_mc_source()").
> + if (!newpsl) {
> + err = -ENOBUFS;
> + goto done;
> + }
> + newpsl->sl_max = count;
> + newpsl->sl_count = i;
> + if (psl) {
> + for (j = 0; j < psl->sl_count; j++)
> + newpsl->sl_addr[j] = psl->sl_addr[j];
> + }
> + newpsl->sl_addr[i - 1] = mreqs->imr_sourceaddr;
> +
> /* update the interface list */
> ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
> &mreqs->imr_sourceaddr, 1);
> +
> + if (psl) {
> + /* decrease mem now to avoid the memleak warning */
> + atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
> + &sk->sk_omem_alloc);
> + }
> + rcu_assign_pointer(pmc->sflist, newpsl);
> + if (psl)
> + kfree_rcu(psl, rcu);
> + err = 0;
> +
> done:
> if (leavegroup)
> err = ip_mc_leave_group(sk, &imr);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source()
2026-11-19 12:51 [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source() Binbin Deng
2026-11-22 14:44 ` Ido Schimmel
@ 2026-11-23 13:13 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 13:13 UTC (permalink / raw)
To: 18983559317
Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In ip_mc_source() (net/ipv4/igmp.c), the rewritten add path
makes the source list far larger than it needs to be.
- [Low] In ip_mc_source() (net/ipv4/igmp.c), removing the last source
from an EXCLUDE-mode filter now sets pmc->sflist to NULL (`if…
- [Low] In ip_mc_source() (net/ipv4/igmp.c), the source-removal path
(IP_DROP_SOURCE_MEMBERSHIP, IP_UNBLOCK_SOURCE,…
--
igmp: use copy-on-write RCU updates in ip_mc_source()
This commit changes ip_mc_source() so that adding or removing a source
filter entry builds a fully populated replacement ip_sf_socklist. It then
publishes that list with rcu_assign_pointer() and frees the old one with
kfree_rcu(). The goal is to stop ip_mc_sf_allow() readers from seeing a
list that is being changed in place.
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 52cde8782eebd..75292f4550216 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
[ ... ]
> @@ -2556,13 +2556,33 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
> goto done;
> }
>
> + atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
> + &sk->sk_omem_alloc);
> + if (psl->sl_count == 1) {
> + newpsl = NULL;
[Severity: Low]
Is this change in setsockopt behaviour intended? When the last source is
removed from an MCAST_EXCLUDE filter, this now publishes NULL into
pmc->sflist. The old code shifted the entries in place and left a non-NULL
list with sl_count == 0. The MCAST_INCLUDE case with one source becomes
leavegroup before it gets here.
The mode check at the top of ip_mc_source() only allows a mode switch
when sflist is NULL:
if (pmc->sflist) {
if (pmc->sfmode != omode) {
err = -EINVAL;
goto done;
}
} else if (pmc->sfmode != omode) {
/* allow mode switches for empty-set filters */
Take this sequence: IP_ADD_MEMBERSHIP, IP_BLOCK_SOURCE S,
IP_UNBLOCK_SOURCE S, then IP_ADD_SOURCE_MEMBERSHIP S2. The last call used
to fail with -EINVAL. It now succeeds and switches the group to
MCAST_INCLUDE with S2.
This matches what ip_mc_msfilter() and ip6_mc_source() already do.
ip_mc_sf_allow() also treats a NULL MCAST_EXCLUDE list and an empty one
the same way.
Since this is a Fixes: tagged data race fix, should the commit message
mention the change?
> + } else {
> + newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
> + psl->sl_count - 1), GFP_KERNEL);
> + if (!newpsl) {
> + atomic_add(struct_size(psl, sl_addr, psl->sl_max),
> + &sk->sk_omem_alloc);
> + err = -ENOBUFS;
> + goto done;
> + }
[Severity: Low]
Can removing a source now fail with -ENOBUFS? Before this patch,
IP_DROP_SOURCE_MEMBERSHIP, IP_UNBLOCK_SOURCE, MCAST_LEAVE_SOURCE_GROUP and
MCAST_UNBLOCK_SOURCE always succeeded once the source was found.
The old list's charge is subtracted first, so the optmem check usually
passes. However, sock_kmalloc() reads optmem_max at call time:
int optmem_max = READ_ONCE(sock_net(sk)->core.sysctl_optmem_max);
if ((unsigned int)size <= optmem_max &&
atomic_read(&sk->sk_omem_alloc) + size < optmem_max) {
This allocation can fail in two cases:
- optmem_max was lowered below the socket's other option memory use
- the GFP_KERNEL allocation fails for a large list
In either case userspace cannot drop a single source, and an
MCAST_EXCLUDE block stays in force.
The error path itself restores the accounting cleanly. The workarounds
are IP_MSFILTER with zero sources or leaving the group.
ip6_mc_source() can fail the same way.
> + newpsl->sl_max = psl->sl_count - 1;
> + newpsl->sl_count = psl->sl_count - 1;
[ ... ]
> @@ -2572,49 +2592,52 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
> err = -ENOBUFS;
> goto done;
> }
> - if (!psl || psl->sl_count == psl->sl_max) {
> - struct ip_sf_socklist *newpsl;
> - int count = IP_SFBLOCK;
[ ... ]
> + i = psl ? psl->sl_count + 1 : 1;
> + count = IP_SFBLOCK;
> + if (psl)
> + count += psl->sl_max;
> + newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
> + GFP_KERNEL);
> + if (!newpsl) {
> + err = -ENOBUFS;
> + goto done;
> + }
> + newpsl->sl_max = count;
> + newpsl->sl_count = i;
[Severity: Medium]
Does sl_max now grow by IP_SFBLOCK on every add? The old code only
reallocated when sl_count == sl_max, so the spare slots were filled
before the list grew.
Now a new list is allocated on every add, but it is still sized as the
old sl_max plus IP_SFBLOCK. The spare slots are never used:
add 1: sl_count = 1, sl_max = 10
add 2: sl_count = 2, sl_max = 20
add 3: sl_count = 3, sl_max = 30
After N adds the buffer has room for about 10*N entries instead of N.
The old list's charge is only removed after the new allocation succeeds:
if (psl) {
/* decrease mem now to avoid the memleak warning */
atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
&sk->sk_omem_alloc);
}
So both oversized buffers have to fit under optmem_max in sock_kmalloc()
at the same time.
Assume the default optmem_max of 128 KiB and a raised igmp_max_msf. In
that case IP_ADD_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE and
MCAST_JOIN_SOURCE_GROUP start returning -ENOBUFS at about 1600 sources
per group, compared with about 16000 before. Large lists also become
high-order allocations.
With the default igmp_max_msf of 10, sl_max stays at or below 100.
The delete path in this patch and ip_mc_msfilter() size the new list
exactly. So does ip6_mc_source() in net/ipv6/mcast.c:
i = psl ? psl->sl_count + 1 : 1;
newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, i),
GFP_KERNEL);
...
newpsl->sl_max = i;
newpsl->sl_count = i;
Should the IPv4 add path use struct_size(newpsl, sl_addr, i) and
sl_max = i as well?
> + if (psl) {
> + for (j = 0; j < psl->sl_count; j++)
> + newpsl->sl_addr[j] = psl->sl_addr[j];
> + }
> + newpsl->sl_addr[i - 1] = mreqs->imr_sourceaddr;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119125112.540125-1-18983559317%40163.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 13:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 12:51 [PATCH net v2] igmp: use copy-on-write RCU updates in ip_mc_source() Binbin Deng
2026-11-22 14:44 ` Ido Schimmel
2026-11-23 13:13 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox