Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp132418pxu; Tue, 13 Oct 2020 19:12:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxia0XP6yKAArbmafpjMzvL7KYF0bdb2Cwn3/PtC5ibXHJxg+Ybi9S2n+enbEGG8Pvh80+Y X-Received: by 2002:aa7:ce18:: with SMTP id d24mr2855796edv.9.1602641544496; Tue, 13 Oct 2020 19:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602641544; cv=none; d=google.com; s=arc-20160816; b=w7LLxbRvn4E52Uk5I9rFZTiSWmXmq91g/H7/0RKBTcg70jS04lrmfkoBW+6KHgHFGR oNPFk3uwagrGp2u8izBe+VIMhGNVGkN+XMXpA8DYRyz1jItDlQFMmi5JxJUQQVkT8xQ+ qHFygVuUtD4UTede6G5p4mORnpl25BFOefybVH0B6NKldH3Lee9s5AiYWpsKBm2F4EMC AGTcm+U7k9XX8kS1clpkwHV/e0F5WNmrLZXWXHrfNwI3kCEboOKj9m1KVbWrf6eLhX7f Y84dHMEkLuR7qbHkLhVraf2Y8tXIpo4rBqHXdB9h9PXMEFOXndrKxsUUz+VgTPajooVM X+Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=43KFTvMcj9R4TfTFF056bycAVOaP1MHohC+0XnWqlbk=; b=LeWaaXUWmytLz9SqiIN2Mz2zY7j3iRahuq2rA90uLk+i28KTilNWHM+3w79jRCYtXK LJrRTlkMyjmLBRfrEWOqFAPO3aEcI0JMwY57g6EdtKlg7ZjZbr7CQyQsYmiL9wSvKfon PZ1kcU+tLpP0xXT9kV9dWdQ8mgdOv9SQQIUv90wimnUlvj46zASi2VgcsewD+/7HVl+1 4uVWZRFlFc8vm+FJIULpJZW6gzR8OgyTft79hMqH93gvlZLHujh3TBv47WdPKQ1eSS8B DI6MkAm96wmguftfQDmEvIcnFtxLtN+q6KcOsMTpy+f/VYxInYMHbsIzP7blG98i+BkG /2zQ== 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 z14si1095598edr.215.2020.10.13.19.12.01; Tue, 13 Oct 2020 19:12:24 -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 S2389705AbgJMQXy (ORCPT + 99 others); Tue, 13 Oct 2020 12:23:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58179 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389679AbgJMQXw (ORCPT ); Tue, 13 Oct 2020 12:23:52 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kSN5Y-0007Jb-4T; Tue, 13 Oct 2020 16:23:48 +0000 Subject: Re: [PATCH] ima: Fix sizeof mismatches To: Mimi Zohar , Joe Perches , 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 References: <20201007110243.19033-1-colin.king@canonical.com> <55ae0b6152c84013d483b1bbecb28a425801c408.camel@perches.com> <0ceb198a-a313-f542-49cc-c0b9f6b1ea52@canonical.com> From: Colin Ian King Message-ID: <047842e3-da9d-2dc5-6fa8-60cf6e9fe92d@canonical.com> Date: Tue, 13 Oct 2020 17:23:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/10/2020 17:17, Mimi Zohar wrote: > On Mon, 2020-10-12 at 19:10 +0100, Colin Ian King wrote: >> On 12/10/2020 19:06, Joe Perches wrote: >>> On Mon, 2020-10-12 at 13:51 -0400, Mimi Zohar wrote: >>>> On Wed, 2020-10-07 at 11:27 -0700, Joe Perches wrote: >>>>> On Wed, 2020-10-07 at 12:02 +0100, Colin King wrote: >>>>>> 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. >>>>> [] >>>>>> diff --git 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)); >>>>> >>>>> Maybe use kmemdup instead. >>>>> >>>>> if (fields && num_fields) { >>>>> *fields = kmemdup(found_fields, i * sizeof(**fields), GFP_KERNEL); >>>>> etc... >>>>> >>>> >>>> Thanks, Joe. Since this patch will be backported, perhaps it would be >>>> better to leave this as a bug fix and upstream other changes >>>> independently. >>> >>> IMO: >>> >>> This patch doesn't need need backporting as it doesn't >>> actually fix anything other than a style defect. >>> >>> void * and void ** are the same size. >> >> indeed, same size, it's a semantic difference *and* a style fix :-) > > Colin, based on Joe's suggestion of using kmemdup and his opinion of > not backporting this change, can I assume you'll address his comments > and re-post v3? Oops, I missed that email. Yep, I'll address that later today Colin > > thanks, > > Mimi >