Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp712234ybv; Wed, 5 Feb 2020 13:08:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz658pqvkrXmf5uLVMmSggoSOxVvhBlrd+wkkkvz7y6p7qaAr77dIsd86z90MLcfpN3RULc X-Received: by 2002:a9d:6c9a:: with SMTP id c26mr26505330otr.279.1580936899449; Wed, 05 Feb 2020 13:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580936899; cv=none; d=google.com; s=arc-20160816; b=W+6MWYcPGPBaQrnltGVsVgJZ0RHj3CCD829PbF2wBUZ7M8v6mPNZ0su1H9pW9QiY/E bsPN6WDlE5U4B2SzAOIxbfe423qXskd/hWJ52kloQ9nJk3CJLpRNhk1fpvO+k7JQ0k9N KPlN4pHh3P9BWWikw9j3uhWZrq1+sfZkiA64a9mpxh8CZeYtCnF3HuolasZHmdq0mUEG Ws0IGsKPfFh644N31mOZbQrKrmYWE58pRez9Kdt432vgIUmadjaKOmjclW/vGOlTsEb4 24obnTMQoyFpl33mIe9pMWwaJz1iqgoinkKC7yClbKYq8DAaKpDZ2YGrrbluNyZwkVEN 4ifA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=51aeHheY/rt4DM+DW672ePDwXYA8QyYv8DwatD1TXuQ=; b=z8ywVyjuqpOmtQgVv0ma3bSE5gzpwxHCxx6YrDlIrm36AoM4x+QWs6JM1ZMuAETQVk cd73LKn5mqVG+wRD7GLvGOk6mRLgAIJ4VgkiMie7YlG9f89V+lu6VySIxJYd/YQnTf1N uoRRMaDYOXfECoj98XRWh8Xy5VZYe0hjKeGUEcEjT6GpvHrNUnOt01DTQ8SVGuVIRksj +WnWHNQX3nm323YDJXTRHS7BNm2Aap9fQZ5sBQG7HCBihjUIsKq8/B1cxuR+FOZCkbr4 wLsQD0Qa0WxP9fmCIzPcRTNia1YPQ9ST2biewTTR7gydenZUbH+UgLWTju6RaNG5uzWb nIvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYYUZew3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si462231oti.136.2020.02.05.13.08.06; Wed, 05 Feb 2020 13:08:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYYUZew3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbgBEVHA (ORCPT + 99 others); Wed, 5 Feb 2020 16:07:00 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46802 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbgBEVHA (ORCPT ); Wed, 5 Feb 2020 16:07:00 -0500 Received: by mail-pl1-f193.google.com with SMTP id y8so1367546pll.13 for ; Wed, 05 Feb 2020 13:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=51aeHheY/rt4DM+DW672ePDwXYA8QyYv8DwatD1TXuQ=; b=LYYUZew3BwAE1xoByIz6JPLp2v+5cIbt1vVEbEqSwZU+daxgKZMqXXZNwDO/EaTk89 mefzudnZvyMQwVKqJBHBxwO1RvNhAupM3vfp2JZ3DQ9IdQeNS5iXI/3PVzYsCui3DGPj 7P3Q/vJL71vxTJcoskqAqh1emNeO13XS5W1DGsoywcadkfDagL33w7P5O8vZJh7wky6q WmtHRCfKjsTkS9Sykv4FGUNUyJGu8Z8qxovwgVpr21LdlZRplwPHK7f0FFKzx2hqDm+V tcRkyuNlVmcsvTiGRvHRtK34hPDDBz/R9Y+v2L0jqeFQky+scE8b0KIuMnI+V4AGNj/u ZS6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=51aeHheY/rt4DM+DW672ePDwXYA8QyYv8DwatD1TXuQ=; b=XiPxYB9UPzaRQ1BxN6ERtnT1BR0Wn4hWAvQYPfyMM47kkAgj0mlpgSgfcdxWgYKsiF PU3I2eqZWpCw6xAq0Q3SGkI+dYYy2V27FFtjDrRc4tpstLWYnVvIH020Ehh5Ah7YCcsk h5UKybojlhh3kOj7BNfLRD7rrnySCkBHMqj/ELcwh0h+Re9qOWkMb9TaW3aMHieQyQ2y v47pLkljKBzaybctUzWG1uk4THvdi3AAC3WoEswPqfmVUlKd9jCB+qK1XwaJCEkZ776g vRU0DqiODpNAoluXWOIE4mHTTkSiEEXAPKr4n9n8Awd867Zj0APetKzlXGekPHJ1JEyK kFrA== X-Gm-Message-State: APjAAAVFZmTsCNeecljzZUC4h1kXDtIB4PcXZPRiLyOW4ZKHc4DURy+w Bs7EHqnzci5JDzGUyqqJkK8NEw== X-Received: by 2002:a17:90a:8685:: with SMTP id p5mr103015pjn.92.1580936819090; Wed, 05 Feb 2020 13:06:59 -0800 (PST) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 199sm420457pfv.81.2020.02.05.13.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 13:06:58 -0800 (PST) Date: Wed, 5 Feb 2020 14:06:55 -0700 From: Mathieu Poirier To: Clement Leger Cc: Ohad Ben-Cohen , Bjorn Andersson , Jonathan Corbet , Shawn Guo , Sascha Hauer , linux-remoteproc@vger.kernel.org, Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Andy Gross , Patrice Chotard , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Arnaud Pouliquen , Loic PALLARDY , s-anna Subject: Re: [PATCH v3 1/2] remoteproc: Use u64 len for da_to_va Message-ID: <20200205210655.GA25901@xps15> References: <20200129163013.GA16538@xps15> <20200204174412.16814-1-cleger@kalray.eu> <20200204174412.16814-2-cleger@kalray.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200204174412.16814-2-cleger@kalray.eu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Clement, On Tue, Feb 04, 2020 at 06:44:11PM +0100, Clement Leger wrote: > With upcoming changes in elf loader for elf64 support, section size will > be a u64. When used with da_to_va, this will potentially lead to > overflow if using the current "int" type for len argument. Change > da_to_va prototype to use a u64 for len and fix all users of this > function. > > Signed-off-by: Clement Leger > --- > drivers/remoteproc/imx_rproc.c | 9 +++++---- > drivers/remoteproc/keystone_remoteproc.c | 2 +- > drivers/remoteproc/qcom_q6v5_adsp.c | 2 +- > drivers/remoteproc/qcom_q6v5_mss.c | 2 +- > drivers/remoteproc/qcom_q6v5_pas.c | 2 +- > drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- > drivers/remoteproc/qcom_wcnss.c | 2 +- > drivers/remoteproc/remoteproc_core.c | 2 +- > drivers/remoteproc/remoteproc_internal.h | 2 +- > drivers/remoteproc/st_slim_rproc.c | 4 ++-- > drivers/remoteproc/wkup_m3_rproc.c | 2 +- > include/linux/remoteproc.h | 2 +- > 12 files changed, 17 insertions(+), 16 deletions(-) > > diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c > index 3e72b6f38d4b..1e895d5cf918 100644 > --- a/drivers/remoteproc/imx_rproc.c > +++ b/drivers/remoteproc/imx_rproc.c > @@ -186,7 +186,7 @@ static int imx_rproc_stop(struct rproc *rproc) > } > > static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, > - int len, u64 *sys) > + u64 len, u64 *sys) > { > const struct imx_rproc_dcfg *dcfg = priv->dcfg; > int i; > @@ -203,12 +203,12 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, > } > } > > - dev_warn(priv->dev, "Translation failed: da = 0x%llx len = 0x%x\n", > + dev_warn(priv->dev, "Translation failed: da = 0x%llx len = 0x%llx\n", > da, len); > return -ENOENT; > } > > -static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct imx_rproc *priv = rproc->priv; > void *va = NULL; The condition "if (len <= 0)" at the beginning of the function needs to be fixed. > @@ -235,7 +235,8 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > } > } > > - dev_dbg(&rproc->dev, "da = 0x%llx len = 0x%x va = 0x%p\n", da, len, va); > + dev_dbg(&rproc->dev, "da = 0x%llx len = 0x%llx va = 0x%p\n", > + da, len, va); > > return va; > } > diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c > index 5c4658f00b3d..25c01df47eba 100644 > --- a/drivers/remoteproc/keystone_remoteproc.c > +++ b/drivers/remoteproc/keystone_remoteproc.c > @@ -246,7 +246,7 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid) > * can be used either by the remoteproc core for loading (when using kernel > * remoteproc loader), or by any rpmsg bus drivers. > */ > -static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, u64 len) > { Same comment as above. > struct keystone_rproc *ksproc = rproc->priv; > void __iomem *va = NULL; > diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c > index e953886b2eb7..7518e67a49e5 100644 > --- a/drivers/remoteproc/qcom_q6v5_adsp.c > +++ b/drivers/remoteproc/qcom_q6v5_adsp.c > @@ -270,7 +270,7 @@ static int adsp_stop(struct rproc *rproc) > return ret; > } > > -static void *adsp_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *adsp_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; > int offset; > diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c > index 471128a2e723..248febde6fc1 100644 > --- a/drivers/remoteproc/qcom_q6v5_mss.c > +++ b/drivers/remoteproc/qcom_q6v5_mss.c > @@ -1148,7 +1148,7 @@ static int q6v5_stop(struct rproc *rproc) > return 0; > } > > -static void *q6v5_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *q6v5_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct q6v5 *qproc = rproc->priv; > int offset; > diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c > index db4b3c4bacd7..cf2cd609c90d 100644 > --- a/drivers/remoteproc/qcom_q6v5_pas.c > +++ b/drivers/remoteproc/qcom_q6v5_pas.c > @@ -159,7 +159,7 @@ static int adsp_stop(struct rproc *rproc) > return ret; > } > > -static void *adsp_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *adsp_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; > int offset; > diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c > index f93e1e4a1cc0..3a6b82a16961 100644 > --- a/drivers/remoteproc/qcom_q6v5_wcss.c > +++ b/drivers/remoteproc/qcom_q6v5_wcss.c > @@ -406,7 +406,7 @@ static int q6v5_wcss_stop(struct rproc *rproc) > return 0; > } > > -static void *q6v5_wcss_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *q6v5_wcss_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct q6v5_wcss *wcss = rproc->priv; > int offset; > diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c > index dc135754bb9c..f893219e45a8 100644 > --- a/drivers/remoteproc/qcom_wcnss.c > +++ b/drivers/remoteproc/qcom_wcnss.c > @@ -287,7 +287,7 @@ static int wcnss_stop(struct rproc *rproc) > return ret; > } > > -static void *wcnss_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *wcnss_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; > int offset; > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 307df98347ba..9e6d3c6a60ee 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -185,7 +185,7 @@ EXPORT_SYMBOL(rproc_va_to_pa); > * here the output of the DMA API for the carveouts, which should be more > * correct. > */ > -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) > +void *rproc_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct rproc_mem_entry *carveout; > void *ptr = NULL; > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > index 493ef9262411..004867061721 100644 > --- a/drivers/remoteproc/remoteproc_internal.h > +++ b/drivers/remoteproc/remoteproc_internal.h > @@ -50,7 +50,7 @@ void rproc_exit_sysfs(void); > void rproc_free_vring(struct rproc_vring *rvring); > int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); > > -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); > +void *rproc_da_to_va(struct rproc *rproc, u64 da, u64 len); > phys_addr_t rproc_va_to_pa(void *cpu_addr); > int rproc_trigger_recovery(struct rproc *rproc); > > diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c > index 04492fead3c8..fc01cd879b60 100644 > --- a/drivers/remoteproc/st_slim_rproc.c > +++ b/drivers/remoteproc/st_slim_rproc.c > @@ -174,7 +174,7 @@ static int slim_rproc_stop(struct rproc *rproc) > return 0; > } > > -static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, u64 len) > { > struct st_slim_rproc *slim_rproc = rproc->priv; > void *va = NULL; > @@ -191,7 +191,7 @@ static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > } > } > > - dev_dbg(&rproc->dev, "da = 0x%llx len = 0x%x va = 0x%pK\n", > + dev_dbg(&rproc->dev, "da = 0x%llx len = 0x%llx va = 0x%pK\n", > da, len, va); > > return va; > diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c > index 3984e585c847..0e8082948489 100644 > --- a/drivers/remoteproc/wkup_m3_rproc.c > +++ b/drivers/remoteproc/wkup_m3_rproc.c > @@ -80,7 +80,7 @@ static int wkup_m3_rproc_stop(struct rproc *rproc) > return 0; > } > > -static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, int len) > +static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, u64 len) > { Same comment as above. > struct wkup_m3_rproc *wkupm3 = rproc->priv; > void *va = NULL; > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 16ad66683ad0..f84bd5fe0211 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -374,7 +374,7 @@ struct rproc_ops { > int (*start)(struct rproc *rproc); > int (*stop)(struct rproc *rproc); > void (*kick)(struct rproc *rproc, int vqid); > - void * (*da_to_va)(struct rproc *rproc, u64 da, int len); > + void * (*da_to_va)(struct rproc *rproc, u64 da, u64 len); > int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); > int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc, > int offset, int avail); > -- > 2.15.0.276.g89ea799 >