Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp962168imm; Fri, 13 Jul 2018 09:08:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfldc+0lqKNl7CwoT3DHZjIqZ/ZquwioHF2OXj6DQZXoRH9geDTJxuXLba43aUcZG9dOQR9 X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr6914716plv.193.1531498109504; Fri, 13 Jul 2018 09:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531498109; cv=none; d=google.com; s=arc-20160816; b=cF0nIHyzMycdZJGmpupAhv61hFnbs90mreEY27VSeeGfWGc5fsEwqTThjFk4vA5LPX Pot77WBEm3BTfFov9MYoBUbH5oMj+CSQSOO74/go1LVMfckYLn2GUD1itPzNXBYNpE8Q v5df3nbY9UEuA3uY47NtmOeVQIsuFtlLdE0Z45pW4fPM7EPK14UlQn4010OIURpom3kV 7tDvGCqRy+bQfTIdNFaJPCDFJNoYr5MfNYbUVoig50PZbIi76VBVXwqu0FOfa9y1Oyqf d5nX18+wHAM4ZYJxjqd8gSSafV0X2Z/2ltFDlrK4h5qfbsxOwb7WXhb0Bp2QsoKfdQ/y rsUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mE9+3laZIgxTy2elgI8pb3Ms0oGTLy0NxCqFGT8sid4=; b=0vcoMsl1QkPBdc3Z/Ofb+B2BiMyv5Lss/nc9X/0sG0AuoYEqvbP9Ex/Qvw7RtUM2oR j0rm03dbKvlj/fOYkSFM+mGJgenLUDD2UhWU1R95kAQqJ4EFa9LAAevFYKEvN/b5Jvrw hmuG3qpDSiaI08pO1041HOLH6QixfxYc8RJlVwr6jrhKe1ilE+ngnUY4JmA7Ch2ViyBG 9gT3rKVuXyZI9Evkw5fpyQ8SMx3hOLpgBnVE+odztpnYHYnt7/Wj9In1hEnHk28dwhU0 GS+lsLT92MZsm/Ix702tPbRTgHbak1Yv/nXeWP2M+Kfsb7LPaQzf7PZL2UxY+cHmiR+9 uu8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si24138681pla.9.2018.07.13.09.08.07; Fri, 13 Jul 2018 09:08:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731555AbeGMQWF (ORCPT + 99 others); Fri, 13 Jul 2018 12:22:05 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:38348 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729681AbeGMQWF (ORCPT ); Fri, 13 Jul 2018 12:22:05 -0400 Received: from 2.general.tyhicks.us.vpn ([10.172.64.53] helo=sec.ubuntu-ci) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fe0aj-0006pX-Lz; Fri, 13 Jul 2018 16:06:45 +0000 From: Tyler Hicks To: Greg Kroah-Hartman , Tejun Heo , "David S. Miller" , Stephen Hemminger Cc: Dmitry Torokhov , "Eric W. Biederman" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org, Linux Containers Subject: [PATCH v2 net-next 0/7] Make /sys/class/net per net namespace objects belong to container Date: Fri, 13 Jul 2018 16:05:42 +0000 Message-Id: <1531497949-1766-1-git-send-email-tyhicks@canonical.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a revival of an older patch set from Dmitry Torokhov: https://lore.kernel.org/lkml/1471386795-32918-1-git-send-email-dmitry.torokhov@gmail.com/ Here's Dmitry's description: There are objects in /sys hierarchy (/sys/class/net/) that logically belong to a namespace/container. Unfortunately all sysfs objects start their life belonging to global root, and while we could change ownership manually, keeping tracks of all objects that come and go is cumbersome. It would be better if kernel created them using correct uid/gid from the beginning. This series changes kernfs to allow creating object's with arbitrary uid/gid, adds get_ownership() callback to ktype structure so subsystems could supply their own logic (likely tied to namespace support) for determining ownership of kobjects, and adjusts sysfs code to make use of this information. Lastly net-sysfs is adjusted to make sure that objects in net namespace are owned by the root user from the owning user namespace. Note that we do not adjust ownership of objects moved into a new namespace (as when moving a network device into a container) as userspace can easily do it. I'm reviving this patch set because we would like this feature for system containers. One specific use case that we have is that libvirt is unable to configure its bridge device inside of a system container due to the bridge files in /sys/class/net/ being owned by init root instead of container root. The last two patches in this set are patches that I've added to Dmitry's original set to allow such configuration of the bridge device. Eric had previously provided feedback that he didn't favor these changes affecting all layers of the stack and that most of the changes could remain local to drivers/base/core.c. That feedback is certainly sensible but I wanted to send out v2 of the patch set without making that large of a change since quite a bit of time has passed and the bridge changes in the last patch of this set shows that not all of the changes will be local to drivers/base/core.c. I'm happy to make the changes if the original request still stands. I've verified that all of the bridge related files affected by patch 7 have proper access control checks for CAP_NET_ADMIN inside of the user namespace. I have *not* yet verified that all of the network device related sysfs files affected by patch 5 have proper access control checks. I was working under the assumption that those code paths already were verified when the first iteration of the patches were sent out. * Changes since v1: - Patch 1 was forward ported to use idr instead of ida for the inode num - Patch 5 was forward ported around the ro_after_init changes - Patch 5 received a build failure fix for !CONFIG_SYSFS - Patch 6 and 7 are new Thanks! Tyler