Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1958698imu; Thu, 24 Jan 2019 05:04:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN75MslSONbdau7cpnEVzBHwK56gIuyTyAptvIiizy3oKca11AnfkkDSe0EN5SBw9N/uVnaE X-Received: by 2002:a62:32c4:: with SMTP id y187mr6601349pfy.195.1548335056072; Thu, 24 Jan 2019 05:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548335056; cv=none; d=google.com; s=arc-20160816; b=fAnCQkDKMRii9dkFl61xE0zU5QEOEKni9iXaScqP9brgFPpwF2hLKS9zlvbQCuFK5U Ce6bZspV+9qL4LQt7rouBEIueOXOPL6zWq5PuI8oicEGotm4mODuiCdTHY9q/cV/4W/U 4jrJ5shq4FdllF9C3WCrBgiwe6ixBsB2HgzYKP4vYfEP5zlAbUMpVJxH7UUZhaVBkMWp N527KFDIdwMbzfJG6JqHgbZ4mUmHPEtufiEX9JWytoKttp1XoKQOl2774izu5T9+d9uh tsqnW8uv/lNI5m6ez/N3KM9QuOSXqa+CsLVnohkhmCpuvdjwxZ/BOHeJVkAdTKTBGM5q A0+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ijt3egflFMg9knJNGWsmkNMFFvB2fREnmKCJpL5fPGw=; b=Ts5ZisBEeEqC0adryLe+c0uZqN3UXNmj/ky/jIDgE0U3axVmQB3SF/VikU3dm1YWXH /UB0SHBOhSYNNTSAf07RHu+RkxAfegz8d55m02OirMSmmvy391XcXPrE4PP6GfrhOaXN HyzKCh9wENSW0HVLTqDqBYcv89ms37YEXEcTDHtAc4uLZ8KSgYrL4Q3fOG6kVJoSfqOo chrkEiMYNcnaFY/yufWj6dUmCXL29/tZQzFic+FhOq4F1uTOK1BlN3nrNTcJyWMY8T7A Lc1KAAyLBqhFElqvBpXKcpBgkKHEUp6cEzgG906zK8Br+z9jGRajVgL1dhm1Y7b4AumP 3UzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A0oYIJm6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si22566212plx.33.2019.01.24.05.04.00; Thu, 24 Jan 2019 05:04:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A0oYIJm6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727944AbfAXNDv (ORCPT + 99 others); Thu, 24 Jan 2019 08:03:51 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:43513 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727596AbfAXNDv (ORCPT ); Thu, 24 Jan 2019 08:03:51 -0500 Received: by mail-io1-f65.google.com with SMTP id b23so4616909ios.10; Thu, 24 Jan 2019 05:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ijt3egflFMg9knJNGWsmkNMFFvB2fREnmKCJpL5fPGw=; b=A0oYIJm6tOj3hchGXKE1fLRX+7dYUb0hM8xvs6ML//zvnLc3Revc96OhshKE9TzQcQ jjJ7B2T5OT1IgLcKfFjN5xu8dbvGG8SYV5thVxYXcuZVtz4m6wQSW/Uo+k/qIQtmAXyt k+54RXpn4KPmcon+POa2b7vvQAfJzWpev2MvFwgRYXBisuG0zM4QYJox3HW2pCTE9SiN bzzWLcUdlXERkEK9inH66X/uEn9VWsgzmG8fGEcwyeCL9d+rbzWyZu43iwEAEkIqsF7y pFmtGPBv2Un4scnX/oaRPTtPb+FZnwlhj/3j/7lh+HB4RKellVJP8rxlMFTnP+chz3n2 akiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ijt3egflFMg9knJNGWsmkNMFFvB2fREnmKCJpL5fPGw=; b=EqYgKONjs9h/AFIzDo/DRd/yRcPSKcBNuWZauICbRjdGoSg2lFrGc9NNNZ/OEaHcxH LLsv0aY26ecG0eqxtcykWER3G4kUdvtRJ8FQHEGvi1dvO9ZFB3NhfE/dI3K2CWN6Gl3O YN0kbGmnA+s9Cc/A4oCp69MW50/aCVdB3rpG4bNp1k2QatdKSKb6QKT0S2tpfoAddxPh qD9AQvw5aGU4+Z1yyMPD4c/Z1/W6YdB9QzAIgNn323OFjFcgVnIbNn3QQbUP7jqsM9Mb pxvYr3TNbZUOUjWS7P6FE7ap8xVClU2t9ip0KThi5IXJ3WvGHQOS5eOlaL8jLZ8MDo+R pB7A== X-Gm-Message-State: AHQUAuaRm64wV/2uY/+TCk09gF6wkTYHC1etHwJrk/2814AnQoH2BJd7 MS7XIu6umf8bb8u6KJ7wI4nICDRDkM/U8BBjzFw= X-Received: by 2002:a5d:9257:: with SMTP id e23mr4307129iol.112.1548335030179; Thu, 24 Jan 2019 05:03:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kyungtae Kim Date: Thu, 24 Jan 2019 08:03:38 -0500 Message-ID: Subject: Re: UBSAN: Undefined behaviour in net/ipv4/ip_output.c To: Willem de Bruijn Cc: David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , Byoungyoung Lee , DaeRyong Jeong , syzkaller , Network Development , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org That's my bad. Thank you for your comment and effort. Regards, Kyungtae Kim On Wed, Jan 23, 2019 at 4:34 PM Willem de Bruijn wrote: > > On Mon, Jan 21, 2019 at 2:25 PM Kyungtae Kim wrote: > > > > I'm reporting a bug in linux-5.0-rc2: "UBSAN: Undefined behaviour in > > net/ipv4/ip_output.c" > > > > kernel config: https://kt0755.github.io/etc/config-5.0-rc2 > > repro: https://kt0755.github.io/etc/repro.b6a11.c > > Thanks for the report. > > That reproducer does not seem to exercise system call sendmsg. Did you > mean to share another? Perhaps one that users SO_SNDBUFFORCE or > sysctl_wmem_max. > > When constructing a reproducer, I did easily trigger an UBSAN warning > when setting SO_SNDBUFFORCE to INT_MAX - 1, so I can imagine that this > one can trigger, as well. As long as sk_sndbuf can be set to any > integer value, we'll have to be careful with any such multiplication. > > > Integer overflow happened in __ip_append_data() when 2 * sk->sk_sndbuf > > (at line 1004) > > is larger than the boundary of the destination (i.e., int). > > Some sanity check code right before it would help. > > > > ========================================= > > UBSAN: Undefined behaviour in net/ipv4/ip_output.c:1004:11 > > signed integer overflow: > > 1282607372 * 2 cannot be represented in type 'int' > > CPU: 0 PID: 8465 Comm: syz-executor4 Not tainted 5.0.0-rc2 #1 > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > > Call Trace: > > __dump_stack lib/dump_stack.c:77 [inline] > > dump_stack+0xb1/0x118 lib/dump_stack.c:113 > > ubsan_epilogue+0x12/0x94 lib/ubsan.c:159 > > handle_overflow+0x1cf/0x21a lib/ubsan.c:190 > > __ubsan_handle_mul_overflow+0x2a/0x35 lib/ubsan.c:214 > > __ip_append_data+0x30ed/0x3350 net/ipv4/ip_output.c:1004 > > ip_append_data.part.18+0xf3/0x170 net/ipv4/ip_output.c:1220 > > ip_append_data+0x63/0x80 net/ipv4/ip_output.c:1209 > > raw_sendmsg+0xd99/0x2b60 net/ipv4/raw.c:670 > > inet_sendmsg+0xfc/0x620 net/ipv4/af_inet.c:798 > > sock_sendmsg_nosec net/socket.c:621 [inline] > > sock_sendmsg+0xdd/0x130 net/socket.c:631 > > ___sys_sendmsg+0x7b3/0x950 net/socket.c:2116 > > __sys_sendmsg+0xfc/0x1d0 net/socket.c:2154 > > __do_sys_sendmsg net/socket.c:2163 [inline] > > __se_sys_sendmsg net/socket.c:2161 [inline] > > __x64_sys_sendmsg+0x83/0xc0 net/socket.c:2161 > > do_syscall_64+0xbe/0x4f0 arch/x86/entry/common.c:290 > > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > RIP: 0033:0x4497b9 > > Code: e8 8c 9f 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 > > 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d > > 01 f0 ff ff 0f 83 9b 6b fc ff c3 66 2e 0f 1f 84 00 00 00 00 > > RSP: 002b:00007f0d0100bc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e > > RAX: ffffffffffffffda RBX: 00007f0d0100c6cc RCX: 00000000004497b9 > > RDX: 0000000000000000 RSI: 0000000020000500 RDI: 0000000000000013 > > RBP: 000000000071bea0 R08: 0000000000000000 R09: 0000000000000000 > > R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff > > R13: 00000000000089a0 R14: 00000000006f1a40 R15: 00007f0d0100c700 > > ========================================= > > > > Thanks, > > Kyungtae