All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
@ 2018-07-12 21:53 Ernesto A. Fernández
  2018-07-12 22:55 ` Viacheslav Dubeyko
       [not found] ` <20180712153311.71495c0ea5ba0115414f5301@linux-foundation.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Ernesto A. Fernández @ 2018-07-12 21:53 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Andrew Morton, Xu, Wen

Check that the hidden directory is not NULL before using it, instead of
after.

Reported-by: Wen Xu <wen.xu@gatech.edu>
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
 fs/hfsplus/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index b5254378f011..cd017d7dbdfa 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -78,13 +78,13 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
 				cpu_to_be32(HFSP_HARDLINK_TYPE) &&
 				entry.file.user_info.fdCreator ==
 				cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
+				HFSPLUS_SB(sb)->hidden_dir &&
 				(entry.file.create_date ==
 					HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
 						create_date ||
 				entry.file.create_date ==
 					HFSPLUS_I(d_inode(sb->s_root))->
-						create_date) &&
-				HFSPLUS_SB(sb)->hidden_dir) {
+						create_date)) {
 			struct qstr str;
 			char name[32];
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
  2018-07-12 21:53 [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup() Ernesto A. Fernández
@ 2018-07-12 22:55 ` Viacheslav Dubeyko
  2018-08-21 23:05   ` Andrew Morton
       [not found] ` <20180712153311.71495c0ea5ba0115414f5301@linux-foundation.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Viacheslav Dubeyko @ 2018-07-12 22:55 UTC (permalink / raw)
  To: Ernesto A. Fernández; +Cc: linux-fsdevel, Andrew Morton, Xu, Wen

On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fernández wrote:
> Check that the hidden directory is not NULL before using it, instead of
> after.
> 
> Reported-by: Wen Xu <wen.xu@gatech.edu>
> Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> ---

It's really hard to understand this simple patch. I believe it makes
sense to rework the patch slightly with the goal to make it more clear.
Also, it will be great to add a short comment in the code to explain
what's wrong.

I think it makes sense to split this long check condition on something
more clear, simple and elegant.

Thanks,
Vyacheslav Dubeyko.

>  fs/hfsplus/dir.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index b5254378f011..cd017d7dbdfa 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -78,13 +78,13 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
>  				cpu_to_be32(HFSP_HARDLINK_TYPE) &&
>  				entry.file.user_info.fdCreator ==
>  				cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
> +				HFSPLUS_SB(sb)->hidden_dir &&
>  				(entry.file.create_date ==
>  					HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
>  						create_date ||
>  				entry.file.create_date ==
>  					HFSPLUS_I(d_inode(sb->s_root))->
> -						create_date) &&
> -				HFSPLUS_SB(sb)->hidden_dir) {
> +						create_date)) {
>  			struct qstr str;
>  			char name[32];
>  

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
       [not found] ` <20180712153311.71495c0ea5ba0115414f5301@linux-foundation.org>
@ 2018-07-12 23:07   ` Ernesto A. Fernández
       [not found]     ` <20180712161907.c93f4e70e5d406fd3d2d373e@linux-foundation.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Ernesto A. Fernández @ 2018-07-12 23:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-fsdevel, Xu, Wen

On Thu, Jul 12, 2018 at 03:33:11PM -0700, Andrew Morton wrote:
> On Thu, 12 Jul 2018 18:53:47 -0300 Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> wrote:
> 
> > Check that the hidden directory is not NULL before using it, instead of
> > after.
> > 
> 
> Under what circumstances does the crash happen?  Mount of a corrupted fs?

No, when looking up corrupted catalog data (dentry) on a filesystem with
no metadata directory (this could only ever happen on a read-only mount).
Wen Xu sent the replication steps in detail to the fsdevel list, here is
a link:

https://bugzilla.kernel.org/show_bug.cgi?id=200297

I did not explain this because I think the diff makes it clear that there
is a bug at least.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
       [not found]     ` <20180712161907.c93f4e70e5d406fd3d2d373e@linux-foundation.org>
@ 2018-07-12 23:23       ` Ernesto A. Fernández
  0 siblings, 0 replies; 8+ messages in thread
From: Ernesto A. Fernández @ 2018-07-12 23:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-fsdevel, Xu, Wen

On Thu, Jul 12, 2018 at 04:19:07PM -0700, Andrew Morton wrote:
> On Thu, 12 Jul 2018 20:07:51 -0300 Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> wrote:
> 
> > On Thu, Jul 12, 2018 at 03:33:11PM -0700, Andrew Morton wrote:
> > > On Thu, 12 Jul 2018 18:53:47 -0300 Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> wrote:
> > > 
> > > > Check that the hidden directory is not NULL before using it, instead of
> > > > after.
> > > > 
> > > 
> > > Under what circumstances does the crash happen?  Mount of a corrupted fs?
> > 
> > No, when looking up corrupted catalog data (dentry) on a filesystem with
> > no metadata directory (this could only ever happen on a read-only mount).
> > Wen Xu sent the replication steps in detail to the fsdevel list, here is
> > a link:
> > 
> > https://bugzilla.kernel.org/show_bug.cgi?id=200297
> > 
> > I did not explain this because I think the diff makes it clear that there
> > is a bug at least.
> 
> It is important that we know what circumstances lead to the bug being
> triggered, so that people can decide whether to backport the fix into
> their various kernels.
> 

OK, I'll resend with more details.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
  2018-07-12 22:55 ` Viacheslav Dubeyko
@ 2018-08-21 23:05   ` Andrew Morton
  2018-08-22 18:46     ` Ernesto A. Fernández
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2018-08-21 23:05 UTC (permalink / raw)
  To: Viacheslav Dubeyko; +Cc: Ernesto A. Fernández, linux-fsdevel, Xu, Wen

On Thu, 12 Jul 2018 15:55:33 -0700 Viacheslav Dubeyko <slava@dubeyko.com> wrote:

> On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fern�ndez wrote:
> > Check that the hidden directory is not NULL before using it, instead of
> > after.
> > 
> > Reported-by: Wen Xu <wen.xu@gatech.edu>
> > Signed-off-by: Ernesto A. Fern�ndez <ernesto.mnd.fernandez@gmail.com>
> > ---
> 
> It's really hard to understand this simple patch. I believe it makes
> sense to rework the patch slightly with the goal to make it more clear.
> Also, it will be great to add a short comment in the code to explain
> what's wrong.
> 
> I think it makes sense to split this long check condition on something
> more clear, simple and elegant.

No response, causing this patch to be stuck in limbo land?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
  2018-08-21 23:05   ` Andrew Morton
@ 2018-08-22 18:46     ` Ernesto A. Fernández
  2018-08-22 20:18       ` Viacheslav Dubeyko
  0 siblings, 1 reply; 8+ messages in thread
From: Ernesto A. Fernández @ 2018-08-22 18:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Viacheslav Dubeyko, linux-fsdevel, Xu, Wen

On Tue, Aug 21, 2018 at 04:05:25PM -0700, Andrew Morton wrote:
> On Thu, 12 Jul 2018 15:55:33 -0700 Viacheslav Dubeyko <slava@dubeyko.com> wrote:
> 
> > On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fernández wrote:
> > > Check that the hidden directory is not NULL before using it, instead of
> > > after.
> > > 
> > > Reported-by: Wen Xu <wen.xu@gatech.edu>
> > > Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> > > ---
> > 
> > It's really hard to understand this simple patch. I believe it makes
> > sense to rework the patch slightly with the goal to make it more clear.
> > Also, it will be great to add a short comment in the code to explain
> > what's wrong.

I don't think it's reasonable to expect a comment explaining why we can't
dereference NULL.

> > I think it makes sense to split this long check condition on something
> > more clear, simple and elegant.

The long check condition may not be ideal, but there's a lot of code in
the module that could use style improvements. I don't think that should be
a priority right now, with plenty of serious bugs left to fix.

> 
> No response, causing this patch to be stuck in limbo land?

I believe I sent a second version of this patch.


Ernest

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
  2018-08-22 18:46     ` Ernesto A. Fernández
@ 2018-08-22 20:18       ` Viacheslav Dubeyko
  2018-08-22 21:38         ` Ernesto A. Fernández
  0 siblings, 1 reply; 8+ messages in thread
From: Viacheslav Dubeyko @ 2018-08-22 20:18 UTC (permalink / raw)
  To: Ernesto A. Fernández; +Cc: Andrew Morton, linux-fsdevel, Xu, Wen

On Wed, 2018-08-22 at 15:46 -0300, Ernesto A. Fernández wrote:
> On Tue, Aug 21, 2018 at 04:05:25PM -0700, Andrew Morton wrote:
> > On Thu, 12 Jul 2018 15:55:33 -0700 Viacheslav Dubeyko <slava@dubeyko.com> wrote:
> > 
> > > On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fernández wrote:
> > > > Check that the hidden directory is not NULL before using it, instead of
> > > > after.
> > > > 
> > > > Reported-by: Wen Xu <wen.xu@gatech.edu>
> > > > Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> > > > ---
> > > 
> > > It's really hard to understand this simple patch. I believe it makes
> > > sense to rework the patch slightly with the goal to make it more clear.
> > > Also, it will be great to add a short comment in the code to explain
> > > what's wrong.
> 
> I don't think it's reasonable to expect a comment explaining why we can't
> dereference NULL.
> 

The good comment is always really important part of the patch.

> > > I think it makes sense to split this long check condition on something
> > > more clear, simple and elegant.
> 
> The long check condition may not be ideal, but there's a lot of code in
> the module that could use style improvements. I don't think that should be
> a priority right now, with plenty of serious bugs left to fix.
> 

Bad style of code is one of the reason of bugs. If you don't try to
improve the code then you can simply create an another serious bug and
nobody will be able to understand your fix. The bad style of code in the
module is not the excuse at all. It's the way of open-source community
to achieve the good style of code by means of the discussion. Moreover,
the goal of bug fix is the improvement of code style too but not only to
resolve the issue. Another guys need to understand your way of the fix
too.

Thanks,
Vyacheslav Dubeyko.

> > 
> > No response, causing this patch to be stuck in limbo land?
> 
> I believe I sent a second version of this patch.
> 
> 
> Ernest

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()
  2018-08-22 20:18       ` Viacheslav Dubeyko
@ 2018-08-22 21:38         ` Ernesto A. Fernández
  0 siblings, 0 replies; 8+ messages in thread
From: Ernesto A. Fernández @ 2018-08-22 21:38 UTC (permalink / raw)
  To: Viacheslav Dubeyko; +Cc: Andrew Morton, linux-fsdevel, Xu, Wen

On Wed, Aug 22, 2018 at 01:18:39PM -0700, Viacheslav Dubeyko wrote:
> On Wed, 2018-08-22 at 15:46 -0300, Ernesto A. Fernández wrote:
> > On Tue, Aug 21, 2018 at 04:05:25PM -0700, Andrew Morton wrote:
> > > On Thu, 12 Jul 2018 15:55:33 -0700 Viacheslav Dubeyko <slava@dubeyko.com> wrote:
> > > 
> > > > On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fernández wrote:
> > > > > Check that the hidden directory is not NULL before using it, instead of
> > > > > after.
> > > > > 
> > > > > Reported-by: Wen Xu <wen.xu@gatech.edu>
> > > > > Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> > > > > ---
> > > > 
> > > > It's really hard to understand this simple patch. I believe it makes
> > > > sense to rework the patch slightly with the goal to make it more clear.
> > > > Also, it will be great to add a short comment in the code to explain
> > > > what's wrong.
> > 
> > I don't think it's reasonable to expect a comment explaining why we can't
> > dereference NULL.
> > 
> 
> The good comment is always really important part of the patch.

That's your idea of a good comment?

> > > > I think it makes sense to split this long check condition on something
> > > > more clear, simple and elegant.
> > 
> > The long check condition may not be ideal, but there's a lot of code in
> > the module that could use style improvements. I don't think that should be
> > a priority right now, with plenty of serious bugs left to fix.
> > 
> 
> Bad style of code is one of the reason of bugs. If you don't try to
> improve the code then you can simply create an another serious bug and
> nobody will be able to understand your fix.

All this does is reorder a check. Where could I possibly introduce a bug?

Large unnecessary rewrites with little testing in unmaintained code are far
more likely to cause trouble. I will be more comfortable with such things
once I get the module to pass xfstests, but there's still plenty of bugs in
the way.

> The bad style of code in the
> module is not the excuse at all. It's the way of open-source community
> to achieve the good style of code by means of the discussion. Moreover,
> the goal of bug fix is the improvement of code style too but not only to
> resolve the issue. Another guys need to understand your way of the fix
> too.

This patch couldn't be any simpler. Anybody who finds it confusing would be
completely overwhelmed by a big rewrite.

> Thanks,
> Vyacheslav Dubeyko.
> 
> > > 
> > > No response, causing this patch to be stuck in limbo land?
> > 
> > I believe I sent a second version of this patch.
> > 
> > 
> > Ernest
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-23  1:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 21:53 [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup() Ernesto A. Fernández
2018-07-12 22:55 ` Viacheslav Dubeyko
2018-08-21 23:05   ` Andrew Morton
2018-08-22 18:46     ` Ernesto A. Fernández
2018-08-22 20:18       ` Viacheslav Dubeyko
2018-08-22 21:38         ` Ernesto A. Fernández
     [not found] ` <20180712153311.71495c0ea5ba0115414f5301@linux-foundation.org>
2018-07-12 23:07   ` Ernesto A. Fernández
     [not found]     ` <20180712161907.c93f4e70e5d406fd3d2d373e@linux-foundation.org>
2018-07-12 23:23       ` Ernesto A. Fernández

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.