Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3683562rwe; Mon, 17 Apr 2023 01:45:45 -0700 (PDT) X-Google-Smtp-Source: AKy350aKXI5MQX9FFFnDN9ceNHcFhGTKGOenIjwrnASDkpAsjUXtQx7kWkKiFQu3jlrHywKblWSf X-Received: by 2002:a05:6a20:9144:b0:ef:d2c1:62a with SMTP id x4-20020a056a20914400b000efd2c1062amr3291059pzc.19.1681721145600; Mon, 17 Apr 2023 01:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681721145; cv=none; d=google.com; s=arc-20160816; b=iD98n1hxS0/Q3jCNRDhf/usm/B+AGMicIB4CaI7qXuhPhiu8lalGPRGb0oh4zRo8py MI7xNvizY9SBLDWgvqAQeaARFcfa8A2MWO6WgqJSpnOa1vTp4JFkLlY92zZgrB8h/nfP wOuCcrdcX7yT2n3oBb30ZHENhSqkfph0UCsAzS/CIZrYTu4JcumlwO/b3nn7E/h3GTFn MCL+xx4mw3n0XkjnlO1mOXBRLq1bioVxsQdPeNqoGfIKoNzeHa0PYHXDgrfu1HPcrg6D PnD1cxUktByj8XbmmTkzck2ORiwW4XvknFRVn0Yx4zxtg/ygz8quhYM56Axv5hxnjnlc FfhA== 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=sOC/B69916jn8CziC5rcfxsOPuwjkNWDdwOwh7FiWFM=; b=tLzWsqSspt2cVX/3COB9gPYeaMuWmSSNOAma4hdRv4Bpd3/STN/lvnueH4XtxJT0+N aLO6VfHVQZvFF5d812eyb9Kw+kr19kD8dSZXdbt9Qgi/twPF3PXv4WNz6luZdiU7aRbB hpmjYPOeLD0ONNXZerJDfHtGSm4VlBiCXFIsMzKO45c9LO7KfFPD7WESdbCL+/CBU2vO mTN6OTYli2uFLNMZhE0StH8q2whLnOHK06EK54i9yT4N0NkLecH1B0Y1whpGtS68RMmj quvLq3QNXXp5ONrCoziW66+cl7RV470ia0WWgV05GqgkK8JbX6aAzfurWIsiLrKmhFmc QQcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d135DucK; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a631f4d000000b0051b6e9d4daesi8678387pgm.585.2023.04.17.01.45.35; Mon, 17 Apr 2023 01:45:45 -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=@intel.com header.s=Intel header.b=d135DucK; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjDQIm3 (ORCPT + 63 others); Mon, 17 Apr 2023 04:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbjDQIm2 (ORCPT ); Mon, 17 Apr 2023 04:42:28 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6622830D3 for ; Mon, 17 Apr 2023 01:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681720941; x=1713256941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y0VT5xr/ASFgEZkBgeQLX0wzTKcpl3O8XDdAuUHfbeY=; b=d135DucKlhZH1ENkvtLBw5Ofa8FmMr4hHUHRGLHquBQSRcO/ki2KsepE ol7xvqoXEQGBYUFNhIkuQY2LxJB+IGnk5SZhZig6KinSGuSJGKYByxFgP WNBLq2utQFS2uwTHD3F4B0xIVAYMCvsMD+sGkogZxwwy/2ZVqduE94yCe QeXAl9TBq4U7EyicVCN2jAcym8IBd10wI7OtZL+ln9fFCPfrv+qpMO6Jl GZhvMhjFjKS5YLhk3AmOWadn/6eUV5gRgt0nLkkkHPeZsAOTRZyWo+SBn X1RkiTR+yvf2M9PMgj6WlnBiNyvBaNL0CDejQGObjrlREFAzmrhd2p1Ys Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="333634448" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="333634448" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 01:42:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="693173903" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="693173903" Received: from odotan1x-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.202.32]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 01:42:19 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 14/15] wifi: iwlwifi: mvm: check firmware response size Date: Mon, 17 Apr 2023 11:41:33 +0300 Message-Id: <20230417113648.0d56fcaf68ee.I70e9571f3ed7263929b04f8fabad23c9b999e4ea@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230417084134.1338976-1-gregory.greenman@intel.com> References: <20230417084134.1338976-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 From: Johannes Berg Check the firmware response size for responses to the memory read/write command in debugfs before using it. Fixes: 2b55f43f8e47 ("iwlwifi: mvm: Add mem debugfs entry") Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index affaed4d13fa..84a488538427 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c @@ -1961,6 +1961,11 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf, if (ret < 0) return ret; + if (iwl_rx_packet_payload_len(hcmd.resp_pkt) < sizeof(*rsp)) { + ret = -EIO; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data; if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) { ret = -ENXIO; @@ -2037,6 +2042,11 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file, if (ret < 0) return ret; + if (iwl_rx_packet_payload_len(hcmd.resp_pkt) < sizeof(*rsp)) { + ret = -EIO; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data; if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) { ret = -ENXIO; -- 2.38.1