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
| ||
|
Message-ID: <20221003214501.2050087-12-connoro@google.com> Date: Mon, 3 Oct 2022 21:45:01 +0000 From: "Connor O'Brien" <connoro@...gle.com> To: linux-kernel@...r.kernel.org Cc: kernel-team@...roid.com, John Stultz <jstultz@...gle.com>, Joel Fernandes <joelaf@...gle.com>, Qais Yousef <qais.yousef@....com>, Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>, Juri Lelli <juri.lelli@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>, Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>, Daniel Bristot de Oliveira <bristot@...hat.com>, Valentin Schneider <vschneid@...hat.com>, Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>, "Paul E . McKenney" <paulmck@...nel.org>, "Connor O'Brien" <connoro@...gle.com> Subject: [RFC PATCH 11/11] locktorture: support nested mutexes Quick hack to better surface bugs in proxy execution. The single lock used by locktorture does not reliably exercise proxy exec code paths for handling chains of blocked tasks involving >1 mutex. Add 2 more mutexes and randomize whether they are taken. Signed-off-by: Connor O'Brien <connoro@...gle.com> --- kernel/locking/locktorture.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index 9c2fb613a55d..bc3557677eed 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -48,6 +48,8 @@ torture_param(int, stat_interval, 60, torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable"); torture_param(int, verbose, 1, "Enable verbose debugging printk()s"); +torture_param(int, nlocks, 1, + "Number of locks"); static char *torture_type = "spin_lock"; module_param(torture_type, charp, 0444); @@ -327,6 +329,8 @@ static struct lock_torture_ops rw_lock_irq_ops = { }; static DEFINE_MUTEX(torture_mutex); +static DEFINE_MUTEX(torture_mutex2); +static DEFINE_MUTEX(torture_mutex3); static int torture_mutex_lock(int tid __maybe_unused) __acquires(torture_mutex) @@ -666,6 +670,7 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = { */ static int lock_torture_writer(void *arg) { + bool twolocks = false, threelocks = false; struct lock_stress_stats *lwsp = arg; int tid = lwsp - cxt.lwsa; DEFINE_TORTURE_RANDOM(rand); @@ -677,6 +682,12 @@ static int lock_torture_writer(void *arg) if ((torture_random(&rand) & 0xfffff) == 0) schedule_timeout_uninterruptible(1); + twolocks = nlocks > 1 ? (torture_random(&rand) & 0x1) : 0; + if (twolocks) + mutex_lock(&torture_mutex2); + threelocks = nlocks > 2 ? (torture_random(&rand) & 0x2) : 0; + if (threelocks) + mutex_lock(&torture_mutex3); cxt.cur_ops->task_boost(&rand); cxt.cur_ops->writelock(tid); if (WARN_ON_ONCE(lock_is_write_held)) @@ -691,6 +702,11 @@ static int lock_torture_writer(void *arg) WRITE_ONCE(last_lock_release, jiffies); cxt.cur_ops->writeunlock(tid); + if (threelocks) + mutex_unlock(&torture_mutex3); + if (twolocks) + mutex_unlock(&torture_mutex2); + stutter_wait("lock_torture_writer"); } while (!torture_must_stop()); @@ -830,11 +846,11 @@ lock_torture_print_module_parms(struct lock_torture_ops *cur_ops, const char *tag) { pr_alert("%s" TORTURE_FLAG - "--- %s%s: nwriters_stress=%d nreaders_stress=%d stat_interval=%d verbose=%d shuffle_interval=%d stutter=%d shutdown_secs=%d onoff_interval=%d onoff_holdoff=%d\n", + "--- %s%s: nwriters_stress=%d nreaders_stress=%d stat_interval=%d verbose=%d shuffle_interval=%d stutter=%d shutdown_secs=%d onoff_interval=%d onoff_holdoff=%d nlocks=%d\n", torture_type, tag, cxt.debug_lock ? " [debug]": "", cxt.nrealwriters_stress, cxt.nrealreaders_stress, stat_interval, verbose, shuffle_interval, stutter, shutdown_secs, - onoff_interval, onoff_holdoff); + onoff_interval, onoff_holdoff, nlocks); } static void lock_torture_cleanup(void) -- 2.38.0.rc1.362.ged0d419d3c-goog
Powered by blists - more mailing lists