linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tyler Hicks <tyhicks@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tejun Heo <tj@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	bridge@lists.linux-foundation.org,
	Linux Containers <containers@lists.linux-foundation.org>
Subject: [PATCH net-next v3 3/8] kobject: kset_create_and_add() - fetch ownership info from parent
Date: Fri, 20 Jul 2018 21:56:49 +0000	[thread overview]
Message-ID: <1532123814-1109-4-git-send-email-tyhicks@canonical.com> (raw)
In-Reply-To: <1532123814-1109-1-git-send-email-tyhicks@canonical.com>

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

This change implements get_ownership() for ksets created with
kset_create_and_add() call by fetching ownership data from parent kobject.
This is done mostly for benefit of "queues" attribute of net devices so
that corresponding directory belongs to container's root instead of global
root for network devices in a container.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
---
 lib/kobject.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index f2dc1f756007..389829d3a1d1 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -887,9 +887,16 @@ static void kset_release(struct kobject *kobj)
 	kfree(kset);
 }
 
+void kset_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
+{
+	if (kobj->parent)
+		kobject_get_ownership(kobj->parent, uid, gid);
+}
+
 static struct kobj_type kset_ktype = {
 	.sysfs_ops	= &kobj_sysfs_ops,
-	.release = kset_release,
+	.release	= kset_release,
+	.get_ownership	= kset_get_ownership,
 };
 
 /**
-- 
2.7.4


  parent reply	other threads:[~2018-07-20 21:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 21:56 [PATCH net-next v3 0/8] Make /sys/class/net per net namespace objects belong to container Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 1/8] kernfs: allow creating kernfs objects with arbitrary uid/gid Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 2/8] sysfs, kobject: allow creating kobject belonging to arbitrary users Tyler Hicks
2018-07-20 21:56 ` Tyler Hicks [this message]
2018-07-20 21:56 ` [PATCH net-next v3 4/8] driver core: set up ownership of class devices in sysfs Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 5/8] net-sysfs: require net admin in the init ns for setting tx_maxrate Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 6/8] net-sysfs: make sure objects belong to container's owner Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 7/8] net: create reusable function for getting ownership info of sysfs inodes Tyler Hicks
2018-07-20 21:56 ` [PATCH net-next v3 8/8] bridge: make sure objects belong to container's owner Tyler Hicks
2018-07-21  6:45 ` [PATCH net-next v3 0/8] Make /sys/class/net per net namespace objects belong to container David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532123814-1109-4-git-send-email-tyhicks@canonical.com \
    --to=tyhicks@canonical.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).