Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1188766ybi; Fri, 2 Aug 2019 10:48:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUf2+9Vxmrxhs6zvz+Hd+LIt7tSv8VpUHzf79LltpTwOBS/ofJlgR/Jex4Wez15PHx6rjJ X-Received: by 2002:a62:15c3:: with SMTP id 186mr63044057pfv.141.1564768093838; Fri, 02 Aug 2019 10:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564768093; cv=none; d=google.com; s=arc-20160816; b=mlKYHiS4F6Tm1qQ7PgQbexYblTILcnd3kWtR8Jk4UZbQ7/jlcF9c3YZtAdSYGv8wNZ GvyvYdanQSy6mGDSgB6LgnkUfqefvsJAP4OeRr6SGY2K7lcg8X1FrWl4SLvQCvEd10ZT RP8UQoNNmYT6NfdSRHAANLb3yI2qhj9umOF451exz94E1D/kvI5HSzNY1/WmAd5YjLXd tioOLV8eJ0Vs+xxCYLlQBtBZ3I/VzHLsef0bmF+P9eSqMCOZ3z3ZG3rFlMB53TXjz3lT tsfCcmP4doxz/Cmajx46EfeTQTiPT6kpZJ4V48A3g3OZTSXOTvRKFn/JUNt6EoKtz+7y hr6g== 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=kxoBnEJKed1UzONk2VSpDEgU52vWWZAhoczlTqZOXA8=; b=q2WjnwVq6DceG6RjFf6TaXqkoUjkGgl/d9EOZEOdNMJMk+hg854Cfn/8tDYZlUm7rn XGKuDE7XkHrMM6CPH/lAtheOpE2njbookl/H89Zj7dJRgvD7Om0n+fr+nwK//NIR9jlY 3wrvNj/daBKQKgkxMK5+K0l73Kz6pICA6Pz4voNj+yt5TGnR3qpObBpEJSJuUYc+7noP yS6YyjiRXV7dV3NeyebJrtYJLGMh8M0k7ltcTRUdVcEestLos0nANua/ceM0Qkdvu5ap 1y8pEqEU3fos07vQpz00AkfkOxlIHE9ffhia0qW0f9uW9PRlAQBW6FmlxcAOYhRS5X/J HaeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MHStNdIg; 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 x7si37690406plv.130.2019.08.02.10.47.58; Fri, 02 Aug 2019 10:48:13 -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=MHStNdIg; 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 S2405598AbfHBJuS (ORCPT + 99 others); Fri, 2 Aug 2019 05:50:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:49660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392007AbfHBJps (ORCPT ); Fri, 2 Aug 2019 05:45:48 -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 C1361206A2; Fri, 2 Aug 2019 09:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739147; bh=YIuJfL9nexr+AHskL4zyzbc4OSW0mR1Fd1wyhONjbiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHStNdIgifZnbdPpogKJASeTSagmNz8+mCSLCeObDOMLGLoJpcdFrf3oVE9Km8O39 vxjErQ/NJWP8Pz/uuztILUm8T7WMFQmGhx1on81RScaJUgdRBQDwU2kfynRoKVZ5eZ 3SQRuQ/qp/0MNjtAWXxXKBwUlu8Psd7Y8234ssrI= 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.9 116/223] parisc: Ensure userspace privilege for ptraced processes in regset functions Date: Fri, 2 Aug 2019 11:35:41 +0200 Message-Id: <20190802092246.716520062@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 @@ -499,7 +499,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;