Re: [PATCH 4/4] fanotify: drops the packed attribute from userspace event metadata

From: Andreas Gruenbacher
Date: Mon Aug 23 2010 - 12:19:21 EST


On Monday 23 August 2010 02:37:10 Eric Paris wrote:
> #define FANOTIFY_METADATA_VERSION 1

FANOTIFY_METADATA_VERSION should be incremented, too.

> struct fanotify_event_metadata {
> __u32 event_len;
> __u32 vers;
> __u64 mask;

We don't actually care if there are any holes in this structure; all we
care about is that the structure has the same alignment on 32-bit and
64-bit architectures.

Using type aligned_u64 here instead of __u64 will do the trick.

> +#ifdef __KERNEL__
> +/* see struct fanotify_event_metadata for the reason this exists */
> +struct fan_event_meta_packed {
> + __u32 event_len;
> + __u32 vers;
> + __u64 mask;
> + __s32 fd;
> + __s32 pid;
> +} __attribute__ ((packed));

This does not add much value; the two structures can still go out of sync
A note to be careful about changes to struct fanotify_event_metadata
should really be warning enough.

Andreas
--
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/