[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH net-next 14/15] net/tls: don't BUG() on leftover length in __skb_nsg()


  • To: Mina Almasry <almasrymina@xxxxxxxxxx>
  • From: Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx>
  • Date: Mon, 19 Oct 2026 12:22:52 -0400
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DTIxUhdK5WwE/ZvzqZ/orvmnDy6Zp8KzQx6MCWL0bYU=; fh=rFkbf97nRC+gtwLHBW2vGZt53i94TA0CqB43VrFLPzI=; b=p/StDDcG+vCtC02V0aS/di2vluCTO6SezBnaEZQ6zcP5cFu1bIrT+/y9BbR0Ww3yj8 W/UdR+zh9BQ2+wcM642hjcfBd9v7UP35sjeZRRfjpIsFkesuu10Ievo23pGmA760jgXo /GRIbKzxwoQIJqzUv+aiqx3y7GlEGNLIi3fHyyZoV3LWxILjc1mcXyQh+gZsvEjdZhCW 3hwheSVVWQlO1OEfaCWTTaY40lZ8LgYdQzrxsFQg+qiROmQktaUlyoc9n/lLn/KuuEmv RbXif6kIWX0JAH5SJJerJmvP7ZwfOkE+gzxmG/IXwtEgBDdlwKxfNuuCPNDpYd4WLVNx B+4g==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1792427014; cv=none; d=google.com; s=arc-20260327; b=QfqtTApkJDj2muIa0sVhieDxvFmlOp1ysb53on+xUOVGam3A08+68cc+7EyJPQwuNn nbomLr8PpwT+r1XQb1ke4FzALXdP/ragyyyApl8E5xAIGRlONT84usqmK1gQ4jophJpE j19AClpUaHMIpR/SLniVrxQBIm/EQjPqX7PsQMLJZa5GFpv1WyO5mEfBp+Tuo0X+30f8 iO1TO1xVXhq6ArGdt1ofKj6z2oO+TehOvN8GxN+g/c6pY6LwnouNwPqU4Ssl3SmFdoDh z/SG2xlttooHvcVKc44rT5qmVOVEnr3LUhGcHqz0lT0hM/gLSDLHFH743ZTei0ywy3C/ YmDQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: Josef Bacik <josef@xxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, Eric Dumazet <edumazet@xxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Paolo Abeni <pabeni@xxxxxxxxxx>, Simon Horman <horms@xxxxxxxxxx>, Andrew Lunn <andrew+netdev@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Fernando Fernandez Mancera <fmancera@xxxxxxx>, David Laight <david.laight.linux@xxxxxxxxx>, netdev@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 19 Oct 2026 16:26:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Oct 19, 2026 at 11:13 AM Mina Almasry <almasrymina@xxxxxxxxxx> wrote:
>
> On Mon, Oct 19, 2026 at 6:51 AM Josef Bacik <josef@xxxxxxxxxxxxxx> wrote:
> >
> > __skb_nsg() counts the scatterlist entries for a range of an skb with a
> > copy of the __skb_to_sgvec() walk, including its BUG_ON(len) when the
> > skb runs out before the range does.  tls_decrypt_sg() calls it on the
> > same range it then passes to skb_to_sgvec(), so a bad range would BUG()
> > here before it got to skb_to_sgvec()'s error return.
> >
> > __skb_nsg() already returns -EMSGSIZE for a frag_list nested too deep,
> > and tls_decrypt_sg() fails the record on any return below 1.  Return
> > -EINVAL for the leftover length too, with a DEBUG_NET_WARN_ON_ONCE() for
> > debug kernels.
> >
> > Assisted-by: LLM
> > Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> > ---
> >  net/tls/tls_sw.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
> > index 312e51270f29..1c578ea47a1b 100644
> > --- a/net/tls/tls_sw.c
> > +++ b/net/tls/tls_sw.c
> > @@ -142,7 +142,10 @@ static int __skb_nsg(struct sk_buff *skb, int offset, 
> > int len,
> >                          start = end;
> >                  }
> >          }
> > -        BUG_ON(len);
> > +       if (unlikely(len)) {
> > +               DEBUG_NET_WARN_ON_ONCE(1);
> > +               return -EINVAL;
> > +       }
>
> Ugh, why DEBUG_NET_WARN...? Seems WARN_ON_ONCE() is more appropriate,
> after all we're downgrading from a BUG_ON(). Another nice thing is
> that it could have been done inline:

Because that still triggers on systems with panic_on_warn. See also

https://lore.kernel.org/all/willemdebruijn.kernel.140f4eac91ab3@xxxxxxxxx/



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.