netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: netfilter-devel@vger.kernel.org
Subject: nftables batch abi broken ...
Date: Thu, 27 Aug 2015 17:31:51 +0200	[thread overview]
Message-ID: <20150827153151.GA17804@breakpoint.cc> (raw)

Hi.

batch handling in libnftnl uses this:
libnftnl/src/common.c:  nfg->res_id = NFNL_SUBSYS_NFTABLES;

It SHOULD be:
libnftnl/src/common.c:  nfg->res_id = htons(NFNL_SUBSYS_NFTABLES)

since res_id is a __be16.

The kernel contains the same error when decoding batch messages
which is why this works :-/

I found this problem when looking at sparse error reports on the kernel
where sparse complains about the following line in nfnetlink_rcv():

    nfnetlink_rcv_batch(skb, nlh, nfgenmsg->res_id);

and sparse complaint is correct, __be16 is treated as u16 without
conversion.

How to fix this?
If we want to maintain ABI on Little Endian only solution is to "fix"
it in kernel by annotating this with explicit cast to u16.

But it sucks since ->res_id is used via htons/ntohs in all other places
:-/

Any ideas?

Fix userspace and play 'guess todays endianess' in the kernel...?

             reply	other threads:[~2015-08-27 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 15:31 Florian Westphal [this message]
2015-08-27 16:46 ` nftables batch abi broken 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=20150827153151.GA17804@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).