mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
ipv4: igmp: annotate data-races in igmp_heard_query()
Multiple cpus can run igmp_heard_query() concurrently.
Add missing READ_ONCE()/WRITE_ONCE() over following in_dev fields.
- mr_qrv
- mr_qi
- mr_qri
- mr_v1_seen
- mr_v2_seen
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: syzbot+ae9a171f239b14485310@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/69f38675.050a0220.3cbe47.0002.GAE@google.com
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260430164836.872079-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
4b9e327991
commit
c6bebaa744
|
|
@ -122,16 +122,29 @@
|
||||||
* contradict to specs provided this delay is small enough.
|
* contradict to specs provided this delay is small enough.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IGMP_V1_SEEN(in_dev) \
|
static bool IGMP_V1_SEEN(const struct in_device *in_dev)
|
||||||
(IPV4_DEVCONF_ALL_RO(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 1 || \
|
{
|
||||||
IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 1 || \
|
unsigned long seen;
|
||||||
((in_dev)->mr_v1_seen && \
|
|
||||||
time_before(jiffies, (in_dev)->mr_v1_seen)))
|
if (IPV4_DEVCONF_ALL_RO(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 1)
|
||||||
#define IGMP_V2_SEEN(in_dev) \
|
return true;
|
||||||
(IPV4_DEVCONF_ALL_RO(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 2 || \
|
if (IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 1)
|
||||||
IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 2 || \
|
return true;
|
||||||
((in_dev)->mr_v2_seen && \
|
seen = READ_ONCE(in_dev->mr_v1_seen);
|
||||||
time_before(jiffies, (in_dev)->mr_v2_seen)))
|
return seen && time_before(jiffies, seen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IGMP_V2_SEEN(const struct in_device *in_dev)
|
||||||
|
{
|
||||||
|
unsigned long seen;
|
||||||
|
|
||||||
|
if (IPV4_DEVCONF_ALL_RO(dev_net(in_dev->dev), FORCE_IGMP_VERSION) == 2)
|
||||||
|
return true;
|
||||||
|
if (IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 2)
|
||||||
|
return true;
|
||||||
|
seen = READ_ONCE(in_dev->mr_v2_seen);
|
||||||
|
return seen && time_before(jiffies, seen);
|
||||||
|
}
|
||||||
|
|
||||||
static int unsolicited_report_interval(struct in_device *in_dev)
|
static int unsolicited_report_interval(struct in_device *in_dev)
|
||||||
{
|
{
|
||||||
|
|
@ -954,23 +967,21 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
|
||||||
int max_delay;
|
int max_delay;
|
||||||
int mark = 0;
|
int mark = 0;
|
||||||
struct net *net = dev_net(in_dev->dev);
|
struct net *net = dev_net(in_dev->dev);
|
||||||
|
unsigned long seen;
|
||||||
|
|
||||||
if (len == 8) {
|
if (len == 8) {
|
||||||
|
seen = jiffies + READ_ONCE(in_dev->mr_qrv) * READ_ONCE(in_dev->mr_qi) +
|
||||||
|
READ_ONCE(in_dev->mr_qri);
|
||||||
if (ih->code == 0) {
|
if (ih->code == 0) {
|
||||||
/* Alas, old v1 router presents here. */
|
/* Alas, old v1 router presents here. */
|
||||||
|
|
||||||
max_delay = IGMP_QUERY_RESPONSE_INTERVAL;
|
max_delay = IGMP_QUERY_RESPONSE_INTERVAL;
|
||||||
in_dev->mr_v1_seen = jiffies +
|
WRITE_ONCE(in_dev->mr_v1_seen, seen);
|
||||||
(in_dev->mr_qrv * in_dev->mr_qi) +
|
|
||||||
in_dev->mr_qri;
|
|
||||||
group = 0;
|
group = 0;
|
||||||
} else {
|
} else {
|
||||||
/* v2 router present */
|
/* v2 router present */
|
||||||
max_delay = ih->code*(HZ/IGMP_TIMER_SCALE);
|
max_delay = ih->code*(HZ/IGMP_TIMER_SCALE);
|
||||||
in_dev->mr_v2_seen = jiffies +
|
WRITE_ONCE(in_dev->mr_v2_seen, seen);
|
||||||
(in_dev->mr_qrv * in_dev->mr_qi) +
|
|
||||||
in_dev->mr_qri;
|
|
||||||
}
|
}
|
||||||
/* cancel the interface change timer */
|
/* cancel the interface change timer */
|
||||||
WRITE_ONCE(in_dev->mr_ifc_count, 0);
|
WRITE_ONCE(in_dev->mr_ifc_count, 0);
|
||||||
|
|
@ -995,6 +1006,8 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
|
||||||
if (!max_delay)
|
if (!max_delay)
|
||||||
max_delay = 1; /* can't mod w/ 0 */
|
max_delay = 1; /* can't mod w/ 0 */
|
||||||
} else { /* v3 */
|
} else { /* v3 */
|
||||||
|
unsigned long mr_qi;
|
||||||
|
|
||||||
if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
|
if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -1015,15 +1028,16 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
|
||||||
* received value was zero, use the default or statically
|
* received value was zero, use the default or statically
|
||||||
* configured value.
|
* configured value.
|
||||||
*/
|
*/
|
||||||
in_dev->mr_qrv = ih3->qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);
|
WRITE_ONCE(in_dev->mr_qrv,
|
||||||
in_dev->mr_qi = IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL;
|
ih3->qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv));
|
||||||
|
mr_qi = IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL;
|
||||||
|
WRITE_ONCE(in_dev->mr_qi, mr_qi);
|
||||||
/* RFC3376, 8.3. Query Response Interval:
|
/* RFC3376, 8.3. Query Response Interval:
|
||||||
* The number of seconds represented by the [Query Response
|
* The number of seconds represented by the [Query Response
|
||||||
* Interval] must be less than the [Query Interval].
|
* Interval] must be less than the [Query Interval].
|
||||||
*/
|
*/
|
||||||
if (in_dev->mr_qri >= in_dev->mr_qi)
|
if (READ_ONCE(in_dev->mr_qri) >= mr_qi)
|
||||||
in_dev->mr_qri = (in_dev->mr_qi/HZ - 1)*HZ;
|
WRITE_ONCE(in_dev->mr_qri, (mr_qi/HZ - 1) * HZ);
|
||||||
|
|
||||||
if (!group) { /* general query */
|
if (!group) { /* general query */
|
||||||
if (ih3->nsrcs)
|
if (ih3->nsrcs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user