[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111109141853.GB4010@sergelap>
Date: Wed, 9 Nov 2011 08:18:53 -0600
From: "Serge E. Hallyn" <serge.hallyn@...onical.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Serge Hallyn <serge@...lyn.com>, linux-kernel@...r.kernel.org,
containers@...ts.linux-foundation.org, oleg@...hat.com,
richard@....at, ebiederm@...ssion.com, dhowells@...hat.com,
eparis@...hat.com
Subject: Re: [PATCH 1/6] user namespace: make signal.c respect user
namespaces (v4)
Quoting Andrew Morton (akpm@...ux-foundation.org):
> On Fri, 4 Nov 2011 22:24:37 +0000
> Serge Hallyn <serge@...lyn.com> wrote:
>
> > +static inline void fixup_uid(struct siginfo *info, struct task_struct *t)
> > +{
> > +#ifdef CONFIG_USER_NS
> > + if (current_user_ns() == task_cred_xxx(t, user_ns))
> > +#endif
> > + return;
> > +
> > + if (SI_FROMKERNEL(info))
> > + return;
> > +
> > + info->si_uid = user_ns_map_uid(task_cred_xxx(t, user_ns),
> > + current_cred(), info->si_uid);
> > +}
>
> err, this function is a no-op if CONFIG_USER_NS=n. If that was
> intentional then why on earth do this in such a weird fashion? If
(I didn't write it, but) I think the assumption was that the compiler
would optimize it all away if !CONFIG_USER_NS, and in this way the
call site didn't need to be obscured with the #ifdef. Is there a way
that's better? Would you prefer something like:
+#ifdef CONFIG_USER_NS
+static inline void fixup_uid(struct siginfo *info, struct task_struct *t)
+{
+ if (current_user_ns() == task_cred_xxx(t, user_ns))
+ return;
+
+ if (SI_FROMKERNEL(info))
+ return;
+
+ info->si_uid = user_ns_map_uid(task_cred_xxx(t, user_ns),
+ current_cred(), info->si_uid);
+}
+#else
+static inline void fixup_uid(struct siginfo *info, struct task_struct *t)
+{
+ return;
+}
+#endif
? It's less sneaky at least.
> unintentional then it makes me wonder how well tested all this was with
> CONFIG_USER_NS=n?
>
> I vaguely remember that I've forgotten how all this stuff works. Some
> additional review input would be nice (cough-oleg-cough).
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists