* [PATCH] ext4: added missing kfree @ 2025-05-02 17:40 Nicolas Bretz 2025-05-02 20:37 ` Darrick J. Wong 0 siblings, 1 reply; 5+ messages in thread From: Nicolas Bretz @ 2025-05-02 17:40 UTC (permalink / raw) To: linux-ext4; +Cc: tytso, jack, adilger.kernel, Nicolas Bretz Added one missing kfree to fsmap.c Signed-off-by: Nicolas Bretz <bretznic@gmail.com> --- fs/ext4/fsmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index b232c2767534..d41210abea0c 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -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; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: added missing kfree 2025-05-02 17:40 [PATCH] ext4: added missing kfree Nicolas Bretz @ 2025-05-02 20:37 ` Darrick J. Wong 2025-05-02 22:26 ` Nicolas Bretz 0 siblings, 1 reply; 5+ messages in thread From: Darrick J. Wong @ 2025-05-02 20:37 UTC (permalink / raw) To: Nicolas Bretz; +Cc: linux-ext4, tytso, jack, adilger.kernel On Fri, May 02, 2025 at 10:40:12AM -0700, Nicolas Bretz wrote: > Added one missing kfree to fsmap.c > > Signed-off-by: Nicolas Bretz <bretznic@gmail.com> > --- > fs/ext4/fsmap.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c > index b232c2767534..d41210abea0c 100644 > --- a/fs/ext4/fsmap.c > +++ b/fs/ext4/fsmap.c > @@ -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 > return 0; > } > > -- > 2.43.0 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: added missing kfree 2025-05-02 20:37 ` Darrick J. Wong @ 2025-05-02 22:26 ` Nicolas Bretz 2025-05-03 16:45 ` Theodore Ts'o 0 siblings, 1 reply; 5+ messages in thread From: Nicolas Bretz @ 2025-05-02 22:26 UTC (permalink / raw) To: Darrick J. Wong; +Cc: linux-ext4, tytso, jack, adilger.kernel On Fri, May 2, 2025 at 1:37 PM Darrick J. Wong <djwong@kernel.org> wrote: > > On Fri, May 02, 2025 at 10:40:12AM -0700, Nicolas Bretz wrote: > > Added one missing kfree to fsmap.c > > > > Signed-off-by: Nicolas Bretz <bretznic@gmail.com> > > --- > > fs/ext4/fsmap.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c > > index b232c2767534..d41210abea0c 100644 > > --- a/fs/ext4/fsmap.c > > +++ b/fs/ext4/fsmap.c > > @@ -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 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. > > > return 0; > > } > > > > -- > > 2.43.0 > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: added missing kfree 2025-05-02 22:26 ` Nicolas Bretz @ 2025-05-03 16:45 ` Theodore Ts'o 2025-05-04 0:48 ` Nicolas Bretz 0 siblings, 1 reply; 5+ messages in thread From: Theodore Ts'o @ 2025-05-03 16:45 UTC (permalink / raw) To: Nicolas Bretz; +Cc: Darrick J. Wong, linux-ext4, jack, adilger.kernel On Fri, May 02, 2025 at 03:26:22PM -0700, Nicolas Bretz wrote: > On Fri, May 2, 2025 at 1:37 PM Darrick J. Wong <djwong@kernel.org> wrote: > > > > On Fri, May 02, 2025 at 10:40:12AM -0700, Nicolas Bretz wrote: > > > Added one missing kfree to fsmap.c > > > > > > Signed-off-by: Nicolas Bretz <bretznic@gmail.com> > > > --- > > > fs/ext4/fsmap.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c > > > index b232c2767534..d41210abea0c 100644 > > > --- a/fs/ext4/fsmap.c > > > +++ b/fs/ext4/fsmap.c > > > @@ -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 > > 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: added missing kfree 2025-05-03 16:45 ` Theodore Ts'o @ 2025-05-04 0:48 ` Nicolas Bretz 0 siblings, 0 replies; 5+ messages in thread From: Nicolas Bretz @ 2025-05-04 0:48 UTC (permalink / raw) To: Theodore Ts'o; +Cc: Darrick J. Wong, linux-ext4, jack, adilger.kernel On Sat, May 3, 2025 at 9:45 AM Theodore Ts'o <tytso@mit.edu> wrote: > > On Fri, May 02, 2025 at 03:26:22PM -0700, Nicolas Bretz wrote: > > On Fri, May 2, 2025 at 1:37 PM Darrick J. Wong <djwong@kernel.org> wrote: > > > > > > On Fri, May 02, 2025 at 10:40:12AM -0700, Nicolas Bretz wrote: > > > > Added one missing kfree to fsmap.c > > > > > > > > Signed-off-by: Nicolas Bretz <bretznic@gmail.com> > > > > --- > > > > fs/ext4/fsmap.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c > > > > index b232c2767534..d41210abea0c 100644 > > > > --- a/fs/ext4/fsmap.c > > > > +++ b/fs/ext4/fsmap.c > > > > @@ -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 > > > > 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 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-04 0:49 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-02 17:40 [PATCH] ext4: added missing kfree Nicolas Bretz 2025-05-02 20:37 ` Darrick J. Wong 2025-05-02 22:26 ` Nicolas Bretz 2025-05-03 16:45 ` Theodore Ts'o 2025-05-04 0:48 ` Nicolas Bretz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox