* [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags
@ 2018-05-15 1:33 Su Yue
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Su Yue @ 2018-05-15 1:33 UTC (permalink / raw)
To: linux-btrfs; +Cc: suy.fnst
This patchset can be fetch from my github:
https://github.com/Damenly/btrfs-progs/commits/odd_inode_flags
It's based on devel.
symlinks should never have append/immutable attributes.
This patchset enables btrfs check to verify such corruption.
PATCH[1] is for original mode.
PATCH[2] is for original mode.
PATCH[3] adds a test image.
For further use, the directory is called bad-inode-flags.
#issue 133
---
Changelog:
v2:
Use "rec->errors |=" instead of "rec->errors =" in patch[1].
Define new error bit of invalid inode flags in lowmem mode.
Adjust print message in patch[2]. Thanks, Qu and Nikolay.
Rename test directory from odd-inode-flags to bad-inode-flags.
Su Yue (3):
btrfs-progs: check: check symlinks with append/immutable flags
btrfs-progs: lowmem: check symlinks with append/immutable flags
btrfs-progs: fsck-tests: add test case to check symlinks with bad
flags
check/main.c | 7 +++++++
check/mode-lowmem.c | 10 ++++++++++
check/mode-lowmem.h | 1 +
check/mode-original.h | 1 +
.../034-bad-inode-flags/default_case.img | Bin 0 -> 4096 bytes
tests/fsck-tests/034-bad-inode-flags/test.sh | 15 +++++++++++++++
6 files changed, 34 insertions(+)
create mode 100644 tests/fsck-tests/034-bad-inode-flags/default_case.img
create mode 100755 tests/fsck-tests/034-bad-inode-flags/test.sh
--
2.17.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] btrfs-progs: check: check symlinks with append/immutable flags
2018-05-15 1:33 [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags Su Yue
@ 2018-05-15 1:33 ` Su Yue
2018-05-15 7:37 ` Qu Wenruo
2018-06-07 2:45 ` Misono Tomohiro
2018-05-15 1:33 ` [PATCH v2 2/3] btrfs-progs: lowmem: " Su Yue
` (2 subsequent siblings)
3 siblings, 2 replies; 11+ messages in thread
From: Su Yue @ 2018-05-15 1:33 UTC (permalink / raw)
To: linux-btrfs; +Cc: suy.fnst
Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags.
Symlinks should never have append/immutable flags.
While processing inodes, if found a symlink with append/immutable
flags, mark the inode record with I_ERR_ODD_INODE_FLAGS.
This is for original mode.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
check/main.c | 7 +++++++
check/mode-original.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/check/main.c b/check/main.c
index 68da994f7ae0..c764fc011ded 100644
--- a/check/main.c
+++ b/check/main.c
@@ -576,6 +576,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
fprintf(stderr, ", link count wrong");
if (errors & I_ERR_FILE_EXTENT_ORPHAN)
fprintf(stderr, ", orphan file extent");
+ if (errors & I_ERR_ODD_INODE_FLAGS)
+ fprintf(stderr, ", odd inode flags");
fprintf(stderr, "\n");
/* Print the orphan extents if needed */
if (errors & I_ERR_FILE_EXTENT_ORPHAN)
@@ -805,6 +807,7 @@ static int process_inode_item(struct extent_buffer *eb,
{
struct inode_record *rec;
struct btrfs_inode_item *item;
+ u64 flags;
rec = active_node->current;
BUG_ON(rec->ino != key->objectid || rec->refs > 1);
@@ -822,6 +825,10 @@ static int process_inode_item(struct extent_buffer *eb,
rec->found_inode_item = 1;
if (rec->nlink == 0)
rec->errors |= I_ERR_NO_ORPHAN_ITEM;
+ flags = btrfs_inode_flags(eb, item);
+ if (rec->imode & BTRFS_FT_SYMLINK &&
+ flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
+ rec->errors |= I_ERR_ODD_INODE_FLAGS;
maybe_free_inode_rec(&active_node->inode_cache, rec);
return 0;
}
diff --git a/check/mode-original.h b/check/mode-original.h
index 368de692fdd1..13cfa5b9e1b3 100644
--- a/check/mode-original.h
+++ b/check/mode-original.h
@@ -186,6 +186,7 @@ struct file_extent_hole {
#define I_ERR_LINK_COUNT_WRONG (1 << 13)
#define I_ERR_FILE_EXTENT_ORPHAN (1 << 14)
#define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15)
+#define I_ERR_ODD_INODE_FLAGS (1 << 16)
struct inode_record {
struct list_head backrefs;
--
2.17.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] btrfs-progs: lowmem: check symlinks with append/immutable flags
2018-05-15 1:33 [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags Su Yue
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
@ 2018-05-15 1:33 ` Su Yue
2018-05-15 7:38 ` Qu Wenruo
2018-05-15 1:33 ` [PATCH v2 3/3] btrfs-progs: fsck-tests: add test case to check symlinks with bad flags Su Yue
2018-05-31 11:40 ` [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags David Sterba
3 siblings, 1 reply; 11+ messages in thread
From: Su Yue @ 2018-05-15 1:33 UTC (permalink / raw)
To: linux-btrfs; +Cc: suy.fnst
Define new error bit INODE_FLAGS_ERROR to represents invalid inode
flags error.
Symlinks should never have append/immutable flags set.
While checking inodes, if found a symlink with append/immutable
flags, report and record the inode flags error.
This is for lowmem mode.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
check/mode-lowmem.c | 10 ++++++++++
check/mode-lowmem.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 9890180d1d3c..f598bc364de4 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2274,6 +2274,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
struct btrfs_key last_key;
u64 inode_id;
u32 mode;
+ u64 flags;
u64 nlink;
u64 nbytes;
u64 isize;
@@ -2307,10 +2308,19 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
isize = btrfs_inode_size(node, ii);
nbytes = btrfs_inode_nbytes(node, ii);
mode = btrfs_inode_mode(node, ii);
+ flags = btrfs_inode_flags(node, ii);
dir = imode_to_type(mode) == BTRFS_FT_DIR;
nlink = btrfs_inode_nlink(node, ii);
nodatasum = btrfs_inode_flags(node, ii) & BTRFS_INODE_NODATASUM;
+ if (mode & BTRFS_FT_SYMLINK &&
+ flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND)) {
+ err |= INODE_FLAGS_ERROR;
+ error(
+"symlinks must never have immutable/append flags set, root %llu inode item %llu flags %llu may be corrupted",
+ root->objectid, inode_id, flags);
+ }
+
while (1) {
btrfs_item_key_to_cpu(path->nodes[0], &last_key, path->slots[0]);
ret = btrfs_next_item(root, path);
diff --git a/check/mode-lowmem.h b/check/mode-lowmem.h
index e7ba62e2413e..91f7b6b1db53 100644
--- a/check/mode-lowmem.h
+++ b/check/mode-lowmem.h
@@ -44,6 +44,7 @@
#define DIR_COUNT_AGAIN (1<<20) /* DIR isize should be recalculated */
#define BG_ACCOUNTING_ERROR (1<<21) /* Block group accounting error */
#define FATAL_ERROR (1<<22) /* Fatal bit for errno */
+#define INODE_FLAGS_ERROR (1<<23) /* Invalid inode flags */
/*
* Error bit for low memory mode check.
--
2.17.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] btrfs-progs: fsck-tests: add test case to check symlinks with bad flags
2018-05-15 1:33 [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags Su Yue
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
2018-05-15 1:33 ` [PATCH v2 2/3] btrfs-progs: lowmem: " Su Yue
@ 2018-05-15 1:33 ` Su Yue
2018-05-31 11:40 ` [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags David Sterba
3 siblings, 0 replies; 11+ messages in thread
From: Su Yue @ 2018-05-15 1:33 UTC (permalink / raw)
To: linux-btrfs; +Cc: suy.fnst
There are two bad symlinks in the test case.
One is with immutable attribute.
Another one is with append attribute.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
.../034-bad-inode-flags/default_case.img | Bin 0 -> 4096 bytes
tests/fsck-tests/034-bad-inode-flags/test.sh | 15 +++++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 tests/fsck-tests/034-bad-inode-flags/default_case.img
create mode 100755 tests/fsck-tests/034-bad-inode-flags/test.sh
diff --git a/tests/fsck-tests/034-bad-inode-flags/default_case.img b/tests/fsck-tests/034-bad-inode-flags/default_case.img
new file mode 100644
index 0000000000000000000000000000000000000000..43a2a6f62d5ef3afd77f117b577a56ad6098ed19
GIT binary patch
literal 4096
zcmeH}c{CJUAIFU?k*yI4S@RGnly%15rj(_~G8rO6vS$b*hR9G^M_GnP*~gG%*XULD
zecwiA3?YW>hM5=dd(Ly-=e+&-p7Z|Uo_l`xdw=)dbMEhRes@7VO!Ok2v8iSFcVXRY
z0S9$YY#lgx4lMhgmx00fKp$b;YjjKwbl1Mc|4Xm#`|-vHGaC;^56vNgLjwQD1pG!)
z0%s{UtRTF}`3%o*f~o}Ub~i7&5a;#~3S~wq>yb%mpwOOBQV@&XDK2I`K}NNkK2T)W
zP3ZBKkdz|>(+ppAd?n&e`Mhq5Y_Mx6#)lkr%V0RYfv<lo6x+fvt02ztkuYp%%Q;xT
zy4}PY3R{h2>XKS#j!hDNZK|Zl0`#(aZhs{~>g=;i^@`D<CKuSR)XSV?$%1x;Facnk
z)_??Qc_w|aw;%(sc8y(>f+(}JrN_k>!De44F)K~Z_B2ji*e|B3TM=T#=3J?hFQkLT
zcoHc*_{i*Zl|=_O)<@(9atD)c?k`SQU{$3zUo_)!00YeaVw>N{!sut0FUEY0%ig=a
zMor(Rh4`G&3Z`YTQC;Vd8DgP6v&wwJAFZj(Pk4lF8cYH?czMG@QAi}DN<f3p?YI#U
zyAG(s@OX8AD?h8M^=`Emq#9RwRZ&U}U7n8To_DtZ^4`G6!3#&+-?VowBGl?;Rjaei
zNnff3HtL%3oxdgpDm7yp@ecEi2>#2dOFHE}ny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|`H7=bqHYo?_i^}rkmN0v4k5<iF_OGA_&X0I~s^tv*%{7XL)6hSG5Q~X(
kIq6x%Jnm_FaB;gC4ZY2N*-{?-H$sQqLjs2c{x<~v38kbqN&o-=
literal 0
HcmV?d00001
diff --git a/tests/fsck-tests/034-bad-inode-flags/test.sh b/tests/fsck-tests/034-bad-inode-flags/test.sh
new file mode 100755
index 000000000000..2225efb44e0e
--- /dev/null
+++ b/tests/fsck-tests/034-bad-inode-flags/test.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+# In order to confirm that 'btrfs check' supports checking symlinks
+# with immutable/append attributes.
+#
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+ run_mustfail "check should report errors about inode flags" \
+ $SUDO_HELPER "$TOP/btrfs" check "$1"
+}
+
+check_all_images
--
2.17.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] btrfs-progs: check: check symlinks with append/immutable flags
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
@ 2018-05-15 7:37 ` Qu Wenruo
2018-06-07 2:45 ` Misono Tomohiro
1 sibling, 0 replies; 11+ messages in thread
From: Qu Wenruo @ 2018-05-15 7:37 UTC (permalink / raw)
To: Su Yue, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 2334 bytes --]
On 2018年05月15日 09:33, Su Yue wrote:
> Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags.
>
> Symlinks should never have append/immutable flags.
> While processing inodes, if found a symlink with append/immutable
> flags, mark the inode record with I_ERR_ODD_INODE_FLAGS.
>
> This is for original mode.
>
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> check/main.c | 7 +++++++
> check/mode-original.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/check/main.c b/check/main.c
> index 68da994f7ae0..c764fc011ded 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -576,6 +576,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
> fprintf(stderr, ", link count wrong");
> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
> fprintf(stderr, ", orphan file extent");
> + if (errors & I_ERR_ODD_INODE_FLAGS)
> + fprintf(stderr, ", odd inode flags");
> fprintf(stderr, "\n");
> /* Print the orphan extents if needed */
> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
> @@ -805,6 +807,7 @@ static int process_inode_item(struct extent_buffer *eb,
> {
> struct inode_record *rec;
> struct btrfs_inode_item *item;
> + u64 flags;
>
> rec = active_node->current;
> BUG_ON(rec->ino != key->objectid || rec->refs > 1);
> @@ -822,6 +825,10 @@ static int process_inode_item(struct extent_buffer *eb,
> rec->found_inode_item = 1;
> if (rec->nlink == 0)
> rec->errors |= I_ERR_NO_ORPHAN_ITEM;
> + flags = btrfs_inode_flags(eb, item);
> + if (rec->imode & BTRFS_FT_SYMLINK &&
> + flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
> + rec->errors |= I_ERR_ODD_INODE_FLAGS;
> maybe_free_inode_rec(&active_node->inode_cache, rec);
> return 0;
> }
> diff --git a/check/mode-original.h b/check/mode-original.h
> index 368de692fdd1..13cfa5b9e1b3 100644
> --- a/check/mode-original.h
> +++ b/check/mode-original.h
> @@ -186,6 +186,7 @@ struct file_extent_hole {
> #define I_ERR_LINK_COUNT_WRONG (1 << 13)
> #define I_ERR_FILE_EXTENT_ORPHAN (1 << 14)
> #define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15)
> +#define I_ERR_ODD_INODE_FLAGS (1 << 16)
>
> struct inode_record {
> struct list_head backrefs;
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] btrfs-progs: lowmem: check symlinks with append/immutable flags
2018-05-15 1:33 ` [PATCH v2 2/3] btrfs-progs: lowmem: " Su Yue
@ 2018-05-15 7:38 ` Qu Wenruo
0 siblings, 0 replies; 11+ messages in thread
From: Qu Wenruo @ 2018-05-15 7:38 UTC (permalink / raw)
To: Su Yue, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 2394 bytes --]
On 2018年05月15日 09:33, Su Yue wrote:
> Define new error bit INODE_FLAGS_ERROR to represents invalid inode
> flags error.
>
> Symlinks should never have append/immutable flags set.
> While checking inodes, if found a symlink with append/immutable
> flags, report and record the inode flags error.
>
> This is for lowmem mode.
>
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> check/mode-lowmem.c | 10 ++++++++++
> check/mode-lowmem.h | 1 +
> 2 files changed, 11 insertions(+)
>
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 9890180d1d3c..f598bc364de4 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -2274,6 +2274,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
> struct btrfs_key last_key;
> u64 inode_id;
> u32 mode;
> + u64 flags;
> u64 nlink;
> u64 nbytes;
> u64 isize;
> @@ -2307,10 +2308,19 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
> isize = btrfs_inode_size(node, ii);
> nbytes = btrfs_inode_nbytes(node, ii);
> mode = btrfs_inode_mode(node, ii);
> + flags = btrfs_inode_flags(node, ii);
> dir = imode_to_type(mode) == BTRFS_FT_DIR;
> nlink = btrfs_inode_nlink(node, ii);
> nodatasum = btrfs_inode_flags(node, ii) & BTRFS_INODE_NODATASUM;
>
> + if (mode & BTRFS_FT_SYMLINK &&
> + flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND)) {
> + err |= INODE_FLAGS_ERROR;
> + error(
> +"symlinks must never have immutable/append flags set, root %llu inode item %llu flags %llu may be corrupted",
> + root->objectid, inode_id, flags);
> + }
> +
> while (1) {
> btrfs_item_key_to_cpu(path->nodes[0], &last_key, path->slots[0]);
> ret = btrfs_next_item(root, path);
> diff --git a/check/mode-lowmem.h b/check/mode-lowmem.h
> index e7ba62e2413e..91f7b6b1db53 100644
> --- a/check/mode-lowmem.h
> +++ b/check/mode-lowmem.h
> @@ -44,6 +44,7 @@
> #define DIR_COUNT_AGAIN (1<<20) /* DIR isize should be recalculated */
> #define BG_ACCOUNTING_ERROR (1<<21) /* Block group accounting error */
> #define FATAL_ERROR (1<<22) /* Fatal bit for errno */
> +#define INODE_FLAGS_ERROR (1<<23) /* Invalid inode flags */
>
> /*
> * Error bit for low memory mode check.
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags
2018-05-15 1:33 [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags Su Yue
` (2 preceding siblings ...)
2018-05-15 1:33 ` [PATCH v2 3/3] btrfs-progs: fsck-tests: add test case to check symlinks with bad flags Su Yue
@ 2018-05-31 11:40 ` David Sterba
2018-06-07 6:59 ` Su Yue
3 siblings, 1 reply; 11+ messages in thread
From: David Sterba @ 2018-05-31 11:40 UTC (permalink / raw)
To: Su Yue; +Cc: linux-btrfs
On Tue, May 15, 2018 at 09:33:21AM +0800, Su Yue wrote:
> This patchset can be fetch from my github:
> https://github.com/Damenly/btrfs-progs/commits/odd_inode_flags
> It's based on devel.
>
> symlinks should never have append/immutable attributes.
> This patchset enables btrfs check to verify such corruption.
>
> PATCH[1] is for original mode.
> PATCH[2] is for original mode.
>
> PATCH[3] adds a test image.
> For further use, the directory is called bad-inode-flags.
>
> #issue 133
>
> ---
> Changelog:
> v2:
> Use "rec->errors |=" instead of "rec->errors =" in patch[1].
> Define new error bit of invalid inode flags in lowmem mode.
> Adjust print message in patch[2]. Thanks, Qu and Nikolay.
> Rename test directory from odd-inode-flags to bad-inode-flags.
>
> Su Yue (3):
> btrfs-progs: check: check symlinks with append/immutable flags
> btrfs-progs: lowmem: check symlinks with append/immutable flags
> btrfs-progs: fsck-tests: add test case to check symlinks with bad
> flags
Applied, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] btrfs-progs: check: check symlinks with append/immutable flags
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
2018-05-15 7:37 ` Qu Wenruo
@ 2018-06-07 2:45 ` Misono Tomohiro
2018-06-07 3:53 ` Su Yue
1 sibling, 1 reply; 11+ messages in thread
From: Misono Tomohiro @ 2018-06-07 2:45 UTC (permalink / raw)
To: Su Yue, linux-btrfs
On 2018/05/15 10:33, Su Yue wrote:
> Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags.
>
> Symlinks should never have append/immutable flags.
> While processing inodes, if found a symlink with append/immutable
> flags, mark the inode record with I_ERR_ODD_INODE_FLAGS.
>
> This is for original mode.
>
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
> check/main.c | 7 +++++++
> check/mode-original.h | 1 +
> 2 files changed, 8 insertions(+)
>
> diff --git a/check/main.c b/check/main.c
> index 68da994f7ae0..c764fc011ded 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -576,6 +576,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
> fprintf(stderr, ", link count wrong");
> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
> fprintf(stderr, ", orphan file extent");
> + if (errors & I_ERR_ODD_INODE_FLAGS)
> + fprintf(stderr, ", odd inode flags");
> fprintf(stderr, "\n");
> /* Print the orphan extents if needed */
> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
> @@ -805,6 +807,7 @@ static int process_inode_item(struct extent_buffer *eb,
> {
> struct inode_record *rec;
> struct btrfs_inode_item *item;
> + u64 flags;
>
> rec = active_node->current;
> BUG_ON(rec->ino != key->objectid || rec->refs > 1);
> @@ -822,6 +825,10 @@ static int process_inode_item(struct extent_buffer *eb,
> rec->found_inode_item = 1;
> if (rec->nlink == 0)
> rec->errors |= I_ERR_NO_ORPHAN_ITEM;
> + flags = btrfs_inode_flags(eb, item);
> + if (rec->imode & BTRFS_FT_SYMLINK &&
Hello,
I observed that this commit causes test-convert/009 in current kdave/devel branch.
Since rec->imode uses S_IFLNK (0xa000) for symbolic link and BTRFS_FT_SYMLINK is 7,
above statement does not work well. Shouldn't we use S_ISLNK(rec->imode) instead?
Thanks,
Tomohiro Misono
> + flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
> + rec->errors |= I_ERR_ODD_INODE_FLAGS;
> maybe_free_inode_rec(&active_node->inode_cache, rec);
> return 0;
> }
> diff --git a/check/mode-original.h b/check/mode-original.h
> index 368de692fdd1..13cfa5b9e1b3 100644
> --- a/check/mode-original.h
> +++ b/check/mode-original.h
> @@ -186,6 +186,7 @@ struct file_extent_hole {
> #define I_ERR_LINK_COUNT_WRONG (1 << 13)
> #define I_ERR_FILE_EXTENT_ORPHAN (1 << 14)
> #define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15)
> +#define I_ERR_ODD_INODE_FLAGS (1 << 16)
>
> struct inode_record {
> struct list_head backrefs;
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] btrfs-progs: check: check symlinks with append/immutable flags
2018-06-07 2:45 ` Misono Tomohiro
@ 2018-06-07 3:53 ` Su Yue
0 siblings, 0 replies; 11+ messages in thread
From: Su Yue @ 2018-06-07 3:53 UTC (permalink / raw)
To: Misono Tomohiro, linux-btrfs
On 06/07/2018 10:45 AM, Misono Tomohiro wrote:
>
>
> On 2018/05/15 10:33, Su Yue wrote:
>> Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags.
>>
>> Symlinks should never have append/immutable flags.
>> While processing inodes, if found a symlink with append/immutable
>> flags, mark the inode record with I_ERR_ODD_INODE_FLAGS.
>>
>> This is for original mode.
>>
>> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
>> ---
>> check/main.c | 7 +++++++
>> check/mode-original.h | 1 +
>> 2 files changed, 8 insertions(+)
>>
>> diff --git a/check/main.c b/check/main.c
>> index 68da994f7ae0..c764fc011ded 100644
>> --- a/check/main.c
>> +++ b/check/main.c
>> @@ -576,6 +576,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
>> fprintf(stderr, ", link count wrong");
>> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
>> fprintf(stderr, ", orphan file extent");
>> + if (errors & I_ERR_ODD_INODE_FLAGS)
>> + fprintf(stderr, ", odd inode flags");
>> fprintf(stderr, "\n");
>> /* Print the orphan extents if needed */
>> if (errors & I_ERR_FILE_EXTENT_ORPHAN)
>> @@ -805,6 +807,7 @@ static int process_inode_item(struct extent_buffer *eb,
>> {
>> struct inode_record *rec;
>> struct btrfs_inode_item *item;
>> + u64 flags;
>>
>> rec = active_node->current;
>> BUG_ON(rec->ino != key->objectid || rec->refs > 1);
>> @@ -822,6 +825,10 @@ static int process_inode_item(struct extent_buffer *eb,
>> rec->found_inode_item = 1;
>> if (rec->nlink == 0)
>> rec->errors |= I_ERR_NO_ORPHAN_ITEM;
>> + flags = btrfs_inode_flags(eb, item);
>> + if (rec->imode & BTRFS_FT_SYMLINK &&
>
> Hello,
>
> I observed that this commit causes test-convert/009 in current kdave/devel branch.
> Since rec->imode uses S_IFLNK (0xa000) for symbolic link and BTRFS_FT_SYMLINK is 7,
> above statement does not work well. Shouldn't we use S_ISLNK(rec->imode) instead?
>
Oh.. Yep, my bad.
Since the test case is created by hand, the whole patchset should be
modified in next version.
Thanks a lot.
Su
> Thanks,
> Tomohiro Misono
>
>> + flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
>> + rec->errors |= I_ERR_ODD_INODE_FLAGS;
>> maybe_free_inode_rec(&active_node->inode_cache, rec);
>> return 0;
>> }
>> diff --git a/check/mode-original.h b/check/mode-original.h
>> index 368de692fdd1..13cfa5b9e1b3 100644
>> --- a/check/mode-original.h
>> +++ b/check/mode-original.h
>> @@ -186,6 +186,7 @@ struct file_extent_hole {
>> #define I_ERR_LINK_COUNT_WRONG (1 << 13)
>> #define I_ERR_FILE_EXTENT_ORPHAN (1 << 14)
>> #define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15)
>> +#define I_ERR_ODD_INODE_FLAGS (1 << 16)
>>
>> struct inode_record {
>> struct list_head backrefs;
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags
2018-05-31 11:40 ` [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags David Sterba
@ 2018-06-07 6:59 ` Su Yue
2018-06-07 13:04 ` David Sterba
0 siblings, 1 reply; 11+ messages in thread
From: Su Yue @ 2018-06-07 6:59 UTC (permalink / raw)
To: dsterba, linux-btrfs
On 05/31/2018 07:40 PM, David Sterba wrote:
> On Tue, May 15, 2018 at 09:33:21AM +0800, Su Yue wrote:
>> This patchset can be fetch from my github:
>> https://github.com/Damenly/btrfs-progs/commits/odd_inode_flags
>> It's based on devel.
>>
>> symlinks should never have append/immutable attributes.
>> This patchset enables btrfs check to verify such corruption.
>>
>> PATCH[1] is for original mode.
>> PATCH[2] is for original mode.
>>
>> PATCH[3] adds a test image.
>> For further use, the directory is called bad-inode-flags.
>>
>> #issue 133
>>
>> ---
>> Changelog:
>> v2:
>> Use "rec->errors |=" instead of "rec->errors =" in patch[1].
>> Define new error bit of invalid inode flags in lowmem mode.
>> Adjust print message in patch[2]. Thanks, Qu and Nikolay.
>> Rename test directory from odd-inode-flags to bad-inode-flags.
>>
>> Su Yue (3):
>> btrfs-progs: check: check symlinks with append/immutable flags
>> btrfs-progs: lowmem: check symlinks with append/immutable flags
>> btrfs-progs: fsck-tests: add test case to check symlinks with bad
>> flags
>
> Applied, thanks.
Hi David,
Could you replace this patchset with new V3? It fixes the problem
reported by Misono.
Thanks,
Su
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags
2018-06-07 6:59 ` Su Yue
@ 2018-06-07 13:04 ` David Sterba
0 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2018-06-07 13:04 UTC (permalink / raw)
To: Su Yue; +Cc: dsterba, linux-btrfs
On Thu, Jun 07, 2018 at 02:59:23PM +0800, Su Yue wrote:
> Could you replace this patchset with new V3? It fixes the problem
> reported by Misono.
Done, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-06-07 13:07 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15 1:33 [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags Su Yue
2018-05-15 1:33 ` [PATCH v2 1/3] btrfs-progs: check: check " Su Yue
2018-05-15 7:37 ` Qu Wenruo
2018-06-07 2:45 ` Misono Tomohiro
2018-06-07 3:53 ` Su Yue
2018-05-15 1:33 ` [PATCH v2 2/3] btrfs-progs: lowmem: " Su Yue
2018-05-15 7:38 ` Qu Wenruo
2018-05-15 1:33 ` [PATCH v2 3/3] btrfs-progs: fsck-tests: add test case to check symlinks with bad flags Su Yue
2018-05-31 11:40 ` [PATCH v2 0/3] btrfs-progs: check: verify symlinks with append/immutable flags David Sterba
2018-06-07 6:59 ` Su Yue
2018-06-07 13:04 ` David Sterba
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.