linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: bridge: fix error return code of do_update_counters()
@ 2021-03-09  2:28 Jia-Ju Bai
  2021-03-09 11:01 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-09  2:28 UTC (permalink / raw)
  To: pablo, kadlec, fw, roopa, nikolay, davem, kuba
  Cc: netfilter-devel, coreteam, bridge, netdev, linux-kernel, Jia-Ju Bai

When find_table_lock() returns NULL to t, no error return code of
do_update_counters() is assigned.
To fix this bug, ret is assigned with -ENOENT in this case.

Fixes: 49facff9f925 ("netfilter: ebtables: split update_counters into two functions")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 net/bridge/netfilter/ebtables.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index ebe33b60efd6..66c9e4077985 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1256,8 +1256,10 @@ static int do_update_counters(struct net *net, const char *name,
 		return -ENOMEM;
 
 	t = find_table_lock(net, name, &ret, &ebt_mutex);
-	if (!t)
+	if (!t) {
+		ret = -ENOENT;
 		goto free_tmp;
+	}
 
 	if (num_counters != t->private->nentries) {
 		ret = -EINVAL;
-- 
2.17.1


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

* Re: [PATCH] net: bridge: fix error return code of do_update_counters()
  2021-03-09  2:28 [PATCH] net: bridge: fix error return code of do_update_counters() Jia-Ju Bai
@ 2021-03-09 11:01 ` Florian Westphal
  2021-03-09 13:31   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2021-03-09 11:01 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: pablo, kadlec, fw, roopa, nikolay, davem, kuba, netfilter-devel,
	coreteam, bridge, netdev, linux-kernel

Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
> When find_table_lock() returns NULL to t, no error return code of
> do_update_counters() is assigned.

Its -ENOENT.

>  	t = find_table_lock(net, name, &ret, &ebt_mutex);
                                       ^^^^^

ret is passed to find_table_lock, which passes it to
find_inlist_lock_noload() which will set *ret = -ENOENT
for NULL case.

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

* Re: [PATCH] net: bridge: fix error return code of do_update_counters()
  2021-03-09 11:01 ` Florian Westphal
@ 2021-03-09 13:31   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-09 13:31 UTC (permalink / raw)
  To: Florian Westphal
  Cc: pablo, kadlec, roopa, nikolay, davem, kuba, netfilter-devel,
	coreteam, bridge, netdev, linux-kernel



On 2021/3/9 19:01, Florian Westphal wrote:
> Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
>> When find_table_lock() returns NULL to t, no error return code of
>> do_update_counters() is assigned.
> Its -ENOENT.
>
>>   	t = find_table_lock(net, name, &ret, &ebt_mutex);
>                                         ^^^^^
>
> ret is passed to find_table_lock, which passes it to
> find_inlist_lock_noload() which will set *ret = -ENOENT
> for NULL case.

Thanks for the reply!
I did not notice "&ret" in find_table_lock()...
I am sorry for the false positive.


Best wishes,
Jia-Ju Bai

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

end of thread, other threads:[~2021-03-09 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  2:28 [PATCH] net: bridge: fix error return code of do_update_counters() Jia-Ju Bai
2021-03-09 11:01 ` Florian Westphal
2021-03-09 13:31   ` Jia-Ju Bai

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