Re: [PATCH #2] console lock grabbed too early in printk...

From: Russell King (rmk@arm.linux.org.uk)
Date: Sun Jul 02 2000 - 14:08:32 EST


Chris Lattner writes:
> As I mentioned earlier... this assumes that copy_from_user is not a simple
> memcpy, or that copy_from_user does not induce the page fault... which
> would induce precisely the same problem that I'm seeing. Either way, the
> root problem is unchanged.

No its not.

Consider:

void dump_user_string(char *userstr)
{
        char *kernstr;
        int size = 256;

        kernstr = kmalloc(size);
        if (kernstr) {
                strncopy_from_user(kernstr, userstr, size);
                printk("happy happy joy joy %s\n", kernstr);
        }
        kfree(kernstr);
}

You will NEVER EVER got a page faults from within printk with the above code.
Therefore, you won't get a page faults from within printk. The above is
correct code.

However, from what you've said, you're doing:

void dump_user_string(char *userstr)
{
        printk("crash and burn nice and easily %s\n", userstr);
}

This is highly illegal and breaks the rules about kernel locking, accessing
user memory, buffer overflows, system expolits and security all in one nice
big go.

Suddenly with this code, you are likely to get page faults within the printk,
and printk will break with good reason to - you're calling it illegally.

Its not printk's fault that its deadlocking, but your fault by the way you're
using it.
   _____
  |_____| ------------------------------------------------- ---+---+-
  | | Russell King rmk@arm.linux.org.uk --- ---
  | | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
  | +-+-+ --- -+-
  / | THE developer of ARM Linux |+| /|\
 / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

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



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:12 EST