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, 18 Mar 2019 10:27:36 +0100
From:   Mariusz Bialonczyk <manio@...boo.net>
To:     linux-kernel@...r.kernel.org, Evgeniy Polyakov <zbr@...emap.net>,
        Greg Kroah-Hartman <greg@...ah.com>,
        Jean-Francois Dagenais <jeff.dagenais@...il.com>
Cc:     Mariusz Bialonczyk <manio@...boo.net>
Subject: [PATCH 1/2] w1: ds2408: add a missing reset when retrying in output_write()

When we have success in 'Channel Access Write' but reading back the latch
state has failed, then the code continues but without doing a proper
slave reset. This was leading to protocol errors as the slave treats
the next 'Channel Access Write' as the continuation of previous command.

This commit is fixing this, and because we have to reset no matter if
the actual write or the readback checking is failing then the resetting
is done on the beginning of the loop.

Signed-off-by: Mariusz Bialonczyk <manio@...boo.net>
Cc: Jean-Francois Dagenais <jeff.dagenais@...il.com>
---
 drivers/w1/slaves/w1_ds2408.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
index b535d5ec35b6..562ee2d861e8 100644
--- a/drivers/w1/slaves/w1_ds2408.c
+++ b/drivers/w1/slaves/w1_ds2408.c
@@ -158,6 +158,13 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj,
 		goto error;
 
 	while (retries--) {
+		/* do a reset/resume on every new retry call
+		   except the first one */
+		if (retries < W1_F29_RETRIES - 1) {
+			if (w1_reset_resume_command(sl->master))
+				goto error;
+		}
+
 		w1_buf[0] = W1_F29_FUNC_CHANN_ACCESS_WRITE;
 		w1_buf[1] = *buf;
 		w1_buf[2] = ~(*buf);
@@ -165,12 +172,8 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj,
 
 		readBack = w1_read_8(sl->master);
 
-		if (readBack != W1_F29_SUCCESS_CONFIRM_BYTE) {
-			if (w1_reset_resume_command(sl->master))
-				goto error;
-			/* try again, the slave is ready for a command */
+		if (readBack != W1_F29_SUCCESS_CONFIRM_BYTE)
 			continue;
-		}
 
 #ifdef CONFIG_W1_SLAVE_DS2408_READBACK
 		/* here the master could read another byte which
-- 
2.19.0.rc1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ