[NETFILTER] nfnetlink: only load subsystems if CAP_NET_ADMIN is set

Without this patch, any user can cause nfnetlink subsystems to be
autoloaded.  Those subsystems however could add significant processing
overhead to packet processing, and would refuse any configuration messages
from non-CAP_NET_ADMIN processes anyway.

This patch follows a suggestion from Patrick McHardy.

Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Harald Welte 2005-11-09 13:02:16 -08:00 коммит произвёл David S. Miller
Родитель 5978a9b82c
Коммит ed77de9fc6
1 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -240,15 +240,18 @@ static inline int nfnetlink_rcv_msg(struct sk_buff *skb,
ss = nfnetlink_get_subsys(type); ss = nfnetlink_get_subsys(type);
if (!ss) { if (!ss) {
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
/* don't call nfnl_shunlock, since it would reenter if (cap_raised(NETLINK_CB(skb).eff_cap, CAP_NET_ADMIN)) {
* with further packet processing */ /* don't call nfnl_shunlock, since it would reenter
up(&nfnl_sem); * with further packet processing */
request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type)); up(&nfnl_sem);
nfnl_shlock(); request_module("nfnetlink-subsys-%d",
ss = nfnetlink_get_subsys(type); NFNL_SUBSYS_ID(type));
nfnl_shlock();
ss = nfnetlink_get_subsys(type);
}
if (!ss) if (!ss)
#endif #endif
goto err_inval; goto err_inval;
} }
nc = nfnetlink_find_client(type, ss); nc = nfnetlink_find_client(type, ss);