public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] PM: core: Do not randomize struct dev_pm_ops layout
Date: Thu, 04 Aug 2022 19:15:08 +0200	[thread overview]
Message-ID: <2643836.mvXUDI8C0e@kreacher> (raw)

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), \




             reply	other threads:[~2022-08-04 17:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 17:15 Rafael J. Wysocki [this message]
2022-08-05  2:12 ` [PATCH] PM: core: Do not randomize struct dev_pm_ops layout Kees Cook
2022-08-05 14:10   ` Rafael J. Wysocki
2022-08-05 18:19     ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2643836.mvXUDI8C0e@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox