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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 24 Jan 2020 20:12:20 +0000
From:   Jules Irenge <jbi.octave@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     boqun.feng@...il.com, Jules Irenge <jbi.octave@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] mutex: Add missing annotations

Sparse reports false warnings and hide real warnings
where mutex_lock() and mutex_unlock() are used within the kernel
An example is within the kernel cgroup files
where the below warnings are found
|warning: context imbalance in cgroup_lock_and_drain_offline()
| - wrong count at exit
|warning: context imbalance in cgroup_procs_write_finish()
|- wrong count at exit
|warning: context imbalance in cgroup_procs_write_start()
|- wrong count at exit.

To fix these,
an __acquires(lock) is added to mutex_lock() declaration
a __releases(lock) to mutex_unlock() declaration

Signed-off-by: Jules Irenge <jbi.octave@...il.com>
---
 include/linux/mutex.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index aca8f36dfac9..a8ab4029913e 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -162,7 +162,7 @@ do {									\
 } while (0)
 
 #else
-extern void mutex_lock(struct mutex *lock);
+extern void mutex_lock(struct mutex *lock) __acquires(lock);
 extern int __must_check mutex_lock_interruptible(struct mutex *lock);
 extern int __must_check mutex_lock_killable(struct mutex *lock);
 extern void mutex_lock_io(struct mutex *lock);
@@ -181,7 +181,7 @@ extern void mutex_lock_io(struct mutex *lock);
  * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
  */
 extern int mutex_trylock(struct mutex *lock);
-extern void mutex_unlock(struct mutex *lock);
+extern void mutex_unlock(struct mutex *lock) __releases(lock);
 
 extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
 
-- 
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ