summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheoleun Moon <chleun.moon@samsung.com>2019-09-03 10:22:12 +0900
committerCheoleun Moon <chleun.moon@samsung.com>2019-09-03 10:22:17 +0900
commit5daeffd6da4f7984ef759dc8c48170c1497e35fc (patch)
tree0a9a86bf59ee39f5829d27f2b2ad3be538aee6d3
parentbec3ed0cd8df9ae71e968f8135b1754a8913aad4 (diff)
downloadlibnl3-accepted/tizen_6.5_base.tar.gz
libnl3-accepted/tizen_6.5_base.tar.bz2
libnl3-accepted/tizen_6.5_base.zip
In general, libnl functions are not robust against calling with invalid arguments. Thus, never call libnl functions with invalid arguments. In case of nlmsg_reserve() this means never provide a @len argument that causes overflow. Still, add an additional safeguard to avoid exploiting such bugs. Assume that @pad is a trusted, small integer. Assume that n->nm_size is a valid number of allocated bytes (and thus much smaller then SIZE_T_MAX). Assume, that @len may be set to an untrusted value. Then the patch avoids an integer overflow resulting in reserving too few bytes. http://git.infradead.org/users/tgr/libnl.git/commit/3e18948f17148e6a3c4255bdeaaf01ef6081ceeb Fix CVE-2017-0553 Change-Id: Ia9ad5040d866d2cc4c1c76eac5275d66edda338b Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
-rw-r--r--lib/msg.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/msg.c b/lib/msg.c
index 6478507..b30b90a 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -415,6 +415,9 @@ void *nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
size_t nlmsg_len = n->nm_nlh->nlmsg_len;
size_t tlen;
+ if (len > n->nm_size)
+ return NULL;
+
tlen = pad ? ((len + (pad - 1)) & ~(pad - 1)) : len;
if ((tlen + nlmsg_len) > n->nm_size)