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>] [day] [month] [year] [list]
Message-Id: <1496218729-17992-1-git-send-email-baijiaju1990@163.com>
Date:   Wed, 31 May 2017 16:18:49 +0800
From:   Jia-Ju Bai <baijiaju1990@....com>
To:     oleg.drokin@...el.com, andreas.dilger@...el.com,
        jsimmons@...radead.org, gregkh@...uxfoundation.org,
        bobijam.xu@...el.com, dmitry.eremin@...el.com
Cc:     lustre-devel@...ts.lustre.org, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org, Jia-Ju Bai <baijiaju1990@....com>
Subject: [PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_percpt_lock and cfs_percpt_unlock

The driver may sleep under a spin lock, and the function call path is:
cfs_percpt_lock/cfs_percpt_unlock (acquire the lock by spin_lock)
  LASSERT
    lbug_with_loc
      libcfs_debug_dumplog
        schedule and kthread_run --> may sleep

To fix it, all "LASSERT" is placed out of the spin_lock and spin_unlock.

Signed-off-by: Jia-Ju Bai <baijiaju1990@....com>
---
 drivers/staging/lustre/lnet/libcfs/libcfs_lock.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
index 1967b97c..a2ce092f 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_lock.c
@@ -113,9 +113,10 @@ struct cfs_percpt_lock *
 
 	/* exclusive lock request */
 	for (i = 0; i < ncpt; i++) {
+		if (!i)
+			LASSERT(!pcl->pcl_locked);
 		spin_lock(pcl->pcl_locks[i]);
 		if (!i) {
-			LASSERT(!pcl->pcl_locked);
 			/* nobody should take private lock after this
 			 * so I wouldn't starve for too long time
 			 */
@@ -141,11 +142,11 @@ struct cfs_percpt_lock *
 	}
 
 	for (i = ncpt - 1; i >= 0; i--) {
-		if (!i) {
-			LASSERT(pcl->pcl_locked);
+		if (!i)
 			pcl->pcl_locked = 0;
-		}
 		spin_unlock(pcl->pcl_locks[i]);
+		if (!i)
+			LASSERT(pcl->pcl_locked);
 	}
 }
 EXPORT_SYMBOL(cfs_percpt_unlock);
-- 
1.7.9.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ