netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: re: netfilter: nf_tables: add compatibility layer for x_tables
Date: Mon, 4 Nov 2013 15:58:00 +0300	[thread overview]
Message-ID: <20131104125800.GA12213@longonot.mountain> (raw)

Hello Pablo Neira Ayuso,

The patch 0ca743a55991: "netfilter: nf_tables: add compatibility 
layer for x_tables" from Oct 14, 2013, leads to the following Smatch
warning: "net/netfilter/nft_compat.c:140 nft_parse_compat()
	 warn: signedness bug returning '(-34)'"

net/netfilter/nft_compat.c
   131  static u8 nft_parse_compat(const struct nlattr *attr, bool *inv)
   132  {
   133          struct nlattr *tb[NFTA_RULE_COMPAT_MAX+1];
   134          u32 flags;
   135          int err;
   136  
   137          err = nla_parse_nested(tb, NFTA_RULE_COMPAT_MAX, attr,
   138                                 nft_rule_compat_policy);
   139          if (err < 0)
   140                  return err;
                        ^^^^^^^^^^
   141  
   142          if (!tb[NFTA_RULE_COMPAT_PROTO] || !tb[NFTA_RULE_COMPAT_FLAGS])
   143                  return -EINVAL;
                        ^^^^^^^^^^^^^^^
   144  
   145          flags = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_FLAGS]));
   146          if (flags & ~NFT_RULE_COMPAT_F_MASK)
   147                  return -EINVAL;
                        ^^^^^^^^^^^^^^^

   148          if (flags & NFT_RULE_COMPAT_F_INV)
   149                  *inv = true;
   150  
   151          return ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO]));
   152  }

This function returns error codes but the return type is u8 so the error
codes are transformed into small positive values.  The callers don't
check the return.

regards,
dan carpenter


                 reply	other threads:[~2013-11-04 13:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20131104125800.GA12213@longonot.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).