From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754504AbeAAPDy (ORCPT + 1 other); Mon, 1 Jan 2018 10:03:54 -0500 Received: from smtprelay0065.hostedemail.com ([216.40.44.65]:45015 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754117AbeAAPDu (ORCPT ); Mon, 1 Jan 2018 10:03:50 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: light06_40dd79e2081a X-Filterd-Recvd-Size: 1428 Message-ID: <1514819026.1967.37.camel@perches.com> Subject: Re: [PATCH] crypto: testmgr: change `guard` to unsigned char From: Joe Perches To: Joey Pabalinas , linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-kernel@vger.kernel.org Date: Mon, 01 Jan 2018 07:03:46 -0800 In-Reply-To: <20180101103319.fmmlpeg6kjdmhloq@gmail.com> References: <20180101103319.fmmlpeg6kjdmhloq@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, 2018-01-01 at 00:33 -1000, Joey Pabalinas wrote: > When char is signed, storing the values 0xba (186) and 0xad (173) in the > `guard` array produces signed overflow. Change the type of `guard` to > unsigned char to remove undefined behavior. [] > diff --git a/crypto/testmgr.c b/crypto/testmgr.c [] > @@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq, > char *state; > struct ahash_request *req; > int statesize, ret = -EINVAL; > - const char guard[] = { 0x00, 0xba, 0xad, 0x00 }; > + const unsigned char guard[] = { 0x00, 0xba, 0xad, 0x00 }; Might as well add static too