From patchwork Sat Oct 22 07:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1093923wrr; Sat, 22 Oct 2022 00:58:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54BJpeeq0GV830ZC0ChA2gSwB1UGwMUayYuYejRRMIoPAhfKSsHlMs+qgV8NEatBNF9mgJ X-Received: by 2002:a65:42c7:0:b0:462:7158:c863 with SMTP id l7-20020a6542c7000000b004627158c863mr19940318pgp.590.1666425530838; Sat, 22 Oct 2022 00:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425530; cv=none; d=google.com; s=arc-20160816; b=JguFn4AglWbxNZW6RjucCFmHae2L3sOpl8iw5uCMk4XWJ2//evsXrc3/fp8LQeQRd/ gUM+ow3TmwSiMawt4Uj7hVoQjuFx4q1Ft3ihagVXiTh4z0xbaBri0F85ooyb6mT/JAiQ Pm5zE2vfVeWn778W9q8lAwPCdNNFoXsSJu6BheCqZViVnzaLif8QyLyvH3P7GJSrY/47 uan4D+nq9ROxkzwApdbnoHHe3dh2dZ1ncYSiISk6vRSqN1Nke0df4o8URfgGTtMmu6SD aIwCAGIjizc0cgCiYwuGKOEqzhkk3ad0nUkA9THf3DtEJaIMGCMEUJoToiTaVM7ukFaF KDUg== 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=H4PZH7WiCf/YvJbej1zBr8Hv8NavGNvZ/ApM6k840VA=; b=z1y9Ncq0w2IznVFnHSHkbpr7xLIBjlEQJdYPfkxbJQdyo4O+ejQRNbTVQPHEjp6Ojf WM7FPb3UnMjBGKFzGsTThJiDRetzz1xrzgU/gR1rYRcgENMjDQh7qjpcmXUQT90h6zVd MLWHtQn2MISu9oMfM3QIYQ56yjxnWuR4pcV0Ln859mzr24TKTG/Tj/tUpRfo44jlMx3f aBBMBBUagutFbfTmGK1hCtOD/lnitDLdRLUskLFudq5mmWKFWwPeJfIORJl+lv2Mrcst akPXo+jM2BRUcH0wXDBNZvkASwqx98DBwaCJkT2uxMJUqGcSCUrEd+fQK82SgzJxJ+z9 RLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U5HpgIEN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a72-20020a63904b000000b0046ed15a820esi1876313pge.385.2022.10.22.00.58.38; Sat, 22 Oct 2022 00:58:50 -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=U5HpgIEN; 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 S232362AbiJVH6U (ORCPT + 99 others); Sat, 22 Oct 2022 03:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbiJVHyA (ORCPT ); Sat, 22 Oct 2022 03:54:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A65866F17; Sat, 22 Oct 2022 00:47:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 079C460B76; Sat, 22 Oct 2022 07:46:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DBA6C433D6; Sat, 22 Oct 2022 07:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424761; bh=E0P5Plv7o5uoE/gCMwmS7YD7vzFnZnNz9sL7HO26qXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5HpgIENFTizaHv2DzpBTQLILRcvxSLNAV75QMBBhprLwh582Pbos5QqKkP+ZkQ3Y 2ao3uNgcEcd8lw2A75Ec1RqG5wKcj2UUlkIiERCPZ676Sobd5z9W9t1VMjMc0UOahS r+dsQQmEtYzDm696jmXhCqp69xqpfJwsu6kw5iXQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= , Kalle Valo , Sasha Levin Subject: [PATCH 5.19 227/717] wifi: wfx: prevent underflow in wfx_send_pds() Date: Sat, 22 Oct 2022 09:21:46 +0200 Message-Id: <20221022072455.271461706@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373817031106773?= X-GMAIL-MSGID: =?utf-8?q?1747373817031106773?= From: Dan Carpenter [ Upstream commit f97c81f5b7f8047810b0d79a8f759a83951210a0 ] This does a "chunk_len - 4" subtraction later when it calls: ret = wfx_hif_configuration(wdev, buf + 4, chunk_len - 4); so check for "chunk_len" is less than 4. Fixes: dcbecb497908 ("staging: wfx: allow new PDS format") Signed-off-by: Dan Carpenter Reviewed-by: Jérôme Pouiller Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/Yv8eX7Xv2ubUOvW7@kili Signed-off-by: Sasha Levin --- drivers/net/wireless/silabs/wfx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c index e015bfb8d221..84d82ddded56 100644 --- a/drivers/net/wireless/silabs/wfx/main.c +++ b/drivers/net/wireless/silabs/wfx/main.c @@ -181,7 +181,7 @@ int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len) while (len > 0) { chunk_type = get_unaligned_le16(buf + 0); chunk_len = get_unaligned_le16(buf + 2); - if (chunk_len > len) { + if (chunk_len < 4 || chunk_len > len) { dev_err(wdev->dev, "PDS:%d: corrupted file\n", chunk_num); return -EINVAL; }