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: <4e7e7292-338d-4a57-84ec-ae7427f6ad7c@linux.dev>
Date: Mon, 25 Aug 2025 15:46:42 +0800
From: Lance Yang <lance.yang@...ux.dev>
To: Finn Thain <fthain@...ux-m68k.org>
Cc: akpm@...ux-foundation.org, geert@...ux-m68k.org,
 linux-kernel@...r.kernel.org, mhiramat@...nel.org, oak@...sinkinet.fi,
 peterz@...radead.org, stable@...r.kernel.org, will@...nel.org,
 Lance Yang <ioworker0@...il.com>
Subject: Re: [PATCH] atomic: Specify natural alignment for atomic_t



On 2025/8/25 14:17, Finn Thain wrote:
> 
> On Mon, 25 Aug 2025, Lance Yang wrote:
> 
>>
>> What if we squash the runtime check fix into your patch?
> 
> Did my patch not solve the problem?

Hmm... it should solve the problem for natural alignment, which is a
critical fix.

But it cannot solve the problem of forced misalignment from drivers using
#pragma pack(1). The runtime warning will still trigger in those cases.

I built a simple test module on a kernel with your patch applied:

```
#include <linux/module.h>
#include <linux/init.h>

struct __attribute__((packed)) test_container {
     char padding[49];
     struct mutex io_lock;
};

static int __init alignment_init(void)
{
     struct test_container cont;
     pr_info("io_lock address offset mod 4: %lu\n", (unsigned 
long)&cont.io_lock % 4);
     return 0;
}

static void __exit alignment_exit(void)
{
     pr_info("Module unloaded\n");
}

module_init(alignment_init);
module_exit(alignment_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("x");
MODULE_DESCRIPTION("x");
```

Result from dmesg:
[Mon Aug 25 15:44:50 2025] io_lock address offset mod 4: 1

As we can see, a packed struct can still force the entire mutex object
to an unaligned address. With an address like this, the WARN_ON_ONCE
can still be triggered.

That's why I proposed squashing the runtime check fix into your patch.
Then it can be cleanly backported to stop all the spurious warnings at
once.

I hope this clarifies things.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ