for (i = 0; i < ARRAY_SIZE(write_ranges); i++) { conststruct hid_bpf_offset_write_range *write_range = &write_ranges[i];
s32 type_id;
/* we already found a writeable struct, but there is a * new one, let's break the loop.
*/ if (t == state && write_range->struct_name != cur) break;
/* new struct to look for */ if (write_range->struct_name != cur) {
type_id = btf_find_by_name_kind(reg->btf, write_range->struct_name,
BTF_KIND_STRUCT); if (type_id < 0) return -EINVAL;
state = btf_type_by_id(reg->btf, type_id);
}
/* this is not the struct we are looking for */ if (t != state) {
cur = write_range->struct_name; continue;
}
/* first time we see this struct, check for out of bounds */ if (cur != write_range->struct_name &&
off + size > write_range->struct_length) {
bpf_log(log, "write access for struct %s at off %d with size %d\n",
write_range->struct_name, off, size); return -EACCES;
}
/* now check if we are in our boundaries */ if (off >= write_range->start && off + size <= write_range->end) return NOT_INIT;
cur = write_range->struct_name;
}
if (t != state)
bpf_log(log, "write access to this struct is not supported\n"); else
bpf_log(log, "write access at off %d with size %d on read-only part of %s\n",
off, size, cur);
switch (moff) { case offsetof(struct hid_bpf_ops, hid_id): /* For hid_id and flags fields, this function has to copy it * and return 1 to indicate that the data has been handled by * the struct_ops type, or the verifier will reject the map if * the value of those fields is not zero.
*/
khid_bpf_ops->hid_id = uhid_bpf_ops->hid_id; return 1; case offsetof(struct hid_bpf_ops, flags): if (uhid_bpf_ops->flags & ~BPF_F_BEFORE) return -EINVAL;
khid_bpf_ops->flags = uhid_bpf_ops->flags; return 1;
} return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.