Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10520140ybi; Thu, 25 Jul 2019 00:48:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDdHKO1yEkhPHG6EUbNgYqppcE0dvUn4k8Sb6ixrA612tYoo3Ozgm3h9eGQO73F1o1w6lk X-Received: by 2002:a63:5a0a:: with SMTP id o10mr12121696pgb.282.1564040898907; Thu, 25 Jul 2019 00:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564040898; cv=none; d=google.com; s=arc-20160816; b=ECM8q48z9HdMdKzeWem7EtmfGpq+lMJ1llfx+eKVU1BJZF5UVWZlck7SF/DwSfiBMn tP5DA/Ee9E7XmZoBTUUGVPK9ZMPuKx9Ruy4r3oKQWvShR99J56MLaLBj8H79fxtfCXBv T5k5Gk7QUMCdD3yLkGc5oh4lh4BxLDZS7VbYb7mU7FU/KYrsNxOMePOxFJRWBW4Gq6jL rdX3tdarvzrq0ULX+YD/AmtmD5DnshL6gjNtIy8bIlXQvI4jvZlKEqzbTQClHZLXnw4X xasDLHACKbZTiBAE3P41P79yvSBz0RYpMqs5U4rvvYdLAXXHI+8iXSHONuAnDai9cfuI R52A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vSFAk7iGhPR1K+6MqThPCaIsOzQdmmmp90QPqKsbrx8=; b=yHLBEHKNYJf8uj6qsP34UZbjAMN4v5ITtcHDL3dNEDA1AazC4HE5oCzr5uhPNTeBhF XAv6I8JGaYzKn9Cy1llfiXnnvF9DD+61PaLVNYaMGtDD1HSOvzO3wPj+pkHh0etcG1kV M/SXp2+5sQYvK1nfuUeRCtCGzkzv8tA6L09tVqb2Nd/R5rDosCV8PwVryhPUWXRLaz0o jNK1x733romA3D8NMdITYuns120FZSuJb9Q8H2RgeFrlNOlbKS9zhRDF6vABJFar/0Fk dZyIqpRtZupiHu8tTIK5vKhoI6aR2U35ypzeHTQWT4yrzGdoWveoyfiIlSt5IXocM5pY gUoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vWBORWmw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y71si14999677pgd.271.2019.07.25.00.48.00; Thu, 25 Jul 2019 00:48:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vWBORWmw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405365AbfGXUBN (ORCPT + 99 others); Wed, 24 Jul 2019 16:01:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405350AbfGXUBK (ORCPT ); Wed, 24 Jul 2019 16:01:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC535205C9; Wed, 24 Jul 2019 20:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998469; bh=kEHKA4EUTrNeERxwRQ+APkr3hFEhUC2gW5svMuPHzJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vWBORWmwSPoDt54kkpUD+iTsDXiAPO254V3nTPGcYpxDdkUjG7W2PAlzfLCitT2dH 8vlhV6HqyWTpfmWX8RRBQQ0n6MNmlnperE6L3E0ycSef9B+m2ZOQLPCFfnjyO+r3D0 g0C2cmtw9eCrQz39BZu9d1lzlseyb2/syVzu7wpg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rolf Eike Beer , Helge Deller Subject: [PATCH 5.1 347/371] parisc: Ensure userspace privilege for ptraced processes in regset functions Date: Wed, 24 Jul 2019 21:21:39 +0200 Message-Id: <20190724191749.824479528@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Helge Deller commit 34c32fc603311a72cb558e5e337555434f64c27b upstream. On parisc the privilege level of a process is stored in the lowest two bits of the instruction pointers (IAOQ0 and IAOQ1). On Linux we use privilege level 0 for the kernel and privilege level 3 for user-space. So userspace should not be allowed to modify IAOQ0 or IAOQ1 of a ptraced process to change it's privilege level to e.g. 0 to try to gain kernel privileges. This patch prevents such modifications in the regset support functions by always setting the two lowest bits to one (which relates to privilege level 3 for user-space) if IAOQ0 or IAOQ1 are modified via ptrace regset calls. Link: https://bugs.gentoo.org/481768 Cc: # v4.7+ Tested-by: Rolf Eike Beer Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- arch/parisc/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -496,7 +496,8 @@ static void set_reg(struct pt_regs *regs return; case RI(iaoq[0]): case RI(iaoq[1]): - regs->iaoq[num - RI(iaoq[0])] = val; + /* set 2 lowest bits to ensure userspace privilege: */ + regs->iaoq[num - RI(iaoq[0])] = val | 3; return; case RI(sar): regs->sar = val; return;