Skip to contentSkip to conversation

rpmsg: virtio_rpmsg_bus: replace "%p" with "%pK"

PATCH In review Suman Anna 3 participants 13 messages Oct 24, 2018 – Aug 27, 2019 Remote processor messaging (rpmsg)

lore
Share & tools
lore

Suman Anna

author
#0 lore raw

PATCH 1/1 rpmsg: virtio_rpmsg_bus: replace "%p" with "%pK"

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
Signature · 1 line
2.19.1
author
#1 lore raw

Hi Bjorn,

Quoted 5 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#2 lore raw
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 10 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
author
#3 lore raw

Hi Bjorn,

Quoted 14 lines · Bjorn Andersson
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 7 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Quoted 7 lines
Quoted 3 lines

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?.

I mainly use it during debug when comparing against kernel_page_tables and vmallocinfo. The pools that we use are not always guaranteed to be from linear memory, and behavior changes when using with CMA or DMA pools.

Note that usage of %pK does not leak the addresses automatically, but atleast enables me to get the values when needed. The changes also bring the usage in rpmsg core in sync with the remoteproc core.

regards
Suman

Quoted 28 lines

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#4 lore raw
Quoted 21 lines · Suman Anna

Hi Bjorn,

Quoted 18 lines · Bjorn Andersson
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 10 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

Quoted 8 lines
Quoted 3 lines

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?.

I mainly use it during debug when comparing against kernel_page_tables and vmallocinfo. The pools that we use are not always guaranteed to be from linear memory, and behavior changes when using with CMA or DMA pools.

Thanks Suman. It seems to me that there's room for improvement to aid this kind of debugging. But your usecase seems reasonable, so I'm merging the patch.

Quoted 4 lines

Note that usage of %pK does not leak the addresses automatically, but atleast enables me to get the values when needed. The changes also bring the usage in rpmsg core in sync with the remoteproc core.

Sounds like shouldn't have merged them in remoteproc then ;P

Thanks,
Bjorn

Quoted 32 lines

regards
Suman

Quoted 28 lines

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
author
#5 lore raw
Quoted 27 lines · Bjorn Andersson
Quoted 25 lines · Suman Anna

Hi Bjorn,

Quoted 21 lines · Bjorn Andersson
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 10 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?.

Quoted 8 lines
Quoted 4 lines

I mainly use it during debug when comparing against kernel_page_tables and vmallocinfo. The pools that we use are not always guaranteed to be from linear memory, and behavior changes when using with CMA or DMA pools.

Thanks Suman. It seems to me that there's room for improvement to aid this kind of debugging. But your usecase seems reasonable, so I'm merging the patch.

Thanks Bjorn.

Quoted 7 lines
Quoted 5 lines

Note that usage of %pK does not leak the addresses automatically, but atleast enables me to get the values when needed. The changes also bring the usage in rpmsg core in sync with the remoteproc core.

Sounds like shouldn't have merged them in remoteproc then ;P

Slightly different reasoning looking at the commit, it was probably when %p was leaking the addresses.

regards
Suman

Quoted 36 lines

Thanks,
Bjorn

Quoted 32 lines

regards
Suman

Quoted 28 lines

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
author
#6 lore raw
Quoted 33 lines · Suman Anna
Quoted 32 lines · Bjorn Andersson
Quoted 29 lines · Suman Anna

Hi Bjorn,

Quoted 14 lines · Bjorn Andersson
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 7 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Quoted 7 lines
Quoted 3 lines

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?.

I mainly use it during debug when comparing against kernel_page_tables and vmallocinfo. The pools that we use are not always guaranteed to be from linear memory, and behavior changes when using with CMA or DMA pools.

Quoted 5 lines
Quoted 3 lines

Thanks Suman. It seems to me that there's room for improvement to aid this kind of debugging. But your usecase seems reasonable, so I'm merging the patch.

Thanks Bjorn.

Btw, looks like you applied the patch against rproc-next instead of rpmsg-next.

regards
Suman

Quoted 52 lines
Quoted 8 lines
Quoted 6 lines

Note that usage of %pK does not leak the addresses automatically, but atleast enables me to get the values when needed. The changes also bring the usage in rpmsg core in sync with the remoteproc core.

Sounds like shouldn't have merged them in remoteproc then ;P

Slightly different reasoning looking at the commit, it was probably when %p was leaking the addresses.

regards
Suman

Quoted 36 lines

Thanks,
Bjorn

Quoted 32 lines

regards
Suman

Quoted 28 lines

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#7 lore raw
Quoted 34 lines · Suman Anna
Quoted 33 lines · Suman Anna
Quoted 32 lines · Bjorn Andersson
Quoted 29 lines · Suman Anna

Hi Bjorn,

Quoted 14 lines · Bjorn Andersson
Quoted 2 lines · Suman Anna

Hi Bjorn,

Hi Suman

Quoted 7 lines · Suman Anna
Quoted 5 lines

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

Quoted 7 lines
Quoted 3 lines

Seems to have been lost among the patches, can you pick up this trivial patch for 5.4? Should apply cleanly on the latest HEAD as well.

I share Andrew's question regarding what benefit you have from knowing this value. Should we not just remove the va from the print? Or do you actually have a use case for it?.

I mainly use it during debug when comparing against kernel_page_tables and vmallocinfo. The pools that we use are not always guaranteed to be from linear memory, and behavior changes when using with CMA or DMA pools.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Thanks Suman. It seems to me that there's room for improvement to aid this kind of debugging. But your usecase seems reasonable, so I'm merging the patch.

Thanks Bjorn.

Btw, looks like you applied the patch against rproc-next instead of rpmsg-next.

Thanks for noticing so quick; I moved the change to the correct branch.

Regards,
Bjorn

Quoted 56 lines

regards
Suman

Quoted 52 lines
Quoted 8 lines
Quoted 6 lines

Note that usage of %pK does not leak the addresses automatically, but atleast enables me to get the values when needed. The changes also bring the usage in rpmsg core in sync with the remoteproc core.

Sounds like shouldn't have merged them in remoteproc then ;P

Slightly different reasoning looking at the commit, it was probably when %p was leaking the addresses.

regards
Suman

Quoted 36 lines

Thanks,
Bjorn

Quoted 32 lines

regards
Suman

Quoted 28 lines

Regards,
Bjorn

Quoted 24 lines

regards
Suman

Quoted 20 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#8 lore raw
In reply to Suman Anna
Quoted 6 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

s/previliged/privileged

You describe what the code does, but not why you need this. %pK is used for only about 1% of pointer printing, why do you want to leak this address to userspace at all?

Andrew

Quoted 19 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
author
#9 lore raw
Quoted 10 lines · Andrew F. Davis
Quoted 6 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

s/previliged/privileged

Bjorn,
Can you fix this up when applying.

Quoted 4 lines

You describe what the code does, but not why you need this. %pK is used for only about 1% of pointer printing, why do you want to leak this address to userspace at all?

Andrew,
Default behavior of %pK is same as %p, but it does allow you to control the print. The reason is clearly mentioned in the last sentence in the patch description.

regards
Suman

Quoted 23 lines

Andrew

Quoted 19 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#10 lore raw
Quoted 16 lines · Suman Anna
Quoted 10 lines · Andrew F. Davis
Quoted 6 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

s/previliged/privileged

Bjorn,
Can you fix this up when applying.

Quoted 1 line
Quoted 9 lines
Quoted 3 lines

You describe what the code does, but not why you need this. %pK is used for only about 1% of pointer printing, why do you want to leak this address to userspace at all?

Andrew,
Default behavior of %pK is same as %p, but it does allow you to control the print. The reason is clearly mentioned in the last sentence in the patch description.

Let me rephrase then, why would you ever set 'kptr_restrict' to anything other than 0, or why do you want to be able to leak this address to userspace at all? If the answer is just because you can, then all 12,000 instances of %p in kernel could be converted for the same reason.

Andrew

Quoted 27 lines

regards
Suman

Quoted 23 lines

Andrew

Quoted 19 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
author
#11 lore raw
Quoted 28 lines · Andrew F. Davis
Quoted 16 lines · Suman Anna
Quoted 10 lines · Andrew F. Davis
Quoted 6 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

s/previliged/privileged

Bjorn,
Can you fix this up when applying.

Quoted 1 line
Quoted 9 lines
Quoted 3 lines

You describe what the code does, but not why you need this. %pK is used for only about 1% of pointer printing, why do you want to leak this address to userspace at all?

Andrew,
Default behavior of %pK is same as %p, but it does allow you to control the print. The reason is clearly mentioned in the last sentence in the patch description.

Quoted 4 lines

Let me rephrase then, why would you ever set 'kptr_restrict' to anything other than 0, or why do you want to be able to leak this address to userspace at all? If the answer is just because you can, then all 12,000 instances of %p in kernel could be converted for the same reason.

It is a dev_dbg statement, so it is already under dynamic debug control. We would only ever use it during debug.

regards
Suman

Quoted 31 lines

Andrew

Quoted 27 lines

regards
Suman

Quoted 23 lines

Andrew

Quoted 19 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */
#12 lore raw
Quoted 29 lines · Suman Anna
Quoted 28 lines · Andrew F. Davis
Quoted 25 lines · Suman Anna
Quoted 10 lines · Andrew F. Davis
Quoted 6 lines · Suman Anna

The virtio_rpmsg_bus driver uses the "%p" format-specifier for printing the vring buffer address. This prints only a hashed pointer even for previliged users. Use "%pK" instead so that the address can be printed during debug using kptr_restrict sysctl.

s/previliged/privileged

Bjorn,
Can you fix this up when applying.

Quoted 4 lines

You describe what the code does, but not why you need this. %pK is used for only about 1% of pointer printing, why do you want to leak this address to userspace at all?

Andrew,
Default behavior of %pK is same as %p, but it does allow you to control the print. The reason is clearly mentioned in the last sentence in the patch description.

Quoted 8 lines
Quoted 4 lines

Let me rephrase then, why would you ever set 'kptr_restrict' to anything other than 0, or why do you want to be able to leak this address to userspace at all? If the answer is just because you can, then all 12,000 instances of %p in kernel could be converted for the same reason.

It is a dev_dbg statement, so it is already under dynamic debug control. We would only ever use it during debug.

Most pointer printings are in debug statements..

I'm simply not seeing what this helps us do. The DMA address I can understand, it may be given to a remote core so we may want to verify it is the same on both sides, but the actual virtual kernel address is of no value to us, a hash to track it across uses is just as good.

Andrew

Quoted 35 lines

regards
Suman

Quoted 31 lines

Andrew

Quoted 27 lines

regards
Suman

Quoted 23 lines

Andrew

Quoted 19 lines
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -1
index f29dee731026..1345f373a1a0 100644
@@ -950,7 +950,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
 		goto vqs_del;
 	}
 
-	dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n",
+	dev_dbg(&vdev->dev, "buffers: va %pK, dma %pad\n",
 		bufs_va, &vrp->bufs_dma);
 
 	/* half of the buffers is dedicated for RX */