Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4451861imw; Tue, 19 Jul 2022 06:55:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tHbOtGKrGb69s66YHpQs1mg7gp5BrxTEhxdYM8MbFd59W2NgAYPXdK2P1ktNe9D4yo53m3 X-Received: by 2002:a05:6402:4011:b0:43a:84de:26b1 with SMTP id d17-20020a056402401100b0043a84de26b1mr43371990eda.402.1658238935499; Tue, 19 Jul 2022 06:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238935; cv=none; d=google.com; s=arc-20160816; b=v1yHcUlA2+m0IMiE31rGo5iXfsmScDkE7Led0q8MBqa2+4NUSlYbHDvF4rJ/6Np0ox 5GxeMmQf60K8s3qHys3SNPxWyTKAdByGahi5hYOmNvx8PiR1G5mkZTcD9H8YDcwy11SV SszNUJsmTT3eA9QZh6YJ7QNQ9bL55pU/8ZxSKjbb5j8jkUkoezbQ9JmrSk8npdKYOUxu fkZyKtx+CDKzbghwnEspDcQ+DLdDQ97RunLU1H7LaicdXfvB+tDwt2wAO95rOvx5fHkj 1N8fbVLKAO9irKy6shGMLyp+L2Y+1qFKG1+lcRrzsLeGzGbeWj6DT94I9PutCLcB2EOQ SzgQ== 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=CZJLx5yvhTdQr4apgzrWlhLZs4poibsz6za/lLHPub0=; b=Cy3Wr3mxMfLH/j10hKGBVLbLavbbqUsuA/BwcdvJ1k9JgLroV6HMZ7tqiG2bHZNR5W oZcO1IC4KhGJY9VJuwApndj4aI5/1s8LWSDMEpU/YU8yizIaxck/gJLyu1p2+PHgwcZB aQ4bg+CIZy8Km8okaOBd/+cC1P5y+IxL2eT8GHH9rZkqvHZlFBrNo4xuMXN4ylb3F4Ui S9S60tygIDm8gDh4x5/T0OlBSHs5cTS2t9XLjsYcmJgvqLBEizqLnXGy23hCZTb0iO4g XGejIfXxiFv0U+gEmW9He+NnkDuJLLsrNl78RJtzmW0XPPtIL7mWBEnIy7/FzCb0n2fB ajMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jnB8J1Wi; 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 i15-20020a1709064fcf00b0072f40cafeadsi9139670ejw.637.2022.07.19.06.55.10; Tue, 19 Jul 2022 06:55:35 -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=jnB8J1Wi; 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 S239310AbiGSMVN (ORCPT + 99 others); Tue, 19 Jul 2022 08:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239587AbiGSMTf (ORCPT ); Tue, 19 Jul 2022 08:19:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87ACA58874; Tue, 19 Jul 2022 05:07:01 -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 ams.source.kernel.org (Postfix) with ESMTPS id 98E0BB81B2C; Tue, 19 Jul 2022 12:06:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08355C341C6; Tue, 19 Jul 2022 12:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232406; bh=TUEZca48WL3fXZha1QOFriX2mICYwGrA7prQ5bSVqUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnB8J1Wi29BNNf9N0v4k+Bqqh9zahFMMuCTkWeKLNs/O3tHADdS/7hiIMPWSdeODV z7lktFpGprhqaY8H6Bvttzl/R0Y5Nzu/Mse8DUqE5h4IusLO9vZOEDZWyuA5ZKgkWS auUiQwo0Vb/+5FIeyiX/sL1/7FEtCXt0NaObKNV4= 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.10 019/112] drm/panfrost: Fix shrinker list corruption by madvise IOCTL Date: Tue, 19 Jul 2022 13:53:12 +0200 Message-Id: <20220719114627.846889705@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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 @@ -427,8 +427,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); }