Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3468253imm; Mon, 8 Oct 2018 04:39:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV63aGRAFJLr2M8FWCTefOyUSZ3zz5rVk6Ct2sKN8S3SGWDWoI1rtfYMU+5C4PMA27mBnrHb+ X-Received: by 2002:a62:6b0a:: with SMTP id g10-v6mr125219pfc.174.1538998796731; Mon, 08 Oct 2018 04:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538998796; cv=none; d=google.com; s=arc-20160816; b=B2BW97NefHqjpaAw2P+AdPio84bTQMl+JrWSuYZayZP1xfuZB52OUtPlyecEMMFofN 6BcUlLH5pWYtCbKt6Pvy7YpxsAHAfpr6GLC6wer7riZltq2rRNkHlG1fcNQwtwtpa6om jam7ZrJJNpNdhCgnUyfFdqwNKr/NwtL+9RfcK6kZcZaAQRxBaEuLLdWDR9JmySiEEDRR HZSwqLSMu8FZxYrGBsq9z+zBQUmbZ5O0ROx0xVAJky+zMgThGSzN5uqTSYepO9zivxJ/ JmNAlPhaXMseygF44Z3H8ftLPDHFZzgwVrnLh0olmOoF30xVRLXq0wZ63olpJJI/rttk LjWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=zME3rs+2xcyOm3rsFpLRMIfJQN8W+jcGL4qAhyQKjMM=; b=Mw48GrDjs++kgt3HH87+LjG8kklYGrfwXXpbk9xolK7CwZ0SqvsNtUiNUAYQZg9sFP rmAhFggGsXZaXvwfETvLYMsWQdv1j9FWa+Ld6cH4/S2IKB7Q/5kBqmSmn2OwwgV4uYR5 928I5fEFmq6U67cp9VScakVoK3uZ2cFqWRm/w3XkCYLesROAGwj/anJI2TKZ/3hk61Xv 3LjGop2todAr4nP50Lk/KalsQvGZ2FNkOO8cjooI7eicZEE2BIGJXGxpsAy0KgYQZfcH BY5Hl/HWenSq18NyeipIpYK9cYc0eWsKpLJUqcwr5PkxiyKm/w79Yz5GkMTZR5ILQAyQ i7iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HyotIFZF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4-v6si17162080pls.53.2018.10.08.04.39.37; Mon, 08 Oct 2018 04:39:56 -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; dkim=pass header.i=@linaro.org header.s=google header.b=HyotIFZF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbeJHSuu (ORCPT + 99 others); Mon, 8 Oct 2018 14:50:50 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:54092 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbeJHSuu (ORCPT ); Mon, 8 Oct 2018 14:50:50 -0400 Received: by mail-it1-f195.google.com with SMTP id q70-v6so10979379itb.3 for ; Mon, 08 Oct 2018 04:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zME3rs+2xcyOm3rsFpLRMIfJQN8W+jcGL4qAhyQKjMM=; b=HyotIFZFBQL1DwGXT9GI3Bp5ydInycDiW5q4kpnVyhvNiIih9ZvICAz91VB01L8ksM co71smwiWQrFNaREhxkl5chi3ykLkHVogEMkiypCjM3xfRMerF9PjwCjBC+RfRFdcciy AAkNfG5i52Movk7AMA2vT7rDOyqtKTJ9hFUD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zME3rs+2xcyOm3rsFpLRMIfJQN8W+jcGL4qAhyQKjMM=; b=tVyvJ/r6zYQuHK5RuHhKK/c8m5mni3Ax64SU4lUGEe6iYzU7ZRlcdfoopM2j/7Ch2T GuwkBxEDMIUO8SLYD8rYRhjYlq6Zi0EKWl/IoJekuFw127jmxwdAvkv/qsz/qWorSVsn F0x3moKrJmXyjd8O+j5XcyW3kbL59OfrJayt40WoodNFrsss7CR+t+gxsqt+Pru5IqvY e42EiBZHxhFTGpu/y4rPLOi14HXtA0G+6FMTB5hkXiqJs+6bJvwwK+JcPUxts+q2I/ef 3ytLZWvAVR7xcc4UJ7agEgcw3KAmHrEp/bvAer0RuXB7uluyRbs/21ca0tocIBu8O1km P0EA== X-Gm-Message-State: ABuFfogLBR+Div6vxT69iogoxqi4FPcqGCKqMD1c71rXqn3kxWn5O/AL fVmBm2ZybQ8ZpYuZGZ4n7sy1k8vQ7rsNyGtdlaB6bw== X-Received: by 2002:a02:b015:: with SMTP id p21-v6mr17934223jah.2.1538998770541; Mon, 08 Oct 2018 04:39:30 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:5910:0:0:0:0:0 with HTTP; Mon, 8 Oct 2018 04:39:29 -0700 (PDT) In-Reply-To: <20181007115810.27779-1-michael@schupikov.de> References: <20181007115810.27779-1-michael@schupikov.de> From: Ard Biesheuvel Date: Mon, 8 Oct 2018 13:39:29 +0200 Message-ID: Subject: Re: [PATCH] crypto/testmgr.c: fix sizeof() on COMP_BUF_SIZE To: Michael Schupikov Cc: Herbert Xu , "David S. Miller" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7 October 2018 at 13:58, Michael Schupikov wrote: > After allocation, output and decomp_output both point to memory chunks of > size COMP_BUF_SIZE. Then, only the first bytes are zeroed out using > sizeof(COMP_BUF_SIZE) as parameter to memset(), because > sizeof(COMP_BUF_SIZE) provides the size of the constant and not the size of > allocated memory. > > Instead, the whole allocated memory is meant to be zeroed out. Use > COMP_BUF_SIZE as parameter to memset() directly in order to accomplish > this. > > Fixes: 336073840a872 ("crypto: testmgr - Allow different compression results") > > Signed-off-by: Michael Schupikov Nice catch Reviewed-by: Ard Biesheuvel > --- > crypto/testmgr.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > index a1d42245082a..790aa3536631 100644 > --- a/crypto/testmgr.c > +++ b/crypto/testmgr.c > @@ -1400,8 +1400,8 @@ static int test_comp(struct crypto_comp *tfm, > int ilen; > unsigned int dlen = COMP_BUF_SIZE; > > - memset(output, 0, sizeof(COMP_BUF_SIZE)); > - memset(decomp_output, 0, sizeof(COMP_BUF_SIZE)); > + memset(output, 0, COMP_BUF_SIZE); > + memset(decomp_output, 0, COMP_BUF_SIZE); > > ilen = ctemplate[i].inlen; > ret = crypto_comp_compress(tfm, ctemplate[i].input, > @@ -1445,7 +1445,7 @@ static int test_comp(struct crypto_comp *tfm, > int ilen; > unsigned int dlen = COMP_BUF_SIZE; > > - memset(decomp_output, 0, sizeof(COMP_BUF_SIZE)); > + memset(decomp_output, 0, COMP_BUF_SIZE); > > ilen = dtemplate[i].inlen; > ret = crypto_comp_decompress(tfm, dtemplate[i].input, > -- > 2.19.0 >