linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Christophe Leroy' <christophe.leroy@csgroup.eu>,
	Segher Boessenkool <segher@kernel.crashing.org>
Cc: Alexander Potapenko <glider@google.com>,
	Marco Elver <elver@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dmitriy Vyukov <dvyukov@google.com>,
	Andrey Konovalov <andreyknvl@google.com>,
	Jann Horn <jannh@google.com>, LKML <linux-kernel@vger.kernel.org>,
	"Linux Memory Management List" <linux-mm@kvack.org>,
	kasan-dev <kasan-dev@googlegroups.com>
Subject: RE: [PATCH mm] kfence: fix printk format for ptrdiff_t
Date: Thu, 18 Mar 2021 09:14:27 +0000	[thread overview]
Message-ID: <4f7becfe2b6e4263be83b5ee461b5732@AcuMS.aculab.com> (raw)
In-Reply-To: <001a139e-d4fa-2fd7-348f-173392210dfd@csgroup.eu>

From: Christophe Leroy
> Sent: 17 March 2021 17:35
> 
> Le 17/03/2021 à 13:51, David Laight a écrit :
> > From: Christophe Leroy
> >> Sent: 16 March 2021 15:41
> > ...
> >>>> include/linux/types.h:typedef __kernel_ptrdiff_t	ptrdiff_t;
> >>>>
> >>>> And get:
> >>>>
> >>>>     CC      mm/kfence/report.o
> >>>> In file included from ./include/linux/printk.h:7,
> >>>>                    from ./include/linux/kernel.h:16,
> >>>>                    from mm/kfence/report.c:10:
> >>>> mm/kfence/report.c: In function 'kfence_report_error':
> >>>> ./include/linux/kern_levels.h:5:18: warning: format '%td' expects argument
> >>>> of type 'ptrdiff_t', but argument 6 has type 'long int' [-Wformat=]
> >>>
> >>> This is declared as
> >>>           const ptrdiff_t object_index = meta ? meta - kfence_metadata : -1;
> >>> so maybe something with that goes wrong?  What happens if you delete the
> >>> (useless) "const" here?
> >
> > The obvious thing to try is changing it to 'int'.
> > That will break 64bit builds, but if it fixes the 32bit one
> > it will tell you what type gcc is expecting.
> >
> 
> Yes, if defining 'object_index' as int, gcc is happy.
> If removing the powerpc re-definition of ptrdiff_t typedef in
> https://elixir.bootlin.com/linux/v5.12-rc3/source/arch/powerpc/include/uapi/asm/posix_types.h , it
> works great as well.
> 
> So seems like gcc doesn't take into account the typedef behind ptrdiff_t, it just expects it to be
> int on 32 bits ?

gcc never cares how ptrdiff_t (or any of the related types) is defined
it requires int or long for the format depending on the architecture.
The error message will say ptrdiff_t or size_t (etc) - but that is just
in the error message.

So the ppc32 uapi definition of __kernel_ptrdiff_t is wrong.
However it is probably set in stone.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2021-03-18  9:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 12:11 Marco Elver
2021-03-03 12:27 ` Alexander Potapenko
2021-03-16  8:32   ` Christophe Leroy
2021-03-16 15:33     ` Segher Boessenkool
2021-03-16 15:40       ` Christophe Leroy
2021-03-17 12:51         ` David Laight
2021-03-17 17:35           ` Christophe Leroy
2021-03-18  9:14             ` David Laight [this message]
2021-03-18  9:38               ` Christophe Leroy
2021-03-19 11:37                 ` Segher Boessenkool

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=4f7becfe2b6e4263be83b5ee461b5732@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=jannh@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=segher@kernel.crashing.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