Currently, it is possible to create a sock hash map with key size of 0 and have the kernel return a fd back to user space. This is invalid for hash maps (and kernel also hasn't been tested for zero key size support in general at this point). Thus, reject such configuration.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -2140,7 +2140,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) · 2139 unmodified lines | |||
| 2140 | return ERR_PTR(-EPERM); | 2140 | return ERR_PTR(-EPERM); |
| 2141 | 2141 | ||
| 2142 | /* check sanity of attributes */ | 2142 | /* check sanity of attributes */ |
| 2143 | if (attr->max_entries == 0 || attr->value_size != 4 || | 2143 | if (attr->max_entries == 0 || |
| 2144 | attr->key_size == 0 || | ||
| 2145 | attr->value_size != 4 || | ||
| 2144 | attr->map_flags & ~SOCK_CREATE_FLAG_MASK) | 2146 | attr->map_flags & ~SOCK_CREATE_FLAG_MASK) |
| 2145 | return ERR_PTR(-EINVAL); | 2147 | return ERR_PTR(-EINVAL); |
| 2146 | 2148 | ||