From: Heiko Carstens <hca@linux.ibm.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 5/5] s390/hmcdrv: Replace page allocator calls with k[mz]alloc()
Date: Wed, 18 Nov 2026 15:26:21 +0100 [thread overview]
Message-ID: <20261118142621.14542C9f-hca@linux.ibm.com> (raw)
In-Reply-To: <avxMOsbgkaC_kQA_@kernel.org>
On Tue, Nov 17, 2026 at 02:44:42PM +0200, Mike Rapoport wrote:
> > > int hmcdrv_cache_startup(size_t cachesize)
> > > {
> > > + if (cachesize > KMALLOC_MAX_SIZE)
> > > + return -ENOMEM;
> >
> > What is the reason for this check? I can see that this seems to be a
> > common pattern, however the buddy allocator would warn as well for
> > allocations larger than MAX_PAGE_ORDER if I'm not mistaken.
>
> Since cachesize is a module parameter there's a very corner case when it
> could have value within a page of ULONG_MAX. Then round_up() wraps to 0 and
> kmalloc(0) returns ZERO_SIZE_PTR rather than NULL and does not warn.
>
> The module would load with a bogus cache instead of failing as it does now.
>
> While it's really unlikely to happen in practice I'm sure Sashiko will be
> unhappy without this check :)
Ok, then let's keep that.
> > > + if (!ftp.len || ftp.len > KMALLOC_MAX_SIZE)
> > > + return -ENOMEM;
> >
> > Same here, and as far as I can tell the Sashiko finding seems to be
> > valid as well, even though it looks to me as if this worked only by
> > accident. Also, as far as I can see, the reported "delete" command is
> > currently not used at all from the only existing user space
> > application that I'm aware of. But let's not change this, please.
>
> Sashiko is wrong about get_order(0) returning 0, it actually returns 52, so
> __get_free_pages() returns NULL and we end up with -ENOMEM anyway :)
Yes, indeed.
> So it's either keep if (!ftp.len) and let it fail for "delete" like it does
> today or have
>
> size = round_up(ftp.len, PAGE_SIZE) ? : PAGE_SIZE;
>
> and allocate at least a page for ftp.len == 0.
>
> What's your preference?
Then let's keep the code as it is.
> The ftp.len > KMALLOC_MAX_SIZE check seems bogus indeed.
This can be removed when applying - no need to send a new version.
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
prev parent reply other threads:[~2026-11-18 14:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 8:48 [PATCH 0/5] s390/char: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-08 8:48 ` [PATCH 1/5] s390/zcore: Replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-11-09 8:54 ` sashiko-bot
2026-11-16 13:10 ` Heiko Carstens
2026-11-08 8:48 ` [PATCH 2/5] s390/vmur: " Mike Rapoport (Microsoft)
2026-11-09 8:54 ` sashiko-bot
2026-11-16 13:12 ` Heiko Carstens
2026-11-08 8:49 ` [PATCH 3/5] s390/vmlogrdr: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-11-09 8:54 ` sashiko-bot
2026-11-16 13:14 ` Heiko Carstens
2026-11-08 8:49 ` [PATCH 4/5] s390/uvdevice: " Mike Rapoport (Microsoft)
2026-11-09 8:54 ` sashiko-bot
2026-11-16 13:15 ` Heiko Carstens
2026-11-08 8:49 ` [PATCH 5/5] s390/hmcdrv: Replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-09 8:54 ` sashiko-bot
2026-11-16 13:46 ` Heiko Carstens
2026-11-17 12:44 ` Mike Rapoport
2026-11-18 14:26 ` Heiko Carstens [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=20261118142621.14542C9f-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=svens@linux.ibm.com \
--cc=vbabka@kernel.org \
/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