[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: Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx>
  • From: Mina Almasry <almasrymina@xxxxxxxxxx>
  • Date: Mon, 19 Oct 2026 09:27:27 -0700
  • 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=jvYDp8Hgj7nrDsJX6hOppStmzsVdbwBuZBD84+051RI=; fh=lkB1jETwqzF5ls4xj6Ut4H3anCNEvkrGVOdtIp6ydo8=; b=HqpTBeQ8EiIacWF3aLmoAu2Jct5dA68H5koZ/MsACoay/GHrQFmAmAyn9Q4RPIpWbL BjeS5+7WWY4ncqkwDA7nzSP0B/t0vkeZlDMkSzaitKynGZzYlkwm7KuU7SGKAG7ldkCD EpFaA9FM5a/wcn0uTYhHS4PgGfxgDO52K5ITeH0F1NBw+R5Gjw/11mhag5BG1zehRtpt DMRhBoIBmzG6OqF5bgoXMtAO7OQJbF00DlVM8C+IorcJID9KFO1bCngKjiY2HUAkATco 2cbU5LyvwP6gELLSBlv5vSO91ikZBjKyYO/Ysrs4lDUpFZbOL+XvjeQkXc9hvhvBAf4Q AVTw==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1792427259; cv=none; d=google.com; s=arc-20260327; b=cdrWEL0DacxN36iZehZzgosNWLLpVWvwUXp7yPNKc/U9B2KTGdWB1YGFbMOJb8mi++ g0G1yWeLcNMxW/yiOhZOAI6dGEW+ep9AEa08WPtBQGmO3w+JD6qUagCZ+6uMYlI5QPaq 99L0kMYj5IsDZoD5C3cuovS+bu8S7+W+Kt6V5nVY23IQSySbyiw2EfTs+0uOCST4gn7d XW972dvW8L6yFzlDT4hqLumOm8A0PgA3hqu//11fPWEF1WDUAtpRA/EQZz1SJqYYso3l a1VO4LdefeMkduJoFjUS2j9OJ8G2yFJU/5cmNbB/wjxjTbeezgaLjMKL40oeRRu0iiLu xsXQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=google.com header.i="@google.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:27:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Oct 19, 2026 at 9:23 AM Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
>
> 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/

Heh, looks like we have the opposite instincts here and I missed the
initial conversation. DEBUG_NET_WARN_ is fine by me too. Thanks!

-- 
Thanks,
Mina



 


Rackspace

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