#define pr_fmt(fmt) …
#ifdef DEBUG
#define FORTIFY_REPORT_KUNIT …
#define FORTIFY_WARN_KUNIT …
#else
#define FORTIFY_REPORT_KUNIT(x...) …
#define FORTIFY_WARN_KUNIT(x...) …
#endif
void fortify_add_kunit_error(int write);
#define fortify_panic(func, write, avail, size, retfail) …
#define fortify_warn_once(chk_func, x...) …
#include <kunit/device.h>
#include <kunit/test.h>
#include <kunit/test-bug.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#ifndef __compiletime_strlen
#define __compiletime_strlen …
#endif
static struct kunit_resource read_resource;
static struct kunit_resource write_resource;
static int fortify_read_overflows;
static int fortify_write_overflows;
static const char array_of_10[] = …;
static const char *ptr_of_11 = …;
static char array_unknown[] = …;
void fortify_add_kunit_error(int write)
{ … }
static void fortify_test_known_sizes(struct kunit *test)
{ … }
static volatile int pick;
static noinline size_t want_minus_one(int pick)
{ … }
static void fortify_test_control_flow_split(struct kunit *test)
{ … }
#define KUNIT_EXPECT_BOS(test, p, expected, name) …
#if !__has_builtin(__builtin_dynamic_object_size)
#define KUNIT_EXPECT_BDOS …
#else
#define KUNIT_EXPECT_BDOS(test, p, expected, name) …
#endif
#define check_const(_expected, alloc, free) …
#define check_dynamic(_expected, alloc, free) …
#define CONST_TEST_BODY(TEST_alloc) …
static volatile size_t zero_size;
static volatile size_t unknown_size = …;
#if !__has_builtin(__builtin_dynamic_object_size)
#define DYNAMIC_TEST_BODY …
#else
#define DYNAMIC_TEST_BODY(TEST_alloc) …
#endif
#define DEFINE_ALLOC_SIZE_TEST_PAIR(allocator) …
#define TEST_kmalloc(checker, expected_size, alloc_size) …
DEFINE_ALLOC_SIZE_TEST_PAIR(…)
#define TEST_vmalloc(checker, expected_pages, alloc_pages) …
DEFINE_ALLOC_SIZE_TEST_PAIR(…)
#define TEST_kvmalloc(checker, expected_pages, alloc_pages) …
DEFINE_ALLOC_SIZE_TEST_PAIR(…)
#define TEST_devm_kmalloc(checker, expected_size, alloc_size) …
DEFINE_ALLOC_SIZE_TEST_PAIR(…)
static const char * const test_strs[] = …;
#define TEST_realloc(checker) …
static void fortify_test_realloc_size(struct kunit *test)
{ … }
struct fortify_padding { … };
static volatile int unconst;
static void fortify_test_strlen(struct kunit *test)
{ … }
static void fortify_test_strnlen(struct kunit *test)
{ … }
static void fortify_test_strcpy(struct kunit *test)
{ … }
static void fortify_test_strncpy(struct kunit *test)
{ … }
static void fortify_test_strscpy(struct kunit *test)
{ … }
static void fortify_test_strcat(struct kunit *test)
{ … }
static void fortify_test_strncat(struct kunit *test)
{ … }
static void fortify_test_strlcat(struct kunit *test)
{ … }
struct fortify_zero_sized { … };
#define __fortify_test(memfunc) …
__fortify_test(…)
__fortify_test(…)
static void fortify_test_memscan(struct kunit *test)
{ … }
static void fortify_test_memchr(struct kunit *test)
{ … }
static void fortify_test_memchr_inv(struct kunit *test)
{ … }
static void fortify_test_memcmp(struct kunit *test)
{ … }
static void fortify_test_kmemdup(struct kunit *test)
{ … }
static int fortify_test_init(struct kunit *test)
{ … }
static struct kunit_case fortify_test_cases[] = …;
static struct kunit_suite fortify_test_suite = …;
kunit_test_suite(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;