udf: don't call mark_buffer_dirty on a null bh pointer
Subsystems (2)
PATCH 1/1 udf: don't call mark_buffer_dirty on a null bh pointer
From: Colin Ian King <[email protected]>
There is a null check on the pointer bh to avoid a null pointer dereference on bh->b_data however later bh is passed to mark_buffer_dirty that can also cause a null pointer dereference on bh. Avoid this potential null pointer dereference by moving the call to mark_buffer_dirty inside the null checked block.
--- fs/udf/super.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/udf/super.c +6 -6
@@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) lvid = (struct logicalVolIntegrityDesc *)bh->b_data;udf_finalize_lvid (lvid); - } -/* -* Blockdevice will be synced later so we don't have to submit -* the buffer for IO -*/ -mark_buffer_dirty (bh); +/* +* Blockdevice will be synced later so we don't have +* to submit the buffer for IO +*/ +mark_buffer_dirty (bh); + } sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);
Signature · 1 line
2.20.1
Quoted 10 lines · Colin King
From: Colin Ian King <[email protected]>
There is a null check on the pointer bh to avoid a null pointer dereference on
bh->b_datahowever later bh is passed tomark_buffer_dirtythat can also cause a null pointer dereference on bh. Avoid this potential null pointer dereference by moving the call tomark_buffer_dirtyinside the null checked block.Fixes e8b4274735e4 ("udf: finalize integrity descriptor before writeback")Signed-off-by Colin Ian King <[email protected]>
Thanks for the patch! In fact it is the 'if (bh)' check that's unnecessarily defensive (we cannot have sbi->s_lvid_dirty and !sbi->s_lvid_bh). So I'll just drop that check (attached patch).
Honza
Quoted 32 lines
--- fs/udf/super.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/udf/super.c +6
-6@@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) lvid = (struct logicalVolIntegrityDesc *)bh->b_data;udf_finalize_lvid (lvid); - } -/* -* Blockdevice will be synced later so we don't have to submit -* the buffer for IO -*/ -mark_buffer_dirty (bh); +/* +* Blockdevice will be synced later so we don't have +* to submit the buffer for IO +*/ +mark_buffer_dirty (bh); + } sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
From a00eb52e3f2f815efa52a9e3bf1b730d86c05faa Mon Sep 17 00:00:00 2001
From: Jan Kara <[email protected]>
Date: Tue, 19 Feb 2019 14:59:43 +0100
Subject: [PATCH] udf: Drop pointless check from udf_sync_fs()
The check if (bh) in udf_sync_fs() is pointless as we cannot have sbi->s_lvid_dirty and !sbi->s_lvid_bh (as already asserted by udf_updated_lvid()). So just drop the pointless check.
--- fs/udf/super.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
fs/udf/super.c +3 -6
@@ -2330,13 +2330,10 @@ static int udf_sync_fs(struct super_block *sb, int wait)mutex_lock (&sbi->s_alloc_mutex);if (sbi->s_lvid_dirty) {struct buffer_head *bh = sbi->s_lvid_bh; +struct logicalVolIntegrityDesc *lvid; -if (bh) { -struct logicalVolIntegrityDesc *lvid; - - lvid = (struct logicalVolIntegrityDesc *)bh->b_data; -udf_finalize_lvid (lvid); - } + lvid = (struct logicalVolIntegrityDesc *)bh->b_data; +udf_finalize_lvid (lvid);/* * Blockdevice will be synced later so we don't have to submit
Signature · 1 line
2.16.4
Steve Magnani
Reviewed-by Steven J. MagnaniQuoted 40 lines · Jan Kara
Quoted 10 lines · Colin King
From: Colin Ian King <[email protected]>
There is a null check on the pointer bh to avoid a null pointer dereference on
bh->b_datahowever later bh is passed tomark_buffer_dirtythat can also cause a null pointer dereference on bh. Avoid this potential null pointer dereference by moving the call tomark_buffer_dirtyinside the null checked block.Fixes e8b4274735e4 ("udf: finalize integrity descriptor before writeback")Signed-off-by Colin Ian King <[email protected]>Thanks for the patch! In fact it is the 'if (bh)' check that's unnecessarily defensive (we cannot have
sbi->s_lvid_dirtyand !sbi->s_lvid_bh). So I'll just drop that check (attached patch).Honza
Quoted 23 lines
--- fs/udf/super.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/udf/super.c +4
-6@@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) lvid = (struct logicalVolIntegrityDesc *)bh->b_data;udf_finalize_lvid (lvid); - } -/* -* Blockdevice will be synced later so we don't have to submit -* the buffer for IO -*/ -mark_buffer_dirty (bh); +/* +* Blockdevice will be synced later so we don't have +* to submit the buffer for IO +*/
Quoted 8 lines
Quoted 8 lines
fs/udf/super.c +2
-0+mark_buffer_dirty (bh); + } sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);Signature · 1 line
2.20.1
Doh! Thanks for the catch Colin.
------------------------------------------------------------------------
Steven J. Magnani "I claim this network for MARS! www.digidescorp.com Earthling, return my space modulator!"
#include <standard.disclaimer>
Quoted 40 lines · Steve Magnani
Quoted 39 lines · Jan Kara
Quoted 10 lines · Colin King
From: Colin Ian King <[email protected]>
There is a null check on the pointer bh to avoid a null pointer dereference on
bh->b_datahowever later bh is passed tomark_buffer_dirtythat can also cause a null pointer dereference on bh. Avoid this potential null pointer dereference by moving the call tomark_buffer_dirtyinside the null checked block.Fixes e8b4274735e4 ("udf: finalize integrity descriptor before writeback")Signed-off-by Colin Ian King <[email protected]>Thanks for the patch! In fact it is the 'if (bh)' check that's unnecessarily defensive (we cannot have
sbi->s_lvid_dirtyand !sbi->s_lvid_bh). So I'll just drop that check (attached patch).Honza
Quoted 22 lines
--- fs/udf/super.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/udf/super.c +5
-6@@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) lvid = (struct logicalVolIntegrityDesc *)bh->b_data;udf_finalize_lvid (lvid); - } -/* -* Blockdevice will be synced later so we don't have to submit -* the buffer for IO -*/ -mark_buffer_dirty (bh); +/* +* Blockdevice will be synced later so we don't have +* to submit the buffer for IO +*/ +mark_buffer_dirty (bh);
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
fs/udf/super.c +1
-0+ } sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);Signature · 1 line
2.20.1Reviewed-by Steven J. Magnani <[email protected]>
Is this Reviewed-by for my fixup or the Colin's? Because I've decided to rather remove the 'if (bh)' check completely since it is pointless...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 53 lines · Jan Kara
Quoted 42 lines · Steve Magnani
Quoted 40 lines · Jan Kara
Quoted 11 lines · Colin King
From: Colin Ian King <[email protected]>
There is a null check on the pointer bh to avoid a null pointer dereference on
bh->b_datahowever later bh is passed tomark_buffer_dirtythat can also cause a null pointer dereference on bh. Avoid this potential null pointer dereference by moving the call tomark_buffer_dirtyinside the null checked block.Fixes e8b4274735e4 ("udf: finalize integrity descriptor before writeback")Signed-off-by Colin Ian King <[email protected]>Thanks for the patch! In fact it is the 'if (bh)' check that's unnecessarily defensive (we cannot have
sbi->s_lvid_dirtyand !sbi->s_lvid_bh). So I'll just drop that check (attached patch).Honza
Quoted 22 lines
--- fs/udf/super.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/udf/super.c +5
-6@@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) lvid = (struct logicalVolIntegrityDesc *)bh->b_data;udf_finalize_lvid (lvid); - } -/* -* Blockdevice will be synced later so we don't have to submit -* the buffer for IO -*/ -mark_buffer_dirty (bh); +/* +* Blockdevice will be synced later so we don't have +* to submit the buffer for IO +*/ +mark_buffer_dirty (bh);Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
fs/udf/super.c +1
-0+ } sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);Signature · 1 line
2.20.1Reviewed-by Steven J. Magnani <[email protected]>
Quoted 5 lines
Is this Reviewed-by for my fixup or the Colin's? Because I've decided to rather remove the 'if (bh)' check completely since it is pointless...
Honza
Sorry, I realized on rereading that this could be ambiguous. The R-B is for your patch.
Steve