Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2121914iof; Tue, 7 Jun 2022 20:27:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKgsZVWhI9YEx8xLVJpg4aK0n0ULVWzVhxd3F6elf/HuQCe7AK+sQfHpVUeryhzw6cWu65 X-Received: by 2002:a05:6a00:1946:b0:4fe:309f:d612 with SMTP id s6-20020a056a00194600b004fe309fd612mr100422345pfk.10.1654658870459; Tue, 07 Jun 2022 20:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654658870; cv=none; d=google.com; s=arc-20160816; b=R+4JEeB1tpszLklav/MpWzz62qpG21wXubH29uXXIDq3qR+Q77tAvEqvTjm0xIun3J 9VqWlsqln/BT/Q5mfETYQunzrTmWH1tjSb9+R5tgOg0EeytCkt8n0LF3LaprE7bdPMyx LzEVCIG87TJAIzLRfSYXOlAf8nI/XOjycnq467HGnfFxqBHAgj9z5YdG9PRwnUgDDiHn Gx5FG8YjKhqTXhdqqUfr/BxqqINxddenP2Asa5w+Tq4n07kl5E4jV0vX6b9T0zJCgn9D 2tvYRFPSZTJ5fFBuA2CazJCFQ8eTA0YgZq220kHBSzJTHQid7tcfCiR/5A3Qpb3cmnqB 7tnQ== 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=et5d4DM7Qkz5qPPCoiTPlM6P1258hTgQ0iEkTPrpV+I=; b=DCnTkU1KJy9Er/rZSfE7DDSKNKPhn5hma2FkkOBPhB1KBtVIetfWJkjaOyYYEzlYsY u1RxnxntRIjr0cTfvVDhLXGcED7KhbRe8TLBe7m3RhXKb9aN3XZ2OfyNH+spLdfZJx4a Us/XTCGMKEYoZ3v/h53dnCnnQitRHjMIkDERStiN+4IB/1lQKPsN8yfDKzGu2bUr5dt/ RD5bzSzT1YfmearOvfTmLZ52PejoRvKvQkmh/tM0lzkAUMz465CsF5c8TFImeL07M4dF f7TSj+R2sawup9W/B03NinK2+/7MNnufxIxZxIN2Y6n2hPuAp3EFG5qzWIEIfwaziexv hiHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PuFBuqld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id np16-20020a17090b4c5000b001e86bead2absi14149727pjb.55.2022.06.07.20.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PuFBuqld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FE6E24933D; Tue, 7 Jun 2022 19:48:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380139AbiFGVaO (ORCPT + 99 others); Tue, 7 Jun 2022 17:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377851AbiFGUeJ (ORCPT ); Tue, 7 Jun 2022 16:34:09 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C6F1E7AEC for ; Tue, 7 Jun 2022 11:36:16 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id i66so24990889oia.11 for ; Tue, 07 Jun 2022 11:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=et5d4DM7Qkz5qPPCoiTPlM6P1258hTgQ0iEkTPrpV+I=; b=PuFBuqldb4cHgsAojupGIYPzKREKfkNatPa7bNJQ3T7Y+VXcNNgnWsYkvgJ/efgrh3 6Tn3ounWD12Wg3D59zmyEuUSXPLON+5y+Nue/CWFFSBVH4f/G7rc7jpirEo3w6c2wPxC xHFhs/2y9CqjlPp5zehXBRxbhz6Hoz43R/XOkXaUR/jU++0Rvqfu/8tpLqh0ykZLOqCM E7ev37DY+9K9VrD5xzMbiLXP5yu8PUfmJjpJ3AjJKgAR28c36eSF84wSsYmuVxp65Dy0 ocOiAaBGBT87tJfATIkqFQLfoCX1V2jcq2zXGsnmZpjMeZ56p2G8QVcGYYZG4KFtFwo8 JjHQ== 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=et5d4DM7Qkz5qPPCoiTPlM6P1258hTgQ0iEkTPrpV+I=; b=4Gg/7YwpEOrtmzp8YI9v+H6XIHNupcmqGeEs14X394CNbF3BVFqmFZbfMnCRZnb7Xs uvbzWb6udN2Sb+z7d2k4Z1V+XtNeYpEaXl6O7CGnOw1Z8yMAcb7BuoWysUIZONDchSZF kOkqPY+s8eKGy8hB7ZTTfXZDzSXm8Ff/yZGg1Zhh23b/fDhPqfjP4wmyLmlGkdJNCkk0 tJrkFj2FvPgx0JMYdXCwDLW3YetcGf6oSlIHdp98nAgTVNySBTfGdfynyPZGub5DXMpD ro5zL5lILMNko9/lkCC4vNflTWeDyDYrYyWDCfrgd++OQYKmLJ3qIyNOT64//MrsHHWS hkEg== X-Gm-Message-State: AOAM531o9oZmxYzW0J4WpEiVt+/Atwdz7sMXXVQ+EiwJeoc2SJ/8b1kJ FfF9N3IZ+/DGjyMpb1RDIBtjTU4Wlc0JdB+y6n0= X-Received: by 2002:a54:4f01:0:b0:32e:726c:bced with SMTP id e1-20020a544f01000000b0032e726cbcedmr128014oiy.253.1654626973764; Tue, 07 Jun 2022 11:36:13 -0700 (PDT) MIME-Version: 1.0 References: <20220607151933.32850-1-xiaohuizhang@ruc.edu.cn> In-Reply-To: <20220607151933.32850-1-xiaohuizhang@ruc.edu.cn> From: Alex Deucher Date: Tue, 7 Jun 2022 14:36:02 -0400 Message-ID: Subject: Re: [PATCH 1/1] drm/radeon: Initialize fences array entries in radeon_sa_bo_next_hole To: Xiaohui Zhang Cc: Alex Deucher , Christian Koenig , xinhui pan , David Airlie , Daniel Vetter , amd-gfx list , Maling list - DRI developers , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Applied. Thanks! Alex On Tue, Jun 7, 2022 at 12:04 PM Xiaohui Zhang wrote: > > 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. > > 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); > -- > 2.17.1 >