net: rds: drop VLA in rds_walk_conn_path_info()
authorSalvatore Mesoraca <s.mesoraca16@gmail.com>
Sun, 11 Mar 2018 21:07:50 +0000 (22:07 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Mar 2018 19:07:00 +0000 (15:07 -0400)
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 <s.mesoraca16@gmail.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/connection.c

index f80792c719eb2965c953b418750ad8f5c81e094b..abef75da89a7450092aefc46ed902e6602fba7a6 100644 (file)
@@ -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));
 }