From: Leon Romanovsky <leon@kernel.org>
To: Feng Wang <wangfe@google.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
netdev@vger.kernel.org, antony.antony@secunet.com
Subject: Re: [PATCH] xfrm: add SA information to the offloaded packet
Date: Thu, 29 Aug 2024 13:38:46 +0300 [thread overview]
Message-ID: <20240829103846.GE26654@unreal> (raw)
In-Reply-To: <CADsK2K-mnrz8TV-8-BvBU0U9DDzJhZF2GGM22vgA6GMpvK556w@mail.gmail.com>
On Wed, Aug 28, 2024 at 02:25:22PM -0700, Feng Wang wrote:
> Hi Leon,
Please don't top-post your replies when you are replying to a mailing
list. It makes it hard to follow the conversation.
>
> Thank you for your insightful questions and comments.
>
> Just like in crypto offload mode, now pass SA (Security Association)
> information to the driver in packet offload mode. This helps the
> driver quickly identify the packet's source and destination, rather
> than having to parse the packet itself. The xfrm interface ID is
> especially useful here. As you can see in the kernel code
> (https://elixir.bootlin.com/linux/v6.10/source/net/xfrm/xfrm_policy.c#L1993),
> it's used to differentiate between various policies in complex network
> setups.
Which in-kernel driver use this information?
>
> During my testing of packet offload mode without the patch, I observed
> that the sec_path was NULL. Consequently, xo was also NULL when
> validate_xmit_xfrm was called, leading to an immediate return at line
> 125 (https://elixir.bootlin.com/linux/v6.10/source/net/xfrm/xfrm_device.c#L125).
It is intentional, because the packet is forwarded to HW as plain text
and it is not offloaded (doesn't have xfrm_offload()).
>
> Regarding the potential xfrm_state leak, upon further investigation,
> it may not be the case. It seems that both secpath_reset and kfree_skb
> invoke the xfrm_state_put function, which should be responsible for
> releasing the state. The call flow appears to be as follows: kfree_skb
> -> skb_release_all -> skb_release_head_state -> skb_ext_put ->
> skb_ext_put_sp -> xfrm_state_put.
You are trying to make same flow as for crypto, but it is not the same,
in crypto case secpath_reset() was called to release SKB extensions and
perform cleanup, first and only after that new xfrm_state_hold() was
called, but in new code SKB is not reset.
Thanks
>
> Please let me know if you have any further questions or concerns. I
> appreciate your valuable feedback!
>
> Feng
>
> On Wed, Aug 28, 2024 at 4:26 AM Leon Romanovsky <leon@kernel.org> wrote:
> >
> > On Wed, Aug 28, 2024 at 07:32:47AM +0200, Steffen Klassert wrote:
> > > On Thu, Aug 22, 2024 at 01:02:52PM -0700, Feng Wang wrote:
> > > > From: wangfe <wangfe@google.com>
> > > >
> > > > In packet offload mode, append Security Association (SA) information
> > > > to each packet, replicating the crypto offload implementation.
> > > > The XFRM_XMIT flag is set to enable packet to be returned immediately
> > > > from the validate_xmit_xfrm function, thus aligning with the existing
> > > > code path for packet offload mode.
> > > >
> > > > This SA info helps HW offload match packets to their correct security
> > > > policies. The XFRM interface ID is included, which is crucial in setups
> > > > with multiple XFRM interfaces where source/destination addresses alone
> > > > can't pinpoint the right policy.
> > > >
> > > > Signed-off-by: wangfe <wangfe@google.com>
> > >
> > > Applied to ipsec-next, thanks Feng!
> >
> > Stephen, can you please explain why do you think that this is correct
> > thing to do?
> >
> > There are no in-tree any drivers which is using this information, and it
> > is unclear to me how state is released and it has controversial code
> > around validity of xfrm_offload() too.
> >
> > For example:
> > + sp->olen++;
> > + sp->xvec[sp->len++] = x;
> > + xfrm_state_hold(x);
> > +
> > + xo = xfrm_offload(skb);
> > + if (!xo) { <--- previous code handled this case perfectly in validate_xmit_xfrm
> > + secpath_reset(skb);
> > + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
> > + kfree_skb(skb);
> > + return -EINVAL; <--- xfrm state leak
> > + }
> >
> >
> > Can you please revert/drop this patch for now?
> >
> > Thanks
next prev parent reply other threads:[~2024-08-29 10:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 20:02 [PATCH] xfrm: add SA information to the offloaded packet Feng Wang
2024-08-28 5:32 ` Steffen Klassert
2024-08-28 11:26 ` Leon Romanovsky
2024-08-28 21:25 ` Feng Wang
2024-08-29 10:38 ` Leon Romanovsky [this message]
2024-08-29 21:19 ` Feng Wang
2024-08-30 14:30 ` Leon Romanovsky
2024-08-31 0:27 ` Feng Wang
2024-08-31 17:36 ` Leon Romanovsky
2024-08-31 17:39 ` Leon Romanovsky
2024-09-02 7:44 ` Steffen Klassert
2024-09-02 9:44 ` Leon Romanovsky
2024-09-03 18:19 ` Feng Wang
2024-09-03 19:04 ` Leon Romanovsky
2024-09-04 17:41 ` Feng Wang
2024-09-05 7:49 ` Leon Romanovsky
2024-09-05 18:18 ` Feng Wang
2024-09-09 9:09 ` Steffen Klassert
2024-09-09 10:02 ` Steffen Klassert
2024-09-11 10:40 ` Leon Romanovsky
2024-09-11 23:43 ` Feng Wang
2024-09-16 8:10 ` Leon Romanovsky
2024-09-24 10:07 ` Steffen Klassert
2024-09-24 10:34 ` Steffen Klassert
2024-09-24 17:57 ` Feng Wang
2024-09-24 18:10 ` Steffen Klassert
2024-09-25 8:19 ` Leon Romanovsky
2024-09-25 8:29 ` Leon Romanovsky
2024-09-02 7:47 ` Steffen Klassert
-- strict thread matches above, loose matches on Subject: below --
2024-11-12 19:22 Feng Wang
2024-11-14 10:27 ` Leon Romanovsky
2024-11-18 19:28 ` Feng Wang
2024-11-19 12:51 ` Leon Romanovsky
2024-11-19 19:15 ` Feng Wang
2024-08-12 18:23 Feng Wang
2024-08-19 6:06 ` Steffen Klassert
2024-08-22 20:11 ` Feng Wang
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=20240829103846.GE26654@unreal \
--to=leon@kernel.org \
--cc=antony.antony@secunet.com \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=wangfe@google.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;
as well as URLs for NNTP newsgroup(s).