Skip to content

Commit 20a83af

Browse files
gllghrJohn Gallagher
authored andcommitted
Invalid mem errors when using latest BCC
1 parent d6f5f96 commit 20a83af

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

bpf/estat/backend-io.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
#define READ_STR "read "
1616
#define WRITE_STR "write "
1717
#define OP_NAME_LEN 7
18-
#define DEV_NAME_LEN 8
1918
#define NAME_LENGTH (OP_NAME_LEN + 1)
20-
#define AXIS_LENGTH (DEV_NAME_LEN + 1)
19+
#define AXIS_LENGTH (DISK_NAME_LEN + 1)
2120

2221
// Structure to hold thread local data
2322
typedef struct {
2423
u64 ts;
2524
unsigned int size;
2625
unsigned int cmd_flags;
2726
u32 err;
28-
char device[DEV_NAME_LEN];
27+
char device[DISK_NAME_LEN];
2928
} io_data_t;
3029

3130
BPF_HASH(io_base_data, u64, io_data_t);
@@ -40,7 +39,7 @@ disk_io_start(struct pt_regs *ctx, struct request *reqp)
4039
data.ts = bpf_ktime_get_ns();
4140
data.cmd_flags = reqp->cmd_flags;
4241
data.size = reqp->__data_len;
43-
__builtin_memcpy(&data.device, diskp->disk_name, DEV_NAME_LEN);
42+
bpf_probe_read_str(&data.device, DISK_NAME_LEN, diskp->disk_name);
4443
io_base_data.update((u64 *) &reqp, &data);
4544
return (0);
4645
}

bpf/stbtrace/io.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int disk_io_start(struct pt_regs *ctx, struct request *reqp)
6969
data.ts = bpf_ktime_get_ns();
7070
data.cmd_flags = reqp->cmd_flags;
7171
data.size = reqp->__data_len;
72-
__builtin_memcpy(&data.device, diskp->disk_name, DISK_NAME_LEN);
72+
bpf_probe_read_str(&data.device, DISK_NAME_LEN, diskp->disk_name);
7373
io_base_data.update((u64 *) &reqp, &data);
7474
return 0;
7575
}

0 commit comments

Comments
 (0)