Received: by 10.213.65.68 with SMTP id h4csp442346imn; Tue, 13 Mar 2018 09:10:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELuiWHp+38cG5u9NvSpfo7N0nKFwsfr+YK32fbGM0J8OMaVjkCP3o+8uQFR59ME5ojOUUU1Z X-Received: by 10.98.215.81 with SMTP id v17mr1156201pfl.110.1520957437279; Tue, 13 Mar 2018 09:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520957437; cv=none; d=google.com; s=arc-20160816; b=NYPnEnJJj9wODhSkdkFgMkht2CJjgtSqr62IiFtLNUTVIzLhnpu86ayI6YMgus98vY 3caywcHO9KF4f0miiQad9iMezSMK5QqbNW3jO4xPk2Aroy9Rp7p5xC1ZuKQ0R2G1r7yK +2lHXg7wGe0FH1EZNjNifaF4kLyCFMBOqbhRXE7llMBmeP/KZArUomEfgg/zh6lJAK/c joiwOlj8H17wU+ZmSAUmuna5XiNI8YrNAtFTb1lolObUj/pjNC5QD3BnCzsPO1u9dm39 OdAKqGF9Mn5o9JiZEgjttvYsfW54hzyzRAA8EicRrbfZgS64ah+1awj/K8FBlfSOL0do UDlw== 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:arc-authentication-results; bh=LsAelw7jZmvwW6zBZ9Y9Us1BR8QGp9fm+XNn1WJjqcs=; b=V29Gu20OfxKVqXl+B7JXRWE646kaowbq+Y19ZJV/43yqJC2ZiyNNM/ZsjSYaKzmK8g TEDOBtzhbCpi8JYgjAlgktsO0DaVCnrhvpENb20LUSWMBmNcs5DLCEIlHXcl0mtNFk2i Qtjq7ll3F6XzPBiMGZqTJp96EbjqN+dZHN+p5qJ9qMeu4nwR6mNonPS/zQN8EpQ/9Ppa UdeT5KPsJww9SXo99SnLnLy8cbb1SzxXlb8bMuewWZIMQ3DDq3MJYTEEHuw+/uDD1o7l SOWzvi6m/S0TaPcbje99uH9qriupCPvRLFt0nDMOA/TJpFpUqTklab8KUdDMMc9O1uSX QS+Q== 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 c7si285753pfi.323.2018.03.13.09.10.22; Tue, 13 Mar 2018 09:10:37 -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 S934346AbeCMQJb (ORCPT + 99 others); Tue, 13 Mar 2018 12:09:31 -0400 Received: from mga14.intel.com ([192.55.52.115]:37732 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbeCMQJ2 (ORCPT ); Tue, 13 Mar 2018 12:09:28 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 09:09:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,465,1515484800"; d="scan'208";a="37841470" Received: from sbauer-z170x-ud5.lm.intel.com (HELO sbauer-Z170X-UD5) ([10.232.112.135]) by fmsmga001.fm.intel.com with ESMTP; 13 Mar 2018 09:09:26 -0700 Date: Tue, 13 Mar 2018 09:44:17 -0600 From: Scott Bauer To: Jonas Rabenstein Cc: Jonathan Derrick , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] block: sed-opal: ioctl for writing to shadow mbr Message-ID: <20180313154416.sgptuw7jcn7l76vn@sbauer-Z170X-UD5> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 02:09:01PM +0100, Jonas Rabenstein wrote: > Allow modification of the shadow mbr. If the shadow mbr is not marked as > done, this data will be presented read only as the device content. Only > after marking the shadow mbr as done and unlocking a locking range the > actual content is accessible. > > Signed-off-by: Jonas Rabenstein > +static int opal_write_shadow_mbr(struct opal_dev *dev, > + struct opal_shadow_mbr *info) > +{ > + const struct opal_step mbr_steps[] = { > + { opal_discovery0, }, > + { start_admin1LSP_opal_session, &info->key }, > + { write_shadow_mbr, info }, > + { end_opal_session, }, > + { NULL, } > + }; > + int ret; > + > + if (info->size == 0) > + return 0; We need to bound this to some maximum. I assume we'll at some point come across a controller with crappy firmware that wont check this against the MBR Table size and the user will either brick their drive or overwrite their data. We can get the size of the MBR Table it seems but I'm not sure how hard it is to pull that table yet. TCG SAS 5.7.3.6: The size of the MBR Table is retrievable from the "Table" table of the SP that incorporates the Locking Template. As always the TCG spec is super helpful /s. I will see how todo this and if it's worth it. > diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h > index 0cb9890cdc04..c2669ebff681 100644 > --- a/include/uapi/linux/sed-opal.h > +++ b/include/uapi/linux/sed-opal.h > @@ -104,6 +104,13 @@ struct opal_mbr_data { > __u8 __align[7]; > }; > > +struct opal_shadow_mbr { > + struct opal_key key; > + const __u8 *data; Please use a u64 here for the data and cast it to a pointer in the driver. We do this so we do not have to maintain a compat layer for 32 bit userland.