From: Xiu Jianfeng Date: Tue, 14 Jun 2022 02:14:49 +0000 (+0800) Subject: selinux: Add boundary check in put_entry() X-Git-Tag: v6.0-rc1~172^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15ec76fb29be31df2bccb30fc09875274cba2776;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Paul Moore --- diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h index c24d4e1063ea0..ffc4e7bad2054 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;