mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] Fix mmap_kmem (was: [question] What's the difference between /dev/km
@ 2005-08-12 18:18 Chuck Ebbert
  2005-08-12 18:35 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Chuck Ebbert @ 2005-08-12 18:18 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Steven Rostedt, linux-kernel, Linus Torvalds, Andrew Morton

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

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

* Re: [PATCH] Fix mmap_kmem (was: [question] What's the  difference between /dev/km
  2005-08-12 18:18 [PATCH] Fix mmap_kmem (was: [question] What's the difference between /dev/km Chuck Ebbert
@ 2005-08-12 18:35 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2005-08-12 18:35 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Hugh Dickins, linux-kernel, Linus Torvalds, Andrew Morton


On Fri, 12 Aug 2005, Chuck Ebbert wrote:
>  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."
>

Yeah, I noticed this too. But my programs were only mmaping kmem, and not
reading it, so I didn't bother to fix that.  When I get a chance, I could
also look into that too.  But I guess the next thing to do is send in a
patch that makes kmem a config option, with the default off.

-- Steve


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

end of thread, other threads:[~2005-08-12 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-12 18:18 [PATCH] Fix mmap_kmem (was: [question] What's the difference between /dev/km Chuck Ebbert
2005-08-12 18:35 ` Steven Rostedt

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®