Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7768989rwl; Fri, 30 Dec 2022 14:26:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9/Xi3TwIRwvsXMAbEUjaQeajOZK9lq47IEqMpbGsfWzJUjY513tSTB73Q+WzixJztQpEg X-Received: by 2002:a05:6a21:3a87:b0:b3:9815:4d83 with SMTP id zv7-20020a056a213a8700b000b398154d83mr16126687pzb.46.1672439173332; Fri, 30 Dec 2022 14:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672439173; cv=none; d=google.com; s=arc-20160816; b=F4yvP/sA8Xpx592SyPD7YHERoeXINK9pfZWhD7Soy5veVUucWvv+2RSA4aVLQDQAJS HZiM4ONqV81U6vmFiUBmpikMH2q2REL2Pu/dqF3VoChNV6tjb0LcwEBB5s7I0+kHon1k pAkNvYZ9EjXpVg5QuMfUtxQAFogRCzmd/EeNpdNu+/Hz3+uaEXJ4brRyR+Dg1hes8ww2 e8sjDPKtgPBvWHuLVvQsR+Ap3MFNT13nZDGkXubn771vPyhcPeRDidRpoTbig4GrobIS aNyXW+FnKKixPGTclIusoHThnBSvVPCDZGl36NHoMU+h2MX4s7FR5YiEw6RRZD4FjPMS xdmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=i2Eiv94gXUiZTv5jAScVh7PDfObsExkg3yzW4Xpf6ec=; b=LdQp0h6s9zoraV36FC/FfBBW7oL4m4EyYYAUD6aS42i1IoybZVXGTsVENhXpXJNTIl VYHtniJC6SqAZZ88JXMYQYYIpcFg5sq9/0/kZpJQUmzlRADpvepII9hl3t7dO6QLZFtH Eza3YigFVSdkTlpHsKCyMLoA5c9j334fDlnpplo8gGVNRKImdyKpWGwkxiLWrGaH06oU rVJTlPRcsJhBjVPHPbhGypNs0rjXDqKK3zWQPHA1BAkYr9xUJh/HEDUSuNCQ3WLJmESg qoI5azZpjUesnWoorCCUhdX/5P3A7gqDSZad6dQxeQhZj0N8RBvXZ6fmeUe8JUvQvLJv rxIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fNbGZ4QS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a056a00130900b00566a131ea12si22631852pfu.289.2022.12.30.14.25.54; Fri, 30 Dec 2022 14:26:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fNbGZ4QS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235445AbiL3WSw (ORCPT + 99 others); Fri, 30 Dec 2022 17:18:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiL3WSu (ORCPT ); Fri, 30 Dec 2022 17:18:50 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A261D0D9 for ; Fri, 30 Dec 2022 14:18:48 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id x26so8969124pfq.10 for ; Fri, 30 Dec 2022 14:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=i2Eiv94gXUiZTv5jAScVh7PDfObsExkg3yzW4Xpf6ec=; b=fNbGZ4QS1HISSASq84ExMqyKXBgayNGI3wh9FOogNgn/9U4PUJa6k3MDw4iJDpXDVw g33v+aBkLjcDNP/0V7iywo0w0E47ArN7b3gQ/yic61BeaRtixcmGCjhk//+k+3KMaqQh 4/wwEkgdUgbmwoF9QKdQFSjS21IH00hHfftRf6FLMNqBOhhsEGlUIFrk1K2rFoPEDFh0 5Fi5ZvJmHMgM5y7KanqjryE2NtPrfMAn1zVI5ye17I9mj5mBBuzlOJai3YxoCtIKg4N1 kTe940rRMu4WeEvQ9vbYxbDd37jjZSp8mN+2Em0iy7ZjOV4VmRj8eyJA6k8BcBa0FRri PoSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i2Eiv94gXUiZTv5jAScVh7PDfObsExkg3yzW4Xpf6ec=; b=Ig3JoVr8PeUi7Sp6uXlLTOmF3O/tW1HMpTcA6kn7emrh44mZMf05zw3w3l2qPapmOL dSIKUbLYAzwxofcEIe41e/idyPAFt8+61h+DROZaVC7kKHhYUWrizpc0RyCoTeI4XV4/ fW3luBluigssnbQfs3AWtq8aXEMxuLjAlq+QcTcXfH0yjpQ4aiDXENLWJTJ4UejVBlyI 3I1RgxL5on/PhCL8Ik+q4xCWFIabT7zi4QKTQAUSQoZ9RODHyYTK5qlfReaFzIcxfPBR vmwAucJHXYhlL3S2B1IAdmcb2cx4aEAaOCCX3zj00742yf+RchF99P3LDMWbBcxPOAaa N+Uw== X-Gm-Message-State: AFqh2ko1fOeH5/de28s0mQEQQNxTh3xUzxn+fOLptqfXzB8HKtMx+h1P QmlAcxlsTT58h4/qgxMWeZn0ug== X-Received: by 2002:aa7:8084:0:b0:574:8995:c0d0 with SMTP id v4-20020aa78084000000b005748995c0d0mr2652914pff.1.1672438727649; Fri, 30 Dec 2022 14:18:47 -0800 (PST) Received: from [2620:15c:29:203:8954:8b68:67ce:a964] ([2620:15c:29:203:8954:8b68:67ce:a964]) by smtp.gmail.com with ESMTPSA id c21-20020a621c15000000b00581498190efsm8267889pfc.161.2022.12.30.14.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 14:18:46 -0800 (PST) Date: Fri, 30 Dec 2022 14:18:46 -0800 (PST) From: David Rientjes To: Herbert Xu , "David S. Miller" cc: Peter Gonda , Andy Nguyen , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, John Allen , Tom Lendacky Subject: [patch] crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID2 In-Reply-To: <826b3dda-5b48-2d42-96b8-c49ccebfdfed@google.com> Message-ID: <833b4dd0-7f85-b336-0786-965f3f573f74@google.com> References: <20221214202046.719598-1-pgonda@google.com> <762d33dc-b5fd-d1ef-848c-7de3a6695557@google.com> <826b3dda-5b48-2d42-96b8-c49ccebfdfed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org For SEV_GET_ID2, the user provided length does not have a specified limitation because the length of the ID may change in the future. The kernel memory allocation, however, is implicitly limited to 4MB on x86 by the page allocator, otherwise the kzalloc() will fail. When this happens, it is best not to spam the kernel log with the warning. Simply fail the allocation and return ENOMEM to the user. Fixes: d6112ea0cb34 ("crypto: ccp - introduce SEV_GET_ID2 command") Reported-by: Andy Nguyen Reported-by: Peter Gonda Suggested-by: Herbert Xu Signed-off-by: David Rientjes --- drivers/crypto/ccp/sev-dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -881,7 +881,14 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp) input_address = (void __user *)input.address; if (input.address && input.length) { - id_blob = kzalloc(input.length, GFP_KERNEL); + /* + * The length of the ID shouldn't be assumed by software since + * it may change in the future. The allocation size is limited + * to 1 << (PAGE_SHIFT + MAX_ORDER - 1) by the page allocator. + * If the allocation fails, simply return ENOMEM rather than + * warning in the kernel log. + */ + id_blob = kzalloc(input.length, GFP_KERNEL | __GFP_NOWARN); if (!id_blob) return -ENOMEM;