public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mingming cao <cmm@us.ibm.com>
To: torvalds@transmeta.com, alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org, manfreds@colorfullife.com
Subject: [PATCH]Fix bug in msgrcv/shmat
Date: Thu, 13 Sep 2001 10:07:24 -1000	[thread overview]
Message-ID: <3BA111FC.E5D4E9AD@us.ibm.com> (raw)

Hello, Linux & Alan,

This patch verifies the message queue ID and the shared memory segment
ID for msgrcv and shmat respectively. These IDs consist of a data
structure index value, and a generation number. As data structures are
re-used, the generation number makes it possible to avoid incorrect
data references. The generation numbers are checked via msg_checkid()
and shm_checkid(). The problem is that msgrcv and shmat do not currently
validate the ID. As a result of this, it is possible to reference and
modify the wrong message queue or shared memory segment with the use of
a stale ID.

This patch is against kernel 2.4.9.  I tested it and it runs well.
Please apply and CC your comments to me also, thanks.

-- 
Mingming Cao
IBM Linux Technology Center

diff -urN -X dontdiff linux/ipc/msg.c linux-tk/ipc/msg.c
--- linux/ipc/msg.c     Wed Aug 29 18:26:39 2001
+++ linux-tk/ipc/msg.c  Wed Aug 29 18:21:42 2001
@@ -742,6 +742,10 @@
        if(msq==NULL)
                return -EINVAL;
 retry:
+       err = -EIDRM;
+       if (msg_checkid(msq,msqid))
+               goto out_unlock;
+
        err=-EACCES;
        if (ipcperms (&msq->q_perm, S_IRUGO))
                goto out_unlock;
diff -urN -X dontdiff linux/ipc/shm.c linux-tk/ipc/shm.c
--- linux/ipc/shm.c     Wed Aug 29 18:26:33 2001
+++ linux-tk/ipc/shm.c  Wed Aug 29 18:26:15 2001
@@ -606,6 +606,11 @@
        shp = shm_lock(shmid);
        if(shp == NULL)
                return -EINVAL;
+       err = shm_checkid(shp,shmid);
+       if (err) {
+               shm_unlock(shmid);
+               return err;
+       }
        if (ipcperms(&shp->shm_perm, acc_mode)) {
                shm_unlock(shmid);
                return -EACCES;

                 reply	other threads:[~2001-09-13 17:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3BA111FC.E5D4E9AD@us.ibm.com \
    --to=cmm@us.ibm.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfreds@colorfullife.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