Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1259518imu; Wed, 23 Jan 2019 13:36:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PJVoZf4bXgjzUv7dTgHS1SwPqxhGz0bdsi3FG+1Txs1F6WBbMYq65+s05HRGlLJsaLoAf X-Received: by 2002:a62:7a8b:: with SMTP id v133mr3772098pfc.159.1548279372497; Wed, 23 Jan 2019 13:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548279372; cv=none; d=google.com; s=arc-20160816; b=s7OKNmiunc0VccenmpIp/OUaZe03SV6FnpJtfNyXZ2GsyJW9fBrY/QrokWPF+qvzii 6rLTsNOkmjr5DXqOhCJUXQ3og6cI2F4yo8PbF3rn8aplU6olGg5rHYns1mAiXJgELDUW +o1pxDnEQCM1hnLpE0dTguQn+sVfc4A/iwduHnTvkj+Z0Il5BcNm2+hOhYwjwqMOWQta MuxE0mb8h5lnlI+WZXlFlzLhTM/T2zJWUBAEuo+2Btn2grtyWI2qX9tCaAH3Nqbb5bow RnaHK2Fj26hvV5LkPU40GOL3pwVTqrOt+EUCpIMFk0sUQpmY0xcSRoC40Fi6oK1+WWQG frjw== 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=eqNmfCLdxg8dZkPJvM8nDDSKgrdUES18R7NP6odmBO4=; b=HwgQNBaZcvOAVkpLzj6AlLSIRvwen1wBnrytzc6eevCUrT5HKJqgKxg9xe7mVn3ZrI 29M50rgXCAb3oDLV3IlOaCU6iEG6SkZqN0eUZvzHXltDPwc9IsXl4MpCRL83qcJO0Ybw +GKbqKI0dP5dLXTsdKNQAaZLlN4uppf9HgoHg1TsgaT7ThcO9I5DQc1Y2SobYx3fHXYu slvR7wxTemnBIj5nSyydIwUPX7exQApbkW2JHHQKmsPZmPB4TFPSC/0crkX+jAXSSBU4 g2Ne0MIjTiL0S4SUpM5CX+AzwXafEyDB64xTbm4DnuPTDOEoQLEDfRvZMGofn/CWsr7Z 5q4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i9704N+B; 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 g124si19749050pgc.568.2019.01.23.13.35.57; Wed, 23 Jan 2019 13:36:12 -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=i9704N+B; 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 S1727055AbfAWVeD (ORCPT + 99 others); Wed, 23 Jan 2019 16:34:03 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38063 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbfAWVeC (ORCPT ); Wed, 23 Jan 2019 16:34:02 -0500 Received: by mail-ed1-f65.google.com with SMTP id h50so2906321ede.5; Wed, 23 Jan 2019 13:34:01 -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=eqNmfCLdxg8dZkPJvM8nDDSKgrdUES18R7NP6odmBO4=; b=i9704N+BIX7XWOwkz7DJbr8MulRqdsY2otMP+UDGwF8JMjgWC06ppGtMFWfiLJBM4q zogHFkU3VcH2KHMdsyZwcEjKM2uTX0zZxFxWL0/O4zW9ZCvZcbGGUKWTJbDLrK9Ay/uM FIoQPYYdYiQzYG4TgTVaG346+vKY+wkKNHFq1hYV4lGTmPpjWM7I/NJYI0xcC3ReQn2X gPoep9CvHz2mwbrrJvci1zIZ3fneUK5VLyOIpIn/653mNkhqJefX6wiS01FVoFQyLlmM 0x7hkwazZoyc4nQJK7C3lODcRqvKgYhUA+3BNQPZoFS49BFEfqmlQf9/vFW8omo+WSul Gv5w== 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=eqNmfCLdxg8dZkPJvM8nDDSKgrdUES18R7NP6odmBO4=; b=AGY+1tdsMEVATRgi8dsBkHKkmMFJds+LL2RFDFN5z2sqCj++vd3owRPIGOzld0y2qb SlJZcXvHpNFlGasylFKDFkF2vSnfRL1wFOBFMK09FjZJDkQEjN6O+WdVBOBaDRlATOxl hciwpbXKEAVhO1ecLX+6fuWO6jkZYDEoXhWazM7YrYpgu6YnnESVLBy+HubkKglZS8KQ IIOb2aYrTNOnw2Bn4aa4+SBAks6UrMycmODo5BdSSRTbABg3rwzORFej9MryQvVhgfcW gaG3HYVAW/SC2LAvVOaW0H4x4t102m408qwJsW9OglKHfcdC8v498ojwCGOj4nnlCpZn kEHg== X-Gm-Message-State: AJcUukfSKLl319lCyCPc2pKZti1FtDThWYvyAi35Eq2uiRk6YVGod5+S kRlr4nwI76v5Zw//MriM4njpheMPP674UsZuQK8= X-Received: by 2002:a50:ac81:: with SMTP id x1mr4228663edc.71.1548279240564; Wed, 23 Jan 2019 13:34:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Willem de Bruijn Date: Wed, 23 Jan 2019 16:33:24 -0500 Message-ID: Subject: Re: UBSAN: Undefined behaviour in net/ipv4/ip_output.c To: Kyungtae Kim 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 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