ext4: added missing kfree
PATCH 1/1 ext4: added missing kfree
Added one missing kfree to fsmap.c
--- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/fsmap.c +1 -0
@@ -304,6 +304,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, fsm->fmr_length = len;list_add_tail (&fsm->fmr_list, meta_list); +kfree (fsm);return 0 ; }
Signature · 1 line
2.43.0
Quoted 12 lines · Nicolas Bretz
Added one missing kfree to
fsmap.cSigned-off-by Nicolas Bretz <[email protected]>--- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+)fs/ext4/fsmap.c +0
-0
fs/ext4/fsmap.c static inline int ext4_getfsmap_fill(struct list_head *meta_list, · line 307
Quoted 4 lines
fs/ext4/fsmap.c +1
-0@@ -304,6 +304,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, fsm->fmr_length = len;list_add_tail (&fsm->fmr_list, meta_list); +kfree (fsm);
OI: UAF, NAK.
--D
Quoted 7 lines
fs/ext4/fsmap.c +0
-0return 0 ; }Signature · 1 line
2.43.0
Quoted 17 lines · Darrick J. Wong
Quoted 15 lines · Nicolas Bretz
Added one missing kfree to
fsmap.cSigned-off-by Nicolas Bretz <[email protected]>--- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+)fs/ext4/fsmap.c +0
-0@@ -304,6 +304,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, fsm->fmr_length = len;list_add_tail (&fsm->fmr_list, meta_list);
Quoted 5 lines
fs/ext4/fsmap.c static inline int ext4_getfsmap_fill(struct list_head *meta_list, · line 307
Quoted 1 line
fs/ext4/fsmap.c +1
-0+kfree (fsm);OI: UAF, NAK.
--D
I apologize, it definitely wasn't my intention. I guess not really putting my best foot forward...
I don't yet fully get the UAF in this instance, but I'm studying it.
Quoted 8 lines
Quoted 8 lines
fs/ext4/fsmap.c +0
-1return 0 ; } --2.43.0
Theodore Ts'o
maintainerQuoted 22 lines · Nicolas Bretz
Quoted 21 lines · Darrick J. Wong
Quoted 12 lines · Nicolas Bretz
Added one missing kfree to
fsmap.cSigned-off-by Nicolas Bretz <[email protected]>--- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+)fs/ext4/fsmap.c +0
-0fs/ext4/fsmap.c static inline int ext4_getfsmap_fill(struct list_head *meta_list, · line 307
Quoted 4 lines
fs/ext4/fsmap.c +1
-0@@ -304,6 +304,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, fsm->fmr_length = len;list_add_tail (&fsm->fmr_list, meta_list); +kfree (fsm);OI: UAF, NAK.
Quoted 5 lines
Quoted 1 line
--D
I apologize, it definitely wasn't my intention. I guess not really putting my best foot forward...
I don't yet fully get the UAF in this instance, but I'm studying it.
UAF == "Use After Free"
What this function does is to allocate a data struture, and then add it to a linked list. This is what list_add_tail() does.
By adding the kfree(), this will result in the callers of ext4_getfsap_fill() trying to dereference a pointer to memory that has been freed. So your patch very cleary introduces a bug, and makes it clear you (a) don't understand what lst_add_tail() does, and (b) dont't understand what the ext4_getfsap_fill()function does, and (c) almost certainkly didn't understand how to test a particular code path and/or didn't bother to adequately test the code that you were trying to modify.
For future reference, the commit description for this patch is also not adequate. Don't replicate in English what the change in the C code is. Explain *why* the change was made; what bug were you trying to fix? Or what performance optimization were you going for? And it's often a good idea to explain how you tested your change.
Cheers,
- Ted
Quoted 50 lines · Theodore Ts'o
Quoted 22 lines · Nicolas Bretz
Quoted 21 lines · Darrick J. Wong
Quoted 12 lines · Nicolas Bretz
Added one missing kfree to
fsmap.cSigned-off-by Nicolas Bretz <[email protected]>--- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+)fs/ext4/fsmap.c +0
-0fs/ext4/fsmap.c static inline int ext4_getfsmap_fill(struct list_head *meta_list, · line 307
Quoted 4 lines
fs/ext4/fsmap.c +1
-0@@ -304,6 +304,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, fsm->fmr_length = len;list_add_tail (&fsm->fmr_list, meta_list); +kfree (fsm);OI: UAF, NAK.
Quoted 5 lines
Quoted 1 line
--D
I apologize, it definitely wasn't my intention. I guess not really putting my best foot forward...
I don't yet fully get the UAF in this instance, but I'm studying it.UAF == "Use After Free"
What this function does is to allocate a data struture, and then add it to a linked list. This is what
list_add_tail()does.By adding the
kfree(), this will result in the callers ofext4_getfsap_fill()trying to dereference a pointer to memory that has been freed. So your patch very cleary introduces a bug, and makes it clear you (a) don't understand whatlst_add_tail()does, and (b) dont't understand what the ext4_getfsap_fill()function does, and (c) almost certainkly didn't understand how to test a particular code path and/or didn't bother to adequately test the code that you were trying to modify.For future reference, the commit description for this patch is also not adequate. Don't replicate in English what the change in the C code is. Explain *why* the change was made; what bug were you trying to fix? Or what performance optimization were you going for? And it's often a good idea to explain how you tested your change.
Quoted 3 lines
Cheers,
- Ted
I thought I understood what list_add_tail() does, and also __list_add(), but obviously I was very wrong.
All your points are well taken. It was outright sloppy of me and I apologize again for the trouble I caused.
Nic