Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3413304pxf; Mon, 29 Mar 2021 01:17:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2KCcWEo54N+3SX5Humy5iIGJlFT23gAhuJSjTrHdlkDnCh6QhH1GAbgtKVoK7whKAGoW0 X-Received: by 2002:a05:6402:35c9:: with SMTP id z9mr27288319edc.94.1617005862279; Mon, 29 Mar 2021 01:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617005862; cv=none; d=google.com; s=arc-20160816; b=rORcZSAK6TZzq6uCc3hNp4j+FJ8n1qS4Q9lCEMfqeUFVJnM51qu48WW+ITXWvatWpg 0ul2j+Obr6LHcVVaVmuAoBjNtrC4QpQj9P243XXfkd+pPMGvfVmz2ccseTqOkhXXefHs SM05KdBCeK7uTwMMUbh2tg6n/Nrzl51gXC2ZnqD4LMgzRuOgPMITh8McIOQUWDELTux3 j68bDzdtkKetXCitcCZa/Zf2n91XkywBWe+lU4tBfwuuHvbqRIoAXALXA/4SX99FpStR 4UECC3iryjFn3rgJq1yBdQnYWMhgpo0Xk+CoBzzmevK2JzU64vsoSfLk8rpL03VHoghu d+9w== 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=HOcbsABIdp7Da6mbhqe+3TnQNs41ysrFzfWJfFQzMwQ=; b=QQ95UAyltVu2OKDL6XVOpw1SHK3UEN5gy0YNIjF1rA66YgnmIqeTvzh4vCGuAfvpI4 JAxilMqroe7samsRiGr6Brmcp6dEdynpsf+/NKIglwDuz8TMWcLSWjvBv4sqagdbmvrp 90VKw0MbOkfsRkNNJDBg6PCZClKiFUIbzlUgV8wIwz3uweNQTG6Hox5wDchcFXWV5W4m uctoaT0tNaTYPgnvrUne1+x91yNaGSd8fmVkMRCDbPit/sLAWmK/3X5cySqVF9hWgOkF AofPjbF8o7w5xclKoUJu7/4X9dISUr2gK5jyzrcO394tHhJLUVMfQWKdFQ+Vdu/Zc/V2 d0Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kZ8NHe2Y; 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 b11si12855563edz.197.2021.03.29.01.17.19; Mon, 29 Mar 2021 01:17:42 -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=kZ8NHe2Y; 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 S233134AbhC2IQ2 (ORCPT + 99 others); Mon, 29 Mar 2021 04:16:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:54106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232053AbhC2IKN (ORCPT ); Mon, 29 Mar 2021 04:10:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A6AE6196D; Mon, 29 Mar 2021 08:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005408; bh=XEdT1rkD5uhVOjvNs/ZeSKhfJbb47dQq4m2bfw1UnWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZ8NHe2Yo3G9Pe0N61Q30zH6KXlbUocZhbxQE6e5YjcL/5eXurOiHr6E9J02pOigy /pPqJ5bs7J7NXNw0z93H2q5ZLwZLiuAX7x26tDy6B6/wXXC1KM74D4W9XpzL1SkaVB 1iSD+oICTo7fYOaoIDGKLdXxLJlAMCWyRECQqudo= 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" Subject: [PATCH 4.19 69/72] net: qrtr: fix a kernel-infoleak in qrtr_recvmsg() Date: Mon, 29 Mar 2021 09:58:45 +0200 Message-Id: <20210329075612.555623825@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075610.300795746@linuxfoundation.org> References: <20210329075610.300795746@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 commit 50535249f624d0072cd885bcdce4e4b6fb770160 upstream. 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: Greg Kroah-Hartman --- net/qrtr/qrtr.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -868,6 +868,11 @@ static int qrtr_recvmsg(struct socket *s rc = copied; if (addr) { + /* There is an anonymous 2-byte hole after sq_family, + * make sure to clear it. + */ + memset(addr, 0, sizeof(*addr)); + cb = (struct qrtr_cb *)skb->cb; addr->sq_family = AF_QIPCRTR; addr->sq_node = cb->src_node;