Merge pull request #256 from xmmgithub/tk4/master

net: skb: prevent the split of kfree_skb_reason() by gcc
This commit is contained in:
sclaibin 2022-08-30 11:00:32 +08:00 committed by GitHub
commit 213d7cc512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -270,4 +270,11 @@
*/
#define __weak __attribute__((__weak__))
/*
* Used by functions that use '__builtin_return_address'. These function
* don't want to be splited or made inline, which can make
* the '__builtin_return_address' get unexpected address.
*/
#define __fix_address noinline __noclone
#endif /* __LINUX_COMPILER_ATTRIBUTES_H */

View File

@ -1018,7 +1018,8 @@ static inline bool skb_unref(struct sk_buff *skb)
return true;
}
void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason);
void __fix_address
kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason);
/**
* kfree_skb - free an sk_buff with 'NOT_SPECIFIED' reason

View File

@ -703,9 +703,10 @@ EXPORT_SYMBOL(__kfree_skb);
* hit zero. Meanwhile, pass the drop reason to 'kfree_skb'
* tracepoint.
*/
void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
void __fix_address
kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
{
if (!skb_unref(skb))
if (unlikely(!skb_unref(skb)))
return;
WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX);