lkml.org 
[lkml]   [2001]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject243-pre[78]: mmap changes (breaks) /proc

Hi Linus,

I had some strange userland/proc problems appearing during sysinit.
Symptoms are "Malformed setting kernel.printk=" error message from
sysctl(8) and hanging linuxconf (SAK resolves this). The common thing
are several sed(1) calls silently failing when matching against files
from /proc. cat'ting the /proc-files works as usual. Copying its contents
to some file on ext2 and executing the same sed-command on it works
as expected, i.e. ok in contrast to direct execution on /proc.

Using "sed 's/^\(.\).*/\1/' /proc/sys/kernel/printk" as test case I've
tracked this down as follows:

strace'ing the above command for 2.4.0 ... 2.4.3-pre6 yields

open("/proc/sys/kernel/printk", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 0, PROT_READ, MAP_PRIVATE, 4, 0) = -1 ENODEV (No such device)

whereas for 2.4.3-pre[78] one gets

open("/proc/sys/kernel/printk", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 0, PROT_READ, MAP_PRIVATE, 4, 0) = 0

i.e. mmap used to return ENODEV and now returns success having mapped
len=0 bytes from the file on procfs - which triggers the sed failure.
(glibc is 2.1.3 and sed is 3.02 in case it matters)

This change is apparently due to the merge-mmap-patch which provides:

mm/mmap.c:
- if (file && (!file->f_op || !file->f_op->mmap))
- return -ENODEV;

Putting these two lines back in place restores the old behaviour thus
solving the problem. Although not tested, my impression is all files
not implementing f_op->mmap might be affected a similar way - at least
potentially. On the other hand, anonymous mappings have file=0 so they are
not catched by the above test. Therefore, unless the change was
intentional, my suggestion is to keep the test for valid f_op->mmap
returning -ENODEV.

Regards
Martin

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:17    [W:0.035 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site