Re: fs/proc/base.c: text md5sums; tgid vs tid; and INF vs ONE?

From: Eric W. Biederman
Date: Tue Oct 30 2012 - 18:45:34 EST


Arvid Brodin <Arvid.Brodin@xxxxxxxx> writes:

> Hi,
>
> Below is a patch that adds a file /proc/PID/text_md5sum which when read returns the md5
> checksum of a process' text segment. (This would be used e.g. to make sure a process'
> code hasn't been tampered with.)
>
> However, I have a few questions:
>
> * What's the difference between the tgid_base_stuff and tid_base_stuff arrays? (One for
> processes and one for the process' threads? I haven't been able to find any info about
> this so I'm guessing.)

Yes. One for thread groups and one for threads.

> * When should I use the INF ("read") vs the ONE ("show") macro?

proc_read depends on the caller to allocate a 4k buffer, instead of
sizing the buffer based upon the size of the text being written. Which
makes proc_read an error prone and ultimately deprecated way of handling
things.

Using some variant on seq_file is preferred for new files.

> * Any other comments about the code?

There are known successful attacks against md5 so using md5 for
something new and security related is a bad idea.

Userspace can just as easily compute a security hash itself you don't
need kernel support.


I recommend you checkout the code in security/ima/ looks like it can
already do what you are trying to do.

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