Thread (42 messages) 42 messages, 11 authors, 2016-12-07

[PATCHv4 09/10] mm/usercopy: Switch to using lm_alias

From: Kees Cook <hidden>
Date: 2016-11-29 19:39:55
Also in: linux-mm, lkml

On Tue, Nov 29, 2016 at 10:55 AM, Laura Abbott [off-list ref] wrote:
The usercopy checking code currently calls __va(__pa(...)) to check for
aliases on symbols. Switch to using lm_alias instead.

Signed-off-by: Laura Abbott <redacted>
Acked-by: Kees Cook <redacted>

I should probably add a corresponding alias test to lkdtm...

-Kees
quoted hunk ↗ jump to hunk
---
Found when reviewing the kernel. Tested.
---
 mm/usercopy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/usercopy.c b/mm/usercopy.c
index 3c8da0a..8345299 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -108,13 +108,13 @@ static inline const char *check_kernel_text_object(const void *ptr,
         * __pa() is not just the reverse of __va(). This can be detected
         * and checked:
         */
-       textlow_linear = (unsigned long)__va(__pa(textlow));
+       textlow_linear = (unsigned long)lm_alias(textlow);
        /* No different mapping: we're done. */
        if (textlow_linear == textlow)
                return NULL;

        /* Check the secondary mapping... */
-       texthigh_linear = (unsigned long)__va(__pa(texthigh));
+       texthigh_linear = (unsigned long)lm_alias(texthigh);
        if (overlaps(ptr, n, textlow_linear, texthigh_linear))
                return "<linear kernel text>";

--
2.7.4


-- 
Kees Cook
Nexus Security
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help