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, 18 Mar 2022 17:51:36 +0800
From:   Shengjiu Wang <shengjiu.wang@....com>
To:     bjorn.andersson@...aro.org, mathieu.poirier@...aro.org
Cc:     linux-remoteproc@...r.kernel.org, linux-kernel@...r.kernel.org,
        shengjiu.wang@...il.com
Subject: [PATCH] remoteproc: core: check rproc->power value before decreasing it

There are possibility that two 'stop' operation happen
in parallel, then the rproc->power may be decreased to
-1, that this reference count will be in wrong state.
So check rproc->power to make sure it is larger than
zero before decreasing it.

Signed-off-by: Shengjiu Wang <shengjiu.wang@....com>
---
 drivers/remoteproc/remoteproc_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c510125769b9..84e065ad8743 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2075,6 +2075,9 @@ int rproc_shutdown(struct rproc *rproc)
 		return ret;
 	}
 
+	if (atomic_read(&rproc->power) <= 0)
+		goto out;
+
 	/* if the remote proc is still needed, bail out */
 	if (!atomic_dec_and_test(&rproc->power))
 		goto out;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ