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] [day] [month] [year] [list]
Date:   Mon, 17 Oct 2016 23:52:41 +0200
From:   Pavel Machek <pavel@....cz>
To:     ifaenson@...adcom.com, marcel@...tmann.org,
        kernel list <linux-kernel@...r.kernel.org>,
        gustavo@...ovan.org, johan.hedberg@...il.com,
        linux-bluetooth@...r.kernel.org, sre@...nel.org
Subject: Re: hci_ldisc: suspicious/buggy code

On Mon 2016-10-17 23:32:06, Pavel Machek wrote:
> Hi!
> 
> hci_uart_set_flow_control() contains some rather suspicious
> code. AFAICT:
> 
> set = 0.
> 
> Then we do set &= (magic constant). But as set is 0, it stays zero. It
> just does not make sense. [Nor does it make sense to do |= on known
> value of zero just after else. But that's probably just some artifact
> of editing.]
> 
> (And if you edit the code anyway, temporary variable to store
> TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 | TIOCM_OUT2 | TIOCM_LOOP would
> make sense.)

I think this might be the fix, but it breaks h4p protocol on n900...

  	     	      	       	      	     	 	  Pavel

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 0506806..b549c47 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -271,8 +271,8 @@ void hci_uart_set_rts(struct hci_uart *hu, bool enable)
 		status = tty->driver->ops->tiocmget(tty);
 		BT_DBG("Current tiocm 0x%x", status);
 
-		set &= ~(TIOCM_OUT2 | TIOCM_RTS);
-		clear = ~set;
+		clear |= (TIOCM_OUT2 | TIOCM_RTS);
+		set = ~clear;
 		set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
 		       TIOCM_OUT2 | TIOCM_LOOP;
 		clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |

> /* Flow control or un-flow control the device */
> void hci_uart_set_flow_control(struct hci_uart *hu, bool enable)
> {
> 	...
> 	unsigned int set = 0;
> 	unsigned int clear = 0;
> 
> 	if (enable) {
> 	   	...
> 		set &= ~(TIOCM_OUT2 | TIOCM_RTS);
> 		clear = ~set;
> 		set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> 		       TIOCM_OUT2 | TIOCM_LOOP;
> 		clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> 			 TIOCM_OUT2 | TIOCM_LOOP;
> 		status = tty->driver->ops->tiocmset(tty, set, clear);
> 		BT_DBG("Clearing RTS: %s", status ? "failed" : "success");
> 	} else {
> 	       ...	
> 		set |= (TIOCM_OUT2 | TIOCM_RTS);
> 



-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ