mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Andrew Morton <akpm@linux-foundation.org>,
	zhangzhengming <zhang.zhengming@h3c.com>
Cc: surenb@google.com, wuchi.zero@gmail.com,
	Ilia.Gavrilov@infotecs.ru, xu.panda@zte.com.cn,
	colin.i.king@gmail.com, linux-kernel@vger.kernel.org,
	zhou.kete@h3c.com, Pengcheng Yang <yangpc@wangsu.com>
Subject: Re: [PATCH] relayfs: fix out-of-bounds access in relay_file_read
Date: Wed, 19 Apr 2023 15:07:29 -0600	[thread overview]
Message-ID: <20391481-88bf-2ef4-cac5-7bd2d33c18d6@kernel.dk> (raw)
In-Reply-To: <20230419140325.b85d54794baaa828a19c138f@linux-foundation.org>

On 4/19/23 3:03?PM, Andrew Morton wrote:
> On Wed, 19 Apr 2023 12:02:03 +0800 zhangzhengming <zhang.zhengming@h3c.com> wrote:
> 
>> From: Zhang Zhengming <zhang.zhengming@h3c.com>
>>
>> There is a crash in relay_file_read, as the var from 
>> point to the end of last subbuf.
>> The oops looks something like:
>> pc : __arch_copy_to_user+0x180/0x310
>> lr : relay_file_read+0x20c/0x2c8
>> Call trace:
>>  __arch_copy_to_user+0x180/0x310
>>  full_proxy_read+0x68/0x98
>>  vfs_read+0xb0/0x1d0
>>  ksys_read+0x6c/0xf0
>>  __arm64_sys_read+0x20/0x28
>>  el0_svc_common.constprop.3+0x84/0x108
>>  do_el0_svc+0x74/0x90
>>  el0_svc+0x1c/0x28
>>  el0_sync_handler+0x88/0xb0
>>  el0_sync+0x148/0x180
>>
>> We get the condition by analyzing the vmcore:
>> 1). The last produced byte and last consumed byte
>>     both at the end of the last subbuf
>> 2). A softirq who will call function(e.g __blk_add_trace)
>>     to write relay buffer occurs when an program calling
>>     function relay_file_read_avail.
>>         relay_file_read
>>                 relay_file_read_avail
>>                         relay_file_read_consume(buf, 0, 0);
>>                         //interrupted by softirq who will write subbuf
>>                         ....
>>                         return 1;
>>                 //read_start point to the end of the last subbuf
>>                 read_start = relay_file_read_start_pos
>>                 //avail is equal to subsize
>>                 avail = relay_file_read_subbuf_avail
>>                 //from  points to an invalid memory address             
>>                 from = buf->start + read_start
>>                 //system is crashed
>>                 copy_to_user(buffer, from, avail)
> 
> Thanks.  Hopefully Pengcheng Yang and Jens Axboe can comment.

Patch looks good to me, but that doesn't necessarily say much. I never
did much relayfs hacking, and the bits I did was probably almost 20
years ago at this point when I wrote blktrace...

-- 
Jens Axboe


  reply	other threads:[~2023-04-19 21:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  4:02 zhangzhengming
2023-04-19 21:03 ` Andrew Morton
2023-04-19 21:07   ` Jens Axboe [this message]
2023-04-23  8:28   ` Pengcheng Yang

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=20391481-88bf-2ef4-cac5-7bd2d33c18d6@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=Ilia.Gavrilov@infotecs.ru \
    --cc=akpm@linux-foundation.org \
    --cc=colin.i.king@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=wuchi.zero@gmail.com \
    --cc=xu.panda@zte.com.cn \
    --cc=yangpc@wangsu.com \
    --cc=zhang.zhengming@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®