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:	Mon, 03 Nov 2014 10:05:21 +0000
From:	Daniel Thompson <daniel.thompson@...aro.org>
To:	frowand.list@...il.com
CC:	Stephen Boyd <sboyd@...eaurora.org>, linux-serial@...r.kernel.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org,
	Frank Rowand <frank.rowand@...ymobile.com>,
	linux-arm-msm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 2/2] tty: serial: msm: Support sysrq on uartDM devices

On 31/10/14 18:08, Frank Rowand wrote:
> On 10/31/2014 2:43 AM, Daniel Thompson wrote:
>> On 31/10/14 06:41, Stephen Boyd wrote:
>>> On 10/30, Daniel Thompson wrote:
>>>> On 29/10/14 18:14, Stephen Boyd wrote:
>>>>> +		r_count = min_t(int, count, sizeof(buf));
>>>>> +
>>>>> +		for (i = 0; i < r_count; i++) {
>>>>> +			char flag = TTY_NORMAL;
>>>>>  
>>>>> -		/* TODO: handle sysrq */
>>>>> -		tty_insert_flip_string(tport, buf, min(count, 4));
>>>>> -		count -= 4;
>>>>> +			if (msm_port->break_detected && buf[i] == 0) {
>>>>> +				port->icount.brk++;
>>>>> +				flag = TTY_BREAK;
>>>>> +				msm_port->break_detected = false;
>>>>> +				if (uart_handle_break(port))
>>>>> +					continue;
>>>>> +			}
>>>>> +
>>>>> +			if (!(port->read_status_mask & UART_SR_RX_BREAK))
>>>>> +				flag = TTY_NORMAL;
>>>>
>>>> flag is already known to be TTY_NORMAL.
>>>
>>> Huh? If we detected a break we would set the flag to TTY_BREAK
>>> and if uart_handle_break() returned 0 (perhaps sysrq config is
>>> diasbled) then we would get down here, and then we want to reset
>>> the flag to TTY_NORMAL if the read_status_mask bits indicate that
>>> we want to skip checking for breaks. Otherwise we want to
>>> indicate to the tty layer that it's a break character.
>>
>> Agreed. Sorry for noise.
>>
>> It now reaches the level of silly quibble (meaning I won't bother to
>> raise the issue again if there is a v2 patch) but perhaps updating the
>> flag after the continue would be easier to read.
>>
>>
>>>>> +
>>>>> +			spin_unlock(&port->lock);
>>>>
>>>> Is it safe to unlock at this point? count may no longer be valid when we
>>>> return.
>>>
>>> Can you explain further? If it actually isn't valid something
>>> needs to be done. I believe other serial drivers are doing this
>>> sort of thing though so it doesn't seem that uncommon (of course
>>> those drivers could also be broken I suppose).
>>
>> Calling spin_unlock() means we are allow code to alter the state of the
>> UART. In particular the subsequent call to uart_handle_sysrq_char() can
>> make significant changes to the FIFO state (by calling the poll_char
>> functions). Given count is shadowing the FIFO state, when we retake the
>> lock I think it is possible for count to no longer be valid.
> 
> uart_handle_sysrq_char() will not _read_ from the serial port.  So it will
> not directly modify the FIFO state.

poll_char does not read from the FIFO? Since when?

SysRq-g will enter cause the system to enter kdb/kgdb from within
uart_handle_sysrq_char().


--
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