Skip to content

Commit

Permalink
Trace ringbuffer synced to latest 6.7
Browse files Browse the repository at this point in the history
Panic fix for arm64 due to kernel data leaking (usercopy_hardened)

Signed-off-by: shenping.matt <[email protected]>
  • Loading branch information
shenping-bd committed Dec 22, 2023
1 parent d07db8b commit 92dd102
Show file tree
Hide file tree
Showing 3 changed files with 339 additions and 292 deletions.
2 changes: 1 addition & 1 deletion driver/LKM/include/print_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
__entry = tb_event_data(event); \
__entry->head.id = __class->id; \
{ assign; } \
tb_unlock_commit(__class->trace, event); \
tb_unlock_commit(__class->trace); \
} \
\
static notrace void name##_print(proto) \
Expand Down
17 changes: 7 additions & 10 deletions driver/LKM/include/trace_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
#define raw_spin_lock_init(x) ((x)->slock = 0)
#define raw_spin_lock_irq __raw_spin_lock
#define raw_spin_unlock_irq __raw_spin_unlock
/*
* Safe here to ignore irq flags since we only write ringbuffer in
* kprobe/tracepoint callbacks
*/
#define raw_spin_lock_irqsave(l, f) do {(f) = 0; __raw_spin_lock(l);} while(0)
#define raw_spin_unlock_irqrestore(l, f) do {__raw_spin_unlock(l);} while(0)
#endif

struct tb_ring;
struct tb_iter;

/*
* Don't refer to this struct directly, use functions below.
Expand Down Expand Up @@ -111,6 +114,7 @@ __tb_alloc(unsigned long size, unsigned flags, struct lock_class_key *key);
__tb_alloc((size), (flags), &__key); \
})

void tb_wake_up(struct tb_ring *ring);
int tb_wait(struct tb_ring *ring, int cpu, int full);
void tb_free(struct tb_ring *ring);

Expand All @@ -129,8 +133,7 @@ u64 tb_event_timestamp(struct tb_ring *ring,

struct tb_event *tb_lock_reserve(struct tb_ring *ring,
unsigned long length);
int tb_unlock_commit(struct tb_ring *ring,
struct tb_event *event);
int tb_unlock_commit(struct tb_ring *ring);
int tb_write(struct tb_ring *ring,
unsigned long length, void *data);

Expand All @@ -146,7 +149,7 @@ int tb_write(struct tb_ring *ring,
* if (some_condition)
* tb_discard_commit(buffer, event);
* else
* tb_unlock_commit(buffer, event);
* tb_unlock_commit(buffer);
*/
void tb_discard_commit(struct tb_ring *ring,
struct tb_event *event);
Expand Down Expand Up @@ -180,12 +183,6 @@ size_t tb_nr_dirty_pages(struct tb_ring *ring, int cpu);

void tb_change_overwrite(struct tb_ring *ring, int val);

struct tb_iter *
tb_read_prepare(struct tb_ring *ring, int cpu, gfp_t flags);
void tb_read_prepare_sync(void);
void tb_read_start(struct tb_iter *iter);
void tb_read_finish(struct tb_iter *iter);

u64 tb_time_stamp(struct tb_ring *ring);
void tb_set_time_stamp_abs(struct tb_ring *ring, bool abs);
bool tb_time_stamp_abs(struct tb_ring *ring);
Expand Down
Loading

0 comments on commit 92dd102

Please sign in to comment.