From patchwork Fri Sep 21 20:42:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10610977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D60A112B for ; Fri, 21 Sep 2018 20:43:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ACFC279E0 for ; Fri, 21 Sep 2018 20:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DD93289A8; Fri, 21 Sep 2018 20:43:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F747279E0 for ; Fri, 21 Sep 2018 20:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ocG805++Vt7dvSMSqocr30qlYmsL5TVEjmrdN3pOUr4=; b=tragQrTKS9DbwK iRDY1/N3vRTyJ4vtc98bpeBQk1f54hVYAvDdkon4p4sYNKCvfaxe2bHbqEsEfa10f+1ULPYmpTDui PkzbYoWzutJay27VDXJex5hlDvTZUFH//kvrv/2a7IGnQWMc8QCMtoiS/TbH9ANlZYD5Eh98ef3SF xB3lbQy/OXFxkTbq+In5mdo/JbIea+GAQB8hSS8adMJE9Vg5oUoffl2QmS3ys3j33oXx1qFzw/1zj Ea6dugb2pRz1qanVK3s5D76uA19w1xo2bJ3N3t970xCKV/OhGdMdCnWeovbBkw9frFgFwpeLR4Cbt zIFO0j1LcVzOKScilt9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3SGZ-0005Ui-Ne; Fri, 21 Sep 2018 20:43:07 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3SGX-0005U5-2P for ath10k@lists.infradead.org; Fri, 21 Sep 2018 20:43:06 +0000 Received: by mail-pl1-x643.google.com with SMTP id g2-v6so6448518plo.2 for ; Fri, 21 Sep 2018 13:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lnUnqCIZWKqsR6b+s8TNA2V60rotZRso+B0fzWMs/bc=; b=G4N/YAp7PzkxC4xw8GTnl/wd67zi1we7Z0vGboZW6HyCQR6SYn6UEGPzUWz0W6pAdU 1/mT71pvigbmmz1hMwYk0FxaWQiJBRIuxYA9aIN0zITP7cpfaxoYP13Xdfj1i+ss19b4 w9ZEWoFdZDsFTx15YYY4limNQByp9pifP8fZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lnUnqCIZWKqsR6b+s8TNA2V60rotZRso+B0fzWMs/bc=; b=T5Pxo0e5O9ErGDA4blq+fKlYhvjDXvSrOadvshD+qDLKN9xwxOoH5OS7DbdFrOju7r 0rDIMwpbhotvtlv2Z+ZPi011Jkz4Is95mCS2KM1HIeejtC0abjzanABYBJVTfPaLjiKr 8eNBhOsVE07JSSwdDdj0kENU3Uo2j1qDv1pUonHz6slLopkWhMnXpdfzT10OmROwut3V wCIKIbxhm9pbK3wFJMsyd508ONhPE0ums+xGq7NleN/ruIrkKHXwLssRBXU6AElPJOw7 IQW3p9nysGDSUJuMEr1b5s1FCf7zGFRgUwn6HQZSSYi00uI/0Eo6vI0PBcR6KZHRAj04 P39w== X-Gm-Message-State: APzg51BGbuAls2VoX+ge22cNr1EntdXjTXg5rQcgLWsPX9TRsBiTg9q+ 8m3u4SnrIwS+o6um4p3OkWerg/ao8Bc= X-Google-Smtp-Source: ANB0VdZ7G/cYibGDAnPnqRAqlUX4/MPsaPmWCKEXeP9dINu5rp8VOAxGMniFGEpsZ8K6mNGF3vuOtA== X-Received: by 2002:a17:902:b905:: with SMTP id bf5-v6mr9356308plb.185.1537562574626; Fri, 21 Sep 2018 13:42:54 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id h85-v6sm43682646pfk.71.2018.09.21.13.42.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 13:42:53 -0700 (PDT) From: Brian Norris To: Kalle Valo Subject: [PATCH] ath10k: add missing sanity check on diag download Date: Fri, 21 Sep 2018 13:42:41 -0700 Message-Id: <20180921204241.34316-1-briannorris@chromium.org> X-Mailer: git-send-email 2.19.0.444.g18242da7ef-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180921_134305_134909_2C9B0911 X-CRM114-Status: UNSURE ( 8.04 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris , Carl Huang , linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ath10k_hw_diag_fast_download() generally has good boundary checking, but it misses verifying that the next metadata header actually fits in the remaining buffer space. Add such a check. Fixes: 39501ea64116 ("ath10k: download firmware via diag Copy Engine for QCA6174 and QCA9377.") Signed-off-by: Brian Norris --- drivers/net/wireless/ath/ath10k/hw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/hw.c b/drivers/net/wireless/ath/ath10k/hw.c index 2c2870e3e84d..af8ae8117c62 100644 --- a/drivers/net/wireless/ath/ath10k/hw.c +++ b/drivers/net/wireless/ath/ath10k/hw.c @@ -1044,6 +1044,12 @@ int ath10k_hw_diag_fast_download(struct ath10k *ar, left = length - sizeof(*hdr); while (left > 0) { + if (left < sizeof(*metadata)) { + ath10k_warn(ar, "firmware segment is truncated: %d\n", + left); + ret = -EINVAL; + break; + } base_addr = __le32_to_cpu(metadata->addr); base_len = __le32_to_cpu(metadata->length); buf = metadata->data;