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] [day] [month] [year] [list]
Date:   Wed, 1 Sep 2021 05:19:53 +0000
From:   CAI Yuandao <ycaibb@....ust.hk>
To:     Jiri Olsa <jolsa@...hat.com>
CC:     "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "acme@...nel.org" <acme@...nel.org>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "alexander.shishkin@...ux.intel.com" 
        <alexander.shishkin@...ux.intel.com>,
        "namhyung@...nel.org" <namhyung@...nel.org>,
        "linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        叶澄锋 <dg573847474@...il.com>
Subject: Re: Possible deadlock errors in tools/perf/builtin-sched.c

Hi Jirka,

        They were found by our static code analyzer and manually checked as true positives by us. Are they real bugs?

Best,
Ryan

On 1/9/2021, 2:46 AM, "Jiri Olsa" <jolsa@...hat.com> wrote:

    On Sat, Aug 28, 2021 at 03:57:17PM +0800, 叶澄锋 wrote:
    > Dear developers:
    > 
    > Thank you for your checking.
    > 
    > It seems there are two deadlock errors on the lock
    > *sched->work_done_wait_mutex*and*sched->start_work_mutex.*
    > 
    > They are triggered due to one thread(A) runs function *run_one_test* locating
    > in a loop and unreleasing the two locks in the*wait_for_tasks*function, and
    > another thread(B) runs function *thread_func *acquiring the two locks.
    > 
    > Because the two locks are not properly released in thread A, there will be
    > a  deadlock problem if thread B acquires the two locks.

    hi,
    do you have a way to reproduce this?

    thanks,
    jirka

    > 
    > The related codes are below:
    > 
    > Thread A:
    > 
    > static void create_tasks(struct perf_sched *sched)
    > {
    >      ...;
    >   err = pthread_mutex_lock(&sched->start_work_mutex);
    >     ...;
    >  err = pthread_mutex_lock(&sched->work_done_wait_mutex);
    >        ...;
    > }
    > static int perf_sched__replay(struct perf_sched *sched)
    > {
    >    ...;
    > 
    >         create_tasks(sched);
    >      printf("------------------------------------------------------------\n");
    >      for (i = 0; i < sched->replay_repeat; i++)
    >           run_one_test(sched);   // multiple reacquisition on the lock
    > sched->work_done_wait_mutex and sched->start_work_mutex
    > 
    >    return 0;
    > }
    > 
    > static void run_one_test(struct perf_sched *sched)
    > {
    >  ...;
    >       wait_for_tasks(sched);
    >         ...;
    > }
    > static void wait_for_tasks(struct perf_sched *sched)
    > {
    >        ...;
    >     pthread_mutex_unlock(&sched->work_done_wait_mutex);
    > 
    >   ...;
    >        ret = pthread_mutex_lock(&sched->work_done_wait_mutex);
    >      ...;
    >   pthread_mutex_unlock(&sched->start_work_mutex);
    > 
    >     ...;
    > 
    >  ret = pthread_mutex_lock(&sched->start_work_mutex);
    >    ....;
    > }
    > 
    > Thread B:
    > 
    > static void *thread_func(void *ctx)
    > {
    > 
    > ...;
    > ret = pthread_mutex_lock(&sched->start_work_mutex);
    > ...;
    > ret = pthread_mutex_unlock(&sched->start_work_mutex);
    > 
    > ...;
    > 
    > ret = pthread_mutex_lock(&sched->work_done_wait_mutex);
    > ...;
    > ret = pthread_mutex_unlock(&sched->work_done_wait_mutex);
    > ..;
    > 
    > }
    > 
    > 
    > Thanks,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ