Received: by 10.223.185.116 with SMTP id b49csp2927860wrg; Mon, 5 Mar 2018 10:54:26 -0800 (PST) X-Google-Smtp-Source: AG47ELuS1zUTPj4Kqwyd8Vqu64c52H01n26YfyoDRnJpi0pWcJ8u6Y8UZ1dF0M3gQ7G5J0C9s5YY X-Received: by 10.98.76.215 with SMTP id e84mr16384642pfj.45.1520276066543; Mon, 05 Mar 2018 10:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520276066; cv=none; d=google.com; s=arc-20160816; b=PRvo2Iv+8ciY7f+KHrDLTMf9LDr4QDk9PmHFGh9jGcK0z+QDSlXsNZWYeT716/V9FO pRMOBEQmkuj9PtzA5mKcE0lY+rh2NGqYt27mBuZAAr8pb/F/W/KanufBp+cWGPJeGhrT I9SpzJGsfyf+D+XdYIb++aTtEK91a525H3A4htASgHrII+sJf0+ImJMDt7wPQJosM5FY ZOmAEe4gQxUzm0X8cTR9alYL3899LB8D5XZkAM92HJ925kNoGXY4GNhLryUqXUGW9tB4 641vqTXB2ayrVqs6JfKooaIPEE+k055coM9nXktPxBJqQ8b/0e9mb8vIULqkGC95m7t6 ImTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:cc:dkim-signature:arc-authentication-results; bh=929T2ZTYJNGCvg6A4LZLVGu3gdELJ1EEk1tI17e/I3o=; b=W505ts+ze4zHUkn+Sm0v5puNhDvAc46LS9XV33vd3DUWDAurlwcibAZQ9XUwnkBu5n eWixxZTAL/BDkJLBRGsfTqC0Col5zaZPXH7XX0H89WJFIfOoDMza8sQGQc3/E9+EiwZA LYNRj0x/PDPB0ivPCwEhghs4hrISpYbrwWb4ZiV5jMFGYBoVZi9QdJM/yN5xYK9AUhW+ ik5AiLV0oH9ZOONUJV39txftjSKb1jcwHi0mrTZDECwtpr3RkA8txh3EOK9LB+nEElpb AZ1zaKQL43PFhDo0bv5JK/SYdmPDl4Oxb99xD70Rb73xR+lutOvANtyOVeIjt4NwDMVH Yxwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=33oo+pa2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1-v6si9874417pld.734.2018.03.05.10.54.12; Mon, 05 Mar 2018 10:54:26 -0800 (PST) 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=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=33oo+pa2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752676AbeCESwZ (ORCPT + 99 others); Mon, 5 Mar 2018 13:52:25 -0500 Received: from mail-bn3nam01on0053.outbound.protection.outlook.com ([104.47.33.53]:63936 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751764AbeCESwW (ORCPT ); Mon, 5 Mar 2018 13:52:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=929T2ZTYJNGCvg6A4LZLVGu3gdELJ1EEk1tI17e/I3o=; b=33oo+pa2/YJrJCJ/gemcWSEkwbH3V1Y3JSbVLxJWSzCxGIphf89jp2jb8Q0KXFR0QlRrSIcJGb9SFBULetC5UJK9Ds5W5X1nYyH5vo7ITLyigz4Ut7LABvNBb8oRUdy/VliGwhiBeE9yEDBu/JkHGDy4Ar00whspUzgrGfeGoGk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from Brijeshs-MacBook-Pro.local (70.112.153.56) by DM2PR12MB0154.namprd12.prod.outlook.com (2a01:111:e400:50ce::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Mon, 5 Mar 2018 18:52:16 +0000 Cc: brijesh.singh@amd.com, LKML , kernel-janitors@vger.kernel.org, kvm@vger.kernel.org, Borislav Petkov , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Subject: Re: [PATCH] crypto: ccp: Use memdup_user() rather than duplicating its implementation To: SF Markus Elfring , linux-crypto@vger.kernel.org, "David S. Miller" , Gary Hook , Herbert Xu , Tom Lendacky References: From: Brijesh Singh Message-ID: Date: Mon, 5 Mar 2018 12:52:11 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [70.112.153.56] X-ClientProxiedBy: CO1PR15CA0093.namprd15.prod.outlook.com (2603:10b6:101:21::13) To DM2PR12MB0154.namprd12.prod.outlook.com (2a01:111:e400:50ce::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2e5cd0cb-ba97-400b-38db-08d582ca38a1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:DM2PR12MB0154; X-Microsoft-Exchange-Diagnostics: 1;DM2PR12M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ft3t5EFRmZ2cd7OK0bi1EBicQEPkVP7lTtt6lNlDo5qbLuRy3bq5bmz+aMDy8NE2rEoZJPmh396a4a3N2Q+yDTsK8RJLm6uwBagg58ivySzYbahkrzCbS7k/ufV4y7nHKm5RUoD9xvLDyFDS0wXnzpkyPTsqzrqdPr2v+sF3T6EIdG3duax1vp3iAVM4QbuzIYLGEep5E/yF/2SYae0vGuV4WRYtBnVgqkUlzH4ECMxO8xM+wZ/WvrS0NSNf2wLifvV/Dv52TcFIN3ep6lXZslYalTPy63J7r7744Ld2H1gjpIOAm/RKHnDxh6XauYlOOnHMTtsaowf1GzcSkg9zW13CBKIWIJogDOAJxYG;4:UZafxmsHGD2JLMrJsuI2Qdmdl3l4ufzhe71LwaJ3ZyiYe2RNr6FInRF8BnsvaynJN3eD0EFYL01RmyjlSoxskPRYIFMKIaY0phaAi4XCRJpgoHlEbQwowiOmtUJYtLYgnG0pDC4Nagl6BaJco40aHLyQY/m+oOFj/z2l5F6X2ma1aw+f0olC4t+ffdgtOeBmNxC02QJUSw2y9uuu03zgIbZa2NzcUGotebElcW3qM3MTtazVATHS789ow/WgAQ1CcCvfAoGjE6c9f8v0TJ5xnbmOa0S/fMXgIWK7syIlDbRC/t3YaftnnHMt545WsUfdzAWcFochfRDps2jZFQ8A0w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(42262312472803); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(6041288)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:DM2PR12MB0154;BCL:0;PCL:0;RULEID:;SRVR:DM2PR12MB0154; X-Forefront-PRVS: 06022AA85F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(396003)(376002)(346002)(39380400002)(189003)(199004)(2950100002)(81156014)(65806001)(6666003)(6636002)(65826007)(31696002)(4326008)(52146003)(81166006)(23676004)(2486003)(316002)(97736004)(186003)(478600001)(8936002)(52116002)(230700001)(76176011)(16526019)(86362001)(229853002)(66066001)(7736002)(65956001)(25786009)(305945005)(47776003)(3846002)(6116002)(106356001)(386003)(6506007)(53546011)(53936002)(2906002)(68736007)(54906003)(110136005)(58126008)(8676002)(5660300001)(6486002)(7416002)(36756003)(6512007)(64126003)(6246003)(31686004)(50466002)(105586002)(26005);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR12MB0154;H:Brijeshs-MacBook-Pro.local;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTJQUjEyTUIwMTU0OzIzOklLdHphd1llSlFSeVhLTHJtUzZ2L3FpY25L?= =?utf-8?B?UExLWk5UTCtNSklBZk4wL2xSdW5leXB3RkNIQlNDRnFIai9Xc09EMXpyRXVW?= =?utf-8?B?V2N4MUwvS096R25Icm9WZUZpNUJna0ZhaG5iOXJIdWNVeGRkMzZLUkpySDJE?= =?utf-8?B?ckFHSmNaYmxmTUUxeEFZaHZTNXJ6dW9UQk5kNEFDRDQ5VE9VMUhST1BZcDZN?= =?utf-8?B?a1RLNGROd3JlU0VyRXRORzhJa01PZW94azhxek1zN3FTWFV4a1VobXlHQW4y?= =?utf-8?B?SFc0WmM3cSt6K3ExLytWVnNEWmM5TThFelpqYUdIdk5UZkFSdkNHek1LSHhN?= =?utf-8?B?TzJZb0l3Sjk5MGVKWHhvY3ZkZ24vcExBM2VqeFp2MTZ2RVdNeWRzMFlIRmJj?= =?utf-8?B?U2NFbVhFS0ZqeXRzdHF2aTRJZmpKQzZJNHZtb2JrbE1Wd3k5T0lQd1RTUmwz?= =?utf-8?B?bXYxQkNyeU5DM0RrNGJnQkszd21qZzJ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3MVKGYM24qbQxNqA2U17PxSYdWXSJJfRnsSCS9BDESdlnnTkTPYBOfMTfnnPudpoV5bNRLsJJsgyexvYY3ozevyIbwJ0h3bVX1AEzaviJf5dHOU18yAWEziVWRHAA=;5:uHaO+ov9QLtfxgWTgskNaJLp/WFcn6kudrq8rfHsCAqr+ka3N1KoWF63Tvjkf7CAgEvqOeSzlEKjBelR4K/nqICan/5DyQmlnK2G05Nd4eSG/8hLjYiorTO1T5Mfq12Bh+d/ZoMPq9rAL46aJ1MOITSDk90+S0m7txNN7AZRinM=;24:7AbQc1oEi8KsdvhYU5/MTF/Ch1DK1h5Lm5klEBYdcL0MidvDjtfrs0p8TxLJOMYnqfojUY7h2+4QilF6492coBv35iSXYERmasOQf5AwGAk=;7:bboNY3UgLD8ncrgTu8Sgt3NJV2H0ZC7IRGJ0IXRXk3NK76tbfpo6iKkgvMpXcHYPW4CBd1p7eEkmzub2addYemzUG4xC7Fjncs0KYBvPUdtIAK9B+HgwxoiN/tcayHue/+jrnIkL2ZJxgo0hG7Yuw8MDKUCCn3SyXIlHYo9DV2ot3cpQ5E+KgW2UiVKFcbrFGbsh/9EznIPbh4L5pxo/a+kfMf52pEUBquLWYPMGLdcIQTxRFwyzTJTBlszfl/6G SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0154;20:qFFZaHKIdiDNSMKrHpbNKfPUGBqZWTiXIAj5BuiIZpzcGx/UxRNUt6a3+EYvMQ6IzSIEzoLtdUdDxC9nlTaPitIA/PAzj5yyJS6QHp/eLNWLTsfSqSsc/zwCE9ZIpKsP2/dLaZDvVhApFGeR3NP8tam+erh4lvHyBsz3OJ67UCfwvr//0YC7AO+3z4zJiL656f8mBJC3ze4TI9HJ8nS28agwbIL/kPQi7n9hD0EJmuQAVTBPXGpqEsvnZwr1yIeX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2018 18:52:16.9762 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e5cd0cb-ba97-400b-38db-08d582ca38a1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0154 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/5/18 7:10 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 5 Mar 2018 13:50:13 +0100 > > Reuse existing functionality from memdup_user() instead of keeping > duplicate source code. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring > --- > drivers/crypto/ccp/psp-dev.c | 15 +-------------- > 1 file changed, 1 insertion(+), 14 deletions(-) Reviewed-by: Brijesh Singh thanks > diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c > index fcfa5b1eae61..8255258cd040 100644 > --- a/drivers/crypto/ccp/psp-dev.c > +++ b/drivers/crypto/ccp/psp-dev.c > @@ -367,8 +367,6 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp) > > void *psp_copy_user_blob(u64 __user uaddr, u32 len) > { > - void *data; > - > if (!uaddr || !len) > return ERR_PTR(-EINVAL); > > @@ -376,18 +374,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len) > if (len > SEV_FW_BLOB_MAX_SIZE) > return ERR_PTR(-EINVAL); > > - data = kmalloc(len, GFP_KERNEL); > - if (!data) > - return ERR_PTR(-ENOMEM); > - > - if (copy_from_user(data, (void __user *)(uintptr_t)uaddr, len)) > - goto e_free; > - > - return data; > - > -e_free: > - kfree(data); > - return ERR_PTR(-EFAULT); > + return memdup_user((void __user *)(uintptr_t)uaddr, len); > } > EXPORT_SYMBOL_GPL(psp_copy_user_blob); >