All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2
@ 2021-07-18 12:54 Qu Wenruo
  2021-07-18 12:54 ` [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Qu Wenruo @ 2021-07-18 12:54 UTC (permalink / raw)
  To: linux-btrfs

Linux VFS doesn't allow directory to have hard links, thus for btrfs
on-disk directory inode items, their nlinks should never go beyond 1.

Lowmem mode already has the check and will report it without problem.
Only original mode needs this update.

Reported-by: Pepperpoint <pepperpoint@mb.ardentcoding.com>
Link: https://lore.kernel.org/linux-btrfs/162648632340.7.1932907459648384384.10178178@mb.ardentcoding.com/
Signed-off-by: Qu Wenruo <wqu@suse.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 ee6cf793251c..df2303939ffe 100644
--- a/check/main.c
+++ b/check/main.c
@@ -623,6 +623,9 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
 			rec->imode & ~07777);
 	if (errors & I_ERR_INVALID_GEN)
 		fprintf(stderr, ", invalid inode generation or transid");
+	if (errors & I_ERR_INVALID_NLINK)
+		fprintf(stderr, ", directory has invalid nlink %d",
+			rec->nlink);
 	fprintf(stderr, "\n");
 
 	/* Print the holes if needed */
@@ -909,6 +912,10 @@ static int process_inode_item(struct extent_buffer *eb,
 	if (S_ISLNK(rec->imode) &&
 	    flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
 		rec->errors |= I_ERR_ODD_INODE_FLAGS;
+
+	/* Directory should never have hard link */
+	if (S_ISDIR(rec->imode) && rec->nlink >= 2)
+		rec->errors |= I_ERR_INVALID_NLINK;
 	/*
 	 * We don't have accurate root info to determine the correct
 	 * inode generation uplimit, use super_generation + 1 anyway
diff --git a/check/mode-original.h b/check/mode-original.h
index b075a95c9757..eed16d92d0db 100644
--- a/check/mode-original.h
+++ b/check/mode-original.h
@@ -186,6 +186,7 @@ struct unaligned_extent_rec_t {
 #define I_ERR_MISMATCH_DIR_HASH		(1 << 18)
 #define I_ERR_INVALID_IMODE		(1 << 19)
 #define I_ERR_INVALID_GEN		(1 << 20)
+#define I_ERR_INVALID_NLINK		(1 << 21)
 
 struct inode_record {
 	struct list_head backrefs;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links
  2021-07-18 12:54 [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Qu Wenruo
@ 2021-07-18 12:54 ` Qu Wenruo
  2021-07-19  9:57   ` Anand Jain
  2021-07-19  0:39 ` [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Su Yue
  2021-07-30 13:54 ` David Sterba
  2 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2021-07-18 12:54 UTC (permalink / raw)
  To: linux-btrfs

Make sure btrfs check can detect such problem.

Right now we have no way to fix it yet.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../049-dir-hard-link/default.img.xz          | Bin 0 -> 1712 bytes
 tests/fsck-tests/049-dir-hard-link/test.sh    |  19 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 tests/fsck-tests/049-dir-hard-link/default.img.xz
 create mode 100755 tests/fsck-tests/049-dir-hard-link/test.sh

diff --git a/tests/fsck-tests/049-dir-hard-link/default.img.xz b/tests/fsck-tests/049-dir-hard-link/default.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..fd9971acae78975f5263da022feea39e34b45139
GIT binary patch
literal 1712
zcmV;h22c6@H+ooF000E$*0e?f03iV!0000G&sfah3;zaiT>wRyj;C3^v%$$4d1lq4
zhDvnFHzu^a0%EHA+fjUfU^d-f8FD79nuh5qo92GkFUET_5R5Y~d)afdfW4sb2eW+N
z(-N9N;@zX$?eR^y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ao{g00000
G1X)_MbXXt&

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/049-dir-hard-link/test.sh b/tests/fsck-tests/049-dir-hard-link/test.sh
new file mode 100755
index 000000000000..992ad638bd47
--- /dev/null
+++ b/tests/fsck-tests/049-dir-hard-link/test.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Verify that check can detect overlapped dir with 2 links
+#
+# There is a report that btrfs-check doesn't report dir with 2 links as
+# error, and only get caught by tree-checker.
+#
+# Make sure btrfs check can at least detect such error
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_mustfail "dir with 2 links not detected" \
+		"$TOP/btrfs" check "$1"
+}
+
+check_all_images
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2
  2021-07-18 12:54 [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Qu Wenruo
  2021-07-18 12:54 ` [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links Qu Wenruo
@ 2021-07-19  0:39 ` Su Yue
  2021-07-30 13:54 ` David Sterba
  2 siblings, 0 replies; 6+ messages in thread
From: Su Yue @ 2021-07-19  0:39 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs


On Sun 18 Jul 2021 at 20:54, Qu Wenruo <wqu@suse.com> wrote:

> Linux VFS doesn't allow directory to have hard links, thus for 
> btrfs
> on-disk directory inode items, their nlinks should never go 
> beyond 1.
>
> Lowmem mode already has the check and will report it without 
> problem.
> Only original mode needs this update.
>
> Reported-by: Pepperpoint <pepperpoint@mb.ardentcoding.com>
> Link: 
> https://lore.kernel.org/linux-btrfs/162648632340.7.1932907459648384384.10178178@mb.ardentcoding.com/
> Signed-off-by: Qu Wenruo <wqu@suse.com>
>
Reviewed-by: Su Yue <l@damenly.su>

--
Su
> ---
>  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 ee6cf793251c..df2303939ffe 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -623,6 +623,9 @@ static void print_inode_error(struct 
> btrfs_root *root, struct inode_record *rec)
>  			rec->imode & ~07777);
>  	if (errors & I_ERR_INVALID_GEN)
>  		fprintf(stderr, ", invalid inode generation or transid");
> +	if (errors & I_ERR_INVALID_NLINK)
> +		fprintf(stderr, ", directory has invalid nlink %d",
> +			rec->nlink);
>  	fprintf(stderr, "\n");
>
>  	/* Print the holes if needed */
> @@ -909,6 +912,10 @@ static int process_inode_item(struct 
> extent_buffer *eb,
>  	if (S_ISLNK(rec->imode) &&
>  	    flags & (BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND))
>  		rec->errors |= I_ERR_ODD_INODE_FLAGS;
> +
> +	/* Directory should never have hard link */
> +	if (S_ISDIR(rec->imode) && rec->nlink >= 2)
> +		rec->errors |= I_ERR_INVALID_NLINK;
>  	/*
>  	 * We don't have accurate root info to determine the correct
>  	 * inode generation uplimit, use super_generation + 1 anyway
> diff --git a/check/mode-original.h b/check/mode-original.h
> index b075a95c9757..eed16d92d0db 100644
> --- a/check/mode-original.h
> +++ b/check/mode-original.h
> @@ -186,6 +186,7 @@ struct unaligned_extent_rec_t {
>  #define I_ERR_MISMATCH_DIR_HASH		(1 << 18)
>  #define I_ERR_INVALID_IMODE		(1 << 19)
>  #define I_ERR_INVALID_GEN		(1 << 20)
> +#define I_ERR_INVALID_NLINK		(1 << 21)
>
>  struct inode_record {
>  	struct list_head backrefs;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links
  2021-07-18 12:54 ` [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links Qu Wenruo
@ 2021-07-19  9:57   ` Anand Jain
  2021-07-19 10:25     ` Qu Wenruo
  0 siblings, 1 reply; 6+ messages in thread
From: Anand Jain @ 2021-07-19  9:57 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On 18/07/2021 20:54, Qu Wenruo wrote:
> Make sure btrfs check can detect such problem.
> 
> Right now we have no way to fix it yet.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>


Test case runs fine. Do you use any tool to create the crafted image?

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand

> ---
>   .../049-dir-hard-link/default.img.xz          | Bin 0 -> 1712 bytes
>   tests/fsck-tests/049-dir-hard-link/test.sh    |  19 ++++++++++++++++++
>   2 files changed, 19 insertions(+)
>   create mode 100644 tests/fsck-tests/049-dir-hard-link/default.img.xz
>   create mode 100755 tests/fsck-tests/049-dir-hard-link/test.sh
> 
> diff --git a/tests/fsck-tests/049-dir-hard-link/default.img.xz b/tests/fsck-tests/049-dir-hard-link/default.img.xz
> new file mode 100644
> index 0000000000000000000000000000000000000000..fd9971acae78975f5263da022feea39e34b45139
> GIT binary patch
> literal 1712
> zcmV;h22c6@H+ooF000E$*0e?f03iV!0000G&sfah3;zaiT>wRyj;C3^v%$$4d1lq4
> zhDvnFHzu^a0%EHA+fjUfU^d-f8FD79nuh5qo92GkFUET_5R5Y~d)afdfW4sb2eW+N
> z(-N9N;@zX$?eR^yQlFZnSsfYzwplHEI#}i{O3&^g-%*#*J}6=@&Mr933Z)S+DYvtb
> z5k;9l__I-yJ`AS&v0F{j8)>U_CUcN9uhMMZ>r0aFa$nT3PO%||kR#<>`b&X;^jZx!
> z?T$2In^=Ho4dSN<1OU-V{`iJKl4iT0qZ?qN2!NSUwLkY={)k)$fv5z~^N4kqFTY0A
> zY^ShS`wE?^@sQEzTB{J`c&Co>am(cbBo?iCTX8yDg2XD@%iu+8T>Rs=OS3N#=)3bd
> z$%Q$2o4Jw~)_B}yv$C$3d8z@>PGT?pn~}TQM)H=}8OiIM$T%7bnT!rm9e8Kj*IY>i
> zRi|m%s0@W^`QQLHd#kk%hsBhG;@X+L^icR9?z+_VJJC<foGA3E&6VL0{A;3%cJ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;E|i)7w`)u*a&WXIzpygnt3`|17G^sPOyW0?V~!r7SasXdubQAKKtR^|uf
> z4;4WRHG()C2~#M*GC^l@k>w3^5M{@6>W%dgSU>Zqn+vNd*2f><3(CVuqAnX=(Zu(G
> zF(j4`;!MKu6~PVFgQz$=jt#O~3U4TtOFg;!(X?=T=jRzhT3yzSXD>1GA8~FpzJVnt
> zUmIYu;aQe?QMT(4UkP16u@m}5@AX6}DPA>a!#dt3qbX_CfS5)G-*MI@B#;(Ap1`{;
> z3VE<Z0{u?EC{{mUj$DSQ|Lv6DL`62yckCVEF6WgD4l%e+sw}4(qMD4Y=X-!VdYJo{
> zKb+fu*f8Tk!0fZzzcR|8Tl0H%R#9A&@3h+`YzekzO#*X*=^j()i-pyn&%m-Ln_2H!
> z&+nI1M9}8)2($&79_I@LdA5md{Ue@-$tE1%0OeJZ{UaXg=~jG>C#T>wd^;QzL0K(}
> z6tjZD62IVa<@fK+TssaPJ~B{H`R=bR5r$9ZK8P2Nah9n(3W~$(5piy!QO^Al)?l4Q
> z`5~x}6Pex_Yr=?Q*&mMGj7l@I6&y+9_H<1QmoCJTx0Y6JJmE9n=>iO#ToI;6F9dI)
> z!d^0KXk;SSyDf^@yN)Q-8qxAM^Z)=ciSQA~y}h;o0gMfR7ytk~fZMIH#Ao{g00000
> G1X)_MbXXt&
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/tests/fsck-tests/049-dir-hard-link/test.sh b/tests/fsck-tests/049-dir-hard-link/test.sh
> new file mode 100755
> index 000000000000..992ad638bd47
> --- /dev/null
> +++ b/tests/fsck-tests/049-dir-hard-link/test.sh
> @@ -0,0 +1,19 @@
> +#!/bin/bash
> +#
> +# Verify that check can detect overlapped dir with 2 links
> +#
> +# There is a report that btrfs-check doesn't report dir with 2 links as
> +# error, and only get caught by tree-checker.
> +#
> +# Make sure btrfs check can at least detect such error
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq btrfs
> +
> +check_image() {
> +	run_mustfail "dir with 2 links not detected" \
> +		"$TOP/btrfs" check "$1"
> +}
> +
> +check_all_images
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links
  2021-07-19  9:57   ` Anand Jain
@ 2021-07-19 10:25     ` Qu Wenruo
  0 siblings, 0 replies; 6+ messages in thread
From: Qu Wenruo @ 2021-07-19 10:25 UTC (permalink / raw)
  To: Anand Jain, Qu Wenruo; +Cc: linux-btrfs



On 2021/7/19 下午5:57, Anand Jain wrote:
> On 18/07/2021 20:54, Qu Wenruo wrote:
>> Make sure btrfs check can detect such problem.
>>
>> Right now we have no way to fix it yet.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>
>
> Test case runs fine. Do you use any tool to create the crafted image?

As usual, just hard coded btrfs-corrupt-block to call btrfs_add_link()
for a directory.

Thus there isn't really a good tool to craft such image.

Thanks,
Qu
>
> Reviewed-by: Anand Jain <anand.jain@oracle.com>
>
> Thanks, Anand
>
>> ---
>>   .../049-dir-hard-link/default.img.xz          | Bin 0 -> 1712 bytes
>>   tests/fsck-tests/049-dir-hard-link/test.sh    |  19 ++++++++++++++++++
>>   2 files changed, 19 insertions(+)
>>   create mode 100644 tests/fsck-tests/049-dir-hard-link/default.img.xz
>>   create mode 100755 tests/fsck-tests/049-dir-hard-link/test.sh
>>
>> diff --git a/tests/fsck-tests/049-dir-hard-link/default.img.xz
>> b/tests/fsck-tests/049-dir-hard-link/default.img.xz
>> new file mode 100644
>> index
>> 0000000000000000000000000000000000000000..fd9971acae78975f5263da022feea39e34b45139
>>
>> GIT binary patch
>> literal 1712
>> zcmV;h22c6@H+ooF000E$*0e?f03iV!0000G&sfah3;zaiT>wRyj;C3^v%$$4d1lq4
>> zhDvnFHzu^a0%EHA+fjUfU^d-f8FD79nuh5qo92GkFUET_5R5Y~d)afdfW4sb2eW+N
>> z(-N9N;@zX$?eR^yQlFZnSsfYzwplHEI#}i{O3&^g-%*#*J}6=@&Mr933Z)S+DYv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7ytk~fZMIH#Ao{g00000
>> G1X)_MbXXt&
>>
>> literal 0
>> HcmV?d00001
>>
>> diff --git a/tests/fsck-tests/049-dir-hard-link/test.sh
>> b/tests/fsck-tests/049-dir-hard-link/test.sh
>> new file mode 100755
>> index 000000000000..992ad638bd47
>> --- /dev/null
>> +++ b/tests/fsck-tests/049-dir-hard-link/test.sh
>> @@ -0,0 +1,19 @@
>> +#!/bin/bash
>> +#
>> +# Verify that check can detect overlapped dir with 2 links
>> +#
>> +# There is a report that btrfs-check doesn't report dir with 2 links as
>> +# error, and only get caught by tree-checker.
>> +#
>> +# Make sure btrfs check can at least detect such error
>> +
>> +source "$TEST_TOP/common"
>> +
>> +check_prereq btrfs
>> +
>> +check_image() {
>> +    run_mustfail "dir with 2 links not detected" \
>> +        "$TOP/btrfs" check "$1"
>> +}
>> +
>> +check_all_images
>>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2
  2021-07-18 12:54 [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Qu Wenruo
  2021-07-18 12:54 ` [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links Qu Wenruo
  2021-07-19  0:39 ` [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Su Yue
@ 2021-07-30 13:54 ` David Sterba
  2 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2021-07-30 13:54 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Sun, Jul 18, 2021 at 08:54:48PM +0800, Qu Wenruo wrote:
> Linux VFS doesn't allow directory to have hard links, thus for btrfs
> on-disk directory inode items, their nlinks should never go beyond 1.
> 
> Lowmem mode already has the check and will report it without problem.
> Only original mode needs this update.
> 
> Reported-by: Pepperpoint <pepperpoint@mb.ardentcoding.com>
> Link: https://lore.kernel.org/linux-btrfs/162648632340.7.1932907459648384384.10178178@mb.ardentcoding.com/
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to devel, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-30 13:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18 12:54 [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Qu Wenruo
2021-07-18 12:54 ` [PATCH 2/2] btrfs-progs: fsck-test: add test case where one dir has two links Qu Wenruo
2021-07-19  9:57   ` Anand Jain
2021-07-19 10:25     ` Qu Wenruo
2021-07-19  0:39 ` [PATCH 1/2] btrfs-progs: check/original: detect directory inode with nlinks >= 2 Su Yue
2021-07-30 13:54 ` 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.