Re: [PATCH] Uniquely identifying memory usage

Alexander Viro (viro@math.psu.edu)
Fri, 30 Jul 1999 11:06:19 -0400 (EDT)


On Sat, 31 Jul 1999, Martijn van Oosterhout wrote:

> But userspace programs only need the number to compare. They can't
> use it for anything else. It's just a number. Trying to generate a
> small integer elsewhere only leads to consistancy problems if not
> done right.

Keep in mind that those animals are reused. OTOH adding a generation
number to mm_struct is trivial - the only static one is init_mm (*never*
happens to be tsk->mm under 2.3.11+, only for kernel threads under the
earlier kernels) and the rest is always created by mm_alloc(). So it's a
matter of one static counter.

> In other words, you're hardly exporting state secrets. Any program
> that tries to use this value for anything other than comparisons
> should be shot.

It's a race unless you are dealing with your children. Nothing guarantees
that process will not be killed and its PID reused between the moments
when you read the ids. The only way to do it without race is to watch for
SIGCHLD.

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