lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 5 Oct 2017 06:08:34 -0700
From:   tip-bot for Kees Cook <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     kvalo@....qualcomm.com, heiko.carstens@...ibm.com,
        jejb@...ux.vnet.ibm.com, mdr@....com, schwidefsky@...ibm.com,
        geert@...ux-m68k.org, ubraun@...ux.vnet.ibm.com,
        jiangshanlai@...il.com, sudipm.mukherjee@...il.com, tj@...nel.org,
        martin.petersen@...cle.com, sboyd@...eaurora.org, paulus@...ba.org,
        mark.gross@...el.com, hpa@...or.com, linux-kernel@...r.kernel.org,
        john.stultz@...aro.org, benh@...nel.crashing.org,
        keescook@...omium.org, oleg@...hat.com, wim@...ana.be,
        akpm@...ux-foundation.org, ralf@...ux-mips.org,
        gregkh@...uxfoundation.org, viresh.kumar@...aro.org,
        sre@...nel.org, mingo@...nel.org, mpe@...erman.id.au,
        cmetcalf@...lanox.com, jwi@...ux.vnet.ibm.com,
        manish.chopra@...ium.com, pavel@....cz, tglx@...utronix.de,
        stefanr@...6.in-berlin.de, pmladek@...e.com, arnd@...db.de,
        len.brown@...el.com, rjw@...ysocki.net, harish.patil@...ium.com,
        linux@...ck-us.net
Subject: [tip:timers/core] workqueue: Convert callback to use from_timer()

Commit-ID:  8c20feb60604d91a29cd7fef8ac758bd92d9fd2c
Gitweb:     https://git.kernel.org/tip/8c20feb60604d91a29cd7fef8ac758bd92d9fd2c
Author:     Kees Cook <keescook@...omium.org>
AuthorDate: Wed, 4 Oct 2017 16:27:07 -0700
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Thu, 5 Oct 2017 15:01:22 +0200

workqueue: Convert callback to use from_timer()

In preparation for unconditionally passing the struct timer_list pointer
to all timer callbacks, switch workqueue to use from_timer() and pass the
timer pointer explicitly.

Signed-off-by: Kees Cook <keescook@...omium.org>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-mips@...ux-mips.org
Cc: Petr Mladek <pmladek@...e.com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Lai Jiangshan <jiangshanlai@...il.com>
Cc: Sebastian Reichel <sre@...nel.org>
Cc: Kalle Valo <kvalo@....qualcomm.com>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Pavel Machek <pavel@....cz>
Cc: linux1394-devel@...ts.sourceforge.net
Cc: Chris Metcalf <cmetcalf@...lanox.com>
Cc: linux-s390@...r.kernel.org
Cc: linux-wireless@...r.kernel.org
Cc: "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>
Cc: Wim Van Sebroeck <wim@...ana.be>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Ursula Braun <ubraun@...ux.vnet.ibm.com>
Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Viresh Kumar <viresh.kumar@...aro.org>
Cc: Harish Patil <harish.patil@...ium.com>
Cc: Stephen Boyd <sboyd@...eaurora.org>
Cc: Guenter Roeck <linux@...ck-us.net>
Cc: Manish Chopra <manish.chopra@...ium.com>
Cc: Len Brown <len.brown@...el.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: linux-pm@...r.kernel.org
Cc: Heiko Carstens <heiko.carstens@...ibm.com>
Cc: Martin Schwidefsky <schwidefsky@...ibm.com>
Cc: Julian Wiedmann <jwi@...ux.vnet.ibm.com>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Mark Gross <mark.gross@...el.com>
Cc: linux-watchdog@...r.kernel.org
Cc: linux-scsi@...r.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@...cle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Ralf Baechle <ralf@...ux-mips.org>
Cc: Stefan Richter <stefanr@...6.in-berlin.de>
Cc: Michael Reed <mdr@....com>
Cc: netdev@...r.kernel.org
Cc: Tejun Heo <tj@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linuxppc-dev@...ts.ozlabs.org
Cc: Sudip Mukherjee <sudipm.mukherjee@...il.com>
Link: https://lkml.kernel.org/r/1507159627-127660-14-git-send-email-keescook@chromium.org

---
 include/linux/workqueue.h | 15 ++++++++-------
 kernel/workqueue.c        |  7 +++----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index f496026..f3c47a0 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -17,7 +17,7 @@ struct workqueue_struct;
 
 struct work_struct;
 typedef void (*work_func_t)(struct work_struct *work);
-void delayed_work_timer_fn(unsigned long __data);
+void delayed_work_timer_fn(struct timer_list *t);
 
 /*
  * The first word is the work queue pointer and the flags rolled into
@@ -175,8 +175,8 @@ struct execute_work {
 
 #define __DELAYED_WORK_INITIALIZER(n, f, tflags) {			\
 	.work = __WORK_INITIALIZER((n).work, (f)),			\
-	.timer = __TIMER_INITIALIZER(delayed_work_timer_fn,		\
-				     (unsigned long)&(n),		\
+	.timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+				     (TIMER_DATA_TYPE)&(n.timer),	\
 				     (tflags) | TIMER_IRQSAFE),		\
 	}
 
@@ -241,8 +241,9 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
 #define __INIT_DELAYED_WORK(_work, _func, _tflags)			\
 	do {								\
 		INIT_WORK(&(_work)->work, (_func));			\
-		__setup_timer(&(_work)->timer, delayed_work_timer_fn,	\
-			      (unsigned long)(_work),			\
+		__setup_timer(&(_work)->timer,				\
+			      (TIMER_FUNC_TYPE)delayed_work_timer_fn,	\
+			      (TIMER_DATA_TYPE)&(_work)->timer,		\
 			      (_tflags) | TIMER_IRQSAFE);		\
 	} while (0)
 
@@ -250,8 +251,8 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
 	do {								\
 		INIT_WORK_ONSTACK(&(_work)->work, (_func));		\
 		__setup_timer_on_stack(&(_work)->timer,			\
-				       delayed_work_timer_fn,		\
-				       (unsigned long)(_work),		\
+				       (TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+				       (TIMER_DATA_TYPE)&(_work)->timer,\
 				       (_tflags) | TIMER_IRQSAFE);	\
 	} while (0)
 
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a5361fc..c77fdf6 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1492,9 +1492,9 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
 }
 EXPORT_SYMBOL(queue_work_on);
 
-void delayed_work_timer_fn(unsigned long __data)
+void delayed_work_timer_fn(struct timer_list *t)
 {
-	struct delayed_work *dwork = (struct delayed_work *)__data;
+	struct delayed_work *dwork = from_timer(dwork, t, timer);
 
 	/* should have been called from irqsafe timer with irq already off */
 	__queue_work(dwork->cpu, dwork->wq, &dwork->work);
@@ -1508,8 +1508,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
 	struct work_struct *work = &dwork->work;
 
 	WARN_ON_ONCE(!wq);
-	WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
-		     timer->data != (unsigned long)dwork);
+	WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)delayed_work_timer_fn);
 	WARN_ON_ONCE(timer_pending(timer));
 	WARN_ON_ONCE(!list_empty(&work->entry));
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ