Bug 13134 - Padding/alignment of PAC elements is done wrong on Samba KDCs
Summary: Padding/alignment of PAC elements is done wrong on Samba KDCs
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.7.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Stefan Metzmacher
QA Contact: Samba QA Contact
Depends on:
Reported: 2017-11-14 15:09 UTC by Stefan Metzmacher
Modified: 2021-11-03 12:06 UTC (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Metzmacher 2017-11-14 15:09:20 UTC
The size of PAC_TYPE_LOGON_INFO and PAC_TYPE_UPN_DNS_INFO elements is supposed
to be padded to an 8 byte boundary...
Comment 1 Amit Kumar 2019-06-03 10:44:33 UTC
(In reply to Stefan Metzmacher from comment #0)
My understanding about alignment:
- I think current processors are bit smart and they can handle the unaligned memory but in some bad situation, the processor takes some extra cycles to fetch the unaligned memory. So it would be good for coder to care about alignment when he writes the code.
- Padding increases the performance of the processor at the penalty of memory.
- For structure, union wastage of memory can be saved by rearranging members in the order of largest size to smallest.

- But wont custom struct member alignment cause compatibility issues, for linking external library using different packing alignments?

__attribute__ ((aligned (8)))

Your thoughts
Comment 2 Björn Jacke 2020-12-02 13:51:54 UTC
the alligned attribute might not be supported by all compilers. gcc supports it, xlc also supports it obviously. The studio compiler docs however say, that it will only issue a warning:

    Roughly equivalent to #pragma align. Generates a warning and is ignored if used on variable length arrays

The documentation of the "pragma align" says that this will fix alignment:

We'd need to make configure tests for alignment fixing capablities of the compiler.
Comment 3 Stefan Metzmacher 2020-12-02 13:59:35 UTC
(In reply to Björn Jacke from comment #2)
This bug has absolutely nothing to do with compilers nor the memory representation
of structs...
Comment 4 Stefan Metzmacher 2021-11-03 12:06:26 UTC
I guess it's fixed in 4.15.1, 4.14.9, 4.13.13 by this commit

commit 28a5a586c8e9cd155d676dcfcb81a2587ace99d1
Author:     Joseph Sutton <josephsutton@catalyst.net.nz>
AuthorDate: Wed Aug 11 13:27:11 2021 +1200
Commit:     Andrew Bartlett <abartlet@samba.org>
CommitDate: Thu Oct 14 18:59:31 2021 +0000

    s4/heimdal/lib/krb5/pac.c: Align PAC buffers to match Windows
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642
    Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet@samba.org>

We just need to remember that the rule may also apply to