Linux NFS development
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Jeff Layton <jlayton@kernel.org>,
	Edward Adam Davis <eadavis@qq.com>,
	syzbot+4139435cb1b34cf759c2@syzkaller.appspotmail.com
Cc: amir73il@gmail.com, brauner@kernel.org, chuck.lever@oracle.com,
	jack@suse.cz, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH next] fs: fix oob in do_handle_open
Date: Wed, 3 Apr 2024 06:59:24 -0600	[thread overview]
Message-ID: <88f4493a-2787-4c25-bd0a-80731a603faa@embeddedor.com> (raw)
In-Reply-To: <72d7604e38ee9a37bcb33a6a537758e4412488ee.camel@kernel.org>



On 03/04/24 02:48, Jeff Layton wrote:
> On Wed, 2024-04-03 at 14:54 +0800, Edward Adam Davis wrote:
>> [Syzbot reported]
>> BUG: KASAN: slab-out-of-bounds in instrument_copy_from_user_before include/linux/instrumented.h:129 [inline]
>> BUG: KASAN: slab-out-of-bounds in _copy_from_user+0x7b/0xe0 lib/usercopy.c:22
>> Write of size 48 at addr ffff88802b8cbc88 by task syz-executor333/5090
>>
>> CPU: 0 PID: 5090 Comm: syz-executor333 Not tainted 6.9.0-rc2-next-20240402-syzkaller #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
>> Call Trace:
>>   <TASK>
>>   __dump_stack lib/dump_stack.c:88 [inline]
>>   dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
>>   print_address_description mm/kasan/report.c:377 [inline]
>>   print_report+0x169/0x550 mm/kasan/report.c:488
>>   kasan_report+0x143/0x180 mm/kasan/report.c:601
>>   kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
>>   instrument_copy_from_user_before include/linux/instrumented.h:129 [inline]
>>   _copy_from_user+0x7b/0xe0 lib/usercopy.c:22
>>   copy_from_user include/linux/uaccess.h:183 [inline]
>>   handle_to_path fs/fhandle.c:203 [inline]
>>   do_handle_open+0x204/0x660 fs/fhandle.c:226
>>   do_syscall_64+0xfb/0x240
>>   entry_SYSCALL_64_after_hwframe+0x72/0x7a
>> [Fix]
>> When copying data to f_handle, the length of the copied data should not include
>> the length of "struct file_handle".
>>
>> Reported-by: syzbot+4139435cb1b34cf759c2@syzkaller.appspotmail.com
>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
>> ---
>>   fs/fhandle.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/fhandle.c b/fs/fhandle.c
>> index 53ed54711cd2..8a7f86c2139a 100644
>> --- a/fs/fhandle.c
>> +++ b/fs/fhandle.c
>> @@ -202,7 +202,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
>>   	*handle = f_handle;
>>   	if (copy_from_user(&handle->f_handle,
>>   			   &ufh->f_handle,
>> -			   struct_size(ufh, f_handle, f_handle.handle_bytes))) {
>> +			   f_handle.handle_bytes)) {
>>   		retval = -EFAULT;
>>   		goto out_handle;
>>   	}
> 
> cc'ing Gustavo, since it looks like his patch in -next is what broke
> this.
> 

Oh, sorry about that folks. That looks pretty much like a copy/paste error.

The fix is correct.

Thanks, Edward!
--
Gustavo


      parent reply	other threads:[~2024-04-03 12:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03  8:00 [linux-next:master] [fs] 1b43c46297: kernel_BUG_at_mm/usercopy.c kernel test robot
2024-04-02 17:54 ` [syzbot] [nfs?] KASAN: slab-out-of-bounds Write in do_handle_open syzbot
2024-04-03  6:54   ` [PATCH next] fs: fix oob " Edward Adam Davis
2024-04-03  8:46     ` [linux-next:master] [fs] 1b43c46297: kernel_BUG_at_mm/usercopy.c Christian Brauner
2024-04-03 11:03       ` Jan Kara
2024-04-05 10:26         ` Christian Brauner
2024-04-03  8:48     ` [PATCH next] fs: fix oob in do_handle_open Jeff Layton
2024-04-03  8:50       ` Christian Brauner
2024-04-03 12:59       ` Gustavo A. R. Silva [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=88f4493a-2787-4c25-bd0a-80731a603faa@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=eadavis@qq.com \
    --cc=gustavoars@kernel.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=syzbot+4139435cb1b34cf759c2@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=viro@zeniv.linux.org.uk \
    /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