Page MenuHomeFreeBSD

BPF: Switch to 32 bit compatible mode only when thread is 32 bit
ClosedPublic

Authored by pdk_semihalf.com on Jan 23 2018, 1:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 6 2024, 1:11 AM
Unknown Object (File)
Dec 31 2023, 2:44 AM
Unknown Object (File)
Dec 13 2023, 6:28 AM
Unknown Object (File)
Sep 29 2023, 12:20 AM
Unknown Object (File)
Sep 7 2023, 4:55 AM
Unknown Object (File)
Sep 7 2023, 4:55 AM
Unknown Object (File)
Sep 1 2023, 9:35 PM
Unknown Object (File)
Sep 1 2023, 9:33 PM
Subscribers

Details

Summary

Sometimes 32 bit and 64 bit ioctls are represented by the same number.
It causes unnecessary switch to 32 bit commpatible mode.

This patch prevents switching when we are dealing with 64 bit executable.
It fixes issue mentioned here

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Won't this mean the 32 bit ioctl won't work?

Almost all 32 bit ioctl work. In BPF there is BIOCSRTIMEOUT (takes timeval as argument) and BIOCSRTIMEOUT32 (takes timeval32 as argument) which are equal on non intel arch.
That ioctl works only on amd64 because timeval32 has size of 8 bytes. But on other arch, timeval32 has size of 12 bytes (16 bytes with padding)

andrew requested changes to this revision.Jan 23 2018, 3:22 PM

We should fix the BIOCSRTIMEOUT32 case rather than breaking the ioctl ABI.

This revision now requires changes to proceed.Jan 23 2018, 3:22 PM

My first approach was simply avoid fallback when 64 bit and 32 bit ioctl are equal. But it was terrible idea.
If you thought more about this issue, you would realize that problem is in calculating ioctl number and recognizing 32 bit ioctl using sizeof.
Sooner or later breaking ioctl ABI will be necessary.

Maybe you have some ideas how solve this issue?

EDIT: link to issue fixed by this patch https://lists.freebsd.org/pipermail/freebsd-arm/2018-January/017360.html

But we know if it's a 32 bit ioctl by checking SV_PROC_FLAG(td->td_proc, SV_ILP32), we don't need to break the ABI.

pdk_semihalf.com retitled this revision from Make timeval32 4 byte aligned to BPF: Switch to 32 bit compatible mode only when thread is 32 bit.
pdk_semihalf.com edited the summary of this revision. (Show Details)

Completely changed patch. It uses hint provided by andrew.

andrew added inline comments.
sys/net/bpf.c
65 ↗(On Diff #38378)

This should be sorted, however the other headers aren't.

This revision is now accepted and ready to land.Jan 24 2018, 5:55 PM
This revision was automatically updated to reflect the committed changes.