From patchwork Tue Jul 17 13:51:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 945111 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41VP1P0PQBz9rxs for ; Wed, 18 Jul 2018 01:13:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="klNd7eV5"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41VP1N5z1tzF3KJ for ; Wed, 18 Jul 2018 01:13:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="klNd7eV5"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::243; helo=mail-qt0-x243.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="klNd7eV5"; dkim-atps=neutral Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41VMBr3LFPzF3Hr for ; Tue, 17 Jul 2018 23:51:32 +1000 (AEST) Received: by mail-qt0-x243.google.com with SMTP id q12-v6so887806qtp.6 for ; Tue, 17 Jul 2018 06:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nutFJyVrtXWOudLaWXF3Kuyw8rV0m0afoIg7RwQeFpo=; b=klNd7eV5zE5YE2LiAWerPvLT7qqx0X/8+ciTBOgeaAKwbS9QqtSECAx6iHLr42cHkk Rr1xLquUY6/bDykmW0dmc54uga+E9uObku6xYbHdS2OkF3SGhPmzC6RzSnlFg5JYMPWt 6/UtkVpndxwGFlv0kFjiSU7sXx2Ou1QlZGyO7+UA7Q4d9VoxNCgPIYlrNB3c7X6Yj7sK HR/yZgJBu0yffHnADlEbuoe2nOnVDEOrLi+7pyJ7uuWtHlQ9WMXTPPRQtcX4yb/FOMBl 3kKi2XCN6UiZawOzo+nESjfVBU3NWAzkYJa/VfZqCYbLr0MA+HlAuFECpgudEvn+R1DC Q0hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nutFJyVrtXWOudLaWXF3Kuyw8rV0m0afoIg7RwQeFpo=; b=qdS0yBohlA3zL9js5u/sPKr0hJkHCGzfYiFhtO2mLeT6CGFi3Cl9bsALx+OWf6aoRs dOLxWnPqTOafOai3c0eKJSjqLtfFAaC9vJDr8lOJzjxEcKt2CRHmFrKHGFPQmYIfcdD1 fdJJX8vhG06DCfTgmzM/3OJkdxP5DTE/YkmtyuasUJX4dXC6qZll+VuvK4xk/L3OO8sO GT83QMSEoqcwHhdG+KMvQBk0SaMN+RvDVezCct5FH8JbqTkr6HnldqmrV+YHsppCUEA9 4RIxTmZKwTFz7uuqskTX49uBE2SE2gw4Irj83KUcWIhnUuAn4DVrDdHj2JFMJbz618RR 7FuA== X-Gm-Message-State: AOUpUlHbHwh7kXYgE1VDL3pl0nLaLSOcftPyKVhF9h3JpsrTl48VPPBl xp1aovazTXz/IEjT+FbvTcI= X-Google-Smtp-Source: AAOMgpd5t1fFNiFsQNyF3wN4LW/YhDUT2aV2OE1VdiYgBLlXq2hVePqyBtjzTm5Q8HGOX8i26H3eGg== X-Received: by 2002:ac8:892:: with SMTP id v18-v6mr1631906qth.49.1531835490479; Tue, 17 Jul 2018 06:51:30 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id f3-v6sm785548qtf.61.2018.07.17.06.51.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 06:51:30 -0700 (PDT) From: Ram Pai To: mpe@ellerman.id.au Subject: [PATCH v3 2/9] powerpc/pkeys: Deny read/write/execute by default Date: Tue, 17 Jul 2018 06:51:03 -0700 Message-Id: <1531835470-32691-3-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1531835470-32691-1-git-send-email-linuxram@us.ibm.com> References: <1531835470-32691-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fweimer@redhat.com, Ulrich.Weigand@de.ibm.com, linuxram@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, msuchanek@suse.de, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Deny all permissions on all keys, with some exceptions. pkey-0 must allow all permissions, or else everything comes to a screaching halt. Execute-only key must allow execute permission. Signed-off-by: Ram Pai --- arch/powerpc/mm/pkeys.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 0facc0d..7dc0024 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c @@ -124,12 +124,10 @@ int pkey_initialize(void) /* register mask is in BE format */ pkey_amr_mask = ~0x0ul; - pkey_iamr_mask = ~0x0ul; + pkey_amr_mask &= ~(0x3ul << pkeyshift(0)); - for (i = 0; i < (pkeys_total - os_reserved); i++) { - pkey_amr_mask &= ~(0x3ul << pkeyshift(i)); - pkey_iamr_mask &= ~(0x1ul << pkeyshift(i)); - } + pkey_iamr_mask = ~0x0ul; + pkey_iamr_mask &= ~(0x3ul << pkeyshift(0)); pkey_uamor_mask = ~0x0ul; pkey_uamor_mask &= ~(0x3ul << pkeyshift(0));