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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Dec 2021 10:42:28 +0800
From:   Ryan Cai <ycaibb@...il.com>
To:     Namhyung Kim <namhyung@...nel.org>
CC:     Adrian Hunter <adrian.hunter@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: Lock problems in linux/tools/perf/util/dso.c

Hi, Namhyung,

1. Indeed, I got wrong here.
2. Yes, the branch should be if (pthread_mutex_lock(&dso__data_open_lock)) 
instead of if (pthread_mutex_lock(&dso__data_open_lock) < 0).

Could I send a patch?

Best,
Ryan

On 30/12/2021, 3:08 AM, "Namhyung Kim" <namhyung@...nel.org> wrote:

    Hello,

    On Wed, Dec 22, 2021 at 3:33 AM Ryan Cai <ycaibb@...il.com> wrote:
    >
    > Hi, I found a potential lock problem in dso_data_get_fd. Because the inconsistent branch conditions of pthread_mutex_lock(&dso__data_open_lock) and pthread_mutex_unlock(&dso__data_open_lock), it is possible that the lock dso__data_open_lock is not released in the dso_data_get_fd. Also, I have a question on why the branch condition of pthread_mutex_lock(&dso__data_open_lock) is <0. I think that the branch condition should be !=0, because pthread_mutex_lock would return 0 when succeeding. Looking forward to further discussion. One this bug is confirmed, I can send a patch.

    Please fix your mail client to wrap around 80 characters.

    1. dso__data_get_fd() should be paired with dso__data_put_fd()
       when it returns non-negative.  It'd unlock the mutex.

    2. I've checked the man page and it seems you're right.
       It just says that it'd return an error number or zero.

       https://linux.die.net/man/3/pthread_mutex_lock

    Thanks,
    Namhyung


    >
    >
    >
    > https://github.com/torvalds/linux/blob/e851dfae4371d3c751f1e18e8eb5eba993de1467/tools/perf/util/dso.c#L708-L722
    >
    >
    >
    > Best,
    >
    > Ryan
    >
    >
    >
    >


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ