From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932304AbdEKKRA (ORCPT ); Thu, 11 May 2017 06:17:00 -0400 Received: from mga09.intel.com ([134.134.136.24]:59161 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932258AbdEKKQ7 (ORCPT ); Thu, 11 May 2017 06:16:59 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,323,1491289200"; d="scan'208";a="1167750434" Date: Thu, 11 May 2017 13:16:46 +0300 From: Jarkko Sakkinen To: Luc Van Oostenryck Cc: Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, Peter Huewe , Marcel Selhorst , open list Subject: Re: [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap() Message-ID: <20170511101646.556aoezp77wlcrw7@intel.com> References: <20170507175002.9558-1-jarkko.sakkinen@linux.intel.com> <20170509141353.klo7lilef4qiqfoc@intel.com> <20170509151308.GA13586@obsidianresearch.com> <20170510123458.fh3ef3c55y2wiu35@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 11, 2017 at 01:41:15AM +0200, Luc Van Oostenryck wrote: > On Wed, May 10, 2017 at 2:34 PM, Jarkko Sakkinen > wrote: > > > Arithmetic should work but it's not a good practice to do additions, > > substractions or multiplications in any other byte order than the CPU > > byte order. > > > > sparse also complains about this. > > > > /Jarkko > > Arithmetic should work? > let's try with 0x0080: > in native order: 0x0080 + 0x0080 = 0x0100 > in reverse order: 0x8000 + 0x8000 = 0x0000 != swap16(0x0100) > > Or do I misunderstand what you mean by "arithmetic should work"? > > -- Luc Van Oostenryck I was referring to the specific code snippet in tpm-interface.c. /Jarkko