linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Xion Wang (王鑫)" <Xion.Wang@mediatek.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	wsd_upstream <wsd_upstream@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Huadian Liu (刘华典)" <huadian.liu@mediatek.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH 1/1] misc: Prevent double registration and deregistration of miscdevice
Date: Tue, 2 Sep 2025 01:42:44 +0000	[thread overview]
Message-ID: <836023cd8131e4fa63dc027a8fd6e47ec3d589ee.camel@mediatek.com> (raw)
In-Reply-To: <2025082646-regalia-glass-951d@gregkh>

On Tue, 2025-08-26 at 14:54 +0200, gregkh@linuxfoundation.org wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Tue, Aug 26, 2025 at 12:09:01PM +0000, Xion Wang (王鑫) wrote:
> > On Tue, 2025-08-26 at 12:40 +0200, gregkh@linuxfoundation.org
> > wrote:
> > > External email : Please do not click links or open attachments
> > > until
> > > you have verified the sender or the content.
> > > 
> > > 
> > > On Tue, Aug 26, 2025 at 07:58:47AM +0000, Xion Wang (王鑫) wrote:
> > > > > Again, this shouldn't be something that any driver should hit
> > > > > as
> > > > > this
> > > > > usage is not in the kernel tree that I can see.  Attempting
> > > > > to
> > > > > re-register a device multiple times is normally never a good
> > > > > idea.
> > > > 
> > > > Thank you for your comments.
> > > > 
> > > > I am not the owner of the WiFi driver and do not have full
> > > > details
> > > > of
> > > > its internal logic. However, during internal integration and
> > > > stress
> > > > testing, we observed an issue where repeated registration and
> > > > deregistration of a misc device by the WiFi module led to
> > > > corruption of
> > > > the misc_list. While I cannot provide the exact reasoning
> > > > behind
> > > > the
> > > > WiFi driver's design, I wanted to report the problem and share
> > > > our
> > > > findings with the community in case similar patterns exist
> > > > elsewhere,
> > > > including in vendor or out-of-tree drivers.
> > > 
> > > We do not "harden" our internal apis for external drivers, we fix
> > > drivers to not do foolish things :)
> > > 
> > > Please fix your out-of-tree code, it should not be even touching
> > > the
> > > miscdev api, as that is not something a wifi driver should be
> > > interacting with.  Please use the correct one instead, and then
> > > you
> > > will
> > > not have this type of issue.
> > 
> > Thank you for your feedback.
> > 
> > I agree that the kernel should not be hardened for out-of-tree
> > drivers
> > misusing internal APIs. We will update our internal code to follow
> > best
> > practices and avoid improper use of the miscdevice API.
> > 
> > On a related note, the current 'WARN_ON(list_empty(&misc->list))'
> > check
> > in misc_deregister() does not catch any practical error conditions:
> > 
> > For statically allocated miscdevice structs, the list pointers are
> > zero-initialized, so list_empty() will return false, not true.
> > After list_del(), the pointers are set to LIST_POISON1/2, so
> > repeated
> > deregistration also fails to trigger the check.
> > 
> > Since this condition does not protect in-tree drivers or catch real
> > errors, would it be reasonable to remove it?
> 
> Yes, if it can never be hit, we should remove it.
> 
> > I can submit a patch if the community agrees.
> 
> That would be great, thank you!
> 

Hi,

Thank you for your previous feedback.

As suggested, I have submitted a new patch to remove the ineffective
WARN_ON() check in misc_deregister() in a separate email thread:

	
https://lore.kernel.org/lkml/20250827024201.21407-1-xion.wang@mediatek.com/T/#t
	[PATCH 1/1] misc: remove ineffective WARN_ON() check from
misc_deregister()

Please let me know if you have any comments.

Thanks,
Xion Wang

  reply	other threads:[~2025-09-02  1:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25  8:45 [PATCH 0/1] misc: Prevent double registration and deregistration of miscdevice xion.wang
2025-08-25  8:45 ` [PATCH 1/1] " xion.wang
2025-08-25 20:28   ` Greg Kroah-Hartman
2025-08-26  2:55     ` Xion Wang (王鑫)
2025-08-26  7:05       ` gregkh
2025-08-26  7:58         ` Xion Wang (王鑫)
2025-08-26 10:40           ` gregkh
2025-08-26 12:09             ` Xion Wang (王鑫)
2025-08-26 12:54               ` gregkh
2025-09-02  1:42                 ` Xion Wang (王鑫) [this message]
2025-08-25 20:27 ` [PATCH 0/1] " Greg Kroah-Hartman

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=836023cd8131e4fa63dc027a8fd6e47ec3d589ee.camel@mediatek.com \
    --to=xion.wang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=huadian.liu@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=wsd_upstream@mediatek.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;
as well as URLs for NNTP newsgroup(s).