All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: target: tcmu: allocate zeroed pages for data area
@ 2021-10-13 17:16 Bodo Stroesser
  2021-10-17  2:47 ` Martin K. Petersen
  2021-10-21  3:42 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Bodo Stroesser @ 2021-10-13 17:16 UTC (permalink / raw)
  To: Martin K. Petersen, Mike Christie
  Cc: Bodo Stroesser, linux-scsi, target-devel

Tcmu populates the data area (used for communication with
userspace) with pages that are allocated by calling
alloc_page(GFP_NOIO).
Therefore previous content of the allocated pages is exposed
to user space. Avoid this by adding __GFP_ZERO flag.

Zeroing the pages does (nearly) not affect tcmu throughput,
because allocated pages are re-used for the data transfers of
later SCSI cmds.

Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>
---
 drivers/target/target_core_user.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index dc220fad06fa..a19e53877b0b 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2015 Arrikto, Inc.
  * Copyright (C) 2017 Chinamobile, Inc.
  */
+#include <linux/delay.h>
 
 #include <linux/spinlock.h>
 #include <linux/module.h>
@@ -523,8 +524,8 @@ static inline int tcmu_get_empty_block(struct tcmu_dev *udev,
 	rcu_read_unlock();
 
 	for (i = cnt; i < page_cnt; i++) {
-		/* try to get new page from the mm */
-		page = alloc_page(GFP_NOIO);
+		/* try to get new zeroed page from the mm */
+		page = alloc_page(GFP_NOIO | __GFP_ZERO);
 		if (!page)
 			break;
 
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: target: tcmu: allocate zeroed pages for data area
  2021-10-13 17:16 [PATCH] scsi: target: tcmu: allocate zeroed pages for data area Bodo Stroesser
@ 2021-10-17  2:47 ` Martin K. Petersen
  2021-10-21  3:42 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2021-10-17  2:47 UTC (permalink / raw)
  To: Bodo Stroesser
  Cc: Martin K. Petersen, Mike Christie, linux-scsi, target-devel


Bodo,

> Tcmu populates the data area (used for communication with userspace)
> with pages that are allocated by calling alloc_page(GFP_NOIO).
> Therefore previous content of the allocated pages is exposed to user
> space. Avoid this by adding __GFP_ZERO flag.

Applied to 5.16/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: target: tcmu: allocate zeroed pages for data area
  2021-10-13 17:16 [PATCH] scsi: target: tcmu: allocate zeroed pages for data area Bodo Stroesser
  2021-10-17  2:47 ` Martin K. Petersen
@ 2021-10-21  3:42 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2021-10-21  3:42 UTC (permalink / raw)
  To: Bodo Stroesser, Mike Christie
  Cc: Martin K . Petersen, target-devel, linux-scsi

On Wed, 13 Oct 2021 19:16:06 +0200, Bodo Stroesser wrote:

> Tcmu populates the data area (used for communication with
> userspace) with pages that are allocated by calling
> alloc_page(GFP_NOIO).
> Therefore previous content of the allocated pages is exposed
> to user space. Avoid this by adding __GFP_ZERO flag.
> 
> Zeroing the pages does (nearly) not affect tcmu throughput,
> because allocated pages are re-used for the data transfers of
> later SCSI cmds.
> 
> [...]

Applied to 5.16/scsi-queue, thanks!

[1/1] scsi: target: tcmu: allocate zeroed pages for data area
      https://git.kernel.org/mkp/scsi/c/1d2ac7b69d6a

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-21  3:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 17:16 [PATCH] scsi: target: tcmu: allocate zeroed pages for data area Bodo Stroesser
2021-10-17  2:47 ` Martin K. Petersen
2021-10-21  3:42 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.