Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp268046img; Mon, 18 Mar 2019 02:41:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhZbh24Nk7e1Rs3nIDCn/zmlHoanQsBZmBaYLvLDFKgBxaK4ndhYrchjXb00xhlEDk9ntL X-Received: by 2002:a63:2224:: with SMTP id i36mr16694697pgi.169.1552902077271; Mon, 18 Mar 2019 02:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552902077; cv=none; d=google.com; s=arc-20160816; b=ioJxLIKPUBTuHvcio3tCID5MxWJt0qcY+lvOJCWGlTp6bLNu3gsXA9h0pjLK8Qaln5 k1SVvElMldReTVBz7IYFix15nTLGIHaJN2qTX6zlawhWvVP/6pEC8oGtABRra4A8lL2A KJPhh04lIbzhfFoer5VH3URbL1cDqDvKUw//27Cznl2NNudfFuaRwwmq6+As9Cjw/HTp kPLXZ7ZitadM3nwx/lSgEe6U+WRfbl3CudquGVeKBW9D69jWF6SKJIMAb5Ea2RkxDfkn z1meG91W5Dg6zBG6XmQySHEbjhnIBHFNND2RT1SS2ClcXNgK295p26/D6sN0+O9jtotC Qa7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E+BHrVDXOgyNhf6N9Xh/VgmJS5Hk8G0clcZhmcRq/u0=; b=nySebYJCatp0Wnctn6lrttpZ1KnrifRQzcYq68L8Ge6JAsUOB0cPH41C2vEgvc/iNh moHA60dlrqFippTUKCar08NerurFZNUjxR5jdE6SHMagJd87Uwx4tAzrEeUhmJAYYOdB SNDh431cV7EqOTzCIsHoNikUU6wGP8ue76s6a0lDHKxeiyNl+RVLxrzFmx1DbLT5AHNj Cskb7jO8k75jMgCbY4RcaHsgwSg/VE3OUam2kR5Y2pRQLIWPSu4Y0pClL2Qw+6cFYXmI 7p6SGdcN8A33kchl4ZEKnOZS9bwzZvQaTg7563XjjjNrR6QtIIWf4dIDX+YOXZl/AFFs cYFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NA5+1p7L; 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 g10si8507159plo.308.2019.03.18.02.41.02; Mon, 18 Mar 2019 02:41:17 -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=NA5+1p7L; 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 S2387542AbfCRJfy (ORCPT + 99 others); Mon, 18 Mar 2019 05:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:44232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbfCRJfv (ORCPT ); Mon, 18 Mar 2019 05:35:51 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 97AF12083D; Mon, 18 Mar 2019 09:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901751; bh=yJwZXvdh3kLcuKO+yGKQdc/G67sW/7sDgOnXRdQjKO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NA5+1p7LHXGcLUnmVjTCiduwMHLiPf8KgAGqxAsQ+RL2/uCtTAU/yIQ98NCdh1nyR dWFfE20+xbdE54dFjR9Wvqxrq2noqUgtEVtcP9JaIF37QadwDllHLw7mHjULTp/hWf hK8VdrS32nttmQM4cZpxBgAsMZvRbT9tlXT3N/L8= 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.14 05/34] l2tp: fix infoleak in l2tp_ip6_recvmsg() Date: Mon, 18 Mar 2019 10:25:29 +0100 Message-Id: <20190318084145.394327895@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084144.657740413@linuxfoundation.org> References: <20190318084144.657740413@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 163d1c3d6f17556ed3c340d3789ea93be95d6c28 ] Back in 2013 Hannes took care of most of such leaks in commit bceaa90240b6 ("inet: prevent leakage of uninitialized memory to user in recv syscalls") But the bug in l2tp_ip6_recvmsg() has not been fixed. syzbot report : BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32 CPU: 1 PID: 10996 Comm: syz-executor362 Not tainted 5.0.0+ #11 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x173/0x1d0 lib/dump_stack.c:113 kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:600 kmsan_internal_check_memory+0x9f4/0xb10 mm/kmsan/kmsan.c:694 kmsan_copy_to_user+0xab/0xc0 mm/kmsan/kmsan_hooks.c:601 _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32 copy_to_user include/linux/uaccess.h:174 [inline] move_addr_to_user+0x311/0x570 net/socket.c:227 ___sys_recvmsg+0xb65/0x1310 net/socket.c:2283 do_recvmmsg+0x646/0x10c0 net/socket.c:2390 __sys_recvmmsg net/socket.c:2469 [inline] __do_sys_recvmmsg net/socket.c:2492 [inline] __se_sys_recvmmsg+0x1d1/0x350 net/socket.c:2485 __x64_sys_recvmmsg+0x62/0x80 net/socket.c:2485 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 entry_SYSCALL_64_after_hwframe+0x63/0xe7 RIP: 0033:0x445819 Code: e8 6c b6 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 2b 12 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f64453eddb8 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00000000006dac28 RCX: 0000000000445819 RDX: 0000000000000005 RSI: 0000000020002f80 RDI: 0000000000000003 RBP: 00000000006dac20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dac2c R13: 00007ffeba8f87af R14: 00007f64453ee9c0 R15: 20c49ba5e353f7cf Local variable description: ----addr@___sys_recvmsg Variable was created at: ___sys_recvmsg+0xf6/0x1310 net/socket.c:2244 do_recvmmsg+0x646/0x10c0 net/socket.c:2390 Bytes 0-31 of 32 are uninitialized Memory access of size 32 starts at ffff8880ae62fbb0 Data copied to user address 0000000020000000 Fixes: a32e0eec7042 ("l2tp: introduce L2TPv3 IP encapsulation support for IPv6") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_ip6.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -684,9 +684,6 @@ static int l2tp_ip6_recvmsg(struct sock if (flags & MSG_OOB) goto out; - if (addr_len) - *addr_len = sizeof(*lsa); - if (flags & MSG_ERRQUEUE) return ipv6_recv_error(sk, msg, len, addr_len); @@ -716,6 +713,7 @@ static int l2tp_ip6_recvmsg(struct sock lsa->l2tp_conn_id = 0; if (ipv6_addr_type(&lsa->l2tp_addr) & IPV6_ADDR_LINKLOCAL) lsa->l2tp_scope_id = inet6_iif(skb); + *addr_len = sizeof(*lsa); } if (np->rxopt.all)