Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp690507pxb; Tue, 5 Apr 2022 18:56:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZHTv7N+R8+lajGcuq4zXotZ6yr9fBTtL9RMqh3XZ9fKryvOw1/F376noGZP3Z2YIdd26m X-Received: by 2002:a63:5810:0:b0:381:6562:46fb with SMTP id m16-20020a635810000000b00381656246fbmr5112943pgb.567.1649210198118; Tue, 05 Apr 2022 18:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210198; cv=none; d=google.com; s=arc-20160816; b=05IiEYBHj/niWU2MD2JHkeNoEFOm3UB5v9A6vl54HL0WDY9LqfaOOhq4HY7NMJ1xUd QaPWUCtgsWcvcf5hrNkmMcBYGGKpLOESzbCIWopyEYcRPIj1T+sfFZmmZgiYytf7Nswv t5WZZBlWZg7iy5z34Hb0PVPwu+/ai1hg6fGXQifXbOqFZZsMZlsNV2XaAtL3CMgCGNAn SgjQw4GgXDWtoYt/Fv+8TX9XxXUfGm16Whue4sVJLVtvGtJJ6/P6r4RHmi3sbZazfWd1 rthtFw2AAW5vQvHUme5rrgqe1dgq1rb8/kLchI6IpEBoqKhmplm0emxaWvbbGKxv4OAV H7lw== 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=tUuhfImMQ8xEA/x639YvroiFjvYNgV81TWMmAzXLNDc=; b=PyiyhnBWhLhlsxU4ZmRFVftu3f7NBDitksne1z5RCaNNXuMvi3fauZ1Qd35pic7Pup wBO+daMypMw7fhxZ1+E5ROpcdCOqENZA9ZBJOpi+q83z1bIPPWkHgNo8eYH/vVDRtP1/ F71OfKVfdxUV9RjCQBx04l3u3gKcRxmErkgRCCsURGMsaAAtYrJsy0uACTWo2ZcCsJry ePeGHdBsfhLT6mEk6waaFaN+73Eke5lMN8NHCafSJ9v9SyJVWR40EgDDxEFE/rSvrOsR qyJP7n9h2wD8Mp0+AOfawZ1Kh953JFm+brYABPUcEugZXuGle/1Jecsvwsv21ATZkFPY PVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tHhrAPbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a170902f64100b001567cbd9a37si11205924plg.223.2022.04.05.18.56.24; Tue, 05 Apr 2022 18:56:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tHhrAPbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344905AbiDEM3j (ORCPT + 99 others); Tue, 5 Apr 2022 08:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245730AbiDEI4y (ORCPT ); Tue, 5 Apr 2022 04:56:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C9B919C0B; Tue, 5 Apr 2022 01:52:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 02751B81B75; Tue, 5 Apr 2022 08:52:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65569C385A0; Tue, 5 Apr 2022 08:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148759; bh=6teVxoPhBawGeWELxNYk1AiLJDt6H6dR+P6fL/PEkA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHhrAPbWlRY3eS/WAnf5LPpuKVDigGHSt0bJRafZSyL4kRyQ+QsGvB5+6NPVl7w6A Wr413+bF3Bgcq3pUDse8zLEP9H8j0F0PRvOhMafWNTVVbIoO7GH/b69FFDw7Jgn7LO MxHqoAHZtKF9k2wcGuB9m9tnSdiLoM+Ljnb5rdRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f83a1df1ed4f67e8d8ad@syzkaller.appspotmail.com, Pavel Skripkin , Kalle Valo , Sasha Levin Subject: [PATCH 5.16 0433/1017] ath9k_htc: fix uninit value bugs Date: Tue, 5 Apr 2022 09:22:26 +0200 Message-Id: <20220405070407.147717925@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit d1e0df1c57bd30871dd1c855742a7c346dbca853 ] Syzbot reported 2 KMSAN bugs in ath9k. All of them are caused by missing field initialization. In htc_connect_service() svc_meta_len and pad are not initialized. Based on code it looks like in current skb there is no service data, so simply initialize svc_meta_len to 0. htc_issue_send() does not initialize htc_frame_hdr::control array. Based on firmware code, it will initialize it by itself, so simply zero whole array to make KMSAN happy Fail logs: BUG: KMSAN: kernel-usb-infoleak in usb_submit_urb+0x6c1/0x2aa0 drivers/usb/core/urb.c:430 usb_submit_urb+0x6c1/0x2aa0 drivers/usb/core/urb.c:430 hif_usb_send_regout drivers/net/wireless/ath/ath9k/hif_usb.c:127 [inline] hif_usb_send+0x5f0/0x16f0 drivers/net/wireless/ath/ath9k/hif_usb.c:479 htc_issue_send drivers/net/wireless/ath/ath9k/htc_hst.c:34 [inline] htc_connect_service+0x143e/0x1960 drivers/net/wireless/ath/ath9k/htc_hst.c:275 ... Uninit was created at: slab_post_alloc_hook mm/slab.h:524 [inline] slab_alloc_node mm/slub.c:3251 [inline] __kmalloc_node_track_caller+0xe0c/0x1510 mm/slub.c:4974 kmalloc_reserve net/core/skbuff.c:354 [inline] __alloc_skb+0x545/0xf90 net/core/skbuff.c:426 alloc_skb include/linux/skbuff.h:1126 [inline] htc_connect_service+0x1029/0x1960 drivers/net/wireless/ath/ath9k/htc_hst.c:258 ... Bytes 4-7 of 18 are uninitialized Memory access of size 18 starts at ffff888027377e00 BUG: KMSAN: kernel-usb-infoleak in usb_submit_urb+0x6c1/0x2aa0 drivers/usb/core/urb.c:430 usb_submit_urb+0x6c1/0x2aa0 drivers/usb/core/urb.c:430 hif_usb_send_regout drivers/net/wireless/ath/ath9k/hif_usb.c:127 [inline] hif_usb_send+0x5f0/0x16f0 drivers/net/wireless/ath/ath9k/hif_usb.c:479 htc_issue_send drivers/net/wireless/ath/ath9k/htc_hst.c:34 [inline] htc_connect_service+0x143e/0x1960 drivers/net/wireless/ath/ath9k/htc_hst.c:275 ... Uninit was created at: slab_post_alloc_hook mm/slab.h:524 [inline] slab_alloc_node mm/slub.c:3251 [inline] __kmalloc_node_track_caller+0xe0c/0x1510 mm/slub.c:4974 kmalloc_reserve net/core/skbuff.c:354 [inline] __alloc_skb+0x545/0xf90 net/core/skbuff.c:426 alloc_skb include/linux/skbuff.h:1126 [inline] htc_connect_service+0x1029/0x1960 drivers/net/wireless/ath/ath9k/htc_hst.c:258 ... Bytes 16-17 of 18 are uninitialized Memory access of size 18 starts at ffff888027377e00 Fixes: fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.") Reported-by: syzbot+f83a1df1ed4f67e8d8ad@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220115122733.11160-1-paskripkin@gmail.com Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath9k/htc_hst.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 510e61e97dbc..994ec48b2f66 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c @@ -30,6 +30,7 @@ static int htc_issue_send(struct htc_target *target, struct sk_buff* skb, hdr->endpoint_id = epid; hdr->flags = flags; hdr->payload_len = cpu_to_be16(len); + memset(hdr->control, 0, sizeof(hdr->control)); status = target->hif->send(target->hif_dev, endpoint->ul_pipeid, skb); @@ -272,6 +273,10 @@ int htc_connect_service(struct htc_target *target, conn_msg->dl_pipeid = endpoint->dl_pipeid; conn_msg->ul_pipeid = endpoint->ul_pipeid; + /* To prevent infoleak */ + conn_msg->svc_meta_len = 0; + conn_msg->pad = 0; + ret = htc_issue_send(target, skb, skb->len, 0, ENDPOINT0); if (ret) goto err; -- 2.34.1