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: 9576519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 924E660244 for ; Thu, 16 Feb 2017 05:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A4C1285AA for ; Thu, 16 Feb 2017 05:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ADD8285AD; Thu, 16 Feb 2017 05:59:06 +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=-5.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B95C0285AA for ; Thu, 16 Feb 2017 05:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753101AbdBPF7F (ORCPT ); Thu, 16 Feb 2017 00:59:05 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35428 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751109AbdBPF7E (ORCPT ); Thu, 16 Feb 2017 00:59:04 -0500 Received: by mail-pf0-f180.google.com with SMTP id 202so3004939pfx.2 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=UuVTYdZXadnZPlVH2koD/x2o9OD+ncl3WtuZUXjjUlYOZGG6pwG1VwpUICVBdlvxEg I1lKuBbH065s0jxSMslO8nRTmMq22/fPEGiZBSc1Ij48bJ+HHuV6889VYu1kCRcDy62H INcq4+jexInnRqNNWQdJFBkkbeXqGs44fKFFtyd+SiRMIrynZmWJcaFEiHjkDZEQIlYs bJF00iQGIs9f9xkByTm6YNN8rX1EUhO7iPpf+xZ9bR0KTMyE9w4w/COyLRWrLPJj7UbK 2/7dyAt8uX/wiRLaGUCP3zvwovM5iipuswQbhMJYhXSN5avSBrJvGWloDaJypZ5pOqcZ qJ8A== X-Gm-Message-State: AMke39kylWxi/JorvVlyQxxSHOC9AbeJfzzZSW423W6lJbVpiC1KmlYyVbbUmrQYPERSYJAX 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-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Andy Gross --- drivers/remoteproc/qcom_q6v5_pil.c | 2 +- drivers/soc/qcom/mdt_loader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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;