diff mbox series

net: bridge: fix error return code of do_update_counters()

Message ID 20210309022854.17904-1-baijiaju1990@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net: bridge: fix error return code of do_update_counters() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Jia-Ju Bai March 9, 2021, 2:28 a.m. UTC
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(-)

Comments

Florian Westphal March 9, 2021, 11:01 a.m. UTC | #1
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.
Jia-Ju Bai March 9, 2021, 1:31 p.m. UTC | #2
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
diff mbox series

Patch

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;