|
@@ -568,6 +568,8 @@ static bool cgroup_dev_is_valid_access(int off, int size,
|
|
enum bpf_access_type type,
|
|
enum bpf_access_type type,
|
|
struct bpf_insn_access_aux *info)
|
|
struct bpf_insn_access_aux *info)
|
|
{
|
|
{
|
|
|
|
+ const int size_default = sizeof(__u32);
|
|
|
|
+
|
|
if (type == BPF_WRITE)
|
|
if (type == BPF_WRITE)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
@@ -576,8 +578,17 @@ static bool cgroup_dev_is_valid_access(int off, int size,
|
|
/* The verifier guarantees that size > 0. */
|
|
/* The verifier guarantees that size > 0. */
|
|
if (off % size != 0)
|
|
if (off % size != 0)
|
|
return false;
|
|
return false;
|
|
- if (size != sizeof(__u32))
|
|
|
|
- return false;
|
|
|
|
|
|
+
|
|
|
|
+ switch (off) {
|
|
|
|
+ case bpf_ctx_range(struct bpf_cgroup_dev_ctx, access_type):
|
|
|
|
+ bpf_ctx_record_field_size(info, size_default);
|
|
|
|
+ if (!bpf_ctx_narrow_access_ok(off, size, size_default))
|
|
|
|
+ return false;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ if (size != size_default)
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|