Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2879422rwd; Wed, 14 Jun 2023 08:24:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UHtS739tnPLdqs6zxSJ52leNpgoIYlGoBMMl538k4k5xUDdSI8LUJjXqOmpzmcFDqux8v X-Received: by 2002:a9d:6c0a:0:b0:6b2:b8a3:70d6 with SMTP id f10-20020a9d6c0a000000b006b2b8a370d6mr12922009otq.20.1686756290025; Wed, 14 Jun 2023 08:24:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686756289; cv=pass; d=google.com; s=arc-20160816; b=Pld5ymfqtt/d21cuyclnnVbZsxWCqPrS4PsSbfL+INNSqnvSi1rd3IUqEFQ6v+7yLd iVRIz2faTYfc6IFvUoGY33Td7cTZ4VhQD3XVfD3gfm2Hkiv6NOD2U28ymamPohPW43/o 1ULCZwGgz/5I9nDJxdg5x5yI7Xqy9HFR5uYcEzHiUlB4UU1yVpv/uyLVbW8oI5sKr1y8 PKxEt/BKZVzn362HXJKRWDd+Of/y/7lDJPbXSSI6Kl0M3FxMV75ZKn/pvMhCHTE3N/WW 9tfg5AmZMh5DMI7TX7AIOACCniIWBivPWoGS5k0q5N4FmuQlYW+ZAfyhzqeGqAeF7zkF IOoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:content-language:references:cc:to:subject :user-agent:date:message-id:dkim-signature; bh=qVjII6GF+XBp87YXfiHzhMFgsWYA7XZ7MFMNowT7Iuo=; b=UvAGqVPIsupLrC1LREyBnPx+kVO4Zc0cdyt0h9x2teAGIq4HVZi+CGb7Wx5j0h8I1X V1O4uGi/3emd06Jf0mIvhYDJh2bMrIEK6wNH7CftpSt8IKyJ79s+6Yzb/eIXdFyfuVCN 05ue3BoAiFf4FPq/vywPpCMXMaDIrnAin8VI8SBD4fzQEIWFojtFjf4NQbAl7kM3yjit ExKd3LM9SnNaNZKBTd0cRBf57hUSVnqF72DsSVmh5LdWkojkhZyM7JRhfOtV+5PWtcXG 2H7c7yCN4GEos0tdkMCMPSItjakmrwu2YK3N41mlzzf+Fb8hAC3gIcb8008h5WQI0B72 sCaQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RSzOj42u; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a63e557000000b00513973cb8b8si10482870pgj.202.2023.06.14.08.24.37; Wed, 14 Jun 2023 08:24:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@amd.com header.s=selector1 header.b=RSzOj42u; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236816AbjFNPLk (ORCPT + 99 others); Wed, 14 Jun 2023 11:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343679AbjFNPLj (ORCPT ); Wed, 14 Jun 2023 11:11:39 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F519A6 for ; Wed, 14 Jun 2023 08:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kIy30PzLIj6oRiTATJGFVa03hjjpAnt69RP1+ZL1YIR6EyrFAM/OeFWYJHoBnb+1UA9kFNyn/s77EZkNAqaAnyi0ejTRSE7+4PoiX+F3ET8R6mSfnZgUI/yBZDT1S3XWKDeH3O5htCqOQj2j09qBB9kBhxrJewcgxNCA51Fmv9gCeMOb6mLZFqPPX4ZwDhxtnIVUqEN5khHr0vpmUihNRjnu6/MfcOpIAV5ykCDb1PSIioM/Sq/YW2KJPou+IkpbAOMoc6i8FHavPsDPgzJv9jy91LZDxbSnjcWbBScr+HGoIvEcFYfmBxjvKge75CFQPmxz4IbXr/gEdgjwjyKXHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qVjII6GF+XBp87YXfiHzhMFgsWYA7XZ7MFMNowT7Iuo=; b=FeDSS572wfHirMXCdI9bfNKMbZ04GrwQ5e3LXn6ZyyG6+4rkGaIswcPoMpQskgOIPG6yJEF4UQBZEppk3XncmVgNnGPewFvRhjeyvPcn0A6cv3a0OMjB7zT1eJfLRE8hxlSrjuO9Tl4Bn0gbJKRFRMYhAomEBTMQ/7sKbUHw7NXneAmht/Z/EYx80T9/lv7aEkbC3jcbf+j0o80Cn1+6MzwA/y4qsemYvKLpFPKSn/mEz0cDDH7oipjv6iLbdstrgHsY2+1nXn7MjHECeTa+GU/JACwkQ6nZTg0urV3g7yTm0v917OrMrf23YbXt5bl4gd/bhCWWjZB5Au4QRPT72g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qVjII6GF+XBp87YXfiHzhMFgsWYA7XZ7MFMNowT7Iuo=; b=RSzOj42uoeVHS92++Y1SJT9BSz57hocjeyqyDIAFtyNB1VtAVs8LJVWpx0w/qB4G5ab3RyynkMHuFKSAaYovSdAi7XvCkr5u/ZvF/0Fm0EjsPVJYsz36V9UNPz7y3FO+oUu92f8qoF4e/vu9kuuyizr5wvhy4lpOO3Yvz6JlKHs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) by BL3PR12MB6570.namprd12.prod.outlook.com (2603:10b6:208:38d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Wed, 14 Jun 2023 15:11:33 +0000 Received: from BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::2dc3:c1:e72d:55bc]) by BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::2dc3:c1:e72d:55bc%7]) with mapi id 15.20.6477.028; Wed, 14 Jun 2023 15:11:32 +0000 Message-ID: <56f6f771-8ccc-ec91-e4dc-f4841bce38c5@amd.com> Date: Wed, 14 Jun 2023 11:11:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/amdkfd: Switch over to memdup_user() To: Jiapeng Chong Cc: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Abaci Robot References: <20230614020432.44044-1-jiapeng.chong@linux.alibaba.com> Content-Language: en-US From: Felix Kuehling In-Reply-To: <20230614020432.44044-1-jiapeng.chong@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YQBPR01CA0128.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:1::28) To BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR12MB5115:EE_|BL3PR12MB6570:EE_ X-MS-Office365-Filtering-Correlation-Id: 15aee1a9-8f3c-4f66-1f9a-08db6ce9a34c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S/o7n6yaXWSPSu6R8ckD0h7+1BcpRmcKPFstPSYemGA/M0WzOaU6kpYSFoRgOIVWfFrDSyS4dN0C9hNfWPbJ4PlzmHeYnXJWzFJvxfW2uJ7dC9kQKxe+x7f1aqcfIMUzRy+IvPRRiprTb3cKq/JMGECQ9uuwNy8I2P/OQUG+7x2NkQs5lBh4WvwySa2n/am7JFxSI9P2bJjgsZ1UFVtX6f8LwVvnNT7qKlPftI+G+kOjI5U4NY7wmcvw7z34l0aFSjKcVRAQryQEGL18zc87bC3tk+D4ckSsobLw7AtRvM7u0M0afU3skID0GEpKsG8I3a8tRtsyljwJnJDqy51EOUnM3JYg3T4Z6UxalhcG4EsuBYovqEQtzdky1C/dKqbPKaOaKoXiH+Oib9HklezHBDgi9SwGBMMfy9N96TIgrvd9qA3FfUMNtEzDt/aGaSzHXFuHzwuJX+U9fCItZXJDaRf18h1bZOPdMZ+wOINJ+WpsB3DRHR51gekHo+NNGfxw3QBbvnyXFDgCcXriKPB4XB+okvnpMgcSiV8zQq8jF+BtYM1RuXVcKBLy6/u0uHN3WjSTbqyjtMT04PJ7gvBWhgCwC2MU0RCtaK9YajQZ+MKXwmxde1RLqC3owRAsALgSM1r4K+l/wkIyo3U/C+XYOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR12MB5115.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(346002)(396003)(39860400002)(136003)(451199021)(31686004)(31696002)(66556008)(66476007)(66946007)(966005)(316002)(6916009)(478600001)(4326008)(36756003)(86362001)(6512007)(6506007)(26005)(186003)(83380400001)(8676002)(5660300002)(44832011)(8936002)(6486002)(41300700001)(2616005)(2906002)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SjJtZHp4OGpyajB0cC9oVElyMm55bXVycFJUbDRrSDR5OUIzemEwTlErUkVt?= =?utf-8?B?RmYyUW5XUGRaeW1WUlNOcjREMDNMM2U0MmJMWWhqL1BLTkdGb2ZDSkJHblpy?= =?utf-8?B?bTFqc0drVkV3c0xmSlBackhIRTUyTk9IWkZrcTh0RmdEK2JqTEpLanRNNnpj?= =?utf-8?B?VkhZWTFXd1ozcGhqMkRJYTBVSG1UV2Q1VnA1WDFTSk9nOTJ0RVhjdEIrUnp4?= =?utf-8?B?d0gza2VIR0FFM3I4OXZIaXQvNlBDZTJuQ0hSY1BaK29mc09QYVIrSzArd1cx?= =?utf-8?B?SWI5N1NwMW5vZ1dlYnd6R0NNNzRSdzEvMktyNFU1SncyU1NibUsvNmNjcC82?= =?utf-8?B?WDBVanBWZFlzNlhaR3BlM3ZNZnpKNGVRK2JoTmpTbStTZDFGcGN2ZUk4cWRn?= =?utf-8?B?c3lRU1I3K0ZqUVA1aUU2Mzk2eTVwY3l0VzJGeDczUkdieWo2Mm01K2pHOWlp?= =?utf-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V6VGVVUEt3d3AvWHc5Ly9WdHpD?= =?utf-8?B?STRMR1ZrN2FIRitkSFQza0ZvRlY1Ynp4Wk03TmZKSml0U3o5cktCblZ0WWRm?= =?utf-8?B?WDlwRnYyWE9TU2dUNEQwb1dvL0ZEN0RCSzRoeFRPcDhZdjdjQ0Jtb0M2cGtm?= =?utf-8?B?cXlCM3BsNmVic1dqbWl2SElPNmI1bUVuLytJN1pkVzgyeXlOWUUyb2t2dlJQ?= =?utf-8?B?Sy80YklINUEvNjZidG9kTEJpTlFEMzkyM25ma0VSVWhQWUR1cGZWT3pKWUQv?= =?utf-8?B?R0NvakMxczhaR3hqekY1MG9RMmZqSDZkTXE3SlRDVWhEU3NNVXdqZUJhYysz?= =?utf-8?B?dG00RXBaYXBGbmMzcEFKRW9PL1F1SDZ3Sk52S3lyVXpVQzNUZnhJSTZ0Y3pJ?= =?utf-8?B?eFpGdFRDUkNseFJxc2JsZ0hIL0F6QWJuM3dud05DZVhLNU9LWW9xRnh4RE1u?= =?utf-8?B?WmRQZXY1Y1BmR3ZTVjlUcHpHc0tFRkJWVno4RGJocmhwSVpwUVNaTVF1WGlL?= =?utf-8?B?NWx5VUFXM2N0QXZGcGZqemdtbnp5REZqamt1REEwU3lrdkJtUXBaZnJGWjVw?= =?utf-8?B?cWN4OVBxS3lqdk0rZnBWclFyaUphc0tJTTk2cFdseVZ2eFVobWZNd0Z3QkEy?= =?utf-8?B?VjF6c3lNb2lORVNVcHhseXowVEFmaExScnJLeFM2WnhNZXBWNWd3WEEyT3lK?= =?utf-8?B?S2FEamQyZVduQ2lnRG1qa2VqM2R3eE5XWW9EcS9sVFhYMVlOMmRPTGlUZThh?= =?utf-8?Q?AGrIa9xA+w+Eu3u9051Yvb6yk?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15aee1a9-8f3c-4f66-1f9a-08db6ce9a34c X-MS-Exchange-CrossTenant-AuthSource: BN9PR12MB5115.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 15:11:32.7136 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HrgoiO4WyQxhVorFeJyYJ5WqU4eQf84X3dG3bqXhg1jkNUECYVjnpA/wUHzHUHTagUHo3Ta/6XaKRIyRiweL2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6570 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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-kernel@vger.kernel.org Am 2023-06-13 um 22:04 schrieb Jiapeng Chong: > Use memdup_user() rather than duplicating its implementation. This is a > little bit restricted to reduce false positives. > > ./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2813:13-20: WARNING opportunity for memdup_user. > > Reported-by: Abaci Robot > Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5523 > Signed-off-by: Jiapeng Chong Kernel test robot is reporting a failure with this patch, looks like you used PTR_ERR incorrectly. Please make sure your patch compiles without warnings. I see more opportunities to use memdup_user in kfd_chardev.c, kfd_events.c, kfd_process_queue_manager.c and kfd_svm.c. Do you want to fix those, too, while you're at it? Thanks,   Felix > --- > drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c > index d6b15493fffd..637962d4083c 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c > @@ -2810,12 +2810,9 @@ static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array > if (!usr_queue_id_array) > return NULL; > > - queue_ids = kzalloc(array_size, GFP_KERNEL); > - if (!queue_ids) > - return ERR_PTR(-ENOMEM); > - > - if (copy_from_user(queue_ids, usr_queue_id_array, array_size)) > - return ERR_PTR(-EFAULT); > + queue_ids = memdup_user(usr_queue_id_array, array_size); > + if (IS_ERR(queue_ids)) > + return PTR_ERR(queue_ids); > > return queue_ids; > }