Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3786508ybi; Mon, 29 Jul 2019 12:36:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7hL9xc09Y0blDFcpvQ1Em5OQ7RDjqm040LmmTt8EjEqCSyRl8o7l+RaaYzGCdGrHHYoMW X-Received: by 2002:a63:cb4b:: with SMTP id m11mr31728239pgi.49.1564428965017; Mon, 29 Jul 2019 12:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428965; cv=none; d=google.com; s=arc-20160816; b=D0MJYYURZhgtDBVYG2c6P8MjlSssH7SfvmQccE+uSAC4gEEN8LYKyb2q3gvLhqYk2N 9KMMzSGVdmknNMkY8xLLHiTiLAWbwk+poZ47kdCc49+AIMlNWpVP0TnJwEkMHqirwHm0 pQRT2hRkm+RFy2Y/0b8zhgJR0kQYDsh4KhTTd7TWyTDmTdXMV25R/jQ/yrdegkpncN9w EvjT2zCMfapvfzXvFn2o1hn4Edt4lVtAET2kC7fe6aH/Wb+5/JlQgzvvaFojwqREguZV YAdDgPDmQ9YvSQn5Dh9NzXPNU4d39KXJq7+WycOPvhszyFaICzSWtmq4Eiyi4BhfmFjK 0WqA== 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=kLmH3jfEPRiW6uzT/EockBC1H7RhVVtckRtIvKnOBC4=; b=oQo2Vzr6hFx8G9LB1BSmJ43Q11CgYXGfuOAsQa5UFmun3Bhd6QHjuhgvprmXk2E0EQ w4PFHb5Tq4cEKWpM4i8xnaZ+W+3FusFDJQPELkmSlfalTk9zKF0Ccx08Vl4Zskwwc11x IwhkVX2SGoeF3pYG9Lhe+9ML5pw5PzZjCyRzcJEinJNBv44xfsbAxGQBlz53JGFxuS3e G/L4xmxfDkeRsBkUK4rlBo0oMnXT3duM9Ygrkt0ZHHjCA1y/Z8JSDTimLEExPrEeUbii fqT8Av1A2oSX7yEXO+DjCQ79iRgfKl/uo5NUzRN6IxHgwgdL31A/5uwE4JkXxnPwxsFP /egw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmzwzLAx; 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 y6si27716607pfl.288.2019.07.29.12.35.49; Mon, 29 Jul 2019 12:36:05 -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=jmzwzLAx; 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 S1729433AbfG2TcJ (ORCPT + 99 others); Mon, 29 Jul 2019 15:32:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:45358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730213AbfG2TcI (ORCPT ); Mon, 29 Jul 2019 15:32:08 -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 CB188217D9; Mon, 29 Jul 2019 19:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428727; bh=ty97BlOGJMlLKNU2GM8hXIFhIkRgTfbUOV9TcJh/z+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmzwzLAxXnOA4y3nuVATWqgDlnAHU91KCBHKhi7Xq2MEMkobLWYxF8bWKtKGi357M SZFu13TZe4UbqCc6eiGiQRFYssYxA4/wfcu13LrPTxLNm029jhZBFQI4D68FdtDIr+ jNdDlRN9Me/kx2L6KigGMFoihjBBQL4mHMsV0hjc= 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.14 167/293] parisc: Ensure userspace privilege for ptraced processes in regset functions Date: Mon, 29 Jul 2019 21:20:58 +0200 Message-Id: <20190729190837.314198313@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 @@ -500,7 +500,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;