unix: align Ifreq so its union accessors cannot fault - #287
Conversation
|
This PR (HEAD: 658c19c) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/820000. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Stian Halseth: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
658c19c to
2a96d26
Compare
2a96d26 to
1879a16
Compare
|
This PR (HEAD: 1879a16) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/820000. Important tips:
|
|
Message from Stian Halseth: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 3: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-08-24T18:54:20Z","revision":"d497ef75ba518b96f76efd842f85c3a146911661"} Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 3: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_5206>) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: This CL has failed the run. Reason: Tryjob golang/try/x_sys-gotip-linux-386 has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 3: -Auto-Submit -Code-Review (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
Uint16, SetUint16, Uint32, SetUint32, Inet4Addr and SetInet4Addr cast the ifreq union to uint16, uint32 or RawSockaddrInet4 and access it in place. The generated ifreq declares that union as a byte array, so the type guarantees only byte alignment and the compiler may put an Ifreq at any address - as it does for the elements of a []Ifreq, which pack at the struct's size with an alignment of one. A misaligned access is merely slow on amd64 and arm64; on sparc64 it faults, and TestIoctlIfreq died with SIGBUS. Align the wrapper rather than changing the accessors. The union lies at offset 16 within ifreq on every architecture, so aligning the wrapper aligns the union, and all six accessors are covered instead of only the four integer ones. TestIfreqAlignment pins the invariant. Without the fix it fails on every architecture, reporting an alignment of 1, so catching a regression does not need sparc64 hardware. Updates golang/go#55000 Change-Id: I9c5c04515c42702ffec583881b09745f6a52b167
1879a16 to
637b50d
Compare
|
This PR (HEAD: 637b50d) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/820000. Important tips:
|
|
Message from Stian Halseth: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 4: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-08-25T05:01:43Z","revision":"a6f78ab5cd4df617dd12f22c7c192b55aec1e2e8"} Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 4: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_5206>) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 4: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 4: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from Ian Lance Taylor: Patch Set 4: Code-Review+2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
|
Message from David Chase: Patch Set 4: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/820000. |
Uint16, SetUint16, Uint32, SetUint32, Inet4Addr and SetInet4Addr cast the ifreq union to uint16, uint32 or RawSockaddrInet4 and access it in place. The generated ifreq declares that union as a byte array, so the type guarantees only byte alignment and the compiler may put an Ifreq at any address - as it does for the elements of a []Ifreq, which pack at the struct's size with an alignment of one. A misaligned access is merely slow on amd64 and arm64; on sparc64 it faults, and TestIoctlIfreq died with SIGBUS. Align the wrapper rather than changing the accessors. The union lies at offset 16 within ifreq on every architecture, so aligning the wrapper aligns the union, and all six accessors are covered instead of only the four integer ones. TestIfreqAlignment pins the invariant. Without the fix it fails on every architecture, reporting an alignment of 1, so catching a regression does not need sparc64 hardware. Updates golang/go#55000 Change-Id: I70aca33419086de9eb68032e354e5f666cc20562 GitHub-Last-Rev: 637b50d GitHub-Pull-Request: #287 Reviewed-on: https://go-review.googlesource.com/c/sys/+/820000 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
|
This PR is being closed because golang.org/cl/820000 has been merged. |
Uint16, SetUint16, Uint32, SetUint32, Inet4Addr and SetInet4Addr cast the
ifreq union to uint16, uint32 or RawSockaddrInet4 and access it in place.
The generated ifreq declares that union as a byte array, so the type
guarantees only byte alignment and the compiler may put an Ifreq at any
address - as it does for the elements of a []Ifreq, which pack at the
struct's size with an alignment of one.
A misaligned access is merely slow on amd64 and arm64; on sparc64 it
faults, and TestIoctlIfreq died with SIGBUS.
Align the wrapper rather than changing the accessors. The union lies at
offset 16 within ifreq on every architecture, so aligning the wrapper
aligns the union, and all six accessors are covered instead of only the
four integer ones.
TestIfreqAlignment pins the invariant. Without the fix it fails on every
architecture, reporting an alignment of 1, so catching a regression does
not need sparc64 hardware.
Updates golang/go#55000