2020-11-03 02:29:40

by Joseph Qi

[permalink] [raw]
Subject: [PATCH] ext4: unlock xattr_sem properly in ext4_inline_data_truncate()

It takes xattr_sem to check inline data again but without unlock it
in case not have. So unlock it before return.

Fixes: aef1c8513c1f ("ext4: let ext4_truncate handle inline data correctly")
Reported-by: Dan Carpenter <[email protected]>
Cc: Tao Ma <[email protected]>
Signed-off-by: Joseph Qi <[email protected]>
---
fs/ext4/inline.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index caa5147..b41512d 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1880,6 +1880,7 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)

ext4_write_lock_xattr(inode, &no_expand);
if (!ext4_has_inline_data(inode)) {
+ ext4_write_unlock_xattr(inode, &no_expand);
*has_inline = 0;
ext4_journal_stop(handle);
return 0;
--
1.8.3.1


2020-11-03 03:17:35

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] ext4: unlock xattr_sem properly in ext4_inline_data_truncate()

On Nov 2, 2020, at 7:29 PM, Joseph Qi <[email protected]> wrote:
>
> It takes xattr_sem to check inline data again but without unlock it
> in case not have. So unlock it before return.
>
> Fixes: aef1c8513c1f ("ext4: let ext4_truncate handle inline data correctly")
> Reported-by: Dan Carpenter <[email protected]>
> Cc: Tao Ma <[email protected]>
> Signed-off-by: Joseph Qi <[email protected]>

Reviewed-by: Andreas Dilger <[email protected]>

> ---
> fs/ext4/inline.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index caa5147..b41512d 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -1880,6 +1880,7 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)
>
> ext4_write_lock_xattr(inode, &no_expand);
> if (!ext4_has_inline_data(inode)) {
> + ext4_write_unlock_xattr(inode, &no_expand);
> *has_inline = 0;
> ext4_journal_stop(handle);
> return 0;
> --
> 1.8.3.1
>


Cheers, Andreas






Attachments:
signature.asc (890.00 B)
Message signed with OpenPGP

2020-11-07 03:31:10

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] ext4: unlock xattr_sem properly in ext4_inline_data_truncate()

On Mon, Nov 02, 2020 at 08:15:36PM -0700, Andreas Dilger wrote:
> On Nov 2, 2020, at 7:29 PM, Joseph Qi <[email protected]> wrote:
> >
> > It takes xattr_sem to check inline data again but without unlock it
> > in case not have. So unlock it before return.
> >
> > Fixes: aef1c8513c1f ("ext4: let ext4_truncate handle inline data correctly")
> > Reported-by: Dan Carpenter <[email protected]>
> > Cc: Tao Ma <[email protected]>
> > Signed-off-by: Joseph Qi <[email protected]>
>
> Reviewed-by: Andreas Dilger <[email protected]>

Thanks, applied.

- Ted