Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp323071pxu; Wed, 7 Oct 2020 04:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv+k0VWRzwYeaOYepiZo4nTsXoEh0/tHkZ504fIqCR3UHvNqTrQCffL4ep9mq+8WnmhD8p X-Received: by 2002:a50:fe09:: with SMTP id f9mr3011241edt.239.1602069210379; Wed, 07 Oct 2020 04:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602069210; cv=none; d=google.com; s=arc-20160816; b=w317BMRB66bRVSP+K4vdMx+OgNgEdslRpIu13UbY5o/PWaiZASggQwu4ZOik2tAaim +agYsFFTSy0C5zszWZjqBnlyB9Rm97JsjCFArjHGIv7iKTG3oYC+hOoLHc/+lehSiNQr qFLpy1evX+LsOE32eipaTCxCgn48AVb5LP4BoI6umSOZ+OqJeXO3OzL5cuMmb0K0sGT1 6xnDUxQVGTx1cTVVgkre7r8Gp3VTx7ABEz14QkLCloLw/t+BstZzfuXj9rlvDcrAg0sa vNh5LNRbd5Dk6g3hI6bQOCau1fQnYOrNpSHq6Kb9xWvqHOpa4F/A8Nt0v44EgmysEtxC LKNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Lf/P2Oy395CbbqzZfz+3upWyzb/ArGllEIhvxB50hjo=; b=KE9Lr1VtwlCLmx/z15MCIJ/wRrTMLBC27iPFBz7jQ1YBPDSgp1L0Zti4m86tbMOLiX RP7XXcQLXEAZxnEGxHV93d9GR4EzkmDxgNjmwIjuMugbdUr/xmFttL/NND9N3ifKTVXc 973xP5luhHp0zCrwsB8FG2QbrqpTPrUj7GR1aG6mQrSR79FPBvIyAackGIO+VkRcv65P DL5jfVzew4eo+Rx3Cm1SeLcXwkZAj+QDxUA7cu1Kad3Th5TBz7OGk2WAo6SfuO6chGY7 oOX1yxjxfSohVh7o5vCDVz+bCCUr/JA7tig6hJvKB7TJihaaZX54kmUR39Ug0Yco/txV ntpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si1101726edl.534.2020.10.07.04.13.07; Wed, 07 Oct 2020 04:13:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgJGLCu (ORCPT + 99 others); Wed, 7 Oct 2020 07:02:50 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46048 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgJGLCu (ORCPT ); Wed, 7 Oct 2020 07:02:50 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kQ7DY-0007qH-4x; Wed, 07 Oct 2020 11:02:44 +0000 From: Colin King To: Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E . Hallyn" , Roberto Sassu , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ima: Fix sizeof mismatches Date: Wed, 7 Oct 2020 12:02:43 +0100 Message-Id: <20201007110243.19033-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King An incorrect sizeof is being used, sizeof(*fields) is not correct, it should be sizeof(**fields). This is not causing a problem since the size of these is the same. Fix this in the kmalloc_array and memcpy calls. Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)") Fixes: 1bd7face7439 ("ima: allocate field pointers array on demand in template_desc_init_fields()") Signed-off-by: Colin Ian King --- security/integrity/ima/ima_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c index 1e89e2d3851f..8884bbf03b43 100644 --- a/security/integrity/ima/ima_template.c +++ b/security/integrity/ima/ima_template.c @@ -216,11 +216,11 @@ int template_desc_init_fields(const char *template_fmt, } if (fields && num_fields) { - *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL); + *fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL); if (*fields == NULL) return -ENOMEM; - memcpy(*fields, found_fields, i * sizeof(*fields)); + memcpy(*fields, found_fields, i * sizeof(**fields)); *num_fields = i; } -- 2.27.0