mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
[NETLINK]: Limit NLMSG_GOODSIZE to 8K.
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ca04356939
commit
fc910a2783
2 changed files with 14 additions and 5 deletions
|
@ -171,9 +171,16 @@ int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skb should fit one page. This choice is good for headerless malloc.
|
* skb should fit one page. This choice is good for headerless malloc.
|
||||||
|
* But we should limit to 8K so that userspace does not have to
|
||||||
|
* use enormous buffer sizes on recvmsg() calls just to avoid
|
||||||
|
* MSG_TRUNC when PAGE_SIZE is very large.
|
||||||
*/
|
*/
|
||||||
#define NLMSG_GOODORDER 0
|
#if PAGE_SIZE < 8192UL
|
||||||
#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
|
#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE)
|
||||||
|
#else
|
||||||
|
#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
|
#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,11 @@
|
||||||
|
|
||||||
#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
|
#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
|
||||||
~(SMP_CACHE_BYTES - 1))
|
~(SMP_CACHE_BYTES - 1))
|
||||||
#define SKB_MAX_ORDER(X, ORDER) (((PAGE_SIZE << (ORDER)) - (X) - \
|
#define SKB_WITH_OVERHEAD(X) \
|
||||||
sizeof(struct skb_shared_info)) & \
|
(((X) - sizeof(struct skb_shared_info)) & \
|
||||||
~(SMP_CACHE_BYTES - 1))
|
~(SMP_CACHE_BYTES - 1))
|
||||||
|
#define SKB_MAX_ORDER(X, ORDER) \
|
||||||
|
SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
|
||||||
#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
|
#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
|
||||||
#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
|
#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue