Re: [PATCH 2.6.10-rc2] RLIMIT_MEMLOCK accounting of shmctl() SHM_LOCK is broken

From: Michael Kerrisk
Date: Tue Nov 23 2004 - 13:06:09 EST


> "Michael Kerrisk" <mtk-lkml@xxxxxxx> wrote:
> >
> > The accounting of shmctl() SHM_LOCK memory locks against the
> > user structure is broken. The problem is that the check
> > of the size of the to-be-locked region is based on
> > the size of the segment as specified when it was created
> > by shmget() (this size is *not* rounded up to a page
> > boundary). This size is then rounded down (>> PAGE_SHIFT)
> > to PAGE_SIZE during the check in
> > mm/mlock.c::user_shm_lock().
>
> True. We should make the same change to user_shm_unlock(), and we may as
> well tweak the excessive spinlock coverage in there too.

Thanks for the confirmation Andrew.

[...]

> and then ask Hugh and Manfred to double-check.
>
> Looking at the callers, we do:
>
> user_shm_lock(inode->i_size, ...);
>
> then, later:
>
> user_shm_unlock(inode->i_size, ...);
>
> which does make one wonder "what happens if the file got larger while it
> was locked"?

Not sure if I'm missing your point, but, just considering it from
the point of view of System V shared memory, the segment can't
change in size after it has been created.

Cheers,

Michael

--
Geschenkt: 3 Monate GMX ProMail + 3 Top-Spielfilme auf DVD
++ Jetzt kostenlos testen http://www.gmx.net/de/go/mail ++
-
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/