linux/lib/usercopy_kunit.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Kernel module for testing copy_to/from_user infrastructure.
 *
 * Copyright 2013 Google Inc. All Rights Reserved
 *
 * Authors:
 *      Kees Cook       <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/mman.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <kunit/test.h>

/*
 * Several 32-bit architectures support 64-bit {get,put}_user() calls.
 * As there doesn't appear to be anything that can safely determine
 * their capability at compile-time, we just have to opt-out certain archs.
 */
#if BITS_PER_LONG == 64 || (!(defined(CONFIG_ARM) && !defined(MMU)) && \
			    !defined(CONFIG_M68K) &&		\
			    !defined(CONFIG_MICROBLAZE) &&	\
			    !defined(CONFIG_NIOS2) &&		\
			    !defined(CONFIG_PPC32) &&		\
			    !defined(CONFIG_SUPERH))
#define TEST_U64
#endif

struct usercopy_test_priv {};

static bool is_zeroed(void *from, size_t size)
{}

/* Test usage of check_nonzero_user(). */
static void usercopy_test_check_nonzero_user(struct kunit *test)
{}

/* Test usage of copy_struct_from_user(). */
static void usercopy_test_copy_struct_from_user(struct kunit *test)
{}

/*
 * Legitimate usage: none of these copies should fail.
 */
static void usercopy_test_valid(struct kunit *test)
{}

/*
 * Invalid usage: none of these copies should succeed.
 */
static void usercopy_test_invalid(struct kunit *test)
{}

static int usercopy_test_init(struct kunit *test)
{}

static struct kunit_case usercopy_test_cases[] =;

static struct kunit_suite usercopy_test_suite =;

kunit_test_suites();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();