From: Chad Reese <creese@caviumnetworks.com>
To: linux-mips@linux-mips.org
Subject: 64bit kernel/N32 userspace - shmctl corrupts userspace memory
Date: Tue, 25 Jul 2006 17:32:41 -0700 [thread overview]
Message-ID: <44C6B829.8050508@caviumnetworks.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
If you're running a 64bit kernel with N32 userspace, shmctl will corrupt
memory in userspace. When copy_shmid_to_user() is called, it copies the
entire kernel shmid_ds into userspace. For a 64bit kernel, this is 88
bytes. In N32 userspace it is 76 bytes.
My hack to get around the problem is attached, but I expect someone here
will be able to come up with a better fix. shmid_ds contains a lot of
members that are marked unused. Are these really useless?
Chad
[-- Attachment #2: shared_memory_shmctl_fix.patch --]
[-- Type: text/x-patch, Size: 810 bytes --]
Index: linux/ipc/shm.c
===================================================================
RCS file: /repository/octsw/linux/kernel_2.6/linux/ipc/shm.c,v
retrieving revision 1.1.1.6
retrieving revision 1.2
diff -u -r1.1.1.6 -r1.2
--- linux/ipc/shm.c 7 Jun 2006 19:19:51 -0000 1.1.1.6
+++ linux/ipc/shm.c 22 Jul 2006 02:26:11 -0000 1.2
@@ -321,7 +321,11 @@
out.shm_lpid = in->shm_lpid;
out.shm_nattch = in->shm_nattch;
- return copy_to_user(buf, &out, sizeof(out));
+ /* Use offsetof() instead of sizeof() since N32 userspace has a
+ different size including the unused fields. This just copies
+ what is used. The old method would corrupt data after the
+ structure */
+ return copy_to_user(buf, &out, offsetof(struct shmid_ds, shm_unused2));
}
default:
return -EINVAL;
next reply other threads:[~2006-07-26 0:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-26 0:32 Chad Reese [this message]
2006-07-26 2:04 ` 64bit kernel/N32 userspace - shmctl corrupts userspace memory Ralf Baechle
2006-07-26 2:30 ` Chad Reese
2006-07-26 3:13 ` Atsushi Nemoto
2006-07-26 2:07 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44C6B829.8050508@caviumnetworks.com \
--to=creese@caviumnetworks.com \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox