Received: by 10.192.165.156 with SMTP id m28csp78565imm; Tue, 10 Apr 2018 16:50:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+6VwjR2eqozrQZoQjk+KQW2KBqXxfMw3zEhKEnHAjFt1KR8TqzwcSDZc8a6+DoFNMO064I X-Received: by 10.99.177.78 with SMTP id g14mr1688725pgp.253.1523404251248; Tue, 10 Apr 2018 16:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404251; cv=none; d=google.com; s=arc-20160816; b=YN1co0CX4E0yDvTvHn6/4Qt/ehx4nauehbPN6tOxmw+kOS+uzaMoxUrkZEAZKJ24Ba VJQaM03zkUXUuEQVrVXTORIkztRT//UgDh4sFyVDKPEzqvDyuw7rfNJPdH3yuuD9iRjH oFeFjR3wOMH+b0JhGsGXFePhaqVB8QBfv+ud6oh0H73LLTFDSDlQk/mrJVdT6mqbwScu fS3aquQ3ajPFd7Zs7ZQcrSu+Ai8YkpGG2DYMPNo2fYaAZE1ZViJTwvjfV7dq/RDZ9eGX EzG/T5Go8wr53kQUIZMWKXz1OU6L5aCCDTraFPkee/ESd7u8us49p5njCBUir+IDnLyM LH2g== 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 :arc-authentication-results; bh=ZQ/LS1miJjkhd8Zo0sFXIasbh33BKnGUl5pmWv5mMHc=; b=e+33Y/j0mgkNzrMGqttoPtgmAn1lU0lwkii8ewl6joeiPjVhYfW2scRVcFWb0l9ftw H/cXuhygtYKWk6pGydNf0axbmaRevdXLyQ2MuRJqWmnBmrpomIlwV/4Kur17bJwSJNCs 8qmO8WD7dDH7fhvfI+2jK3c8xOD/NIE+9rvreLi+MRdKgZa3mQwU6IyRdqcxOk4wfNTQ eBkUPM9nZpEQzbQV4eapyu8V7PgRMrjZAuxaSFV001BVYWrmwRpa75h0YEPNN+inQITF PzZOkUidt/RseqkoYYkOe6aq/MibW24lFR8k2lg+hIF65s7gcGfAtnTnPIHPUn0ZY16m qMmg== ARC-Authentication-Results: i=1; mx.google.com; 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 o2-v6si3513682pls.161.2018.04.10.16.50.14; Tue, 10 Apr 2018 16:50:51 -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; 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 S1752572AbeDJWYg (ORCPT + 99 others); Tue, 10 Apr 2018 18:24:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36786 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752401AbeDJWYe (ORCPT ); Tue, 10 Apr 2018 18:24:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5C59DD1C; Tue, 10 Apr 2018 22:24:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Vlad Yasevich , Neil Horman , syzbot , "David S. Miller" Subject: [PATCH 4.16 07/18] sctp: do not leak kernel memory to user space Date: Wed, 11 Apr 2018 00:23:42 +0200 Message-Id: <20180410212758.961732699@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212758.564682823@linuxfoundation.org> References: <20180410212758.564682823@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 6780db244d6b1537d139dea0ec8aad10cf9e4adb ] syzbot produced a nice report [1] Issue here is that a recvmmsg() managed to leak 8 bytes of kernel memory to user space, because sin_zero (padding field) was not properly cleared. [1] BUG: KMSAN: uninit-value in copy_to_user include/linux/uaccess.h:184 [inline] BUG: KMSAN: uninit-value in move_addr_to_user+0x32e/0x530 net/socket.c:227 CPU: 1 PID: 3586 Comm: syzkaller481044 Not tainted 4.16.0+ #82 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:53 kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067 kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176 kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199 copy_to_user include/linux/uaccess.h:184 [inline] move_addr_to_user+0x32e/0x530 net/socket.c:227 ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211 __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313 SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394 SyS_recvmmsg+0x76/0xa0 net/socket.c:2378 do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x4401c9 RSP: 002b:00007ffc56f73098 EFLAGS: 00000217 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004401c9 RDX: 0000000000000001 RSI: 0000000020003ac0 RDI: 0000000000000003 RBP: 00000000006ca018 R08: 0000000020003bc0 R09: 0000000000000010 R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000401af0 R13: 0000000000401b80 R14: 0000000000000000 R15: 0000000000000000 Local variable description: ----addr@___sys_recvmsg Variable was created at: ___sys_recvmsg+0xd5/0x810 net/socket.c:2172 __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313 Bytes 8-15 of 16 are uninitialized ================================================================== Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 3586 Comm: syzkaller481044 Tainted: G B 4.16.0+ #82 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:53 panic+0x39d/0x940 kernel/panic.c:183 kmsan_report+0x238/0x240 mm/kmsan/kmsan.c:1083 kmsan_internal_check_memory+0x164/0x1d0 mm/kmsan/kmsan.c:1176 kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199 copy_to_user include/linux/uaccess.h:184 [inline] move_addr_to_user+0x32e/0x530 net/socket.c:227 ___sys_recvmsg+0x4e2/0x810 net/socket.c:2211 __sys_recvmmsg+0x54e/0xdb0 net/socket.c:2313 SYSC_recvmmsg+0x29b/0x3e0 net/socket.c:2394 SyS_recvmmsg+0x76/0xa0 net/socket.c:2378 do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Cc: Vlad Yasevich Cc: Neil Horman Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/ipv6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -728,8 +728,10 @@ static int sctp_v6_addr_to_user(struct s sctp_v6_map_v4(addr); } - if (addr->sa.sa_family == AF_INET) + if (addr->sa.sa_family == AF_INET) { + memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero)); return sizeof(struct sockaddr_in); + } return sizeof(struct sockaddr_in6); }