Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2047182imm; Thu, 24 May 2018 05:04:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpOBNvnxxK1HXDb0bIm6GWmuH/B/dVbp0HIeg6ebRDnjS7hy1BqTAQPX9lVKznjc/eud+M8 X-Received: by 2002:a63:9041:: with SMTP id a62-v6mr2821753pge.191.1527163443660; Thu, 24 May 2018 05:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163443; cv=none; d=google.com; s=arc-20160816; b=sYsC2uPqNKVI8vyyvEsPLv/PszdfFQ+7hsnw+/nnih3viWa1g/ec3fN+lQbAgri+VM xpSX3TvXnIWF2uwWvJd7z3kJCzSW2tK5uuI5QGWqlpDbN4oiANV6C7C30BUlY1MeWWzv OlEnl8eDQrH4KdeH0ppP56dNQxzdgiowjlYI/XdaLpJv07n9zAHK/az8cpOjv0wM8mX2 hLp8Qq/Jq/4yY28e8baZWkPaABEpWEVLj4j+PEhR9pEZCwwJ/0BeBcoj2rd5j97FKFZp r//f3/hW3bZQNmsXgcMSUhlirAXZ74i3leweoelPWJTNVW9ow5ZMm1eIrG6oi7LvA0zo l7+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=v0DGOePfF5SJulIsC5LnDoqgOnRkiehqmdJdmYuDzYw=; b=d2/o0ertqs9nEZPlKD1iUsZIHzY8RUEt0tYVcRxAXylNRwuEdSVjjg6SLV7F7kYo6U 6P13snZuaqPDqGHII1vlwMsmRnTIkaS4T3ToAa7SXqZEWhAxf3/fapJ1NNHwA+72+3Xo 1q6nGk8W+oII6Puk7n43c1M8rz8RW/6Lw2cAwM25RU/DNDmzZ6ELwEW1+ZZrZGKcXtIa ivoCWrfh650i5RMQO3LVAW6TXxUxnmQpsFGHIG8am3MUd9udxXu5z29IVNkrFmaDLO/r pcMJQ0GFdlSLT+rcGiTNxvfZR3nqaHT0yLqKv67jQtprRky22yFs84B3RM8aFb2gbFXZ TXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ojsOPwpf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f85-v6si20908300pfj.125.2018.05.24.05.03.28; Thu, 24 May 2018 05:04:03 -0700 (PDT) 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=@kernel.org header.s=default header.b=ojsOPwpf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969607AbeEXMC2 (ORCPT + 99 others); Thu, 24 May 2018 08:02:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:56008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966688AbeEXJoq (ORCPT ); Thu, 24 May 2018 05:44:46 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 66373208CD; Thu, 24 May 2018 09:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155085; bh=p44Y27+uEIT7u0UZa/QI512wi7OARxktVJ33vlh42Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ojsOPwpftafolc7ynvpdjLYoYy0V5BQ76byC4O/OzE7p+Llw2+eGSdgXfdpy+m5Im IAy8l+gony2pJZaiX9jG3jKWM4iTdSPeSXuhWX+7/yrr1kgbnl0x0Be2lbMeQEX75t HN1vpEuYtEQaIsvk3PinkL8KA/UKmfHrT1GEWzw0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.4 05/92] llc: better deal with too small mtu Date: Thu, 24 May 2018 11:37:42 +0200 Message-Id: <20180524093159.755180960@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 2c5d5b13c6eb79f5677e206b8aad59b3a2097f60 ] syzbot loves to set very small mtu on devices, since it brings joy. We must make llc_ui_sendmsg() fool proof. usercopy: Kernel memory overwrite attempt detected to wrapped address (offset 0, size 18446612139802320068)! kernel BUG at mm/usercopy.c:100! invalid opcode: 0000 [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 0 PID: 17464 Comm: syz-executor1 Not tainted 4.17.0-rc3+ #36 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:usercopy_abort+0xbb/0xbd mm/usercopy.c:88 RSP: 0018:ffff8801868bf800 EFLAGS: 00010282 RAX: 000000000000006c RBX: ffffffff87d2fb00 RCX: 0000000000000000 RDX: 000000000000006c RSI: ffffffff81610731 RDI: ffffed0030d17ef6 RBP: ffff8801868bf858 R08: ffff88018daa4200 R09: ffffed003b5c4fb0 R10: ffffed003b5c4fb0 R11: ffff8801dae27d87 R12: ffffffff87d2f8e0 R13: ffffffff87d2f7a0 R14: ffffffff87d2f7a0 R15: ffffffff87d2f7a0 FS: 00007f56a14ac700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2bc21000 CR3: 00000001abeb1000 CR4: 00000000001426f0 DR0: 0000000020000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000030602 Call Trace: check_bogus_address mm/usercopy.c:153 [inline] __check_object_size+0x5d9/0x5d9 mm/usercopy.c:256 check_object_size include/linux/thread_info.h:108 [inline] check_copy_size include/linux/thread_info.h:139 [inline] copy_from_iter_full include/linux/uio.h:121 [inline] memcpy_from_msg include/linux/skbuff.h:3305 [inline] llc_ui_sendmsg+0x4b1/0x1530 net/llc/af_llc.c:941 sock_sendmsg_nosec net/socket.c:629 [inline] sock_sendmsg+0xd5/0x120 net/socket.c:639 __sys_sendto+0x3d7/0x670 net/socket.c:1789 __do_sys_sendto net/socket.c:1801 [inline] __se_sys_sendto net/socket.c:1797 [inline] __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1797 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x455979 RSP: 002b:00007f56a14abc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00007f56a14ac6d4 RCX: 0000000000455979 RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000018 RBP: 000000000072bea0 R08: 00000000200012c0 R09: 0000000000000010 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000000548 R14: 00000000006fbf60 R15: 0000000000000000 Code: 55 c0 e8 c0 55 bb ff ff 75 c8 48 8b 55 c0 4d 89 f9 ff 75 d0 4d 89 e8 48 89 d9 4c 89 e6 41 56 48 c7 c7 80 fa d2 87 e8 a0 0b a3 ff <0f> 0b e8 95 55 bb ff e8 c0 a8 f7 ff 8b 95 14 ff ff ff 4d 89 e8 RIP: usercopy_abort+0xbb/0xbd mm/usercopy.c:88 RSP: ffff8801868bf800 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/llc/af_llc.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -926,6 +926,9 @@ static int llc_ui_sendmsg(struct socket if (size > llc->dev->mtu) size = llc->dev->mtu; copied = size - hdrlen; + rc = -EINVAL; + if (copied < 0) + goto release; release_sock(sk); skb = sock_alloc_send_skb(sk, size, noblock, &rc); lock_sock(sk);