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: <1496216516-16324-1-git-send-email-baijiaju1990@163.com>
Date:   Wed, 31 May 2017 15:41:56 +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_wi_exit

The driver may sleep under a spin lock, and the function call path is:
cfs_wi_exit (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/workitem.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c
index dbc2a9b..cef25c8 100644
--- a/drivers/staging/lustre/lnet/libcfs/workitem.c
+++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
@@ -111,20 +111,20 @@ struct cfs_wi_sched {
 {
 	LASSERT(!in_interrupt()); /* because we use plain spinlock */
 	LASSERT(!sched->ws_stopping);
+	LASSERT(wi->wi_running);
+	if (wi->wi_scheduled) {
+		LASSERT(!list_empty(&wi->wi_list));
+		LASSERT(sched->ws_nscheduled > 0);
+	}
+	LASSERT(list_empty(&wi->wi_list));
 
 	spin_lock(&sched->ws_lock);
 
-	LASSERT(wi->wi_running);
 	if (wi->wi_scheduled) { /* cancel pending schedules */
-		LASSERT(!list_empty(&wi->wi_list));
 		list_del_init(&wi->wi_list);
-
-		LASSERT(sched->ws_nscheduled > 0);
 		sched->ws_nscheduled--;
 	}
 
-	LASSERT(list_empty(&wi->wi_list));
-
 	wi->wi_scheduled = 1; /* LBUG future schedule attempts */
 	spin_unlock(&sched->ws_lock);
 }
-- 
1.7.9.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ