From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Yousef Alhouseen <alhouseenyousef@gmail.com>,
Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
syzbot+bf5586280a66e9ccdfa9@syzkaller.appspotmail.com,
Barry Song <baohua@kernel.org>
Subject: Re: [PATCH] tmpfs: zero unused folio tail for long symlinks
Date: Mon, 29 Jun 2026 11:27:47 +0800 [thread overview]
Message-ID: <dde92cd4-c6fe-4339-a892-004ca78ebc30@linux.alibaba.com> (raw)
In-Reply-To: <20260628004314.27370-1-alhouseenyousef@gmail.com>
CC Barry.
On 6/28/26 8:43 AM, Yousef Alhouseen wrote:
> shmem_symlink() marks the entire folio uptodate after copying only the
> NUL-terminated link target. The remainder of the freshly allocated folio
> is left uninitialized.
>
> Reclaim may pass the whole folio to a swap compressor. KMSAN observed
> sw842_compress() computing a checksum over the uninitialized tail. If
> the folio is written to a swap device, those bytes can also leave the
> kernel.
>
> Zero the remainder of the folio before marking it uptodate and dirty.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: syzbot+bf5586280a66e9ccdfa9@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=bf5586280a66e9ccdfa9
> Cc: stable@vger.kernel.org
Do we need CC stable? Have you observed any actual impact?
> Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
> ---
> mm/shmem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index b51f83c970bb..b06c1ae2f50c 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4057,6 +4057,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
> goto out_remove_offset;
> inode->i_op = &shmem_symlink_inode_operations;
> memcpy(folio_address(folio), symname, len);
> + folio_zero_range(folio, len, folio_size(folio) - len);
> folio_mark_uptodate(folio);
> folio_mark_dirty(folio);
> folio_unlock(folio);
Thanks. Barry sent the same fix before[1] (though I forgot why it didn't
get merged). I think this is a reasonable fix. So:
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
[1] https://lore.kernel.org/lkml/20251224020424.52976-1-21cnbao@gmail.com/
prev parent reply other threads:[~2026-06-29 3:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 0:43 [PATCH] tmpfs: zero unused folio tail for long symlinks Yousef Alhouseen
2026-06-29 3:27 ` Baolin Wang [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=dde92cd4-c6fe-4339-a892-004ca78ebc30@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=alhouseenyousef@gmail.com \
--cc=baohua@kernel.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+bf5586280a66e9ccdfa9@syzkaller.appspotmail.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