cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

fexit_bpf2bpf_simple.c (488B)


      1// SPDX-License-Identifier: GPL-2.0
      2/* Copyright (c) 2019 Facebook */
      3#include <linux/bpf.h>
      4#include <bpf/bpf_helpers.h>
      5#include <bpf/bpf_tracing.h>
      6
      7struct sk_buff {
      8	unsigned int len;
      9};
     10
     11__u64 test_result = 0;
     12
     13SEC("fexit/test_pkt_md_access")
     14int BPF_PROG(test_main2, struct sk_buff *skb, int ret)
     15{
     16	int len;
     17
     18	__builtin_preserve_access_index(({
     19		len = skb->len;
     20	}));
     21	if (len != 74 || ret != 0)
     22		return 0;
     23
     24	test_result = 1;
     25	return 0;
     26}
     27char _license[] SEC("license") = "GPL";