All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM: core: Do not randomize struct dev_pm_ops layout
@ 2022-08-04 17:15 Rafael J. Wysocki
  2022-08-05  2:12 ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-08-04 17:15 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Kees Cook, Greg Kroah-Hartman

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Because __rpm_get_callback() uses offsetof() to compute the address of
the callback in question in struct dev_pm_ops, randomizing the layout
of the latter leads to interesting, but unfortunately also undesirable
results in some cases.

Prevent that from happening by using the __no_randomize_layout
annotation on struct dev_pm_ops.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/linux/pm.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/include/linux/pm.h
===================================================================
--- linux-pm.orig/include/linux/pm.h
+++ linux-pm/include/linux/pm.h
@@ -307,7 +307,7 @@ struct dev_pm_ops {
 	int (*runtime_suspend)(struct device *dev);
 	int (*runtime_resume)(struct device *dev);
 	int (*runtime_idle)(struct device *dev);
-};
+} __no_randomize_layout;
 
 #define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
 	.suspend = pm_sleep_ptr(suspend_fn), \




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-05 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 17:15 [PATCH] PM: core: Do not randomize struct dev_pm_ops layout Rafael J. Wysocki
2022-08-05  2:12 ` Kees Cook
2022-08-05 14:10   ` Rafael J. Wysocki
2022-08-05 18:19     ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.