From patchwork Wed Feb 15 22:00:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 94040 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2359999qgi; Wed, 15 Feb 2017 21:59:06 -0800 (PST) X-Received: by 10.98.66.138 with SMTP id h10mr666844pfd.94.1487224746897; Wed, 15 Feb 2017 21:59:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si4601490pfu.222.2017.02.15.21.59.06; Wed, 15 Feb 2017 21:59:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751109AbdBPF7F (ORCPT + 9 others); Thu, 16 Feb 2017 00:59:05 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33923 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751529AbdBPF7E (ORCPT ); Thu, 16 Feb 2017 00:59:04 -0500 Received: by mail-pf0-f171.google.com with SMTP id e4so3001976pfg.1 for ; Wed, 15 Feb 2017 21:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Ul2/GSJOKNfFAfkNtUEq3L695xNS1iURQD0pWXQhh10=; b=kUdkg/T9lYfc1s1bcgSXN4jXcr6/9Z1R2JZU9x772Td0Xw1GBulPN+S+AAnLyT55zw f7GzBHpB5efENM882/Zch4yO/HZy+VuHLPeVOx+25I+9bR/x35gu6810XA2KcNu0ffAG J7GdXNUoSQeAh+7zR+x4NE6MSlf2+Rn/kp3WA= 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; bh=Ul2/GSJOKNfFAfkNtUEq3L695xNS1iURQD0pWXQhh10=; b=QTkFfggYU+2XxDc1szoTJM8XKhOxUELM7VBgUdkh3H8Vh7H/fhzl49I9z2rg7v0UX0 twZ/Gz71K0wbVvjKG9KH3NGfTRmJeav9EX4brQtoQNdunwouMmUBzq7jEDIYlnjd0oa2 aaEWdnFuGS5Pvxf4BvdbLeGaTw6LKGxXbU9jL+7V/+YAL2wj815WwI/bOHYOFD7RQXRf IYsMNSR3iW00beBfWnlxpa6ilXmU8FmzDYo8IOB5150Z6NB1TIXYcO4QVMOjweS2XTnC zY7K81d6bjKea9KBRhrLV4POgalgSoJA6lslAOuB1hdTCEM747vgyt/uxVwqyiSSiZry Uwxw== X-Gm-Message-State: AMke39mbdm0B4WLGaWndpbhhcUqeklUor8Ba3a7Mk4M/6ruC5+pka1xW72uc8LpO5TyQ6TDX X-Received: by 10.98.147.207 with SMTP id r76mr637951pfk.111.1487224743514; Wed, 15 Feb 2017 21:59:03 -0800 (PST) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id x81sm10752736pff.69.2017.02.15.21.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Feb 2017 21:59:02 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Andy Gross , David Brown Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Dan Carpenter , Stanimir Varbanov Subject: [PATCH] remoteproc: qcom: mdt_loader: Use signed type for offset Date: Wed, 15 Feb 2017 14:00:41 -0800 Message-Id: <20170215220041.3077-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the transition from using rproc_da_to_va(), the type of the load offset became unsigned. This causes the subsequent check to let negative values less than p_memsz + mem_size through and we write outside of the buffer. Change the type back to a signed value to catch this. Fixes: 7f0dd07a9b29 ("remoteproc: qcom: mdt_loader: Refactor MDT loader") Fixes: e7fd25226295 ("remoteproc: qcom: q6v5: Decouple driver from MDT loader") Reported-by: Dan Carpenter Reported-by: Stanimir Varbanov Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_q6v5_pil.c | 2 +- drivers/soc/qcom/mdt_loader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 26446eb08bd8..8fd697a3cf8f 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -502,7 +502,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc) phys_addr_t max_addr = 0; bool relocate = false; char seg_name[10]; - size_t offset; + ssize_t offset; size_t size; void *ptr; int ret; diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 98b2373c3a97..bd63df0d14e0 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -98,7 +98,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; phys_addr_t max_addr = 0; size_t fw_name_len; - size_t offset; + ssize_t offset; char *fw_name; bool relocate = false; void *ptr;