Re: [PATCH] rust: miscdevice: Export vtable testing

From: Greg KH
Date: Sat Jun 28 2025 - 02:07:31 EST


On Fri, Jun 27, 2025 at 04:46:04PM -0700, Matthew Maurer wrote:
> On Fri, Jun 27, 2025 at 4:42 PM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote:
> >
> > A common pattern in the kernel is to test whether a file belongs to a
> > particular driver by checking its `f_op` struct against an expected
> > value. This provides a safe way to perform that test for `MiscDevice`
> > implementations without needing to directly expose the vtable.
> >
> > Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx>
>
> Additionally, we have a sample user[1] of this in the Android ashmem
> wrapper. They're currently working around it by grabbing the vtable
> out of the registration and testing manually.
>
> [1]: https://android-review.git.corp.google.com/c/kernel/common/+/3477511

As ashmem isn't going to be upstream, it's hard for us to treat this as
a real user :)