linux/include/linux/sockptr.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2020 Christoph Hellwig.
 *
 * Support for "universal" pointers that can point to either kernel or userspace
 * memory.
 */
#ifndef _LINUX_SOCKPTR_H
#define _LINUX_SOCKPTR_H

#include <linux/slab.h>
#include <linux/uaccess.h>

sockptr_t;

static inline bool sockptr_is_kernel(sockptr_t sockptr)
{}

static inline sockptr_t KERNEL_SOCKPTR(void *p)
{}

static inline sockptr_t USER_SOCKPTR(void __user *p)
{}

static inline bool sockptr_is_null(sockptr_t sockptr)
{}

static inline int copy_from_sockptr_offset(void *dst, sockptr_t src,
		size_t offset, size_t size)
{}

/* Deprecated.
 * This is unsafe, unless caller checked user provided optlen.
 * Prefer copy_safe_from_sockptr() instead.
 */
static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size)
{}

/**
 * copy_safe_from_sockptr: copy a struct from sockptr
 * @dst:   Destination address, in kernel space. This buffer must be @ksize
 *         bytes long.
 * @ksize: Size of @dst struct.
 * @optval: Source address. (in user or kernel space)
 * @optlen: Size of @optval data.
 *
 * Returns:
 *  * -EINVAL: @optlen < @ksize
 *  * -EFAULT: access to userspace failed.
 *  * 0 : @ksize bytes were copied
 */
static inline int copy_safe_from_sockptr(void *dst, size_t ksize,
					 sockptr_t optval, unsigned int optlen)
{}

static inline int copy_struct_from_sockptr(void *dst, size_t ksize,
		sockptr_t src, size_t usize)
{}

static inline int copy_to_sockptr_offset(sockptr_t dst, size_t offset,
		const void *src, size_t size)
{}

static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size)
{}

static inline void *memdup_sockptr_noprof(sockptr_t src, size_t len)
{}
#define memdup_sockptr(...)

static inline void *memdup_sockptr_nul_noprof(sockptr_t src, size_t len)
{}
#define memdup_sockptr_nul(...)

static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count)
{}

static inline int check_zeroed_sockptr(sockptr_t src, size_t offset,
				       size_t size)
{}

#endif /* _LINUX_SOCKPTR_H */