LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Xianting TIan <xianting.tian@linux.alibaba.com>
To: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	guoren@kernel.org
Subject: Re: [PATCH] mailbox: fix a UAF bug in msg_submit()
Date: Tue, 17 Aug 2021 16:01:08 +0800	[thread overview]
Message-ID: <26a45754-4227-5f20-8c7d-c320d3905b60@linux.alibaba.com> (raw)
In-Reply-To: <977740a4-c08d-663d-410e-3375d034d2e8@linux.alibaba.com>


在 2021/8/17 下午1:58, Xianting TIan 写道:
>
> 在 2021/8/17 下午12:29, Jassi Brar 写道:
>> On Fri, Aug 6, 2021 at 7:15 AM Xianting Tian
>> <xianting.tian@linux.alibaba.com> wrote:
>>> We met a UAF issue during our mailbox testing.
>>>
>>> In synchronous mailbox, we use mbox_send_message() to send a message
>>> and wait for completion. mbox_send_message() calls msg_submit() to
>>> send the message for the first time, if timeout, it will send the
>>> message in tx_tick() for the second time.
>>>
>> Seems like your controller's  .send_data() returns error. Can you
>> please explain why it does so? Because
>> send_data() only _accepts_ data for further transmission... which
>> should seldom be a problem.
>
> Thanks for the comments,
>
> We developed virtio-mailbox for heterogeneous virtualization system.
>
> virtio-mailbox is based on the mialbox framework.
>
> In virtio framework, its send func 'virtqueue_add_outbuf()' may return 
> error, which caused .send_data() return error.  And also contains 
> other csenarios.
>
> But I think mailbox framework shouldn't depend on .send_data() always 
> return OK,  as .send_data() is implemented by mailbox hardware 
> manufacturer, which is not controlled by mailbox framework itself.
>
> You said 'seldom',  but it still possible we can meet such issue. sucn 
> as flexrm_send_data() of drivers/mailbox/bcm-flexrm-mailbox.c.
>
> I think mailbox framework should be work normaly no matter 
> .send_data() returns ok or not ok.  Do you think so? thanks

Another solution is to ignore the return value of .send_data() in 
msg_submit(),

change

         err = chan->mbox->ops->send_data(chan, data);
         if (!err) {
                 chan->active_req = data;
                 chan->msg_count--;
         }

to

         chan->mbox->ops->send_data(chan, data);
         chan->active_req = data;
         chan->msg_count--;

But the side effect of the solution is obvious, as if send failed in the 
first time, it will have no chance to sent it in tx_tick() for the 
second time. That is to say, no retry.

So I think the solution in this patch is better.

Looking forward to your further comments, thanks

>
>>
>> thanks.

  reply	other threads:[~2021-08-17  8:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06 12:15 Xianting Tian
2021-08-10 10:45 ` Xianting TIan
2021-08-11  2:37 ` Guo Ren
2021-08-17  3:40   ` Xianting TIan
2021-08-17  4:29 ` Jassi Brar
2021-08-17  5:40   ` Xianting TIan
2021-08-17  5:58   ` Xianting TIan
2021-08-17  8:01     ` Xianting TIan [this message]
2021-08-17 23:33       ` Jassi Brar
2021-08-18  1:40         ` Xianting TIan

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=26a45754-4227-5f20-8c7d-c320d3905b60@linux.alibaba.com \
    --to=xianting.tian@linux.alibaba.com \
    --cc=guoren@kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] mailbox: fix a UAF bug in msg_submit()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).