mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <shao.mingyin@zte.com.cn>, <richard@nod.at>,
	<linux-mtd@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH 2/5] ubifs: reject xattr inodes whose size does not match the value
Date: Tue, 3 Nov 2026 10:06:15 +0800	[thread overview]
Message-ID: <9ff68e0a-18b4-fb7f-238c-105e5b247a9d@huawei.com> (raw)
In-Reply-To: <20261102214934411GPsnXXiPDuCvO4pgPeTgU@zte.com.cn>

在 2026/11/2 21:49, shao.mingyin@zte.com.cn 写道:
> An extended attribute inode stores the value in the inode node and
> UBIFS keeps inode->i_size equal to ubifs_inode->data_len (see
> create_xattr() and change_xattr()).  validate_inode() does not check
> this for inodes that carry UBIFS_XATTR_FL, so an image with a mismatch
> is accepted.  ubifs_xattr_get() and remove_xattr() then trip their
> ubifs_assert() on the invariant; with the assert=read-only or
> assert=panic mount option a plain getxattr() or removexattr() turns the
> file system read-only or panics the kernel.
> 
> Reject such inodes at iget time.
> 
> Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 38972786817e..9f608c10b39e 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -91,6 +91,18 @@ static int validate_inode(struct ubifs_info *c, const struct inode *inode)
>   	if (ui->xattr && !S_ISREG(inode->i_mode))
>   		return 5;
>   
> +	/*
> +	 * Extended attribute inodes keep the value in the inode node and
> +	 * maintain i_size == data_len everywhere (see create_xattr() and
> +	 * change_xattr()).
> +	 */
> +	if (ui->xattr && inode->i_size != ui->data_len) {
> +		ubifs_err(c, "xattr inode %llu has size %lld, but %d bytes of data",
> +			  inode->i_ino, (long long)inode->i_size,
> +			  ui->data_len);
> +		return 6;
> +	}
> +

Above two ui->xattr check could be merged like:
if (ui->xattr) {
   if (!S_ISREG(inode->i_mode))
     return 5;

   if (inode->i_size != ui->data_len)
     return 6;
}
>   	if (!ubifs_compr_present(c, ui->compr_type)) {
>   		ubifs_warn(c, "inode %llu uses '%s' compression, but it was not compiled in",
>   			   inode->i_ino, ubifs_compr_name(c, ui->compr_type));
> .
> 


  reply	other threads:[~2026-11-03  2:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 13:45 [PATCH 0/5] ubifs: harden validation of on-disk inode and node metadata shao.mingyin
2026-11-02 13:45 ` [PATCH 1/5] ubifs: reject inodes with an out-of-range size shao.mingyin
2026-11-02 13:49 ` [PATCH 2/5] ubifs: reject xattr inodes whose size does not match the value shao.mingyin
2026-11-03  2:06   ` Zhihao Cheng [this message]
2026-11-03  4:31     ` shao.mingyin
2026-11-02 13:49 ` [PATCH 3/5] ubifs: reject master nodes claiming a too small inode number shao.mingyin
2026-11-03  2:06   ` Zhihao Cheng
2026-11-03  4:31     ` shao.mingyin
2026-11-03  4:50       ` Zhihao Cheng
2026-11-02 13:49 ` [PATCH 4/5] ubifs: validate inode and data node sizes during replay shao.mingyin
2026-11-02 13:49 ` [PATCH 5/5] ubifs: xattr: guard against xattr accounting underflow shao.mingyin
2026-11-03  2:06 ` [PATCH 0/5] ubifs: harden validation of on-disk inode and node metadata Zhihao Cheng
2026-11-03  4:30   ` shao.mingyin
2026-11-03  4:50     ` Zhihao Cheng

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=9ff68e0a-18b4-fb7f-238c-105e5b247a9d@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=shao.mingyin@zte.com.cn \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®