]> git.baikalelectronics.ru Git - kernel.git/commit
skbuff: introduce skb_pull_data
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 1 Dec 2021 18:54:52 +0000 (10:54 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 7 Dec 2021 16:05:38 +0000 (17:05 +0100)
commit75e3408df4158b214294bd939214a2fc0f477b66
treea6f62154833573b637d1ce75ac7ca99b88311da2
parent587d4d147a25c4c6804a2daaf6a9cc41c52fb9eb
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>
include/linux/skbuff.h
net/core/skbuff.c