mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuck Ebbert <76306.1226@compuserve.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] Fix mmap_kmem (was: [question] What's the difference between /dev/km
Date: Fri, 12 Aug 2005 14:18:52 -0400	[thread overview]
Message-ID: <200508121422_MC3-1-A70F-D742@compuserve.com> (raw)

On Fri, 12 Aug 2005 at 15:25:18 +0100 (BST), Hugh Dickins wrote:

> On Thu, 11 Aug 2005, Steven Rostedt wrote:
> > 
> > Found the problem.  It is a bug with mmap_kmem.  The order of checks is
> > wrong, so here's the patch.
> 
> Good find, looks right to me, so far as it goes (why does this check

 Even with Steven's patch applied, root cannot read from /dev/kmem with the
following program, which works on 2.6.9.  "Invalid argument" means that the
"fd is attached to an object that is unsuitable for reading."

# ./desc2
GDT is at 0xc13097a0
read /dev/kmem: Invalid argument


#include <stdio.h>
#include <fcntl.h>
#define perr(err) { perror(err), exit(1); }

struct {
        unsigned short limit;
        unsigned int base;
} __attribute__ ((packed)) dtr;

int kmem, i;
int buf[1024];

int main() {
        if ((kmem = open("/dev/kmem", O_RDONLY)) < 0)
                perr("open /dev/kmem");

        asm("sgdtl %0" : "=m"(dtr));
        printf("GDT is at 0x%x\n", dtr.base);
        dtr.limit++;  /* convert to size */

        if (lseek(kmem, dtr.base, SEEK_SET) != dtr.base)
                perr("lseek /dev/kmem");
        if (read(kmem, buf, dtr.limit) != dtr.limit)
                perr("read /dev/kmem");

        for (i = 0; i < dtr.limit / 4; i += 2)
                if (buf[i+1])
                        printf("entry %d(0x%x): 0x%x 0x%x\n",
                                i / 2, i / 2, buf[i], buf[i+1]);

        return 0;
}

__
Chuck

             reply	other threads:[~2005-08-12 18:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-12 18:18 Chuck Ebbert [this message]
2005-08-12 18:35 ` Steven Rostedt

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=200508121422_MC3-1-A70F-D742@compuserve.com \
    --to=76306.1226@compuserve.com \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@osdl.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

all inboxes | Powered by JetHome®