]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/tipc-check-link-name-with-right-length-in-tipc_nl_compat_link_set.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / tipc-check-link-name-with-right-length-in-tipc_nl_compat_link_set.patch
CommitLineData
9e4b7051
GKH
1From 8c63bf9ab4be8b83bd8c34aacfd2f1d2c8901c8a Mon Sep 17 00:00:00 2001
2From: Xin Long <lucien.xin@gmail.com>
3Date: Sun, 31 Mar 2019 22:50:09 +0800
4Subject: tipc: check link name with right length in tipc_nl_compat_link_set
5
6From: Xin Long <lucien.xin@gmail.com>
7
8commit 8c63bf9ab4be8b83bd8c34aacfd2f1d2c8901c8a upstream.
9
10A similar issue as fixed by Patch "tipc: check bearer name with right
11length in tipc_nl_compat_bearer_enable" was also found by syzbot in
12tipc_nl_compat_link_set().
13
14The length to check with should be 'TLV_GET_DATA_LEN(msg->req) -
15offsetof(struct tipc_link_config, name)'.
16
17Reported-by: syzbot+de00a87b8644a582ae79@syzkaller.appspotmail.com
18Signed-off-by: Xin Long <lucien.xin@gmail.com>
19Signed-off-by: David S. Miller <davem@davemloft.net>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 net/tipc/netlink_compat.c | 7 ++++++-
24 1 file changed, 6 insertions(+), 1 deletion(-)
25
26--- a/net/tipc/netlink_compat.c
27+++ b/net/tipc/netlink_compat.c
28@@ -738,7 +738,12 @@ static int tipc_nl_compat_link_set(struc
29
30 lc = (struct tipc_link_config *)TLV_DATA(msg->req);
31
32- len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME);
33+ len = TLV_GET_DATA_LEN(msg->req);
34+ len -= offsetof(struct tipc_link_config, name);
35+ if (len <= 0)
36+ return -EINVAL;
37+
38+ len = min_t(int, len, TIPC_MAX_LINK_NAME);
39 if (!string_is_valid(lc->name, len))
40 return -EINVAL;
41