Re: [PATCH 3 of 4] ima: Linux Security Module implementation

From: Greg KH (greg@private)
Date: Fri May 20 2005 - 23:28:17 PDT


On Fri, May 20, 2005 at 09:43:34AM -0400, Reiner Sailer wrote:
> +/* security structure appended to inodes */
> +#define IMA_MAGIC 0x9999
> +struct ima_inode {
> +	unsigned short magic;
> +	atomic_t measure_count;	/* # processes currently using this file in measure-mode */
> +	ima_entry_flags dirty;
> +	char *file_name;	/* points to measure entry->fileName */
> +};
> +
> +/* security structure appended to measured files*/
> +struct ima_file {
> +	unsigned short magic;	/* identify our struct format */
> +	char is_measuring;	/* identify fds that are "measuring" */
> +};

magic values for structures protect you from nothing.  Do not use them.


> +static u32 decode_u32(u8 * buf)
> +{
> +	u32 val = buf[0];
> +	val = (val << 8) | (u8) buf[1];
> +	val = (val << 8) | (u8) buf[2];
> +	val = (val << 8) | (u8) buf[3];
> +	return val;
> +}
> +
> +static void encode_u32(u8 * buf, u32 val)
> +{
> +	buf[0] = (u8) val >> 24;
> +	buf[1] = (u8) val >> 16;
> +	buf[2] = (u8) val >> 8;
> +	buf[3] = (u8) val >> 0;
> +}

Hm, what's wrong with the standard kernel functions to do this kind of
thing?


> diff -uprN linux-2.6.12-rc4/security/ima/INSTALL linux-2.6.12-rc4-ima/security/ima/INSTALL
> --- linux-2.6.12-rc4/security/ima/INSTALL	1969-12-31 19:00:00.000000000 -0500
> +++ linux-2.6.12-rc4-ima/security/ima/INSTALL	2005-05-19 17:59:20.000000000 -0400

Kernel directories do not get a INSTALL file.  Stuff like that goes into
the Documentation/ directory.

greg k-h



This archive was generated by hypermail 2.1.3 : Fri May 20 2005 - 23:21:35 PDT