From: David Sterba <dsterba@suse.cz>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Kees Cook <keescook@chromium.org>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] btrfs: sysfs: Handle NULL return values
Date: Mon, 6 Feb 2023 19:33:27 +0100 [thread overview]
Message-ID: <20230206183327.GC28288@twin.jikos.cz> (raw)
In-Reply-To: <Y99XGrFvXBL32cOO@kroah.com>
On Sun, Feb 05, 2023 at 08:13:30AM +0100, Greg KH wrote:
> On Sat, Feb 04, 2023 at 10:35:10AM -0800, Kees Cook wrote:
> > Each of to_fs_info(), discard_to_fs_info(), and to_space_info() can
> > return NULL values.
>
> The code says it could, but I really do not think that is possible at
> all, especially based on the fact that there have never been any crashes
> reported here.
>
> So the NULL returns should just be removed instead, right?
Yes. The access to any sysfs callback always implies an existing
fs_info, the sysfs files are destroyed before the instance of fs_info.
If the callback is slow or stuck for some reason, the removal will block
due to reference counts.
> Also, to_space_info() is a macro of container_of() which can not return
> NULL.
>
> And get_btrfs_kobj() is just odd, that probably should be fixed up as
> well, that's an indication that something is wrong with the sysfs code
> if anyone has to attempt to walk the whole kobject parent path :(
The get_btrfs_kobj is relatively new and more generic than the other
helpers that basically hardcoded the kobj path relative to the main
sysfs object.
> So while this patch might fix up the compiler warning, it's logically
> not going to change anything, let's fix this properly. I can look at it
> next week if someone doesn't beat me to it.
Let me have a look, I was meaning to clean up the code to use only
get_btrfs_kobj. So far there was no pressing reason for that but if gcc
13 is going to warn about the checks it needs to be fixed.
next prev parent reply other threads:[~2023-02-06 18:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 18:35 Kees Cook
2023-02-05 7:13 ` Greg KH
2023-02-06 18:33 ` David Sterba [this message]
2023-02-06 18:37 ` Kees Cook
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=20230206183327.GC28288@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=josef@toxicpanda.com \
--cc=keescook@chromium.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--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
all inboxes | Powered by JetHome®