lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 19 May 2022 17:24:29 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Chris Down <chris@...isdown.name>
Cc:     linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
        kernel-team@...com
Subject: Re: [RFC PATCH] printk: console: Allow each console to have its own
 loglevel

On Thu, May 19, 2022 at 04:08:04PM +0100, Chris Down wrote:
> Greg Kroah-Hartman writes:
> > >  struct console {
> > >  	char	name[16];
> > >  	void	(*write)(struct console *, const char *, unsigned);
> > > @@ -179,9 +173,11 @@ struct console {
> > >  	void	*data;
> > >  	struct	 console *next;
> > >  	int	level;
> > > -	struct	device classdev;
> > > +	struct	device *classdev;
> > 
> > Ick, no, keep the real structure here.  It can properly handle the
> > reference counting for the object.  Just correctly clean up in the
> > release function, not anywhere else.
> 
> Sorry, I'm getting more and more confused about what you're asking me to do,
> and less and less clear on the rationale.
> 
> Can you please clarify what "correctly cleaning up" would mean for a
> non-pointer `struct device'?
> 
> Is your concern that...
> 
>     register_console(c)
>         device_initialize(c->d)
>         device_add(c->d)
>     unregister_console(c)
>         device_unregister(c->d)      console_classdev_release(c->d)
>     register_console(c)
>         device_initialize(c->d)  <-- classdev was not previously zeroed out
> 				     in console_classdev_release() and bad 				     things may happen
> 
> If that's not the point, I could really use some clarification about what
> "correctly cleaning up" means for a non-pointer `struct device' :-)

The problem is that your release() callback for your class HAS TO clean
up the memory for that object.  You can not have an empty function, or
just say "it will be handled elsewhere."  That is the LAST call that
will be made when the object is to be freed from memory, as that is when
the last reference count is dropped.  Anytime before then, you do not
know if it is safe to free the memory or not.

Does that help?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ