From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B25664CF2; Mon, 8 Apr 2024 13:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581300; cv=none; b=OQuOTCA9V9mErzeihbKR+DIoYxw8KkJtaxeMWqYJEjnQmURgG/vYTvxYi5RvlMGr32i4isyXU3pgdBcQeAxKLyv+aNqCi3UIHcTVKEIXxuuRM6AoqxDrx1if9VjRvOr4AL1e9/MJpsAuFl9R9WNj2VDeO+03+nWQkZuM+Y5Vs1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581300; c=relaxed/simple; bh=EMiZ4mOc3YyTGBwkBhLaby5XULUoNOZQU1QnTM3WqpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XM5cCnOZouFsZML1IUVXsV+4oBW2piBx60Sj2/TXgQXrDEtqTwcDdLPeBcOhKb4E6nQyKYd87upzTeZ2L1zCkLYAlvX+8cWOXVpYMEAb7b8DHBHh2HTz1Krlj2d+MDVayvY4ndiMUeMunY6fAMfTAfGSFDuJyqcWytRbCXMaPcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=z8ost3Iz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="z8ost3Iz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78392C433C7; Mon, 8 Apr 2024 13:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712581299; bh=EMiZ4mOc3YyTGBwkBhLaby5XULUoNOZQU1QnTM3WqpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z8ost3Izd4Jjk6GyZsA5aQZjU/wzBzPBp6eAMQUkic0v8i+wCwWP7/r8WACEzpO7w bvvuLIpKnqyZ1tTAGMdC/t5ybA9gLKIvPx55I00pLBoUtuaKJGV6DSXbCF+k5AfEnf 04xw3Pw/sPwvWgir7+h4XrHf7j4oK1/ApEqyb6rc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Steven Rostedt , Thomas Gleixner , Guenter Roeck , Jacob Keller , Anna-Maria Behnsen , Sasha Levin Subject: [PATCH 5.15 008/690] timers: Use del_timer_sync() even on UP Date: Mon, 8 Apr 2024 14:47:54 +0200 Message-ID: <20240408125359.844849797@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408125359.506372836@linuxfoundation.org> References: <20240408125359.506372836@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner [ Upstream commit 168f6b6ffbeec0b9333f3582e4cf637300858db5 ] del_timer_sync() is assumed to be pointless on uniprocessor systems and can be mapped to del_timer() because in theory del_timer() can never be invoked while the timer callback function is executed. This is not entirely true because del_timer() can be invoked from interrupt context and therefore hit in the middle of a running timer callback. Contrary to that del_timer_sync() is not allowed to be invoked from interrupt context unless the affected timer is marked with TIMER_IRQSAFE. del_timer_sync() has proper checks in place to detect such a situation. Give up on the UP optimization and make del_timer_sync() unconditionally available. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org Link: https://lore.kernel.org/r/20221123201624.888306160@linutronix.de Stable-dep-of: 0f7352557a35 ("wifi: brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach") Signed-off-by: Sasha Levin --- include/linux/timer.h | 7 +------ kernel/time/timer.c | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index fda13c9d1256c..2e6f50b342662 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -183,12 +183,7 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires); extern void add_timer(struct timer_list *timer); extern int try_to_del_timer_sync(struct timer_list *timer); - -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) - extern int del_timer_sync(struct timer_list *timer); -#else -# define del_timer_sync(t) del_timer(t) -#endif +extern int del_timer_sync(struct timer_list *timer); #define del_singleshot_timer_sync(t) del_timer_sync(t) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index f64dd2bd0a84c..2c0e26718c7a9 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1341,7 +1341,6 @@ static inline void timer_sync_wait_running(struct timer_base *base) { } static inline void del_timer_wait_running(struct timer_list *timer) { } #endif -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) /** * del_timer_sync - Deactivate a timer and wait for the handler to finish. * @timer: The timer to be deactivated @@ -1422,7 +1421,6 @@ int del_timer_sync(struct timer_list *timer) return ret; } EXPORT_SYMBOL(del_timer_sync); -#endif static void call_timer_fn(struct timer_list *timer, void (*fn)(struct timer_list *), -- 2.43.0