Re: [syzbot] [mm?] WARNING in ep_write_iter
Zi Yan <[email protected]>
| Newsgroups | org.kernel.vger.linux-usb,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On 17 Aug 2026, at 11:37, Alan Stern wrote: > On Mon, Aug 17, 2026 at 11:22:47AM -0400, Zi Yan wrote: >>> Again, I disagree with some of the details of this argument in this >>> context. For instance, if all kernel developers are supposed to know >>> that they shouldn't ask kmalloc() for more than MAX_PAGE_ORDER at the >>> risk of provoking a WARN, if this is such an important restriction, then >>> shouldn't this requirement be mentioned in the kerneldoc for kmalloc()? >> >> >> kmalloc is the normal method of allocating memory >> for objects smaller than page size in the kernel. > > This means when you are allocating small objects, kmalloc is the normal > way to do it. It says nothing about what you should do when allocating > large objects. alloc_pages() or vmalloc or kvmalloc(). kmalloc() is used if you really want physically contiguous memory. > > In particular, it doesn't say that if you ask kmalloc for more than 4 MB > of memory, your system is likely to crash. Crash because panic_on_warn is set. You just conflate a sysctl config with a WARN. I understand panic_on_warn is set by many systems, but that does not mean every system crashes. Plus, if you use kvmalloc with a really large size, you also can get a WARN[1][2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/slub.c?h=v7.2#n6912 [2] https://lore.kernel.org/all/CAHk-=wiRq+_jd_O1gz3J6-ANtXMY7iLpi8XFUcmtB3rBixvUXQ@mail.gmail.com/ > >> See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/slab.h?h=v7.2#n1001 >> >> In this case, kmalloc is used to request > 4MB memory. >> >>> >>> Regardless, if it is important to let kernel developers know that their >>> code is doing something wrong, why not make the WARN conditional on >>> CONFIG_EXPERT or something similar? In other words, prevent it from >>> crashing production systems. > > You didn't respond to this. I do not get your argument here. Why does this WARN need to be conditional on CONFIG_EXPERT? What makes it special? Or you mean you want all WARNs to be conditional CONFIG_EXPERT? Anyway, if you do not want to check user input len and want core MM to do the check. I will send a patch to make kmalloc return NULL when the requested len is bigger than KMALLOC_MAX_SIZE without giving a warning, based on my discussion with Vlastimil on IRC (he is out until next week). Best Regards, Yan, Zi