From: Stephan Wurm <stephan.wurm@a-eberle.de>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
syzbot+671e2853f9851d039551@syzkaller.appspotmail.com,
WingMan Kwok <w-kwok2@ti.com>,
Murali Karicheri <m-karicheri2@ti.com>,
MD Danish Anwar <danishanwar@ti.com>,
Jiri Pirko <jiri@nvidia.com>,
George McCollister <george.mccollister@gmail.com>
Subject: Re: [PATCH net] net: hsr: avoid potential out-of-bound access in fill_frame_info()
Date: Wed, 22 Jan 2025 11:26:41 +0100 [thread overview]
Message-ID: <Z5DH4cIqndQOyUfX@PC-LX-SteWu> (raw)
In-Reply-To: <CANn89iJ0+==pXHdMBcAXDd4MFDMvtFQhajKWWKj5kX7gU+NtTw@mail.gmail.com>
Am 21. Jan 16:35 hat Eric Dumazet geschrieben:
> On Tue, Jan 21, 2025 at 4:15 PM Stephan Wurm <stephan.wurm@a-eberle.de> wrote:
>
> > I did some additional experiments.
> e
> > First, I was able to get v6.13 running on the system, although it did
> > not fix my issue.
> >
> > Then I played around with VLAN interfaces.
> >
> > I created an explicit VLAN interface on top of the prp interface. In that
> > case the VLAN header gets transparently attached to the tx frames and
> > forwarding through the interface layers works as expected.
> >
> > It was even possible to get my application working on top of the vlan
> > interface, but it resulted in two VLAN headers - the inner from the
> > application, the outer from the vlan interface.
> >
> > So when sending vlan tagged frames directly from an application through
> > a prp interface the mac_len field does not get updated, even though the
> > VLAN protocol header is properly detected; when sending frames through
> > an explicit vlan interface, the mac_len seems to be properly parsed
> > into the skb.
> >
> > Now I am running out of ideas how to proceed.
> >
> > For the time being I would locally revert this fix, to make my
> > application working again.
> > But I can support in testing proposed solutions.
>
>
> If mac_len can not be used, we need yet another pskb_may_pull()
>
> I am unsure why hsr_get_node() is working, since it also uses skb->mac_len
>
> Please test the following patch :
>
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 87bb3a91598ee96b825f7aaff53aafb32ffe4f9..8942592130c151f2c948308e1ae16a6736822d5
> 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
> @@ -700,9 +700,11 @@ static int fill_frame_info(struct hsr_frame_info *frame,
> frame->is_vlan = true;
>
> if (frame->is_vlan) {
> - if (skb->mac_len < offsetofend(struct hsr_vlan_ethhdr, vlanhdr))
> + if (pskb_may_pull(skb,
> + skb_mac_offset(skb) +
> + offsetofend(struct hsr_vlan_ethhdr, vlanhdr)))
> return -EINVAL;
> - vlan_hdr = (struct hsr_vlan_ethhdr *)ethhdr;
> + vlan_hdr = (struct hsr_vlan_ethhdr *)skb_mac_header(skb);
> proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto;
> }
Thank you very much! With this patch (slightly modified) everything works
as expected now :)
I only needed to invert the logic in the if clause, as otherwise all
proper VLAN frames were dropped from PRP.
Here is the modified version:
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 87bb3a91598e..3491627bbaf4 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -700,9 +700,11 @@ static int fill_frame_info(struct hsr_frame_info *frame,
frame->is_vlan = true;
if (frame->is_vlan) {
- if (skb->mac_len < offsetofend(struct hsr_vlan_ethhdr, vlanhdr))
+ if (!pskb_may_pull(skb,
+ skb_mac_offset(skb) +
+ offsetofend(struct hsr_vlan_ethhdr, vlanhdr)))
return -EINVAL;
- vlan_hdr = (struct hsr_vlan_ethhdr *)ethhdr;
+ vlan_hdr = (struct hsr_vlan_ethhdr *)skb_mac_header(skb);
proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto;
}
next prev parent reply other threads:[~2025-01-22 10:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 14:43 [PATCH net] net: hsr: avoid potential out-of-bound access in fill_frame_info() Eric Dumazet
2024-11-30 22:20 ` patchwork-bot+netdevbpf
2025-01-17 11:30 ` Stephan Wurm
2025-01-17 13:22 ` Eric Dumazet
2025-01-17 14:15 ` Stephan Wurm
2025-01-17 18:14 ` Eric Dumazet
2025-01-17 18:18 ` Eric Dumazet
2025-01-20 7:31 ` Stephan Wurm
2025-01-20 12:24 ` Eric Dumazet
2025-01-21 15:14 ` Stephan Wurm
2025-01-21 15:35 ` Eric Dumazet
2025-01-22 10:26 ` Stephan Wurm [this message]
2025-01-22 10:29 ` Eric Dumazet
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=Z5DH4cIqndQOyUfX@PC-LX-SteWu \
--to=stephan.wurm@a-eberle.de \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=m-karicheri2@ti.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+671e2853f9851d039551@syzkaller.appspotmail.com \
--cc=w-kwok2@ti.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