lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAApbN=K4gMqsk1SEPfdR1+J0CgoxYDONSi83TPNMxxHisXmA9A@mail.gmail.com>
Date:	Sat, 16 Nov 2013 13:57:12 -0800
From:	mpb <mpb.mail@...il.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	Hannes Frederic Sowa <hannes@...essinduktion.org>,
	netdev@...r.kernel.org
Subject: Re: [PATCH v3] net: don't return uninitialized addresses on
 concurrent socket shutdown

>> @@ -1847,6 +1848,8 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
>>       err = sock_recvmsg(sock, &msg, size, flags);
>>
>>       if (err >= 0 && addr != NULL) {
>> +             if (unlikely(address.ss_family == AF_INVALID))
>> +                     memset(&address, 0, sizeof(address));

Or perhaps only when err == 0?

      if (err >= 0 && addr != NULL) {
+             if ( (err == 0)  &&  unlikely(address.ss_family == AF_INVALID) )
+                     memset(&address, 0, sizeof(address));

In other words, in pseudo code:

When err == 0, the kernel checks to make sure the socket has not been
shutdown before calling move_addr_to_user.
If err == 0 and a shutdown has happened, then set addr to a value that
signifies that a shutdown was detected (or at least that a message was
not received).  After a shutdown, I believe err will only be one of 0
or -1.  If err > 0, then a shutdown has not happened.

Another approach would be to return -1 to userland and set errno to
something like EWOULDBLOCK.

Another thought: addr_len is probably smaller than sizeof(address), so
only memset whichever is smaller.

If I had a *BSD box or VM sitting around, I would look to see what
*BSD does (and perhaps copy the *BSD behavior if it were acceptable).

Eric Dumazet wrote:
> I really don't think userland should expect to read 128 null bytes if it
> asked 128 bytes.
>
> We can certainly return 2 null bytes (AF_UNSPEC)

AF_UNSPEC is good (and sufficient, IMO).

Do we need to add AF_INVALID at all?  Why not just use AF_UNSPEC?

> and comply with the documentation.

What documentation?  The interesting thing about this situation is I
have not seen any manpage that describes what should happen after a
concurrent shutdown.

-mpb
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ