Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10429891ybi; Wed, 24 Jul 2019 23:04:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqys+URwrw0zVCXil0dzHBWzlHYdfufKB1PkeDhQ6mY4FfJsQS0Q63bO5wB9z6bsgaSxr9Jv X-Received: by 2002:a17:902:724c:: with SMTP id c12mr87807280pll.219.1564034673555; Wed, 24 Jul 2019 23:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034673; cv=none; d=google.com; s=arc-20160816; b=wvYLRHx6WiBTJz1dHARbq2Bf8Uzr5pJhSkqvfUbcttwAkjqOx90/9YgdEafJjp8f7a 9NZCRrpMotIbUCCHAOBilFaV0cCNFiA8gMheyyXrijctdZGzIw1twcV/uR1pXSVp9HuZ tTEeqVGjR92IY8gl7DDvdA0oQORmIQOvxhAgkkd7PDpUBhuGB6wuBz9ynpJTBsn7HGOY dAo9yqKhY08TRL8U2F0RK0dDpQycglgcn+grHfRoAM+kAj2Klei4G+lcrAgd/ivRcPmd JsPcERywSk+4lzmbFZo5RsgmhBh7sqblSNH/Ed0gwR0IAVl20h0bSu4dJPCRxs3wSedt 37Cg== 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=LrlLBAN0zlNNcU+I4OFiZw+3/AX3K/JLgZVep86eM3efwBTYrRM9jXgzNdXi/OikFb dB3YnH2U6mX5Miken4hIwzASCARcahZXFQdRJ95zdVpI9SNVcHOrt0Fp7qcL/h8crjCO 9I1RgPa3MPS/cngxJ3rHjqKi9orbvG0U1mVa2zIuyZWWl7pOFjRYxdlxflVbi2okK0jD KkM0XW6ETYYOc6ObZsqTvcY8W3HPeL7HVzbQkeB24DtWPGrEU2THp3CAllIAXP2/7PiY Yi2EV79KfIlj+RPyHAKQl3fRYg+zO5J9ajRSwI3Q1KN09MlKGlHJfRQM3ClOhWFx6XI3 xYDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ItYyDMwj; 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 p5si20549483pfp.64.2019.07.24.23.04.19; Wed, 24 Jul 2019 23:04:33 -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=ItYyDMwj; 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 S1728930AbfGYFrd (ORCPT + 99 others); Thu, 25 Jul 2019 01:47:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:35396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391561AbfGYFr1 (ORCPT ); Thu, 25 Jul 2019 01:47:27 -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 011F220657; Thu, 25 Jul 2019 05:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033646; bh=kEHKA4EUTrNeERxwRQ+APkr3hFEhUC2gW5svMuPHzJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItYyDMwj9EWZRt5sq+MqOJJtQD2Tdqq2D5J7/nCMt46e3hgJSVjLyZ62Cp4p2aaCz v+BL4to4v9xXMRQ6d5HE2VR5kKU+2uI/SQAttwbKLmpaNeb0ZEhpjmBJ+stWm8h2tI tbUD1F46jk/LPp/3h1aRpLD719D5BBH4m7BW0+Ic= 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 4.19 253/271] parisc: Ensure userspace privilege for ptraced processes in regset functions Date: Wed, 24 Jul 2019 21:22:02 +0200 Message-Id: <20190724191716.885680591@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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;