a relatively major problem with ext2.

From: Eric Kjeldergaard <kjelderg_at_gmail.com>
Date: Tue, 8 Mar 2005 20:54:44 -0600
After a bit of discussion on the kde list regarding a problem I've
been having with kreadconfig (which uses mmap), I've stumbled (largely
directed by Michael Nottebrock) upon an ext2 bug.  Michael wrote and
posted the following code:

#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char ** argv) {
   int fd;
   struct stat sb;
   void * region;

   if ((fd = open(argv[1], O_RDONLY)) < 0) {
       perror("open");
       return 1;
   }

   if (fstat(fd, &sb)) {
       perror("fstat");
       return 1;
   }

   region = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
   if (region == ((caddr_t) -1)) {
       perror("mmap");
       return 1;
   }

   close(fd);

   if (write(1, region, sb.st_size) != sb.st_size) {
       perror("write");
       return 1;
   }

   return 0;
}

Well, this code run on something mounted as an ext2 partition reliably
kernel panics my FreeBSD-CURRENT box.  Hopefully someone can direct me
as to any information they would need to try to sort this out.  The
kernel panic is this (hand typed):

Fatal trap 12: page fault while in kernel mode
fault virtual address = 0x1c
fault code = supervisor write, page not present
instruction pointer = 0x8:0xc04d199d
stack pointer = 0x10:0xe2428b0c
frame pointer = 0x10:0xe2428b64
code segment = base 0x0, limit 0xfffff, type 0x1b
= dpl 0, pres 1, def32 1, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
current process = 543 (truss)
trap number = 12

In case anyone doesn't wish to sift through the kde mailing list
looking for what the original problem was, it is this:  When
kreadconfig (recent versions) tries to access a file on my
ext2-mounted $HOME, it gets an error trying to mmap.  The error
(discovered via truss) looks a bit like this:

open("/root/.kde/share/config/kpersonalizerrc",0x0,0666) = 4 (0x4)
fstat(4,0xbfbfe650)                              = 0 (0x0)
fstat(4,0xbfbfe510)                              = 0 (0x0)
mmap(0x0,125,(0x1)PROT_READ,(0x2)MAP_PRIVATE,4,0x0) ERR#22 'Invalid argument'

And kreadconfig silently fails and reports the incorrect result.

-- 
If I write a signature, my emails will appear more personalised.
Received on Wed Mar 09 2005 - 01:54:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:29 UTC