From: Hangbin Liu <hangbin.liu@linux.dev>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH net 4/4] drop_monitor: fix out-of-bounds write in reset_per_cpu_data()
Date: Fri, 11 Sep 2026 18:02:33 +0800 [thread overview]
Message-ID: <aqPRufC2SefOtiB4@fedora> (raw)
In-Reply-To: <20260910204612.3762015-5-edumazet@google.com>
On Thu, Sep 10, 2026 at 08:46:12PM +0000, Eric Dumazet wrote:
> In reset_per_cpu_data(), al is computed as:
>
> al = sizeof(struct net_dm_alert_msg);
> al += dm_hit_limit * sizeof(struct net_dm_drop_point);
> al += sizeof(struct nlattr);
>
> skb = genlmsg_new(al, GFP_KERNEL);
> ...
> nla = nla_reserve(skb, NLA_UNSPEC, sizeof(struct net_dm_alert_msg));
> ...
> msg = nla_data(nla);
> memset(msg, 0, al);
>
> Because al includes sizeof(struct nlattr) (the 4-byte attribute header),
> genlmsg_new() allocates al bytes of tailroom starting at nla.
> However, msg points to nla_data(nla), which is located
> sizeof(struct nlattr) bytes past nla. Calling memset(msg, 0, al)
> therefore writes al bytes starting from msg, exceeding the allocated
> buffer by sizeof(struct nlattr) (4 bytes) and corrupting
> skb_shared_info.
>
> Fix this by letting al represent only the payload length, allocating
> the skb with genlmsg_new(nla_total_size(al), GFP_KERNEL), and zeroing
> al bytes from msg.
>
> Fixes: 683703a26e46 ("drop_monitor: Update netlink protocol to include netlink attribute header in alert message")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/core/drop_monitor.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
> index 795c15dd1771a2a5f15e109d0ef2eed967c45443..edc660778408e1bb996124be5a5349dfc9be3568 100644
> --- a/net/core/drop_monitor.c
> +++ b/net/core/drop_monitor.c
> @@ -141,9 +141,8 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
>
> al = sizeof(struct net_dm_alert_msg);
> al += dm_hit_limit * sizeof(struct net_dm_drop_point);
> - al += sizeof(struct nlattr);
>
> - skb = genlmsg_new(al, GFP_KERNEL);
> + skb = genlmsg_new(nla_total_size(al), GFP_KERNEL);
>
> if (!skb)
> goto err;
> --
> 2.55.0.1007.g17ff1f9808-goog
>
Yes, nla_total_size is safer.
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
next prev parent reply other threads:[~2026-09-11 10:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 20:46 [PATCH net 0/4] net: drop_monitor: fix concurrency issues, preemption warning, and buffer overrun Eric Dumazet
2026-09-10 20:46 ` [PATCH net 1/4] drop_monitor: synchronize tracepoint unregistration on error path Eric Dumazet
2026-09-11 9:46 ` Hangbin Liu
2026-09-10 20:46 ` [PATCH net 2/4] drop_monitor: use timer_shutdown_sync() to prevent timer rearming during teardown Eric Dumazet
2026-09-11 9:57 ` Hangbin Liu
2026-09-10 20:46 ` [PATCH net 3/4] drop_monitor: use raw_cpu_ptr() in tracepoint probes Eric Dumazet
2026-09-10 20:46 ` [PATCH net 4/4] drop_monitor: fix out-of-bounds write in reset_per_cpu_data() Eric Dumazet
2026-09-11 10:02 ` Hangbin Liu [this message]
2026-09-11 21:08 ` netdev-bot+sashiko
2026-09-12 14:46 ` Eric Dumazet
2026-09-16 1:10 ` [PATCH net 0/4] net: drop_monitor: fix concurrency issues, preemption warning, and buffer overrun patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aqPRufC2SefOtiB4@fedora \
--to=hangbin.liu@linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox