linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Su Yue <suy.fnst@cn.fujitsu.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 2/3] btrfs-progs: lowmem: check symlinks with append/immutable flags
Date: Tue, 15 May 2018 15:38:04 +0800	[thread overview]
Message-ID: <72f90dd2-5a17-12c2-b87d-53acd0d3e78f@gmx.com> (raw)
In-Reply-To: <20180515013324.18838-3-suy.fnst@cn.fujitsu.com>


[-- 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 --]

  reply	other threads:[~2018-05-15  7:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72f90dd2-5a17-12c2-b87d-53acd0d3e78f@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=suy.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).