Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3764334pxt; Tue, 10 Aug 2021 10:46:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/9r6VILpl7qCffs3RpF30JqD2DXyNUbvjQHpSOFoLiVoGeVAh8XUyf5KSaMC3uHQXZDyV X-Received: by 2002:a6b:5d18:: with SMTP id r24mr349430iob.156.1628617595482; Tue, 10 Aug 2021 10:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617595; cv=none; d=google.com; s=arc-20160816; b=IxWrwDCmFYYpmr/4Qsp+c5xTbT7DT4RW0G0q0YDICnD3+cmgygHuYUevpLbLDoEVQA ryJ2+5PH7vHAXHEXWgR/YPTzcRDDq2StH07jHqJJPrsUZdGCRbj6JY4xsYxZBNaQ5kpR xuGMHr3nSUSuWzmvSi0CCLEXlIbRUYEkyx0wfaigimlTwtER76l5suk84YmhyjjcirG6 ZA0kGg8E9Z+TvwVga3s1AsVowCrswKh656CknfZpL9aJPs+YWWzQlfDG/u0WAAw9hZYn NuIDCYncqy0fG78fKFg2eVFVfaOHI+q6TmSZdwG+M3YXDqsie6x3NJWbdPuNUXp4aRFC Ki6w== 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=/v5wWQ6zw0B3L/a8JoKpMWcz3iFBrtGSS5BGZyrXmhs=; b=jSPVGtQtesxGkvNo+nSbLpfc0vzwwkjQVX3BX3VzXeh5QNh4W0YO/s/xybeQyUvE0H a6aSj3lekHwjUk4upbR1HHoxk5fF3vnlyjkch7HaNPdJ24+RIDqF/gmE4x9XahUULH5m M8Tqb395AYAe4WcV++wvDzmp5CIr0g0jUrjuXCgEywe1rbJ7FeCgO9EIg8tV/UnHnJqs ZBEzVDf4tnl33jpvIjRpPIqHMqD3LQ2MW1qP1yFPVVy3ecsis6NfbW5uALsRTV9coHI/ c9MXkw4jFzwosZNt1kxNPhs1RsIqB8maqJKD39Hqxb8G4twTwt29gtVrljVGV/cL2hkV kUeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oIdhXtTx; 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 h14si12007241iow.53.2021.08.10.10.46.22; Tue, 10 Aug 2021 10:46:35 -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=oIdhXtTx; 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 S230309AbhHJRpW (ORCPT + 99 others); Tue, 10 Aug 2021 13:45:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234023AbhHJRld (ORCPT ); Tue, 10 Aug 2021 13:41:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65A446120E; Tue, 10 Aug 2021 17:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617103; bh=2j2nIHbAOsZ5cWv9EELU6sQc9Iuicje8JyfIA6YcXBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oIdhXtTx/4yIEbTSyBHUzSvqfdYQA0ZyGblGOqNXseX43aPTpErFoXkXL7SrF7oob HpriOqK4QzSOydQxZ+A4iv8FrGgZDy6zrl/vHOW3vK3yP6Zk9xFt2WBgIHXo4MQAue qsYQN/mRMYE6zjURt0EZAwpBq3K96JNG4s2hLRoE= 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 5.10 047/135] net: pegasus: fix uninit-value in get_interrupt_interval Date: Tue, 10 Aug 2021 19:29:41 +0200 Message-Id: <20210810172957.291090167@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 32e1335c94ad..0d7935924e58 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c @@ -736,12 +736,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) { @@ -756,6 +760,8 @@ static inline void get_interrupt_interval(pegasus_t *pegasus) } } pegasus->intr_interval = interval; + + return 0; } static void set_carrier(struct net_device *net) @@ -1150,7 +1156,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