Skip to contentSkip to conversation

rdma: Check comm string before print in print_comm()

PATCH In review Leon Romanovsky 2 participants 3 messages Sep 11, 2019 – Sep 16, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rdma: Check comm string before print in print_comm()

From: Mark Zhang <[email protected]>

Broken kernels (not-upstream) can provide wrong empty "comm" field. It causes to segfault while printing in JSON format.

Fixes 8ecac46a60ff ("rdma: Add QP resource tracking information")
---
 rdma/res.c | 3 +++
 1 file changed, 3 insertions(+)
rdma/res.c +3 -0
index 97a7b964..6003006e 100644
@@ -161,6 +161,9 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
 {
 	char tmp[18];
 
+	if (!str)
+		return;
+
 	if (rd->json_output) {
 		/* Don't beatify output in JSON format */
 		jsonw_string_field(rd->jw, "comm", str);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Leon Romanovsky

From: Mark Zhang <[email protected]>

Broken kernels (not-upstream) can provide wrong empty "comm" field. It causes to segfault while printing in JSON format.

Fixes 8ecac46a60ff ("rdma: Add QP resource tracking information")

that commit is from 2018, so this should go to master; re-assigned in patchwork.

Quoted 21 lines
---
 rdma/res.c | 3 +++
 1 file changed, 3 insertions(+)
rdma/res.c +3 -0
index 97a7b964..6003006e 100644
@@ -161,6 +161,9 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
 {
 	char tmp[18];
 
+	if (!str)
+		return;
+
 	if (rd->json_output) {
 		/* Don't beatify output in JSON format */
 		jsonw_string_field(rd->jw, "comm", str);
#2 lore raw
Quoted 10 lines · David Ahern
Quoted 6 lines · Leon Romanovsky

From: Mark Zhang <[email protected]>

Broken kernels (not-upstream) can provide wrong empty "comm" field. It causes to segfault while printing in JSON format.

Fixes 8ecac46a60ff ("rdma: Add QP resource tracking information")

that commit is from 2018, so this should go to master; re-assigned in patchwork.

This is exactly why I sent it to -next, it is not urgent :)

Thanks