All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Pablo Neira <pablo@eurodev.net>
Cc: netdev@oss.sgi.com, "David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH 2/4] [NETLINK] introduce netlink_check_skb function
Date: Fri, 11 Feb 2005 04:24:48 +0100	[thread overview]
Message-ID: <20050211032448.GD31837@postel.suug.ch> (raw)
In-Reply-To: <420BF8CB.6080005@eurodev.net>

* Pablo Neira <420BF8CB.6080005@eurodev.net> 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.

  reply	other threads:[~2005-02-11  3:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11  0:14 [PATCH 2/4] [NETLINK] introduce netlink_check_skb function Pablo Neira
2005-02-11  3:24 ` Thomas Graf [this message]
2005-02-11 21:31   ` Pablo Neira
2005-02-11 22:43     ` Thomas Graf
2005-02-12 21:18       ` Pablo Neira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050211032448.GD31837@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    --cc=pablo@eurodev.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.