Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3017094imm; Sun, 1 Jul 2018 10:22:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfn2uPcYpSswIBm+DGwfN28YwDNMjcLqz2+AJ+9VzxCT9T16UutirAB5X3IPfzVnnRzGyGt X-Received: by 2002:a65:4b07:: with SMTP id r7-v6mr6862846pgq.150.1530465751446; Sun, 01 Jul 2018 10:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465751; cv=none; d=google.com; s=arc-20160816; b=ite+66g2BpEp71U/CnV2WVSPXhJMKJwH9+gFPFZGpLjKJQ75vwhwa/1g/7fmLmcBMm K7aAiMhX2brR5T/3mfXPs0vkMXDD4iU/xSAsQEr3JrQLcXSOgOb/bbGGvDp8b5x/8mK8 OwH8SOTobat/g4R2IXnzw9nTMWogS5y6u6V2atW7SW1Ft8+eQBYTmsTII8vqDyMplhbA mtJl0M/s/dPo9taLwv8t+gChcLJWZsRMUH2UXjO7ZSdpG0iaCH+I9yiBBKel4yMdhnFw nOUuSsomJtM32VoYWfGKj5Fm+mW0Im+gVKPJuaA/pzDFKQIrz/n8MVjAPtcMlH4IRwsR Ykdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7Z40GufArHmJDHGpdGtehIGcnkSzbRK46SvAy3DOtqE=; b=li+SJMHuuSKSkeVwOUt+zrV63iEjLYhz1/piCmTrJPSpVXEccXFbNQ48JbuyrMiRGm ZKDbs96OSu2JVGwaHQKLU9kihGYnppveus9cOZKVZjBehW5MCjw1ant/Qs8vzmWIuSac 3Aj7JqxNtYz+TYF9X2+rwwO+35mI1jnhJ4k6FThMYN9oMfxrSAeM+YFp64ID9EzB0Ges h/kd1TBPdUtD35aAcseNWMARt3/wUatuUNb2FPOvSVGVROk6EWaeh04KIY4W7vrkuIYr dFBlbKdaJlF/A7taKWWoS/xy7SRsQ0md+DMf43eLE1Op2YFx6t9teRDid8gJXhHmnaqA V9CQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v4-v6si11850411pgf.488.2018.07.01.10.22.17; Sun, 01 Jul 2018 10:22:31 -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; 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 S965906AbeGARUl (ORCPT + 99 others); Sun, 1 Jul 2018 13:20:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36720 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031593AbeGAQi2 (ORCPT ); Sun, 1 Jul 2018 12:38:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4B7A9AA6; Sun, 1 Jul 2018 16:38:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shakeel Butt , Ram Pai , Thiago Jung Bauermann , Michael Ellerman Subject: [PATCH 4.17 045/220] powerpc/pkeys: Detach execute_only key on !PROT_EXEC Date: Sun, 1 Jul 2018 18:21:09 +0200 Message-Id: <20180701160910.206851258@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ram Pai commit eabdb8ca8690eedd461e61ea7780595fbbae8132 upstream. Disassociate the exec_key from a VMA if the VMA permission is not PROT_EXEC anymore. Otherwise the exec_only key continues to be associated with the vma, causing unexpected behavior. The problem was reported on x86 by Shakeel Butt, which is also applicable on powerpc. Fixes: 5586cf61e108 ("powerpc: introduce execute-only pkey") Cc: stable@vger.kernel.org # v4.16+ Reported-by: Shakeel Butt Signed-off-by: Ram Pai Reviewed-by: Thiago Jung Bauermann Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/pkeys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c @@ -383,9 +383,9 @@ int __arch_override_mprotect_pkey(struct { /* * If the currently associated pkey is execute-only, but the requested - * protection requires read or write, move it back to the default pkey. + * protection is not execute-only, move it back to the default pkey. */ - if (vma_is_pkey_exec_only(vma) && (prot & (PROT_READ | PROT_WRITE))) + if (vma_is_pkey_exec_only(vma) && (prot != PROT_EXEC)) return 0; /*