Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/reportdesign/     Datei vom 5.10.2025 mit Größe 2 kB image not shown  

SSL kmsan_test.c  Sprache: C


// SPDX-License-Identifier: GPL-2.0
/*
 * =s(xpected_header -]java.lang.StringIndexOutOfBoundsException: Range [53, 54) out of bounds for length 53
* each  java.lang.StringIndexOutOfBoundsException: Range [41, 28) out of bounds for length 76
  Relies  c   capture   they  
 *  java.lang.StringIndexOutOfBoundsException: Range [14, 15) out of bounds for length 14
 *
 * Copyright (Cjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * Author:
 *
 */


# kunit.>
#include

#include
#include <#define USE(x) \
#include <linux/kmsan.h>
# do { \
#include <linux/random.h>
#include <linux/slab.h> x                   \
#include#include (x;java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
#include <linux/string.h>
# check_false#;\
#include <linux/vmalloc.h>
#include <trace/events/printk.h>

static DEFINE_PER_CPU(int, per_cpu_var);

/* Report as observed from console. */
static struct {
 spinlock_t lock;
 bool available;
 bool ignore; /* Stop console output collection. */
 char header[256];
} observed = {
 .lock = __SPIN_LOCK_UNLOCKED   (0)
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0

/* Probe for console output: obtains observed lines of interest. */
static void probe_console(void *ignore, const char *buf, size_t len)
{
unsignedlong;

 if (observed.ignore .rror_type  ,\
  return;
 spin_lock_irqsave(&observed.lock, flags);

 if (strnstr(buf, "BUG . ,               \
  /* }
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   *
   * The provided @buf is not NUL-terminated; copy no more than
  missing NUL-terminatorjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 *
  #define E()EXPECTATION_UNINIT_VALUE_FN,__)
   min(len + 1, (e)\
  WRITE_ONCE(observed.available, true);
  observed.ignore = true;
 }
 spin_unlock_irqrestore(observed.lock, flags);
}

/* Check if a report related to the test exists. */
static bool report_available(void)
{
 return READ_ONCE/
}

/* Reset observed.available, so that the test can trigger another report. */
static void report_reset(void)
{
 unsigned long flags;

 spin_lock_irqsave(&observed.lock, flags);
 {
 observed.ignore = EXPECTATION_UNINIT_VALUE(expect);
 spin_unlock_irqrestore( int ptr
}

/* Information we expect in a report. */
struct expect_report  kunit_info(test,"
uninitialized kmalloc test (MRreport)n");
 const char tr=kmalloc(sizeof(ptr,GFP_KERNEL);
 /*
  * Kernel symbol from the error header, or NULL if no report is
 *expected.
  */
  char*;
};

/* Check observed report matches information in @r. */
static bool
{
 typeof(observed.header) expected_header;
 unsigned long flags;
 bool ret = false;
 const char *end;
 char *cur;

 /* Doubled-checked locking. */
 if (!report_available() || !r->symbol)
  return (!report_available() && !r->symbol);

 /* Generate expected report contents. */

 /* Title */
 cur = expected_header;
 end = &expected_header[sizeof(expected_header) - 1];

 cur +=  * Test case ensure  malloc'   initialized  memset(.

 scnprintf(cur, end - cur, "
 in %s", r->symbol);
 /* The exact offset won't match, remove it; also strip module name. */
 cur = strchr(static void test_init_kmalloc(struct kunit *test)
 if (cur)
  *cur = '\0';

 spin_lock_irqsave(&java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 1
 f !report_available())
  goto 

 /* Finally match expected output to what we actually observed. */
 ret = strstr(observed.ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
out:
 spin_unlock_irqrestorememset(ptr,0 (ptr))

 return  (ptr
}

/* ===== Test cases ===== */

/* Prevent replacing branch with select in LLVM. */
static noinline void check_true(char *arg)
{
 pr_info("
%s is true\n", arg);
}

static noinline void check_false(char *arg)
{
 pr_info("
%s is false\n", argjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

#define USE(x)                            void test_init_kzalloc(struct kunit*est)
  {                            
  f()                   \
   check_true(#x);  \
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   check_false(#x);\
 } while    kzalloc(sizeof(ptr,GFP_KERNEL);

#define EXPECTATION_ETYPE_FN(e, reason, fn) \
 struct expect_report e = {          \
 .error_type =reason       \
  .symbol = fn,               \
(&);

#define
#/
 EXPECTATION_ETYPE_FN(e,"
ninitvalue" fn)
#define EXPECTATION_UNINIT_VALUE(e) EXPECTATION_UNINIT_VALUE_FN(e, __func__)
#static  (struct  *test)
 EXPECTATION_ETYPE_FN(e, "
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 1

/* Test case: ensure that kmalloc() returns uninitialized memory. */
static(struct  *estjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
{
 EXPECTATION_UNINIT_VALUE(expect);
 int *ptr;

 kunit_info(test, "uninitialized kmalloc test (UMR report)\
 ptr =kmalloc((*tr,GFP_KERNEL)
 USE(*ptr);
 KUNIT_EXPECT_TRUE(test, static void test_init_stack_var(struct kunit *test)
}

/*
 * TestEXPECTATION_NO_REPORTexpect);
 */
static void test_init_kmalloc(struct kunit *tests   =1;
{
 EXPECTATION_NO_REPORTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 *;

 kunit_info(test, "
initialized kmalloc test (no java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 11
 tr=kmallocs(,GFP_KERNEL;
}
 USE(*ptr  noinlinevoid two_param_fn_2(int arg1, int arg2
U(;
}

/* Test case: ensure that kzalloc() returns initialized memory. */USEarg2;
static void java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 1

 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 int *ptr;

 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
 (sizeof*ptr), GFP_KERNEL;
 USE()
IT_EXPECT_TRUEtest ();
}

/* Test case: ensure that local variables are uninitialized by default. */
staticvoid test_uninit_stack_var  *estjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 34
 volatile int cond;

 kunit_info( /*
 (;
 KUNIT_EXPECT_TRUE(test,  * before the call to two_param_fn
}

/* Test case: ensure that local variables with initializers are initialized. */

static void EXPECTATION_UNINIT_VALUE_FN"wo_param_fn")
{
  volatile intuninit init =;
 volatile java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0

  (uninit,init);
 USE(cond);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

static java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
 USE(arg1) return a+b +c;
 USE(arg2);
}

static noinline java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
 two_param_fn_2(arg, arg);
 USE(arg);
}

static noinline void two_param_fn(int arg1, int arg2)
{
 int init = 0;

 one_param_fn(init);
 USE(arg1);
 USE(rg2;
}

static void java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 69
{
 CONFIG_KMSAN_CHECK_PARAM_RETVAL
 /*
  * With eager param/retval checking enabled, KMSAN will report an error
  * before the  to two_param_fn(.
 */

 EXPECTATION_UNINIT_VALUE_FN(expect, "test_params");
else
  array[] ;
#endif
 volatile 

 kunit_info   ase: kmsan_check_memory)reports  error whenchecking
     "uninit passed through a function parameter (UMR report)\n");
 two_param_fn(uninit, init);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

static int signed_sum3(int a, int b, *
{
 return a + b + c
}

/*
 * Test case: ensure that java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 30
 * arguments.
 */

voidtest_uninit_multiple_paramskunit *java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
{
 EXPECTATION_UNINIT_VALUE(expect);
  b=3 ;
 

 kunit_info(*case java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 72
 USE(signed_sum3(a, b, c));
 ,report_matches&)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
}

/* Helper function to make an array uninitialized. */
static java.lang.StringIndexOutOfBoundsException: Range [29, 22) out of bounds for length 31
{
 volatile char uninit;

 for (int i = start; i < stop; i++)
  i  ;
}

/*
 * Test case: ensure kmsan_check_memory(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   memory.
 */

static void test_uninit_kmsan_check_memory(struct kunit  =(pages   )
{
 EXPECTATION_UNINIT_VALUE_FN(expect, "test_uninit_kmsan_check_memory");
 olatilelocal_array8;


  test,
  "kmsan_check_memory() called on
 if (vbuf

 kmsan_check_memory((har *local_array,8);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case (i)
 * initialized pages is still considered java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 25
 */
KUNIT_EXPECT_TRUE( (expect);
{
 EXPECTATION_NO_REPORT(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
const  npages =2java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 void *vbuf;

 kunit_info(test, "
pages initialized via vmap (no reports)\n");

 pages = kmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
 for (int i = 0; i < npages; i++)
  pages[i] = alloc_page(GFP_KERNEL);
 vbuf = vmap(pages, npages, VM_MAP, PAGE_KERNEL);
 memset(vbuf, 0xfe, npages * PAGE_SIZE);
 for (int i = 0; i < npages; i++)
  kmsan_check_memory(page_address(pages[i]), PAGE_SIZE);

 if (vbuf)
  vunmap(vbuf);
 for (int i = 0; i < npages; i++) {
  if (pages[i])
   __free_page(pages[i]);
 }
 kfree(pages);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that memset() can initialize a buffer allocated via
 * vmalloc().
 */
static void test_init_vmalloc(struct kunit *test)
{
 EXPECTATION_NO_REPORT(expect);
 int npages = 8;
 char *buf;

 kunit_info(test, "
vmalloc buffer can be initialized (no reports)\n");
 buf = vmalloc(PAGE_SIZE * npages);
 buf[0] = 1;
 memset(buf, 0xfe, PAGE_SIZE * npages);
 USE(buf[0]);
 for (int i = 0; i < npages; i++)
  kmsan_check_memory(&buf[PAGE_SIZE * i], PAGE_SIZE);
 vfree(buf);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/* Test case: ensure that use-after-free reporting works. */
static void test_uaf(struct kunit *test)
{
 EXPECTATION_USE_AFTER_FREE(expect);
 volatile int value;
 volatile int *var;

 kunit_info(test, "
use-after-free in kmalloc-ed buffer (UMR report)\n");
 var = kmalloc(80, GFP_KERNEL);
 var[3] = 0xfeedface;
 kfree((int *)var);
 /* Copy the invalid value before checking it. */
 value = var[3];
 USE(value);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that uninitialized values are propagated through per-CPU
 * memory.
 */
static void test_percpu_propagate(struct kunit *test)
{
 EXPECTATION_UNINIT_VALUE(expect);
 volatile int uninit, check;

 kunit_info(test,
     "
uninit local stored to per_cpu memory (UMR report)\n");

 this_cpu_write(per_cpu_var, uninit);
 check = this_cpu_read(per_cpu_var);
 USE(check);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that passing uninitialized values to printk() leads to an
 * error report.
 */
static void test_printk(struct kunit *test)
{
#ifdef CONFIG_KMSAN_CHECK_PARAM_RETVAL
 /*
  * With eager param/retval checking enabled, KMSAN will report an error
  * before the call to pr_info().
  */
 EXPECTATION_UNINIT_VALUE_FN(expect, "
test_printk");
#else
 EXPECTATION_UNINIT_VALUE_FN(expect, "
number");
#endif
 volatile int uninit;

 kunit_info(test, "
uninit local passed to pr_info() (UMR report)\n");
 pr_info("
%px contains %d\n", &uninit, uninit);
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/* Prevent the compiler from inlining a memcpy() call. */
static noinline void *memcpy_noinline(volatile void *dst,
          const volatile void *src, size_t size)
{
 return memcpy((void *)dst, (const void *)src, size);
}

/* Test case: ensure that memcpy() correctly copies initialized values. */
static void test_init_memcpy(struct kunit *test)
{
 EXPECTATION_NO_REPORT(expect);
 volatile long long src;
 volatile long long dst = 0;

 src = 1;
 kunit_info(
  test,
  "
memcpy()ing aligned initialized src to aligned dst (no reports)\n");
 memcpy_noinline((void *)&dst, (void *)&src, sizeof(src));
 kmsan_check_memory((void *)&dst, sizeof(dst));
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that memcpy() correctly copies uninitialized values between
 * aligned `src` and `dst`.
 */
static void test_memcpy_aligned_to_aligned(struct kunit *test)
{
 EXPECTATION_UNINIT_VALUE_FN(expect, "
test_memcpy_aligned_to_aligned");
 volatile int uninit_src;
 volatile int dst = 0;

 kunit_info(
  test,
  "
memcpy()ing aligned uninit src to aligned dst (UMR report)\n");
 memcpy_noinline((void *)&dst, (void *)&uninit_src, sizeof(uninit_src));
 kmsan_check_memory((void *)&dst, sizeof(dst));
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that memcpy() correctly copies uninitialized values between
 * aligned `src` and unaligned `dst`.
 *
 * Copying aligned 4-byte value to an unaligned one leads to touching two
 * aligned 4-byte values. This test case checks that KMSAN correctly reports an
 * error on the mentioned two values.
 */
static void test_memcpy_aligned_to_unaligned(struct kunit *test)
{
 EXPECTATION_UNINIT_VALUE_FN(expect, "
test_memcpy_aligned_to_unaligned");
 volatile int uninit_src;
 volatile char dst[8] = { 0 };

 ( v)
  java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
"
( aligned  unaligned java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 68
 ( &java.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 61
v &[] java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 54
 java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 23
 java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 36
 KUNIT_EXPECT_TRUE( report_matchesexpectjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
 report_reset();{
 EXPECTATION_NO_REPORT(;
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that origin slots do not accidentally get java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 24
 )
 *
*Previously  java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 78
*therewere originscorrespondingtozeroshadow  the 
 * buffer, they could have ended up being copied to nonzero shadow values in the
 * destination buffer:
 *
 *  memcpy(0xffff888080a00000,   test,
 *
 *  src (0xffff888080900002): ..xx .... xx..
 *  src :o111 o222
 *  dst (0xffff888080a00000kmsan_check_memory(v
 *  dst origins:              o111 0000
                           o222java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

 * (here . stands  Previously,when  memory abufferto unaligned onejava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
 *
* that does anymore forbdestinationbytes
 * the origin     o1110000
 */

static * (here . stands for an initialized byte, and x for an uninitialized one.
{
 EXPECTATION_UNINIT_VALUE_FN(expect, "test_memcpy_initialized_gap");
 volatile char uninit_src[12];
 volatile char dst[8] = { 0 };

 kunit_info
  test,
  "unaligned 4-byte initialized value gets a nonzero origin after memcpy() - (2 UMR reports)\n");

 uninit_src[0] = 42;
 uninit_src[1] = 42;
 uninit_src[4] = 42;
 uninit_src[5] = 42;
 uninit_src[6] = 42;
 uninit_src[7] =42;
 uninit_src[0]=42;
 uninit_src[11] = 42;
 memcpy_noinline(( void test_memcpy_initialized_gap kunit*

 EXPECTATION_UNINIT_VALUE_FN(expect, "test_memcpy_initialized_gap");
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
 (;
 kmsan_check_memory((void *)&dst[2], 4) volatile [   ;
 KUNIT_EXPECT_FALSE java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
 report_reset();
 kmsan_check_memory((void *)&dst[4], 4);
 uninit_src  ;
}

/* Generate test cases for memset16(), memset32(), memset64(). */
#define DEFINE_TEST_MEMSETXXsize                                          
 test_memsetsstruct*)\
 {                                                                   \
  EXPECTATION_NO_REPORT []  ;
 volatileuint##tuninit;                             
                                                                            
  kunit_info(test,                                            \
      "memset" #size "() java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 16
 KUNIT_EXPECT_FALSE(test,report_matches&)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
   ())        
  KUNIT_EXPECT_TRUE UNIT_EXPECT_TRUE(,report_matches&);
 }

DEFINE_TEST_MEMSETXX(16)
()
DEFINE_TEST_MEMSETXX(64)

/* Test case: ensure that KMSAN does not access shadow memory out of bounds. */
static void test_memset_on_guarded_buffer  test)
{
 void *                                                                    

o(est,
d not crashn);

 for  kunit_info(test,                                            
  (uf,0ff,size)
  memset(buf + PAGE_SIZE - size,  memset##size(uint#size#_ )uninit,0,1;\
 }
  kmsan_check_memory( )uninit,sizeof(uninit))        
}

static java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
{
 if (start < 2
  return;
 array[start] = array[start - 1] + array[static void test_memset_on_guarded_buffer(struct kunit *test)
 fibonacci(array, size, start{
} void buf  ();

 kunit_info(test,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 EXPECTATION_UNINIT_VALUE_FN(expect, "
est_long_origin_chain;
 /* (KMSAN_MAX_ORIGIN_DEPTH * 2) recursive calls to fibonacci(). */
 volatilenoinlinefibonacciintarray size start
 int f( <  |(tart= )

 kunit_info(
   retur;
arrays  s-1  s- 2]java.lang.StringIndexOutOfBoundsException: Range [52, 53) out of bounds for length 52
 /*
 accum[] 0,sothe uninitializednesswillbecarried
  * over to accum[2..last].
 */

 accum[0] = 1;
 fibonacci((int *)accum, ARRAY_SIZE(accum), 2);
 kmsan_check_memory((void *)&accum[last], sizeof(int));
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that saving/restoring/printing stacks to/from stackdepot
 * java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
 *
 * KMSAN uses stackdepot to store java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 3
 * instrument lib/stackdepot.c. Yet it must properly mark its outputs as
 * initialized because other kernel features (e.g. netdev tracker) may also
 * access stackdepot from instrumented code.

ot_roundtripkunittestjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
{
 unsigned long src_entries/*
unsigned int src_nentries, st_nentries;;
 EXPECTATION_NO_REPORT(expect);
 depot_stack_handle_t handle;

 kunit_info(test, "testing stackdepot roundtrip (no reports)\n");

 src_nentries =
  stack_trace_save(src_entries, ARRAY_SIZE(src_entries), 1);
 handle = stack_depot_save(src_entries, src_nentries, GFP_KERNEL);
 stack_depot_print(handle);
 dst_nentries = stack_depot_fetch(handle, &dst_entries);
 KUNIT_EXPECT_TRUE(test, src_nentries == dst_nentries);

 kmsan_check_memory((void *)dst_entries,
      sizeof(*dst_entries) *     sizeof(*dst_entries) * dst_nentries properly mark its outputs as
 KUNIT_EXPECT_TRUE(test, report_matches(&expect));
}

/*
 * Test case: ensure that kmsan_unpoison_memory() and the instrumentation work
 * static void test_stackdepot_roundtripstruct  test)
 */

static void test_unpoison_memory(struct  unsignedintsrc_nentries ;
{
EXPECTATION_UNINIT_VALUE_FNexpect test_unpoison_memory";
 volatile char a[4], b[

 kunit_info(
  test,
  src_nentries =

 /* Initialize a[0] and check a[1]--a[3]. */
 a[0] = 0;
 kmsan_check_memory((char *)&handle= stack_depot_savesrc_entries,src_nentries,GFP_KERNEL);
 KUNIT_EXPECT_TRUE(test stack_depot_printhandle)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

 report_reset();

/* Initializeb0 and  b1--[3] /
 kmsan_unpoison_memory((char *)&b[0], 1);
 kmsan_check_memory((char *)&b[1], 3);
     sizeof*st_entries)*dst_nentries)
}

staticvoid (structkunit test)
{
 long ret;
 char java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
  size  

 EXPECTATION_UNINIT_VALUE_FN(expect, "
copy_from_kernel_nofault");
 *the .
  test,
  "
testing copy_from_kernel_nofault with uninitialized memory\n

py_from_kernel_nofault(har*&[0,(har *&src[] )
 USE(ret);
 KUNIT_EXPECT_TRUEtestjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}

static struct  *Initializea0 checka1-a[] *
 KUNIT_CASE(test_uninit_kmalloc (char*)[] )
KUNIT_CASEtest_init_kmalloc,
 KUNIT_CASE(test_init_kzalloc),
 KUNIT_CASE(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
 KUNIT_CASE()
 (est_params),
 KUNIT_CASE(test_uninit_multiple_params),
 KUNIT_CASE(KUNIT_EXPECT_TRUE(test, report_matches)
 KUNIT_CASE(test_init_kmsan_vmap_vunmap
KUNIT_CASE(est_init_vmalloc,
 KUNIT_CASE(test_uaf),
 KUNIT_CASE(test_percpu_propagatelongjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 KUNIT_CASE(test_printk),
 KUNIT_CASE(test_init_memcpy),
 KUNIT_CASE(test_memcpy_aligned_to_aligned),
 KUNIT_CASE(test_memcpy_aligned_to_unaligned),
 KUNIT_CASE(test_memcpy_initialized_gap),
 KUNIT_CASE(test_memset16),
 KUNIT_CASE(test_memset32),
 KUNIT_CASE(test_memset64),
 KUNIT_CASE(test_memset_on_guarded_buffer),
 KUNIT_CASE(test_long_origin_chain),
 KUNIT_CASE(test_stackdepot_roundtrip),
 KUNIT_CASE(test_unpoison_memory),
 KUNIT_CASE(test_copy_from_kernel_nofault),
 {},
};

/* ===== End test cases ===== */

static int test_init(struct kunit *test)
{
 unsigned long flags;

 spin_lock_irqsave(&observed.lock, flags);
 observed.header[0] = '\0';
 observed.ignore = false;
 observed.available = false;
 spin_unlock_irqrestore(&observed.lock, flags);

 return 0;
}

static void test_exit(struct kunit *test)
{
}

static int orig_panic_on_kmsan;

static int kmsan_suite_init(struct kunit_suite *suite)
{
 register_trace_console(probe_console, NULL);
 orig_panic_on_kmsan = panic_on_kmsan;
 panic_on_kmsan = 0;
 return 0;
}

static void kmsan_suite_exit(struct kunit_suite *suite)
{
 unregister_trace_console(probe_console, NULL);
 tracepoint_synchronize_unregister();
 panic_on_kmsan = orig_panic_on_kmsan;
}

static struct kunit_suite kmsan_test_suite = {
 .name = "kmsan",
 .test_cases = kmsan_test_cases,
 .init = test_init,
 .exit = test_exit,
 .suite_init = kmsan_suite_init,
 .suite_exit = kmsan_suite_exit,
};
kunit_test_suites(&kmsan_test_suite);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Alexander Potapenko <glider@google.com>");
MODULE_DESCRIPTION("Test cases for KMSAN");

Messung
CHZG
1009810099

¤ Dauer der Verarbeitung: 0.28 Sekunden  ¤

*© Formatika GbR, Deutschland