mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Nan Lin <lin.nan@h3c.com>, <richard@nod.at>
Cc: <linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<wangxiaoqing@h3c.com>, <zhou.kete@h3c.com>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH v2] ubifs: fix host inode TNC offset when deleting an xattr
Date: Tue, 13 Oct 2026 14:09:22 +0800	[thread overview]
Message-ID: <e9bde32f-753c-a803-3fab-cb49e1031aeb@huawei.com> (raw)
In-Reply-To: <20261013052953.1401741-1-lin.nan@h3c.com>

在 2026/10/13 13:29, Nan Lin 写道:
> ubifs_jnl_delete_xattr() writes a group of three nodes: the xent, the
> xattr inode and the host inode. The host inode is packed at
> xent_offs + aligned_xlen + UBIFS_INO_NODE_SZ, but its TNC position is
> computed backwards as xent_offs + len - hlen. Since len includes the
> group's tail padding, ALIGN(hlen, 8) - hlen, the two differ whenever
> the host inode's inline data length is not a multiple of 8. This
> affects symlinks and device nodes.
> 
> The unaligned offset ends up in the on-flash index and the next mount
> rejects the index node, turning the filesystem read-only.
> 
> Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
> Cc: stable@vger.kernel.org
> Tested-by: Zhihao Cheng <chengzhihao1@huawei.com>
> Signed-off-by: Nan Lin <lin.nan@h3c.com>
> 
> Changes since v1:
>   - compute the host inode offset into a new host_offs variable instead
>     of open-coding the offset (Richard Weinberger);
>   - shorten the commit message.
> 
> ---
>   fs/ubifs/journal.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index 40a95a2fad50..0b2dae57e467 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -1858,7 +1858,8 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
>   			   const struct inode *inode,
>   			   const struct fscrypt_name *nm)
>   {
> -	int err, xlen, hlen, len, lnum, xent_offs, aligned_xlen, write_len;
> +	int err, xlen, hlen, len, lnum, xent_offs, host_offs, aligned_xlen,
> +		write_len;
>   	struct ubifs_dent_node *xent;
>   	struct ubifs_ino_node *ino;
>   	union ubifs_key xent_key, key1, key2;
> @@ -1915,6 +1916,8 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
>   		ubifs_wbuf_add_ino_nolock(&c->jheads[BASEHD].wbuf, host->i_ino);
>   	release_head(c, BASEHD);
>   
> +	host_offs = xent_offs + aligned_xlen + UBIFS_INO_NODE_SZ;
> +
>   	ubifs_add_auth_dirt(c, lnum);
>   	kfree(xent);
>   	if (err)
> @@ -1943,7 +1946,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
>   
>   	/* And update TNC with the new host inode position */
>   	ino_key_init(c, &key1, host->i_ino);
> -	err = ubifs_tnc_add(c, &key1, lnum, xent_offs + len - hlen, hlen, hash);
> +	err = ubifs_tnc_add(c, &key1, lnum, host_offs, hlen, hash);
>   	if (err)
>   		goto out_ro;
>   
> 


      reply	other threads:[~2026-10-13  6:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12  7:50 [PATCH] " Nan Lin
2026-10-12 19:56 ` AW: " Richard Weinberger
2026-10-13  2:15   ` Zhihao Cheng
2026-10-13  5:29   ` [PATCH v2] " Nan Lin
2026-10-13  6:09     ` Zhihao Cheng [this message]

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=e9bde32f-753c-a803-3fab-cb49e1031aeb@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=lin.nan@h3c.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=wangxiaoqing@h3c.com \
    --cc=zhou.kete@h3c.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

all inboxes | Powered by JetHome®