From patchwork Tue Dec 21 19:39:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Skripkin X-Patchwork-Id: 12690493 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EFA1C433FE for ; Tue, 21 Dec 2021 19:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241846AbhLUTkF (ORCPT ); Tue, 21 Dec 2021 14:40:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237467AbhLUTkD (ORCPT ); Tue, 21 Dec 2021 14:40:03 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53524C061574; Tue, 21 Dec 2021 11:40:03 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id i31so120909lfv.10; Tue, 21 Dec 2021 11:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X+qQ8cOWr3KYDLsqh+E8A3qJbCcPj8hXX9NXQmQghMw=; b=IOh1sSAi35BrRDyT2BlikmB1kEuAJLWXMHKnQ5egM133fsVbRUwZrbL8GzMG1WdWyz lUR/VXFc1/sC4h9Kmv4tH4YXzBue1EEXp8YZTb0sfqQJwIGeap2S4ukbBvtDTnovRsAw kXMvMOJqamHKy/pzrvOF5oR1ZvdflKwSfbrNI8WV+CH0MZ8PA9siP1QiIlLU4/d1Tko3 CFVEtDtmUi6kzyss2xIpEkJES7rxOWwFktkFVU8F1q/INoZtj/NQH+pi9rxbM6HxG7DH 9YNssPt9pTO9LaNRReO6qlASl6nA9iClNSg4hKKzuogHlmioiKdFq/I9trDBXM6RATHL 6A7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X+qQ8cOWr3KYDLsqh+E8A3qJbCcPj8hXX9NXQmQghMw=; b=XxL/ZYgTpkyu0jpZuxXIkbbK31QV1VpGpcHwqE12O9XthzsCuGVcsd10FeVbDQ2CuJ F8LkpCnkc7p6UZB5alIZsAEf+LnL9BmccbO2MsRBHMxMGHuaPG9WpF7OqLcCXm+5f1iS ZWcUNXmzJ8BvNSlth0re0V0JqZnyoqb/iiMccsMiN93IE1OufzjyewiVNdqAh36nD7Bk 2eY/lGz5MoaM/HRDyetMpr5wcSMagRc+LqCeoG/5rjMitpHzVOAy1n+r8k8OLAU08M+1 SKPj0P+ZAsGkjNuFGfP/R14iuMsQZUop6ladOpt3mpwX3rbNPAXXcVi2EXwyqfcRO+Qc E2Dg== X-Gm-Message-State: AOAM531eeRoi/s8ksGHO3cQvfIV/EOjIFb2AB9TTuXlJGLMq6qxngYtb zxXt+VtKLAO/U/Aj6VO05Dk= X-Google-Smtp-Source: ABdhPJyiWYtCRiDHXtbL3FNBAPDPseFmLc0mG9mUtTOEL9oDneTuykecD30kXs+F2wE2ie8XpjqfXg== X-Received: by 2002:a05:6512:3e28:: with SMTP id i40mr4084008lfv.436.1640115601549; Tue, 21 Dec 2021 11:40:01 -0800 (PST) Received: from localhost.localdomain ([94.103.235.97]) by smtp.gmail.com with ESMTPSA id d5sm662799lfv.83.2021.12.21.11.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 11:40:01 -0800 (PST) From: Pavel Skripkin To: davem@davemloft.net, kuba@kernel.org, linux@rempel-privat.de, andrew@lunn.ch, robert.foss@collabora.com, freddy@asix.com.tw Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Skripkin , syzbot+f44badb06036334e867a@syzkaller.appspotmail.com Subject: [PATCH 1/2] asix: fix uninit-value in asix_mdio_read() Date: Tue, 21 Dec 2021 22:39:32 +0300 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org asix_read_cmd() may read less than sizeof(smsr) bytes and in this case smsr will be uninitialized. Fail log: BUG: KMSAN: uninit-value in asix_check_host_enable drivers/net/usb/asix_common.c:82 [inline] BUG: KMSAN: uninit-value in asix_check_host_enable drivers/net/usb/asix_common.c:82 [inline] drivers/net/usb/asix_common.c:497 BUG: KMSAN: uninit-value in asix_mdio_read+0x3c1/0xb00 drivers/net/usb/asix_common.c:497 drivers/net/usb/asix_common.c:497 asix_check_host_enable drivers/net/usb/asix_common.c:82 [inline] asix_check_host_enable drivers/net/usb/asix_common.c:82 [inline] drivers/net/usb/asix_common.c:497 asix_mdio_read+0x3c1/0xb00 drivers/net/usb/asix_common.c:497 drivers/net/usb/asix_common.c:497 Fixes: d9fe64e51114 ("net: asix: Add in_pm parameter") Reported-and-tested-by: syzbot+f44badb06036334e867a@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Reviewed-by: Andrew Lunn --- drivers/net/usb/asix_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c index 42ba4af68090..06823d7141b6 100644 --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c @@ -77,7 +77,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm) 0, 0, 1, &smsr, in_pm); if (ret == -ENODEV) break; - else if (ret < 0) + else if (ret < sizeof(smsr)) continue; else if (smsr & AX_HOST_EN) break; From patchwork Tue Dec 21 19:40:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Skripkin X-Patchwork-Id: 12690495 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 021F0C433F5 for ; Tue, 21 Dec 2021 19:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241857AbhLUTkK (ORCPT ); Tue, 21 Dec 2021 14:40:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241842AbhLUTkJ (ORCPT ); Tue, 21 Dec 2021 14:40:09 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BEA2C061574; Tue, 21 Dec 2021 11:40:09 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id p8so21510ljo.5; Tue, 21 Dec 2021 11:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/uKyyOqK31yVvTxepIWf3C0/nG0qY+9vHEVmcazif6A=; b=mDwpKytDas5WfYtyTNm4aXCVrv1Kd6hSyQs6O1BA538BAsxZY8NtZgVeZShQZSi+PL Upe8i69lpPviyuHiY8D+DBnvF45fWgVNKhIaOoqnVWBmnEBhIFw1VyqZRNzTFRW/rlwH DrB1ZGxIIs+29C99QacgeQpeqpl/C12yHB6hwrs990lx2fx8yAfoCt1W1R86Q+7foYM9 D9jcfsfW2gohC/FVxcAP58zLL/JuSN+Kn6YVcQKuizG00o187cNbD11I7AD7puhIhFNK 6A5IgcYpjyI4bc262CsymBb3DoBZhILlrNaRnWA0jiVI2EB4yr7asIFLCPCAjqY5czRl 7H4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/uKyyOqK31yVvTxepIWf3C0/nG0qY+9vHEVmcazif6A=; b=Q1Yi4VXEW5XO1+QFtcKN0XZ8Q0SlSsa0l4T++C9mIEZyNnm/UigWih7WIPrd8lcnYh C6rwie5ybMgBdg/COgksTyAJqTTNmODY4oOr0rpAgtMIw+hGRjCIrG/77m3YhLSEGi9f /fTgq3yQH4hhcEfJBgVGDPwYtrEMliNfaGjKQyvcKmOo6cN+mSsZbKsCs6bRsUGotz0c 6YMXV+3L/YM9PNmQ8VFmbnojHQE1wiBpsgK1XACilLreXkXeC89bJkHtCmbd9jTVjaUa RZtwC+MzoaLhuXKrlKUvHIAF6FX/UAidKbi9yRsHNijxDJ8yhOvY6yt4+lrB/dzMMWgx Vqow== X-Gm-Message-State: AOAM530SJevlhxgdw792XijLWTm3MdMCwQhoFVTuJ0jGmjXzTYpWLsaQ zwBJQ28GdC088MwfwOsCz7M= X-Google-Smtp-Source: ABdhPJxCT5s/kKAWn+YxAhCAhMXMP3dAl+/J/UAgVhopQojePuKy41uetIeiPF5CNpqFiUhXZIUnUg== X-Received: by 2002:a2e:8e88:: with SMTP id z8mr3540873ljk.197.1640115607420; Tue, 21 Dec 2021 11:40:07 -0800 (PST) Received: from localhost.localdomain ([94.103.235.97]) by smtp.gmail.com with ESMTPSA id j21sm2819061lji.88.2021.12.21.11.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 11:40:07 -0800 (PST) From: Pavel Skripkin To: davem@davemloft.net, kuba@kernel.org, linux@rempel-privat.de, andrew@lunn.ch, robert.foss@collabora.com, freddy@asix.com.tw Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Skripkin Subject: [PATCH 2/2] asix: fix wrong return value in asix_check_host_enable() Date: Tue, 21 Dec 2021 22:40:05 +0300 Message-Id: <989915c5f8887e4a0281ed87325277aa8c997291.1640115493.git.paskripkin@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If asix_read_cmd() returns 0 on 30th interation, 0 will be returned from asix_check_host_enable(), which is logically wrong. Fix it by returning -ETIMEDOUT explicitly if we have exceeded 30 iterations Fixes: a786e3195d6a ("net: asix: fix uninit value bugs") Reported-by: Andrew Lunn Signed-off-by: Pavel Skripkin --- drivers/net/usb/asix_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c index 06823d7141b6..8c61d410a123 100644 --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c @@ -83,7 +83,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm) break; } - return ret; + return i >= 30? -ETIMEDOUT: ret; } static void reset_asix_rx_fixup_info(struct asix_rx_fixup_info *rx)