RE: [PATCH] kobject: Refactor kobject_set_name_vargs()

David Laight
2022-05-07T10:02:07Z

From: Jagdish Gediya
> Sent: 06 May 2022 18:24
...
> > Are you sure this can ever work from a module?
> > This all relies on:
> >
> > static inline bool is_kernel_rodata(unsigned long addr)
> > {
> > return addr >= (unsigned long)__start_rodata &&
> > addr < (unsigned long)__end_rodata;
> > }
> >
> > which isn't going to do anything sane given an "xxx" inside a module.
> >
> > Indeed can kobject_set_name_vargs() end up with a constant string
> > inside a module?
>
> No, kobject_set_name_vargs() is not exported. I exported
> set_name_vargs() because it can have a broader use, but you are right
> it shouldn't be exported.

I was thinking that some function that creates a 'kobject'
could easily be called from a module - so you end up calling
the set_name code from a module and then end up calling
kfree() on a literal from a module.

Now it might be that it is impossible to actually the quoted
literal from a module into somewhere that is_kernel_rodata()
is applied to.

But, as i said, it is fragile.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)