From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbdEJXlS (ORCPT ); Wed, 10 May 2017 19:41:18 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:35969 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbdEJXlQ (ORCPT ); Wed, 10 May 2017 19:41:16 -0400 MIME-Version: 1.0 In-Reply-To: <20170510123458.fh3ef3c55y2wiu35@intel.com> References: <20170507175002.9558-1-jarkko.sakkinen@linux.intel.com> <20170509141353.klo7lilef4qiqfoc@intel.com> <20170509151308.GA13586@obsidianresearch.com> <20170510123458.fh3ef3c55y2wiu35@intel.com> From: Luc Van Oostenryck Date: Thu, 11 May 2017 01:41:15 +0200 X-Google-Sender-Auth: 1NdgfcGUi8onFZigcJtLTKtmQkk Message-ID: Subject: Re: [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap() To: Jarkko Sakkinen Cc: Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, Peter Huewe , Marcel Selhorst , open list Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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