From: Antoine Tenart <atenart@kernel.org>
To: 174124876418.4824.8589202932419197412@kwain.smtp.subspace.kernel.org,
Qasim Ijaz <qasdev00@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, jdamato@fastly.com,
aleksander.lobakin@intel.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net-sysfs: fix NULL pointer dereference
Date: Mon, 10 Mar 2025 17:29:05 +0100 [thread overview]
Message-ID: <174162414566.58153.13543967750742784209@kwain> (raw)
In-Reply-To: <Z8w7ezFX3T01ptjH@qasdev.system>
Quoting Qasim Ijaz (2025-03-08 13:43:39)
> On Thu, Mar 06, 2025 at 09:12:44AM +0100, Antoine Tenart wrote:
> > Quoting Qasim Ijaz (2025-03-06 00:53:07)
> >
> > > Later on the code calls sysfs_unbreak_active_protection(kn)
> > > unconditionally, which could lead to a NULL pointer dereference.
> > >
> > > Resolve this bug by introducing a NULL check before using kn
> > > in the sysfs_unbreak_active_protection() call.
> >
> > Did you see this in practice? Can you describe what led to this?
>
> I have not seen this in practise but I think in terms of defensive
> programming it could be a good addition to add a check to see if it
> fails. If a function can return NULL then we should check for that, also
> if we look at sysfs_break_active_protection being used throughout the
> kernel there is multiple NULL checks so I think adding one here would be
> handy.
Not everywhere, there are at least two other examples. The only reason
sysfs_break_active_protection would return NULL is if the attribute
cannot be found in the kobject's sysfs directory; we got there because
of that exact attribute in that exact sysfs directory and refcounting
prevents them from disappearing.
We usually do not add a check if there is 0 chance to catch something.
Thanks,
Antoine
next prev parent reply other threads:[~2025-03-10 16:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 12:43 [PATCH] net-sysfs: fix NULL pointer dereference Qasim Ijaz
2025-03-10 16:29 ` Antoine Tenart [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-05 23:53 Qasim Ijaz
2025-03-06 8:12 ` Antoine Tenart
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=174162414566.58153.13543967750742784209@kwain \
--to=atenart@kernel.org \
--cc=174124876418.4824.8589202932419197412@kwain.smtp.subspace.kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qasdev00@gmail.com \
/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