Skip to contentSkip to conversation

selinux: Add boundary check in put_entry()

PATCH In review Xiu Jianfeng 2 participants 2 messages Jun 14, 2022 – Jun 15, 2022 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: Add boundary check in put_entry()

Just like next_entry(), boundary check is necessary to prevent memory out-of-bound access.

---
 security/selinux/ss/policydb.h | 2 ++
 1 file changed, 2 insertions(+)
security/selinux/ss/policydb.h +2 -0
index c24d4e1063ea..ffc4e7bad205 100644
@@ -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;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · Xiu Jianfeng

Just like next_entry(), boundary check is necessary to prevent memory out-of-bound access.

---
 security/selinux/ss/policydb.h | 2 ++
 1 file changed, 2 insertions(+)

It's not as critical here as it is for next_entry(), but it's still not a bad idea. Merged into selinux/next.

Signature · 1 line
paul-moore.com