Bug 13906

Summary: BusyBox's IP applet: Flush all ip addresses if the given device is not exist
Product: Busybox Reporter: Devi Allipilli <devi.allipilli>
Component: NetworkingAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs, ranamazharp
Priority: P5    
Version: 1.31.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Devi Allipilli 2021-07-05 10:24:29 UTC
we have identified that BusyBox's IP applet flush IP addresses of all device if device given in command is not exist in system

e.g:
#busybox ip -4 address flush dev abcdefg

In this case if device 'abcdefg' not exists on system then it will flush addresses of all interfaces.

This behaviour is same across all version of BusyBox and since inception.


RCA:
We have analysed the issue and identified that whenever we are calling 'xll_name_to_index' function to perform interface name to interface index opertation we are not cheking the return values of it in the caller functions.


Proposing the below patch for the fix and requesting you to do the needful.
May be need to look into other areas for the same condition.


PATCH:
--- busybox-1.31.1/networking/libiproute/ipaddress.c    2021-04-30 19:06:47.872878596 +0530
+++ ipaddress.c 2021-04-30 19:00:14.688899593 +0530
@@ -486,7 +486,9 @@ int FAST_FUNC ipaddr_list_or_flush(char
     ll_init_map(&rth);

 

        if (filter_dev) {
-               G_filter.ifindex = xll_name_to_index(filter_dev);
+               if((G_filter.ifindex = xll_name_to_index(filter_dev)) <= 0) {
+                       return 1;
+               }
        }

 

        if (flush) {
Comment 1 Devi Allipilli 2021-07-05 10:39:01 UTC
*** Bug 13921 has been marked as a duplicate of this bug. ***
Comment 2 Devi Allipilli 2021-07-05 10:39:33 UTC
*** Bug 13916 has been marked as a duplicate of this bug. ***
Comment 3 Devi Allipilli 2021-07-05 10:40:00 UTC
*** Bug 13911 has been marked as a duplicate of this bug. ***