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, 03 Apr 2014 10:00:26 +0200
From:	Jiri Slaby <jslaby@...e.cz>
To:	Takashi Iwai <tiwai@...e.de>
CC:	Samo Pogacnik <samo_pogacnik@....net>,
	Jean Delvare <jdelvare@...e.de>, Arnd Bergmann <arnd@...db.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Struan Bartlett <struan.bartlett@...il.com>,
	Andreas Schwab <schwab@...ux-m68k.org>,
	gnomes@...rguk.ukuu.org.uk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] ttyprintk: Fix wrong tty_unregister_driver() call
 in the error path

On 04/03/2014 08:10 AM, Takashi Iwai wrote:
> At Wed, 02 Apr 2014 14:24:33 +0200,
> Jean Delvare wrote:
>>
>> Le Wednesday 02 April 2014 à 12:29 +0200, Takashi Iwai a écrit :
>>> ttyprintk driver calls tty_unregister_driver() wrongly in the error
>>> path of tty_register_driver().  Also, setting ttyprintk_driver to NULL
>>> is utterly superfluous, so let's get rid of it, too.
>>>
>>> Reported-by: Jean Delvare <jdelvare@...e.de>
>>> Signed-off-by: Takashi Iwai <tiwai@...e.de>
>>> ---
>>>  drivers/char/ttyprintk.c | 2 --
>>>  1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
>>> index daea84c41743..2a39c5790364 100644
>>> --- a/drivers/char/ttyprintk.c
>>> +++ b/drivers/char/ttyprintk.c
>>> @@ -210,10 +210,8 @@ static int __init ttyprintk_init(void)
>>>  	return 0;
>>>  
>>>  error:
>>> -	tty_unregister_driver(ttyprintk_driver);
>>>  	put_tty_driver(ttyprintk_driver);
>>>  	tty_port_destroy(&tpk_port.port);
>>> -	ttyprintk_driver = NULL;
>>>  	return ret;
>>>  }
>>>  device_initcall(ttyprintk_init);
>>
>> Reviewed-by: Jean Delvare <jdelvare@...e.de>
> 
> Meanwhile, I found that tty_unregister_driver() was added
> intentionally in the commit f06fb543c1d0,
>     TTY: ttyprintk, unregister tty driver on failure
>     
>     When the tty_printk driver fails to create a node in sysfs, the
>     system
>     crashes. It is because the driver registers a tty driver and frees
>     it
>     without deregistering it first. The fix is easy: add a call to
>     tty_unregister_driver to the fail path.
> 
> But, I failed to see why this is needed in the current code.
> 
> Jiri, is your fix still valid at all?

The code was different. There was also device_create after
tty_register_driver. I must admit that I don't know why I didn't change
'goto error' in the tty_register_driver fail path.

        ret = tty_register_driver(ttyprintk_driver);
        if (ret < 0) {
                printk(KERN_ERR "Couldn't register ttyprintk driver\n");
                goto error;
        }

        /* create our unnumbered device */
        rp = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL,
                                ttyprintk_driver->name);
        if (IS_ERR(rp)) {
                printk(KERN_ERR "Couldn't create ttyprintk device\n");
                ret = PTR_ERR(rp);
                goto error;
        }



So yes, there should be no tty_unregister_driver in the fail path when
device_create is gone now.

thanks,
-- 
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ