Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf_sk_lookup.remote_port fixes #59

Closed
wants to merge 4 commits into from

Commits on Feb 22, 2022

  1. adding ci files

    Nobody committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    5201557 View commit details
    Browse the repository at this point in the history
  2. bpf: Fix certain narrow loads with offsets

    Verifier treats bpf_sk_lookup.remote_port as a 32-bit field for
    backward compatibility, regardless of what the uapi headers say.
    This field is mapped onto the 16-bit bpf_sk_lookup_kern.sport field.
    Therefore, accessing the most significant 16 bits of
    bpf_sk_lookup.remote_port must produce 0, which is currently not
    the case.
    
    The problem is that narrow loads with offset - commit 46f53a6
    ("bpf: Allow narrow loads with offset > 0"), don't play nicely with
    the masking optimization - commit 2399463 ("bpf: possibly avoid
    extra masking for narrower load in verifier"). In particular, when we
    suppress extra masking, we suppress shifting as well, which is not
    correct.
    
    Fix by moving the masking suppression check to BPF_AND generation.
    
    Fixes: 46f53a6 ("bpf: Allow narrow loads with offset > 0")
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    iii-i authored and Nobody committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    24126d8 View commit details
    Browse the repository at this point in the history
  3. bpf: Fix bpf_sk_lookup.remote_port on big-endian

    On big-endian, the port is available in the second __u16, not the first
    one. Therefore, provide a big-endian-specific definition that reflects
    that. Also, define remote_port_compat in order to have nicer
    architecture-agnostic code in the verifier and in tests.
    
    Fixes: 9a69e2b ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide")
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    iii-i authored and Nobody committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    4824b2d View commit details
    Browse the repository at this point in the history
  4. selftests/bpf: Adapt bpf_sk_lookup.remote_port loads

    - Remove some remote_port tests that are not applicable to u16.
    - Use remote_port_compat for backward compatibility tests.
    - Add LSB/LSW backward compatibility tests.
    - u32 load produces SRC_PORT on both little- and big-endian machines,
      so check just that.
    
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    iii-i authored and Nobody committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    c9ba25b View commit details
    Browse the repository at this point in the history