[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <174162414566.58153.13543967750742784209@kwain>
Date: Mon, 10 Mar 2025 17:29:05 +0100
From: Antoine Tenart <atenart@...nel.org>
To: 174124876418.4824.8589202932419197412@...in.smtp.subspace.kernel.org, Qasim Ijaz <qasdev00@...il.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, horms@...nel.org, jdamato@...tly.com, aleksander.lobakin@...el.com, netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net-sysfs: fix NULL pointer dereference
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
Powered by blists - more mailing lists