diff options
author | Daniel Rosenberg <drosen@google.com> | 2023-05-05 18:31:30 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-05-06 16:42:57 -0700 |
commit | 3bda08b63670c39be390fcb00e7718775508e673 (patch) | |
tree | cdbbc77269e5b94951bdf4a89d9aa03469587c81 /include/linux/skbuff.h | |
parent | e04ddf179c2acb6de841016e5bcf29b26705b4ec (diff) | |
download | lwn-3bda08b63670c39be390fcb00e7718775508e673.tar.gz lwn-3bda08b63670c39be390fcb00e7718775508e673.zip |
bpf: Allow NULL buffers in bpf_dynptr_slice(_rw)
bpf_dynptr_slice(_rw) uses a user provided buffer if it can not provide
a pointer to a block of contiguous memory. This buffer is unused in the
case of local dynptrs, and may be unused in other cases as well. There
is no need to require the buffer, as the kfunc can just return NULL if
it was needed and not provided.
This adds another kfunc annotation, __opt, which combines with __sz and
__szk to allow the buffer associated with the size to be NULL. If the
buffer is NULL, the verifier does not check that the buffer is of
sufficient size.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Link: https://lore.kernel.org/r/20230506013134.2492210-2-drosen@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 738776ab8838..8ddb4af1a501 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4033,7 +4033,7 @@ __skb_header_pointer(const struct sk_buff *skb, int offset, int len, if (likely(hlen - offset >= len)) return (void *)data + offset; - if (!skb || unlikely(skb_copy_bits(skb, offset, buffer, len) < 0)) + if (!skb || !buffer || unlikely(skb_copy_bits(skb, offset, buffer, len) < 0)) return NULL; return buffer; |