public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* SHMLBA and compat tasks
@ 2004-02-28  1:41 Arun Sharma
  2004-02-28 23:55 ` David S. Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Arun Sharma @ 2004-02-28  1:41 UTC (permalink / raw)
  To: linux-arch

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

The current Linux implementation of shmat() insists on SHMLBA alignment
even when shmflg & SHM_RND == 0. This is not consistent with the man pages
and the single UNIX spec, which require only a page-aligned address.

man page:

> If shmaddr isn’t NULL and SHM_RND is asserted  in  shmflg,  the  attach
> occurs at the address equal to shmaddr rounded down to the nearest mul-
> tiple of SHMLBA.  Otherwise shmaddr must be a page-aligned  address  at
> which the attach occurs.

This is not a problem for many platforms because SHMLBA == PAGE_SIZE. It's
also not a problem for 64 bit programs running on 64 bit platforms,
because arch_get_unmapped_area() typically guarantees SHMLBA alignment,
even when SHM_RND is not asserted.

However, for 32 bit compatiblity programs, an innocuous sequence such as:

p = shmat(id, 0, shmflg)  /* shmflag & SHM_RND == 0 */
/* p is page-aligned, but may not be SHMLBA aligned */
shmdt(p)
shmat(id, p, shmflg) == -EINVAL ??

can fail. The attached patch fixes the problem for ia64. Can other arch
maintainers confirm that it doesn't break anything for you ?

	-Arun

[-- Attachment #2: shmat.patch --]
[-- Type: text/plain, Size: 339 bytes --]

--- linux/ipc/shm.c.orig	2003-04-28 11:19:24.000000000 -0700
+++ linux/ipc/shm.c	2003-05-09 13:26:13.000000000 -0700
@@ -600,7 +600,7 @@
 		if (addr & (SHMLBA-1)) {
 			if (shmflg & SHM_RND)
 				addr &= ~(SHMLBA-1);	   /* round down */
-			else
+			else if (addr & ~PAGE_MASK)
 				return -EINVAL;
 		}
 		flags = MAP_SHARED | MAP_FIXED;

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-03-06  7:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-28  1:41 SHMLBA and compat tasks Arun Sharma
2004-02-28 23:55 ` David S. Miller
2004-02-29  2:11   ` Arun Sharma
2004-03-01  5:57     ` David S. Miller
2004-03-01 19:33       ` Arun Sharma
2004-03-01 19:41         ` David Mosberger
2004-03-01 20:11           ` David S. Miller
2004-03-01 20:17             ` David Mosberger
2004-03-01 20:16           ` Arun Sharma
2004-03-01 20:55             ` Matthew Wilcox
2004-03-02 19:43               ` Arun Sharma
2004-03-06  2:37                 ` Arun Sharma
2004-03-06  7:39                   ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox