Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2772197imu; Mon, 19 Nov 2018 05:58:57 -0800 (PST) X-Google-Smtp-Source: AJdET5eIi+JflWt/gg8eK9SxgzXaennChh5CCWKr7G8eOxVpHQOjdlSQU9A2co7GgoEl/l6BNs1I X-Received: by 2002:a63:9dca:: with SMTP id i193-v6mr18785507pgd.98.1542635937297; Mon, 19 Nov 2018 05:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542635937; cv=none; d=google.com; s=arc-20160816; b=sy/KAyFPZ271YEMHsGBrPUe9pQTylVx7p0QRxTK5I9ABqqfPwQRpY2qiYreZyLA+mb 4oBaIFDJNBQs0bpWKaiitOuyfg7BHMMvUKEbFgY1o9nCVqN4eZylHJaN/msm1ovB++rt aAwzVQQUB/bhN6ye6YkXsSNGAfM3ETN3o07gHc2NjfYVKuXX6RpXQZVDkcR3SiVZjQeU +eL/ahaTq3IXCgTvflLLEbRifd3qdqJ3hrOffaf9+hrFV8kT0ulnzCCZlIWo0mTPa6hW ByMOmcHLicaclyq21+FErKrszPHD06x1PLyeXenZ+juQ+lNMIgMH2QaGuitQUnNSfhvr l6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=F6Zp3KNgpYH9cfsTyk9vtjdjyC9L+sgH3FGSrj9laDg=; b=wdX27dUOnNw9Q7ezXmBW01lSQqmwudqP7rK+27B7tGYY0igZjsiGU4R2lDnHLTnyK8 0nS5C0auDtRFqoPaVPNXP8ISl6MdmcZAqGihZsI/wKsxbCQaoBaUgUOdffftAHprhKet WFcC6F5s5dconrP8rQjS4ySdcmkiJdS0ZigyaE3iGxqBTvW9bIFoCYp9mxSWi6ibk0Zz C0Xz6riuQlaHuADZiG4GYxIb9sgaA+mFNo3JFBMB9HSCtYJ30XIY4XRDwe5BxJuRmPLs wteDaUAohCApbMPm/DQK9kcJp2YtL/r9qkULbpHBrAXnTD3gkfgz6xHKGJMWPLJ8H0+y A1rg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x142si39241929pgx.202.2018.11.19.05.58.41; Mon, 19 Nov 2018 05:58:57 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729378AbeKTAVp (ORCPT + 99 others); Mon, 19 Nov 2018 19:21:45 -0500 Received: from mga06.intel.com ([134.134.136.31]:8070 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbeKTAVp (ORCPT ); Mon, 19 Nov 2018 19:21:45 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 05:58:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,252,1539673200"; d="scan'208";a="250905002" Received: from tmuluk-mobl4.ger.corp.intel.com (HELO localhost) ([10.249.254.135]) by orsmga004.jf.intel.com with ESMTP; 19 Nov 2018 05:58:01 -0800 Date: Mon, 19 Nov 2018 15:58:00 +0200 From: Jarkko Sakkinen To: Tadeusz Struk Cc: jgg@ziepe.ca, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] tpm: add support for partial reads Message-ID: <20181119135800.GE8755@linux.intel.com> References: <154239067364.2880.13752725056462237016.stgit@tstruk-mobl1.jf.intel.com> <154239071144.2924.17574189056250189697.stgit@tstruk-mobl1.jf.intel.com> <20181118074832.GG5897@linux.intel.com> <90072f09-6388-b1f7-387b-42f056f8893d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90072f09-6388-b1f7-387b-42f056f8893d@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 18, 2018 at 07:05:19PM -0800, Tadeusz Struk wrote: > > When ret_size < 0? Shouldn't this be just "if (!ret_size)"? > > What we want to check here is if ret_size is positive, which is a valid > value, or if it is negative or zero, which is an invalid value, so in > this case (!ret_size) will not work. Please explain a scenario where "!ret_size" would no work given that both size and partial_data have always positive value? > >> /* Holds the resul of the last successful call to tpm_transmit() */ > >> size_t transmit_result; > >> + /* Holds the count how much of the response is still unread */ > >> + size_t partial_data; > > I'm otherwise happy how this look like but why call it partial_data. > > You cannot really tell from the name anything about its contents as > > data is very abstract term. > > so I will rename these two to response_length and response_length_rem, > how does this sound? Yes, assuming that there would be a hard requirement to even have two variables in the first place. > > BTW, why you need the new variable anyway and not just decrease the > > variable where the length is original stored? > > We need to have two variables, otherwise how do we tell if some part of > response was consumed to allow sending a new command? I don't understand. In order to maintain backwards compatibility you can send a new command at any time. > The transmit_result is used for that. If it is zero then one can transmit > a new command even if the whole response is not consumed. The new variable > tracks how much of the response is still to be read. AFAIK you only need to track the latter, not both. /Jarkko