Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Andreas Gruenbacher
On Wed, 24 Jul 2019 at 12:55, Steven Whitehouse wrote: > On 24/07/2019 11:27, Christoph Hellwig wrote: > > On Wed, Jul 24, 2019 at 11:22:46AM +0100, Steven Whitehouse wrote: > >> and it would have the same effect, so far as I can tell. I don't mind > >> changing it, if that is perhaps a clearer

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Steven Whitehouse
Hi, On 24/07/2019 11:27, Christoph Hellwig wrote: On Wed, Jul 24, 2019 at 11:22:46AM +0100, Steven Whitehouse wrote: and it would have the same effect, so far as I can tell. I don't mind changing it, if that is perhaps a clearer way to write the same thing, rather than >i_inode; The cleanest

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Christoph Hellwig
On Wed, Jul 24, 2019 at 11:22:46AM +0100, Steven Whitehouse wrote: > and it would have the same effect, so far as I can tell. I don't mind > changing it, if that is perhaps a clearer way to write the same thing, > rather than >i_inode; The cleanest thing is to not rely on any of that magic and

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Steven Whitehouse
Hi, On 24/07/2019 11:02, Christoph Hellwig wrote: On Wed, Jul 24, 2019 at 09:48:38AM +0100, Steven Whitehouse wrote: Hi, On 24/07/2019 09:43, Jia-Ju Bai wrote: In gfs2_alloc_inode(), when kmem_cache_alloc() on line 1724 returns NULL, ip is assigned to NULL. In this case, "return >i_inode"

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Edwin Török
On 24/07/2019 11:02, Christoph Hellwig wrote: > On Wed, Jul 24, 2019 at 09:48:38AM +0100, Steven Whitehouse wrote: >> Hi, >> >> On 24/07/2019 09:43, Jia-Ju Bai wrote: >>> In gfs2_alloc_inode(), when kmem_cache_alloc() on line 1724 returns >>> NULL, ip is assigned to NULL. In this case, "return

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Christoph Hellwig
On Wed, Jul 24, 2019 at 09:48:38AM +0100, Steven Whitehouse wrote: > Hi, > > On 24/07/2019 09:43, Jia-Ju Bai wrote: > > In gfs2_alloc_inode(), when kmem_cache_alloc() on line 1724 returns > > NULL, ip is assigned to NULL. In this case, "return >i_inode" will > > cause a null-pointer dereference.

Re: [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Christoph Hellwig
On Wed, Jul 24, 2019 at 04:43:03PM +0800, Jia-Ju Bai wrote: > index 0acc5834f653..c07c3f4f8451 100644 > --- a/fs/gfs2/super.c > +++ b/fs/gfs2/super.c > @@ -1728,8 +1728,9 @@ static struct inode *gfs2_alloc_inode(struct > super_block *sb) > memset(>i_res, 0, sizeof(ip->i_res)); >

Re: [Cluster-devel] [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()

2019-07-24 Thread Jia-Ju Bai
Thanks for the reply :) On 2019/7/24 17:04, Steven Whitehouse wrote: Hi, On 24/07/2019 09:50, Jia-Ju Bai wrote: In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check whether "rgd->rd_bits[0].bi_bh" is NULL. That is how we detect whether the rgrp has already been read in, so

Re: [Cluster-devel] [BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()

2019-07-24 Thread Steven Whitehouse
Hi, On 24/07/2019 09:50, Jia-Ju Bai wrote: In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check whether "rgd->rd_bits[0].bi_bh" is NULL. That is how we detect whether the rgrp has already been read in, so the function is skipped in the case that we've already read in the rgrp.

[BUG] fs: gfs2: possible null-pointer dereferences in gfs2_rgrp_bh_get()

2019-07-24 Thread Jia-Ju Bai
In gfs2_rgrp_bh_get, there is an if statement on line 1191 to check whether "rgd->rd_bits[0].bi_bh" is NULL. When "rgd->rd_bits[0].bi_bh" is NULL, it is used on line 1216:     gfs2_rgrp_in(rgd, (rgd->rd_bits[0].bi_bh)->b_data); and on line 1225:     gfs2_rgrp_ondisk2lvb(...,

Re: [Cluster-devel] [PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Steven Whitehouse
Hi, On 24/07/2019 09:43, Jia-Ju Bai wrote: In gfs2_alloc_inode(), when kmem_cache_alloc() on line 1724 returns NULL, ip is assigned to NULL. In this case, "return >i_inode" will cause a null-pointer dereference. To fix this null-pointer dereference, NULL is returned when ip is NULL. This bug

[PATCH] fs: gfs2: Fix a null-pointer dereference in gfs2_alloc_inode()

2019-07-24 Thread Jia-Ju Bai
In gfs2_alloc_inode(), when kmem_cache_alloc() on line 1724 returns NULL, ip is assigned to NULL. In this case, "return >i_inode" will cause a null-pointer dereference. To fix this null-pointer dereference, NULL is returned when ip is NULL. This bug is found by a static analysis tool STCheck