tc/ebpf: unable to use BPF_FUNC_skb_change_head

Bug #1896504 reported by Nicolas Dichtel
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Incomplete
Undecided
Thadeu Lima de Souza Cascardo
Focal
Fix Released
Undecided
Thadeu Lima de Souza Cascardo
Groovy
Incomplete
Undecided
Thadeu Lima de Souza Cascardo

Bug Description

[Impact]

tc ebpf program that uses BPF_FUNC_skb_change_head are rejected.

This helper exists since linux v4.10, but it cannot be used until the the upstream commit 6f3f65d80dac ("net: bpf: Allow TC programs to call BPF_FUNC_skb_change_head"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f3f65d80dac

[Test Case]

Create a, ebpf program that uses this helper and load it with tc.

[Regression Potential]

The patch is trivial, the potential regressions are low.

CVE References

description: updated
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1896504

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Nicolas Dichtel (nicolas-dichtel) wrote :

Here is an example:

root@ubuntu1804hwe:~# uname -a
Linux ubuntu1804hwe 5.4.0-47-generic #51~18.04.1-Ubuntu SMP Sat Sep 5 14:35:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu1804hwe:~# cat test.c
#include <linux/pkt_cls.h>
#include <linux/bpf.h>

#ifndef __section
# define __section(NAME) __attribute__((section(NAME), used))
#endif

static int (*bpf_skb_change_head)(void *ctx, int headroom, int flags) =
        (void *) BPF_FUNC_skb_change_head;

__section("test")
int _test(struct __sk_buff *skb)
{
        bpf_skb_change_head(skb, 14, 0);
        return TC_ACT_OK;
}

char _license[] __section("license") = "GPL";
root@ubuntu1804hwe:~# clang -target bpf -I/usr/include/x86_64-linux-gnu/ -O2 -o test.o -c test.c
root@ubuntu1804hwe:~# ip link add name dummy1 type dummy
root@ubuntu1804hwe:~# ip link set dummy1 up
root@ubuntu1804hwe:~# tc qdisc add dev dummy1 clsact
root@ubuntu1804hwe:~# tc filter add dev dummy1 egress matchall action bpf obj ./test.o sec test

Prog section 'test' rejected: Invalid argument (22)!
 - Type: 4
 - Instructions: 5 (0 over limit)
 - License: GPL

Verifier analysis:

0: (b7) r2 = 14
1: (b7) r3 = 0
2: (85) call bpf_skb_change_head#43
unknown func bpf_skb_change_head#43
processed 3 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0

Error fetching program/map!
bad action parsing
parse_action: bad value (5:bpf)!
Illegal "action"
root@ubuntu1804hwe:~#

Revision history for this message
Nicolas Dichtel (nicolas-dichtel) wrote :

With a newer kernel, the last command succeeds (not output):

root@ubuntu1804hwe:~# uname -a
Linux ubuntu1804hwe 5.9.0-rc3-ge1b81391421b+6wind-net #1 SMP Mon Sep 21 19:31:31 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu1804hwe:~# tc filter add dev dummy1 egress matchall action bpf obj ./test.o sec test
root@ubuntu1804hwe:~#

Revision history for this message
Nicolas Dichtel (nicolas-dichtel) wrote :

I forget to explain how to check that the tc command was accepted:

root@ubuntu1804hwe:~# tc filter show dev dummy1 egress
filter protocol all pref 49152 matchall chain 0
filter protocol all pref 49152 matchall chain 0 handle 0x1
  not_in_hw
        action order 1: bpf test.o:[test] id 9 tag 26af4b090d2d67ee jited default-action pipe
        index 1 ref 1 bind 1

root@ubuntu1804hwe:~#

Changed in linux (Ubuntu Focal):
status: New → Confirmed
Changed in linux (Ubuntu Groovy):
assignee: nobody → Thadeu Lima de Souza Cascardo (cascardo)
Changed in linux (Ubuntu Focal):
assignee: nobody → Thadeu Lima de Souza Cascardo (cascardo)
Ian May (ian-may)
Changed in linux (Ubuntu Focal):
status: Confirmed → Fix Committed
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-focal' to 'verification-done-focal'. If the problem still exists, change the tag 'verification-needed-focal' to 'verification-failed-focal'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-focal
tags: added: verification-done-focal
removed: verification-needed-focal
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (78.9 KiB)

This bug was fixed in the package linux - 5.4.0-56.62

---------------
linux (5.4.0-56.62) focal; urgency=medium

  * focal/linux: 5.4.0-56.62 -proposed tracker (LP: #1905300)

  * CVE-2020-4788
    - selftests/powerpc: rfi_flush: disable entry flush if present
    - powerpc/64s: flush L1D on kernel entry
    - powerpc/64s: flush L1D after user accesses
    - selftests/powerpc: entry flush test

linux (5.4.0-55.61) focal; urgency=medium

  * focal/linux: 5.4.0-55.61 -proposed tracker (LP: #1903175)

  * Update kernel packaging to support forward porting kernels (LP: #1902957)
    - [Debian] Update for leader included in BACKPORT_SUFFIX

  * Avoid double newline when running insertchanges (LP: #1903293)
    - [Packaging] insertchanges: avoid double newline

  * EFI: Fails when BootCurrent entry does not exist (LP: #1899993)
    - efivarfs: Replace invalid slashes with exclamation marks in dentries.

  * CVE-2020-14351
    - perf/core: Fix race in the perf_mmap_close() function

  * raid10: Block discard is very slow, causing severe delays for mkfs and
    fstrim operations (LP: #1896578)
    - md: add md_submit_discard_bio() for submitting discard bio
    - md/raid10: extend r10bio devs to raid disks
    - md/raid10: pull codes that wait for blocked dev into one function
    - md/raid10: improve raid10 discard request
    - md/raid10: improve discard request for far layout
    - dm raid: fix discard limits for raid1 and raid10
    - dm raid: remove unnecessary discard limits for raid10

  * Bionic: btrfs: kernel BUG at /build/linux-
    eTBZpZ/linux-4.15.0/fs/btrfs/ctree.c:3233! (LP: #1902254)
    - btrfs: drop unnecessary offset_in_page in extent buffer helpers
    - btrfs: extent_io: do extra check for extent buffer read write functions
    - btrfs: extent-tree: kill BUG_ON() in __btrfs_free_extent()
    - btrfs: extent-tree: kill the BUG_ON() in insert_inline_extent_backref()
    - btrfs: ctree: check key order before merging tree blocks

  * Ethernet no link lights after reboot (Intel i225-v 2.5G) (LP: #1902578)
    - igc: Add PHY power management control

  * Undetected Data corruption in MPI workloads that use VSX for reductions on
    POWER9 DD2.1 systems (LP: #1902694)
    - powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation
    - selftests/powerpc: Make alignment handler test P9N DD2.1 vector CI load
      workaround

  * [20.04 FEAT] Support/enhancement of NVMe IPL (LP: #1902179)
    - s390: nvme ipl
    - s390: nvme reipl
    - s390/ipl: support NVMe IPL kernel parameters

  * uvcvideo: add mapping for HEVC payloads (LP: #1895803)
    - media: uvcvideo: Add mapping for HEVC payloads

  * Focal update: v5.4.73 upstream stable release (LP: #1902115)
    - ibmveth: Switch order of ibmveth_helper calls.
    - ibmveth: Identify ingress large send packets.
    - ipv4: Restore flowi4_oif update before call to xfrm_lookup_route
    - mlx4: handle non-napi callers to napi_poll
    - net: fec: Fix phy_device lookup for phy_reset_after_clk_enable()
    - net: fec: Fix PHY init after phy_reset_after_clk_enable()
    - net: fix pos incrementment in ipv6_route_seq_next
    - net/smc: fix valid DMBE buffer sizes
    - net...

Changed in linux (Ubuntu Focal):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.