netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: fix type mismatch with error return from nft_parse_u32_check
@ 2016-10-25 19:08 John W. Linville
  2016-10-25 19:55 ` John W. Linville
  2016-10-25 19:56 ` [PATCH v2] " John W. Linville
  0 siblings, 2 replies; 4+ messages in thread
From: John W. Linville @ 2016-10-25 19:08 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller, netdev,
	John W. Linville, Laura Garcia Liebana, Pablo Neira Ayuso,
	Dan Carpenter

Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of
u32 netlink attributes") introduced nft_parse_u32_check with a return
value of "unsigned int", yet on error it returns "-ERANGE".

This patch corrects the mismatch by changing the return value to "int",
which happens to match the actual users of nft_parse_u32_check already.

Found by Coverity, CID 1373930.

Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error
handling in nft_exthdr_init()) attempted to address the issue, but
did not address the return type of nft_parse_u32_check.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Cc: Laura Garcia Liebana <nevola@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 0eadf37afc250 ("netfilter: nf_tables: validate maximum value...")
---
 include/net/netfilter/nf_tables.h | 2 +-
 net/netfilter/nf_tables_api.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 5031e072567b..da43f50b39c6 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -145,7 +145,7 @@ static inline enum nft_registers nft_type_to_reg(enum nft_data_types type)
 	return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE;
 }
 
-unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
 unsigned int nft_parse_register(const struct nlattr *attr);
 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
 
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 24db22257586..32fa4f08444a 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4421,7 +4421,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
  *	Otherwise a 0 is returned and the attribute value is stored in the
  *	destination variable.
  */
-unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
 {
 	u32 val;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: fix type mismatch with error return from nft_parse_u32_check
  2016-10-25 19:08 [PATCH] netfilter: fix type mismatch with error return from nft_parse_u32_check John W. Linville
@ 2016-10-25 19:55 ` John W. Linville
  2016-10-25 19:56 ` [PATCH v2] " John W. Linville
  1 sibling, 0 replies; 4+ messages in thread
From: John W. Linville @ 2016-10-25 19:55 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller, netdev,
	Laura Garcia Liebana, Pablo Neira Ayuso, Dan Carpenter

On Tue, Oct 25, 2016 at 03:08:04PM -0400, John W. Linville wrote:
> Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of
> u32 netlink attributes") introduced nft_parse_u32_check with a return
> value of "unsigned int", yet on error it returns "-ERANGE".
> 
> This patch corrects the mismatch by changing the return value to "int",
> which happens to match the actual users of nft_parse_u32_check already.
> 
> Found by Coverity, CID 1373930.
> 
> Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error
> handling in nft_exthdr_init()) attempted to address the issue, but
> did not address the return type of nft_parse_u32_check.
> 
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> Cc: Laura Garcia Liebana <nevola@gmail.com>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: 0eadf37afc250 ("netfilter: nf_tables: validate maximum value...")

The Fixes line is incorrect -- corrected patch to follow!

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] netfilter: fix type mismatch with error return from nft_parse_u32_check
  2016-10-25 19:08 [PATCH] netfilter: fix type mismatch with error return from nft_parse_u32_check John W. Linville
  2016-10-25 19:55 ` John W. Linville
@ 2016-10-25 19:56 ` John W. Linville
  2016-10-27 16:26   ` Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: John W. Linville @ 2016-10-25 19:56 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Patrick McHardy, Jozsef Kadlecsik, David S. Miller, netdev,
	John W. Linville, Laura Garcia Liebana, Pablo Neira Ayuso,
	Dan Carpenter

Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of
u32 netlink attributes") introduced nft_parse_u32_check with a return
value of "unsigned int", yet on error it returns "-ERANGE".

This patch corrects the mismatch by changing the return value to "int",
which happens to match the actual users of nft_parse_u32_check already.

Found by Coverity, CID 1373930.

Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error
handling in nft_exthdr_init()) attempted to address the issue, but
did not address the return type of nft_parse_u32_check.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Cc: Laura Garcia Liebana <nevola@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 36b701fae12ac ("netfilter: nf_tables: validate maximum value...")
---
 include/net/netfilter/nf_tables.h | 2 +-
 net/netfilter/nf_tables_api.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 5031e072567b..da43f50b39c6 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -145,7 +145,7 @@ static inline enum nft_registers nft_type_to_reg(enum nft_data_types type)
 	return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE;
 }
 
-unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest);
 unsigned int nft_parse_register(const struct nlattr *attr);
 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
 
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 24db22257586..32fa4f08444a 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4421,7 +4421,7 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
  *	Otherwise a 0 is returned and the attribute value is stored in the
  *	destination variable.
  */
-unsigned int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
+int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest)
 {
 	u32 val;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] netfilter: fix type mismatch with error return from nft_parse_u32_check
  2016-10-25 19:56 ` [PATCH v2] " John W. Linville
@ 2016-10-27 16:26   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-10-27 16:26 UTC (permalink / raw)
  To: John W. Linville
  Cc: netfilter-devel, Patrick McHardy, Jozsef Kadlecsik,
	David S. Miller, netdev, Laura Garcia Liebana, Dan Carpenter

On Tue, Oct 25, 2016 at 03:56:39PM -0400, John W. Linville wrote:
> Commit 36b701fae12ac ("netfilter: nf_tables: validate maximum value of
> u32 netlink attributes") introduced nft_parse_u32_check with a return
> value of "unsigned int", yet on error it returns "-ERANGE".
> 
> This patch corrects the mismatch by changing the return value to "int",
> which happens to match the actual users of nft_parse_u32_check already.
> 
> Found by Coverity, CID 1373930.
> 
> Note that commit 21a9e0f1568ea ("netfilter: nft_exthdr: fix error
> handling in nft_exthdr_init()) attempted to address the issue, but
> did not address the return type of nft_parse_u32_check.

Applied, thanks John.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-27 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-25 19:08 [PATCH] netfilter: fix type mismatch with error return from nft_parse_u32_check John W. Linville
2016-10-25 19:55 ` John W. Linville
2016-10-25 19:56 ` [PATCH v2] " John W. Linville
2016-10-27 16:26   ` Pablo Neira Ayuso

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).