mirror of
https://github.com/torvalds/linux.git
synced 2026-11-28 09:22:27 +00:00
bpf_probe_read_kernel_str() will add a nul terminator to the dst, then we don't care about if the dst size is big enough. This patch also replaces the hard-coded 16 with TASK_COMM_LEN to make it grepable. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Michal Miroslaw <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Al Viro <[email protected]> Cc: Kees Cook <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Dennis Dalessandro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
38 lines
879 B
C
38 lines
879 B
C
/* Copyright (c) 2016 Facebook
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of version 2 of the GNU General Public
|
|
* License as published by the Free Software Foundation.
|
|
*/
|
|
#include <linux/sched.h>
|
|
#include <uapi/linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
/* from /sys/kernel/debug/tracing/events/task/task_rename/format */
|
|
struct task_rename {
|
|
__u64 pad;
|
|
__u32 pid;
|
|
char oldcomm[TASK_COMM_LEN];
|
|
char newcomm[TASK_COMM_LEN];
|
|
__u16 oom_score_adj;
|
|
};
|
|
SEC("tracepoint/task/task_rename")
|
|
int prog(struct task_rename *ctx)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/* from /sys/kernel/debug/tracing/events/random/urandom_read/format */
|
|
struct urandom_read {
|
|
__u64 pad;
|
|
int got_bits;
|
|
int pool_left;
|
|
int input_left;
|
|
};
|
|
SEC("tracepoint/random/urandom_read")
|
|
int prog2(struct urandom_read *ctx)
|
|
{
|
|
return 0;
|
|
}
|
|
char _license[] SEC("license") = "GPL";
|