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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 26 Nov 2015 16:31:06 +0100
From:	Dmitry Vyukov <dvyukov@...gle.com>
To:	Eric Dumazet <edumazet@...gle.com>
Cc:	"David S. Miller" <davem@...emloft.net>,
	netdev <netdev@...r.kernel.org>
Subject: Re: WARNING in tcp_recvmsg

On Wed, Nov 25, 2015 at 8:37 PM, Eric Dumazet <edumazet@...gle.com> wrote:
> On Wed, Nov 25, 2015 at 8:36 AM, Dmitry Vyukov <dvyukov@...gle.com> wrote:
>> Hello,
>>
>> The following program triggers WARNING in tcp_recvmsg:
>>
>> // autogenerated by syzkaller (http://github.com/google/syzkaller)
>> #include <syscall.h>
>> #include <string.h>
>> #include <stdint.h>
>> #include <pthread.h>
>> #include <sys/types.h>
>> #include <sys/socket.h>
>> #include <netinet/ip.h>
>> #include <netinet/tcp.h>
>>
>> int fd = -1;
>>
>> void *thr0(void *arg)
>> {
>>         memcpy((void*)0x20003000,
>> "\xf2\x2c\xed\x4d\x91\xef\x43\x15\x40\x67\x6d\xfa\x00\xd5\xe1\x10\x7e\x31\x16\x93\x94\x58\x86\x1b\x2b\x9b\x31\xca\xe4\x84\xe7\x9d\x58\xc5\x33\x05\x1c\x17\x38",
>> 39);
>>         memcpy((void*)0x20002000,
>> "\x02\x00\x33\xe3\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
>> 128);
>>         syscall(SYS_sendto, fd, 0x20003000ul, 0x27ul,
>> 0x69a6e88a31dc2927ul, 0x20002000ul, 0x80ul);
>>         return 0;
>> }
>>
>> void *thr1(void *arg)
>> {
>>         syscall(SYS_read, fd, 0x20005000ul, 0xcbul, 0, 0, 0);
>>         return 0;
>> }
>>
>> void *thr2(void *arg)
>> {
>>         syscall(SYS_close, fd, 0, 0, 0, 0, 0);
>>         return 0;
>> }
>>
>> int main()
>> {
>>         syscall(SYS_mmap, 0x20000000ul, 0x10000ul, 0x3ul, 0x32ul,
>> 0xfffffffffffffffful, 0x0ul);
>>         fd = syscall(SYS_socket, PF_INET, SOCK_STREAM, IPPROTO_IP);
>>         memcpy((void*)0x20000000,
>> "\x02\x00\x33\xe3\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
>> 128);
>>         long r3 = syscall(SYS_bind, fd, 0x20000000ul, 0x80ul, 0, 0, 0);
>>         pthread_t th[3];
>>         pthread_create(&th[0], 0, thr0, 0);
>>         pthread_create(&th[1], 0, thr1, 0);
>>         pthread_create(&th[2], 0, thr2, 0);
>>         pthread_join(th[0], 0);
>>         pthread_join(th[1], 0);
>>         pthread_join(th[2], 0);
>>         return 0;
>> }
>>
>>
>> ------------[ cut here ]------------
>> WARNING: CPU: 2 PID: 1991 at net/ipv4/tcp.c:1729 tcp_recvmsg+0x171f/0x2ba0()
>> Modules linked in:
>> CPU: 2 PID: 1991 Comm: a.out Tainted: G    B   W       4.4.0-rc2+ #51
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
>>  ffffffff85ac2e60 ffff8800321af8d0 ffffffff826c8be0 0000000000000000
>>  ffff8800321af910 ffffffff81233651 ffffffff8464bfbf 0000000000000000
>>  0000000000000000 ffff880033545080 ffff88003354589c ffff8800335457f0
>> Call Trace:
>>  [<ffffffff81233815>] warn_slowpath_null+0x15/0x20 kernel/panic.c:493
>>  [<ffffffff8464bfbf>] tcp_recvmsg+0x171f/0x2ba0 net/ipv4/tcp.c:1728
>>  [<ffffffff84713328>] inet_recvmsg+0x2a8/0x460 net/ipv4/af_inet.c:764
>>  [<     inline     >] sock_recvmsg_nosec net/socket.c:712
>>  [<ffffffff842b1d1d>] sock_recvmsg+0x7d/0xa0 net/socket.c:720
>>  [<ffffffff842b1f4b>] sock_read_iter+0x20b/0x3b0 net/socket.c:797
>>  [<     inline     >] new_sync_read fs/read_write.c:422
>>  [<ffffffff81633d5b>] __vfs_read+0x26b/0x490 fs/read_write.c:434
>>  [<ffffffff81635edb>] vfs_read+0xdb/0x2d0 fs/read_write.c:454
>>  [<     inline     >] SYSC_read fs/read_write.c:569
>>  [<ffffffff81638c1c>] SyS_read+0x10c/0x220 fs/read_write.c:562
>>  [<ffffffff852a7876>] entry_SYSCALL_64_fastpath+0x16/0x7a
>> arch/x86/entry/entry_64.S:185
>> ---[ end trace a91322778567c814 ]---
>>
>>
>> I am on commit 6ffeba9607343f15303a399bc402a538800d89d9 (Now 24).
>>
>> Thank you
>
> I could not see your mail on netdev, only in my private mailbox.
>
> I hope this answer will make it, I removed some of the recipients, as
> really netdev is what matters.
>
> Cross SYN were probably never correctly tested with random stuff I guess...
>
> Could you test following fix ?

The patch fixes the WARNING for me.

Tested-by: Dmitry Vyukov <dvyukov@...gle.com>

> Thanks.
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index a4a0b6b3bcf2..2d656eef7f8e 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -5683,6 +5683,7 @@ discard:
>                 }
>
>                 tp->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
> +               tp->copied_seq = tp->rcv_nxt;
>                 tp->rcv_wup = TCP_SKB_CB(skb)->seq + 1;
>
>                 /* RFC1323: The window in SYN & SYN/ACK segments is
--
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