Received: by 10.213.65.68 with SMTP id h4csp208900imn; Mon, 26 Mar 2018 19:28:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELsUzGfZwe2J8NmDMdmmla3RVgbp0hOqgLrUokDlV/sdmIwUpFSskt8b5GNJxo+qUqXkSE+2 X-Received: by 10.167.129.136 with SMTP id g8mr11931536pfi.19.1522117739794; Mon, 26 Mar 2018 19:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522117739; cv=none; d=google.com; s=arc-20160816; b=ZaHD/KwvwmMOUw7wZ1Sc/E8dXGwU8fMTVAfv0HuNKZE/5Nxwtgq60AMMs2PG53bJDh 7mr+9Z3YKYBgTmQN1GVZQADRahjhyl43jFaeg3wmHL9MM/gTjOXLJSU1t0dDOX5CDNG4 bfg6YVHM8vXn46ZQqi2+mhH9mRA6afQElvkQSdTfL0T61Qm6eUpWszmJ/4HvLBSk6/FT D+BbqqW/ZdxapL+yHkoU2F/+PmmmEbJ8ostPnSKO6VlgqQL6ImulINc/GdqK3WS2EbQb b1fw2ofWkyKRqqX05cjDHQGprC1Elz+IXQHm0zL4jYZKcwYXSW+NeGZ4HZ4mhDI5Ny8R N7kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=O3prudtf76bn2RYKHN1y5+sLGnm1Ou60LXtZhSuJEWc=; b=mFBj7jtT98KM/LYQK+xr59PR9TXm0vt7eJ0vzTbxiB9mnHkBzSjM4CPwqfJ9RIUpaj Hqz7u5uBft2A6p4z74Z8XqeJaRV+tMabgzeCVD+RXaWxRAIsU+N64nPz7j8zxG0IAuoH zPWDTPwwacPd+jvIBNsos5F1HEDECNZhLaa/mMm85L3VlvQ6rQly2YcTC5Y+suJQcGMb WT8rYNAoj37tEn33dszwAJ02MZ0Af9EQ7O7nW2uB8EHSSurs1UdZr+M9vyzlvcu965+d O73RRyr5HgUd37hYwcNPQ5xYqdgcm1Zo9Jk7uU2t7Pf8hf55L4h+hspUnstD47Ccch+h YsOQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16-v6si120218plo.358.2018.03.26.19.28.45; Mon, 26 Mar 2018 19:28:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752526AbeC0C1b (ORCPT + 99 others); Mon, 26 Mar 2018 22:27:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33302 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752480AbeC0C1a (ORCPT ); Mon, 26 Mar 2018 22:27:30 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2R2OTIS131392 for ; Mon, 26 Mar 2018 22:27:29 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gy7qa2rjb-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 26 Mar 2018 22:27:29 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Mar 2018 03:27:27 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Mar 2018 03:27:24 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2R2RN5S262538; Tue, 27 Mar 2018 02:27:23 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D212452047; Tue, 27 Mar 2018 02:18:40 +0100 (BST) Received: from ram.oc3035372033.ibm.com (unknown [9.85.192.202]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 01A7C5203F; Tue, 27 Mar 2018 02:18:38 +0100 (BST) Date: Mon, 26 Mar 2018 19:27:18 -0700 From: Ram Pai To: Dave Hansen Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, dave.hansen@intel.com, mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org, shuah@kernel.org Subject: Re: [PATCH 1/9] x86, pkeys: do not special case protection key 0 Reply-To: Ram Pai References: <20180323180903.33B17168@viggo.jf.intel.com> <20180323180905.B40984E6@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180323180905.B40984E6@viggo.jf.intel.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18032702-0012-0000-0000-000005C3936B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18032702-0013-0000-0000-0000193FCB90 Message-Id: <20180327022718.GD5743@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-27_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803270024 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 11:09:05AM -0700, Dave Hansen wrote: > > From: Dave Hansen > > mm_pkey_is_allocated() treats pkey 0 as unallocated. That is > inconsistent with the manpages, and also inconsistent with > mm->context.pkey_allocation_map. Stop special casing it and only > disallow values that are actually bad (< 0). > > The end-user visible effect of this is that you can now use > mprotect_pkey() to set pkey=0. > > This is a bit nicer than what Ram proposed because it is simpler > and removes special-casing for pkey 0. On the other hand, it does > allow applciations to pkey_free() pkey-0, but that's just a silly > thing to do, so we are not going to protect against it. The more I think about this, the more I feel we are opening up a can of worms. I am ok with a bad application, shooting itself in its feet. But I am worried about all the bug reports and support requests we will encounter when applications inadvertently shoot themselves and blame it on the kernel. a warning in dmesg logs indicating a free-of-pkey-0 can help deflect the blame from the kernel. RP