[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e0a2655b-3bc6-fd45-bd84-8df2dc6bc5f@namei.org>
Date: Thu, 15 Jul 2021 05:05:50 +1000 (AEST)
From: James Morris <jmorris@...ei.org>
To: Austin Kim <austindh.kim@...il.com>
cc: serge@...lyn.com, keescook@...omium.org,
linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, austin.kim@....com,
kernel-team@....com
Subject: Re: [PATCH] LSM: add NULL check for kcalloc()
On Tue, 13 Jul 2021, Austin Kim wrote:
> From: Austin Kim <austin.kim@....com>
>
> kcalloc() may return NULL when memory allocation fails.
> So it is necessary to add NULL check after the call to kcalloc() is made.
>
> Signed-off-by: Austin Kim <austin.kim@....com>
> ---
> security/security.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/security/security.c b/security/security.c
> index 09533cbb7221..f885c9e9bc35 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -321,6 +321,8 @@ static void __init ordered_lsm_init(void)
>
> ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms),
> GFP_KERNEL);
> + if (ordered_lsms)
> + return;
Your logic is reversed here.
Should this also be a kernel panic?
>
> if (chosen_lsm_order) {
> if (chosen_major_lsm) {
> --
> 2.20.1
>
--
James Morris
<jmorris@...ei.org>
Powered by blists - more mailing lists