[PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

Subsystems: networking [general], rds - reliable datagram sockets, the rest

STALE3141d

7 messages, 3 authors, 2018-03-12 · open the first message on its own page

[PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

From: Salvatore Mesoraca <hidden>
Date: 2018-03-11 21:07:49

Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
---
 net/rds/connection.c | 2 +-
 net/rds/ib.c         | 3 +++
 net/rds/rds.h        | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/rds/connection.c b/net/rds/connection.c
index 2da3176..f80792c 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -540,9 +540,9 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len,
 			  struct rds_info_iterator *iter,
 			  struct rds_info_lengths *lens,
 			  int (*visitor)(struct rds_connection *, void *),
+			  u64 *buffer,
 			  size_t item_len)
 {
-	uint64_t buffer[(item_len + 7) / 8];
 	struct hlist_head *head;
 	struct rds_connection *conn;
 	size_t i;
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 50a88f3..02deee2 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -321,8 +321,11 @@ static void rds_ib_ic_info(struct socket *sock, unsigned int len,
 			   struct rds_info_iterator *iter,
 			   struct rds_info_lengths *lens)
 {
+	u64 buffer[(sizeof(struct rds_info_rdma_connection) + 7) / 8];
+
 	rds_for_each_conn_info(sock, len, iter, lens,
 				rds_ib_conn_info_visitor,
+				buffer,
 				sizeof(struct rds_info_rdma_connection));
 }
 
diff --git a/net/rds/rds.h b/net/rds/rds.h
index 7301b9b..91ea08f 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -709,6 +709,7 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len,
 			  struct rds_info_iterator *iter,
 			  struct rds_info_lengths *lens,
 			  int (*visitor)(struct rds_connection *, void *),
+			  u64 *buffer,
 			  size_t item_len);
 
 __printf(2, 3)
-- 
1.9.1

[PATCH 2/2] net: rds: drop VLA in rds_walk_conn_path_info()

From: Salvatore Mesoraca <hidden>
Date: 2018-03-11 21:07:50

Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
---
 net/rds/connection.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/rds/connection.c b/net/rds/connection.c
index f80792c..abef75d 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -578,9 +578,9 @@ static void rds_walk_conn_path_info(struct socket *sock, unsigned int len,
 				    struct rds_info_iterator *iter,
 				    struct rds_info_lengths *lens,
 				    int (*visitor)(struct rds_conn_path *, void *),
+				    u64 *buffer,
 				    size_t item_len)
 {
-	u64  buffer[(item_len + 7) / 8];
 	struct hlist_head *head;
 	struct rds_connection *conn;
 	size_t i;
@@ -649,8 +649,11 @@ static void rds_conn_info(struct socket *sock, unsigned int len,
 			  struct rds_info_iterator *iter,
 			  struct rds_info_lengths *lens)
 {
+	u64 buffer[(sizeof(struct rds_info_connection) + 7) / 8];
+
 	rds_walk_conn_path_info(sock, len, iter, lens,
 				rds_conn_info_visitor,
+				buffer,
 				sizeof(struct rds_info_connection));
 }
 
-- 
1.9.1

Re: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

From: santosh.shilimkar@oracle.com <hidden>
Date: 2018-03-12 07:06:01

On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:
Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
---
Thanks for both VLA fixes Salvatore.

FWIW, Acked-by: Santosh Shilimkar [off-list ref]

Re: [PATCH 2/2] net: rds: drop VLA in rds_walk_conn_path_info()

From: santosh.shilimkar@oracle.com <hidden>
Date: 2018-03-12 07:06:29

On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:
Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
---
Acked-by: Santosh Shilimkar <redacted>

Re: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

From: Salvatore Mesoraca <hidden>
Date: 2018-03-12 10:12:57

2018-03-12 8:06 GMT+01:00 santosh.shilimkar@oracle.com
[off-list ref]:
On 3/11/18 2:07 PM, Salvatore Mesoraca wrote:
quoted
Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
---
Thanks for both VLA fixes Salvatore.

FWIW, Acked-by: Santosh Shilimkar [off-list ref]
Thank you very much for your time,

Salvatore

Re: [PATCH 1/2] net: rds: drop VLA in rds_for_each_conn_info()

From: David Miller <davem@davemloft.net>
Date: 2018-03-12 19:07:57

From: Salvatore Mesoraca <redacted>
Date: Sun, 11 Mar 2018 22:07:49 +0100
Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
Applied.

Re: [PATCH 2/2] net: rds: drop VLA in rds_walk_conn_path_info()

From: David Miller <davem@davemloft.net>
Date: 2018-03-12 19:08:15

From: Salvatore Mesoraca <redacted>
Date: Sun, 11 Mar 2018 22:07:50 +0100
Avoid VLA[1] by using an already allocated buffer passed
by the caller.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Salvatore Mesoraca <redacted>
Also applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help