diff options
Diffstat (limited to 'net/tipc/netlink_compat.c')
-rw-r--r-- | net/tipc/netlink_compat.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 77e4b2418f30..b2b115b22871 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
@@ -87,6 +87,11 @@ static int tipc_skb_tailroom(struct sk_buff *skb) | |||
87 | return limit; | 87 | return limit; |
88 | } | 88 | } |
89 | 89 | ||
90 | static inline int TLV_GET_DATA_LEN(struct tlv_desc *tlv) | ||
91 | { | ||
92 | return TLV_GET_LEN(tlv) - TLV_SPACE(0); | ||
93 | } | ||
94 | |||
90 | static int tipc_add_tlv(struct sk_buff *skb, u16 type, void *data, u16 len) | 95 | static int tipc_add_tlv(struct sk_buff *skb, u16 type, void *data, u16 len) |
91 | { | 96 | { |
92 | struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(skb); | 97 | struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(skb); |
@@ -166,6 +171,11 @@ static struct sk_buff *tipc_get_err_tlv(char *str) | |||
166 | return buf; | 171 | return buf; |
167 | } | 172 | } |
168 | 173 | ||
174 | static inline bool string_is_valid(char *s, int len) | ||
175 | { | ||
176 | return memchr(s, '\0', len) ? true : false; | ||
177 | } | ||
178 | |||
169 | static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, | 179 | static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, |
170 | struct tipc_nl_compat_msg *msg, | 180 | struct tipc_nl_compat_msg *msg, |
171 | struct sk_buff *arg) | 181 | struct sk_buff *arg) |
@@ -750,6 +760,7 @@ static int tipc_nl_compat_link_reset_stats(struct tipc_nl_compat_cmd_doit *cmd, | |||
750 | { | 760 | { |
751 | char *name; | 761 | char *name; |
752 | struct nlattr *link; | 762 | struct nlattr *link; |
763 | int len; | ||
753 | 764 | ||
754 | name = (char *)TLV_DATA(msg->req); | 765 | name = (char *)TLV_DATA(msg->req); |
755 | 766 | ||
@@ -757,6 +768,10 @@ static int tipc_nl_compat_link_reset_stats(struct tipc_nl_compat_cmd_doit *cmd, | |||
757 | if (!link) | 768 | if (!link) |
758 | return -EMSGSIZE; | 769 | return -EMSGSIZE; |
759 | 770 | ||
771 | len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME); | ||
772 | if (!string_is_valid(name, len)) | ||
773 | return -EINVAL; | ||
774 | |||
760 | if (nla_put_string(skb, TIPC_NLA_LINK_NAME, name)) | 775 | if (nla_put_string(skb, TIPC_NLA_LINK_NAME, name)) |
761 | return -EMSGSIZE; | 776 | return -EMSGSIZE; |
762 | 777 | ||