Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3423834pxf; Mon, 29 Mar 2021 01:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqkTEH2bBII0H6ZU34zhGKeQJ1AEBbhUFpEY2/SVOz7CYGGp7L0p9IbMrc07EiuXuJ2YBT X-Received: by 2002:a05:6402:51cd:: with SMTP id r13mr27634740edd.116.1617007173853; Mon, 29 Mar 2021 01:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007173; cv=none; d=google.com; s=arc-20160816; b=bJA/ln4P/zP5j9p6viXE3sO1wB8HqFbUIxKcdvc/DqGEXASkE9iRbJeQXq/zGfUEfA JNLnfsYhklCzp6l5XIDRwx8u0Z5YOlcTY8x7ITLwZoQK5jvAfztry9rx8QWBqLz7PrCK 2CHF6WQPkZ2DcjfOcBl5CpFcoYJSKvAA/YSF0KJSNRKH+QpNZqU2PM0jztd950f+HDGK o7YKLxtwo3x3kvwngluN092fPcwODJshE+r/DEI64/ztwSoqP6potQ7RxVHV47Lrmn+P Efgsn/rQ6JjW9A4U+neJAcl0KD61Efu4aSow6plM8a0i2TgZS61w9/IsBRMGwq6VtyKq QUcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XM0z3vGfXW+2a+s1qJNjQqyStY0I0Bjt2Dl73A6VDAY=; b=Tx2GF3f6t+2iqimgPkXEwqrt+aGNFPr8VlmJ3KJFCjD2VoyymI5XCWiQA6R3Ioi3Ot VgryKwCWYX6mmRg/uNsUE5PZgoxrTZiYuLz+mR+O4Co6zMfcJeG+bhShAn3yytG17ICy kPSrMb+t2DYssVLu5YTF0M9rRqBWvj6073bNEDbZEQqKnji6JPQgnoiySCmdnMMi/6Wa zR9q3KrNwNykAId9XOj4H1wnxyZ7v+acpD+ExuK7jNaDj869C0BmvdX2g9xQgobnorKS gsM7HfFtmlOMpBqkO+l2ImK8VSWnqLeh0Rdb3e/O0h/uMCXT3fNK7kKeLlqKOpuW1Xcy yCHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZPENFdV4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt26si12483546ejb.216.2021.03.29.01.39.11; Mon, 29 Mar 2021 01:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZPENFdV4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbhC2IfB (ORCPT + 99 others); Mon, 29 Mar 2021 04:35:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:38466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbhC2IVd (ORCPT ); Mon, 29 Mar 2021 04:21:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C4E76197C; Mon, 29 Mar 2021 08:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006093; bh=NFRGoH2I14XIttQ8SkMKpRIyZdGV73E3L7CqyUTrvXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZPENFdV4enYQ7KMpyIq6xxbZUQygBRifsmdGoHIaOIKuktuG7ZAhrNlG7yd62kKF2 NpLN7IAyNGJ8eZCR5VPfRm4iEIc1R7IwBJcB3OReiqKq0w6uBLUzmyALlJg2tlMNyu AZPYCHKQYQLn72I/Mjz+jkJJMRcpGsTcT7mg6+es= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Courtney Cavin , syzbot , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 116/221] net: qrtr: fix a kernel-infoleak in qrtr_recvmsg() Date: Mon, 29 Mar 2021 09:57:27 +0200 Message-Id: <20210329075633.080146853@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 50535249f624d0072cd885bcdce4e4b6fb770160 ] struct sockaddr_qrtr has a 2-byte hole, and qrtr_recvmsg() currently does not clear it before copying kernel data to user space. It might be too late to name the hole since sockaddr_qrtr structure is uapi. BUG: KMSAN: kernel-infoleak in kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249 CPU: 0 PID: 29705 Comm: syz-executor.3 Not tainted 5.11.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x21c/0x280 lib/dump_stack.c:120 kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118 kmsan_internal_check_memory+0x202/0x520 mm/kmsan/kmsan.c:402 kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249 instrument_copy_to_user include/linux/instrumented.h:121 [inline] _copy_to_user+0x1ac/0x270 lib/usercopy.c:33 copy_to_user include/linux/uaccess.h:209 [inline] move_addr_to_user+0x3a2/0x640 net/socket.c:237 ____sys_recvmsg+0x696/0xd50 net/socket.c:2575 ___sys_recvmsg net/socket.c:2610 [inline] do_recvmmsg+0xa97/0x22d0 net/socket.c:2710 __sys_recvmmsg net/socket.c:2789 [inline] __do_sys_recvmmsg net/socket.c:2812 [inline] __se_sys_recvmmsg+0x24a/0x410 net/socket.c:2805 __x64_sys_recvmmsg+0x62/0x80 net/socket.c:2805 do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x465f69 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f43659d6188 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000465f69 RDX: 0000000000000008 RSI: 0000000020003e40 RDI: 0000000000000003 RBP: 00000000004bfa8f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000010060 R11: 0000000000000246 R12: 000000000056bf60 R13: 0000000000a9fb1f R14: 00007f43659d6300 R15: 0000000000022000 Local variable ----addr@____sys_recvmsg created at: ____sys_recvmsg+0x168/0xd50 net/socket.c:2550 ____sys_recvmsg+0x168/0xd50 net/socket.c:2550 Bytes 2-3 of 12 are uninitialized Memory access of size 12 starts at ffff88817c627b40 Data copied to user address 0000000020000140 Fixes: bdabad3e363d ("net: Add Qualcomm IPC router") Signed-off-by: Eric Dumazet Cc: Courtney Cavin Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/qrtr/qrtr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 54031ee079a2..45fbf5f4dcd2 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -1035,6 +1035,11 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, rc = copied; if (addr) { + /* There is an anonymous 2-byte hole after sq_family, + * make sure to clear it. + */ + memset(addr, 0, sizeof(*addr)); + addr->sq_family = AF_QIPCRTR; addr->sq_node = cb->src_node; addr->sq_port = cb->src_port; -- 2.30.1