From: Linkui Xiao <redacted>
fib_nl_fill_rule() emits FRA_GOTO and FRA_L3MDEV, but
fib_rule_nlmsg_size() reserves room for neither. Its only caller,
notify_rule_change(), allocates the notification skb with that size and
treats a failure as a bug:
/* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
A rule that has both a goto target and l3mdev set needs 16 more bytes
than are reserved. nlmsg_new() rounds the allocation up through
SKB_DATA_ALIGN(), so the slack hides the mistake most of the time and
the bug stays latent, but the accounting is wrong and the notification
can still fail with -EMSGSIZE.
Reserve the two missing attributes, keeping the order used by
fib_nl_fill_rule().
Fixes: 0947c9fe56d9 ("[NET] fib_rules: goto rule action")
Fixes: 96c63fa7393d ("net: Add l3mdev rule")
Signed-off-by: Linkui Xiao <redacted>
---
net/core/fib_rules.c | 2 ++
1 file changed, 2 insertions(+)
From: David Ahern <dsahern@kernel.org> Date: 2026-09-13 01:06:15
On 9/11/26 2:12 AM, Linkui Xiao wrote:
From: Linkui Xiao <redacted>
fib_nl_fill_rule() emits FRA_GOTO and FRA_L3MDEV, but
fib_rule_nlmsg_size() reserves room for neither. Its only caller,
notify_rule_change(), allocates the notification skb with that size and
treats a failure as a bug:
/* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
not really going to fail since the size has so many attributes that are
not applicable to this rule.
quoted hunk
A rule that has both a goto target and l3mdev set needs 16 more bytes
than are reserved. nlmsg_new() rounds the allocation up through
SKB_DATA_ALIGN(), so the slack hides the mistake most of the time and
the bug stays latent, but the accounting is wrong and the notification
can still fail with -EMSGSIZE.
Reserve the two missing attributes, keeping the order used by
fib_nl_fill_rule().
Fixes: 0947c9fe56d9 ("[NET] fib_rules: goto rule action")
Fixes: 96c63fa7393d ("net: Add l3mdev rule")
Signed-off-by: Linkui Xiao <redacted>
---
net/core/fib_rules.c | 2 ++
1 file changed, 2 insertions(+)
From: Linkui Xiao <redacted>
fib_nl_fill_rule() emits FRA_GOTO and FRA_L3MDEV, but
fib_rule_nlmsg_size() reserves room for neither. Its only caller,
notify_rule_change(), allocates the notification skb with that size and
treats a failure as a bug:
/* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
not really going to fail since the size has so many attributes that are
not applicable to this rule.
You are right, the other attributes reserved in fib_rule_nlmsg_size()
already provide more than enough slack for the common case, so the
missing FRA_GOTO/FRA_L3MDEV accounting cannot actually overflow the skb.
I will drop this patch. Thanks for taking the time to review it.
Thanks,
Linkui Xiao
quoted
A rule that has both a goto target and l3mdev set needs 16 more bytes
than are reserved. nlmsg_new() rounds the allocation up through
SKB_DATA_ALIGN(), so the slack hides the mistake most of the time and
the bug stays latent, but the accounting is wrong and the notification
can still fail with -EMSGSIZE.
Reserve the two missing attributes, keeping the order used by
fib_nl_fill_rule().
Fixes: 0947c9fe56d9 ("[NET] fib_rules: goto rule action")
Fixes: 96c63fa7393d ("net: Add l3mdev rule")
Signed-off-by: Linkui Xiao <redacted>
---
net/core/fib_rules.c | 2 ++
1 file changed, 2 insertions(+)
From: Linkui Xiao <redacted>
fib_nl_fill_rule() emits FRA_GOTO and FRA_L3MDEV, but
fib_rule_nlmsg_size() reserves room for neither. Its only caller,
notify_rule_change(), allocates the notification skb with that size and
treats a failure as a bug:
/* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
not really going to fail since the size has so many attributes that are
not applicable to this rule.
You are right, the other attributes reserved in fib_rule_nlmsg_size()
already provide more than enough slack for the common case, so the
missing FRA_GOTO/FRA_L3MDEV accounting cannot actually overflow the skb.
I will drop this patch. Thanks for taking the time to review it.
Thanks,
Linkui Xiao
quoted
A rule that has both a goto target and l3mdev set needs 16 more bytes
than are reserved. nlmsg_new() rounds the allocation up through
SKB_DATA_ALIGN(), so the slack hides the mistake most of the time and
the bug stays latent, but the accounting is wrong and the notification
can still fail with -EMSGSIZE.
Reserve the two missing attributes, keeping the order used by
fib_nl_fill_rule().
Fixes: 0947c9fe56d9 ("[NET] fib_rules: goto rule action")
Fixes: 96c63fa7393d ("net: Add l3mdev rule")
Signed-off-by: Linkui Xiao <redacted>
---
net/core/fib_rules.c | 2 ++
1 file changed, 2 insertions(+)