mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
Merge remote-tracking branch 'sm8350/lineage-20' into lineage-23.0
* sm8350/lineage-20: (841 commits)
UPSTREAM: fs: prevent out-of-bounds array speculation when closing a file descriptor
UPSTREAM: file: let pick_file() tell caller it's done
BACKPORT: rcu-tasks: Add a grace-period start time for throttling and debug
BACKPORT: maccess: rename probe_user_{read,write} to copy_{from,to}_user_nofault
BACKPORT: powerpc: use probe_user_read() and probe_user_write()
BACKPORT: maccess: rename probe_kernel_address to get_kernel_nofault
BACKPORT: tracing/kprobes: handle mixed kernel/userspace probes better
BACKPORT: maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault
UPSTREAM: maccess: unexport probe_kernel_write()
UPSTREAM: maccess: return -ERANGE when probe_kernel_read() fails
UPSTREAM: maccess: allow architectures to provide kernel probing directly
BACKPORT: maccess: remove strncpy_from_unsafe
UPSTREAM: bpf:bpf_seq_printf(): handle potentially unsafe format string better
UPSTREAM: bpf: Use strncpy_from_unsafe_strict() in bpf_seq_printf() helper
UPSTREAM: bpf: handle the compat string in bpf_trace_copy_string better
UPSTREAM: bpf: factor out a bpf_trace_copy_string helper
BACKPORT: maccess: always use strict semantics for probe_kernel_read
UPSTREAM: maccess: unify the probe kernel arch hooks
UPSTREAM: maccess: remove probe_read_common and probe_write_common
UPSTREAM: maccess: remove duplicate kerneldoc comments
...
Change-Id: I22cf7d6fb34826727904effb4f012b0ef459149d
This commit is contained in:
commit
2eb0f824a1
529 changed files with 40893 additions and 9494 deletions
26
Documentation/ABI/obsolete/sysfs-selinux-disable
Normal file
26
Documentation/ABI/obsolete/sysfs-selinux-disable
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
What: /sys/fs/selinux/disable
|
||||
Date: April 2005 (predates git)
|
||||
KernelVersion: 2.6.12-rc2 (predates git)
|
||||
Contact: selinux@vger.kernel.org
|
||||
Description:
|
||||
|
||||
The selinuxfs "disable" node allows SELinux to be disabled at runtime
|
||||
prior to a policy being loaded into the kernel. If disabled via this
|
||||
mechanism, SELinux will remain disabled until the system is rebooted.
|
||||
|
||||
The preferred method of disabling SELinux is via the "selinux=0" boot
|
||||
parameter, but the selinuxfs "disable" node was created to make it
|
||||
easier for systems with primitive bootloaders that did not allow for
|
||||
easy modification of the kernel command line. Unfortunately, allowing
|
||||
for SELinux to be disabled at runtime makes it difficult to secure the
|
||||
kernel's LSM hooks using the "__ro_after_init" feature.
|
||||
|
||||
Thankfully, the need for the SELinux runtime disable appears to be
|
||||
gone, the default Kconfig configuration disables this selinuxfs node,
|
||||
and only one of the major distributions, Fedora, supports disabling
|
||||
SELinux at runtime. Fedora is in the process of removing the
|
||||
selinuxfs "disable" node and once that is complete we will start the
|
||||
slow process of removing this code from the kernel.
|
||||
|
||||
More information on /sys/fs/selinux/disable can be found under the
|
||||
CONFIG_SECURITY_SELINUX_DISABLE Kconfig option.
|
||||
|
|
@ -186,6 +186,17 @@ cgroup v2 currently supports the following mount options.
|
|||
modified through remount from the init namespace. The mount
|
||||
option is ignored on non-init namespace mounts.
|
||||
|
||||
memory_recursiveprot
|
||||
|
||||
Recursively apply memory.min and memory.low protection to
|
||||
entire subtrees, without requiring explicit downward
|
||||
propagation into leaf cgroups. This allows protecting entire
|
||||
subtrees from one another, while retaining free competition
|
||||
within those subtrees. This should have been the default
|
||||
behavior but is a mount-option to avoid regressing setups
|
||||
relying on the original semantics (e.g. specifying bogusly
|
||||
high 'bypass' protection values at higher tree levels).
|
||||
|
||||
|
||||
Organizing Processes and Threads
|
||||
--------------------------------
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@
|
|||
1 -- check protection requested by application.
|
||||
Default value is set via a kernel config option.
|
||||
Value can be changed at runtime via
|
||||
/selinux/checkreqprot.
|
||||
/sys/fs/selinux/checkreqprot.
|
||||
|
||||
cio_ignore= [S390]
|
||||
See Documentation/s390/common_io.rst for details.
|
||||
|
|
@ -1251,7 +1251,8 @@
|
|||
0 -- permissive (log only, no denials).
|
||||
1 -- enforcing (deny and log).
|
||||
Default value is 0.
|
||||
Value can be changed at runtime via /selinux/enforce.
|
||||
Value can be changed at runtime via
|
||||
/sys/fs/selinux/enforce.
|
||||
|
||||
erst_disable [ACPI]
|
||||
Disable Error Record Serialization Table (ERST)
|
||||
|
|
@ -4280,6 +4281,13 @@
|
|||
only normal grace-period primitives. No effect
|
||||
on CONFIG_TINY_RCU kernels.
|
||||
|
||||
rcupdate.rcu_task_ipi_delay= [KNL]
|
||||
Set time in jiffies during which RCU tasks will
|
||||
avoid sending IPIs, starting with the beginning
|
||||
of a given grace period. Setting a large
|
||||
number avoids disturbing real-time workloads,
|
||||
but lengthens grace periods.
|
||||
|
||||
rcupdate.rcu_task_stall_timeout= [KNL]
|
||||
Set timeout in jiffies for RCU task stall warning
|
||||
messages. Disable with a value less than or equal
|
||||
|
|
@ -4479,9 +4487,7 @@
|
|||
See security/selinux/Kconfig help text.
|
||||
0 -- disable.
|
||||
1 -- enable.
|
||||
Default value is set via kernel config option.
|
||||
If enabled at boot time, /selinux/disable can be used
|
||||
later to disable prior to initial policy load.
|
||||
Default value is 1.
|
||||
|
||||
apparmor= [APPARMOR] Disable or enable AppArmor at boot time
|
||||
Format: { "0" | "1" }
|
||||
|
|
|
|||
|
|
@ -142,3 +142,6 @@ BPF flow dissector doesn't support exporting all the metadata that in-kernel
|
|||
C-based implementation can export. Notable example is single VLAN (802.1Q)
|
||||
and double VLAN (802.1AD) tags. Please refer to the ``struct bpf_flow_keys``
|
||||
for a set of information that's currently can be exported from the BPF context.
|
||||
|
||||
When BPF flow dissector is attached to the root network namespace (machine-wide
|
||||
policy), users can't override it in their child network namespaces.
|
||||
|
|
|
|||
|
|
@ -110,6 +110,20 @@ used when printing stack backtraces. The specifier takes into
|
|||
consideration the effect of compiler optimisations which may occur
|
||||
when tail-calls are used and marked with the noreturn GCC attribute.
|
||||
|
||||
Probed Pointers from BPF / tracing
|
||||
----------------------------------
|
||||
|
||||
::
|
||||
|
||||
%pks kernel string
|
||||
%pus user string
|
||||
|
||||
The ``k`` and ``u`` specifiers are used for printing prior probed memory from
|
||||
either kernel memory (k) or user memory (u). The subsequent ``s`` specifier
|
||||
results in printing a string. For direct use in regular vsnprintf() the (k)
|
||||
and (u) annotation is ignored, however, when used out of BPF's bpf_trace_printk(),
|
||||
for example, it reads the memory it is pointing to without faulting.
|
||||
|
||||
Kernel Pointers
|
||||
---------------
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ SipHash - a short input PRF
|
|||
SipHash is a cryptographically secure PRF -- a keyed hash function -- that
|
||||
performs very well for short inputs, hence the name. It was designed by
|
||||
cryptographers Daniel J. Bernstein and Jean-Philippe Aumasson. It is intended
|
||||
as a replacement for some uses of: `jhash`, `md5_transform`, `sha_transform`,
|
||||
as a replacement for some uses of: `jhash`, `md5_transform`, `sha1_transform`,
|
||||
and so forth.
|
||||
|
||||
SipHash takes a secret key filled with randomly generated numbers and either
|
||||
|
|
|
|||
|
|
@ -170,6 +170,14 @@ FTRACE_OPS_FL_RCU
|
|||
a callback may be executed and RCU synchronization will not protect
|
||||
it.
|
||||
|
||||
FTRACE_OPS_FL_PERMANENT
|
||||
If this is set on any ftrace ops, then the tracing cannot disabled by
|
||||
writing 0 to the proc sysctl ftrace_enabled. Equally, a callback with
|
||||
the flag set cannot be registered if ftrace_enabled is 0.
|
||||
|
||||
Livepatch uses it not to lose the function redirection, so the system
|
||||
stays protected.
|
||||
|
||||
|
||||
Filtering which functions to trace
|
||||
==================================
|
||||
|
|
|
|||
|
|
@ -2976,7 +2976,9 @@ Note, the proc sysctl ftrace_enable is a big on/off switch for the
|
|||
function tracer. By default it is enabled (when function tracing is
|
||||
enabled in the kernel). If it is disabled, all function tracing is
|
||||
disabled. This includes not only the function tracers for ftrace, but
|
||||
also for any other uses (perf, kprobes, stack tracing, profiling, etc).
|
||||
also for any other uses (perf, kprobes, stack tracing, profiling, etc). It
|
||||
cannot be disabled if there is a callback with FTRACE_OPS_FL_PERMANENT set
|
||||
registered.
|
||||
|
||||
Please disable this with care.
|
||||
|
||||
|
|
|
|||
|
|
@ -3054,6 +3054,7 @@ R: Martin KaFai Lau <kafai@fb.com>
|
|||
R: Song Liu <songliubraving@fb.com>
|
||||
R: Yonghong Song <yhs@fb.com>
|
||||
R: Andrii Nakryiko <andriin@fb.com>
|
||||
R: KP Singh <kpsingh@chromium.org>
|
||||
L: netdev@vger.kernel.org
|
||||
L: bpf@vger.kernel.org
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
|
||||
|
|
@ -14622,6 +14623,7 @@ F: include/uapi/linux/selinux_netlink.h
|
|||
F: security/selinux/
|
||||
F: scripts/selinux/
|
||||
F: Documentation/admin-guide/LSM/SELinux.rst
|
||||
F: Documentation/ABI/obsolete/sysfs-selinux-disable
|
||||
|
||||
SENSABLE PHANTOM
|
||||
M: Jiri Slaby <jirislaby@gmail.com>
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -447,6 +447,7 @@ OBJSIZE = $(CROSS_COMPILE)size
|
|||
STRIP = $(CROSS_COMPILE)strip
|
||||
endif
|
||||
PAHOLE = pahole
|
||||
RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids
|
||||
LEX = flex
|
||||
YACC = bison
|
||||
AWK = awk
|
||||
|
|
@ -509,7 +510,7 @@ GCC_PLUGINS_CFLAGS :=
|
|||
CLANG_FLAGS :=
|
||||
|
||||
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
|
||||
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
|
||||
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
|
||||
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
|
||||
export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ
|
||||
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ config ARM
|
|||
select ARCH_HAS_KEEPINITRD
|
||||
select ARCH_HAS_KCOV
|
||||
select ARCH_HAS_MEMBARRIER_SYNC_CORE
|
||||
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
|
||||
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
|
||||
select ARCH_HAS_PHYS_TO_DMA
|
||||
select ARCH_HAS_SETUP_DMA_OPS
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
|
|||
}
|
||||
|
||||
if (validate) {
|
||||
if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(&replaced, (void *)pc,
|
||||
MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
if (replaced != old)
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
|
|||
/* patch_text() only supports int-sized breakpoints */
|
||||
BUILD_BUG_ON(sizeof(int) != BREAK_INSTR_SIZE);
|
||||
|
||||
err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
|
||||
err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr,
|
||||
BREAK_INSTR_SIZE);
|
||||
if (err)
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ int is_valid_bugaddr(unsigned long pc)
|
|||
u32 insn = __opcode_to_mem_arm(BUG_INSTR_VALUE);
|
||||
#endif
|
||||
|
||||
if (probe_kernel_address((unsigned *)pc, bkpt))
|
||||
if (get_kernel_nofault(bkpt, (unsigned *)pc))
|
||||
return 0;
|
||||
|
||||
return bkpt == insn;
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ static int alignment_get_arm(struct pt_regs *regs, u32 *ip, u32 *inst)
|
|||
if (user_mode(regs))
|
||||
fault = get_user(instr, ip);
|
||||
else
|
||||
fault = probe_kernel_address(ip, instr);
|
||||
fault = get_kernel_nofault(instr, ip);
|
||||
|
||||
*inst = __mem_to_opcode_arm(instr);
|
||||
|
||||
|
|
@ -789,7 +789,7 @@ static int alignment_get_thumb(struct pt_regs *regs, u16 *ip, u16 *inst)
|
|||
if (user_mode(regs))
|
||||
fault = get_user(instr, ip);
|
||||
else
|
||||
fault = probe_kernel_address(ip, instr);
|
||||
fault = get_kernel_nofault(instr, ip);
|
||||
|
||||
*inst = __mem_to_opcode_thumb16(instr);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ config ARM64
|
|||
select ARCH_HAS_KCOV
|
||||
select ARCH_HAS_KEEPINITRD
|
||||
select ARCH_HAS_MEMBARRIER_SYNC_CORE
|
||||
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
|
||||
select ARCH_HAS_PTE_DEVMAP
|
||||
select ARCH_HAS_PTE_SPECIAL
|
||||
select ARCH_HAS_SETUP_DMA_OPS
|
||||
|
|
@ -73,6 +74,7 @@ config ARM64
|
|||
select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG
|
||||
select ARCH_SUPPORTS_NUMA_BALANCING
|
||||
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
|
||||
select ARCH_WANT_DEFAULT_BPF_JIT
|
||||
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
|
||||
select ARCH_WANT_FRAME_POINTERS
|
||||
select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
|
||||
|
|
|
|||
|
|
@ -313,6 +313,8 @@ CONFIG_KEYBOARD_GPIO=y
|
|||
# CONFIG_INPUT_MOUSE is not set
|
||||
CONFIG_INPUT_JOYSTICK=y
|
||||
CONFIG_JOYSTICK_XPAD=y
|
||||
CONFIG_JOYSTICK_XPAD_FF=y
|
||||
CONFIG_JOYSTICK_XPAD_LEDS=y
|
||||
CONFIG_INPUT_TOUCHSCREEN=y
|
||||
CONFIG_INPUT_MISC=y
|
||||
CONFIG_INPUT_UINPUT=y
|
||||
|
|
@ -393,6 +395,7 @@ CONFIG_HID_BATTERY_STRENGTH=y
|
|||
CONFIG_HIDRAW=y
|
||||
CONFIG_UHID=y
|
||||
CONFIG_HID_APPLE=y
|
||||
CONFIG_HID_BETOP_FF=y
|
||||
CONFIG_HID_PRODIKEYS=y
|
||||
CONFIG_HID_ELECOM=y
|
||||
CONFIG_HID_UCLOGIC=y
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ static void __init register_insn_emulation(struct insn_emulation_ops *ops)
|
|||
}
|
||||
|
||||
static int emulation_proc_handler(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
void *buffer, size_t *lenp,
|
||||
loff_t *ppos)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
|
|||
|
|
@ -341,8 +341,7 @@ static unsigned int find_supported_vector_length(unsigned int vl)
|
|||
#if defined(CONFIG_ARM64_SVE) && defined(CONFIG_SYSCTL)
|
||||
|
||||
static int sve_proc_do_default_vl(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int ret;
|
||||
int vl = sve_default_vl;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ int __kprobes aarch64_insn_read(void *addr, u32 *insnp)
|
|||
int ret;
|
||||
__le32 val;
|
||||
|
||||
ret = probe_kernel_read(&val, addr, AARCH64_INSN_SIZE);
|
||||
ret = copy_from_kernel_nofault(&val, addr, AARCH64_INSN_SIZE);
|
||||
if (!ret)
|
||||
*insnp = le32_to_cpu(val);
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ static int __kprobes __aarch64_insn_write(void *addr, __le32 insn)
|
|||
raw_spin_lock_irqsave(&patch_lock, flags);
|
||||
waddr = patch_map(addr, FIX_TEXT_POKE0);
|
||||
|
||||
ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE);
|
||||
ret = copy_to_kernel_nofault(waddr, &insn, AARCH64_INSN_SIZE);
|
||||
|
||||
patch_unmap(FIX_TEXT_POKE0);
|
||||
raw_spin_unlock_irqrestore(&patch_lock, flags);
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ static int call_undef_hook(struct pt_regs *regs)
|
|||
|
||||
if (!user_mode(regs)) {
|
||||
__le32 instr_le;
|
||||
if (probe_kernel_address((__force __le32 *)pc, instr_le))
|
||||
if (get_kernel_nofault(instr_le, (__force __le32 *)pc))
|
||||
goto exit;
|
||||
instr = le32_to_cpu(instr_le);
|
||||
} else if (compat_thumb_mode(regs)) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ static int ftrace_check_current_nop(unsigned long hook)
|
|||
uint16_t olds[7];
|
||||
unsigned long hook_pos = hook - 2;
|
||||
|
||||
if (probe_kernel_read((void *)olds, (void *)hook_pos, sizeof(nops)))
|
||||
if (copy_from_kernel_nofault((void *)olds, (void *)hook_pos,
|
||||
sizeof(nops)))
|
||||
return -EFAULT;
|
||||
|
||||
if (memcmp((void *)nops, (void *)olds, sizeof(nops))) {
|
||||
|
|
@ -96,7 +97,7 @@ static int ftrace_modify_code(unsigned long hook, unsigned long target,
|
|||
|
||||
make_jbsr(target, hook, call, nolr);
|
||||
|
||||
ret = probe_kernel_write((void *)hook_pos, enable ? call : nops,
|
||||
ret = copy_to_kernel_nofault((void *)hook_pos, enable ? call : nops,
|
||||
sizeof(nops));
|
||||
if (ret)
|
||||
return -EPERM;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ static inline void *dereference_function_descriptor(void *ptr)
|
|||
struct fdesc *desc = ptr;
|
||||
void *p;
|
||||
|
||||
if (!probe_kernel_address(&desc->ip, p))
|
||||
if (!get_kernel_nofault(p, &desc->ip))
|
||||
ptr = p;
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
|
|||
goto skip_check;
|
||||
|
||||
/* read the text we want to modify */
|
||||
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* Make sure it is what we expect it to be */
|
||||
|
|
@ -117,7 +117,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
|
|||
|
||||
skip_check:
|
||||
/* replace the text with the new text */
|
||||
if (probe_kernel_write(((void *)ip), new_code, MCOUNT_INSN_SIZE))
|
||||
if (copy_to_kernel_nofault(((void *)ip), new_code, MCOUNT_INSN_SIZE))
|
||||
return -EPERM;
|
||||
flush_icache_range(ip, ip + MCOUNT_INSN_SIZE);
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ static int ftrace_make_nop_check(struct dyn_ftrace *rec, unsigned long addr)
|
|||
unsigned char __attribute__((aligned(8))) replaced[MCOUNT_INSN_SIZE];
|
||||
unsigned long ip = rec->ip;
|
||||
|
||||
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
if (rec->flags & FTRACE_FL_CONVERTED) {
|
||||
struct ftrace_call_insn *call_insn, *tmp_call;
|
||||
|
|
|
|||
|
|
@ -398,6 +398,8 @@ static inline pte_t pte_mkspecial(pte_t pte)
|
|||
return pte;
|
||||
}
|
||||
|
||||
#define pte_sw_mkyoung pte_mkyoung
|
||||
|
||||
#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
|
||||
static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_HUGE; }
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if ((probe_kernel_read(&prev_insn, p->addr - 1,
|
||||
sizeof(mips_instruction)) == 0) &&
|
||||
insn_has_delayslot(prev_insn)) {
|
||||
if (copy_from_kernel_nofault(&prev_insn, p->addr - 1,
|
||||
sizeof(mips_instruction)) == 0 &&
|
||||
insn_has_delayslot(prev_insn)) {
|
||||
pr_notice("Kprobes for branch delayslot are not supported\n");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
|
|
|||
|
|
@ -95,16 +95,15 @@ int proc_lasat_ip(struct ctl_table *table, int write,
|
|||
len = 0;
|
||||
p = buffer;
|
||||
while (len < *lenp) {
|
||||
if (get_user(c, p++))
|
||||
return -EFAULT;
|
||||
c = *p;
|
||||
p++;
|
||||
if (c == 0 || c == '\n')
|
||||
break;
|
||||
len++;
|
||||
}
|
||||
if (len >= sizeof(ipbuf)-1)
|
||||
len = sizeof(ipbuf) - 1;
|
||||
if (copy_from_user(ipbuf, buffer, len))
|
||||
return -EFAULT;
|
||||
memcpy(ipbuf, buffer, len);
|
||||
ipbuf[len] = 0;
|
||||
*ppos += *lenp;
|
||||
/* Now see if we can convert it to a valid IP */
|
||||
|
|
@ -122,11 +121,9 @@ int proc_lasat_ip(struct ctl_table *table, int write,
|
|||
if (len > *lenp)
|
||||
len = *lenp;
|
||||
if (len)
|
||||
if (copy_to_user(buffer, ipbuf, len))
|
||||
return -EFAULT;
|
||||
memcpy(buffer, ipbuf, len);
|
||||
if (len < *lenp) {
|
||||
if (put_user('\n', ((char *) buffer) + len))
|
||||
return -EFAULT;
|
||||
*((char *)buffer + len) = '\n';
|
||||
len++;
|
||||
}
|
||||
*lenp = len;
|
||||
|
|
|
|||
|
|
@ -143,13 +143,14 @@ static int __ftrace_modify_code(unsigned long pc, unsigned long *old_insn,
|
|||
unsigned long orig_insn[3];
|
||||
|
||||
if (validate) {
|
||||
if (probe_kernel_read(orig_insn, (void *)pc, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(orig_insn, (void *)pc,
|
||||
MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
if (memcmp(orig_insn, old_insn, MCOUNT_INSN_SIZE))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (probe_kernel_write((void *)pc, new_insn, MCOUNT_INSN_SIZE))
|
||||
if (copy_to_kernel_nofault((void *)pc, new_insn, MCOUNT_INSN_SIZE))
|
||||
return -EPERM;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
|
|||
|
||||
ip = (void *)(rec->ip + 4 - size);
|
||||
|
||||
ret = probe_kernel_read(insn, ip, size);
|
||||
ret = copy_from_kernel_nofault(insn, ip, size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
|
|||
|
||||
int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
|
||||
{
|
||||
int ret = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
|
||||
BREAK_INSTR_SIZE);
|
||||
int ret = copy_from_kernel_nofault(bpt->saved_instr,
|
||||
(char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ void *dereference_function_descriptor(void *ptr)
|
|||
Elf64_Fdesc *desc = ptr;
|
||||
void *p;
|
||||
|
||||
if (!probe_kernel_address(&desc->addr, p))
|
||||
if (!get_kernel_nofault(p, &desc->addr))
|
||||
ptr = p;
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,14 +57,10 @@ void * memcpy(void * dst,const void *src, size_t count)
|
|||
EXPORT_SYMBOL(raw_copy_in_user);
|
||||
EXPORT_SYMBOL(memcpy);
|
||||
|
||||
long probe_kernel_read(void *dst, const void *src, size_t size)
|
||||
bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
|
||||
{
|
||||
unsigned long addr = (unsigned long)src;
|
||||
|
||||
if (addr < PAGE_SIZE)
|
||||
return -EFAULT;
|
||||
|
||||
if ((unsigned long)unsafe_src < PAGE_SIZE)
|
||||
return false;
|
||||
/* check for I/O space F_EXTEND(0xfff00000) access as well? */
|
||||
|
||||
return __probe_kernel_read(dst, src, size);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ static inline void *dereference_function_descriptor(void *ptr)
|
|||
struct ppc64_opd_entry *desc = ptr;
|
||||
void *p;
|
||||
|
||||
if (!probe_kernel_address(&desc->funcaddr, p))
|
||||
if (!get_kernel_nofault(p, &desc->funcaddr))
|
||||
ptr = p;
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
|
|||
unsigned int instr;
|
||||
unsigned int *addr = (unsigned int *)bpt->bpt_addr;
|
||||
|
||||
err = probe_kernel_address(addr, instr);
|
||||
err = get_kernel_nofault(instr, addr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ int module_trampoline_target(struct module *mod, unsigned long addr,
|
|||
|
||||
stub = (struct ppc64_stub_entry *)addr;
|
||||
|
||||
if (probe_kernel_read(&magic, &stub->magic, sizeof(magic))) {
|
||||
if (copy_from_kernel_nofault(&magic, &stub->magic, sizeof(magic))) {
|
||||
pr_err("%s: fault reading magic for stub %lx for %s\n", __func__, addr, mod->name);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ int module_trampoline_target(struct module *mod, unsigned long addr,
|
|||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (probe_kernel_read(&funcdata, &stub->funcdata, sizeof(funcdata))) {
|
||||
if (copy_from_kernel_nofault(&funcdata, &stub->funcdata, sizeof(funcdata))) {
|
||||
pr_err("%s: fault reading funcdata for stub %lx for %s\n", __func__, addr, mod->name);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1239,7 +1239,7 @@ static void show_instructions(struct pt_regs *regs)
|
|||
pr_cont("\n");
|
||||
|
||||
if (!__kernel_text_address(pc) ||
|
||||
probe_kernel_address((const void *)pc, instr)) {
|
||||
get_kernel_nofault(instr, (const void *)pc)) {
|
||||
pr_cont("XXXXXXXX ");
|
||||
} else {
|
||||
if (nip == pc)
|
||||
|
|
@ -1263,16 +1263,6 @@ void show_user_instructions(struct pt_regs *regs)
|
|||
|
||||
pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int));
|
||||
|
||||
/*
|
||||
* Make sure the NIP points at userspace, not kernel text/data or
|
||||
* elsewhere.
|
||||
*/
|
||||
if (!__access_ok(pc, NR_INSN_TO_PRINT * sizeof(int), USER_DS)) {
|
||||
pr_info("%s[%d]: Bad NIP, not dumping instructions.\n",
|
||||
current->comm, current->pid);
|
||||
return;
|
||||
}
|
||||
|
||||
seq_buf_init(&s, buf, sizeof(buf));
|
||||
|
||||
while (n) {
|
||||
|
|
@ -1283,7 +1273,8 @@ void show_user_instructions(struct pt_regs *regs)
|
|||
for (i = 0; i < 8 && n; i++, n--, pc += sizeof(int)) {
|
||||
int instr;
|
||||
|
||||
if (probe_kernel_address((const void *)pc, instr)) {
|
||||
if (copy_from_user_nofault(&instr, (void __user *)pc,
|
||||
sizeof(instr))) {
|
||||
seq_buf_printf(&s, "XXXXXXXX ");
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
|
|||
*/
|
||||
|
||||
/* read the text we want to modify */
|
||||
if (probe_kernel_read(&replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(&replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* Make sure it is what we expect it to be */
|
||||
|
|
@ -128,7 +128,7 @@ __ftrace_make_nop(struct module *mod,
|
|||
unsigned int op, pop;
|
||||
|
||||
/* read where this goes */
|
||||
if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)ip, sizeof(int))) {
|
||||
pr_err("Fetching opcode failed.\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ __ftrace_make_nop(struct module *mod,
|
|||
/* When using -mkernel_profile there is no load to jump over */
|
||||
pop = PPC_INST_NOP;
|
||||
|
||||
if (probe_kernel_read(&op, (void *)(ip - 4), 4)) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)(ip - 4), 4)) {
|
||||
pr_err("Fetching instruction at %lx failed.\n", ip - 4);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ __ftrace_make_nop(struct module *mod,
|
|||
* Check what is in the next instruction. We can see ld r2,40(r1), but
|
||||
* on first pass after boot we will see mflr r0.
|
||||
*/
|
||||
if (probe_kernel_read(&op, (void *)(ip+4), MCOUNT_INSN_SIZE)) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)(ip+4), MCOUNT_INSN_SIZE)) {
|
||||
pr_err("Fetching op failed.\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ __ftrace_make_nop(struct module *mod,
|
|||
unsigned long ip = rec->ip;
|
||||
unsigned long tramp;
|
||||
|
||||
if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(&op, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* Make sure that that this is still a 24bit jump */
|
||||
|
|
@ -245,7 +245,7 @@ __ftrace_make_nop(struct module *mod,
|
|||
pr_devel("ip:%lx jumps to %lx", ip, tramp);
|
||||
|
||||
/* Find where the trampoline jumps to */
|
||||
if (probe_kernel_read(jmp, (void *)tramp, sizeof(jmp))) {
|
||||
if (copy_from_kernel_nofault(jmp, (void *)tramp, sizeof(jmp))) {
|
||||
pr_err("Failed to read %lx\n", tramp);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
|
|||
return -1;
|
||||
|
||||
/* New trampoline -- read where this goes */
|
||||
if (probe_kernel_read(&op, (void *)tramp, sizeof(int))) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)tramp, sizeof(int))) {
|
||||
pr_debug("Fetching opcode failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ static int __ftrace_make_nop_kernel(struct dyn_ftrace *rec, unsigned long addr)
|
|||
unsigned int op;
|
||||
|
||||
/* Read where this goes */
|
||||
if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)ip, sizeof(int))) {
|
||||
pr_err("Fetching opcode failed.\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -514,7 +514,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
|
|||
struct module *mod = rec->arch.mod;
|
||||
|
||||
/* read where this goes */
|
||||
if (probe_kernel_read(op, ip, sizeof(op)))
|
||||
if (copy_from_kernel_nofault(op, ip, sizeof(op)))
|
||||
return -EFAULT;
|
||||
|
||||
if (!expected_nop_sequence(ip, op[0], op[1])) {
|
||||
|
|
@ -576,7 +576,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
|
|||
unsigned long ip = rec->ip;
|
||||
|
||||
/* read where this goes */
|
||||
if (probe_kernel_read(&op, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(&op, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* It should be pointing to a nop */
|
||||
|
|
@ -632,7 +632,7 @@ static int __ftrace_make_call_kernel(struct dyn_ftrace *rec, unsigned long addr)
|
|||
}
|
||||
|
||||
/* Make sure we have a nop */
|
||||
if (probe_kernel_read(&op, ip, sizeof(op))) {
|
||||
if (copy_from_kernel_nofault(&op, ip, sizeof(op))) {
|
||||
pr_err("Unable to read ftrace location %p\n", ip);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
@ -710,7 +710,7 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
|
|||
}
|
||||
|
||||
/* read where this goes */
|
||||
if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
|
||||
if (copy_from_kernel_nofault(&op, (void *)ip, sizeof(int))) {
|
||||
pr_err("Fetching opcode failed.\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,10 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
|
|||
}
|
||||
isync();
|
||||
|
||||
pagefault_disable();
|
||||
if (is_load)
|
||||
ret = raw_copy_from_user(to, from, n);
|
||||
ret = copy_from_user_nofault(to, (const void __user *)from, n);
|
||||
else
|
||||
ret = raw_copy_to_user(to, from, n);
|
||||
pagefault_enable();
|
||||
ret = copy_to_user_nofault((void __user *)to, from, n);
|
||||
|
||||
/* switch the pid first to avoid running host with unallocated pid */
|
||||
if (quadrant == 1 && pid != old_pid)
|
||||
|
|
|
|||
|
|
@ -280,12 +280,8 @@ static bool bad_stack_expansion(struct pt_regs *regs, unsigned long address,
|
|||
if ((flags & FAULT_FLAG_WRITE) && (flags & FAULT_FLAG_USER) &&
|
||||
access_ok(nip, sizeof(*nip))) {
|
||||
unsigned int inst;
|
||||
int res;
|
||||
|
||||
pagefault_disable();
|
||||
res = __get_user_inatomic(inst, nip);
|
||||
pagefault_enable();
|
||||
if (!res)
|
||||
if (!probe_user_read(&inst, nip, sizeof(inst)))
|
||||
return !store_updates_sp(inst);
|
||||
*must_retry = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,15 +28,13 @@ static unsigned int user_getsp32(unsigned int sp, int is_first)
|
|||
unsigned int stack_frame[2];
|
||||
void __user *p = compat_ptr(sp);
|
||||
|
||||
if (!access_ok(p, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The most likely reason for this is that we returned -EFAULT,
|
||||
* which means that we've done all that we can do from
|
||||
* interrupt context.
|
||||
*/
|
||||
if (__copy_from_user_inatomic(stack_frame, p, sizeof(stack_frame)))
|
||||
if (copy_from_user_nofault(stack_frame, (void __user *)p,
|
||||
sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (!is_first)
|
||||
|
|
@ -54,11 +52,8 @@ static unsigned long user_getsp64(unsigned long sp, int is_first)
|
|||
{
|
||||
unsigned long stack_frame[3];
|
||||
|
||||
if (!access_ok((void __user *)sp, sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (__copy_from_user_inatomic(stack_frame, (void __user *)sp,
|
||||
sizeof(stack_frame)))
|
||||
if (copy_from_user_nofault(stack_frame, (void __user *)sp,
|
||||
sizeof(stack_frame)))
|
||||
return 0;
|
||||
|
||||
if (!is_first)
|
||||
|
|
@ -103,7 +98,6 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
|||
first_frame = 0;
|
||||
}
|
||||
} else {
|
||||
pagefault_disable();
|
||||
#ifdef CONFIG_PPC64
|
||||
if (!is_32bit_task()) {
|
||||
while (depth--) {
|
||||
|
|
@ -112,7 +106,6 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
|||
break;
|
||||
first_frame = 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -123,6 +116,5 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
|
|||
break;
|
||||
first_frame = 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,12 +156,8 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret)
|
|||
((unsigned long)ptr & 7))
|
||||
return -EFAULT;
|
||||
|
||||
pagefault_disable();
|
||||
if (!__get_user_inatomic(*ret, ptr)) {
|
||||
pagefault_enable();
|
||||
if (!probe_user_read(ret, ptr, sizeof(*ret)))
|
||||
return 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
|
||||
return read_user_stack_slow(ptr, ret, 8);
|
||||
}
|
||||
|
|
@ -172,12 +168,8 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
|
|||
((unsigned long)ptr & 3))
|
||||
return -EFAULT;
|
||||
|
||||
pagefault_disable();
|
||||
if (!__get_user_inatomic(*ret, ptr)) {
|
||||
pagefault_enable();
|
||||
if (!probe_user_read(ret, ptr, sizeof(*ret)))
|
||||
return 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
|
||||
return read_user_stack_slow(ptr, ret, 4);
|
||||
}
|
||||
|
|
@ -304,17 +296,11 @@ static inline int current_is_64bit(void)
|
|||
*/
|
||||
static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
|
||||
((unsigned long)ptr & 3))
|
||||
return -EFAULT;
|
||||
|
||||
pagefault_disable();
|
||||
rc = __get_user_inatomic(*ret, ptr);
|
||||
pagefault_enable();
|
||||
|
||||
return rc;
|
||||
return probe_user_read(ret, ptr, sizeof(*ret));
|
||||
}
|
||||
|
||||
static inline void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
|
||||
|
|
|
|||
|
|
@ -418,24 +418,20 @@ static void power_pmu_sched_task(struct perf_event_context *ctx, bool sched_in)
|
|||
static __u64 power_pmu_bhrb_to(u64 addr)
|
||||
{
|
||||
unsigned int instr;
|
||||
int ret;
|
||||
__u64 target;
|
||||
|
||||
if (is_kernel_addr(addr)) {
|
||||
if (probe_kernel_read(&instr, (void *)addr, sizeof(instr)))
|
||||
if (copy_from_kernel_nofault(&instr, (void *)addr,
|
||||
sizeof(instr)))
|
||||
return 0;
|
||||
|
||||
return branch_target(&instr);
|
||||
}
|
||||
|
||||
/* Userspace: need copy instruction here then translate it */
|
||||
pagefault_disable();
|
||||
ret = __get_user_inatomic(instr, (unsigned int __user *)addr);
|
||||
if (ret) {
|
||||
pagefault_enable();
|
||||
if (copy_from_user_nofault(&instr, (unsigned int __user *)addr,
|
||||
sizeof(instr)))
|
||||
return 0;
|
||||
}
|
||||
pagefault_enable();
|
||||
|
||||
target = branch_target(&instr);
|
||||
if ((!target) || (instr & BRANCH_ABSOLUTE))
|
||||
|
|
|
|||
|
|
@ -1073,13 +1073,11 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs)
|
|||
addr += mfspr(SPRN_MCAR);
|
||||
|
||||
if (is_in_pci_mem_space(addr)) {
|
||||
if (user_mode(regs)) {
|
||||
pagefault_disable();
|
||||
ret = get_user(inst, (__u32 __user *)regs->nip);
|
||||
pagefault_enable();
|
||||
} else {
|
||||
if (user_mode(regs))
|
||||
ret = copy_from_user_nofault(&inst,
|
||||
(void __user *)regs->nip, sizeof(inst));
|
||||
else
|
||||
ret = probe_kernel_address((void *)regs->nip, inst);
|
||||
}
|
||||
|
||||
if (!ret && mcheck_handle_load(regs, inst)) {
|
||||
regs->nip += 4;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ static int ftrace_check_current_call(unsigned long hook_pos,
|
|||
* Read the text we want to modify;
|
||||
* return must be -EFAULT on read error
|
||||
*/
|
||||
if (probe_kernel_read(replaced, (void *)hook_pos, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)hook_pos,
|
||||
MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
|
|||
{
|
||||
bug_insn_t insn;
|
||||
|
||||
if (probe_kernel_address((bug_insn_t *)pc, insn))
|
||||
if (get_kernel_nofault(insn, (bug_insn_t *)pc))
|
||||
return 0;
|
||||
return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ int is_valid_bugaddr(unsigned long pc)
|
|||
|
||||
if (pc < VMALLOC_START)
|
||||
return 0;
|
||||
if (probe_kernel_address((bug_insn_t *)pc, insn))
|
||||
if (get_kernel_nofault(insn, (bug_insn_t *)pc))
|
||||
return 0;
|
||||
if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32)
|
||||
return (insn == __BUG_INSN_32);
|
||||
|
|
|
|||
|
|
@ -51,10 +51,9 @@ static struct platform_device *appldata_pdev;
|
|||
*/
|
||||
static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata";
|
||||
static int appldata_timer_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos);
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
static int appldata_interval_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
|
||||
static struct ctl_table_header *appldata_sysctl_header;
|
||||
static struct ctl_table appldata_table[] = {
|
||||
|
|
@ -217,7 +216,7 @@ static void __appldata_vtimer_setup(int cmd)
|
|||
*/
|
||||
static int
|
||||
appldata_timer_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int timer_active = appldata_timer_active;
|
||||
int rc;
|
||||
|
|
@ -250,7 +249,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,
|
|||
*/
|
||||
static int
|
||||
appldata_interval_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int interval = appldata_interval;
|
||||
int rc;
|
||||
|
|
@ -280,7 +279,7 @@ appldata_interval_handler(struct ctl_table *ctl, int write,
|
|||
*/
|
||||
static int
|
||||
appldata_generic_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
struct appldata_ops *ops = NULL, *tmp_ops;
|
||||
struct list_head *lh;
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ static int debug_active = 1;
|
|||
* if debug_active is already off
|
||||
*/
|
||||
static int s390dbf_procactive(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
if (!write || debug_stoppable || !debug_active)
|
||||
return proc_dointvec(table, write, buffer, lenp, ppos);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
|
|||
{
|
||||
struct ftrace_insn orig, new, old;
|
||||
|
||||
if (probe_kernel_read(&old, (void *) rec->ip, sizeof(old)))
|
||||
if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old)))
|
||||
return -EFAULT;
|
||||
if (addr == MCOUNT_ADDR) {
|
||||
/* Initial code replacement */
|
||||
|
|
@ -141,7 +141,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
|
|||
{
|
||||
struct ftrace_insn orig, new, old;
|
||||
|
||||
if (probe_kernel_read(&old, (void *) rec->ip, sizeof(old)))
|
||||
if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old)))
|
||||
return -EFAULT;
|
||||
if (is_kprobe_on_ftrace(&old)) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ static int __init topology_setup(char *str)
|
|||
early_param("topology", topology_setup);
|
||||
|
||||
static int topology_ctl_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int enabled = topology_is_enabled();
|
||||
int new_mode;
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ static int cmm_skip_blanks(char *cp, char **endp)
|
|||
}
|
||||
|
||||
static int cmm_pages_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
long nr = cmm_get_pages();
|
||||
struct ctl_table ctl_entry = {
|
||||
|
|
@ -282,7 +282,7 @@ static int cmm_pages_handler(struct ctl_table *ctl, int write,
|
|||
}
|
||||
|
||||
static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
void *buffer, size_t *lenp,
|
||||
loff_t *ppos)
|
||||
{
|
||||
long nr = cmm_get_timed_pages();
|
||||
|
|
@ -302,7 +302,7 @@ static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
|
|||
}
|
||||
|
||||
static int cmm_timeout_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
char buf[64], *p;
|
||||
long nr, seconds;
|
||||
|
|
@ -315,8 +315,7 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
|
|||
|
||||
if (write) {
|
||||
len = min(*lenp, sizeof(buf));
|
||||
if (copy_from_user(buf, buffer, len))
|
||||
return -EFAULT;
|
||||
memcpy(buf, buffer, len);
|
||||
buf[len - 1] = '\0';
|
||||
cmm_skip_blanks(buf, &p);
|
||||
nr = simple_strtoul(p, &p, 0);
|
||||
|
|
@ -329,8 +328,7 @@ static int cmm_timeout_handler(struct ctl_table *ctl, int write,
|
|||
cmm_timeout_pages, cmm_timeout_seconds);
|
||||
if (len > *lenp)
|
||||
len = *lenp;
|
||||
if (copy_to_user(buffer, buf, len))
|
||||
return -EFAULT;
|
||||
memcpy(buffer, buf, len);
|
||||
*lenp = len;
|
||||
*ppos += len;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static int bad_address(void *p)
|
|||
{
|
||||
unsigned long dummy;
|
||||
|
||||
return probe_kernel_address((unsigned long *)p, dummy);
|
||||
return get_kernel_nofault(dummy, (unsigned long *)p);
|
||||
}
|
||||
|
||||
static void dump_pagetable(unsigned long asce, unsigned long address)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static void ftrace_mod_code(void)
|
|||
* But if one were to fail, then they all should, and if one were
|
||||
* to succeed, then they all should.
|
||||
*/
|
||||
mod_code_status = probe_kernel_write(mod_code_ip, mod_code_newcode,
|
||||
mod_code_status = copy_to_kernel_nofault(mod_code_ip, mod_code_newcode,
|
||||
MCOUNT_INSN_SIZE);
|
||||
|
||||
/* if we fail, then kill any new writers */
|
||||
|
|
@ -203,7 +203,7 @@ static int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
|
|||
*/
|
||||
|
||||
/* read the text we want to modify */
|
||||
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* Make sure it is what we expect it to be */
|
||||
|
|
@ -268,7 +268,7 @@ static int ftrace_mod(unsigned long ip, unsigned long old_addr,
|
|||
{
|
||||
unsigned char code[MCOUNT_INSN_SIZE];
|
||||
|
||||
if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(code, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
if (old_addr != __raw_readl((unsigned long *)code))
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ int is_valid_bugaddr(unsigned long addr)
|
|||
|
||||
if (addr < PAGE_OFFSET)
|
||||
return 0;
|
||||
if (probe_kernel_address((insn_size_t *)addr, opcode))
|
||||
if (get_kernel_nofault(opcode, (insn_size_t *)addr))
|
||||
return 0;
|
||||
if (opcode == TRAPA_BUG_OPCODE)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <os.h>
|
||||
|
||||
long probe_kernel_read(void *dst, const void *src, size_t size)
|
||||
bool copy_from_kernel_nofault_allowed(const void *src, size_t size)
|
||||
{
|
||||
void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE);
|
||||
|
||||
if ((unsigned long)src < PAGE_SIZE || size <= 0)
|
||||
return -EFAULT;
|
||||
|
||||
return false;
|
||||
if (os_mincore(psrc, size + src - psrc) <= 0)
|
||||
return -EFAULT;
|
||||
|
||||
return __probe_kernel_read(dst, src, size);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ config X86
|
|||
select ARCH_HAS_KCOV if X86_64
|
||||
select ARCH_HAS_MEM_ENCRYPT
|
||||
select ARCH_HAS_MEMBARRIER_SYNC_CORE
|
||||
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
|
||||
select ARCH_HAS_PMEM_API if X86_64
|
||||
select ARCH_HAS_PTE_DEVMAP if X86_64
|
||||
select ARCH_HAS_PTE_SPECIAL
|
||||
|
|
@ -96,6 +97,7 @@ config X86
|
|||
select ARCH_USE_QUEUED_RWLOCKS
|
||||
select ARCH_USE_QUEUED_SPINLOCKS
|
||||
select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
|
||||
select ARCH_WANT_DEFAULT_BPF_JIT if X86_64
|
||||
select ARCH_WANTS_DYNAMIC_TASK_STRUCT
|
||||
select ARCH_WANT_HUGE_PMD_SHARE if X86_64
|
||||
select ARCH_WANTS_THP_SWAP if X86_64
|
||||
|
|
|
|||
|
|
@ -288,6 +288,8 @@ CONFIG_KEYBOARD_GPIO=y
|
|||
# CONFIG_INPUT_MOUSE is not set
|
||||
CONFIG_INPUT_JOYSTICK=y
|
||||
CONFIG_JOYSTICK_XPAD=y
|
||||
CONFIG_JOYSTICK_XPAD_FF=y
|
||||
CONFIG_JOYSTICK_XPAD_LEDS=y
|
||||
CONFIG_INPUT_TOUCHSCREEN=y
|
||||
CONFIG_INPUT_MISC=y
|
||||
CONFIG_INPUT_UINPUT=y
|
||||
|
|
@ -344,6 +346,7 @@ CONFIG_HID_BATTERY_STRENGTH=y
|
|||
CONFIG_HIDRAW=y
|
||||
CONFIG_UHID=y
|
||||
CONFIG_HID_APPLE=y
|
||||
CONFIG_HID_BETOP_FF=y
|
||||
CONFIG_HID_PRODIKEYS=y
|
||||
CONFIG_HID_ELECOM=y
|
||||
CONFIG_HID_UCLOGIC=y
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ static int hv_cpu_init(unsigned int cpu)
|
|||
* not be stopped in the case of CPU offlining and the VM will hang.
|
||||
*/
|
||||
if (!*hvp) {
|
||||
*hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO,
|
||||
PAGE_KERNEL);
|
||||
*hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO);
|
||||
}
|
||||
|
||||
if (*hvp) {
|
||||
|
|
|
|||
|
|
@ -414,19 +414,19 @@ static inline void mds_idle_clear_cpu_buffers(void)
|
|||
* lfence
|
||||
* jmp spec_trap
|
||||
* do_rop:
|
||||
* mov %rax,(%rsp) for x86_64
|
||||
* mov %rcx,(%rsp) for x86_64
|
||||
* mov %edx,(%esp) for x86_32
|
||||
* retq
|
||||
*
|
||||
* Without retpolines configured:
|
||||
*
|
||||
* jmp *%rax for x86_64
|
||||
* jmp *%rcx for x86_64
|
||||
* jmp *%edx for x86_32
|
||||
*/
|
||||
#ifdef CONFIG_RETPOLINE
|
||||
# ifdef CONFIG_X86_64
|
||||
# define RETPOLINE_RAX_BPF_JIT_SIZE 17
|
||||
# define RETPOLINE_RAX_BPF_JIT() \
|
||||
# define RETPOLINE_RCX_BPF_JIT_SIZE 17
|
||||
# define RETPOLINE_RCX_BPF_JIT() \
|
||||
do { \
|
||||
EMIT1_off32(0xE8, 7); /* callq do_rop */ \
|
||||
/* spec_trap: */ \
|
||||
|
|
@ -434,7 +434,7 @@ do { \
|
|||
EMIT3(0x0F, 0xAE, 0xE8); /* lfence */ \
|
||||
EMIT2(0xEB, 0xF9); /* jmp spec_trap */ \
|
||||
/* do_rop: */ \
|
||||
EMIT4(0x48, 0x89, 0x04, 0x24); /* mov %rax,(%rsp) */ \
|
||||
EMIT4(0x48, 0x89, 0x0C, 0x24); /* mov %rcx,(%rsp) */ \
|
||||
EMIT1(0xC3); /* retq */ \
|
||||
} while (0)
|
||||
# else /* !CONFIG_X86_64 */
|
||||
|
|
@ -452,9 +452,9 @@ do { \
|
|||
# endif
|
||||
#else /* !CONFIG_RETPOLINE */
|
||||
# ifdef CONFIG_X86_64
|
||||
# define RETPOLINE_RAX_BPF_JIT_SIZE 2
|
||||
# define RETPOLINE_RAX_BPF_JIT() \
|
||||
EMIT2(0xFF, 0xE0); /* jmp *%rax */
|
||||
# define RETPOLINE_RCX_BPF_JIT_SIZE 2
|
||||
# define RETPOLINE_RCX_BPF_JIT() \
|
||||
EMIT2(0xFF, 0xE1); /* jmp *%rcx */
|
||||
# else /* !CONFIG_X86_64 */
|
||||
# define RETPOLINE_EDX_BPF_JIT() \
|
||||
EMIT2(0xFF, 0xE2) /* jmp *%edx */
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ static inline unsigned long *regs_get_kernel_stack_nth_addr(struct pt_regs *regs
|
|||
}
|
||||
|
||||
/* To avoid include hell, we can't include uaccess.h */
|
||||
extern long probe_kernel_read(void *dst, const void *src, size_t size);
|
||||
extern long copy_from_kernel_nofault(void *dst, const void *src, size_t size);
|
||||
|
||||
/**
|
||||
* regs_get_kernel_stack_nth() - get Nth entry of the stack
|
||||
|
|
@ -285,7 +285,7 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
|
|||
|
||||
addr = regs_get_kernel_stack_nth_addr(regs, n);
|
||||
if (addr) {
|
||||
ret = probe_kernel_read(&val, addr, sizeof(val));
|
||||
ret = copy_from_kernel_nofault(&val, addr, sizeof(val));
|
||||
if (!ret)
|
||||
return val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ void show_opcodes(struct pt_regs *regs, const char *loglvl)
|
|||
bad_ip = user_mode(regs) &&
|
||||
__chk_range_not_ok(prologue, OPCODE_BUFSIZE, TASK_SIZE_MAX);
|
||||
|
||||
if (bad_ip || probe_kernel_read(opcodes, (u8 *)prologue,
|
||||
if (bad_ip || copy_from_kernel_nofault(opcodes, (u8 *)prologue,
|
||||
OPCODE_BUFSIZE)) {
|
||||
printk("%sCode: Bad RIP value.\n", loglvl);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
|
|||
*/
|
||||
|
||||
/* read the text we want to modify */
|
||||
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* Make sure it is what we expect it to be */
|
||||
|
|
@ -341,7 +341,7 @@ static int add_break(unsigned long ip, const char *old)
|
|||
unsigned char replaced[MCOUNT_INSN_SIZE];
|
||||
unsigned char brk = BREAKPOINT_INSTRUCTION;
|
||||
|
||||
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
ftrace_expected = old;
|
||||
|
|
@ -415,7 +415,7 @@ static int remove_breakpoint(struct dyn_ftrace *rec)
|
|||
unsigned long ip = rec->ip;
|
||||
|
||||
/* If we fail the read, just give up */
|
||||
if (probe_kernel_read(ins, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(ins, (void *)ip, MCOUNT_INSN_SIZE))
|
||||
return -EFAULT;
|
||||
|
||||
/* If this does not have a breakpoint, we are done */
|
||||
|
|
@ -784,7 +784,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
|
|||
npages = DIV_ROUND_UP(*tramp_size, PAGE_SIZE);
|
||||
|
||||
/* Copy ftrace_caller onto the trampoline memory */
|
||||
ret = probe_kernel_read(trampoline, (void *)start_offset, size);
|
||||
ret = copy_from_kernel_nofault(trampoline, (void *)start_offset, size);
|
||||
if (WARN_ON(ret < 0))
|
||||
goto fail;
|
||||
|
||||
|
|
@ -792,7 +792,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
|
|||
|
||||
/* The trampoline ends with ret(q) */
|
||||
retq = (unsigned long)ftrace_stub;
|
||||
ret = probe_kernel_read(ip, (void *)retq, RET_SIZE);
|
||||
ret = copy_from_kernel_nofault(ip, (void *)retq, RET_SIZE);
|
||||
if (WARN_ON(ret < 0))
|
||||
goto fail;
|
||||
|
||||
|
|
@ -904,7 +904,7 @@ static void *addr_from_call(void *ptr)
|
|||
union ftrace_code_union calc;
|
||||
int ret;
|
||||
|
||||
ret = probe_kernel_read(&calc, ptr, MCOUNT_INSN_SIZE);
|
||||
ret = copy_from_kernel_nofault(&calc, ptr, MCOUNT_INSN_SIZE);
|
||||
if (WARN_ON_ONCE(ret < 0))
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ static bool __read_mostly sched_itmt_capable;
|
|||
unsigned int __read_mostly sysctl_sched_itmt_enabled;
|
||||
|
||||
static int sched_itmt_update_handler(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
unsigned int old_sysctl;
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -732,11 +732,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
|
|||
int err;
|
||||
|
||||
bpt->type = BP_BREAKPOINT;
|
||||
err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
|
||||
err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr,
|
||||
BREAK_INSTR_SIZE);
|
||||
if (err)
|
||||
return err;
|
||||
err = probe_kernel_write((char *)bpt->bpt_addr,
|
||||
err = copy_to_kernel_nofault((char *)bpt->bpt_addr,
|
||||
arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
|
||||
if (!err)
|
||||
return err;
|
||||
|
|
@ -768,7 +768,7 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
|
|||
return 0;
|
||||
|
||||
knl_write:
|
||||
return probe_kernel_write((char *)bpt->bpt_addr,
|
||||
return copy_to_kernel_nofault((char *)bpt->bpt_addr,
|
||||
(char *)bpt->saved_instr, BREAK_INSTR_SIZE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
|
|||
* Fortunately, we know that the original code is the ideal 5-byte
|
||||
* long NOP.
|
||||
*/
|
||||
if (probe_kernel_read(buf, (void *)addr,
|
||||
if (copy_from_kernel_nofault(buf, (void *)addr,
|
||||
MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
|
||||
return 0UL;
|
||||
|
||||
|
|
@ -352,7 +352,8 @@ int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn)
|
|||
return 0;
|
||||
|
||||
/* This can access kernel text if given address is not recovered */
|
||||
if (probe_kernel_read(dest, (void *)recovered_insn, MAX_INSN_SIZE))
|
||||
if (copy_from_kernel_nofault(dest, (void *)recovered_insn,
|
||||
MAX_INSN_SIZE))
|
||||
return 0;
|
||||
|
||||
kernel_insn_init(insn, dest, MAX_INSN_SIZE);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ found:
|
|||
* overwritten by jump destination address. In this case, original
|
||||
* bytes must be recovered from op->optinsn.copied_insn buffer.
|
||||
*/
|
||||
if (probe_kernel_read(buf, (void *)addr,
|
||||
if (copy_from_kernel_nofault(buf, (void *)addr,
|
||||
MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
|
||||
return 0UL;
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ static bool probe_list(struct pci_dev *pdev, unsigned short vendor,
|
|||
unsigned short device;
|
||||
|
||||
do {
|
||||
if (probe_kernel_address(rom_list, device) != 0)
|
||||
if (get_kernel_nofault(device, rom_list) != 0)
|
||||
device = 0;
|
||||
|
||||
if (device && match_id(pdev, vendor, device))
|
||||
|
|
@ -125,13 +125,13 @@ static struct resource *find_oprom(struct pci_dev *pdev)
|
|||
break;
|
||||
|
||||
rom = isa_bus_to_virt(res->start);
|
||||
if (probe_kernel_address(rom + 0x18, offset) != 0)
|
||||
if (get_kernel_nofault(offset, rom + 0x18) != 0)
|
||||
continue;
|
||||
|
||||
if (probe_kernel_address(rom + offset + 0x4, vendor) != 0)
|
||||
if (get_kernel_nofault(vendor, rom + offset + 0x4) != 0)
|
||||
continue;
|
||||
|
||||
if (probe_kernel_address(rom + offset + 0x6, device) != 0)
|
||||
if (get_kernel_nofault(device, rom + offset + 0x6) != 0)
|
||||
continue;
|
||||
|
||||
if (match_id(pdev, vendor, device)) {
|
||||
|
|
@ -139,8 +139,8 @@ static struct resource *find_oprom(struct pci_dev *pdev)
|
|||
break;
|
||||
}
|
||||
|
||||
if (probe_kernel_address(rom + offset + 0x8, list) == 0 &&
|
||||
probe_kernel_address(rom + offset + 0xc, rev) == 0 &&
|
||||
if (get_kernel_nofault(list, rom + offset + 0x8) == 0 &&
|
||||
get_kernel_nofault(rev, rom + offset + 0xc) == 0 &&
|
||||
rev >= 3 && list &&
|
||||
probe_list(pdev, vendor, rom + offset + list)) {
|
||||
oprom = res;
|
||||
|
|
@ -183,14 +183,14 @@ static int __init romsignature(const unsigned char *rom)
|
|||
const unsigned short * const ptr = (const unsigned short *)rom;
|
||||
unsigned short sig;
|
||||
|
||||
return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
|
||||
return get_kernel_nofault(sig, ptr) == 0 && sig == ROMSIGNATURE;
|
||||
}
|
||||
|
||||
static int __init romchecksum(const unsigned char *rom, unsigned long length)
|
||||
{
|
||||
unsigned char sum, c;
|
||||
|
||||
for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
|
||||
for (sum = 0; length && get_kernel_nofault(c, rom++) == 0; length--)
|
||||
sum += c;
|
||||
return !length && !sum;
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ void __init probe_roms(void)
|
|||
|
||||
video_rom_resource.start = start;
|
||||
|
||||
if (probe_kernel_address(rom + 2, c) != 0)
|
||||
if (get_kernel_nofault(c, rom + 2) != 0)
|
||||
continue;
|
||||
|
||||
/* 0 < length <= 0x7f * 512, historically */
|
||||
|
|
@ -249,7 +249,7 @@ void __init probe_roms(void)
|
|||
if (!romsignature(rom))
|
||||
continue;
|
||||
|
||||
if (probe_kernel_address(rom + 2, c) != 0)
|
||||
if (get_kernel_nofault(c, rom + 2) != 0)
|
||||
continue;
|
||||
|
||||
/* 0 < length <= 0x7f * 512, historically */
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ int is_valid_bugaddr(unsigned long addr)
|
|||
if (addr < TASK_SIZE_MAX)
|
||||
return 0;
|
||||
|
||||
if (probe_kernel_address((unsigned short *)addr, ud))
|
||||
if (get_kernel_nofault(ud, (unsigned short *)addr))
|
||||
return 0;
|
||||
|
||||
return ud == INSN_UD0 || ud == INSN_UD2;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ CFLAGS_REMOVE_mem_encrypt_identity.o = -pg
|
|||
endif
|
||||
|
||||
obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
|
||||
pat.o pgtable.o physaddr.o setup_nx.o tlb.o cpu_entry_area.o
|
||||
pat.o pgtable.o physaddr.o setup_nx.o tlb.o cpu_entry_area.o maccess.o
|
||||
|
||||
# Make sure __phys_addr has no stackprotector
|
||||
nostackp := $(call cc-option, -fno-stack-protector)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
|
|||
return !instr_lo || (instr_lo>>1) == 1;
|
||||
case 0x00:
|
||||
/* Prefetch instruction is 0x0F0D or 0x0F18 */
|
||||
if (probe_kernel_address(instr, opcode))
|
||||
if (get_kernel_nofault(opcode, instr))
|
||||
return 0;
|
||||
|
||||
*prefetch = (instr_lo == 0xF) &&
|
||||
|
|
@ -131,7 +131,7 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
|
|||
while (instr < max_instr) {
|
||||
unsigned char opcode;
|
||||
|
||||
if (probe_kernel_address(instr, opcode))
|
||||
if (get_kernel_nofault(opcode, instr))
|
||||
break;
|
||||
|
||||
instr++;
|
||||
|
|
@ -440,7 +440,7 @@ static int bad_address(void *p)
|
|||
{
|
||||
unsigned long dummy;
|
||||
|
||||
return probe_kernel_address((unsigned long *)p, dummy);
|
||||
return get_kernel_nofault(dummy, (unsigned long *)p);
|
||||
}
|
||||
|
||||
static void dump_pagetable(unsigned long address)
|
||||
|
|
@ -589,7 +589,7 @@ static void show_ldttss(const struct desc_ptr *gdt, const char *name, u16 index)
|
|||
return;
|
||||
}
|
||||
|
||||
if (probe_kernel_read(&desc, (void *)(gdt->address + offset),
|
||||
if (copy_from_kernel_nofault(&desc, (void *)(gdt->address + offset),
|
||||
sizeof(struct ldttss_desc))) {
|
||||
pr_alert("%s: 0x%hx -- GDT entry is not readable\n",
|
||||
name, index);
|
||||
|
|
|
|||
|
|
@ -752,7 +752,7 @@ static void __init test_wp_bit(void)
|
|||
|
||||
__set_fixmap(FIX_WP_TEST, __pa_symbol(empty_zero_page), PAGE_KERNEL_RO);
|
||||
|
||||
if (probe_kernel_write((char *)fix_to_virt(FIX_WP_TEST), &z, 1)) {
|
||||
if (copy_to_kernel_nofault((char *)fix_to_virt(FIX_WP_TEST), &z, 1)) {
|
||||
clear_fixmap(FIX_WP_TEST);
|
||||
printk(KERN_CONT "Ok.\n");
|
||||
return;
|
||||
|
|
|
|||
29
arch/x86/mm/maccess.c
Normal file
29
arch/x86/mm/maccess.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
static __always_inline u64 canonical_address(u64 vaddr, u8 vaddr_bits)
|
||||
{
|
||||
return ((s64)vaddr << (64 - vaddr_bits)) >> (64 - vaddr_bits);
|
||||
}
|
||||
|
||||
bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
|
||||
{
|
||||
unsigned long vaddr = (unsigned long)unsafe_src;
|
||||
|
||||
/*
|
||||
* Range covering the highest possible canonical userspace address
|
||||
* as well as non-canonical address range. For the canonical range
|
||||
* we also need to include the userspace guard page.
|
||||
*/
|
||||
return vaddr >= TASK_SIZE_MAX + PAGE_SIZE &&
|
||||
canonical_address(vaddr, boot_cpu_data.x86_virt_bits) == vaddr;
|
||||
}
|
||||
#else
|
||||
bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
|
||||
{
|
||||
return (unsigned long)unsafe_src >= TASK_SIZE_MAX;
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -302,7 +302,7 @@ static const struct pci_raw_ops *__init pci_find_bios(void)
|
|||
check <= (union bios32 *) __va(0xffff0);
|
||||
++check) {
|
||||
long sig;
|
||||
if (probe_kernel_address(&check->fields.signature, sig))
|
||||
if (get_kernel_nofault(sig, &check->fields.signature))
|
||||
continue;
|
||||
|
||||
if (check->fields.signature != BIOS32_SIGNATURE)
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ static void set_aliased_prot(void *v, pgprot_t prot)
|
|||
|
||||
preempt_disable();
|
||||
|
||||
probe_kernel_read(&dummy, v, 1);
|
||||
copy_from_kernel_nofault(&dummy, v, 1);
|
||||
|
||||
if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))
|
||||
BUG();
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ EXPORT_SYMBOL_GPL(sha1_zero_message_hash);
|
|||
static void sha1_generic_block_fn(struct sha1_state *sst, u8 const *src,
|
||||
int blocks)
|
||||
{
|
||||
u32 temp[SHA_WORKSPACE_WORDS];
|
||||
u32 temp[SHA1_WORKSPACE_WORDS];
|
||||
|
||||
while (blocks--) {
|
||||
sha_transform(sst->state, src, temp);
|
||||
sha1_transform(sst->state, src, temp);
|
||||
src += SHA1_BLOCK_SIZE;
|
||||
}
|
||||
memzero_explicit(temp, sizeof(temp));
|
||||
|
|
|
|||
|
|
@ -396,9 +396,7 @@ static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want)
|
|||
bytes = sizeof(struct page *)*want;
|
||||
new_pages = kzalloc(bytes, GFP_NOIO | __GFP_NOWARN);
|
||||
if (!new_pages) {
|
||||
new_pages = __vmalloc(bytes,
|
||||
GFP_NOIO | __GFP_ZERO,
|
||||
PAGE_KERNEL);
|
||||
new_pages = __vmalloc(bytes, GFP_NOIO | __GFP_ZERO);
|
||||
if (!new_pages)
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3608,7 +3608,7 @@ static void cdrom_update_settings(void)
|
|||
}
|
||||
|
||||
static int cdrom_sysctl_handler(struct ctl_table *ctl, int write,
|
||||
void __user *buffer, size_t *lenp, loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
|
|||
if (!ptr)
|
||||
goto failed;
|
||||
|
||||
probe = probe_kernel_read(bounce, ptr, sz);
|
||||
probe = copy_from_kernel_nofault(bounce, ptr, sz);
|
||||
unxlate_dev_mem_ptr(p, ptr);
|
||||
if (probe)
|
||||
goto failed;
|
||||
|
|
|
|||
|
|
@ -1446,7 +1446,7 @@ static u8 sysctl_bootid[UUID_SIZE];
|
|||
* UUID. The difference is in whether table->data is NULL; if it is,
|
||||
* then a new UUID is generated and returned to the user.
|
||||
*/
|
||||
static int proc_do_uuid(struct ctl_table *table, int write, void __user *buf,
|
||||
static int proc_do_uuid(struct ctl_table *table, int write, void *buf,
|
||||
size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
u8 tmp_uuid[UUID_SIZE], *uuid;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ int __init dio_find(int deviceid)
|
|||
else
|
||||
va = ioremap(pa, PAGE_SIZE);
|
||||
|
||||
if (probe_kernel_read(&i, (unsigned char *)va + DIO_IDOFF, 1)) {
|
||||
if (copy_from_kernel_nofault(&i,
|
||||
(unsigned char *)va + DIO_IDOFF, 1)) {
|
||||
if (scode >= DIOII_SCBASE)
|
||||
iounmap(va);
|
||||
continue; /* no board present at that select code */
|
||||
|
|
@ -214,7 +215,8 @@ static int __init dio_init(void)
|
|||
else
|
||||
va = ioremap(pa, PAGE_SIZE);
|
||||
|
||||
if (probe_kernel_read(&i, (unsigned char *)va + DIO_IDOFF, 1)) {
|
||||
if (copy_from_kernel_nofault(&i,
|
||||
(unsigned char *)va + DIO_IDOFF, 1)) {
|
||||
if (scode >= DIOII_SCBASE)
|
||||
iounmap(va);
|
||||
continue; /* no board present at that select code */
|
||||
|
|
|
|||
|
|
@ -159,8 +159,8 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit)
|
|||
file_size += sizeof(*iter.hdr) * n_obj;
|
||||
|
||||
/* Allocate the file in vmalloc memory, it's likely to be big */
|
||||
iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
|
||||
PAGE_KERNEL);
|
||||
iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN |
|
||||
__GFP_NORETRY);
|
||||
if (!iter.start) {
|
||||
mutex_unlock(&submit->mmu_context->lock);
|
||||
dev_warn(gpu->dev, "failed to allocate devcoredump file\n");
|
||||
|
|
|
|||
|
|
@ -1021,7 +1021,7 @@ static int __init hp_sdc_register(void)
|
|||
hp_sdc.base_io = (unsigned long) 0xf0428000;
|
||||
hp_sdc.data_io = (unsigned long) hp_sdc.base_io + 1;
|
||||
hp_sdc.status_io = (unsigned long) hp_sdc.base_io + 3;
|
||||
if (!probe_kernel_read(&i, (unsigned char *)hp_sdc.data_io, 1))
|
||||
if (!copy_from_kernel_nofault(&i, (unsigned char *)hp_sdc.data_io, 1))
|
||||
hp_sdc.dev = (void *)1;
|
||||
hp_sdc.dev_err = hp_sdc_init();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -145,9 +145,8 @@ static int pblk_l2p_init(struct pblk *pblk, bool factory_init)
|
|||
int ret = 0;
|
||||
|
||||
map_size = pblk_trans_map_size(pblk);
|
||||
pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
|
||||
| __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
|
||||
PAGE_KERNEL);
|
||||
pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN |
|
||||
__GFP_RETRY_MAYFAIL | __GFP_HIGHMEM);
|
||||
if (!pblk->trans_map) {
|
||||
pblk_err(pblk, "failed to allocate L2P (need %zu of memory)\n",
|
||||
map_size);
|
||||
|
|
|
|||
|
|
@ -183,8 +183,7 @@ static void mac_hid_stop_emulation(void)
|
|||
}
|
||||
|
||||
static int mac_hid_toggle_emumouse(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
loff_t *ppos)
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int *valp = table->data;
|
||||
int old_val = *valp;
|
||||
|
|
|
|||
|
|
@ -400,13 +400,13 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
|
|||
*/
|
||||
if (gfp_mask & __GFP_NORETRY) {
|
||||
unsigned noio_flag = memalloc_noio_save();
|
||||
void *ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
|
||||
void *ptr = __vmalloc(c->block_size, gfp_mask);
|
||||
|
||||
memalloc_noio_restore(noio_flag);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
|
||||
return __vmalloc(c->block_size, gfp_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ lirc_mode2_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
|
|||
case BPF_FUNC_get_prandom_u32:
|
||||
return &bpf_get_prandom_u32_proto;
|
||||
case BPF_FUNC_trace_printk:
|
||||
if (capable(CAP_SYS_ADMIN))
|
||||
if (perfmon_capable())
|
||||
return bpf_get_trace_printk_proto();
|
||||
/* fall through */
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -829,7 +829,7 @@ static void run_plant_and_detach_test(int is_early)
|
|||
char before[BREAK_INSTR_SIZE];
|
||||
char after[BREAK_INSTR_SIZE];
|
||||
|
||||
probe_kernel_read(before, (char *)kgdbts_break_test,
|
||||
copy_from_kernel_nofault(before, (char *)kgdbts_break_test,
|
||||
BREAK_INSTR_SIZE);
|
||||
init_simple_test();
|
||||
ts.tst = plant_and_detach_test;
|
||||
|
|
@ -837,8 +837,8 @@ static void run_plant_and_detach_test(int is_early)
|
|||
/* Activate test with initial breakpoint */
|
||||
if (!is_early)
|
||||
kgdb_breakpoint();
|
||||
probe_kernel_read(after, (char *)kgdbts_break_test,
|
||||
BREAK_INSTR_SIZE);
|
||||
copy_from_kernel_nofault(after, (char *)kgdbts_break_test,
|
||||
BREAK_INSTR_SIZE);
|
||||
if (memcmp(before, after, BREAK_INSTR_SIZE)) {
|
||||
printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
|
||||
panic("kgdb memory corruption");
|
||||
|
|
|
|||
|
|
@ -1308,7 +1308,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
|
|||
if (!ubi_dbg_chk_io(ubi))
|
||||
return 0;
|
||||
|
||||
buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
|
||||
buf1 = __vmalloc(len, GFP_NOFS);
|
||||
if (!buf1) {
|
||||
ubi_err(ubi, "cannot allocate memory to check writes");
|
||||
return 0;
|
||||
|
|
@ -1372,7 +1372,7 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
|
|||
if (!ubi_dbg_chk_io(ubi))
|
||||
return 0;
|
||||
|
||||
buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
|
||||
buf = __vmalloc(len, GFP_NOFS);
|
||||
if (!buf) {
|
||||
ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -3213,13 +3213,8 @@ static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr)
|
|||
bnxt_init_rxbd_pages(ring, type);
|
||||
|
||||
if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) {
|
||||
rxr->xdp_prog = bpf_prog_add(bp->xdp_prog, 1);
|
||||
if (IS_ERR(rxr->xdp_prog)) {
|
||||
int rc = PTR_ERR(rxr->xdp_prog);
|
||||
|
||||
rxr->xdp_prog = NULL;
|
||||
return rc;
|
||||
}
|
||||
bpf_prog_add(bp->xdp_prog, 1);
|
||||
rxr->xdp_prog = bp->xdp_prog;
|
||||
}
|
||||
prod = rxr->rx_prod;
|
||||
for (i = 0; i < bp->rx_ring_size; i++) {
|
||||
|
|
|
|||
|
|
@ -1876,13 +1876,8 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog)
|
|||
|
||||
if (nic->xdp_prog) {
|
||||
/* Attach BPF program */
|
||||
nic->xdp_prog = bpf_prog_add(nic->xdp_prog, nic->rx_queues - 1);
|
||||
if (!IS_ERR(nic->xdp_prog)) {
|
||||
bpf_attached = true;
|
||||
} else {
|
||||
ret = PTR_ERR(nic->xdp_prog);
|
||||
nic->xdp_prog = NULL;
|
||||
}
|
||||
bpf_prog_add(nic->xdp_prog, nic->rx_queues - 1);
|
||||
bpf_attached = true;
|
||||
}
|
||||
|
||||
/* Calculate Tx queues needed for XDP and network stack */
|
||||
|
|
|
|||
|
|
@ -1772,11 +1772,8 @@ static int setup_xdp(struct net_device *dev, struct bpf_prog *prog)
|
|||
if (prog && !xdp_mtu_valid(priv, dev->mtu))
|
||||
return -EINVAL;
|
||||
|
||||
if (prog) {
|
||||
prog = bpf_prog_add(prog, priv->num_channels);
|
||||
if (IS_ERR(prog))
|
||||
return PTR_ERR(prog);
|
||||
}
|
||||
if (prog)
|
||||
bpf_prog_add(prog, priv->num_channels);
|
||||
|
||||
up = netif_running(dev);
|
||||
need_update = (!!priv->xdp_prog != !!prog);
|
||||
|
|
|
|||
|
|
@ -2194,7 +2194,7 @@ static int i40e_xmit_xdp_ring(struct xdp_frame *xdpf,
|
|||
|
||||
int i40e_xmit_xdp_tx_ring(struct xdp_buff *xdp, struct i40e_ring *xdp_ring)
|
||||
{
|
||||
struct xdp_frame *xdpf = convert_to_xdp_frame(xdp);
|
||||
struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp);
|
||||
|
||||
if (unlikely(!xdpf))
|
||||
return I40E_XDP_CONSUMED;
|
||||
|
|
|
|||
|
|
@ -2225,7 +2225,7 @@ static struct sk_buff *ixgbe_run_xdp(struct ixgbe_adapter *adapter,
|
|||
case XDP_PASS:
|
||||
break;
|
||||
case XDP_TX:
|
||||
xdpf = convert_to_xdp_frame(xdp);
|
||||
xdpf = xdp_convert_buff_to_frame(xdp);
|
||||
if (unlikely(!xdpf)) {
|
||||
result = IXGBE_XDP_CONSUMED;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
|
|||
case XDP_PASS:
|
||||
break;
|
||||
case XDP_TX:
|
||||
xdpf = convert_to_xdp_frame(xdp);
|
||||
xdpf = xdp_convert_buff_to_frame(xdp);
|
||||
if (unlikely(!xdpf)) {
|
||||
result = IXGBE_XDP_CONSUMED;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -2307,11 +2307,7 @@ int mlx4_en_try_alloc_resources(struct mlx4_en_priv *priv,
|
|||
lockdep_is_held(&priv->mdev->state_lock));
|
||||
|
||||
if (xdp_prog && carry_xdp_prog) {
|
||||
xdp_prog = bpf_prog_add(xdp_prog, tmp->rx_ring_num);
|
||||
if (IS_ERR(xdp_prog)) {
|
||||
mlx4_en_free_resources(tmp);
|
||||
return PTR_ERR(xdp_prog);
|
||||
}
|
||||
bpf_prog_add(xdp_prog, tmp->rx_ring_num);
|
||||
for (i = 0; i < tmp->rx_ring_num; i++)
|
||||
rcu_assign_pointer(tmp->rx_ring[i]->xdp_prog,
|
||||
xdp_prog);
|
||||
|
|
@ -2805,11 +2801,9 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
|
|||
* program for a new one.
|
||||
*/
|
||||
if (priv->tx_ring_num[TX_XDP] == xdp_ring_num) {
|
||||
if (prog) {
|
||||
prog = bpf_prog_add(prog, priv->rx_ring_num - 1);
|
||||
if (IS_ERR(prog))
|
||||
return PTR_ERR(prog);
|
||||
}
|
||||
if (prog)
|
||||
bpf_prog_add(prog, priv->rx_ring_num - 1);
|
||||
|
||||
mutex_lock(&mdev->state_lock);
|
||||
for (i = 0; i < priv->rx_ring_num; i++) {
|
||||
old_prog = rcu_dereference_protected(
|
||||
|
|
@ -2830,13 +2824,8 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
|
|||
if (!tmp)
|
||||
return -ENOMEM;
|
||||
|
||||
if (prog) {
|
||||
prog = bpf_prog_add(prog, priv->rx_ring_num - 1);
|
||||
if (IS_ERR(prog)) {
|
||||
err = PTR_ERR(prog);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (prog)
|
||||
bpf_prog_add(prog, priv->rx_ring_num - 1);
|
||||
|
||||
mutex_lock(&mdev->state_lock);
|
||||
memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
|
||||
|
|
@ -2886,7 +2875,6 @@ static int mlx4_xdp_set(struct net_device *dev, struct bpf_prog *prog)
|
|||
|
||||
unlock_out:
|
||||
mutex_unlock(&mdev->state_lock);
|
||||
out:
|
||||
kfree(tmp);
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq,
|
|||
struct xdp_frame *xdpf;
|
||||
dma_addr_t dma_addr;
|
||||
|
||||
xdpf = convert_to_xdp_frame(xdp);
|
||||
xdpf = xdp_convert_buff_to_frame(xdp);
|
||||
if (unlikely(!xdpf))
|
||||
return false;
|
||||
|
||||
|
|
@ -97,10 +97,10 @@ mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq,
|
|||
xdpi.frame.xdpf = xdpf;
|
||||
xdpi.frame.dma_addr = dma_addr;
|
||||
} else {
|
||||
/* Driver assumes that convert_to_xdp_frame returns an xdp_frame
|
||||
* that points to the same memory region as the original
|
||||
* xdp_buff. It allows to map the memory only once and to use
|
||||
* the DMA_BIDIRECTIONAL mode.
|
||||
/* Driver assumes that xdp_convert_buff_to_frame returns
|
||||
* an xdp_frame that points to the same memory region as
|
||||
* the original xdp_buff. It allows to map the memory only
|
||||
* once and to use the DMA_BIDIRECTIONAL mode.
|
||||
*/
|
||||
|
||||
xdpi.mode = MLX5E_XDP_XMIT_MODE_PAGE;
|
||||
|
|
|
|||
|
|
@ -448,12 +448,9 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
|
|||
rq->stats = &c->priv->channel_stats[c->ix].rq;
|
||||
INIT_WORK(&rq->recover_work, mlx5e_rq_err_cqe_work);
|
||||
|
||||
rq->xdp_prog = params->xdp_prog ? bpf_prog_inc(params->xdp_prog) : NULL;
|
||||
if (IS_ERR(rq->xdp_prog)) {
|
||||
err = PTR_ERR(rq->xdp_prog);
|
||||
rq->xdp_prog = NULL;
|
||||
goto err_rq_wq_destroy;
|
||||
}
|
||||
if (params->xdp_prog)
|
||||
bpf_prog_inc(params->xdp_prog);
|
||||
rq->xdp_prog = params->xdp_prog;
|
||||
|
||||
rq_xdp_ix = rq->ix;
|
||||
if (xsk)
|
||||
|
|
@ -4567,16 +4564,11 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
|
|||
/* no need for full reset when exchanging programs */
|
||||
reset = (!priv->channels.params.xdp_prog || !prog);
|
||||
|
||||
if (was_opened && !reset) {
|
||||
if (was_opened && !reset)
|
||||
/* num_channels is invariant here, so we can take the
|
||||
* batched reference right upfront.
|
||||
*/
|
||||
prog = bpf_prog_add(prog, priv->channels.num);
|
||||
if (IS_ERR(prog)) {
|
||||
err = PTR_ERR(prog);
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
bpf_prog_add(prog, priv->channels.num);
|
||||
|
||||
if (was_opened && reset) {
|
||||
struct mlx5e_channels new_channels = {};
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ nfp_map_ptr_record(struct nfp_app_bpf *bpf, struct nfp_prog *nfp_prog,
|
|||
/* Grab a single ref to the map for our record. The prog destroy ndo
|
||||
* happens after free_used_maps().
|
||||
*/
|
||||
map = bpf_map_inc(map, false);
|
||||
if (IS_ERR(map))
|
||||
return PTR_ERR(map);
|
||||
bpf_map_inc(map);
|
||||
|
||||
record = kmalloc(sizeof(*record), GFP_KERNEL);
|
||||
if (!record) {
|
||||
|
|
@ -113,7 +111,9 @@ static int
|
|||
nfp_map_ptrs_record(struct nfp_app_bpf *bpf, struct nfp_prog *nfp_prog,
|
||||
struct bpf_prog *prog)
|
||||
{
|
||||
int i, cnt, err;
|
||||
int i, cnt, err = 0;
|
||||
|
||||
mutex_lock(&prog->aux->used_maps_mutex);
|
||||
|
||||
/* Quickly count the maps we will have to remember */
|
||||
cnt = 0;
|
||||
|
|
@ -121,13 +121,15 @@ nfp_map_ptrs_record(struct nfp_app_bpf *bpf, struct nfp_prog *nfp_prog,
|
|||
if (bpf_map_offload_neutral(prog->aux->used_maps[i]))
|
||||
cnt++;
|
||||
if (!cnt)
|
||||
return 0;
|
||||
goto out;
|
||||
|
||||
nfp_prog->map_records = kmalloc_array(cnt,
|
||||
sizeof(nfp_prog->map_records[0]),
|
||||
GFP_KERNEL);
|
||||
if (!nfp_prog->map_records)
|
||||
return -ENOMEM;
|
||||
if (!nfp_prog->map_records) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < prog->aux->used_map_cnt; i++)
|
||||
if (bpf_map_offload_neutral(prog->aux->used_maps[i])) {
|
||||
|
|
@ -135,12 +137,14 @@ nfp_map_ptrs_record(struct nfp_app_bpf *bpf, struct nfp_prog *nfp_prog,
|
|||
prog->aux->used_maps[i]);
|
||||
if (err) {
|
||||
nfp_map_ptrs_forget(bpf, nfp_prog);
|
||||
return err;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
WARN_ON(cnt != nfp_prog->map_records_cnt);
|
||||
|
||||
return 0;
|
||||
out:
|
||||
mutex_unlock(&prog->aux->used_maps_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -2124,12 +2124,8 @@ static int qede_start_queues(struct qede_dev *edev, bool clear_stats)
|
|||
if (rc)
|
||||
goto out;
|
||||
|
||||
fp->rxq->xdp_prog = bpf_prog_add(edev->xdp_prog, 1);
|
||||
if (IS_ERR(fp->rxq->xdp_prog)) {
|
||||
rc = PTR_ERR(fp->rxq->xdp_prog);
|
||||
fp->rxq->xdp_prog = NULL;
|
||||
goto out;
|
||||
}
|
||||
bpf_prog_add(edev->xdp_prog, 1);
|
||||
fp->rxq->xdp_prog = edev->xdp_prog;
|
||||
}
|
||||
|
||||
if (fp->type & QEDE_FASTPATH_TX) {
|
||||
|
|
|
|||
|
|
@ -867,7 +867,7 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
|
|||
static u32 netsec_xdp_xmit_back(struct netsec_priv *priv, struct xdp_buff *xdp)
|
||||
{
|
||||
struct netsec_desc_ring *tx_ring = &priv->desc_ring[NETSEC_RING_TX];
|
||||
struct xdp_frame *xdpf = convert_to_xdp_frame(xdp);
|
||||
struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp);
|
||||
u32 ret;
|
||||
|
||||
if (unlikely(!xdpf))
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue