OSDN Git Service

ext2: fix improper assignment for e_value_offs
authorChengguang Xu <cgxu519@mykernel.net>
Wed, 3 Jun 2020 08:44:29 +0000 (16:44 +0800)
committerJan Kara <jack@suse.cz>
Thu, 9 Jul 2020 06:14:00 +0000 (08:14 +0200)
In the process of changing value for existing EA,
there is an improper assignment of e_value_offs(setting to 0),
because it will be reset to incorrect value in the following
loop(shifting EA values before target). Delayed assignment
can avoid this issue.

Link: https://lore.kernel.org/r/20200603084429.25344-1-cgxu519@mykernel.net
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext2/xattr.c

index 943cc46..c802ea6 100644 (file)
@@ -588,7 +588,6 @@ bad_block:
                        /* Remove the old value. */
                        memmove(first_val + size, first_val, val - first_val);
                        memset(first_val, 0, size);
-                       here->e_value_offs = 0;
                        min_offs += size;
 
                        /* Adjust all value offsets. */
@@ -600,6 +599,8 @@ bad_block:
                                                cpu_to_le16(o + size);
                                last = EXT2_XATTR_NEXT(last);
                        }
+
+                       here->e_value_offs = 0;
                }
                if (value == NULL) {
                        /* Remove the old name. */