aboutsummaryrefslogtreecommitdiff
path: root/security/selinux
diff options
context:
space:
mode:
authorXiu Jianfeng2022-06-14 10:14:49 +0800
committerPaul Moore2022-06-14 21:52:37 -0400
commit15ec76fb29be31df2bccb30fc09875274cba2776 (patch)
tree77a1eb30dffc1231cafb9f21ea2aa2a55af72c16 /security/selinux
parent73de1befcc53a7c68b0c5e76b9b5ac41c517760f (diff)
selinux: Add boundary check in put_entry()
Just like next_entry(), boundary check is necessary to prevent memory out-of-bound access. Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/ss/policydb.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h
index c24d4e1063ea..ffc4e7bad205 100644
--- a/security/selinux/ss/policydb.h
+++ b/security/selinux/ss/policydb.h
@@ -370,6 +370,8 @@ static inline int put_entry(const void *buf, size_t bytes, int num, struct polic
{
size_t len = bytes * num;
+ if (len > fp->len)
+ return -EINVAL;
memcpy(fp->data, buf, len);
fp->data += len;
fp->len -= len;