* Re: [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces
@ 2015-10-09 3:43 Hillf Danton
2015-10-09 7:34 ` Sergei Zviagintsev
0 siblings, 1 reply; 3+ messages in thread
From: Hillf Danton @ 2015-10-09 3:43 UTC (permalink / raw)
To: 'Sergei Zviagintsev'
Cc: Greg Kroah-Hartman, 'Daniel Mack',
'David Herrmann', 'Djalal Harouni', linux-kernel
> @@ -730,15 +730,21 @@ static void kdbus_meta_export_caps(struct kdbus_meta_caps *out,
>
> /*
> * This translates the effective capabilities of 'cred' into the given
> - * user-namespace. If the given user-namespace is a child-namespace of
> - * the user-namespace of 'cred', the mask can be copied verbatim. If
> - * not, the mask is cleared.
> - * There's one exception: If 'cred' is the owner of any user-namespace
> - * in the path between the given user-namespace and the user-namespace
> - * of 'cred', then it has all effective capabilities set. This means,
> - * the user who created a user-namespace always has all effective
> - * capabilities in any child namespaces. Note that this is based on the
> - * uid of the namespace creator, not the task hierarchy.
> + * user namespace according to the following rules:
> + *
> + * - If 'cred' is a member of the given user namespace or any of its
> + * parent user namespaces, the mask is copied verbatim. That is, if
Clearer/Better if "if not, the mask is cleared." is reserved.
> + * a process has a capability in a user namespace, then it has it in
> + * all child user namespaces too.
> + *
> + * - If the effective UID of 'cred' matches the owner of the given user
> + * namespace or any of its parent user namespaces and 'cred' itself
> + * resides in the parent of that user namespace which it owns, then
> + * it has all effective capabilities set. This means that the user
> + * who created a user namespace always has all effective capabilities
> + * in all child namespaces while staying in the parent of the user
> + * namespace which it owns. Note that this is based on the UID of the
> + * namespace creator, not the task hierarchy.
> */
> for (iter = user_ns; iter; iter = iter->parent) {
> if (iter == cred->user_ns) {
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces
2015-10-09 3:43 [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces Hillf Danton
@ 2015-10-09 7:34 ` Sergei Zviagintsev
0 siblings, 0 replies; 3+ messages in thread
From: Sergei Zviagintsev @ 2015-10-09 7:34 UTC (permalink / raw)
To: Hillf Danton
Cc: Greg Kroah-Hartman, 'Daniel Mack',
'David Herrmann', 'Djalal Harouni', linux-kernel
Hi,
On Fri, Oct 09, 2015 at 11:43:22AM +0800, Hillf Danton wrote:
> > @@ -730,15 +730,21 @@ static void kdbus_meta_export_caps(struct kdbus_meta_caps *out,
> >
> > /*
> > * This translates the effective capabilities of 'cred' into the given
> > - * user-namespace. If the given user-namespace is a child-namespace of
> > - * the user-namespace of 'cred', the mask can be copied verbatim. If
> > - * not, the mask is cleared.
> > - * There's one exception: If 'cred' is the owner of any user-namespace
> > - * in the path between the given user-namespace and the user-namespace
> > - * of 'cred', then it has all effective capabilities set. This means,
> > - * the user who created a user-namespace always has all effective
> > - * capabilities in any child namespaces. Note that this is based on the
> > - * uid of the namespace creator, not the task hierarchy.
> > + * user namespace according to the following rules:
> > + *
> > + * - If 'cred' is a member of the given user namespace or any of its
> > + * parent user namespaces, the mask is copied verbatim. That is, if
>
> Clearer/Better if "if not, the mask is cleared." is reserved.
Indeed, thanks!
>
> > + * a process has a capability in a user namespace, then it has it in
> > + * all child user namespaces too.
> > + *
> > + * - If the effective UID of 'cred' matches the owner of the given user
> > + * namespace or any of its parent user namespaces and 'cred' itself
> > + * resides in the parent of that user namespace which it owns, then
> > + * it has all effective capabilities set. This means that the user
> > + * who created a user namespace always has all effective capabilities
> > + * in all child namespaces while staying in the parent of the user
> > + * namespace which it owns. Note that this is based on the UID of the
> > + * namespace creator, not the task hierarchy.
> > */
> > for (iter = user_ns; iter; iter = iter->parent) {
> > if (iter == cred->user_ns) {
> > --
> > 1.8.3.1
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 00/44] kdbus cleanups
@ 2015-10-08 11:31 Sergei Zviagintsev
2015-10-08 11:31 ` [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces Sergei Zviagintsev
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Zviagintsev @ 2015-10-08 11:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Daniel Mack, David Herrmann, Djalal Harouni
Cc: linux-kernel, Sergei Zviagintsev
Hi all,
This is a set of various kdbus code cleanups. Patches are ordered by
increasing complexity, starting with docs and comments fixes and
one-liners.
Patch 29 is the revised version of
http://lkml.kernel.org/g/1435497454-10464-6-git-send-email-sergei@s15v.net
Feel free to ask to change layout of this, split/join, etc if necessary.
Thanks, Sergei
Sergei Zviagintsev (44):
Documentation/kdbus: Document new name registry flags
uapi: kdbus.h: Kernel-doc fixes
kdbus: Kernel-docs and comments trivial fixes
kdbus: Update kernel-doc for struct kdbus_pool
kdbus: Add comment on merging free pool slices
kdbus: Fix kernel-doc for struct kdbus_gaps
kdbus: Fix comment on translation of caps between namespaces
kdbus: Rename var in kdbus_meta_export_caps()
kdbus: Remove unused KDBUS_MSG_MAX_SIZE constant
kdbus: Use conditional operator
kdbus: Cosmetic fix of kdbus_name_is_valid()
kdbus: Use conventional list macros in __kdbus_pool_slice_release()
kdbus: Use list_next_entry() in kdbus_queue_entry_unlink()
kdbus: Simplify expression in kdbus_get_memfd()
kdbus: Simplify bitwise expression in kdbus_meta_get_mask()
kdbus: Drop redundant code from kdbus_name_acquire()
kdbus: Drop duplicated code from kdbus_pool_slice_alloc()
kdbus: Add var initialization to kdbus_conn_entry_insert()
kdbus: Drop useless initialization from kdbus_conn_reply()
kdbus: Drop useless initialization from kdbus_cmd_hello()
kdbus: Cleanup tests in kdbus_cmd_send()
kdbus: Cleanup error path in kdbus_staging_new_user()
kdbus: Cleanup kdbus_conn_call()
kdbus: Cleanup kdbus_conn_unicast()
kdbus: Cleanup kdbus_cmd_conn_info()
kdbus: Cleanup kdbus_pin_dst()
kdbus: Cleanup kdbus_conn_new()
kdbus: Cleanup kdbus_queue_entry_new()
kdbus: Improve tests on incrementing quota
kdbus: Cleanup kdbus_meta_proc_mask()
kdbus: Cleanup kdbus_conn_move_messages()
kdbus: Remove duplicated code from kdbus_conn_lock2()
kdbus: Improve kdbus_staging_reserve()
kdbus: Improve kdbus_conn_entry_sync_attach()
kdbus: Drop goto from kdbus_queue_entry_link()
kdbus: Improve kdbus_name_release()
kdbus: Fix error path in kdbus_meta_proc_collect_cgroup()
kdbus: Fix error path in kdbus_user_lookup()
kdbus: Cleanup kdbus_user_lookup()
kdbus: Cleanup kdbus_item_validate_name()
kdbus: Fix memfd install algorithm
kdbus: Check if fd is allocated before trying to free it
kdbus: Give up on failed fd allocation
kdbus: Cleanup kdbus_gaps_install()
Documentation/kdbus/kdbus.name.xml | 42 +++++++++-
include/uapi/linux/kdbus.h | 43 +++++-----
ipc/kdbus/connection.c | 157 +++++++++++++++----------------------
ipc/kdbus/connection.h | 19 ++---
ipc/kdbus/domain.c | 38 +++++----
ipc/kdbus/fs.c | 2 +-
ipc/kdbus/item.c | 26 +++---
ipc/kdbus/limits.h | 3 -
ipc/kdbus/message.c | 81 +++++++++----------
ipc/kdbus/message.h | 9 ++-
ipc/kdbus/metadata.c | 79 ++++++++++---------
ipc/kdbus/names.c | 32 ++++----
ipc/kdbus/node.c | 4 +-
ipc/kdbus/pool.c | 26 +++---
ipc/kdbus/queue.c | 51 ++++++------
ipc/kdbus/queue.h | 2 +-
16 files changed, 298 insertions(+), 316 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces
2015-10-08 11:31 [PATCH 00/44] kdbus cleanups Sergei Zviagintsev
@ 2015-10-08 11:31 ` Sergei Zviagintsev
0 siblings, 0 replies; 3+ messages in thread
From: Sergei Zviagintsev @ 2015-10-08 11:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Daniel Mack, David Herrmann, Djalal Harouni
Cc: linux-kernel, Sergei Zviagintsev
Update the comment to keep it in sync with the algorithm. The current
one lacks words on that in order to have all capabilities in the owned
user namespace the process must stay in the parent of that namespace.
Also (obvious, but should be mentioned for completeness) the mask is
copied verbatim if the process is a member of the given userns.
Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
---
ipc/kdbus/metadata.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
index 71ca475a80d5..4ff4b99a40e0 100644
--- a/ipc/kdbus/metadata.c
+++ b/ipc/kdbus/metadata.c
@@ -730,15 +730,21 @@ static void kdbus_meta_export_caps(struct kdbus_meta_caps *out,
/*
* This translates the effective capabilities of 'cred' into the given
- * user-namespace. If the given user-namespace is a child-namespace of
- * the user-namespace of 'cred', the mask can be copied verbatim. If
- * not, the mask is cleared.
- * There's one exception: If 'cred' is the owner of any user-namespace
- * in the path between the given user-namespace and the user-namespace
- * of 'cred', then it has all effective capabilities set. This means,
- * the user who created a user-namespace always has all effective
- * capabilities in any child namespaces. Note that this is based on the
- * uid of the namespace creator, not the task hierarchy.
+ * user namespace according to the following rules:
+ *
+ * - If 'cred' is a member of the given user namespace or any of its
+ * parent user namespaces, the mask is copied verbatim. That is, if
+ * a process has a capability in a user namespace, then it has it in
+ * all child user namespaces too.
+ *
+ * - If the effective UID of 'cred' matches the owner of the given user
+ * namespace or any of its parent user namespaces and 'cred' itself
+ * resides in the parent of that user namespace which it owns, then
+ * it has all effective capabilities set. This means that the user
+ * who created a user namespace always has all effective capabilities
+ * in all child namespaces while staying in the parent of the user
+ * namespace which it owns. Note that this is based on the UID of the
+ * namespace creator, not the task hierarchy.
*/
for (iter = user_ns; iter; iter = iter->parent) {
if (iter == cred->user_ns) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-09 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 3:43 [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces Hillf Danton
2015-10-09 7:34 ` Sergei Zviagintsev
-- strict thread matches above, loose matches on Subject: below --
2015-10-08 11:31 [PATCH 00/44] kdbus cleanups Sergei Zviagintsev
2015-10-08 11:31 ` [PATCH 07/44] kdbus: Fix comment on translation of caps between namespaces Sergei Zviagintsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox