[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] EFAULT implmentation in linux-user

From: Stuart Anderson
Subject: [Qemu-devel] [PATCH] EFAULT implmentation in linux-user
Date: Sun, 3 Jun 2007 20:47:45 -0400 (EDT)

The attached patch implements EFAULT detection in linux-user. It is
suprising how much software "relies" on the kernel returning EFAULT
instead of just crashing.

This patch can be broken down into 3 parts:

        Add page_check_range(), which uses the page map of the target to
        determine wether an address and range are valid.EFAULT is
        returned when an invalid address is detected.

        Add lock_and_check_user_struct(), wich is similar to
        lock_user_struct(), but adds a call to page_check_range()
        to detect bad addresses. Once all occurrances of
        lock_user_struct() have been converted over to this new function,
        the new function could be renamed back to lock_user_struct() to
        shorten it slightly.

        This is where lock_and_check_user_struct() is used. It is used
        to perform the mapping from target to host addresses. Generally,
        calls to lock_user_struct() have been replaced with calls to
        lock_and_check_user_struct(). For example

-    lock_user_struct(target_tv, target_addr, 0);
+    if( (ret=lock_and_check_user_struct(&target_tv,target_addr,
                sizeof(*target_tv),0,PAGE_WRITE)) != 0 ) return -ret;

These changes permit many of the tests in LTP for error conditions to
now pass.


Stuart R. Anderson                               address@hidden
Network & Software Engineering                   http://www.netsweng.com/
1024D/37A79149:                                  0791 D3B8 9A4C 2CDC A31F
                                                 BD03 0A62 E534 37A7 9149

Attachment: 06_efault.patch
Description: EFAULT implementation

reply via email to

[Prev in Thread] Current Thread [Next in Thread]