From: Hangbin Liu <liuhangbin@gmail.com>
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,
Tangxin Xie <xietangxin@h-partners.com>
Subject: Re: [PATCH net] macvlan: inherit needed_headroom and needed_tailroom from lowerdev
Date: Fri, 7 Aug 2026 14:21:22 +0800 [thread overview]
Message-ID: <anV5Cu3V6UF2Ilqe@fedora> (raw)
In-Reply-To: <20260806141938.287660-1-edumazet@google.com>
On 06.08.2026 14:19, Eric Dumazet wrote:
>macvlan devices inherit hard_header_len from lowerdev during macvlan_init(),
>but leave needed_headroom and needed_tailroom set to 0.
>
>When the underlying lowerdev requires extra headroom or tailroom for
>headers/trailers (e.g. macsec, ipsec, wireguard, tunnels, or veth with rx
>headroom), upper layers calculating packet headroom and tailroom fail to
>reserve sufficient space.
>
>This can result in reallocation overhead, skb headroom underflows, or KASAN
>slab-use-after-free crashes when dev_hard_header() / macvlan_hard_header()
>prepends header data or when lower devices append tailroom.
>
>Fix this by:
>1. Inheriting needed_headroom and needed_tailroom from lowerdev in macvlan_init().
>2. Propagating needed_headroom and needed_tailroom updates to attached macvlans
> in macvlan_device_event() when receiving NETDEV_FEAT_CHANGE events.
>
>Fixes: b863ceb7ddce ("[NET]: Add macvlan driver")
>Reported-by: Tangxin Xie <xietangxin@h-partners.com>
>Closes: https://lore.kernel.org/netdev/CANn89i+1EW-sFNK8xoq98gMbPCeLS7e=+rs9gHfLg5Wj+4x0sw@mail.gmail.com/T/#m16adf0ff972cbfd8066c3a8e656e75eaeb12d021
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>---
> drivers/net/macvlan.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
>index c40fa331836bb2395267914807542ae5094e1a3c..ff2f4bb651b74cdb054f245ea0f4e8cfe2297193 100644
>--- a/drivers/net/macvlan.c
>+++ b/drivers/net/macvlan.c
>@@ -950,6 +950,8 @@ static int macvlan_init(struct net_device *dev)
> dev->lltx = true;
> netif_inherit_tso_max(dev, lowerdev);
> dev->hard_header_len = lowerdev->hard_header_len;
>+ dev->needed_headroom = lowerdev->needed_headroom;
>+ dev->needed_tailroom = lowerdev->needed_tailroom;
> macvlan_set_lockdep_class(dev);
>
> vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
>@@ -1824,6 +1826,8 @@ static int macvlan_device_event(struct notifier_block *unused,
> case NETDEV_FEAT_CHANGE:
> list_for_each_entry(vlan, &port->vlans, list) {
> netif_inherit_tso_max(vlan->dev, dev);
>+ vlan->dev->needed_headroom = dev->needed_headroom;
>+ vlan->dev->needed_tailroom = dev->needed_tailroom;
> netdev_update_features(vlan->dev);
> }
> break;
>--
>2.55.0.629.g250fe7f194-goog
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
prev parent reply other threads:[~2026-08-07 6:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 14:19 [PATCH net] macvlan: inherit needed_headroom and needed_tailroom from lowerdev Eric Dumazet
2026-08-07 6:21 ` Hangbin Liu [this message]
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=anV5Cu3V6UF2Ilqe@fedora \
--to=liuhangbin@gmail.com \
--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 \
--cc=xietangxin@h-partners.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