From fc910a27839584209726537698b596576940add4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sun, 25 Mar 2007 20:27:59 -0700 Subject: [NETLINK]: Limit NLMSG_GOODSIZE to 8K. Signed-off-by: David S. Miller --- include/linux/netlink.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/linux/netlink.h') diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 2a20f488ac1b..a9d3ad5bc80f 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -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. + * 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 -#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER)) +#if PAGE_SIZE < 8192UL +#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) -- cgit v1.2.3