Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp928525rwb; Fri, 28 Jul 2023 01:53:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlHw9UCCMrGEsCZqJHO4vtm9t1WuSZqPMOq4vaw3e49TKQgmkjy4WygIH6ztOg/ucblRF4Dx X-Received: by 2002:a05:6a20:160b:b0:133:bf18:ef7b with SMTP id l11-20020a056a20160b00b00133bf18ef7bmr1711236pzj.24.1690534420352; Fri, 28 Jul 2023 01:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690534420; cv=none; d=google.com; s=arc-20160816; b=GCYgUZ6WoCTouNjD+RNBZbxCzNJbjgcnBsC62iHDMgHpIfn1alhTmya8JtYjMwZjtM /o3KtgWNFhx4QJADHM94sHZ7Oj+dax37WFu8T2pzY8sw5LO98TqeF2GLJzS8RAx/FkvO ys/pZ0rXmGoqMq6URx6aAkKlHh8PDLVYQTw2fKLjbbZOm3X/8MP+ckHeHyNudfaRwbxY faJsyKMr34VHxwf1M+pgNhBRr7RttEtAq5FIKgd7fX0YLMuMKKQzwQsfD3lXocZIwDJQ XcPDqju4/DC/K1oY/O2s8H9hODlTYtvzO29Crtu/qqbiRKgDmIUpJovBLaNvZPXi4FFX LAcw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pMw6xofZHOSIHegJ1kvDTVYC2zzE+2xrkl70iyfOzxo=; fh=qNTNQJCwXPXlkhMjfcbW5RmVTNlOQmtiwNfLT5XSKFo=; b=NPXt4bdVeJV513iF0ZCpZemtHt7SouTRKEvMCUNxWvcfOhYJPw6sC/+5afCqaZwhAO m3r8y6gPlxjKyALS4vyqv685zwXz40okXiPcRpeddADj4EW8DdOw9MXtQJILJA6xKGYv pKEo6qBdJuXhuP6eoaForXr5a1MCJV2Q5cc9OihU3uCh/UXseTNGSyT1D+qgch+/0MSM owKaQsCq+jVdkBn/MB3a64C+rHdyApEABlh1bAMjCIJWSm4SLlRswpUCoKMFn6aWkjLn Hal8V3aNII64hKWxZc1falPF7TOk1CWliNhBz9ZnAIR5a9oLp5mHWiYV68wZGH7CQCjn QI6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=WZdryhG5; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s8-20020a637708000000b0055c8d5ad18esi2720455pgc.509.2023.07.28.01.53.26; Fri, 28 Jul 2023 01:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@yandex.ru header.s=mail header.b=WZdryhG5; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235121AbjG1Iom (ORCPT + 59 others); Fri, 28 Jul 2023 04:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233951AbjG1IoW (ORCPT ); Fri, 28 Jul 2023 04:44:22 -0400 Received: from forward103c.mail.yandex.net (forward103c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182BF2728 for ; Fri, 28 Jul 2023 01:44:21 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:a712:0:640:d986:0]) by forward103c.mail.yandex.net (Yandex) with ESMTP id B23FD6009C; Fri, 28 Jul 2023 11:44:19 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id EiIwG59DYW20-WQz64S0s; Fri, 28 Jul 2023 11:44:19 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690533859; bh=pMw6xofZHOSIHegJ1kvDTVYC2zzE+2xrkl70iyfOzxo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=WZdryhG5UeqEOjy6VJaL/ph0YU7NyZ6TpcbvwSR4OLH2xo7gZaD70liEatM/2t7vL kNxqHilXuZyWYeMPYCxEqc1jA00OF1KPGv4c3e8MJ01UMWjSY8MTBq5Wnnh9CV6cQB tK52z9CryhZGxwZXNo+FT/U+MNVQl1HFPKw7Hkw8= Authentication-Results: mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Brian Norris Cc: Kalle Valo , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 4/5] [v2] wifi: mwifiex: handle possible sscanf() errors Date: Fri, 28 Jul 2023 11:43:45 +0300 Message-ID: <20230728084407.101930-4-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230728084407.101930-1-dmantipov@yandex.ru> References: <20230728084407.101930-1-dmantipov@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-wireless@vger.kernel.org Return -EINVAL on possible 'sscanf()' errors in 'mwifiex_regrdwr_write()' and 'mwifiex_rdeeprom_write()'. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov --- v2: adjust to match series --- drivers/net/wireless/marvell/mwifiex/debugfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c index 0cdd6c50c1c0..f9c9fec7c792 100644 --- a/drivers/net/wireless/marvell/mwifiex/debugfs.c +++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c @@ -425,7 +425,10 @@ mwifiex_regrdwr_write(struct file *file, if (IS_ERR(buf)) return PTR_ERR(buf); - sscanf(buf, "%u %x %x", ®_type, ®_offset, ®_value); + if (sscanf(buf, "%u %x %x", ®_type, ®_offset, ®_value) != 3) { + ret = -EINVAL; + goto done; + } if (reg_type == 0 || reg_offset == 0) { ret = -EINVAL; @@ -691,7 +694,10 @@ mwifiex_rdeeprom_write(struct file *file, if (IS_ERR(buf)) return PTR_ERR(buf); - sscanf(buf, "%d %d", &offset, &bytes); + if (sscanf(buf, "%d %d", &offset, &bytes) != 2) { + ret = -EINVAL; + goto done; + } if (offset == -1 || bytes == -1) { ret = -EINVAL; -- 2.41.0