public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Rohland <cr@sap.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Richard Jerrell <jerrell@missioncriticallinux.com>
Cc: linux-kernel@vger.kernel.org
Subject: [Patch] Re: Bug in 2.4.0-test9 and test10 with sys_shmat()
Date: 17 Nov 2000 15:37:38 +0100	[thread overview]
Message-ID: <qwwn1eyu0jx.fsf@sap.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0011161156270.13545-100000@jerrell.lowell.mclinux.com>
In-Reply-To: Richard Jerrell's message of "Thu, 16 Nov 2000 11:57:15 -0500 (EST)"

Hi Linus,

The attached patch fixes two things:

1) shmat should not oops on shmid < 0
2) I think the shm tables should be allocated with GFP_USER instead of
   GFP_KERNEL since these are user requests.

Greetings
		Christoph

--- 4-11-6/ipc/shm.c	Wed Oct  4 15:58:02 2000
+++ linux/ipc/shm.c	Fri Nov 17 13:47:29 2000
@@ -572,13 +572,13 @@
 	if (pages == 0)
 		return NULL;
 
-	ret = kmalloc ((dir+1) * sizeof(pte_t *), GFP_KERNEL);
+	ret = kmalloc ((dir+1) * sizeof(pte_t *), GFP_USER);
 	if (!ret)
 		goto nomem;
 
 	for (ptr = ret; ptr < ret+dir ; ptr++)
 	{
-		*ptr = (pte_t *)__get_free_page (GFP_KERNEL);
+		*ptr = (pte_t *)__get_free_page (GFP_USER);
 		if (!*ptr)
 			goto free;
 		init_ptes (*ptr, PTES_PER_PAGE);
@@ -586,7 +586,7 @@
 
 	/* The last one is probably not of PAGE_SIZE: we use kmalloc */
 	if (last) {
-		*ptr = kmalloc (last*sizeof(pte_t), GFP_KERNEL);
+		*ptr = kmalloc (last*sizeof(pte_t), GFP_USER);
 		if (!*ptr)
 			goto free;
 		init_ptes (*ptr, last);
@@ -724,7 +724,7 @@
 	struct shmid_kernel *shp;
 	pte_t		   **dir;
 
-	shp = (struct shmid_kernel *) kmalloc (sizeof (*shp) + namelen, GFP_KERNEL);
+	shp = (struct shmid_kernel *) kmalloc (sizeof (*shp) + namelen, GFP_USER);
 	if (!shp)
 		return ERR_PTR(-ENOMEM);
 
@@ -1202,7 +1202,7 @@
 	char   name[SHM_FMT_LEN+1];
 	void *user_addr;
 
-	if (!shm_sb || (shmid % SEQ_MULTIPLIER) == zero_id)
+	if (!shm_sb || shmid < 0 || (shmid % SEQ_MULTIPLIER) == zero_id)
 		return -EINVAL;
 
 	if ((addr = (ulong)shmaddr)) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

      reply	other threads:[~2000-11-17 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-16 16:57 Bug in 2.4.0-test9 and test10 with sys_shmat() Richard Jerrell
2000-11-17 14:37 ` Christoph Rohland [this message]

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=qwwn1eyu0jx.fsf@sap.com \
    --to=cr@sap.com \
    --cc=jerrell@missioncriticallinux.com \
    --cc=torvalds@transmeta.com \
    /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