bugs.c (2612e3bbc0386368a850140a6c9b990cd496a5ec) bugs.c (aebc7b0d8d91bbc69e976909963046bc48bca4fd)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * This is for all the tests related to logic bugs (e.g. bad dereferences,
4 * bad alignment, bad loops, bad locking, bad scheduling, deep stacks, and
5 * lockups) along with other things that don't fit well into existing LKDTM
6 * test source files.
7 */
8#include "lkdtm.h"

--- 379 unchanged lines hidden (view full) ---

388 */
389 test_head.next = redirection;
390 list_add(&bad.node, &test_head);
391
392 if (target[0] == NULL && target[1] == NULL)
393 pr_err("Overwrite did not happen, but no BUG?!\n");
394 else {
395 pr_err("list_add() corruption not detected!\n");
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * This is for all the tests related to logic bugs (e.g. bad dereferences,
4 * bad alignment, bad loops, bad locking, bad scheduling, deep stacks, and
5 * lockups) along with other things that don't fit well into existing LKDTM
6 * test source files.
7 */
8#include "lkdtm.h"

--- 379 unchanged lines hidden (view full) ---

388 */
389 test_head.next = redirection;
390 list_add(&bad.node, &test_head);
391
392 if (target[0] == NULL && target[1] == NULL)
393 pr_err("Overwrite did not happen, but no BUG?!\n");
394 else {
395 pr_err("list_add() corruption not detected!\n");
396 pr_expected_config(CONFIG_DEBUG_LIST);
396 pr_expected_config(CONFIG_LIST_HARDENED);
397 }
398}
399
400static void lkdtm_CORRUPT_LIST_DEL(void)
401{
402 LIST_HEAD(test_head);
403 struct lkdtm_list item;
404 void *target[2] = { };

--- 10 unchanged lines hidden (view full) ---

415 /* As with the list_add() test above, this corrupts "next". */
416 item.node.next = redirection;
417 list_del(&item.node);
418
419 if (target[0] == NULL && target[1] == NULL)
420 pr_err("Overwrite did not happen, but no BUG?!\n");
421 else {
422 pr_err("list_del() corruption not detected!\n");
397 }
398}
399
400static void lkdtm_CORRUPT_LIST_DEL(void)
401{
402 LIST_HEAD(test_head);
403 struct lkdtm_list item;
404 void *target[2] = { };

--- 10 unchanged lines hidden (view full) ---

415 /* As with the list_add() test above, this corrupts "next". */
416 item.node.next = redirection;
417 list_del(&item.node);
418
419 if (target[0] == NULL && target[1] == NULL)
420 pr_err("Overwrite did not happen, but no BUG?!\n");
421 else {
422 pr_err("list_del() corruption not detected!\n");
423 pr_expected_config(CONFIG_DEBUG_LIST);
423 pr_expected_config(CONFIG_LIST_HARDENED);
424 }
425}
426
427/* Test that VMAP_STACK is actually allocating with a leading guard page */
428static void lkdtm_STACK_GUARD_PAGE_LEADING(void)
429{
430 const unsigned char *stack = task_stack_page(current);
431 const unsigned char *ptr = stack - 1;

--- 200 unchanged lines hidden ---
424 }
425}
426
427/* Test that VMAP_STACK is actually allocating with a leading guard page */
428static void lkdtm_STACK_GUARD_PAGE_LEADING(void)
429{
430 const unsigned char *stack = task_stack_page(current);
431 const unsigned char *ptr = stack - 1;

--- 200 unchanged lines hidden ---