Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4126549ybg; Fri, 25 Oct 2019 13:45:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoTSEaFDIJP+eGEOpNdb2sap7VdyGVP/J++gDmw2NWssbfn9t/Xld6oK3RVH5OA+D5qxYu X-Received: by 2002:a50:970e:: with SMTP id c14mr6287809edb.20.1572036314820; Fri, 25 Oct 2019 13:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572036314; cv=none; d=google.com; s=arc-20160816; b=pdWNh01oIyTQW4eZE2GywpwIvbx37iBeMa3dhA7MA35g5e7IFWOPAh+atJ47AD49b7 6cVcyrsMxfCHPTNw9hkAzi1RCIzXpstqBnUZSYaOfddFq+1XDc/4YFZ2F3XnytN6N6Qq cC6+yjbuJrIjTmZAalPM1o/xckv02yxCPt+Ev5c4CgmyHPMEYAVUPqsr4n0aYmZVNH1B weHzLMjRFBND4T69RLF4auxRHznWod2AxDkQfdAcYeB4+qcvwIbwVf7oEODy+jR1FuvM /Fglnp6F3CdhXp1AcrK279lnlleCMt39jlCznIdg7ZkWjzILND28ghtDi844A88Hvc2q ZGrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=OgpaEOi3NtTvH8dAdXEaqJn/1OjtmfuxmiFQB2mjN+g=; b=P+mfAmOIU7+W0H3eqw+TmmN4LVQj9hBNA6C5hcq8w1/Cfd3Z/2pdBktNa0p39l+iQr cC7n0GOKvVWy1mF78HyzLyljY2yp2yKHSQ2oTL7mHV9PsGXcothY7doSzcEOBDzMAxLe NgdSzCfIuMQ0IU5z0RgedXupAP+fPDlNxAM+J8HtVSYtmCdxl8oHmpTuC6zSXJF90WV6 8owvOL2ycD2XkkHLmZjkzfwIIF6gyTdhYctWZL0DDsOGUSuQFj2Q58TiJmtkirELVUR+ DZb9lrOY3/JAUh4X1PykuWrthAsl5CJWrg5pvAawZw1GBTPBhFOLMz3PkoLW6IjrAicO yMeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ZG+7BShM; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si1784967ejr.125.2019.10.25.13.44.51; Fri, 25 Oct 2019 13:45:14 -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=@linux.microsoft.com header.s=default header.b=ZG+7BShM; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393785AbfJYQCt (ORCPT + 99 others); Fri, 25 Oct 2019 12:02:49 -0400 Received: from linux.microsoft.com ([13.77.154.182]:39564 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730061AbfJYQCt (ORCPT ); Fri, 25 Oct 2019 12:02:49 -0400 Received: from [10.137.112.108] (unknown [131.107.174.108]) by linux.microsoft.com (Postfix) with ESMTPSA id 167462010AC4; Fri, 25 Oct 2019 09:02:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 167462010AC4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1572019368; bh=OgpaEOi3NtTvH8dAdXEaqJn/1OjtmfuxmiFQB2mjN+g=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ZG+7BShM7Zs+mQe8xyrHK3yGYcucqlMeIramEfEZ1sTdU9sg8hPD0fYRb6sPTmWOE mfuzyQAWb2eGe7bxnNeeHBCOX5WDqTnqNjsV8KOUmQJyoHqYr5+3BSb7PCe/79h6cs un5CwwbPOuujsxZ9OErVRUI0EgJ/VAIxSVOFu1K4= Subject: Re: [PATCH v5 4/4] powerpc: load firmware trusted keys/hashes into kernel keyring To: Nayna Jain , linuxppc-dev@ozlabs.org, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ard Biesheuvel , Jeremy Kerr , Matthew Garret , Mimi Zohar , Greg Kroah-Hartman , Claudio Carvalho , George Wilson , Elaine Palmer , Eric Ricther , Oliver O'Halloran References: <20191025005839.4498-1-nayna@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: <5be98aad-66b9-2549-2772-ef30aa1275b4@linux.microsoft.com> Date: Fri, 25 Oct 2019 09:02:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191025005839.4498-1-nayna@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/24/19 5:58 PM, Nayna Jain wrote: > + > +/* > + * Get a certificate list blob from the named secure variable. > + */ > +static __init void *get_cert_list(u8 *key, unsigned long keylen, uint64_t *size) > +{ > + int rc; > + void *db; > + > + rc = secvar_ops->get(key, keylen, NULL, size); > + if (rc) { > + pr_err("Couldn't get size: %d\n", rc); > + return NULL; > + } > + > + db = kmalloc(*size, GFP_KERNEL); Is there a MIN\MAX limit on size that should be validated here before memory allocation? > + if (!db) > + return NULL; > + > + rc = secvar_ops->get(key, keylen, db, size); > + if (rc) { > + kfree(db); > + pr_err("Error reading db var: %d\n", rc); > + return NULL; nit: set db to NULL and return from the end of the function. > + } > + > + return db; > +}