* [PATCH] Fixed null-ptr-deref Read in drop_buffers
@ 2024-11-08 2:37 Saru2003
2024-11-08 3:46 ` Al Viro
0 siblings, 1 reply; 2+ messages in thread
From: Saru2003 @ 2024-11-08 2:37 UTC (permalink / raw)
To: viro; +Cc: brauner, jack, linux-fsdevel, linux-kernel, Saru2003
Signed-off-by: Saru2003 <sarvesh20123@gmail.com>
---
fs/buffer.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index 1fc9a50def0b..e32420d8b9e3 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2888,14 +2888,23 @@ drop_buffers(struct folio *folio, struct buffer_head **buffers_to_free)
struct buffer_head *head = folio_buffers(folio);
struct buffer_head *bh;
+ if (!head) {
+ goto failed;
+ }
+
bh = head;
do {
+ if (!bh)
+ goto failed;
if (buffer_busy(bh))
goto failed;
bh = bh->b_this_page;
} while (bh != head);
do {
+ if (!bh)
+ goto failed;
+
struct buffer_head *next = bh->b_this_page;
if (bh->b_assoc_map)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fixed null-ptr-deref Read in drop_buffers
2024-11-08 2:37 [PATCH] Fixed null-ptr-deref Read in drop_buffers Saru2003
@ 2024-11-08 3:46 ` Al Viro
0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2024-11-08 3:46 UTC (permalink / raw)
To: Saru2003; +Cc: brauner, jack, linux-fsdevel, linux-kernel
On Fri, Nov 08, 2024 at 08:07:17AM +0530, Saru2003 wrote:
> Signed-off-by: Saru2003 <sarvesh20123@gmail.com>
> ---
> fs/buffer.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 1fc9a50def0b..e32420d8b9e3 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -2888,14 +2888,23 @@ drop_buffers(struct folio *folio, struct buffer_head **buffers_to_free)
> struct buffer_head *head = folio_buffers(folio);
> struct buffer_head *bh;
>
> + if (!head) {
> + goto failed;
> + }
Which caller can hit that?
> bh = head;
> do {
> + if (!bh)
> + goto failed;
Huh? How the hell can _that_ happen? "Somehow got called for a folio
without associated buffer_heads" is one thing, but this would require
an obvious memory corruption; a NULL forward pointer in the middle of
a cyclic list.
> if (buffer_busy(bh))
> goto failed;
> bh = bh->b_this_page;
> } while (bh != head);
>
> do {
> + if (!bh)
> + goto failed;
NAK. In the best case you are papering over unrelated memory corruption.
Please, explain what's going on. Random checks for pointers being NULL
are not magical unicorn piss to be sprinkled all over the place...
And "fixed null-pointer-deref" does *not* work as an explanation - not
with otherwise empty commit message.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-08 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 2:37 [PATCH] Fixed null-ptr-deref Read in drop_buffers Saru2003
2024-11-08 3:46 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox