Re: [ckrm-tech] Re: [PATCH] Process Events Connector

From: Matt Helsley
Date: Fri Oct 28 2005 - 20:05:16 EST


On Fri, 2005-10-28 at 16:56 -0700, Matt Helsley wrote:
> OK, I wasn't as thorough as I had hoped re: 64-bit kernel/32-bit
> userspace. The uid_t and gid_t types appear to present a problem to the
> following:
>
> User <-> Kernel
> i386 <-> x86_64/IA64
> sparc <-> sparc64
> s390 <-> s390x
>
> :(
>
> I'll look at this some more and see if I need to resubmit. Until then
> I'll hold off on my request for inclusion in -mm.
>
> Cheers,
> -Matt Helsley

Userspace can include sys/types.h -- in which case uid_t and gid_t
match -- or linux/types.h -- in which case they are not guaranteed to
match. To further complicate things translation is not possible because
the connector broadcasts the events to multiple 'listener's. A mix of 32
and 64-bit userspace programs could be listening; guaranteeing
incompatibility if the structure layouts do not match.

This patch addresses the problem by fixing the size to the largest size
found in the kernel (and likely the largest size needed). This preserves
the total size of the event structure while ensuring that the event
structure layouts match.

Are there better alternative solutions?

Signed-off-by: Matt Helsley <matthltc@xxxxxxxxxx>

---

Index: linux-2.6.14/include/linux/cn_proc.h
===================================================================
--- linux-2.6.14.orig/include/linux/cn_proc.h
+++ linux-2.6.14/include/linux/cn_proc.h
@@ -84,16 +84,16 @@ struct proc_event {

struct id_proc_event {
pid_t process_pid;
pid_t process_tgid;
union {
- uid_t ruid; /* current->uid */
- gid_t rgid; /* current->gid */
+ __u32 ruid; /* task uid */
+ __u32 rgid; /* task gid */
};
union {
- uid_t euid;
- gid_t egid;
+ __u32 euid;
+ __u32 egid;
};
} id;

struct exit_proc_event {
pid_t process_pid;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/