Skip to content

Commit 7ff0b60

Browse files
committed
Merge branch 'tipc-a-batch-of-uninit-value-fixes-for-netlink_compat'
Xin Long says: ==================== tipc: a batch of uninit-value fixes for netlink_compat These issues were all reported by syzbot, and exist since very beginning. See the details on each patch. ==================== Acked-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents d3de85a + 2ac695d commit 7ff0b60

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

net/tipc/netlink_compat.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,14 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
267267
if (msg->rep_type)
268268
tipc_tlv_init(msg->rep, msg->rep_type);
269269

270-
if (cmd->header)
271-
(*cmd->header)(msg);
270+
if (cmd->header) {
271+
err = (*cmd->header)(msg);
272+
if (err) {
273+
kfree_skb(msg->rep);
274+
msg->rep = NULL;
275+
return err;
276+
}
277+
}
272278

273279
arg = nlmsg_new(0, GFP_KERNEL);
274280
if (!arg) {
@@ -397,7 +403,12 @@ static int tipc_nl_compat_bearer_enable(struct tipc_nl_compat_cmd_doit *cmd,
397403
if (!bearer)
398404
return -EMSGSIZE;
399405

400-
len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_BEARER_NAME);
406+
len = TLV_GET_DATA_LEN(msg->req);
407+
len -= offsetof(struct tipc_bearer_config, name);
408+
if (len <= 0)
409+
return -EINVAL;
410+
411+
len = min_t(int, len, TIPC_MAX_BEARER_NAME);
401412
if (!string_is_valid(b->name, len))
402413
return -EINVAL;
403414

@@ -766,7 +777,12 @@ static int tipc_nl_compat_link_set(struct tipc_nl_compat_cmd_doit *cmd,
766777

767778
lc = (struct tipc_link_config *)TLV_DATA(msg->req);
768779

769-
len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME);
780+
len = TLV_GET_DATA_LEN(msg->req);
781+
len -= offsetof(struct tipc_link_config, name);
782+
if (len <= 0)
783+
return -EINVAL;
784+
785+
len = min_t(int, len, TIPC_MAX_LINK_NAME);
770786
if (!string_is_valid(lc->name, len))
771787
return -EINVAL;
772788

0 commit comments

Comments
 (0)