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:   Fri, 4 Jan 2019 19:23:14 +0900
From:   Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
To:     Paul Fulghum <paulkf@...rogate.com>
Cc:     Jiri Slaby <jslaby@...e.cz>, Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alan Cox <alan@...rguk.ukuu.org.uk>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty/n_hdlc: fix sleep in !TASK_RUNNING state warning

On 2019/01/04 0:57, Paul Fulghum wrote:
>> On Jan 3, 2019, at 3:32 AM, Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp> wrote:
>>
>> On 2019/01/03 18:09, Jiri Slaby wrote:
>>> On 02. 01. 19, 16:04, Tetsuo Handa wrote:
>>>> +	if (wait_event_interruptible(tty->read_wait,
>>>> +	     (ret = -EIO, test_bit(TTY_OTHER_CLOSED, &tty->flags)) ||
>>>> +	     (ret = 0, tty_hung_up_p(file)) ||
>>>> +	     (rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list)) != NULL ||
>>>> +	     (ret = -EAGAIN, tty_io_nonblock(tty, file))))
>>>> +		return -EINTR;
>>>
>>> Oh, that looks really ugly. Could you move all this to a function
>>> returning a bool and taking &ret and &rbuf as parameters?
>>>
>>
>> OK. Something like this?
> 
> 
> I agree with Jiri that placing all the conditional logic in a single expression is difficult to read.
> 
> But exchanging that many locals with a separate function defeats the original purpose of
> simplifying code and this implementation changes the logic (write no
> longer checks for line discipline changing under it during wait).

Not only defeating the original purpose but also increasing object size.

> 
> Converting to wait_event_interruptible where possible is a good goal but this instance
> may be better left alone. The current structure mirrors the existing n_tty line discipline.

But why not to clarify what are appropriate sanity checks?

Currently, read side does not check "n_hdlc->magic != HDLC_MAGIC" case
while write side does. If it is intended for catching memory corruption
etc. then both sides should do the same thing.

Currently, write side does not check "tty != n_hdlc->tty" case before
schedule() while does after schedule(). If "tty != n_hdlc->tty" case
can ever happen, what prevents n_hdlc_tty_write() from being called again
after n_hdlc_tty_write() once returned with -EIO due to "tty != n_hdlc->tty"
case? If it is intended for catching memory corruption etc. then both
sides should check "tty != n_hdlc->tty" case.

Current logic is unclear, in addition to want a cleanup for scripts/checkpatch.pl .

  total: 158 errors, 95 warnings, 994 lines checked

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ