All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: don't unnecessarily load kernel modules in dev_ioctl()
@ 2018-03-06 22:27 ` Paul Moore
  0 siblings, 0 replies; 27+ messages in thread
From: Paul Moore @ 2018-03-06 22:27 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA, Al Viro
  Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA,
	selinux-+05T5uksL2qpZYMLLGbcSA

From: Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org>

Starting with v4.16-rc1 we've been seeing a higher than usual number
of requests for the kernel to load networking modules, even on events
which shouldn't trigger a module load (e.g. ioctl(TCGETS)).  Stephen
Smalley suggested the problem may lie in commit 44c02a2c3dc5
("dev_ioctl(): move copyin/copyout to callers") which moves changes
the network dev_ioctl() function to always call dev_load(),
regardless of the requested ioctl.

This patch moves the dev_load() calls back into the individual ioctls
while preserving the rest of the original patch.

Reported-by: Dominick Grift <dac.override-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Suggested-by: Stephen Smalley <sds-+05T5uksL2qpZYMLLGbcSA@public.gmane.org>
Signed-off-by: Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org>
---
 net/core/dev_ioctl.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 0ab1af04296c..a04e1e88bf3a 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -402,8 +402,6 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 	if (colon)
 		*colon = 0;
 
-	dev_load(net, ifr->ifr_name);
-
 	/*
 	 *	See which interface the caller is talking about.
 	 */
@@ -423,6 +421,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 	case SIOCGIFMAP:
 	case SIOCGIFINDEX:
 	case SIOCGIFTXQLEN:
+		dev_load(net, ifr->ifr_name);
 		rcu_read_lock();
 		ret = dev_ifsioc_locked(net, ifr, cmd);
 		rcu_read_unlock();
@@ -431,6 +430,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 		return ret;
 
 	case SIOCETHTOOL:
+		dev_load(net, ifr->ifr_name);
 		rtnl_lock();
 		ret = dev_ethtool(net, ifr);
 		rtnl_unlock();
@@ -447,6 +447,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 	case SIOCGMIIPHY:
 	case SIOCGMIIREG:
 	case SIOCSIFNAME:
+		dev_load(net, ifr->ifr_name);
 		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
 			return -EPERM;
 		rtnl_lock();
@@ -494,6 +495,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 		/* fall through */
 	case SIOCBONDSLAVEINFOQUERY:
 	case SIOCBONDINFOQUERY:
+		dev_load(net, ifr->ifr_name);
 		rtnl_lock();
 		ret = dev_ifsioc(net, ifr, cmd);
 		rtnl_unlock();
@@ -518,6 +520,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
 		    cmd == SIOCGHWTSTAMP ||
 		    (cmd >= SIOCDEVPRIVATE &&
 		     cmd <= SIOCDEVPRIVATE + 15)) {
+			dev_load(net, ifr->ifr_name);
 			rtnl_lock();
 			ret = dev_ifsioc(net, ifr, cmd);
 			rtnl_unlock();

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

end of thread, other threads:[~2018-03-08 20:53 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 22:27 [PATCH] net: don't unnecessarily load kernel modules in dev_ioctl() Paul Moore
2018-03-06 22:27 ` Paul Moore
2018-03-06 22:27 ` Paul Moore
2018-03-06 22:32 ` Paul Moore
2018-03-06 22:32   ` Paul Moore
2018-03-06 22:32   ` Paul Moore
     [not found]   ` <CAHC9VhR4FzwsAEO9O9Pnpkm2jOBajwZUkn_i0FqOMR_4ycag2g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-07 20:13     ` David Miller
2018-03-07 20:13       ` David Miller
2018-03-07 20:13       ` David Miller
2018-03-06 23:59 ` Stephen Hemminger
2018-03-06 23:59   ` Stephen Hemminger
2018-03-06 23:59   ` Stephen Hemminger
2018-03-07 13:46   ` Paul Moore
2018-03-07 13:46     ` Paul Moore
2018-03-07 13:46     ` Paul Moore
2018-03-08 17:34   ` David Miller
2018-03-08 17:34     ` David Miller
2018-03-08 17:34     ` David Miller
     [not found]     ` <20180308.123440.2224695014753871221.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2018-03-08 18:05       ` Eric Dumazet
2018-03-08 18:05         ` Eric Dumazet
2018-03-08 18:05         ` Eric Dumazet
     [not found]         ` <c2d378b6-80b3-d9e1-7087-95f143875067-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-08 18:11           ` David Miller
2018-03-08 18:11             ` David Miller
2018-03-08 18:11             ` David Miller
     [not found]             ` <20180308.131115.611191617522587758.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2018-03-08 20:53               ` Eric Dumazet
2018-03-08 20:53                 ` Eric Dumazet
2018-03-08 20:53                 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.