Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2336623iof; Wed, 8 Jun 2022 02:49:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbtLaR7Lw07WuaLgbv/NtmqoWQG/HnNEiEsC3JVf6XjIb1ppSLt1QG2f9PlZ+/rlRTZRB4 X-Received: by 2002:a17:903:2308:b0:167:62ae:28fc with SMTP id d8-20020a170903230800b0016762ae28fcmr20471353plh.100.1654681749831; Wed, 08 Jun 2022 02:49:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654681749; cv=pass; d=google.com; s=arc-20160816; b=r/BgrIDwYtKfVhqWmAT/0vuA7ODp2ecOifJ5+wh+zFpLSODmArorlfALzZmqsa86Xz Q7FB4AbYT19CPmovBsR//sBH55VUWS3eASu51ZLWNVYaugNgCc+Sb4nWGjpbNf5Zsoc6 bdNtJwjJwslzEEx8MZwcLPFjwJtW7fhoouK08qBqqhIRL03vo5Q6+Xzb5g+V58WtN7Nl IsVysH9o/aq3Ag7aK48BxteIsukFCXjNbH1LNIo2fTTfRUTUyf+LHMhOZbsuw4bFepOg XftY3P5IFgszvoYjkzGJJgoWMR9OLp5XDCjZSH2sZCyyUiyuhyVB8qazSQvXaoKhvm70 tFAQ== 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:references:to:content-language:subject:user-agent :date:message-id:dkim-signature; bh=HIlG6/V8CagKWFtxZL2sj8vN0WzsSEz59i8JmuREPsY=; b=t/Daq1RqB3KKAfDMNHWQeNH8AZ35qHfkMQquj6D1yfL2aH/l+R0PD5k1gX5MWpuW/0 bih4iTM/EiPMJulQ0BvJSXjRP9uibXed1uyJEYPTOYjQ26LM4SL7d81EBQKF+3oz04jc PP5xeEBR8UTGRaNXMa6pZl63bUkxpew6NmDKgm1zIzeweJfZz4IMz+ivLtHRvPy4RHr0 aFlFJe1NSWao551BR8SOpJe0y7aljKQPxMB11M2zMkFtSIJX91AWK9HwyFiIzD7KOtnv lF/NyXGy5fZH7TFwuvbNJqUzrbUKbRUAIo4+a12RV9+SM1HKYoD2zzcVkM30gLuF88To PzcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="zHSGkn//"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h68-20020a636c47000000b003fdd2ab1ea0si9997522pgc.293.2022.06.08.02.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:49:09 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="zHSGkn//"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17A2A394BCA; Wed, 8 Jun 2022 02:18:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234456AbiFHJRx (ORCPT + 99 others); Wed, 8 Jun 2022 05:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234936AbiFHJOU (ORCPT ); Wed, 8 Jun 2022 05:14:20 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2065.outbound.protection.outlook.com [40.107.92.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB85BBA987 for ; Wed, 8 Jun 2022 01:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lr9AtieIHTfd5ZUR0f+92lyEdm4YH5548wc6DCdh9Ca/trLcsovTftV3aAJkNSa+T1Kz6W56uf2jb/utofi8JjYO3i/LQb8wZk1Diz4Rv0IT7zYaNc4rx+qvqlsrltQoQmYTj29AT4AVGO08fERhWYlXw/RAAm4LYIrmaG92nUIVBHm59mEQmA6/0xYODHmUmY0foe3w8s0WMyezgdV7/J0AvFdpWlZl4wl4Fcq2QBrs33XVEuh673lHewhlhUsSkxYkkP/xsVFdMC7bfquF0aIAs04sSXeYPXaXP0N4ajQgm/75geCCaTfDK9uQSq9cWyimp58pc1a/9m47xQQMFQ== 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=HIlG6/V8CagKWFtxZL2sj8vN0WzsSEz59i8JmuREPsY=; b=nmyngiuZZ39Cx+HYSSCn3F6uZchbht+KJkLefFVwhWT4u8ceX5+wgW1FD2jRBCFh/2mwurxE33bXP83UDGtv7d9B8wVmCX42qgTCJzQEQEShX2JVkk7znHxoZg6Rj1QZHNkuHV9BW8MUtiiLN5jt0Q4T0jE1gjj+qwzKMubnRowByJKWby4K3YdgWxE/TMZ3Jutd+3X0WXWZqEMTfbTm3LzjZqEnxAgr2YhZj4Nl5iOxz715XbdZqfcwbqlG+XzsZa81Brmy5w+SzoyvoQyW/PnR3X8wOHIVRYV0Y7FDs3um2admX+IJKiCjRmfgPUGvJKM5j4MkyormFw+y3fNA0A== 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=HIlG6/V8CagKWFtxZL2sj8vN0WzsSEz59i8JmuREPsY=; b=zHSGkn//5llILg9droLK791BN2yHDFv5gb+DnFwpcfWAxhyHXZWaHcK4F3mpPcCbM42m/zG16v961/Erz3WuMusR7gwdljo4vrLGZDdbWcRNL2d0Sfz6KetMmWUPBEihTOZj7WqZDOJfgxgArA8hYTJUKafszthjQ2vdl66cZ8U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by BY5PR12MB4180.namprd12.prod.outlook.com (2603:10b6:a03:213::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12; Wed, 8 Jun 2022 08:35:19 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::7146:65ee:8fd3:dd03]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::7146:65ee:8fd3:dd03%4]) with mapi id 15.20.5314.019; Wed, 8 Jun 2022 08:35:19 +0000 Message-ID: Date: Wed, 8 Jun 2022 10:35:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 1/1] drm/radeon: Initialize fences array entries in radeon_sa_bo_next_hole Content-Language: en-US To: Xiaohui Zhang , Alex Deucher , Xinhui.Pan@amd.com, David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220607151933.32850-1-xiaohuizhang@ruc.edu.cn> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220607151933.32850-1-xiaohuizhang@ruc.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:20b:2e::36) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7de2be80-9d48-4ee5-e86e-08da4929d1b6 X-MS-TrafficTypeDiagnostic: BY5PR12MB4180:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hLaWZvEUCIUboOpp9QswVm0FN3LyfjASjVY9LNswIRTs3IHNqtU4FV8H0HKjBZu2xCAehjYGwfMXKFIV8VAKEPW2HF8yqp9ChWByFwTfPV18FBKkDVgckzJ9Lfv6Aml0hpvoOxA3uADVLBNhMn+euOdXKfHRnnebbqTHqsLNtg6fwv0Loo7TX/6LwL86sdGPbPspTr2Wa0q49jMXzhSPL6GjBf7tvfHvF/L1fDdzK2ZVwmKG7TFcipeEg7hvYxK/KUZLwE/UEsUSeO8XcEf6pk5JColxILA+b777sChjK7ADoex3xP4fAvoEkKmA1eAPdhxXfFDHLYlPgp+ftJuaG3gCRrK1Jed3KS57RjkX2lqtuZihR37gjL6XE7qpVsx11VZ5IzyD9DtfEx1DaHYmCIiXriwwM2AYHcwXXVH1Qq/6YaAQsWSerE5nBvcOUZ9KisOtTYr+zP+mezqPF5mfEnRlPJnh5U18kKjqUUxYyQjin93C9Nu6+IcrTz95MZKMDF/R/JZAWJQRHWPzwZ9woh73VauEVn11/BpDoNfWIxSoTvpI+L9btipnTZZ86F+b6kiCeuGXPRutf575HbDf9BgRxl80146eNFGhfcDvIV8/PtDC/3k6xiD8jEh24sD4wUKt4o0Ks8aYBjKYfwr831rMk4hdhQceW1ORXDl1TTjumLqYhkp/QRJEhvpw+VV37h4NFJPewU/KqJmqnNPEwbQozrackF5119TTxw2Fk6zN1iLsb+anU9502QUUNeEk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(31696002)(8676002)(83380400001)(38100700002)(31686004)(6506007)(66556008)(66476007)(5660300002)(2906002)(36756003)(8936002)(6512007)(508600001)(6486002)(66946007)(110136005)(186003)(6666004)(2616005)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?M0NnMUF3bHQxWm1jVjErQ0JleVc2a0h4eW0wUXpMVFdvdDhpNGtDT0lvbnRU?= =?utf-8?B?cFUvdURnWmQveWJoOXJjczRldEVtdGV4cmYxL0ZhU1BJc1NFNXEwSXNjTFZz?= =?utf-8?B?dW1iQWcyRm9DUEdZYUt0clo0K1FKcDR2QkNiNVB0a1NrdjBoRjA3QWpod3po?= =?utf-8?B?VTVCeGhTejNCRmMrNzhpc3ZSYjV5Y1NuMUp2NDVuRTh6T2hwemQ5RnVFdDRh?= =?utf-8?B?RXlrOFgza1RaMEZBTUMycFdveG1INWlxbzFpeUdJYUJDdURDYmVneWo1MWdW?= =?utf-8?B?QmNaVkFSY0V0UUVJS012Zzd6dWV2dm5rM250eHZkR0lmUUsxNGJZalZndDYr?= =?utf-8?B?N3QrTUFPd2RNbFNMa2pwT2xOcDQwTlQzMXV3OURveVJxU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GQ1YnVRTHliWU4yYlhZRmx6RFJKUFJXNll6bENZTzlHOG9hWUJTSGVR?= =?utf-8?B?cklUKy9qL012YlBPcU02M09COTM0Zm1uMkpHQmJQdkQ1ZHdjL0I1T0R4MVRq?= =?utf-8?B?UVZXRGlwdGs5T29LeXZYT3NQOXpIR0gxcHRMYmtkT1lnUTRXcEV4R2IwaHFQ?= =?utf-8?Q?Z4li4e6LfOHRkaMFtD7dYJ3FdqUvqWquGL32ldJIi04rU?= X-MS-Exchange-AntiSpam-MessageData-1: p4mqBjnlsbvhng== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7de2be80-9d48-4ee5-e86e-08da4929d1b6 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2022 08:35:18.9445 (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: nfViJrY8L1P0DODqXu+TpfXPiQil4qojPInlN+bgvFrnfbs57/WnLqBkHY19cOTi X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4180 X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org Am 07.06.22 um 17:19 schrieb Xiaohui Zhang: > Similar to the handling of amdgpu_sa_bo_next_hole in commit 6a15f3ff19a8 > ("drm/amdgpu: Initialize fences array entries in amdgpu_sa_bo_next_hole"), > we thought a patch might be needed here as well. > > The entries were only initialized once in radeon_sa_bo_new. If a fence > wasn't signalled yet in the first radeon_sa_bo_next_hole call, but then > got signalled before a later radeon_sa_bo_next_hole call, it could > destroy the fence but leave its pointer in the array, resulting in > use-after-free in radeon_sa_bo_new. I would rather like to see the sub allocator moved into a common drm helper. Regards, Christian. > > Signed-off-by: Xiaohui Zhang > --- > drivers/gpu/drm/radeon/radeon_sa.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c > index 310c322c7112..0981948bd9ed 100644 > --- a/drivers/gpu/drm/radeon/radeon_sa.c > +++ b/drivers/gpu/drm/radeon/radeon_sa.c > @@ -267,6 +267,8 @@ static bool radeon_sa_bo_next_hole(struct radeon_sa_manager *sa_manager, > for (i = 0; i < RADEON_NUM_RINGS; ++i) { > struct radeon_sa_bo *sa_bo; > > + fences[i] = NULL; > + > if (list_empty(&sa_manager->flist[i])) { > continue; > } > @@ -332,10 +334,8 @@ int radeon_sa_bo_new(struct radeon_device *rdev, > > spin_lock(&sa_manager->wq.lock); > do { > - for (i = 0; i < RADEON_NUM_RINGS; ++i) { > - fences[i] = NULL; > + for (i = 0; i < RADEON_NUM_RINGS; ++i) > tries[i] = 0; > - } > > do { > radeon_sa_bo_try_free(sa_manager);