linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: "Christian Löhle" <CLoehle@hyperstone.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kobject: Safe return of kobject_get_path with NULL
Date: Thu, 24 Jun 2021 11:02:17 +0200	[thread overview]
Message-ID: <YNRKGUgXW9gciMzO@kroah.com> (raw)
In-Reply-To: <CWXP265MB26809893E168B75CF57ECC86C4079@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM>

On Thu, Jun 24, 2021 at 06:42:41AM +0000, Christian Löhle wrote:
> Hey Greg,
> 
> >> Prevent NULL dereference within get_kobj_path_length
> >> 
> >> Calling kobject_get_path could provoke a NULL dereference
> >> if NULL was passed. while fill_kobj_path will return
> >> with a sane 0 for NULL, kobjet_get_path_length did not.
> >
> >Who passes NULL into that function?  Shouldn't that be fixed first?
> 
> It seems to me like here specifically it was a sd_open on some no longer
> existing device. I agree, but could not find a fix for that, and even if, it might
> not have been in the current tree.
> But when looking at the kobject code it felt like it was meant to be safe for
> NULL, (like any parent in the tree can be NULL), but the do while does hide that
> a bit.
> So is it not meant to be safe?

Not always, no.  It's better to fix the root problem and not paper over
it by doing something like this.

> I will try to find the sd_open issue some more, but cannot reproduce the issue
> consistently enough right now.
> 
> 
> >Pleaase always run your patches through checkpatch.pl so you do not get
> >maintainers asking you to use checkpatch.pl...
> 
> I did, so please tell me what part bothers you, so I can get that fixed, either in v2
> or maybe even in checkpatch.pl?
> (Only thing I spotted now is the kobjet typo)

You should put a blank line after variable definitions and before the
code logic.  Normally checkpatch catches that, odd it did not here...

thanks,

greg k-h

      reply	other threads:[~2021-06-24  9:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 14:47 [PATCH] kobject: Safe return of kobject_get_path with NULL Christian Löhle
2021-06-23 14:49 ` Christian Löhle
2021-06-23 15:12   ` gregkh
2021-06-23 15:11 ` gregkh
2021-06-24  6:42   ` Christian Löhle
2021-06-24  9:02     ` gregkh [this message]

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=YNRKGUgXW9gciMzO@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=CLoehle@hyperstone.com \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).