lkml.org 
[lkml]   [2022]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 105/545] selinux: Add boundary check in put_entry()
    Date
    From: Xiu Jianfeng <xiujianfeng@huawei.com>

    [ Upstream commit 15ec76fb29be31df2bccb30fc09875274cba2776 ]

    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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    security/selinux/ss/policydb.h | 2 ++
    1 file changed, 2 insertions(+)

    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;
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-19 17:59    [W:2.121 / U:0.180 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site