Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5129692ybl; Wed, 22 Jan 2020 10:52:37 -0800 (PST) X-Google-Smtp-Source: APXvYqz0+aMWVdddcO50FWhkoxidmmPK+UdcqeOxVFWXQtPnGEiXx6a/ctRsow+vK/CRBYt/P0AK X-Received: by 2002:aca:4b14:: with SMTP id y20mr7504926oia.160.1579719157160; Wed, 22 Jan 2020 10:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579719157; cv=none; d=google.com; s=arc-20160816; b=K2y+I2+S5s22YcdOe5ahSiYclvSvjDoKA4zkuCDwXkT6xzI3kVPRNRiCIAl6cWSyho gC8LIE9XkPphdDX8BYBNBTBPsQjTt5VgH6oM9SV4pMX4zbtxNXkz4Frt1XsHfjYli9px 1WXsklg6J3ZRvA24L/+1lfLrelJ4S+MUcDGgyUisA5NKWgqCzmGWDFRfPjQTFu7ptKVd oeB+HhYCq4Uq6uuMC2gESSYDriyeJTo23Ulz81k2TZ1cmthFgBmduK1eN6Z5mN3AKiZd 44p0teWzAu/1XRRGqXjRtORon+gvN9oHlTK9TGQQARh8IYRHw+p2k2KGv3FGXQG0xn9Z GMHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ioinkAh+8hdBjKUdjvbPg5cD8nQTjz9Mvaag/O1Zfys=; b=AwGEFm9e2LY8Q1ys6klHlNM0vRDyyjPXKJxkTp4Ywrkdl/4Fb02Hwy3ciDO6pzy/ql N6qfjRy7NML11tV3RR8Nab2ORvBPNHWo6mFdjc5e3HDJK8fMnqWzYuDLrvggZt8bUEx9 NiADfoyL75THVMn5LmjtdxT/EKiR2xw9UtmfPu9dIUtC6AGyRRG3zhAXOkPYOho/PtKN vJ4hsLcBhSPEZIQcMH6ZobgDAng+IUlanL0gWm1X1TFMmSm4OjxRSkad87WbD5aWMo+/ Z5HtZmno6Vy4GWsQxhX3mPyvUHs51xp9iUA5z/bfQQ6G4D7Nt+w0wKQcDEKGaxG/Dh55 FpHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vRogBaF9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r22si21727269otn.192.2020.01.22.10.52.25; Wed, 22 Jan 2020 10:52:37 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vRogBaF9; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgAVSvP (ORCPT + 99 others); Wed, 22 Jan 2020 13:51:15 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44313 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgAVSvO (ORCPT ); Wed, 22 Jan 2020 13:51:14 -0500 Received: by mail-lf1-f67.google.com with SMTP id v201so369994lfa.11 for ; Wed, 22 Jan 2020 10:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ioinkAh+8hdBjKUdjvbPg5cD8nQTjz9Mvaag/O1Zfys=; b=vRogBaF9UTfXPjeHyGqb2gtDG1LjoYaZY5MYvVinMWT4Enta6ifi55KXyBM1f6wf+K hzUbXdLlAXo4+fD8QBq/QXemZ/JMV+HViaZXHtn+13vZrghRsZzK4yNrpoHc6xO9h5yo ly+JmalLEu2N71ldvZ9hR1NcG2U7LDTsO+qN9jNpjpMbSgn5dW7zhIc23MaJVAb0K/fn 1BJ8hkPDxblsltfCmuKQ8FXh7QlDIYNr1xzl1dSGAFLqRa4J4Z4aouyBmty/CDedTzJW F/V9BrBA2iiLpAxPywlG7hH09R7IkULMx8DO9C+FISntXZv/tTiHOPN9iPlIxNqE1q0M pzFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ioinkAh+8hdBjKUdjvbPg5cD8nQTjz9Mvaag/O1Zfys=; b=hFdpp/UfFPZvYyqKEZLvKOqHFsNMxhAxM7BVdyh/lOqr9mrT3Skk0KrEsP1zFwR9gY vPnxwpFO1VFO6vk0RULUveTZOaXFg3TrhI0hxwUk0xgws32m4aptmVFcKqD4aVDisMkh hzczIU4wltyA9vH20MXzQ9pEsSITmBvXFmCRHcc65Q2oIKf2c4es2rNMIViDTtldhtNV G+OPEK6luAbxiTvpc5m8lqZbH3Rl+zF74eri3tCoohRi3pItSvwkcIVf9BPGEDYw9x+F ibaNDUtp4Z85BdvxZ+GrL+1IuKqDoCGwTT7H+RZ0wrPSIldj1ggT0oIxssIwf6HBfvB1 laHQ== X-Gm-Message-State: APjAAAXK+dfi8bdEK3PMORDHgqNIXQvOQJKGAM/NxcvaU137dulqUfB1 8+sjFHJl2JwjXUcd1xuyq6w= X-Received: by 2002:ac2:5964:: with SMTP id h4mr2505320lfp.213.1579719072960; Wed, 22 Jan 2020 10:51:12 -0800 (PST) Received: from uranus.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id y194sm8736491lff.94.2020.01.22.10.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 10:51:11 -0800 (PST) Received: by uranus.localdomain (Postfix, from userid 1000) id 0CE4246180B; Wed, 22 Jan 2020 21:51:11 +0300 (MSK) Date: Wed, 22 Jan 2020 21:51:11 +0300 From: Cyrill Gorcunov To: Dave Hansen Cc: linux-kernel@vger.kernel.org, alex.shi@linux.alibaba.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, bigeasy@linutronix.de, pankaj.laxminarayan.bharadiya@intel.com, aubrey.li@linux.intel.com, dave.hansen@intel.com Subject: Re: [PATCH] x86/pkeys: add check for pkey "overflow" Message-ID: <20200122185111.GK2437@uranus> References: <20200122165346.AD4DA150@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200122165346.AD4DA150@viggo.jf.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 22, 2020 at 08:53:46AM -0800, Dave Hansen wrote: > > Alex Shi reported the pkey macros above arch_set_user_pkey_access() > to be unused. They are unused, and even refer to a nonexistent > CONFIG option. > > @@ -922,6 +920,13 @@ int arch_set_user_pkey_access(struct tas > if (!boot_cpu_has(X86_FEATURE_OSPKE)) > return -EINVAL; > > + /* > + * This code should only be called with valid 'pkey' > + * values originating from in-kernel users. Complain > + * if a bad value is observed. > + */ > + WARN_ON_ONCE(pkey >= arch_max_pkey()); Should not we rather abort this operation and exit with EINVAL or something similar instead of calling wrmsr with overflowed value? IOW, if (pkey >= arch_max_pkey()) { WARN_ON_ONCE(1); return -EINVAL; }