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] [day] [month] [year] [list]
Message-ID: <20250513224229.78c95926@pumpkin>
Date: Tue, 13 May 2025 22:42:29 +0100
From: David Laight <david.laight.linux@...il.com>
To: Heiner Kallweit <hkallweit1@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Greg Kroah-Hartman
 <gregkh@...uxfoundation.org>, Ingo Molnar <mingo@...nel.org>, Linux Kernel
 Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: Documentation of locking needs when working with lists?

On Sat, 10 May 2025 10:46:32 +0200
Heiner Kallweit <hkallweit1@...il.com> wrote:

> Even though lists are used everywhere, I was surprised not being able to find
> documentation about which operations need locking, and which ones are safe
> lock-less.
> 
> My case:
> I have a list where the only operation is adding entries.
> It's clear that adding entries has to be serialized.
> Question is whether a list_for_each_entry is safe lock-less.
> 
> Looking at the code I *think* it's safe, under the precondition that
> reading/writing pointers is atomic.
> 
> Any hint or documentation link would be appreciated. Thanks!
> 

Well, somewhere you must have code that destroys the list.
That must be locked against anything that traverses it ...

But if you have a singly linked list and keep a pointer to the last
entry in order to append entries then the list traversal code wont
explode.

However, on many architectures, you need memory sequencing instructions
to guarantee the list traversal code reads the expected contents of
newly added (or any other recently changed) items.
Read up on the semantics acquire and release operations.
Locks will give the required guarantee.

Most lockless lists in the kernel use 'rcu'.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ