Re: [PATCH -next] LSM: fix return value check in safesetid_init_securityfs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 11, 2019 at 11:44 PM Wei Yongjun <weiyongjun1@xxxxxxxxxx> wrote:
>
> In case of error, the function securityfs_create_dir() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should
> be replaced with IS_ERR().
>
> Fixes: aeca4e2ca65c ("LSM: add SafeSetID module that gates setid calls")
> Signed-off-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>

Nice catch! Thanks,

Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>

-Kees

> ---
>  security/safesetid/securityfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
> index 61be4ee459cc..2c6c829be044 100644
> --- a/security/safesetid/securityfs.c
> +++ b/security/safesetid/securityfs.c
> @@ -167,7 +167,7 @@ static int __init safesetid_init_securityfs(void)
>                 return 0;
>
>         safesetid_policy_dir = securityfs_create_dir("safesetid", NULL);
> -       if (!safesetid_policy_dir) {
> +       if (IS_ERR(safesetid_policy_dir)) {
>                 ret = PTR_ERR(safesetid_policy_dir);
>                 goto error;
>         }
>
>
>


-- 
Kees Cook



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux