Netdev List
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Simon Horman <horms@kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] xfrm: fix integer overflow in xfrm_replay_state_esn_len()
Date: Wed, 22 Jan 2025 16:50:45 +0300	[thread overview]
Message-ID: <32890a3f-1258-4c03-86e1-86c0e4e8e415@stanley.mountain> (raw)
In-Reply-To: <670272e2-a4b2-4bdd-95c0-26d1e7c65816@stanley.mountain>

On Wed, Jan 22, 2025 at 04:16:48PM +0300, Dan Carpenter wrote:
> On Wed, Jan 22, 2025 at 12:39:36PM +0000, Simon Horman wrote:
> > > The one caller that I didn't modify was xfrm_sa_len().  That's a bit
> > > complicated and also I'm kind of hoping that we don't handle user
> > > controlled data in that function?  The place where we definitely are
> > > handling user data is in xfrm_alloc_replay_state_esn() and this patch
> > > fixes that.
> > 
> > Yes, that is a bit "complex".
> > 
> 
> I don't have a reason to suspect xfrm_sa_len() but if we were to write
> a paranoid version of it then I've written that draft below.  I stole
> Herbert's xfrm_kblen2klen() function[1].  Also the nlmsg_new() function
> would need to be updated as well.
> 
> https://lore.kernel.org/all/Z2KZC71JZ0QnrhfU@gondor.apana.org.au/
> 
> regards,
> dan carpenter
> 
> diff --git a/include/net/netlink.h b/include/net/netlink.h
> index e015ffbed819..ca7a8152e6d4 100644
> --- a/include/net/netlink.h
> +++ b/include/net/netlink.h
> @@ -1015,6 +1015,8 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb,
>   */
>  static inline struct sk_buff *nlmsg_new(size_t payload, gfp_t flags)
>  {
> +	if (payload > INT_MAX)
> +		return NULL;
>  	return alloc_skb(nlmsg_total_size(payload), flags);
>  }

Actually, this chunk is necessary.  Let me sent that by itself.

regards,
dan carpenter


  reply	other threads:[~2025-01-22 13:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 11:16 [PATCH net] xfrm: fix integer overflow in xfrm_replay_state_esn_len() Dan Carpenter
2025-01-22 12:39 ` Simon Horman
2025-01-22 13:16   ` Dan Carpenter
2025-01-22 13:50     ` Dan Carpenter [this message]
2025-01-22 16:53 ` kernel test robot
2025-01-30  8:16   ` Dan Carpenter
2025-01-31 20:28 ` kernel test robot

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=32890a3f-1258-4c03-86e1-86c0e4e8e415@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.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