Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1656442iob; Thu, 19 May 2022 11:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLEOewouV1hTAd5NetLokTl9oH1x9hVo5SYuo0VxotpMguTfeW5k0rv+9i6icJIZxG33OO X-Received: by 2002:a17:90a:17e8:b0:1df:4e82:a7aa with SMTP id q95-20020a17090a17e800b001df4e82a7aamr7082143pja.4.1652984048017; Thu, 19 May 2022 11:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652984048; cv=none; d=google.com; s=arc-20160816; b=WKIxXbvXXN/xi/hF5xhPY1cCMBB/u3dbU4O1Spxqamy/jLOMMyOWi9No3JHXt+nk+P 3T9+n0AIxDqZiDFV+GHTqjQTmtx1iMz2U9XD8ygvzoN1/phIIG8h1pMqquWkqp2/jAqs 9ioozed0G4F3w8wy0MyGbTf8q32cOGgjIBVYhlw6No3S6XAT9ef8EO2VxIrJIZ1x6mYK wh3+b2K+KdcP3Uhh8UR6qmf/qE23Lxo7WImWfeV5gDtpchAqOn+USNDnWGoEECbjMSgM K5TrHltxgn2W7+hO3uo8vTN9QT2EQQAkDdAyKhEKcjIMpFXPX5sXltLaE1EmMH/jWJ8T JYYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZBzTfN538cxBF+q89A7MrTkcGPI553HZ7cX5UmHJfys=; b=qoVnJgsV59GdATWyUS/YqBeAlO+v9d/xsyqwQXXLL7OjTDFt5Bk1AjJmejEQnC58cC ZOTcOk3OoyXtGJyeSlT/Oh+MzTHt3SvsSUj+F+ippTYXOGRZkBktzt96YeGM+r2oCC15 wumuKdTTs8eRZMKqEY93b5rvOedF1HcovqY9m9bcSSsRot6sR6QyGorGnqGZAOTLazV4 mE3P6HDIOc8Xdsb2c4B9qQd4CNQXaya1ItxDJ1cyaoYXguaDmiwUAxLBk0mrBd/UGIXA xyHDYYawuZQYrQWArxxlFTa1yA+SSpqZTnE3Baxm1fUnjKqxv4Nmz6hM10ygx6Djzz1O OnyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="B0Mu/43Q"; 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 u9-20020a170902e5c900b00161872d6f01si8610157plf.98.2022.05.19.11.13.37; Thu, 19 May 2022 11:14:08 -0700 (PDT) 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="B0Mu/43Q"; 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 S242343AbiESRHT (ORCPT + 99 others); Thu, 19 May 2022 13:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237863AbiESRHS (ORCPT ); Thu, 19 May 2022 13:07:18 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32C539C2CD for ; Thu, 19 May 2022 10:07:17 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id u23so10254689lfc.1 for ; Thu, 19 May 2022 10:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZBzTfN538cxBF+q89A7MrTkcGPI553HZ7cX5UmHJfys=; b=B0Mu/43QbEIOlNIrY4EF6Nu9VKILrU5jInF7PJeWChpZlGVenW1CcucpwyTj5xpz2Z 9BJ8VarPMzBRSmVfD8oVbg/DS4cvoIHaMVke/ZWI+u8FNxumHWBcEMh/ifz4r4ArBK79 Izlrm8gSFCMY8EWlqttn/m0VKTJSwQxlLFdSGF5hbCXUMDxPgMsCNPhE822mEGsihzm8 hDh9a6GVpgmwYpOxpjwsuP1EDOlU/7NgPHLphuwnYICM27RfSisYO58bc6btroxc3Huo GuEdhFK/AkvX68eTJmt8Xa30n5AOBcNCA7Gbk2rXpO9NAyaZVuae9c8d3wt3brM04Xkv aKFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZBzTfN538cxBF+q89A7MrTkcGPI553HZ7cX5UmHJfys=; b=3DpeEZlLq6K2+S4lHxOlno5z+PH1BUAt5yg9YbrKqNwg2Q5bFavNExrCCoszT+2DP4 AP4lHjjHhUmNR4fA4lNkE401T6kzP17Y+gRAA2AQBJIszfbHwF07cT7Fwykth6rzmuSG D4s2jUClCSz0R3EjVP0wycJv1MLwEYs51s2e2zqfrQss6U1fKtb4lZnBbXY4O5TL2aex WcwzDdKExcKxXymVfmBSSHzjCNygPKTytM69x0s8S0h/vOjPgDDpRYzyJt9F7N2X7JPn EUyLgCVcMlC7j4kwrzOw8Ha5vzTsY8ODzLRTQDB5vtLP6tLxJda3oJMhwJApeLzZTY53 0M/Q== X-Gm-Message-State: AOAM531yvPcIB5FxNi9Le6aUCFjwgGjVLUAiX+BNy+KJ+WH7UpuaNGcc 1nHoybpIcf6AeNEdNgilg6BieyFCkXALue8Pz5OnjQ== X-Received: by 2002:a05:6512:23a6:b0:477:943a:818d with SMTP id c38-20020a05651223a600b00477943a818dmr3942903lfv.644.1652980035171; Thu, 19 May 2022 10:07:15 -0700 (PDT) MIME-Version: 1.0 References: <20220518153126.265074-1-john.allen@amd.com> In-Reply-To: <20220518153126.265074-1-john.allen@amd.com> From: Peter Gonda Date: Thu, 19 May 2022 10:07:03 -0700 Message-ID: Subject: Re: [PATCH v4] crypto: ccp - Use kzalloc for sev ioctl interfaces to prevent kernel memory leak To: John Allen Cc: Herbert Xu , Linux Crypto Mailing List , Sean Christopherson , "Lendacky, Thomas" , Ashish Kalra , LKML , Andy Nguyen , David Rientjes , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Wed, May 18, 2022 at 8:31 AM John Allen wrote: > > For some sev ioctl interfaces, input may be passed that is less than or > equal to SEV_FW_BLOB_MAX_SIZE, but larger than the data that PSP > firmware returns. In this case, kmalloc will allocate memory that is the > size of the input rather than the size of the data. Since PSP firmware > doesn't fully overwrite the buffer, the sev ioctl interfaces with the > issue may return uninitialized slab memory. > > Currently, all of the ioctl interfaces in the ccp driver are safe, but > to prevent future problems, change all ioctl interfaces that allocate > memory with kmalloc to use kzalloc and memset the data buffer to zero > in sev_ioctl_do_platform_status. > > Fixes: 38103671aad3 ("crypto: ccp: Use the stack and common buffer for status commands") > Fixes: e799035609e15 ("crypto: ccp: Implement SEV_PEK_CSR ioctl command") > Fixes: 76a2b524a4b1d ("crypto: ccp: Implement SEV_PDH_CERT_EXPORT ioctl command") > Fixes: d6112ea0cb344 ("crypto: ccp - introduce SEV_GET_ID2 command") > Cc: stable@vger.kernel.org > Reported-by: Andy Nguyen > Suggested-by: David Rientjes > Suggested-by: Peter Gonda > Signed-off-by: John Allen Reviewed-by: Peter Gonda