mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Kriish Sharma <kriish.sharma2006@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, willemb@google.com,
	kerneljasonxing@gmail.com, martin.lau@kernel.org, mhal@rbox.co,
	almasrymina@google.com, ebiggers@google.com,
	aleksander.lobakin@intel.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	syzbot+5a2250fd91b28106c37b@syzkaller.appspotmail.com
Subject: Re: [PATCH] net: skb: guard kmalloc_reserve() against oversized allocations
Date: Sat, 20 Sep 2025 17:38:37 +0200	[thread overview]
Message-ID: <34a4e8db-b0b8-4ad8-b8a2-bdfd69cc8b00@lunn.ch> (raw)
In-Reply-To: <20250920113723.380498-1-kriish.sharma2006@gmail.com>

On Sat, Sep 20, 2025 at 11:37:23AM +0000, Kriish Sharma wrote:
> Add an explicit size check in kmalloc_reserve() to reject requests
> larger than KMALLOC_MAX_SIZE before they reach the allocator.
> 
> syzbot reported warnings triggered by attempts to allocate buffers
> with an object size exceeding KMALLOC_MAX_SIZE. While the existing
> code relies on kmalloc() failure and a comment states that truncation
> is "harmless", in practice this causes high-order allocation warnings
> and noisy kernel logs that interfere with testing.
> 
> This patch introduces an early guard in kmalloc_reserve() that returns
> NULL if obj_size exceeds KMALLOC_MAX_SIZE. This ensures impossible
> requests fail fast and silently, avoiding allocator warnings while
> keeping the intended semantics unchanged.

What is the value of KMALLOC_MAX_SIZE? Do we actually want a
warn_once() here because it indicates a driver bug, or missing
validation of user space parameters?

	   Andrew

      reply	other threads:[~2025-09-20 15:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-20 11:37 Kriish Sharma
2025-09-20 15:38 ` Andrew Lunn [this message]

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=34a4e8db-b0b8-4ad8-b8a2-bdfd69cc8b00@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=aleksander.lobakin@intel.com \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kriish.sharma2006@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=mhal@rbox.co \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+5a2250fd91b28106c37b@syzkaller.appspotmail.com \
    --cc=willemb@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

all inboxes | Powered by JetHome®