Page MenuHomeFreeBSD

tunefs: Better fix for arm64 alignment issues
Needs ReviewPublic

Authored by des on Fri, Apr 3, 5:11 PM.

Details

Summary

Rather than trust that the compiler will lay out the stack frame the
way we expect it to, use a union to force the correct alignment.

MFC after: 1 week
Fixes: 616f47f176c3 ("tunefs: Fix alignment warning on arm64")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71947
Build 68830: arc lint + arc unit

Event Timeline

des requested review of this revision.Fri, Apr 3, 5:11 PM

If __aligned(sizeof(max_aljgn_t)) or some variant works on stack buffers, that seems like a reasonable solution for these as well

sbin/tunefs/tunefs.c
643

Applies here as well, no?

731

And here

You could also do something similar with the directory filling routine dir_clear_block() and the two functions that call it dir_insert() and dir_extend().

sbin/tunefs/tunefs.c
643

Here we're adding a variable offset to the pointer before casting, we should assert that alignment is preserved but the union trick won't help us, and in fact a corrupt or manipulated file system can cause us to perform an unaligned read.

731

Here we add a caller-provided offset to the pointer before casting, we should assert that alignment is preserved but the union trick won't help us.