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]
Message-Id: <97E87223-A3FF-476E-86F2-AE923D4AB955@osterried.de>
Date:	Fri, 2 Oct 2015 12:35:17 +0200
From:	Thomas Osterried <thomas@...erried.de>
To:	Jean-Christian de Rivaz <jc@...is.ch>
Cc:	Peter Hurley <peter@...leysoftware.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Jiri Slaby <jslaby@...e.com>, David Ranch <dranch@...nnet.net>,
	Ralf Bächle DL5RB <ralf@...ux-mips.org>,
	linux-hams@...nnet.net, linux-hams@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: Force mkiss to reset the line discipline when serial device is removed

Hello,


> Am 02.10.2015 um 10:30 schrieb Jean-Christian de Rivaz <jc@...is.ch>:
> 
> Le 02. 10. 15 00:57, Peter Hurley a écrit :
>> On 10/01/2015 12:56 PM, Jean-Christian de Rivaz wrote:
>>> Hi Greg and Jiri,
>>> 
>>> I try to fix a kernel panic bug related to the AX25 (and probably SLIP) line discipline when the corresponding serial device is removed [1]. I proposed some patches [2] [3] on the linux-hams mailing list but I think there raise more questions about how tty_ldisc_hangup() should work when a serial device is removed [4].
>>> 
>>> I actually see the following options:
>>> 
>>> a) Let the specific line discipline set the TTY_DRIVER_RESET_TERMIOS flag in tty->driver as in [2] but this is suspected bad practice [5].
>>> 
>>> b) Let the specific line discipline set the TTY_OTHER_CLOSED flag in tty and check it in tty_ldisc_hangup() as in [3].

If I understand correctly, in current kernels TTY_OTHER_DONE is introduced, instead of TTY_OTHER_CLOSED.

>>> c) Let the specific line discipline set the TTY_LDISC_HALTED flag in tty and check it in tty_ldisc_hangup().
>>> 
>>> d) Let the specific line discipline set a new flag for that purpose, for example TTY_LDISC_RESET, and check it in tty_ldisc_hangup().
>>> 
>>> e) Close the tty earlier so that tty_ldisc_reinit() is not even called. Need some advise on how this should be done.
>>> 
>>> f) That's all wrong, something other need to be changed.
>>> 
>>> I would appreciate some comments from tty subsystem experts about this issue.
>>> 
>>> [1] http://www.spinics.net/lists/linux-hams/msg03500.html
> 
> Hi Peter, thanks for your time,
> 
>> The crash reported here appears to be related to how mkiss handles its netdev;
>> maybe prematurely freeing the tx/rx buffers? I'd relook at how slip handles
>> netdev teardown.
> 
> Yes but this is a consequence of the fact that the ax0 interface was re-opened uninitialized while the corresponding serial device is no longer connected to the system. I don’t see any rational to create this bogus interface: the serial device is gone.

I also tried 6pack, and the traditional slip interface. The same thing happens - device reappears.

I don’t think there’s a good reason for this, because after reinitialization, the iface is down, ip address and routes over it have disappeard. Thus it’s even not usable anymore as not-active-dummy-interface for ip/routes.

I’ve not tested ppp and possible other line-based protocols - but I assume they’ve all the same issue, and nobody noticed before. Anyone likes to track down ppp’s behavior?

Do we have a way to determine if the interface was re-initialized by the ldisc handler? Then we (and any other line based driver) could try to check in the .open call and decide what to do.
But imho, it would always may cause problems when people write new drivers and oversee the not obvious situation where devices may reappear. The default should be not to call open again.

I also wonder why userspace processes like kissattach do not get a signal by the kernel, indicating that the filedescriptor is not valid anymore.
Who’s job would it be to signal, the serial driver’s (slip, ppp, mkiss, ..), or ldisc’s?

>> I don't see a problem with the ACM tty/tty core side of this.
>> 
>> At the time the hangup occurs, there is actually still an ACM tty device.
> 
> Not physically, sorry. The physical serial device was unplugged front the system (or in hardware forced reset in the case of my test), causing a USB disconnect. It's important to understand that the USB disconnect has already occurred seconds before the crash. The fact that there is still an ACM tty structure in the kernel corresponding to nothing real is the cause of the problem.
> 
>> The line discipline is reinited as a security precaution to prevent a previous
>> session's data from being visible in the new session.
> 
> Pragmatically reinited to N_TTY is ok, this is in fact how my proposed patches work. But reinited to N_AX25 while the serial device is no more have no sense at all and cause the crash when the new uninitialized parasitic interface try to send a packet.
> 
>>  The tty core does not know
>> at the time the vhangup() occurs that the ACM driver plans to unregister the
>> tty device.
> 
> That’s the root problem: It must a least known that it must not call mkiss_open().

Or at least mkiss_open() must have a way to dectect that a re-open was initiated.
But as said, I’d prefer it would not happen, because otherwise it depends on every serial protocol driver to implement it correctly.

> That's the bug that must be fixed. Or maybe the option e) fix must be developed.
> 
>> Don't do any of the things you suggest above.
>> 
> 
> Can I ask what did you suggest to solve the problem ? The bug is real, causing a kernel panic and complete crash of the system, requiring a hardware reset to reboot.
> 
> Best Regards,
> Jean-Christian de Rivaz

vy 73,
	- Thomas  dl9sau--
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