* + mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch added to -mm tree
@ 2022-01-27 2:55 akpm
2022-01-27 15:45 ` Manfred Spraul
0 siblings, 1 reply; 3+ messages in thread
From: akpm @ 2022-01-27 2:55 UTC (permalink / raw)
To: 1vier1, arnd, cgel.zte, chi.minghao, dbueso, manfred, mhocko,
mm-commits, rdunlap, shakeelb, stable, unixbhaskar, urezki, vvs,
zealci
The patch titled
Subject: mm/util.c: make kvfree() safe for calling while holding spinlocks
has been added to the -mm tree. Its filename is
mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Manfred Spraul <manfred@colorfullife.com>
Subject: mm/util.c: make kvfree() safe for calling while holding spinlocks
One codepath in find_alloc_undo() calls kvfree() while holding a spinlock.
Since vfree() can sleep this is a bug.
Previously, the code path used kfree(), and kfree() is safe to be called
while holding a spinlock.
Minghao proposed to fix this by updating find_alloc_undo().
Alternate proposal to fix this: Instead of changing find_alloc_undo(),
change kvfree() so that the same rules as for kfree() apply: Having
different rules for kfree() and kvfree() just asks for bugs.
Disadvantage: Releasing vmalloc'ed memory will be delayed a bit.
Link: https://lkml.kernel.org/r/20211222194828.15320-1-manfred@colorfullife.com
Link: https://lore.kernel.org/all/20211222081026.484058-1-chi.minghao@zte.com.cn/
Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation")
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Reported-by: Zeal Robot <zealci@zte.com.cn>
Reported-by: Minghao Chi <chi.minghao@zte.com.cn>
Cc: Vasily Averin <vvs@virtuozzo.com>
Cc: CGEL ZTE <cgel.zte@gmail.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Uladzislau Rezki <urezki@gmail.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: <1vier1@web.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/mm/util.c~mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks
+++ a/mm/util.c
@@ -603,12 +603,12 @@ EXPORT_SYMBOL(kvmalloc_node);
* It is slightly more efficient to use kfree() or vfree() if you are certain
* that you know which one to use.
*
- * Context: Either preemptible task context or not-NMI interrupt.
+ * Context: Any context except NMI interrupt.
*/
void kvfree(const void *addr)
{
if (is_vmalloc_addr(addr))
- vfree(addr);
+ vfree_atomic(addr);
else
kfree(addr);
}
_
Patches currently in -mm which might be from manfred@colorfullife.com are
mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: + mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch added to -mm tree
2022-01-27 2:55 + mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch added to -mm tree akpm
@ 2022-01-27 15:45 ` Manfred Spraul
2022-01-27 22:04 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2022-01-27 15:45 UTC (permalink / raw)
To: akpm, 1vier1, arnd, cgel.zte, chi.minghao, dbueso, mhocko,
mm-commits, rdunlap, shakeelb, stable, unixbhaskar, urezki, vvs,
zealci
Hi Andrew,
On 1/27/22 03:55, akpm@linux-foundation.org wrote:
> The patch titled
> Subject: mm/util.c: make kvfree() safe for calling while holding spinlocks
> has been added to the -mm tree. Its filename is
> mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
>
> This patch should soon appear at
> https://ozlabs.org/~akpm/mmots/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
> and later at
> https://ozlabs.org/~akpm/mmotm/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
Please drop and replace with
https://marc.info/?l=linux-kernel&m=164132744522325&w=2
If I should rediff/resend, just ping me.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: + mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch added to -mm tree
2022-01-27 15:45 ` Manfred Spraul
@ 2022-01-27 22:04 ` Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2022-01-27 22:04 UTC (permalink / raw)
To: Manfred Spraul
Cc: 1vier1, arnd, cgel.zte, chi.minghao, dbueso, mhocko, mm-commits,
rdunlap, shakeelb, stable, unixbhaskar, urezki, vvs, zealci
On Thu, 27 Jan 2022 16:45:58 +0100 Manfred Spraul <manfred@colorfullife.com> wrote:
> Hi Andrew,
>
> On 1/27/22 03:55, akpm@linux-foundation.org wrote:
> > The patch titled
> > Subject: mm/util.c: make kvfree() safe for calling while holding spinlocks
> > has been added to the -mm tree. Its filename is
> > mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
> >
> > This patch should soon appear at
> > https://ozlabs.org/~akpm/mmots/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
> > and later at
> > https://ozlabs.org/~akpm/mmotm/broken-out/mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch
>
> Please drop and replace with
>
> https://marc.info/?l=linux-kernel&m=164132744522325&w=2
>
Ah, OK, that's been in -mm and -next for a month. I didn't send it
upstream because it wasn't clear to me which way we're going. I'll add
cc:stable and send it to Linus this week or next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-27 22:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 2:55 + mm-utilc-make-kvfree-safe-for-calling-while-holding-spinlocks.patch added to -mm tree akpm
2022-01-27 15:45 ` Manfred Spraul
2022-01-27 22:04 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).