Re: git: f6ee1d20d368 - main - kern_thread: Fix i386 p_emuldata KBI assertion

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Sun, 01 Nov 2026 17:13:24 UTC
On 1 Nov 2026, at 16:26, Harry Schmalzbauer <freebsd@omnilan.de> wrote:
> On 2026-11-01 10:29, Harry Schmalzbauer wrote:
>> On 2026-07-13 05:03, Jessica Clarke wrote:
>>> The branch main has been updated by jrtc27:
>>> 
>>> URL: https://cgit.FreeBSD.org/src/commit/?id=f6ee1d20d36813e9906916f48cf06f44a2fd668d
>>> 
>>> commit f6ee1d20d36813e9906916f48cf06f44a2fd668d
>>> Author:     Jessica Clarke <jrtc27@FreeBSD.org>
>>> AuthorDate: 2026-07-13 03:03:03 +0000
>>> Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
>>> CommitDate: 2026-07-13 03:03:03 +0000
>>> 
>>>      kern_thread: Fix i386 p_emuldata KBI assertion
>>>           On amd64 there was 4 bytes of padding between the 20-byte p_comm and
>>>      (for LP64) 8-byte p_sysent, so the addition of p_execblock just caused
>>>      that padding to be eaten up. However, on i386, there was no such
>>>      padding, and so the addition of p_execblock rippled through to
>>>      p_emuldata.
>>>           Fixes:  e1a84b7708c2 ("execve_block(): a mechanism for mutual exclusion with execve() on the process")
>> 
>> 
>> Hello,
>> 
>> I think this is a quiet important fix missing in stable/15 (15.2) - despite i386 isn't tier0 anymore.
> 
> 
> Test-build failed with this e1a84b7708c2-fix.
> I couldn't identify the change which made this fix superfluous, but reverting local-MFC of f6ee1d20d368 lets me build i386 kernel.
> With this applied:
>     i386 kernel build fails with f6ee1d20d368 MFCd on 15.2-PRERELEASE:
> 
>     sys/kern/kern_thread.c:125:16: error: static assertion failed due to
>     requirement
>           '__builtin_offsetof(struct proc, p_emuldata) == 796': struct proc
>     KBI p_emuldata
>       125 | _Static_assert(offsetof(struct proc, p_emuldata) == 0x31c,
>           | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     sys/sys/stddef.h:41:31:
>     note: expanded from macro 'offsetof'
>        41 | #define offsetof(type, field)   __offsetof(type, field)
>           |                                 ^
>     sys/sys/cdefs.h:368:34:
>     note: expanded from macro '__offsetof'
>       368 | #define __offsetof(type, field) __builtin_offsetof(type, field)
>           |                                  ^
>     sys/kern/kern_thread.c:125:50:
>     note: expression evaluates to '792 == 796'
>       125 | _Static_assert(offsetof(struct proc, p_emuldata) == 0x31c,
>           | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
>     1 error generated.
> 
>     This reverts commit 75d28f36da6658c032613d7a1e4eabf70ec6cd27 (local MFC).
> 
> note: expression evaluates to '792 == 796'
> 0x318 == 0x31c
> 
> 
> Sorry for the noise, please ignore.

9d6498310f5c was the stable/15 cherry-pick of e1a84b7708c2 and put
p_execblock at the end of struct proc rather than in the middle where
it more logically belongs, in order to (mostly*) preserve KBI on the
stable branch. Putting it in the middle would be much more of a break.

Jessica

* Sizes of structs is also KBI, but there was no reserved space at the
  end to use, so this is about the closest you can get to that and
  presumably the slight KBI breakage was weighed against the security
  importance of the fix.