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

bpf_iter_task_file.c (748B)


      1// SPDX-License-Identifier: GPL-2.0
      2/* Copyright (c) 2020 Facebook */
      3#include "bpf_iter.h"
      4#include <bpf/bpf_helpers.h>
      5
      6char _license[] SEC("license") = "GPL";
      7
      8int count = 0;
      9int tgid = 0;
     10
     11SEC("iter/task_file")
     12int dump_task_file(struct bpf_iter__task_file *ctx)
     13{
     14	struct seq_file *seq = ctx->meta->seq;
     15	struct task_struct *task = ctx->task;
     16	__u32 fd = ctx->fd;
     17	struct file *file = ctx->file;
     18
     19	if (task == (void *)0 || file == (void *)0)
     20		return 0;
     21
     22	if (ctx->meta->seq_num == 0) {
     23		count = 0;
     24		BPF_SEQ_PRINTF(seq, "    tgid      gid       fd      file\n");
     25	}
     26
     27	if (tgid == task->tgid && task->tgid != task->pid)
     28		count++;
     29
     30	BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd,
     31		       (long)file->f_op);
     32	return 0;
     33}