ANDROID: workqueue: cfi: disable callback pointer check with modules

With CFI, a callback function passed to __queue_delayed_work from a
module can point to a jump table entry defined in the module instead
of the one used in the core kernel, which breaks this test:

  WARN_ON_ONCE(timer->function != delayed_work_timer_fn);

To work around the problem, disable the warning when CFI and modules
are both enabled.

Bug: 145210207
Change-Id: I2a631ea3da9e401af38accf1001082b93b9b3443
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
Sami Tolvanen
2020-03-19 17:09:31 -07:00
committed by Alistair Delva
parent a4e9712d70
commit 83eeb88742

View File

@@ -1634,7 +1634,14 @@ 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);
/*
* With CFI, timer->function can point to a jump table entry in a module,
* which fails the comparison. Disable the warning if CFI and modules are
* both enabled.
*/
if (!IS_ENABLED(CONFIG_CFI_CLANG) || !IS_ENABLED(CONFIG_MODULES))
WARN_ON_ONCE(timer->function != delayed_work_timer_fn);
WARN_ON_ONCE(timer_pending(timer));
WARN_ON_ONCE(!list_empty(&work->entry));