Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1452384 > unrolled thread

[PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer

Started byNicolas Iooss <nicolas.iooss_linux@m4x.org>
First post2016-07-29 13:20 +0200
Last post2016-07-30 10:40 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2016-07-29 13:20 +0200
    Re: [PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer Joe Perches <joe@perches.com> - 2016-07-29 22:00 +0200
      Re: [PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2016-07-30 10:30 +0200
        [PATCH 1/1] UBSAN: fix typo in format string Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2016-07-30 10:40 +0200

#1452384 — [PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer

FromNicolas Iooss <nicolas.iooss_linux@m4x.org>
Date2016-07-29 13:20 +0200
Subject[PATCH 1/1] UBSAN: use uppercase K to format a kernel pointer
Message-ID<s0dZD-3Vu-3@gated-at.bofh.it>
handle_object_size_mismatch() used %pk to format a kernel pointer in
pr_err().  This seems to be a misspelling for %pK.

Fixes: c6d308534aef ("UBSAN: run-time undefined behavior sanity checker")
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 lib/ubsan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index 8799ae5e2e42..d57d1e7e98a3 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -308,7 +308,7 @@ static void handle_object_size_mismatch(struct type_mismatch_data *data,
 		return;
 
 	ubsan_prologue(&data->location, &flags);
-	pr_err("%s address %pk with insufficient space\n",
+	pr_err("%s address %pK with insufficient space\n",
 		type_check_kinds[data->type_check_kind],
 		(void *) ptr);
 	pr_err("for an object of type %s\n", data->type->type_name);
-- 
2.9.0

[toc] | [next] | [standalone]


#1452537

FromJoe Perches <joe@perches.com>
Date2016-07-29 22:00 +0200
Message-ID<s0m6S-Em-11@gated-at.bofh.it>
In reply to#1452384
On Fri, 2016-07-29 at 13:10 +0200, Nicolas Iooss wrote:
> handle_object_size_mismatch() used %pk to format a kernel pointer in
> pr_err().  This seems to be a misspelling for %pK.

Thanks


> diff --git a/lib/ubsan.c b/lib/ubsan.c
[]
> @@ -308,7 +308,7 @@ static void handle_object_size_mismatch(struct
> type_mismatch_data *data,
>  		return;
>  
>  	ubsan_prologue(&data->location, &flags);
> -	pr_err("%s address %pk with insufficient space\n",
> +	pr_err("%s address %pK with insufficient space\n",
>  		type_check_kinds[data->type_check_kind],
>  		(void *) ptr);
>  	pr_err("for an object of type %s\n", data->type->type_name);

Maybe change this to a single output line:

	pr_err("%s address %pK with insufficient space for an object of type %s\n",
	       type_check_kinds[data->type_check_kind], (void *)ptr,
	       data->type->type_name);

[toc] | [prev] | [next] | [standalone]


#1452661

FromNicolas Iooss <nicolas.iooss_linux@m4x.org>
Date2016-07-30 10:30 +0200
Message-ID<s0xOF-8uB-3@gated-at.bofh.it>
In reply to#1452537
On 07/29/2016 09:53 PM, Joe Perches wrote:
> On Fri, 2016-07-29 at 13:10 +0200, Nicolas Iooss wrote:
>> handle_object_size_mismatch() used %pk to format a kernel pointer in
>> pr_err().  This seems to be a misspelling for %pK.
> 
> Thanks

Thanks for your feedbacks. I agree %pK does not make much sense in the
context it is used. I will modify this patch to use %p instead.

>> diff --git a/lib/ubsan.c b/lib/ubsan.c
> []
>> @@ -308,7 +308,7 @@ static void handle_object_size_mismatch(struct
>> type_mismatch_data *data,
>>  		return;
>>  
>>  	ubsan_prologue(&data->location, &flags);
>> -	pr_err("%s address %pk with insufficient space\n",
>> +	pr_err("%s address %pK with insufficient space\n",
>>  		type_check_kinds[data->type_check_kind],
>>  		(void *) ptr);
>>  	pr_err("for an object of type %s\n", data->type->type_name);
> 
> Maybe change this to a single output line:
> 
> 	pr_err("%s address %pK with insufficient space for an object of type %s\n",
> 	       type_check_kinds[data->type_check_kind], (void *)ptr,
> 	       data->type->type_name);

As both handle_missaligned_access() and handle_object_size_mismatch()
use two pr_err() calls to display their error messages, it seems the
split has been made on purpose (maybe to avoid logging long lines).
I won't merge the calls in my patch as this appears to be more an
ergonomic subject for people really using this code.

-- Nicolas

[toc] | [prev] | [next] | [standalone]


#1452662 — [PATCH 1/1] UBSAN: fix typo in format string

FromNicolas Iooss <nicolas.iooss_linux@m4x.org>
Date2016-07-30 10:40 +0200
Subject[PATCH 1/1] UBSAN: fix typo in format string
Message-ID<s0xYm-6t-11@gated-at.bofh.it>
In reply to#1452661
handle_object_size_mismatch() used %pk to format a kernel pointer with
pr_err().  This seemed to be a misspelling for %pK, but using this to
format a kernel pointer does not make much sence here.

Therefore use %p instead, like in handle_missaligned_access().

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
 lib/ubsan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index 8799ae5e2e42..fb0409df1bcf 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -308,7 +308,7 @@ static void handle_object_size_mismatch(struct type_mismatch_data *data,
 		return;
 
 	ubsan_prologue(&data->location, &flags);
-	pr_err("%s address %pk with insufficient space\n",
+	pr_err("%s address %p with insufficient space\n",
 		type_check_kinds[data->type_check_kind],
 		(void *) ptr);
 	pr_err("for an object of type %s\n", data->type->type_name);
-- 
2.9.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web