Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3807425ioo; Mon, 30 May 2022 10:02:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJmY3SQ3taboNhHNjFro4XlNeaixSPYzDXVAsmggWqZLERPVytUXm15961q5d4Yyigx8by X-Received: by 2002:a05:6402:3491:b0:42b:635a:efaf with SMTP id v17-20020a056402349100b0042b635aefafmr41853917edc.135.1653930160568; Mon, 30 May 2022 10:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653930160; cv=none; d=google.com; s=arc-20160816; b=odL6I7hWvbHgJEFenaWuj1zPBxThES+sSXZfDf25rZj7jPoLlwCo27QLTSCDh6CXPW mDWnWp6FgBpW05ht8mkg5apfz1gnMZiecBBV0vug7mfAURsgyqJAUpBCSaaPDg8+fqw9 wgAefNz5Y14dEY3pGd4iD8tkvbn5psHyYZLsepmQfvO3B5pHDZx6F7W5c8Lu/4V9rcEE Os6BVhx+LHKGI8d7FkExHdmwk0xCsR9zK5O3c9X6LA8OwXKFhkEXUqCP/8cTCldHO34y OzLvzXz5EeNUjWOyHejK2HC1zyIh6c5RAeatp8GgQQY8G08fLiXeWmTFdwi0Ed+O7EWL vrww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=728SWygTCYgk0WrAgtHBr7Z3OMatQgArm+oAdaQJ3l8=; b=GIf1DzNdWTtVtSjiu19jOQYkPfoWBZHuFnBR8apkGyizrMJegSLJpm4kpCz+KZ0FN2 /yqKPqTrE4Dcl0pkp4XdUP4+ReQElJ48DKucLos2xnE3CRCG9aNu87lwXGfHCfLevLQH UaP4k1cDoNH1PGY+chAzUpa4IHRP5rX0GU9TuAfVwftODXYU3A1Y6IvCzQdheuUmTIrQ MRTi6+gQjcMV7kT+JfurhUldArWHS4GJe7qh9+ITuwZorUiRYFLV8h6ZC+oCpvj5RFDH CoRf9LQ+QmerATPzUqFjz22B4EjdSAlsbIgu9I+xajBRtD53KA0IROJ2g/1TQc4Xs81c 6Zcw== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a056402348a00b0042b394e389dsi15474638edc.16.2022.05.30.10.02.11; Mon, 30 May 2022 10:02:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234756AbiE3Jly (ORCPT + 99 others); Mon, 30 May 2022 05:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbiE3Jlw (ORCPT ); Mon, 30 May 2022 05:41:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5692AE09D; Mon, 30 May 2022 02:41:49 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FD46113E; Mon, 30 May 2022 02:41:49 -0700 (PDT) Received: from [10.57.34.243] (unknown [10.57.34.243]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C86863F73D; Mon, 30 May 2022 02:41:43 -0700 (PDT) Message-ID: <4f86be27-fcf3-e897-701d-bbec79a2dd32@arm.com> Date: Mon, 30 May 2022 10:41:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v6 04/22] drm/panfrost: Fix shrinker list corruption by madvise IOCTL Content-Language: en-GB To: Dmitry Osipenko , 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 , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: 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 References: <20220526235040.678984-1-dmitry.osipenko@collabora.com> <20220526235040.678984-5-dmitry.osipenko@collabora.com> From: Steven Price In-Reply-To: <20220526235040.678984-5-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 27/05/2022 00:50, 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 Reviewed-by: Steven Price > --- > 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); > }