Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5070719pxb; Mon, 15 Feb 2021 08:44:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYlOgybAuU2IXrS/osgR5wngcDsnhIKEhMDe0fdYNvKAiHesKgl3Lf9vTIcEmq1RthqWIk X-Received: by 2002:a17:906:c1c1:: with SMTP id bw1mr16773206ejb.86.1613407478994; Mon, 15 Feb 2021 08:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407478; cv=none; d=google.com; s=arc-20160816; b=0G4MWzckcXUWhcO6CDNZe8FqE9AEGMPi9O/G/zaTDExubJYn2U0lx1BsX5tghiNHMF OiOTJsRz6eFmopiwFxjWanRHRm1/q8x/kdz1m22r7kuRxI4UNgsV9zu8zBw/yjcrhFI3 sqowUsfxbjp2b8koTUdbd1zTgyykp9qfJSZQTmmtevbYHmz+JDe7eN6MZk1eSBDhpdZA NGm8oGd9GVpAJGx8eIPOAQ16IpEOdiWPgugjbPv6FwzKu8hTvK1snVjeSxUt6YGT7f1W ift7h1UqqZ1LKYEHn47Nkdu50lxvFnS8D34bTAaXPGSmtpv2Zb2XBW/lSnYnmvuAMZUt PmLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IAJdsixyA9bBhIUe16H5HylXS7E4Sx/iLqzu7NBa1j4=; b=Pp8W8P96WDAhY6JGAVzS9bmlWRUxgbKyqrB4gvStLJIogAH3AhiJa4sBexlvi9QLbg 3lHNve3dZFFuyP4vz4hg0UXEHoCaa5mtFRqT9nJ9J96dxG6/nUTivxoSKRS/hN27t5WW GQTA8BWV43SC5v78FZ96qaHDH9qiLI+xZ8acjyTttThCi/hjKaguLAApo5wbk3TX87eX fbFrVGZxzH3zLH91MxIp0+VOIClv2NS6iNI5zZz9ZCIWNxVZi9dBExx+9iM5daJHHcP/ Mmsv3zoV2GmkXxN4+OxTZ+5J2nulBUfvRuZvPcKRcqHx2a5m+S4waSiReG9V8XwwlU1T Xzhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xF0EwvTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c59si12140186edd.508.2021.02.15.08.44.15; Mon, 15 Feb 2021 08:44:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xF0EwvTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbhBOQmK (ORCPT + 99 others); Mon, 15 Feb 2021 11:42:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:50360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbhBOPiB (ORCPT ); Mon, 15 Feb 2021 10:38:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51F3C64EE9; Mon, 15 Feb 2021 15:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403230; bh=ft4G97VhIjJwaES8UFkwK1Ab7kaT0oqcang245BltCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xF0EwvTAQJvQc7BzyRaxUdpqfOvdHZX5yrtLZ262gP1z5C4SmpfyASuI+xgUWw9ym hfHpFMhI034FzW0Rx0XbVM5ElKQu5SrlAGsXzV+veuSDcGAWmyZ9NuR2AlSSsYUg18 Fq1Kp0RAXqDqgFbVJZDq4OEQObAplcqY5wsGaQJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Russell King , Sasha Levin Subject: [PATCH 5.10 041/104] ARM: ensure the signal page contains defined contents Date: Mon, 15 Feb 2021 16:26:54 +0100 Message-Id: <20210215152720.801524308@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King [ Upstream commit 9c698bff66ab4914bb3d71da7dc6112519bde23e ] Ensure that the signal page contains our poison instruction to increase the protection against ROP attacks and also contains well defined contents. Acked-by: Will Deacon Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/kernel/signal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 585edbfccf6df..2f81d3af5f9af 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -693,18 +693,20 @@ struct page *get_signal_page(void) addr = page_address(page); + /* Poison the entire page */ + memset32(addr, __opcode_to_mem_arm(0xe7fddef1), + PAGE_SIZE / sizeof(u32)); + /* Give the signal return code some randomness */ offset = 0x200 + (get_random_int() & 0x7fc); signal_return_offset = offset; - /* - * Copy signal return handlers into the vector page, and - * set sigreturn to be a pointer to these. - */ + /* Copy signal return handlers into the page */ memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes)); - ptr = (unsigned long)addr + offset; - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes)); + /* Flush out all instructions in this page */ + ptr = (unsigned long)addr; + flush_icache_range(ptr, ptr + PAGE_SIZE); return page; } -- 2.27.0