Bug 6962 - ip: addr flush hangs forever when called by non-root user
Summary: ip: addr flush hangs forever when called by non-root user
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.22.x
Hardware: All Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-17 17:39 UTC by Andrej Gantvorg
Modified: 2019-05-22 20:37 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments
The quick-and-dirty patch that should further illustrate the issue. (1.67 KB, application/octet-stream)
2014-03-17 17:39 UTC, Andrej Gantvorg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrej Gantvorg 2014-03-17 17:39:48 UTC
Created attachment 5276 [details]
The quick-and-dirty patch that should further illustrate the issue.

When called without root privilleges, the "ip flush dev" command should return with a "permission denied" message.

Busybox' implementation sends an according rtnl message but does not check for response from kernel containing the error state (networking/libiproute/ipaddress.c, flush_update()). Thus, the for-loop in ipaddr_list_or_flush() is never left causing the applet to hang forever.
Comment 1 Andrej Gantvorg 2014-03-18 17:18:49 UTC
My initial impression proved partly incorrect: in case of success "ip addr flush dev XXX" receives no response from kernel. The receive in flush_update() must not block.
Comment 2 Mikael 2019-05-22 09:25:29 UTC
This problem also occurs when running as root without cap_net_admin capability. Docker containers by default run without this capability and hang with 100% CPU utilization if you run "ip addr flush dev <ifname>". This includes containers based on alpine which use busybox by default.
It would be nice with a solution to this problem.
Comment 3 Denys Vlasenko 2019-05-22 10:24:56 UTC
(In reply to Mikael from comment #2)

Can you strace the offending command?
Comment 4 Denys Vlasenko 2019-05-22 11:55:57 UTC
Fixed in git, please test.
Comment 5 Mikael 2019-05-22 20:37:08 UTC
Thanks for the patch, it solves the problem for me. It applied cleanly on version 1.30.1 which I tested.