Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4371825imw; Tue, 19 Jul 2022 05:32:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tgLtBGwcy31o/KsL0o3Va/JcRZuHeGNXu2fcI0WZNG4gfaf8emtEJh1LiYhHIeS5uMqz7K X-Received: by 2002:a17:907:2854:b0:72b:8f44:26a3 with SMTP id el20-20020a170907285400b0072b8f4426a3mr30042449ejc.96.1658233945177; Tue, 19 Jul 2022 05:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233945; cv=none; d=google.com; s=arc-20160816; b=xCSqvGjqc7P8TGWx+aqwiLbUDQEmZXJ8x6x7tLE/NEwSKyIqC5CQBADByKzIcuxHIF mhru7LT6C27wYF/YTM1gexci2sxYm5xAu/0Jp0LBsgQJ04FEwHeXiz46gK1S+sM8sY4H CKdTL6wqcx7sejmO5btt0gM2KI3OVJUIlwa6MtfIPvLoUriDiXPNZHlsFUmoARw7WJ6s n6RUIu0Uzit7fRNHTbau8NAUwihDsIkj1WPHw21Izflzl1WQ9Y2U7auR/VuGtrHBy5/H 2p8jKNNNJVhWDqg/tzkDgPfz/mmH/S3xW9iOdDVlUC+YzB+Rq3vY+daytZmPml9EpdRB tXCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LMNW12P2RfJpgn29zTVhDm9JA10yS08oF4N1Lxl/z5I=; b=KPTHPJaeLPak4azhOX8ghk3A6YLKZ/o7eZSbbLo0KcjY9BJhLUNL/0kkwHjX+1e1B5 2xgnJK8lxn9n3FOgSOB77r8a5uTgXNHhz4IeuMp/cx7Ipd8lk39M+9taM0Qg3vKaUlyB K3c+ixJBp/VpEec+6LVtMP0BFEmcTTb4kZ9D3vteAcQDVhcGKpV2MwfOAbyDy1UYy/zY nVrkEo6uTlTDDTQBlbxZm+dDiwgkuiCCc238k1K3LQ52k+7O1B/eC8NykXpcPfkkqt0E GDiCFh5RTM0RGRrrlmMdFPGhDMSxXUBsKK3tSI8vt8Au0OYGlzAQmo73znuB37gxuBDM Wc+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QZZaUdOa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170906b30d00b007157046560csi16178655ejz.884.2022.07.19.05.32.00; Tue, 19 Jul 2022 05:32:25 -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=@linuxfoundation.org header.s=korg header.b=QZZaUdOa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238554AbiGSMJF (ORCPT + 99 others); Tue, 19 Jul 2022 08:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238470AbiGSMIq (ORCPT ); Tue, 19 Jul 2022 08:08:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32EA4F6B5; Tue, 19 Jul 2022 05:01:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BF1B460F10; Tue, 19 Jul 2022 12:01:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90077C341C6; Tue, 19 Jul 2022 12:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232103; bh=zTMGL2Dz4oaFfdIx4+ZUzqOgMdKuokBrEPksJo03C0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZZaUdOaDpa0eIgEjUfm9dKevR0fIMZ0taSAwwNh04jG3ZmLkRzwW0IX240qmhyzt hUNlCsqJDrHbx4uvxqfyh4K4vLyjBxriKqXztksqOWm4N6BK+U3iOQsi5hu5eCeM8j uwTlpG265HEwCadtklb1rwRLOOUgDnyoiqcE5CMI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alyssa Rosenzweig , Steven Price , Dmitry Osipenko Subject: [PATCH 5.4 14/71] drm/panfrost: Fix shrinker list corruption by madvise IOCTL Date: Tue, 19 Jul 2022 13:53:37 +0200 Message-Id: <20220719114553.602589941@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114552.477018590@linuxfoundation.org> References: <20220719114552.477018590@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Dmitry Osipenko commit 9fc33eaaa979d112d10fea729edcd2a2e21aa912 upstream. 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 the list before it's re-added. Fix it. Cc: stable@vger.kernel.org Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") Acked-by: Alyssa Rosenzweig Reviewed-by: Steven Price Signed-off-by: Dmitry Osipenko Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20220630200601.1884120-3-dmitry.osipenko@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/panfrost/panfrost_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -428,8 +428,8 @@ static int panfrost_ioctl_madvise(struct 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); }