All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shoaib Rao <rao.shoaib@oracle.com>
To: Eric Dumazet <edumazet@google.com>
Cc: netdev <netdev@vger.kernel.org>, Jakub Kicinski <kuba@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] af_unix: fix holding spinlock in oob handling
Date: Thu, 12 Aug 2021 09:23:34 -0700	[thread overview]
Message-ID: <faeb0704-b495-36ef-3138-6223d28d5eab@oracle.com> (raw)
In-Reply-To: <CANn89i+utnHk-aoS=q2sLC8uLaMJDYsW=1O+c4fzODQd0P3stA@mail.gmail.com>

Hi Eric,

Thanks for your review I will take care of the comments.

Shoaib

On 8/12/21 12:53 AM, Eric Dumazet wrote:
> On Thu, Aug 12, 2021 at 12:07 AM Rao Shoaib <Rao.Shoaib@oracle.com> wrote:
>> From: Rao Shoaib <rao.shoaib@oracle.com>
>>
>> syzkaller found that OOB code was holding spinlock
>> while calling a function in which it could sleep.
>>
>> Reported-by: syzbot+8760ca6c1ee783ac4abd@syzkaller.appspotmail.com
>>
>> Fixes: 314001f0bf92 ("af_unix: Add OOB support")
>>
>> Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
>> ---
> Please do not add these empty lines.
>
> Fixes: ...
> Reported-by: ...
> Signed-off-by: ...
> Also you might take a look at queue_oob()
>
> 1)  Setting skb->len tp 1 should not be needed, skb_put() already does that
> 2) After unix_state_lock(other); we probably need to check status of
> the other socket.
> 3) Some skb_free() calls should have been consume_skb()
>
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index ec02e70a549b42f6c102253508c48426a13f7bc4..0c27e2976f9d234ca3bb131731375bc51a056846
> 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -1908,7 +1908,6 @@ static int queue_oob(struct socket *sock, struct
> msghdr *msg, struct sock *other
>                  return err;
>
>          skb_put(skb, 1);
> -       skb->len = 1;
>          err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, 1);
>
>          if (err) {
> @@ -1917,11 +1916,17 @@ static int queue_oob(struct socket *sock,
> struct msghdr *msg, struct sock *other
>          }
>
>          unix_state_lock(other);
> +       if (sock_flag(other, SOCK_DEAD) ||
> +           (other->sk_shutdown & RCV_SHUTDOWN)) {
> +               unix_state_unlock(other);
> +               kfree_skb(skb);
> +               return -EPIPE;
> +       }
>          maybe_add_creds(skb, sock, other);
>          skb_get(skb);
>
>          if (ousk->oob_skb)
> -               kfree_skb(ousk->oob_skb);
> +               consume_skb(ousk->oob_skb);
>
>          ousk->oob_skb = skb;

  reply	other threads:[~2021-08-12 16:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 22:06 [PATCH] af_unix: fix holding spinlock in oob handling Rao Shoaib
2021-08-12  7:53 ` Eric Dumazet
2021-08-12 16:23   ` Shoaib Rao [this message]
2021-08-12 17:37   ` Shoaib Rao
2021-08-12 20:33     ` Eric Dumazet
2021-08-12 20:38       ` Shoaib Rao
2021-08-13 17:32 ` Jakub Kicinski
2021-08-13 17:59   ` Shoaib Rao
2021-08-13 17:46 Rao Shoaib

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=faeb0704-b495-36ef-3138-6223d28d5eab@oracle.com \
    --to=rao.shoaib@oracle.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.