netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denis Kirjanov <kda@linux-powerpc.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH] net/af_unix: don't create a path for a binded socket
Date: Thu, 26 Nov 2020 17:22:08 +0300	[thread overview]
Message-ID: <CAOJe8K1EVPapfRrtzK1hD4_St9vqFT1aad4JvE1Ch6X-rD6=iA@mail.gmail.com> (raw)
In-Reply-To: <20201125152742.05800094@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On 11/26/20, Jakub Kicinski <kuba@kernel.org> wrote:
> On Tue, 24 Nov 2020 15:24:21 +0300 Denis Kirjanov wrote:
>> in the case of the socket which is bound to an adress
>> there is no sense to create a path in the next attempts
>
>> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
>> index 41c3303c3357..fd76a8fe3907 100644
>> --- a/net/unix/af_unix.c
>> +++ b/net/unix/af_unix.c
>> @@ -1021,7 +1021,7 @@ static int unix_bind(struct socket *sock, struct
>> sockaddr *uaddr, int addr_len)
>>
>>  	err = -EINVAL;
>>  	if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
>> -	    sunaddr->sun_family != AF_UNIX)
>> +	    sunaddr->sun_family != AF_UNIX || u->addr)
>>  		goto out;
>>
>>  	if (addr_len == sizeof(short)) {
>> @@ -1049,10 +1049,6 @@ static int unix_bind(struct socket *sock, struct
>> sockaddr *uaddr, int addr_len)
>>  	if (err)
>>  		goto out_put;
>>
>> -	err = -EINVAL;
>> -	if (u->addr)
>> -		goto out_up;
>> -
>>  	err = -ENOMEM;
>>  	addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL);
>>  	if (!addr)
>
> Well, after your change the check on u->addr is no longer protected by
> u->bindlock. Is that okay?

Since we're just checking the assigned address and it's an atomic
operation I think it's okay.
A process performing binding is still protected.

Thanks!


>

  reply	other threads:[~2020-11-26 14:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 12:24 [PATCH] net/af_unix: don't create a path for a binded socket Denis Kirjanov
2020-11-25 23:27 ` Jakub Kicinski
2020-11-26 14:22   ` Denis Kirjanov [this message]
2020-11-27 22:48     ` Jakub Kicinski

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='CAOJe8K1EVPapfRrtzK1hD4_St9vqFT1aad4JvE1Ch6X-rD6=iA@mail.gmail.com' \
    --to=kda@linux-powerpc.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).