arch/powerpc/include/asm/uaccess.h

Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/uaccess.h

File Facts

System
Linux kernel
Corpus path
arch/powerpc/include/asm/uaccess.h
Extension
.h
Size
18399 bytes
Lines
626
Domain
Architecture Layer
Bucket
arch/powerpc
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (unlikely(ret)) {
			allow_user_access(to, dir);
			ret = __copy_tofrom_user_base(to, from, n);
			prevent_user_access(dir);
		}
		return ret;
	}

	allow_user_access(to, dir);
	ret = __copy_tofrom_user(to, from, n);
	prevent_user_access(dir);
	return ret;
}

#ifdef CONFIG_PPC64
static inline unsigned long
raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
{
	barrier_nospec();
	return raw_copy_tofrom_user(to, from, n, KUAP_READ_WRITE);
}
#endif /* CONFIG_PPC64 */

static inline unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
	return raw_copy_tofrom_user((__force void __user *)to, from, n, KUAP_READ);
}

static inline unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
	return raw_copy_tofrom_user(to, (__force const void __user *)from, n, KUAP_WRITE);
}

unsigned long __arch_clear_user(void __user *addr, unsigned long size);

static inline unsigned long __clear_user(void __user *addr, unsigned long size)
{
	unsigned long ret;

	might_fault();
	allow_user_access(addr, KUAP_WRITE);
	ret = __arch_clear_user(addr, size);
	prevent_user_access(KUAP_WRITE);
	return ret;
}

static inline unsigned long clear_user(void __user *addr, unsigned long size)
{
	return likely(access_ok(addr, size)) ? __clear_user(addr, size) : size;
}

extern long strncpy_from_user(char *dst, const char __user *src, long count);
extern __must_check long strnlen_user(const char __user *str, long n);

#ifdef CONFIG_ARCH_HAS_COPY_MC
unsigned long __must_check
copy_mc_generic(void *to, const void *from, unsigned long size);

static inline unsigned long __must_check
copy_mc_to_kernel(void *to, const void *from, unsigned long size)
{
	return copy_mc_generic(to, from, size);
}
#define copy_mc_to_kernel copy_mc_to_kernel

static inline unsigned long __must_check
copy_mc_to_user(void __user *to, const void *from, unsigned long n)
{
	if (check_copy_size(from, n, true)) {
		if (access_ok(to, n)) {
			allow_user_access(to, KUAP_WRITE);
			n = copy_mc_generic((void __force *)to, from, n);
			prevent_user_access(KUAP_WRITE);
		}
	}

	return n;
}
#endif

extern size_t copy_from_user_flushcache(void *dst, const void __user *src, size_t size);

static __must_check __always_inline bool __user_access_begin(const void __user *ptr, size_t len,
							     unsigned long dir)
{
	if (unlikely(!access_ok(ptr, len)))
		return false;

	might_fault();

Annotation

Implementation Notes