[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230726000827.724389-1-joanbrugueram@gmail.com>
Date: Wed, 26 Jul 2023 00:08:26 +0000
From: Joan Bruguera Micó <joanbrugueram@...il.com>
To: Steven Price <steven.price@....com>
Cc: zhengqi.arch@...edance.com,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] mm: shrinkers: fix race condition on debugfs cleanup
Hmmm, indeed linux-next crashes with a null pointer dereference when
calling `ida_free(..., -1)`.
It appears to me that 69cb69ea5542 ("ida: Remove assertions that an ID was
allocated") didn't intend to make `ida_free(..., -1)` invalid; after all,
it was authored & introduced immediately after fc82bbf4dede ("ida: don't
use BUG_ON() for debugging") whose commit message calls for making it
legal, with Matthew's support.
And the referenced Bluetooth HCI code that also calls `ida_free(..., -1)`
is still there, as far as I can tell ([1]).
Rather, probably the `((int)id < 0)` was accidentally dropped, or the idea
was that it would be handled by the `not_found:` label in `ida_free`, but
for that to work you'd need to change the `!test_bit(bit, bitmap->bitmap)`
condition to `!bitmap || !test_bit(bit, bitmap->bitmap)` since otherwise
`bitmap->bitmap` is a null pointer dereference.
I will send a patch to get it fixed.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/hci_sock.c#n106
Powered by blists - more mailing lists