summaryrefslogtreecommitdiff
path: root/arch/x86/entry/common.c
diff options
context:
space:
mode:
authorSrinivasarao P <spathi@codeaurora.org>2018-12-03 11:28:33 +0530
committerSrinivasarao P <spathi@codeaurora.org>2018-12-03 11:29:54 +0530
commitd8cd72b9e7afc44098b29c1ece1fb5247269cc21 (patch)
treeaedd34cba720ea4ee3fef766c573505a79faa09a /arch/x86/entry/common.c
parent0a858409d5cd7283b8720d989bd2dba3f9353a6c (diff)
parent4c4bedf5b3fdd6bacb84222d579eb13706588a34 (diff)
Merge android-4.4.166 (4c4bedf) into msm-4.4
* refs/heads/tmp-4c4bedf Linux 4.4.166 drm/ast: Remove existing framebuffers before loading driver s390/mm: Check for valid vma before zapping in gmap_discard namei: allow restricted O_CREAT of FIFOs and regular files sched/core: Allow __sched_setscheduler() in interrupts when PI is not used btrfs: Ensure btrfs_trim_fs can trim the whole filesystem usb: xhci: fix uninitialized completion when USB3 port got wrong status tty: wipe buffer if not echoing data tty: wipe buffer. iwlwifi: mvm: fix regulatory domain update when the firmware starts scsi: qla2xxx: do not queue commands when unloading scsi: ufshcd: release resources if probe fails scsi: ufs: fix race between clock gating and devfreq scaling work scsi: ufshcd: Fix race between clk scaling and ungate work scsi: ufs: fix bugs related to null pointer access and array size netfilter: nf_tables: fix oops when inserting an element into a verdict map mwifiex: fix p2p device doesn't find in scan problem mwifiex: Fix NULL pointer dereference in skb_dequeue() cw1200: Don't leak memory if krealloc failes Input: xpad - add support for Xbox1 PDP Camo series gamepad Input: xpad - fix GPD Win 2 controller name Input: xpad - add GPD Win 2 Controller USB IDs Input: xpad - avoid using __set_bit() for capabilities Input: xpad - fix some coding style issues Input: xpad - add PDP device id 0x02a4 Input: xpad - add support for PDP Xbox One controllers Input: xpad - validate USB endpoint type during probe Input: xpad - fix PowerA init quirk for some gamepad models Input: xpad - constify usb_device_id Input: xpad - sync supported devices with XBCD Input: xpad - sync supported devices with 360Controller Input: xpad - add USB IDs for Mad Catz Brawlstick and Razer Sabertooth Input: xpad - sync supported devices with xboxdrv Input: xpad - sort supported devices by USB ID Input: xpad - support some quirky Xbox One pads Input: xpad - restore LED state after device resume Input: xpad - fix stuck mode button on Xbox One S pad Input: xpad - don't depend on endpoint order Input: xpad - simplify error condition in init_output Input: xpad - move reporting xbox one home button to common function Input: xpad - correctly sort vendor id's Input: xpad - fix Xbox One rumble stopping after 2.5 secs Input: xpad - add product ID for Xbox One S pad Input: xpad - power off wireless 360 controllers on suspend Input: xpad - fix rumble on Xbox One controllers with 2015 firmware Input: xpad - xbox one elite controller support Input: xpad - add more third-party controllers Input: xpad - prevent spurious input from wired Xbox 360 controllers Input: xpad - add Mad Catz FightStick TE 2 VID/PID Input: xpad - remove unused function Input: xpad - correct xbox one pad device name Input: xpad - use LED API when identifying wireless controllers Input: xpad - workaround dead irq_out after suspend/ resume Input: xpad - update Xbox One Force Feedback Support Input: xpad - handle "present" and "gone" correctly Input: xpad - remove spurious events of wireless xpad 360 controller ath10k: fix kernel panic due to race in accessing arvif list arm64: remove no-op -p linker flag x86/entry/64: Remove %ebx handling from error_entry/exit x86/entry: spell EBX register correctly in documentation net: bcmgenet: fix OF child-node lookup NFC: nfcmrvl_uart: fix OF child-node lookup of: add helper to lookup compatible child node tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset powerpc/numa: Suppress "VPHN is not supported" messages kdb: Use strscpy with destination buffer size SUNRPC: Fix a bogus get/put in generic_key_to_expire() cpufreq: imx6q: add return value check for voltage scale KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE usb: xhci: Prevent bus suspend if a port connect change or polling state is detected can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb can: dev: __can_get_echo_skb(): Don't crash the kernel if can_priv::echo_skb is accessed out of bounds can: dev: __can_get_echo_skb(): replace struct can_frame by canfd_frame to access frame length can: dev: can_get_echo_skb(): factor out non sending code to __can_get_echo_skb() drm/ast: fixed cursor may disappear sometimes drm/ast: change resolution may cause screen blurred llc: do not use sk_eat_skb() gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer bfs: add sanity check at bfs_fill_super() v9fs_dir_readdir: fix double-free on p9stat_read error iwlwifi: mvm: support sta_statistics() even on older firmware MAINTAINERS: Add Sasha as a stable branch maintainer usb: xhci: fix timeout for transition from RExit to U0 usb: core: Fix hub port connection events lost ANDROID: arm64 defconfig / build config for cuttlefish ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple" ANDROID: sdcardfs: Add option to not link obb ANDROID: sdcardfs: Add sandbox UPSTREAM: seccomp: Fix tracer exit notifications during fatal signals UPSTREAM: arm64/ptrace: run seccomp after ptrace UPSTREAM: arm/ptrace: run seccomp after ptrace BACKPORT: x86/ptrace: run seccomp after ptrace UPSTREAM: seccomp: recheck the syscall after RET_TRACE UPSTREAM: seccomp: remove 2-phase API BACKPORT: x86/entry: Get rid of two-phase syscall entry work BACKPORT: seccomp: Add a seccomp_data parameter secure_computing() BACKPORT: x86/entry/64: Always run ptregs-using syscalls on the slow path UPSTREAM: x86/syscalls: Add syscall entry qualifiers UPSTREAM: x86/syscalls: Move compat syscall entry handling into syscalltbl.sh UPSTREAM: x86/syscalls: Remove __SYSCALL_COMMON and __SYSCALL_X32 UPSTREAM: x86/syscalls: Refactor syscalltbl.sh Makefile: Tidy up 4.4.165 merge Conflicts: drivers/scsi/ufs/ufshcd.c Change-Id: I18bf85f3f24b37e8bb0839bd43eba65cc7eafc64 Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
Diffstat (limited to 'arch/x86/entry/common.c')
-rw-r--r--arch/x86/entry/common.c126
1 files changed, 30 insertions, 96 deletions
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index a9e501303e15..c611c1ed064b 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -64,22 +64,16 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
}
/*
- * We can return 0 to resume the syscall or anything else to go to phase
- * 2. If we resume the syscall, we need to put something appropriate in
- * regs->orig_ax.
- *
- * NB: We don't have full pt_regs here, but regs->orig_ax and regs->ax
- * are fully functional.
- *
- * For phase 2's benefit, our return value is:
- * 0: resume the syscall
- * 1: go to phase 2; no seccomp phase 2 needed
- * anything else: go to phase 2; pass return value to seccomp
+ * Returns the syscall nr to run (which should match regs->orig_ax) or -1
+ * to skip the syscall.
*/
-unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch)
+long syscall_trace_enter(struct pt_regs *regs)
{
+ u32 arch = is_ia32_task() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64;
+
struct thread_info *ti = pt_regs_to_thread_info(regs);
unsigned long ret = 0;
+ bool emulated = false;
u32 work;
if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
@@ -98,11 +92,29 @@ unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch)
}
#endif
+ /*
+ * If we stepped into a sysenter/syscall insn, it trapped in
+ * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
+ * If user-mode had set TF itself, then it's still clear from
+ * do_debug() and we need to set it again to restore the user
+ * state. If we entered on the slow path, TF was already set.
+ */
+ if (work & _TIF_SINGLESTEP)
+ regs->flags |= X86_EFLAGS_TF;
+
+ if (unlikely(work & _TIF_SYSCALL_EMU))
+ emulated = true;
+
+ if ((emulated || (work & _TIF_SYSCALL_TRACE)) &&
+ tracehook_report_syscall_entry(regs))
+ return -1L;
+
+ if (emulated)
+ return -1L;
+
#ifdef CONFIG_SECCOMP
/*
- * Do seccomp first -- it should minimize exposure of other
- * code, and keeping seccomp fast is probably more valuable
- * than the rest of this.
+ * Do seccomp after ptrace, to catch any tracer changes.
*/
if (work & _TIF_SECCOMP) {
struct seccomp_data sd;
@@ -129,79 +141,12 @@ unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch)
sd.args[5] = regs->bp;
}
- BUILD_BUG_ON(SECCOMP_PHASE1_OK != 0);
- BUILD_BUG_ON(SECCOMP_PHASE1_SKIP != 1);
-
- ret = seccomp_phase1(&sd);
- if (ret == SECCOMP_PHASE1_SKIP) {
- regs->orig_ax = -1;
- ret = 0;
- } else if (ret != SECCOMP_PHASE1_OK) {
- return ret; /* Go directly to phase 2 */
- }
-
- work &= ~_TIF_SECCOMP;
- }
-#endif
-
- /* Do our best to finish without phase 2. */
- if (work == 0)
- return ret; /* seccomp and/or nohz only (ret == 0 here) */
-
-#ifdef CONFIG_AUDITSYSCALL
- if (work == _TIF_SYSCALL_AUDIT) {
- /*
- * If there is no more work to be done except auditing,
- * then audit in phase 1. Phase 2 always audits, so, if
- * we audit here, then we can't go on to phase 2.
- */
- do_audit_syscall_entry(regs, arch);
- return 0;
+ ret = __secure_computing(&sd);
+ if (ret == -1)
+ return ret;
}
#endif
- return 1; /* Something is enabled that we can't handle in phase 1 */
-}
-
-/* Returns the syscall nr to run (which should match regs->orig_ax). */
-long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
- unsigned long phase1_result)
-{
- struct thread_info *ti = pt_regs_to_thread_info(regs);
- long ret = 0;
- u32 work = ACCESS_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY;
-
- if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
- BUG_ON(regs != task_pt_regs(current));
-
- /*
- * If we stepped into a sysenter/syscall insn, it trapped in
- * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
- * If user-mode had set TF itself, then it's still clear from
- * do_debug() and we need to set it again to restore the user
- * state. If we entered on the slow path, TF was already set.
- */
- if (work & _TIF_SINGLESTEP)
- regs->flags |= X86_EFLAGS_TF;
-
-#ifdef CONFIG_SECCOMP
- /*
- * Call seccomp_phase2 before running the other hooks so that
- * they can see any changes made by a seccomp tracer.
- */
- if (phase1_result > 1 && seccomp_phase2(phase1_result)) {
- /* seccomp failures shouldn't expose any additional code. */
- return -1;
- }
-#endif
-
- if (unlikely(work & _TIF_SYSCALL_EMU))
- ret = -1L;
-
- if ((ret || test_thread_flag(TIF_SYSCALL_TRACE)) &&
- tracehook_report_syscall_entry(regs))
- ret = -1L;
-
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
trace_sys_enter(regs, regs->orig_ax);
@@ -210,17 +155,6 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
return ret ?: regs->orig_ax;
}
-long syscall_trace_enter(struct pt_regs *regs)
-{
- u32 arch = is_ia32_task() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64;
- unsigned long phase1_result = syscall_trace_enter_phase1(regs, arch);
-
- if (phase1_result == 0)
- return regs->orig_ax;
- else
- return syscall_trace_enter_phase2(regs, arch, phase1_result);
-}
-
#define EXIT_TO_USERMODE_LOOP_FLAGS \
(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
_TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY)