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-next>] [day] [month] [year] [list]
Date:   Fri, 11 Nov 2016 16:32:17 +0100
From:   Yves-Alexis Perez <corsac@...sac.net>
To:     linux-kernel@...r.kernel.org
Cc:     johannes@...solutions.net, j@...fi, jslaby@...e.com, teg@...m.no,
        kay@...y.org, jwboyer@...oraproject.org, dmitry.torokhov@...il.com,
        luto@...capital.net, harald@...hat.com, seth.forshee@...onical.com,
        wagi@...om.org, Yves-Alexis Perez <corsac@...sac.net>,
        "Luis R . Rodriguez" <mcgrof@...nel.org>,
        Ming Lei <ming.lei@...onical.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        stable@...r.kernel.org
Subject: [PATCH v2] firmware: fix async, manual firmware loading

When wait_for_completion_interruptible_timeout() is called from
_request_firmware_load() with a large timeout value (here, MAX_JIFFY_OFFSET
because it's a an explicit call to the user helper), its return value (a
long) will overflow when silently casted to int, be stored as a negative
integer and then treated as an error.

This bug was introduced in commit 68ff2a00dbf5 ("firmware_loader: handle
timeout via wait_for_completion_interruptible_timeout()") when a delay work
was replaced by the call to wait_for_completion_interruptible_timeout().

Fix this by re-using the timeout variable and only set retval in specific
cases.

Signed-off-by: Yves-Alexis Perez <corsac@...sac.net>
Fixes: 68ff2a00dbf5 "firmware_loader: handle timeout via wait_for_completion_interruptible_timeout()"
Cc: Luis R. Rodriguez <mcgrof@...nel.org>
Cc: Ming Lei <ming.lei@...onical.com>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: stable@...r.kernel.org
Acked-by: Luis R. Rodriguez <mcgrof@...nel.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@...aro.org>
---
Changelog:

  v2: rewrite the changelog following comments by Luis

 drivers/base/firmware_class.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 22d1760..a95e1e5 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -955,13 +955,14 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
 		timeout = MAX_JIFFY_OFFSET;
 	}
 
-	retval = wait_for_completion_interruptible_timeout(&buf->completion,
+	timeout = wait_for_completion_interruptible_timeout(&buf->completion,
 			timeout);
-	if (retval == -ERESTARTSYS || !retval) {
+	if (timeout == -ERESTARTSYS || !timeout) {
+		retval = timeout;
 		mutex_lock(&fw_lock);
 		fw_load_abort(fw_priv);
 		mutex_unlock(&fw_lock);
-	} else if (retval > 0) {
+	} else if (timeout > 0) {
 		retval = 0;
 	}
 
-- 
2.10.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ