Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1639785pxy; Mon, 2 Aug 2021 06:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDl5DO8UQVga2WITz4oBIqc6EGS8AXDwndpxlyNJ9IcR8D2UlPvaOJg/CF2GpkLalDbSNo X-Received: by 2002:a92:d112:: with SMTP id a18mr831836ilb.67.1627912326394; Mon, 02 Aug 2021 06:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912326; cv=none; d=google.com; s=arc-20160816; b=vO/zbk3p1mab4mYAe2Uqd332nraIimwZfLbfaNh7mw30n6yZmCELNEs3PXuacmGriK u6rec6AhZXnSresEPfAs1/jHoC2vf4bafZ7p7yKWQZ1FDHbq0PS+w/ZR6OfcaPasW832 MNxkJZVL6Fe8OvR8BSPvFrd9czGsyk6Y2NVdUSedgvL66XEbzV6hKo5fRd6Rzk59lAlv 6Q1e6Qo3taIhfwyf3cAV7Q0wtpldzaqkM3YpzfNGmwY0sI9MBiHhqbMOHJWvlFCbJ9P+ /gv3IRqxmmHPcr/mvHUitMzYQGcvAx2aUdFHXKF+0FxWr+SVr2eUpt781IXUerDf5kQH lYTg== 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=5nX5ProOzRUeuQ8D/t2VIBdk1svXAQ6D481zdQ5qUuo=; b=tfHTzxGrmViPYHuvpIfkEaRpbw2p12wt7BftFsGgyrNGm9h/e4wN0gCXoi0jsim4VL KKNbxCv1tm2EQUPdz8Hx15PznStj0+DCT98oGGx61nSCBmI0hopPUm37XJqXnhDXVEBS EoI7dUmA7mfo2doaMxTHcvEHGMnYEOcAM42OartgtN3u02LvpVJaKD+vhlg1FJ0VVh5u e0AQW3GD0uYTT1+jKaiEzaeVDTIo6kz8GKNIiy2DQPK8B3nbHhbPpto3Zle49McqYYUo 9saUrr576XWzvnFpYhjgdbMx2pjg4FV6ZBkEPdZ2isZH6JGdTB30fVz8xtIzaW+sqoCE t7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x20ogkwE; 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 v17si13340352ilo.17.2021.08.02.06.51.55; Mon, 02 Aug 2021 06:52:06 -0700 (PDT) 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=x20ogkwE; 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 S234750AbhHBNvK (ORCPT + 99 others); Mon, 2 Aug 2021 09:51:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234412AbhHBNsK (ORCPT ); Mon, 2 Aug 2021 09:48:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9EB8C61131; Mon, 2 Aug 2021 13:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912080; bh=TLuHBacfy6zJyeCibSLTST2gSrfB2psfKd7bI6DsLCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x20ogkwE2gWLI1kqaqnCzj8cA6nQonmN1dDKz3bQoVWuc78ekf5NT7yGIejaV0Mzu 7PPZmeffGHEoz7HnkztilYYHK6p6Vg1eqEOQKmwp9NxJHM7ep35tiIN4/lYUzrlMfE kd1g/LjAtgxBa1ntRm/kLgk+R7oJFmt9jbJc/ESE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Russell King , "Nobuhiro Iwamatsu (CIP)" Subject: [PATCH 4.9 14/32] ARM: ensure the signal page contains defined contents Date: Mon, 2 Aug 2021 15:44:34 +0200 Message-Id: <20210802134333.377069865@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.931915241@linuxfoundation.org> References: <20210802134332.931915241@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 commit 9c698bff66ab4914bb3d71da7dc6112519bde23e upstream. 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: Nobuhiro Iwamatsu (CIP) Signed-off-by: Greg Kroah-Hartman --- arch/arm/kernel/signal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -625,18 +625,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; }