Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3657440pxb; Tue, 7 Sep 2021 04:54:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Sz5W1TD4vwNW17VeXVj5Lf8zAJLzkIGBC8fcDOxT1vDxaUMZ5awTY8iplRNicQ41u0Kv X-Received: by 2002:a05:6602:2c0f:: with SMTP id w15mr14369560iov.106.1631015684184; Tue, 07 Sep 2021 04:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631015684; cv=none; d=google.com; s=arc-20160816; b=B4MC0x9BBzCguw5zyfDXE44wSZ6gd8KcZI7fLwG/q2z4eEf/3THJBGYLg3C751Y6U3 y6JrweLZZxYBPcJfw/qKXNegxY2oO7+qWzNfAQruW6RzgQND8BChkZkM85elYwXIoXzM 2xFjs3YxLfAT99Jfa+QHPkPBFeffD+LDhAtCER0ELaSA9I7hhWSCA26tOnJGvGhYk75U ejsoirgLcxe6jPCPxqsTVJPCVIbILPqHlRTctSVxPk0ncXwM9POldOFgkGsMXSdHCIXb dQswDhaRV2EhNwXaV5QRciLUl9m/5iaGBSxjuaXJPMSqCCb/lI57nFI/2DmsNPVH43pg R20A== 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 :message-id:date:subject:cc:to:from; bh=uhbOp4/uaMNcHY4/CmjNf3tbSt8Zu+yidySm8HfX3oA=; b=cPtsXjeNA/3dD9YRmMvHT+iTqvhmwD6DatMhzbgA1pygxETOWuD6IRuXvR0Hj95916 zXyYOh8XLpRea47t8LEqvdH8Jukz0oBNTX/ylIg+aBbrdoJh9gZSukW33USYC5ztX6+L 4moCxkpsiCAjF1fvdfG7PZhqPmYVeGCOzyhmYxbuiapk3NkwWXVx+1HW+SNEEzQgfjVE vtfqzUDlulV/aBdOMgVaN0yL8qkC1rokJWHc2lfJDD5rbkk3Z+e43PboknP9AO4Kiy/n NkFqRAaRDdJd9nF5TgIPR8Jocgav3fNWawig+og8zRn3vmxTMpHn7g0WRIYF5Db33vY1 edsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r13si10495179ilo.33.2021.09.07.04.54.31; Tue, 07 Sep 2021 04:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243105AbhIGLon (ORCPT + 99 others); Tue, 7 Sep 2021 07:44:43 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:15301 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbhIGLoj (ORCPT ); Tue, 7 Sep 2021 07:44:39 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4H3k0j4mfVz8srh; Tue, 7 Sep 2021 19:43:01 +0800 (CST) Received: from dggema773-chm.china.huawei.com (10.1.198.217) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Tue, 7 Sep 2021 19:43:30 +0800 Received: from localhost.huawei.com (10.175.124.27) by dggema773-chm.china.huawei.com (10.1.198.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Tue, 7 Sep 2021 19:43:29 +0800 From: Li Jinlin To: , CC: , , , , Subject: [PATCH] blk-throttle: fix UAF by deleteing timer in blk_throtl_exit() Date: Tue, 7 Sep 2021 20:12:42 +0800 Message-ID: <20210907121242.2885564-1-lijinlin3@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggema773-chm.china.huawei.com (10.1.198.217) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Jinlin The pending timer has been set up in blk_throtl_init(). However, the timer is not deleted in blk_throtl_exit(). This means that the timer handler may still be running after freeing the timer, which would result in a use-after-free. Fix by calling del_timer_sync() to delete the timer in blk_throtl_exit(). Signed-off-by: Li Jinlin --- block/blk-throttle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 55c49015e533..dbe49e181a88 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -2458,6 +2458,7 @@ int blk_throtl_init(struct request_queue *q) void blk_throtl_exit(struct request_queue *q) { BUG_ON(!q->td); + del_timer_sync(&q->td->service_queue.pending_timer); throtl_shutdown_wq(q); blkcg_deactivate_policy(q, &blkcg_policy_throtl); free_percpu(q->td->latency_buckets[READ]); -- 2.27.0