Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-12-03 Thread Theodore Y. Ts'o
On Tue, Nov 27, 2018 at 10:14:53AM +0100, Jan Kara wrote:
> On Mon 26-11-18 11:21:06, Pan Bian wrote:
> > The function frees qf_inode via iput but then pass qf_inode to
> > lockdep_set_quota_inode on the failure path. This may result in a
> > use-after-free bug. The patch frees df_inode only when it is never used.
> > 
> > Signed-off-by: Pan Bian 
> > Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")
> 
> Thanks for the fix! The patch looks good. You can add:
> 
> Reviewed-by: Jan Kara 

Thanks, applied.

- Ted


Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-12-03 Thread Theodore Y. Ts'o
On Tue, Nov 27, 2018 at 10:14:53AM +0100, Jan Kara wrote:
> On Mon 26-11-18 11:21:06, Pan Bian wrote:
> > The function frees qf_inode via iput but then pass qf_inode to
> > lockdep_set_quota_inode on the failure path. This may result in a
> > use-after-free bug. The patch frees df_inode only when it is never used.
> > 
> > Signed-off-by: Pan Bian 
> > Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")
> 
> Thanks for the fix! The patch looks good. You can add:
> 
> Reviewed-by: Jan Kara 

Thanks, applied.

- Ted


Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-11-27 Thread Jan Kara
On Mon 26-11-18 11:21:06, Pan Bian wrote:
> The function frees qf_inode via iput but then pass qf_inode to
> lockdep_set_quota_inode on the failure path. This may result in a
> use-after-free bug. The patch frees df_inode only when it is never used.
> 
> Signed-off-by: Pan Bian 
> Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")

Thanks for the fix! The patch looks good. You can add:

Reviewed-by: Jan Kara 

Honza

> ---
>  fs/ext4/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 53ff6c2..35689eb 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5690,9 +5690,9 @@ static int ext4_quota_enable(struct super_block *sb, 
> int type, int format_id,
>   qf_inode->i_flags |= S_NOQUOTA;
>   lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
>   err = dquot_enable(qf_inode, type, format_id, flags);
> - iput(qf_inode);
>   if (err)
>   lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
> + iput(qf_inode);
>  
>   return err;
>  }
> -- 
> 2.7.4
> 
> 
-- 
Jan Kara 
SUSE Labs, CR


Re: [PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-11-27 Thread Jan Kara
On Mon 26-11-18 11:21:06, Pan Bian wrote:
> The function frees qf_inode via iput but then pass qf_inode to
> lockdep_set_quota_inode on the failure path. This may result in a
> use-after-free bug. The patch frees df_inode only when it is never used.
> 
> Signed-off-by: Pan Bian 
> Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")

Thanks for the fix! The patch looks good. You can add:

Reviewed-by: Jan Kara 

Honza

> ---
>  fs/ext4/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 53ff6c2..35689eb 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5690,9 +5690,9 @@ static int ext4_quota_enable(struct super_block *sb, 
> int type, int format_id,
>   qf_inode->i_flags |= S_NOQUOTA;
>   lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
>   err = dquot_enable(qf_inode, type, format_id, flags);
> - iput(qf_inode);
>   if (err)
>   lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
> + iput(qf_inode);
>  
>   return err;
>  }
> -- 
> 2.7.4
> 
> 
-- 
Jan Kara 
SUSE Labs, CR


[PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-11-25 Thread Pan Bian
The function frees qf_inode via iput but then pass qf_inode to
lockdep_set_quota_inode on the failure path. This may result in a
use-after-free bug. The patch frees df_inode only when it is never used.

Signed-off-by: Pan Bian 
Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 53ff6c2..35689eb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5690,9 +5690,9 @@ static int ext4_quota_enable(struct super_block *sb, int 
type, int format_id,
qf_inode->i_flags |= S_NOQUOTA;
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
err = dquot_enable(qf_inode, type, format_id, flags);
-   iput(qf_inode);
if (err)
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
+   iput(qf_inode);
 
return err;
 }
-- 
2.7.4




[PATCH] ext4: fix possible use after free in ext4_quota_enable

2018-11-25 Thread Pan Bian
The function frees qf_inode via iput but then pass qf_inode to
lockdep_set_quota_inode on the failure path. This may result in a
use-after-free bug. The patch frees df_inode only when it is never used.

Signed-off-by: Pan Bian 
Fixes: daf647d2dd5("ext4: add lockdep annotations for i_data_sem")
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 53ff6c2..35689eb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5690,9 +5690,9 @@ static int ext4_quota_enable(struct super_block *sb, int 
type, int format_id,
qf_inode->i_flags |= S_NOQUOTA;
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
err = dquot_enable(qf_inode, type, format_id, flags);
-   iput(qf_inode);
if (err)
lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
+   iput(qf_inode);
 
return err;
 }
-- 
2.7.4