Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5164905ybl; Wed, 22 Jan 2020 11:31:30 -0800 (PST) X-Google-Smtp-Source: APXvYqy3KtT0887KHTTyx3Zhw8gi0g9OkOQvVYtt7Fk9wftj00iFL3scT8SMt1hlpaT8c6jnC5MW X-Received: by 2002:aca:8d5:: with SMTP id 204mr7747692oii.141.1579721490471; Wed, 22 Jan 2020 11:31:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579721490; cv=none; d=google.com; s=arc-20160816; b=v8snLJEVHaN4/w0zHEq1VWOX9QYCMWfUp27uVcI5C9nvp9wx3m3+13nhxH2L4+gcsz vEFmLwvBRSmnnqc4ZoGmgqoLbjBzpW9V0heZ06+3IMk06uthRjgUu+nEnMByAQhKpJSI ZgAa7244DGFANBfolVWSH6iZUg/wtF3vtdD0JzZxdiF5WyMzUXk3r+b+u5D5RoOz+tsi IUW1I1/+zguE3kStEbvzKalPduSe1IDuQ+JuVYtdJvUmyHTc/mbDxJJ0jaO/gA28Orgv BiRePXXBTKv1B+EyFX28EuEyjb8Ni5+cbi0qIIHIz0swNGNlP4ypyTQkyMai/4+2si9T +eqA== 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=/8PhwQ7PARQ3iAPf2q6hZ8qBDbIwXVdDfMoRjqypk98=; b=1K+axcqaFGhLhulJHDijTIZwweeq9tIndM10oeewP7YBi27+73Wf06PbGRhynbvl7a 4wJ0hNTYdb54h4s4rY1C0Qg9z4snxPUH4tRNQD4eJ++Y2WjKXViTeKZN2bo0CTbMNAKF 8U5OrlYyDkt6UDT/l4Ju1+1W2dRSRW8fyIbfcnDsragjadFtK4MzuqxwhvxT3pKWtyNt YCEMqb98EL+2Xjxn2ZJXyS2Qyu9urSKY+fOhyi7iWqPFu/rXv6JnAf8IUCPHNdCdUoqD k4+Gk9pENkBU+Q3nYV/PzC1QpSm51FMeq3OnKJ5XA2NqHv3D3XacyI73heeWTHXotE/B UfHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VCvThtJv; 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 o15si23028636otp.314.2020.01.22.11.31.18; Wed, 22 Jan 2020 11:31:30 -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=VCvThtJv; 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 S1728205AbgAVT3s (ORCPT + 99 others); Wed, 22 Jan 2020 14:29:48 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34982 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbgAVT3s (ORCPT ); Wed, 22 Jan 2020 14:29:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id j1so353973lja.2 for ; Wed, 22 Jan 2020 11:29:46 -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=/8PhwQ7PARQ3iAPf2q6hZ8qBDbIwXVdDfMoRjqypk98=; b=VCvThtJv4iskIOTDyB9qsKIzrebzj7NOZKES1kA/7kGsmEoslzuSc4Y0CEusiLFbfl sJq/RASWZ8dtWjqJQsZTpblBu+LqE9E1y6RAK2kVXxfN135JczX8ersybzLckQwUBqnS 1Tikd506F0Ssgrvngx2P5XxR7FD+UHnpS6x0+USCjinW6ajxGUQIZa1UI45NP3tMnHro 2mbz16dMb4OhnegNSThBC9CEf/O+BjtdPFN3FefK0ibTxi6O/wkMLwLnHoooYwyciHqV dvzaXwKhS+Pwgv0aQfiMNHynikhdfoHRDALhRvkeq9URmdzyo7jaVNf6bWmC6RF9UOTU 5ZTA== 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=/8PhwQ7PARQ3iAPf2q6hZ8qBDbIwXVdDfMoRjqypk98=; b=hwInYg0CzHqUTflJ7wUxLZjB22SOkJcUIG+AO4vZgma/PRspBORsJwScrgsgkwrJQ2 eh96GbObMp7U/Z812br1EQmjT4sii3m1mPXvhiGX0Unc8TkLZ2rzqG86UKPR5/1GIiKl rAfbN9AWJoMW3plHnosZwit15GHPYGU0sQ6dOrsfs5b/WCgnnqataKlalI9EgrhawUUL lzc/7uB4YDFEwWzasnGkI+r2Lk4y7O+3tklGZYF5oMEbt4vd6hSo25cRXHdppdBEOkiC z/fMN/Quq2hZM+beMI4FT374jMmfJHH0IIxyQ3r+/qW97btKI8tDftwrdf19ZlbpHXnK oGEA== X-Gm-Message-State: APjAAAUMdrjqbfnFpNv8LK/mebOVskqrFzSTIIybXwBPGRRtE6Q+QTz/ XOGuPCTr8/VBeesHlPLidM5EOCrCGQ8= X-Received: by 2002:a2e:943:: with SMTP id 64mr20475535ljj.17.1579721385988; Wed, 22 Jan 2020 11:29:45 -0800 (PST) Received: from uranus.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id y23sm20854173ljk.6.2020.01.22.11.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 11:29:44 -0800 (PST) Received: by uranus.localdomain (Postfix, from userid 1000) id 2814446180B; Wed, 22 Jan 2020 22:29:44 +0300 (MSK) Date: Wed, 22 Jan 2020 22:29:44 +0300 From: Cyrill Gorcunov To: Dave Hansen Cc: Dave Hansen , 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 Subject: Re: [PATCH] x86/pkeys: add check for pkey "overflow" Message-ID: <20200122192944.GL2437@uranus> References: <20200122165346.AD4DA150@viggo.jf.intel.com> <20200122185111.GK2437@uranus> <99b572a5-6a98-d22a-01f1-8bab60e96155@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99b572a5-6a98-d22a-01f1-8bab60e96155@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 11:09:47AM -0800, Dave Hansen wrote: > On 1/22/20 10:51 AM, Cyrill Gorcunov wrote: > >> + /* > >> + * 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; > > } > > I don't feel strongly about it. The reason I didn't do that is to > minimize the chance that this would cause any functional regression. OK, I don't mind leaving just WARN_ON_ONCE. > > It's not a huge chance, but I've certainly fat-fingered my share of > off-by-one bugs. Heh :)