Skip to content

Commit 9a4c8d7

Browse files
jsitnickiKernel Patches Daemon
authored andcommitted
net: Preserve metadata on pskb_expand_head
pskb_expand_head() copies headroom, including skb metadata, into the newly allocated head, but then clears the metadata. As a result, metadata is lost when BPF helpers trigger an skb head reallocation. Let the skb metadata remain in the newly created copy of head. Signed-off-by: Jakub Sitnicki <[email protected]>
1 parent ee4e5e6 commit 9a4c8d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/core/skbuff.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,10 @@ EXPORT_SYMBOL(__pskb_copy_fclone);
22182218
*
22192219
* All the pointers pointing into skb header may change and must be
22202220
* reloaded after call to this function.
2221+
*
2222+
* Note: If you skb_push() the start of the buffer after reallocating the
2223+
* header, call skb_postpush_data_move() first to move the metadata out of
2224+
* the way before writing to &sk_buff->data.
22212225
*/
22222226

22232227
int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
@@ -2289,8 +2293,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
22892293
skb->nohdr = 0;
22902294
atomic_set(&skb_shinfo(skb)->dataref, 1);
22912295

2292-
skb_metadata_clear(skb);
2293-
22942296
/* It is not generally safe to change skb->truesize.
22952297
* For the moment, we really care of rx path, or
22962298
* when skb is orphaned (not attached to a socket).

0 commit comments

Comments
 (0)