* Pablo Neira <420BF8CB.6080005@xxxxxxxxxxx> 2005-02-11 01:14
> This patch introduces a new function called netlink_check_skb that does
> the sanity checkings for received messages.
The patch description doesn't really match the patch itself.
> ===== net/netlink/af_netlink.c 1.69 vs edited =====
> --- 1.69/net/netlink/af_netlink.c 2005-01-21 21:25:32 +01:00
> +++ edited/net/netlink/af_netlink.c 2005-02-10 00:37:57 +01:00
> @@ -1201,6 +1201,42 @@
> netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
> }
>
> +/*
> + * Process one packet of messages.
> + * Malformed skbs with wrong lengths of messages are discarded silently.
> + */
> +int netlink_process_skb(struct sk_buff *skb,
> + int (*process_msg)(struct sk_buff *skb,
> + struct nlmsghdr *nlh,
> + int *err))
> +{
> + int err;
> + struct nlmsghdr * nlh;
> +
> + while (skb->len >= NLMSG_SPACE(0)) {
While you're at it, change that to NLMSG_LENGTH(0) or even to
NLMSG_ALIGN(sizeof(*nlh)) to make it more readable. NLMSG_SPACE()
represents the total size of a netlink message in the byte stream
including the padding to payload in order to enforce proper
alignement for successive netlink message header.
|