Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp1999520lfo; Sat, 28 May 2022 13:17:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkr/Mm7WNAf4e556JEqShzIj5WytohsJtw/6B18C+nBMNT5pCODirJ6mnRz1eWDfjsMwea X-Received: by 2002:a17:90a:f803:b0:1e0:c0cc:8635 with SMTP id ij3-20020a17090af80300b001e0c0cc8635mr14752094pjb.240.1653769053737; Sat, 28 May 2022 13:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769053; cv=none; d=google.com; s=arc-20160816; b=fRB9fP9zMsHXZvmuh0bEhBRaRNT+wD8NbcqjKEtacxXXOuetdFsW+5LlPuFw4LUiyC mVTqUEntcOBfgpTQmUzYjN6eX+lNxHCbQedbhm5kylKuCc9NUBPLHLnwd4cf7fkMCD9g abr+Rp+8wEEobc45RSiFBseMJ92i8ZPNsmX3FH6zqVNy9KOeqSTQ9NgfdEoA1TnK4Wfy tsPXHt6sjsPi5tavpleqMr2m7DjX9cHjIJOwW+lzAt3koGoSag4gCUczb7El6UiPGAcl 0QekF1ywmzvnbgqKOyzzMvHWZd8zFciBqa26gpadYwV6DxCYuXRwPU7tf/9RHPekhPLO yXOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0D/e2C92xTkb2sLy7Mlb9jvsO8wbeKgbwSMnQbLWyu4=; b=pRMTcNLVd7LdZhhjtIDie0JkiibEFwciPsuewBQcXLURb6lJSrAKJH23at2a16URIE iwhZDBGunOKab5sRStxoKPjfECR6OMm08/hwMV2YJEfMQbo1uvSDHnDFQmklUrxj2M3k AFUgZrSephYwiMOW/a/d2hgU0+Mo7tqeIALtPmofR6f5AtEMJKa0gC+NpafXAjIEyieL qsRuDffuGBojCyetPhcJSwHS0nc4D2PKc6EvuBnQCm5od2r22KqYU8QfVaEN+E6vGe7i 5FbBto2iPDM3+9a5jxOX9j9Th49VEN5WOaG37LVmmpYvA2SDLIn4oJBQxY+fzxgsYFiH mOjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Q6kTO5Ap; 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=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x20-20020a633114000000b003fbb430e4f8si6123054pgx.96.2022.05.28.13.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:17:33 -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=@collabora.com header.s=mail header.b=Q6kTO5Ap; 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=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A3BA53724; Sat, 28 May 2022 12:28:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354174AbiE0P6K (ORCPT + 99 others); Fri, 27 May 2022 11:58:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353864AbiE0P5W (ORCPT ); Fri, 27 May 2022 11:57:22 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16CAA66697; Fri, 27 May 2022 08:56:52 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: alyssa) with ESMTPSA id 3D3D51F463CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653667011; bh=n5RHKvs6olD8LksjT484qw9Rh0JisRhUIQ7ggPkOqx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q6kTO5Ap+i5kmaF5um389IzxbauaGndK+JrcD4hEezqh4whcGeSqpoC5zDuWw57KI 8fh+bDAIu8408A79BVtUamQIZPLFV90q8BABnbTh44p5m/jr3XQRDvEP68ncgCedK7 iWk55rkqi/komv0pBkw1cQB5acBLw5+u+DvpIejXBAgHDD4NeyeS1JVK49uoVmHCS2 mbrHXxwVcX6JnH811NUonPSSXnHqfm2ChKbnZSgvS/P41yiK/z0a3BBHsiTV5+ccK9 oLlgD/Myd6w2UL6nCNj7WWOM5ohWFrt2ikdxXL5RtRt+P5YoENL4mecu8Xj8kkWW7F NZnyFvgN0M2lA== Date: Fri, 27 May 2022 11:56:36 -0400 From: Alyssa Rosenzweig To: Dmitry Osipenko Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , Christian K??nig , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com Subject: Re: [PATCH v6 04/22] drm/panfrost: Fix shrinker list corruption by madvise IOCTL Message-ID: References: <20220526235040.678984-1-dmitry.osipenko@collabora.com> <20220526235040.678984-5-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220526235040.678984-5-dmitry.osipenko@collabora.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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 Acked-by: Alyssa Rosenzweig On Fri, May 27, 2022 at 02:50:22AM +0300, Dmitry Osipenko wrote: > Calling madvise IOCTL twice on BO causes memory shrinker list corruption > and crashes kernel because BO is already on the list and it's added to > the list again, while BO should be removed from from the list before it's > re-added. Fix it. > > Cc: stable@vger.kernel.org > Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/panfrost/panfrost_drv.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c > index 087e69b98d06..b1e6d238674f 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_drv.c > +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c > @@ -433,8 +433,8 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, > > if (args->retained) { > if (args->madv == PANFROST_MADV_DONTNEED) > - list_add_tail(&bo->base.madv_list, > - &pfdev->shrinker_list); > + list_move_tail(&bo->base.madv_list, > + &pfdev->shrinker_list); > else if (args->madv == PANFROST_MADV_WILLNEED) > list_del_init(&bo->base.madv_list); > } > -- > 2.35.3 >