From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: Maik Hentsche <netfilter@mm-double.de>,
netfilter-devel@lists.netfilter.org
Subject: Re: [PATCH] libnfnetlink
Date: Mon, 02 Oct 2006 15:47:09 +0200 [thread overview]
Message-ID: <4521185D.8040005@netfilter.org> (raw)
In-Reply-To: <451D2B3B.7070604@trash.net>
Patrick McHardy wrote:
> Maik Hentsche wrote:
>> Hello Pablo, hello readers of the list,
>> I found another bug in libnfnetlink. The comment of nfnl_recv states, in
>> case of success 0 is returned. In fact at success the returnvalue of
>> recvfrom is returned, which is the number of received bytes
>> (libnfnetlink_recv_comment.patch). The second issue is a little more
>> serious. The comment states, in case of an error, errno is set when in
>> fact it is not. I appended a patch for two occurences, but I since I
>> don't know, in which case addrlen might be != sizeof(peer) and what
>> peer.nl_pid means (and therefore why it is a problem, if it's not 0)
>> two error cases without appropriate errno value still exist.
>
> addrlen != sizeof(peer) should never happen. I can't think of anything
> better than EINVAL. nl_pid != 0 means the message originated in
> userspace and some other program is trying to feed us messages.
> We could handle this by just calling recvmsg again. But this is mainly
> because I can't think of a proper errno code for this either :)
what do you think about the following solution?
> if (len < sizeof(struct nlmsgerr)
> || len < sizeof(struct nlmsghdr))
errno = EBADMSG;
> [...]
> if (addrlen != sizeof(peer))
errno = EINVAL;
> return -1;
>
> if (peer.nl_pid != 0)
errno = ENOMSG;
> return -1;
>
> nlh = (struct nlmsghdr *)buf;
> if (nlh->nlmsg_flags & MSG_TRUNC || status > len)
errno = ENOSPC;
> return -1;
--
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
next prev parent reply other threads:[~2006-10-02 13:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-29 12:10 [PATCH] libnfnetlink Maik Hentsche
2006-09-29 14:18 ` Patrick McHardy
2006-10-02 13:47 ` Pablo Neira Ayuso [this message]
2006-10-11 10:32 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2006-10-09 15:07 Maik Hentsche
2006-10-09 15:14 ` Pablo Neira Ayuso
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=4521185D.8040005@netfilter.org \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=netfilter@mm-double.de \
/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.