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: 9985913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D20B7602B8 for ; Wed, 4 Oct 2017 23:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C440226E96 for ; Wed, 4 Oct 2017 23:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B865328C21; Wed, 4 Oct 2017 23:31:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CE4E26E96 for ; Wed, 4 Oct 2017 23:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751875AbdJDX3I (ORCPT ); Wed, 4 Oct 2017 19:29:08 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:46445 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751548AbdJDX2H (ORCPT ); Wed, 4 Oct 2017 19:28:07 -0400 Received: by mail-pf0-f178.google.com with SMTP id r68so7042349pfj.3 for ; Wed, 04 Oct 2017 16:28:07 -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=QwOHxBqfzH5zUaT9ecRvTwx4h5aLcu8Ze5fMs1QAEAwoHJzxXnQGRgihnpQ9UJ86jt cuzUzQpOHUWdY4OtWPUR4jJk0pXynQYVn1JtbAVT8G1iKJ0hdTxtXEeM+vaTWdLouizt QLF3QidHm6rcN5mYKzq9LpqCiSGBqgVZssA8nx7gEhRQ7O7raO1INEqHWCZA+AneHcMY 6wcZeq6N5loxa0OQlwa0jAB3Sfj5FwKXwbQMjxjcgtm/HyZ+rspV3JyNtqjgYF8kCCIV 4iPx2KCM60q11KICPsMZkfeMTlDkDxT0fvqkZ3WAlcHTHQ8hPSDns/PEPzG3j1pEF95s 6NeQ== X-Gm-Message-State: AHPjjUhpo0blScooT/Za+mWoatdwg/b2r4rlegSpOLea98fKZF05SpV9 oPhXzNodjMSzm3WU1SmHkJC/JQ== 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 Cc: Kees Cook , Tejun Heo , Lai Jiangshan , Andrew Morton , Arnd Bergmann , Benjamin Herrenschmidt , Chris Metcalf , Geert Uytterhoeven , Greg Kroah-Hartman , Guenter Roeck , Harish Patil , Heiko Carstens , "James E.J. Bottomley" , John Stultz , Julian Wiedmann , Kalle Valo , Len Brown , Manish Chopra , Mark Gross , "Martin K. Petersen" , Martin Schwidefsky , Michael Ellerman , Michael Reed , netdev@vger.kernel.org, Oleg Nesterov , Paul Mackerras , Pavel Machek , Petr Mladek , "Rafael J. Wysocki" , Ralf Baechle , Sebastian Reichel , Stefan Richter , Stephen Boyd , Sudip Mukherjee , Ursula Braun , Viresh Kumar , Wim Van Sebroeck , linux1394-devel@lists.sourceforge.net, linux-mips@linux-mips.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org 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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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));