lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 6 Aug 2021 14:33:25 -0400
From:   Ken Goldman <kgold@...ux.ibm.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     linux-security-module <linux-security-module@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        kernel-team@....com
Subject: Re: [PATCH] LSM: add NULL check for kcalloc()

On 7/14/2021 5:44 PM, Austin Kim wrote:
> 2021년 7월 15일 (목) 오전 4:12, James Morris <jmorris@...ei.org>님이 작성:
>>
>> 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.
> 
> I feel very sorry for my terrible mistake.
> 'if (ordered_lsms)' should have been 'if (!ordered_lsms)'.
> 

I know it's a bit more typing, but

	if (ordered_lsms == NULL)

compiles down to the same binary and avoids there errors that
try to treat a pointer as a boolean.



Download attachment "smime.p7s" of type "application/pkcs7-signature" (4490 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ