From patchwork Tue Jan 9 14:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1884498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T8Xzz1kySz1yPh for ; Wed, 10 Jan 2024 01:16:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rNCuC-0008BZ-D5; Tue, 09 Jan 2024 14:16:36 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rNCu9-0008B4-9s for kernel-team@lists.ubuntu.com; Tue, 09 Jan 2024 14:16:33 +0000 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id CF8423F2C4 for ; Tue, 9 Jan 2024 14:16:32 +0000 (UTC) Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3bd24849608so3684740b6e.2 for ; Tue, 09 Jan 2024 06:16:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704809791; x=1705414591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r4TRUllwdRKDxIQM8gogXjFafXnFoAO9W+KpjXZMiBI=; b=OfE9KXbbzxtxxsDsrdo+R1db9XdDXRw0mB+h1jNo/MyWn++dzRc8h0wALYPvHvxGAk joCDcHrfcutOskKnB71MiKt2+X9b2OvIcJR7Z/hEdF2N2nSjI0gnGYBc2Hky4LJlr7Xh OejhMySVj66fxCwVWMqXuEYGzfRgDU66MNrebXYKTqTpZCGJrxzqTov7f3M9ENG6stoC 6Ay0zpCTgsT+AmX9nHrdgGjbsypnZ0GVJfWaD8e0TOJ4gPp3FVWuhZk2Rl1jtWznlQO0 44KHS3Bs1uckiwKN9kANADhNwEY9Deix79gm1XAvaw0ArroL7I764Bj5UKAt2RqCTCho yBAg== X-Gm-Message-State: AOJu0Yy/0Tro+NA4iLq4PGKRySAuUeHKs5sd5nuM+3Y0Kf0i8EWgUedt cidFcTQiSeIUl0qDAnOwxFZCz+E6cBQHpZ/nmiPOwYTUpiArLDnnnMoOPx5ytnXQba7fi1qIF+Q LEypFQ/g6ngsBCItPHu/FRicaiaF2LuKmfcNNi072+4ZVGQ0QJiR+2IQt X-Received: by 2002:a05:6808:1208:b0:3bb:d3ae:905a with SMTP id a8-20020a056808120800b003bbd3ae905amr6296923oil.77.1704809791337; Tue, 09 Jan 2024 06:16:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1l7uuHqHBe8mhLOD6PCPjojQ1ZFpR4syZwOcSvoQCxodPwFJ8tWm5yyCmbRWs1nrA5BSiZw== X-Received: by 2002:a05:6808:1208:b0:3bb:d3ae:905a with SMTP id a8-20020a056808120800b003bbd3ae905amr6296911oil.77.1704809791013; Tue, 09 Jan 2024 06:16:31 -0800 (PST) Received: from smtp.gmail.com (184-091-006-043.res.spectrum.com. [184.91.6.43]) by smtp.gmail.com with ESMTPSA id o17-20020a0561023f9100b00467bdea3a41sm282706vsv.19.2024.01.09.06.16.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:16:30 -0800 (PST) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][Focal][PATCH 1/1] Input: cyttsp4_core - change del_timer_sync() to timer_shutdown_sync() Date: Tue, 9 Jan 2024 09:16:28 -0500 Message-Id: <20240109141628.20674-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240109141628.20674-1-bethany.jamison@canonical.com> References: <20240109141628.20674-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Duoming Zhou The watchdog_timer can schedule tx_timeout_task and watchdog_work can also arm watchdog_timer. The process is shown below: ----------- timer schedules work ------------ cyttsp4_watchdog_timer() //timer handler schedule_work(&cd->watchdog_work) ----------- work arms timer ------------ cyttsp4_watchdog_work() //workqueue callback function cyttsp4_start_wd_timer() mod_timer(&cd->watchdog_timer, ...) Although del_timer_sync() and cancel_work_sync() are called in cyttsp4_remove(), the timer and workqueue could still be rearmed. As a result, the possible use after free bugs could happen. The process is shown below: (cleanup routine) | (timer and workqueue routine) cyttsp4_remove() | cyttsp4_watchdog_timer() //timer cyttsp4_stop_wd_timer() | schedule_work() del_timer_sync() | | cyttsp4_watchdog_work() //worker | cyttsp4_start_wd_timer() | mod_timer() cancel_work_sync() | | cyttsp4_watchdog_timer() //timer | schedule_work() del_timer_sync() | kfree(cd) //FREE | | cyttsp4_watchdog_work() // reschedule! | cd-> //USE This patch changes del_timer_sync() to timer_shutdown_sync(), which could prevent rearming of the timer from the workqueue. Fixes: 17fb1563d69b ("Input: cyttsp4 - add core driver for Cypress TMA4XX touchscreen devices") Signed-off-by: Duoming Zhou Link: https://lore.kernel.org/r/20230421082919.8471-1-duoming@zju.edu.cn Signed-off-by: Dmitry Torokhov (cherry picked from commit dbe836576f12743a7d2d170ad4ad4fd324c4d47a) CVE-2023-4134 Signed-off-by: Bethany Jamison --- drivers/input/touchscreen/cyttsp4_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index dccbcb942fe5..f999265896f4 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -1263,9 +1263,8 @@ static void cyttsp4_stop_wd_timer(struct cyttsp4 *cd) * Ensure we wait until the watchdog timer * running on a different CPU finishes */ - del_timer_sync(&cd->watchdog_timer); + timer_shutdown_sync(&cd->watchdog_timer); cancel_work_sync(&cd->watchdog_work); - del_timer_sync(&cd->watchdog_timer); } static void cyttsp4_watchdog_timer(struct timer_list *t)