]> granicus.if.org Git - strace/commitdiff
tests: check decoding of modify_ldt with for 4-byte-available user_desc
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 8 Jan 2018 17:46:32 +0000 (18:46 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 10 Jan 2018 01:57:53 +0000 (01:57 +0000)
Since there is possibility now that strace read only entry_number field
of the user_desc struct, let's check that it doesn't do it with
modify_ldt syscall.

* tests/modify_ldt.c (main): Add 4-byte-sized tail_alloc'ed variable.
Try to provide it as an argument to modify_ldt.

tests/modify_ldt.c

index fb8d453b4360c1cfe0e4375bc0f4594f02e77d62..1e26bda44ef2eddc36fc0faf82e0904180574925 100644 (file)
@@ -68,6 +68,7 @@ main(void)
                (kernel_ulong_t) 0xdeadfacefa57beefULL;
 
        struct user_desc *us = tail_alloc(sizeof(*us));
+       unsigned int *bogus_int = tail_alloc(sizeof(*bogus_int));
        long rc;
 
        fill_memory(us, sizeof(*us));
@@ -97,6 +98,16 @@ main(void)
               (int) bogus_func, us + 1, sizeof(*us));
        printrc(rc);
 
+       /*
+        * print_user_desc handles entry_number field in a special way for
+        * get_thread_area syscall, so let's also check here that we don't
+        * retrieve it accidentally.
+        */
+       rc = syscall(__NR_modify_ldt, bogus_func, bogus_int, sizeof(*us));
+       printf("modify_ldt(%d, %p, %zu) = ",
+              (int) bogus_func, bogus_int, sizeof(*us));
+       printrc(rc);
+
        rc = syscall(__NR_modify_ldt, bogus_func, us, sizeof(*us));
        printf("modify_ldt(%d, ", (int) bogus_func);
        print_user_desc(us, NULL);