From patchwork Wed Oct 4 23:27:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 821535 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y6t5C14MWz9t39 for ; Thu, 5 Oct 2017 10:53:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PZH4ATsX"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3y6t5B73FHzDr2n for ; Thu, 5 Oct 2017 10:53:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PZH4ATsX"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:400e:c00::22f; helo=mail-pf0-x22f.google.com; envelope-from=keescook@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PZH4ATsX"; dkim-atps=neutral Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com [IPv6:2607:f8b0:400e:c00::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3y6sX90PR6zDr1y for ; Thu, 5 Oct 2017 10:28:09 +1100 (AEDT) Received: by mail-pf0-x22f.google.com with SMTP id z84so7040890pfi.2 for ; Wed, 04 Oct 2017 16:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DT4cSE8CrReZntu4jHNGhn7m+qOKVCaJI6Hr85gR040=; b=PZH4ATsXg52DJOJBqiBbSv+Jckrl9j2ea2iz1J4oLKOOa0b+k2RViAkh7sGOwAzoj9 /iqceILnwT8/nr0TOH+VzgKuFO+GQsyNz2m+bDy15rjwnBlDSE6ANOnDDWJmtQhAIoX8 wfqiARND5kC4aKKjTbkU0A93QDa4jiKo1OjRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DT4cSE8CrReZntu4jHNGhn7m+qOKVCaJI6Hr85gR040=; b=P+oIJs0gKwHu2ZIcufi8CFEEWvV396uulHeQLz49s5rWMzuZbP+G0oOy51p8CG35iU hg1dQFsljlENUUQlWtOGVtrIPGQ+e7ffomLgxrzf9SVvaT9Wp6AUZe/sIuFQvUIgj1C1 g0kFr9waw2lj3HxwTOgQPzDFGd9a+TIfE6aSMSPj+2+a1NH1le8ZdTGAEMA9LWIUNbPP oBmcs+WiL4Z4h0pPa3qSQQ8cmj2qgeY633WXhnMKAxIGMRjpDf54EVl1k0s7ypZY0rF0 0wgvVCkt9B8z4srJaPJMNUfIJOCWHbh5+bqPp8NzgEwxlPx0xgXeoJOvfR9WV+3lnzUH GqfA== X-Gm-Message-State: AHPjjUi073rEqKm4ABEJLZGXUKVHjmXhIgOEzT87fNNNAlJY0pPm7syI CxWtntH7qnl87QQFxaIi5bNmfA== X-Google-Smtp-Source: AOwi7QB9FqJmxHiOwuV2vB5TfENqHLFIYclzbhARdf33WFIVWjrY7Lol2zIjFj0VYKIs0uK8JfSjQA== X-Received: by 10.84.160.6 with SMTP id n6mr21387467pla.393.1507159687244; Wed, 04 Oct 2017 16:28:07 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id x4sm27395101pfb.101.2017.10.04.16.27.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 16:28:04 -0700 (PDT) From: Kees Cook To: Thomas Gleixner Subject: [PATCH 13/13] workqueue: Convert callback to use from_timer() Date: Wed, 4 Oct 2017 16:27:07 -0700 Message-Id: <1507159627-127660-14-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507159627-127660-1-git-send-email-keescook@chromium.org> References: <1507159627-127660-1-git-send-email-keescook@chromium.org> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Petr Mladek , Lai Jiangshan , Sebastian Reichel , Kalle Valo , Paul Mackerras , Pavel Machek , linux1394-devel@lists.sourceforge.net, Chris Metcalf , linux-s390@vger.kernel.org, linux-wireless@vger.kernel.org, "James E.J. Bottomley" , Wim Van Sebroeck , Ursula Braun , Geert Uytterhoeven , Viresh Kumar , Harish Patil , Stephen Boyd , Guenter Roeck , Manish Chopra , Len Brown , Kees Cook , Arnd Bergmann , linux-pm@vger.kernel.org, Heiko Carstens , Martin Schwidefsky , Julian Wiedmann , John Stultz , Mark Gross , linux-watchdog@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K. Petersen" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Oleg Nesterov , Ralf Baechle , linux-kernel@vger.kernel.org, Stefan Richter , Michael Reed , netdev@vger.kernel.org, Tejun Heo , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Sudip Mukherjee Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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. Cc: Tejun Heo Cc: Lai Jiangshan Signed-off-by: Kees Cook --- 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 f4960260feaf..f3c47a05fd06 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 a5361fc6215d..c77fdf6bf24f 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));