[rh8,1/2] netlink: protect NETLINK_REPAIR

Submitted by Andrey Zhadchenko on Nov. 11, 2020, 7:09 a.m.

Details

Message ID 1605078553-104365-1-git-send-email-andrey.zhadchenko@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Zhadchenko Nov. 11, 2020, 7:09 a.m.
Prevent using netlink repair mode from containers.

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
---
 net/netlink/af_netlink.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 46c2dbd..2b9e9c7 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1670,6 +1670,13 @@  static int netlink_setsockopt(struct socket *sock, int level, int optname,
 
 	switch (optname) {
 	case NETLINK_REPAIR:
+#ifdef CONFIG_VE
+		{
+			struct ve_struct *ve = get_exec_env();
+			if (!ve_is_super(ve) && !ve->is_pseudosuper)
+				return -ENOPROTOOPT;
+		}
+#endif
 		if (val)
 			nlk->flags |= NETLINK_F_REPAIR;
 		else