mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd@bsbernd.com>
To: Joanne Koong <joannelkoong@gmail.com>, Xiang Mei <xmei5@asu.edu>
Cc: Baokun Li <libaokun@linux.alibaba.com>,
	Miklos Szeredi <miklos@szeredi.hu>, Kees Cook <kees@kernel.org>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	fuse-devel@lists.linux.dev, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Luis Henriques <luis@igalia.com>,
	Pavel Begunkov <asml.silence@gmail.com>,
	bestswngs@gmail.com
Subject: Re: [PATCH v4 1/3] fuse: whitelist the request headers for usercopy
Date: Wed, 15 Jul 2026 23:59:30 +0200	[thread overview]
Message-ID: <c48c4541-c62a-45cc-aa3d-1c78a48d0676@bsbernd.com> (raw)
In-Reply-To: <CAJnrk1b4VAsyEMx7obFTBgP8M3dBcD1+QnKVQK-r881MBySDOg@mail.gmail.com>



On 7/15/26 20:13, Joanne Koong wrote:
> On Tue, Jul 14, 2026 at 4:54 PM Xiang Mei <xmei5@asu.edu> wrote:
>>
>> The fuse-io-uring transport copies req->in.h out to the ring in
>> fuse_uring_copy_to_ring() and req->out.h back in fuse_uring_commit().
>> Both headers live inside the fuse_request slab object, whose cache
>> (fuse_req_cachep) is created without a usercopy whitelist, so copying
>> them directly to/from userspace trips CONFIG_HARDENED_USERCOPY and
>> panics:
>>
>>   usercopy: Kernel memory exposure attempt detected from SLUB object
>>   'fuse_request' (offset 56, size 40)!
>>   kernel BUG at mm/usercopy.c:102!
>>   Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
>>   RIP: 0010:usercopy_abort (mm/usercopy.c:90)
>>   Call Trace:
>>    __check_heap_object (mm/slub.c:8268)
>>    __check_object_size (mm/usercopy.c:197 mm/usercopy.c:258 mm/usercopy.c:223)
>>    copy_header_to_ring (fs/fuse/dev_uring.c:618)
>>    fuse_uring_prepare_send (fs/fuse/dev_uring.c:776 fs/fuse/dev_uring.c:785)
>>    fuse_uring_send_in_task (fs/fuse/dev_uring.c:1306)
>>    tctx_task_work_run (io_uring/tw.c:96)
>>    task_work_run (kernel/task_work.c:233)
>>    io_run_task_work (io_uring/tw.h:84)
>>    io_cqring_wait (io_uring/wait.c:278)
>>    __do_sys_io_uring_enter (io_uring/io_uring.c:2685)
>>    entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
>>
>> in.h and out.h are adjacent in struct fuse_req, so a single usercopy
>> region starting at in.h covers both and nothing else.  Create the cache
>> with that region whitelisted.
>>
>> Fixes: c090c8abae4b ("fuse: Add io-uring sqe commit and fetch support")
>> Cc: stable@vger.kernel.org
>> Reported-by: Weiming Shi <bestswngs@gmail.com>
>> Suggested-by: Baokun Li <libaokun@linux.alibaba.com>
>> Assisted-by: Claude:claude-opus-4-8
>> Signed-off-by: Xiang Mei <xmei5@asu.edu>
>> ---
>> v3: no context change; add Bernd's Reviewed-by
>> v4: drop previous tags; use kmem_cache_args to reserve usercopy area
>>
>>  fs/fuse/dev.c        | 9 +++++++--
>>  fs/fuse/fuse_dev_i.h | 5 +++++
>>  2 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
>> index 5763a7cd3b37..b8e43e374b35 100644
>> --- a/fs/fuse/dev.c
>> +++ b/fs/fuse/dev.c
>> @@ -2404,10 +2404,15 @@ static struct miscdevice fuse_miscdevice = {
>>
>>  int __init fuse_dev_init(void)
>>  {
>> +       struct kmem_cache_args args = {
>> +               .useroffset = offsetof(struct fuse_req, in.h),
>> +               .usersize = sizeof_field(struct fuse_req, in.h) +
>> +                           sizeof_field(struct fuse_req, out.h),
>> +       };
>>         int err = -ENOMEM;
>> +
>>         fuse_req_cachep = kmem_cache_create("fuse_request",
>> -                                           sizeof(struct fuse_req),
>> -                                           0, 0, NULL);
>> +                                           sizeof(struct fuse_req), &args, 0);
>>         if (!fuse_req_cachep)
>>                 goto out;
>>
>> diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
>> index 668c8391d61c..b511aaab6bfc 100644
>> --- a/fs/fuse/fuse_dev_i.h
>> +++ b/fs/fuse/fuse_dev_i.h
>> @@ -81,6 +81,11 @@ struct fuse_req {
>>         /** @flags: Request flags, updated with test/set/clear_bit() */
>>         unsigned long flags;
>>
>> +       /*
>> +        * @in and @out are the usercopy region of this cache (see
>> +        * fuse_dev_init()); keep them adjacent.
>> +        */
>> +
>>         /** @in: The request input header */
>>         struct {
>>                 /** @in.h: The request input header */
>> --
>> 2.43.0
>>
> 
> I think this is more a matter of preference as they're both
> functionally correct but imo the previous approach seemed cleaner,
> given that only the io-uring path needs this. The extra hop goes
> through a tmp stack variable whose memory is already in the L1 cache
> and the memcpys are small (~40 bytes), so I think the cost is
> essentially negligible. Not sure if Bernd or Miklos or Amir have a
> preference here.

Sorry for late replies, currently on vacation and reviews only when
everyone else is asleep.

I don't have a strong opinion, I wondered the same if the stack copy was
avoidable, but then came to the same conclusion as Joanne - negligible
overhead.


Thanks,
Bernd

  reply	other threads:[~2026-07-15 21:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 23:54 Xiang Mei
2026-07-14 23:54 ` [PATCH v4 2/3] fuse: bound io-uring payload copies to the registered buffer size Xiang Mei
2026-07-14 23:54 ` [PATCH v4 3/3] fuse: deduplicate the oversized-request error selection Xiang Mei
2026-07-15 18:30   ` Joanne Koong
2026-07-15  2:17 ` [PATCH v4 1/3] fuse: whitelist the request headers for usercopy Baokun Li
2026-07-15 18:13 ` Joanne Koong
2026-07-15 21:59   ` Bernd Schubert [this message]
2026-07-27 23:39     ` Xiang Mei

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=c48c4541-c62a-45cc-aa3d-1c78a48d0676@bsbernd.com \
    --to=bernd@bsbernd.com \
    --cc=asml.silence@gmail.com \
    --cc=bestswngs@gmail.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=gustavoars@kernel.org \
    --cc=joannelkoong@gmail.com \
    --cc=kees@kernel.org \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luis@igalia.com \
    --cc=miklos@szeredi.hu \
    --cc=stable@vger.kernel.org \
    --cc=xmei5@asu.edu \
    /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®