[clug] Code question: Why doesn't this seqfault (kernel/printk.c)
Michael Still
mikal at stillhq.com
Mon Oct 20 12:14:47 EST 2003
Folk,
So, I'm reading kernel/printk.c, specifically looking at the printk()
function. Anyways, I see these lines:
for (p = printk_buf; *p; p++) {
if (log_level_unknown) {
if (p[0] != '<' || p[1] < '0' || p[1] > '7' || p[2] != '>') {
emit_log_char('<');
emit_log_char(default_message_loglevel + '0');
emit_log_char('>');
}
log_level_unknown = 0;
}
emit_log_char(*p);
if (*p == '\n')
log_level_unknown = 1;
}
Which is a few lines in. Anyways, I'm now left wondering why the first if
statement doesn't cause a segmentation fault. As best as I can see, there
is no check to make sure that two characters after *p is in our memory
space.
Is there some page alignment thing happening here which saves the day?
Am I missing something obvious?
Thanks,
Mikal
--
Michael Still (mikal at stillhq.com) | "All my life I've had one dream,
http://www.stillhq.com | to achieve my many goals"
UTC + 10 | -- Homer Simpson
More information about the linux
mailing list