Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp872545pxb; Fri, 13 Aug 2021 08:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp2dUBzc7m1vaJfwFDWJ2SiMiRxf96uFHkiRN2tUn/prutt+L3r8sb4uh7TWFByyktaBsX X-Received: by 2002:a05:6e02:13f0:: with SMTP id w16mr2060806ilj.268.1628867417104; Fri, 13 Aug 2021 08:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628867417; cv=none; d=google.com; s=arc-20160816; b=GZjYY4Qr9/uu31z3HnnbY+29cY89S25sJx3pC2GDGY4OyW2QgdITplJJQslewrnCyS CK8L4ze6AWONxkUWsrYBNz+QWA/czJSPpiGMJ0CNIQXqKiNrMatGIy+Q7lo99lQJ6e7E a+Gx2bvStAVNNEMLPeZwwjXFquAabqPyz7eyNGlKKVF10DgMVc26n+zaai/BLJAyQCrG FMZprFbXRn+dkddkUiL79Mh14HpkVy4FGiNXd43W9RxLVAD4mQTJ34Rw0z1FNl8O49vB bbOByr/hp5jEE2tTh7oTAIrVWH53bKtrTpsCqAVJb+BQdmMCSM/0eiynKH3CeC1iOZNK U3pA== 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=h+XW4OmZtYXFzgDh3utyOufjtr/e3NCIFESwMMtKeVM=; b=KdiqglP8pRg5DZV+reWw36E3vX3PlWXeyLhhvWFJoY9HcpDCC7Lwqfr6d9t9N+ohnT PM38eQVvt8RDBC484PHusxQBxIyL7Rzi79ufRdbWwOGAjyG/3TaMcm5mAxIxWpoEj9tK SwgARdYK8UDaOuIbXzD3kccyzjCm2Sd0Y2oCltE0rbqSzKxtjnSUFajxsNW41lpqNDTB YU8uYfv0G6+mG0D598iPRFDK3100uR+L/7RnBT1ZoU5PmQFajVeIGMV8GwSERWp/KFI6 7sL8tglTYJ2ZS/afJKLnVq7RZ9az72tzxwvabPJ3LSecsJVPprWAUP0n8+UAwuuJL1Oa 3JXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wjP9QxeL; 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 k34si1944671jav.61.2021.08.13.08.10.00; Fri, 13 Aug 2021 08:10:17 -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=wjP9QxeL; 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 S241345AbhHMPJO (ORCPT + 99 others); Fri, 13 Aug 2021 11:09:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:51872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241343AbhHMPJO (ORCPT ); Fri, 13 Aug 2021 11:09:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7AE6C6109D; Fri, 13 Aug 2021 15:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628867327; bh=SId3e+sMIHGk87nm6B5/FjcOk/bnVTUQ/TCs0d5TgPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wjP9QxeLjekeZxaZ4EYky+eZvUyzkBfabEHMFcBQkpyvWe2EZhwaJ+bVJ9NQJ+KQg 1XsBeUTjzCCcHLL2Gxzd9c4gAdOiSYeLtSJr1+7STBAGnLZnTuHPizIIDsYR223OHM X6BXa+45ziehFCPowvhZZGMrPCPtYZgVrtcCia+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Jakub Kicinski , Sasha Levin , syzbot+02c9f70f3afae308464a@syzkaller.appspotmail.com Subject: [PATCH 4.4 07/25] net: pegasus: fix uninit-value in get_interrupt_interval Date: Fri, 13 Aug 2021 17:06:31 +0200 Message-Id: <20210813150520.966371231@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813150520.718161915@linuxfoundation.org> References: <20210813150520.718161915@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: Pavel Skripkin [ Upstream commit af35fc37354cda3c9c8cc4961b1d24bdc9d27903 ] Syzbot reported uninit value pegasus_probe(). The problem was in missing error handling. get_interrupt_interval() internally calls read_eprom_word() which can fail in some cases. For example: failed to receive usb control message. These cases should be handled to prevent uninit value bug, since read_eprom_word() will not initialize passed stack variable in case of internal failure. Fail log: BUG: KMSAN: uninit-value in get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline] BUG: KMSAN: uninit-value in pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152 CPU: 1 PID: 825 Comm: kworker/1:1 Not tainted 5.12.0-rc6-syzkaller #0 ... Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x24c/0x2e0 lib/dump_stack.c:120 kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118 __msan_warning+0x5c/0xa0 mm/kmsan/kmsan_instr.c:197 get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline] pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152 .... Local variable ----data.i@pegasus_probe created at: get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline] pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152 get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline] pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152 Reported-and-tested-by: syzbot+02c9f70f3afae308464a@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/20210804143005.439-1-paskripkin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/pegasus.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 4f505eb4f422..a7b1df01e0f7 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c @@ -755,12 +755,16 @@ static inline void disable_net_traffic(pegasus_t *pegasus) set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp); } -static inline void get_interrupt_interval(pegasus_t *pegasus) +static inline int get_interrupt_interval(pegasus_t *pegasus) { u16 data; u8 interval; + int ret; + + ret = read_eprom_word(pegasus, 4, &data); + if (ret < 0) + return ret; - read_eprom_word(pegasus, 4, &data); interval = data >> 8; if (pegasus->usb->speed != USB_SPEED_HIGH) { if (interval < 0x80) { @@ -775,6 +779,8 @@ static inline void get_interrupt_interval(pegasus_t *pegasus) } } pegasus->intr_interval = interval; + + return 0; } static void set_carrier(struct net_device *net) @@ -1190,7 +1196,9 @@ static int pegasus_probe(struct usb_interface *intf, | NETIF_MSG_PROBE | NETIF_MSG_LINK); pegasus->features = usb_dev_id[dev_index].private; - get_interrupt_interval(pegasus); + res = get_interrupt_interval(pegasus); + if (res) + goto out2; if (reset_mac(pegasus)) { dev_err(&intf->dev, "can't reset MAC\n"); res = -EIO; -- 2.30.2