Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1332286
| From | Rainer Weikusat <rweikusat@mobileactivedefense.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: Bug 4.1.16: self-detected stall in net/unix/? |
| Date | 2016-02-11 19:40 +0100 |
| Message-ID | <r14jL-48t-5@gated-at.bofh.it> (permalink) |
| References | <qYQuB-22s-11@gated-at.bofh.it> <r0ZN8-13S-15@gated-at.bofh.it> <r11OW-2po-11@gated-at.bofh.it> <r12UG-3l3-7@gated-at.bofh.it> <r13xn-3yp-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Rainer Weikusat <rw@doppelsaurus.mobileactivedefense.com> writes:
> Ben Hutchings <ben@decadent.org.uk> writes:
[...]
>> unix: Fix potential double-unlock in unix_dgram_sendmsg()
>>
>> A datagram socket may be peered with itself, so that sk == other. We
>> use unix_state_double_lock() to lock sk and other in the right order,
>> which also guards against this and only locks the socket once, but we
>> then end up trying to unlock it twice. Add the check for sk != other.
[...]
> other was found via
>
> if (!other) {
> err = -ECONNRESET;
> if (sunaddr == NULL)
> goto out_free;
>
> other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
> hash, &err);
> if (other == NULL)
> goto out_free;
> }
>
> and the if-block leading to the double lock should never have been
> executed as it's supposed to deal with the case where sk is connect to
> other but other not to sk (eg, /dev/log).
Test program triggering a double unlock (w/o the MSG_DONTWAIT, it blocks
which it isn't supposed to do):
--------
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#define SUN_NAME "\0other-is-me"
int main(int argc, char **argv)
{
struct sockaddr_un sun;
unsigned max;
int sk, rc;
sk = socket(AF_UNIX, SOCK_DGRAM, 0);
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, SUN_NAME, sizeof(sun.sun_path));
bind(sk, (struct sockaddr *)&sun, sizeof(sun));
max = 12;
do
sendto(sk, &sun, sizeof(sun), MSG_DONTWAIT,
(struct sockaddr *)&sun, sizeof(sun));
while (--max);
return 0;
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Bug 4.1.16: self-detected stall in net/unix/? Philipp Hahn <pmhahn@pmhahn.de> - 2016-02-11 14:50 +0100
Re: Bug 4.1.16: self-detected stall in net/unix/? Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-11 17:00 +0100
Re: Bug 4.1.16: self-detected stall in net/unix/? Ben Hutchings <ben@decadent.org.uk> - 2016-02-11 18:10 +0100
Re: Bug 4.1.16: self-detected stall in net/unix/? Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-11 18:50 +0100
Re: Bug 4.1.16: self-detected stall in net/unix/? Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-11 19:00 +0100
Re: Bug 4.1.16: self-detected stall in net/unix/? Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-11 19:40 +0100
[PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-11 20:40 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Philipp Hahn <pmhahn@pmhahn.de> - 2016-02-12 10:20 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-12 14:30 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Ben Hutchings <ben@decadent.org.uk> - 2016-02-12 21:00 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-12 21:20 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Ben Hutchings <ben@decadent.org.uk> - 2016-02-12 21:50 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-12 22:10 +0100
Re: [PATCH net] af_unix: Guard against other == sk in unix_dgram_sendmsg David Miller <davem@davemloft.net> - 2016-02-16 19:00 +0100
csiph-web