All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: Replace sock_create with sock_create_kern
@ 2025-03-24  3:17 shaopeijie
  2025-03-24 21:04 ` David Laight
  2025-03-24 23:24 ` [PATCH] nvmet: Replace sock_create with sock_create_kern Chaitanya Kulkarni
  0 siblings, 2 replies; 16+ messages in thread
From: shaopeijie @ 2025-03-24  3:17 UTC (permalink / raw)
  To: hch, sagi, kch
  Cc: linux-nvme, linux-kernel, zhang.guanghui, gechangzhong,
	Peijie Shao

From: Peijie Shao <shaopeijie@cestc.cn>

Replacing sock_create() with sock_create_kern()
changes the socket object's label to kernel_t,
thereby bypassing unnecessary SELinux permission
checks. It also helps to avoid copy and paste bugs.

Signed-off-by: Peijie Shao <shaopeijie@cestc.cn>
---
 drivers/nvme/target/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 4f9cac8a5abe..216afacc8179 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -2049,7 +2049,8 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport)
 	if (port->nport->inline_data_size < 0)
 		port->nport->inline_data_size = NVMET_TCP_DEF_INLINE_DATA_SIZE;
 
-	ret = sock_create(port->addr.ss_family, SOCK_STREAM,
+	ret = sock_create_kern(current->nsproxy->net_ns,
+				port->addr.ss_family, SOCK_STREAM,
 				IPPROTO_TCP, &port->sock);
 	if (ret) {
 		pr_err("failed to create a socket\n");
-- 
2.43.0





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

end of thread, other threads:[~2025-04-08  6:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24  3:17 [PATCH] nvmet: Replace sock_create with sock_create_kern shaopeijie
2025-03-24 21:04 ` David Laight
2025-03-28  8:51   ` Peijie Shao
2025-04-01  6:19     ` [PATCH] Fix netns UAF introduced by commit 1be52169c348 shaopeijie
2025-04-03  4:30       ` Christoph Hellwig
2025-04-03  4:30         ` Christoph Hellwig
2025-04-03 13:59           ` Peijie Shao
2025-04-03 14:47             ` [PATCH v2] nvme-tcp: " shaopeijie
2025-04-04  6:17               ` Christoph Hellwig
2025-04-07 14:31               ` Christoph Hellwig
2025-04-07 17:18                 ` Kuniyuki Iwashima
2025-04-08  5:04                   ` Christoph Hellwig
2025-04-08  5:55                     ` Kuniyuki Iwashima
2025-04-08  5:58                       ` Christoph Hellwig
2025-04-08  6:08                         ` Kuniyuki Iwashima
2025-03-24 23:24 ` [PATCH] nvmet: Replace sock_create with sock_create_kern Chaitanya Kulkarni

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.