LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Austin Kim <austindh.kim@gmail.com>
To: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
	"Kees Cook" <keescook@chromium.org>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	김동현 <austin.kim@lge.com>,
	kernel-team@lge.com
Subject: Re: [PATCH] LSM: add NULL check for kcalloc()
Date: Thu, 15 Jul 2021 06:44:52 +0900	[thread overview]
Message-ID: <CADLLry6RmSDuB4nmVKDEiqxXmEU0xrhMn2wieuuVTypMWqc4cQ@mail.gmail.com> (raw)
In-Reply-To: <e0a2655b-3bc6-fd45-bd84-8df2dc6bc5f@namei.org>

2021년 7월 15일 (목) 오전 4:12, James Morris <jmorris@namei.org>님이 작성:
>
> On Tue, 13 Jul 2021, Austin Kim wrote:
>
> > From: Austin Kim <austin.kim@lge.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@lge.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)'.

Let me resend patch(v2) soon.

Thanks,
Austin Kim

>
> Should this also be a kernel panic?
>
> >
> >       if (chosen_lsm_order) {
> >               if (chosen_major_lsm) {
> > --
> > 2.20.1
> >
>
> --
> James Morris
> <jmorris@namei.org>
>

  reply	other threads:[~2021-07-14 21:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 23:44 Austin Kim
2021-07-14 19:05 ` James Morris
2021-07-14 21:44   ` Austin Kim [this message]
2021-08-06 18:33     ` Ken Goldman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADLLry6RmSDuB4nmVKDEiqxXmEU0xrhMn2wieuuVTypMWqc4cQ@mail.gmail.com \
    --to=austindh.kim@gmail.com \
    --cc=austin.kim@lge.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --subject='Re: [PATCH] LSM: add NULL check for kcalloc()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).