mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amelie Delaunay <amelie.delaunay@foss.st.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Vinod Koul" <vkoul@kernel.org>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>
Cc: <dmaengine@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: stm32: Don't use %pK through printk
Date: Mon, 14 Apr 2025 13:17:18 +0200	[thread overview]
Message-ID: <f7dcc10e-b2c6-4252-9c71-6715cebe49fd@foss.st.com> (raw)
In-Reply-To: <20250407-restricted-pointers-dma-v1-1-b617dd0e293a@linutronix.de>



On 4/7/25 10:26, Thomas Weißschuh wrote:
> In the past %pK was preferable to %p as it would not leak raw pointer
> values into the kernel log.
> Since commit ad67b74d2469 ("printk: hash addresses printed with %p")
> the regular %p has been improved to avoid this issue.
> Furthermore, restricted pointers ("%pK") were never meant to be used
> through printk(). They can still unintentionally leak raw pointers or
> acquire sleeping looks in atomic contexts.

I forgot to highlight this typo:

s/looks/locks

> 
> Switch to the regular pointer formatting which is safer and
> easier to reason about.
> There are still a few users of %pK left, but these use it through seq_file,
> for which its usage is safe.
> 
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
>   drivers/dma/stm32/stm32-dma.c  | 10 +++++-----
>   drivers/dma/stm32/stm32-dma3.c | 10 +++++-----
>   drivers/dma/stm32/stm32-mdma.c |  8 ++++----
>   3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index 917f8e9223739af853e492d97cecac0e95e0aea3..ee9246c6888ffde2d416270f25890c04c72daff7 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -613,7 +613,7 @@ static void stm32_dma_start_transfer(struct stm32_dma_chan *chan)
>   	reg->dma_scr |= STM32_DMA_SCR_EN;
>   	stm32_dma_write(dmadev, STM32_DMA_SCR(chan->id), reg->dma_scr);
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: started\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
> @@ -676,7 +676,7 @@ static void stm32_dma_handle_chan_paused(struct stm32_dma_chan *chan)
>   
>   	chan->status = DMA_PAUSED;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: paused\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: paused\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_post_resume_reconfigure(struct stm32_dma_chan *chan)
> @@ -728,7 +728,7 @@ static void stm32_dma_post_resume_reconfigure(struct stm32_dma_chan *chan)
>   	dma_scr |= STM32_DMA_SCR_EN;
>   	stm32_dma_write(dmadev, STM32_DMA_SCR(chan->id), dma_scr);
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: reconfigured after pause/resume\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: reconfigured after pause/resume\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan, u32 scr)
> @@ -820,7 +820,7 @@ static void stm32_dma_issue_pending(struct dma_chan *c)
>   
>   	spin_lock_irqsave(&chan->vchan.lock, flags);
>   	if (vchan_issue_pending(&chan->vchan) && !chan->desc && !chan->busy) {
> -		dev_dbg(chan2dev(chan), "vchan %pK: issued\n", &chan->vchan);
> +		dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
>   		stm32_dma_start_transfer(chan);
>   
>   	}
> @@ -922,7 +922,7 @@ static int stm32_dma_resume(struct dma_chan *c)
>   
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: resumed\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: resumed\n", &chan->vchan);
>   
>   	return 0;
>   }
> diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
> index 0c6c4258b19561c94f1c68f26ade16b82660ebe6..50e7106c5cb73394c1de52ad5f571f6db63750e6 100644
> --- a/drivers/dma/stm32/stm32-dma3.c
> +++ b/drivers/dma/stm32/stm32-dma3.c
> @@ -801,7 +801,7 @@ static void stm32_dma3_chan_start(struct stm32_dma3_chan *chan)
>   
>   	chan->dma_status = DMA_IN_PROGRESS;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: started\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static int stm32_dma3_chan_suspend(struct stm32_dma3_chan *chan, bool susp)
> @@ -1452,7 +1452,7 @@ static int stm32_dma3_pause(struct dma_chan *c)
>   
>   	chan->dma_status = DMA_PAUSED;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: paused\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: paused\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1465,7 +1465,7 @@ static int stm32_dma3_resume(struct dma_chan *c)
>   
>   	chan->dma_status = DMA_IN_PROGRESS;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: resumed\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: resumed\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1490,7 +1490,7 @@ static int stm32_dma3_terminate_all(struct dma_chan *c)
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   	vchan_dma_desc_free_list(&chan->vchan, &head);
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: terminated\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: terminated\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1543,7 +1543,7 @@ static void stm32_dma3_issue_pending(struct dma_chan *c)
>   	spin_lock_irqsave(&chan->vchan.lock, flags);
>   
>   	if (vchan_issue_pending(&chan->vchan) && !chan->swdesc) {
> -		dev_dbg(chan2dev(chan), "vchan %pK: issued\n", &chan->vchan);
> +		dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
>   		stm32_dma3_chan_start(chan);
>   	}
>   
> diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
> index e6d525901de7ecf822d218b87b95aba6bbf0a3ef..080c1c725216cb627675c372591b4c0c227c3cea 100644
> --- a/drivers/dma/stm32/stm32-mdma.c
> +++ b/drivers/dma/stm32/stm32-mdma.c
> @@ -1187,7 +1187,7 @@ static void stm32_mdma_start_transfer(struct stm32_mdma_chan *chan)
>   
>   	chan->busy = true;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: started\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static void stm32_mdma_issue_pending(struct dma_chan *c)
> @@ -1200,7 +1200,7 @@ static void stm32_mdma_issue_pending(struct dma_chan *c)
>   	if (!vchan_issue_pending(&chan->vchan))
>   		goto end;
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: issued\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
>   
>   	if (!chan->desc && !chan->busy)
>   		stm32_mdma_start_transfer(chan);
> @@ -1220,7 +1220,7 @@ static int stm32_mdma_pause(struct dma_chan *c)
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
>   	if (!ret)
> -		dev_dbg(chan2dev(chan), "vchan %pK: pause\n", &chan->vchan);
> +		dev_dbg(chan2dev(chan), "vchan %p: pause\n", &chan->vchan);
>   
>   	return ret;
>   }
> @@ -1261,7 +1261,7 @@ static int stm32_mdma_resume(struct dma_chan *c)
>   
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
> -	dev_dbg(chan2dev(chan), "vchan %pK: resume\n", &chan->vchan);
> +	dev_dbg(chan2dev(chan), "vchan %p: resume\n", &chan->vchan);
>   
>   	return 0;
>   }
> 
> ---
> base-commit: e48e99b6edf41c69c5528aa7ffb2daf3c59ee105
> change-id: 20250404-restricted-pointers-dma-29cf839a1a0b
> 
> Best regards,

      parent reply	other threads:[~2025-04-14 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07  8:26 Thomas Weißschuh
2025-04-14  8:40 ` Amelie Delaunay
2025-04-14 11:17 ` Amelie Delaunay [this message]

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=f7dcc10e-b2c6-4252-9c71-6715cebe49fd@foss.st.com \
    --to=amelie.delaunay@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=vkoul@kernel.org \
    /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®