From patchwork Thu Jun 9 21:02:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9167995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 60C00607DA for ; Thu, 9 Jun 2016 21:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5177328338 for ; Thu, 9 Jun 2016 21:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 443662835B; Thu, 9 Jun 2016 21:09:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC17828338 for ; Thu, 9 Jun 2016 21:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751802AbcFIVHl (ORCPT ); Thu, 9 Jun 2016 17:07:41 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:35151 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbcFIVC3 (ORCPT ); Thu, 9 Jun 2016 17:02:29 -0400 Received: by mail-pf0-f178.google.com with SMTP id c2so16363159pfa.2 for ; Thu, 09 Jun 2016 14:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oYG2fs7qhrt3SB3C1gIg78Ki38XUW1yWQYHGxsDi4jM=; b=KUhlYh9YOyuXBPOs6E+cskJoTnOLRBiV+xqRaF7vJof5BbOKS/I/J7I0EGGIpssRLt Rinq+l7z/VivEQwl7LIe5Za6gqZrJ77MrFPYpAVEqynv/AS69YeUTeVAp3xZ60mmPSud 4jNx8jFMyKERWgSsWLQdK2JAIhTBb+omFfH0Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oYG2fs7qhrt3SB3C1gIg78Ki38XUW1yWQYHGxsDi4jM=; b=I//929QE74dcdy4sizveJUHOuDUmcOfft67QPJUjD+0MrapFzoINy8rstnumqLQQth g8he+3iBjkg2D16u1CPVU1p6IheO/zNTDG6N07cYU53wT3ClD1JMXT92OMV+nusDfC1w kGC/rz2hs6d6qB3Gt0cbIb3CfH23OXLbEoKKMMYHBlQs4/ue4vdWAOl2L5bpMvh7CvSh eCsVrHJuw4CLWM1Ocj+0lyIZgFd+oRbUganY+RipZOBvX/j+u1zD7MnZerTYTO31H5jZ TxRd7EquoyXqy8HMj64kBouwdpa8X/nVM0wjMWxvYaAreITWyanJ+bP2nCku/YHgEtGm is9w== X-Gm-Message-State: ALyK8tKObqD7yf3kNgikVAXjP4qf4BvG5xR3piwJiAGecSeQC6Qqx4BZLEk5iYo9uHMztj4j X-Received: by 10.98.10.137 with SMTP id 9mr6453218pfk.28.1465506149191; Thu, 09 Jun 2016 14:02:29 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id s124sm12163691pfb.63.2016.06.09.14.02.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 14:02:27 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Andy Lutomirski , Benjamin Herrenschmidt , Catalin Marinas , Chris Metcalf , Heiko Carstens , James Hogan , Jeff Dike , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, "Maciej W. Rozycki" , Mark Rutland , Martin Schwidefsky , Michael Ellerman , Paul Mackerras , Ralf Baechle , Richard Weinberger , Russell King , user-mode-linux-devel@lists.sourceforge.net, Will Deacon , x86@kernel.org Subject: [PATCH 10/14] parisc/ptrace: run seccomp after ptrace Date: Thu, 9 Jun 2016 14:02:00 -0700 Message-Id: <1465506124-21866-11-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465506124-21866-1-git-send-email-keescook@chromium.org> References: <1465506124-21866-1-git-send-email-keescook@chromium.org> Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Close the hole where ptrace can change a syscall out from under seccomp. Signed-off-by: Kees Cook Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org --- arch/parisc/kernel/ptrace.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index 8edc47c0b98e..e02d7b4d2b69 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -311,10 +311,6 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, long do_syscall_trace_enter(struct pt_regs *regs) { - /* Do the secure computing check first. */ - if (secure_computing(NULL) == -1) - return -1; - if (test_thread_flag(TIF_SYSCALL_TRACE) && tracehook_report_syscall_entry(regs)) { /* @@ -325,6 +321,11 @@ long do_syscall_trace_enter(struct pt_regs *regs) regs->gr[20] = -1UL; goto out; } + + /* Do the secure computing check after ptrace. */ + if (secure_computing(NULL) == -1) + return -1; + #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) trace_sys_enter(regs, regs->gr[20]);