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]
Message-ID: <YOq19zTsOzKA8v7c@shinobu>
Date:   Sun, 11 Jul 2021 18:12:23 +0900
From:   William Breathitt Gray <vilhelm.gray@...il.com>
To:     David Lechner <david@...hnology.com>
Cc:     Jarkko Nikula <jarkko.nikula@...ux.intel.com>, jic23@...nel.org,
        linux-stm32@...md-mailman.stormreply.com, kernel@...gutronix.de,
        a.fatoum@...gutronix.de, kamel.bouhara@...tlin.com,
        gwendal@...omium.org, alexandre.belloni@...tlin.com,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, syednwaris@...il.com,
        patrick.havelange@...ensium.com, fabrice.gasnier@...com,
        mcoquelin.stm32@...il.com, alexandre.torgue@...com,
        o.rempel@...gutronix.de
Subject: Re: [PATCH v12 15/17] counter: Implement events_queue_size sysfs
 attribute

On Sat, Jul 10, 2021 at 10:43:22AM -0500, David Lechner wrote:
> On 7/10/21 5:25 AM, William Breathitt Gray wrote:
> >> and after that
> >>
> >> [   16.564403] ================================================
> >> [   16.570725] WARNING: lock held when returning to user space!
> >> [   16.577044] 5.13.0-next-20210706+ #4 Not tainted
> >> [   16.582198] ------------------------------------------------
> >> [   16.588507] cat/331 is leaving the kernel with locks still held!
> >> [   16.595214] 1 lock held by cat/331:
> >> [   16.599103]  #0: ffff888102bb3630
> >> (&counter->chrdev_lock){+.+.}-{3:3}, at: counter_chrdev_open+0x21/0x60
> >> [counter]
> >>
> >> Jarkko
> > I'm not sure how to resolve this warning. The purpose of this lock is to
> > limit chrdev to a single open at a time. To accomplish this I grab this
> > lock in counter_chrdev_open() and hold it until counter_chrdev_release()
> > is called. Is there a better way to accomplish this?
> 
> How about using an atomic flag, e.g test_and_set_bit()?

Yes, I think this might work: atomically test and set the bit to lock
and atomically clear it to unlock. I'll replace the mutex with an atomic
flag.

By the way, what is the difference between test_and_set_bit() and
test_and_set_bit_lock()?

William Breathitt Gray

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ