File: map_excl.c

package info (click to toggle)
linux 6.18.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,742,212 kB
  • sloc: ansic: 26,783,651; asm: 272,129; sh: 148,799; python: 79,242; makefile: 57,742; perl: 36,527; xml: 19,542; cpp: 5,911; yacc: 4,939; lex: 2,950; awk: 1,607; sed: 30; ruby: 25
file content (34 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2025 Google LLC. */
#include <linux/bpf.h>
#include <time.h>
#include <bpf/bpf_helpers.h>

#include "bpf_misc.h"

struct {
	__uint(type, BPF_MAP_TYPE_ARRAY);
	__type(key, __u32);
	__type(value, __u32);
	__uint(max_entries, 1);
} excl_map SEC(".maps");

char _license[] SEC("license") = "GPL";

SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
int should_have_access(void *ctx)
{
	int key = 0, value = 0xdeadbeef;

	bpf_map_update_elem(&excl_map, &key, &value, 0);
	return 0;
}

SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
int should_not_have_access(void *ctx)
{
	int key = 0, value = 0xdeadbeef;

	bpf_map_update_elem(&excl_map, &key, &value, 0);
	return 0;
}