diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-12-01 21:54:52 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2021-12-07 19:05:38 +0300 |
commit | 13244cccc2b61ec715f0ac583d3037497004d4a5 (patch) | |
tree | a6f62154833573b637d1ce75ac7ca99b88311da2 /include | |
parent | 561ae1d46a8ddcbc13162d5771f5ed6c8249e730 (diff) | |
download | linux-13244cccc2b61ec715f0ac583d3037497004d4a5.tar.xz |
skbuff: introduce skb_pull_data
Like skb_pull but returns the original data pointer before pulling the
data after performing a check against sbk->len.
This allows to change code that does "struct foo *p = (void *)skb->data;"
which is hard to audit and error prone, to:
p = skb_pull_data(skb, sizeof(*p));
if (!p)
return;
Which is both safer and cleaner.
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/skbuff.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index eba256af64a5..877dda38684a 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2373,6 +2373,8 @@ static inline void *skb_pull_inline(struct sk_buff *skb, unsigned int len) return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); } +void *skb_pull_data(struct sk_buff *skb, size_t len); + void *__pskb_pull_tail(struct sk_buff *skb, int delta); static inline void *__pskb_pull(struct sk_buff *skb, unsigned int len) |