mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Arnd Bergmann <arnd@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Yajun Deng <yajun.deng@linux.dev>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: avoid non-constant format string
Date: Fri, 19 Jul 2024 08:49:46 -0700	[thread overview]
Message-ID: <8ad5a485-6803-495a-98ee-9f7ad3e85946@intel.com> (raw)
In-Reply-To: <20240719102319.546622-1-arnd@kernel.org>



On 7/19/24 3:23 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Using an arbitrary string as a printf-style format can be a security
> problem if that string contains % characters, as the optionalal
> -Wformat-security flag points out:
> 
> drivers/dma/dmaengine.c: In function '__dma_async_device_channel_register':
> drivers/dma/dmaengine.c:1073:17: error: format not a string literal and no format arguments [-Werror=format-security]
>  1073 |                 dev_set_name(&chan->dev->device, name);
>       |                 ^~~~~~~~~~~~
> 
> Change this newly added instance to use "%s" as the format instead to
> pass the actual name.
> 
> Fixes: 10b8e0fd3f72 ("dmaengine: add channel device name to channel registration")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  drivers/dma/dmaengine.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index c380a4dda77a..c1357d7f3dc6 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -1070,7 +1070,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	if (!name)
>  		dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
>  	else
> -		dev_set_name(&chan->dev->device, name);
> +		dev_set_name(&chan->dev->device, "%s", name);
>  	rc = device_register(&chan->dev->device);
>  	if (rc)
>  		goto err_out_ida;

  reply	other threads:[~2024-07-19 15:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 10:23 Arnd Bergmann
2024-07-19 15:49 ` Dave Jiang [this message]
2024-08-29 17:30 ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ad5a485-6803-495a-98ee-9f7ad3e85946@intel.com \
    --to=dave.jiang@intel.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=yajun.deng@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®