public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Gao Xiang <hsiangkao@linux.alibaba.com>, xiang@kernel.org
Cc: chao@kernel.org, linux-erofs@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH] erofs: fix UAF issue in erofs_fileio_rq_submit()
Date: Fri, 6 Feb 2026 15:15:46 +0800	[thread overview]
Message-ID: <712352c3-c0a1-4e9f-a689-0761e7a2f197@kernel.org> (raw)
In-Reply-To: <9d70646b-ddf8-42b5-8015-fb54a6f24296@linux.alibaba.com>

Xiang,

On 2/6/2026 3:11 PM, Gao Xiang wrote:
> Hi Chao,
> 
> On 2026/2/6 06:30, Chao Yu wrote:
>> [    9.269940][ T3222] Call trace:
>> [    9.269948][ T3222]  ext4_file_read_iter+0xac/0x108
>> [    9.269979][ T3222]  vfs_iocb_iter_read+0xac/0x198
>> [    9.269993][ T3222]  erofs_fileio_rq_submit+0x12c/0x180
>> [    9.270008][ T3222]  erofs_fileio_submit_bio+0x14/0x24
>> [    9.270030][ T3222]  z_erofs_runqueue+0x834/0x8ac
>> [    9.270054][ T3222]  z_erofs_read_folio+0x120/0x220
>> [    9.270083][ T3222]  filemap_read_folio+0x60/0x120
>> [    9.270102][ T3222]  filemap_fault+0xcac/0x1060
>> [    9.270119][ T3222]  do_pte_missing+0x2d8/0x1554
>> [    9.270131][ T3222]  handle_mm_fault+0x5ec/0x70c
>> [    9.270142][ T3222]  do_page_fault+0x178/0x88c
>> [    9.270167][ T3222]  do_translation_fault+0x38/0x54
>> [    9.270183][ T3222]  do_mem_abort+0x54/0xac
>> [    9.270208][ T3222]  el0_da+0x44/0x7c
>> [    9.270227][ T3222]  el0t_64_sync_handler+0x5c/0xf4
>> [    9.270253][ T3222]  el0t_64_sync+0x1bc/0x1c0
>>
>> erofs may encounter above panic when enabling file-backed mount w/ directio
>> mount option, the root cause is it may suffer UAF in below race condition:
>>
>> - z_erofs_read_folio                          wq s_dio_done_wq
>>    - z_erofs_runqueue
>>     - erofs_fileio_submit_bio
>>      - erofs_fileio_rq_submit
>>       - vfs_iocb_iter_read
>>        - ext4_file_read_iter
>>         - ext4_dio_read_iter
>>          - iomap_dio_rw
>>          : bio was submitted and return -EIOCBQUEUED
>>                                                 - dio_aio_complete_work
>>                                                  - dio_complete
>>                                                   - dio->iocb->ki_complete (erofs_fileio_ki_complete())
>>                                                    - kfree(rq)
>>                                                    : it frees iocb, iocb.ki_filp can be UAF in file_accessed().
>>          - file_accessed
>>          : access NULL file point
>>
>> Introduce a reference count in struct erofs_fileio_rq, and initialize it
>> as two, both erofs_fileio_ki_complete() and erofs_fileio_rq_submit() will
>> decrease reference count, the last one decreasing the reference count
>> to zero will free rq.
>>
>> Cc: stable@kernel.org
>> Fixes: fb176750266a ("erofs: add file-backed mount support")
>> Signed-off-by: Chao Yu <chao@kernel.org>
> 
> Thanks for catching this:>
> I will update the subject as
> "erofs: fix UAF issue for file-backed mounts w/ directio"
> 
> to make it more clear about the impacts.

Make sense to me, thanks for the review.

Thanks,

> 
> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> 
> Thanks,
> Gao Xiang



      reply	other threads:[~2026-02-06  7:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 22:30 [PATCH] erofs: fix UAF issue in erofs_fileio_rq_submit() Chao Yu
2026-02-06  7:11 ` Gao Xiang
2026-02-06  7:15   ` Chao Yu [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=712352c3-c0a1-4e9f-a689-0761e7a2f197@kernel.org \
    --to=chao@kernel.org \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    --cc=xiang@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