Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2440140imu; Thu, 10 Jan 2019 14:22:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN56ew8scbeGnl64GVXfDH62HBeNAfZdpy1I9t/ShU6eXM5Qm/k8Ol2xIVVy8s/LV8qdlUbt X-Received: by 2002:a63:d10:: with SMTP id c16mr11080453pgl.382.1547158964055; Thu, 10 Jan 2019 14:22:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547158964; cv=none; d=google.com; s=arc-20160816; b=FTDtTtvWNSavIMr82Y/NGBGpobg5WAEtoayc4GKfeIUuJBZIsGpgzVAwMYX7AThmJo SpJWI4Dc9ObdFP6OZaecVIPcQYlM7xVgyoE2DnYB4nVgR5/PRrHpC0PUr7hrDv419W6r +rx7QAIlm4PhEhvhZ+JZgeHd8oCYJ+w+chihPpEZGWXkiIYwp+LdOqIqbyPTO2sO+bpG Wjgb/dsITXxfxO6YN1plEOkAvStGdnOTzlES3Ku92NPv25w6RmjulZE2EET1dV0y8hnM escfZvgC+L/f7uD8SIRIhVwMYaBEz8bIVGm+xmmgQ8E8/Q0qznuZ9APQ8eCdnt+m5WXF FXag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LOW/eLF4sEItu7qrfvvWaq4y3fuqgWxNIdjbrAYm1vQ=; b=dGO49Qi2rE5xg7fm0nKCpcnT+/TfL6pQvoGxEH5uAw5idme7pgblCNXLczhdAZLPXz 4AOuqdr6ctnN0lC/tETOtR2EUyGcAZ7sd/NeTK+AwVcXdZGWtt8YUIEjvht4hfKL7pCM u7gG2GfayEX9q7j0FPTSdErb+tn8N85qe28PfwXGM9dYDFgJpJ0hSt+LKpppzhsDt3Ps H2bYvBN6q8cAiCMJ5+twOxDpocVi1GqFZeWTQioidYj8gjAMBmCYRz12sr7nHtr1YsR2 Ek2jcjeG1CNZ9KPyCQyhPOyali2cA+bgQVd93OlVlFmER+i/rDgKswylpNP3oGpxdwvu 2vFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UeZztLgA; 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 23si12169725pfu.2.2019.01.10.14.22.28; Thu, 10 Jan 2019 14:22:44 -0800 (PST) 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=UeZztLgA; 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 S1729210AbfAJTJ0 (ORCPT + 99 others); Thu, 10 Jan 2019 14:09:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:37390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbfAJTJZ (ORCPT ); Thu, 10 Jan 2019 14:09:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 3336B20879; Thu, 10 Jan 2019 19:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547147364; bh=iXg8q6MzR9ytC5PYy/ErCiygn/3Vt+ib7OUE8Hx+OpQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UeZztLgAeJzQ51FbDYcl18ethcjt6juD5AEsrcwj6UdP4G9+xYI/dDPaYjia2YVFP UDkemw4fJ+hc48/3q2cHQrStR2XavZdRFz9c1bdT/OCPBcQORNOZP5sp7WMleMq/Z/ aaRNyoz/iC4MDJYJkSYaBiRH/4fRj4r91RuhOzC0= Date: Thu, 10 Jan 2019 20:09:21 +0100 From: "gregkh@linuxfoundation.org" To: Paul Burton Cc: "stable@vger.kernel.org" , Paul Burton , Andy Lutomirski , "linux-mips@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rich Felker , David Daney Subject: Re: [4.9 PATCH] MIPS: math-emu: Write-protect delay slot emulation pages Message-ID: <20190110190921.GA18221@kroah.com> References: <154685090718637@kroah.com> <20190110174724.24713-1-paul.burton@mips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190110174724.24713-1-paul.burton@mips.com> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 05:47:42PM +0000, Paul Burton wrote: > commit adcc81f148d733b7e8e641300c5590a2cdc13bf3 upstream. > > Mapping the delay slot emulation page as both writeable & executable > presents a security risk, in that if an exploit can write to & jump into > the page then it can be used as an easy way to execute arbitrary code. > > Prevent this by mapping the page read-only for userland, and using > access_process_vm() with the FOLL_FORCE flag to write to it from > mips_dsemul(). > > This will likely be less efficient due to copy_to_user_page() performing > cache maintenance on a whole page, rather than a single line as in the > previous use of flush_cache_sigtramp(). However this delay slot > emulation code ought not to be running in any performance critical paths > anyway so this isn't really a problem, and we can probably do better in > copy_to_user_page() anyway in future. > > A major advantage of this approach is that the fix is small & simple to > backport to stable kernels. > > Reported-by: Andy Lutomirski > Signed-off-by: Paul Burton > Fixes: 432c6bacbd0c ("MIPS: Use per-mm page to execute branch delay slot instructions") > Cc: stable@vger.kernel.org # v4.8+ > Cc: linux-mips@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: Rich Felker > Cc: David Daney > --- > arch/mips/kernel/vdso.c | 4 ++-- > arch/mips/math-emu/dsemul.c | 38 +++++++++++++++++++------------------ > 2 files changed, 22 insertions(+), 20 deletions(-) > Thanks for the backport, now queued up. greg k-h