linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM: declare __tracedata symbols as char[] rather than char
@ 2016-01-25  2:08 Eric Biggers
  2016-02-21 13:45 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2016-01-25  2:08 UTC (permalink / raw)
  To: rjw; +Cc: linux-pm, pavel, len.brown, gregkh, linux-kernel, Eric Biggers

Accessing more than one byte from a symbol declared simply 'char' is undefined
behavior, as reported by UBSAN:

	UBSAN: Undefined behaviour in drivers/base/power/trace.c:178:18
	load of address ffffffff8203fc78 with insufficient space
	for an object of type 'char'

Avoid this by declaring the symbols as arrays.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
 drivers/base/power/trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index a311cfa..a697579 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -166,14 +166,14 @@ void generate_pm_trace(const void *tracedata, unsigned int user)
 }
 EXPORT_SYMBOL(generate_pm_trace);
 
-extern char __tracedata_start, __tracedata_end;
+extern char __tracedata_start[], __tracedata_end[];
 static int show_file_hash(unsigned int value)
 {
 	int match;
 	char *tracedata;
 
 	match = 0;
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ;
+	for (tracedata = __tracedata_start ; tracedata < __tracedata_end ;
 			tracedata += 2 + sizeof(unsigned long)) {
 		unsigned short lineno = *(unsigned short *)tracedata;
 		const char *file = *(const char **)(tracedata + 2);
-- 
2.7.0


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

* Re: [PATCH] PM: declare __tracedata symbols as char[] rather than char
  2016-01-25  2:08 [PATCH] PM: declare __tracedata symbols as char[] rather than char Eric Biggers
@ 2016-02-21 13:45 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2016-02-21 13:45 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-pm, pavel, len.brown, gregkh, linux-kernel

On Sunday, January 24, 2016 08:08:52 PM Eric Biggers wrote:
> Accessing more than one byte from a symbol declared simply 'char' is undefined
> behavior, as reported by UBSAN:
> 
> 	UBSAN: Undefined behaviour in drivers/base/power/trace.c:178:18
> 	load of address ffffffff8203fc78 with insufficient space
> 	for an object of type 'char'
> 
> Avoid this by declaring the symbols as arrays.
> 
> Signed-off-by: Eric Biggers <ebiggers3@gmail.com>

Queued up for 4.6, thanks!

Rafael

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

end of thread, other threads:[~2016-02-21 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25  2:08 [PATCH] PM: declare __tracedata symbols as char[] rather than char Eric Biggers
2016-02-21 13:45 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).