All of lore.kernel.org
 help / color / mirror / Atom feed
* [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
@ 2022-04-16 23:26 kernel test robot
  2022-04-18 22:25   ` Kees Cook
  0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2022-04-16 23:26 UTC (permalink / raw)
  To: Kees Cook; +Cc: kbuild-all, linux-kernel, Dan Li

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp@intel.com/config)
compiler: sparc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
        git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
        git fetch --no-tags kees for-next/lkdtm
        git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
>> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
         |                                     ^
   drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
      72 |         if (no_pac_addr(*ret_addr) == expected)
         |             ^~~~~~~~~~~
>> drivers/misc/lkdtm/cfi.c:62:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
         |          ^
   drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
      72 |         if (no_pac_addr(*ret_addr) == expected)
         |             ^~~~~~~~~~~
   drivers/misc/lkdtm/cfi.c: In function 'set_return_addr':
>> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
         |                                     ^
   drivers/misc/lkdtm/cfi.c:87:13: note: in expansion of macro 'no_pac_addr'
      87 |         if (no_pac_addr(*ret_addr) == expected)
         |             ^~~~~~~~~~~
>> drivers/misc/lkdtm/cfi.c:62:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
         |          ^
   drivers/misc/lkdtm/cfi.c:87:13: note: in expansion of macro 'no_pac_addr'
      87 |         if (no_pac_addr(*ret_addr) == expected)
         |             ^~~~~~~~~~~


vim +62 drivers/misc/lkdtm/cfi.c

    60	
    61	#define no_pac_addr(addr)      \
  > 62		((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
    63	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
  2022-04-16 23:26 [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size kernel test robot
@ 2022-04-18 22:25   ` Kees Cook
  0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2022-04-18 22:25 UTC (permalink / raw)
  To: Dan Li; +Cc: kbuild-all, linux-kernel, kernel test robot

On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp@intel.com/config)
> compiler: sparc-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
>         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
>         git fetch --no-tags kees for-next/lkdtm
>         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
>          |                                     ^
>    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
>       72 |         if (no_pac_addr(*ret_addr) == expected)
>          |             ^~~~~~~~~~~

Hmm. I don't see why this is warning. The macro looks like untagged_addr():

#define untagged_addr(addr)     ({ \
        u64 __addr = (__force u64)(addr); \
        __addr &= __untagged_addr(__addr); \
        (__force __typeof__(addr))__addr; \
})


-- 
Kees Cook

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
@ 2022-04-18 22:25   ` Kees Cook
  0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2022-04-18 22:25 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2186 bytes --]

On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp(a)intel.com/config)
> compiler: sparc-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
>         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
>         git fetch --no-tags kees for-next/lkdtm
>         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
>          |                                     ^
>    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
>       72 |         if (no_pac_addr(*ret_addr) == expected)
>          |             ^~~~~~~~~~~

Hmm. I don't see why this is warning. The macro looks like untagged_addr():

#define untagged_addr(addr)     ({ \
        u64 __addr = (__force u64)(addr); \
        __addr &= __untagged_addr(__addr); \
        (__force __typeof__(addr))__addr; \
})


-- 
Kees Cook

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
  2022-04-18 22:25   ` Kees Cook
@ 2022-04-26 13:03     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2022-04-26 13:03 UTC (permalink / raw)
  To: Kees Cook
  Cc: Dan Li, kbuild-all, Linux Kernel Mailing List, kernel test robot

Hi Kees,

On Tue, Apr 19, 2022 at 9:20 PM Kees Cook <keescook@chromium.org> wrote:
> On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> > head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> > config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp@intel.com/config)

Just received a failure for m68k-allmodconfig on next-20220426:

drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
different size [-Werror=int-to-pointer-cast]
drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
different size [-Werror=int-to-pointer-cast]

> > compiler: sparc-linux-gcc (GCC) 11.2.0
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> >         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
> >         git fetch --no-tags kees for-next/lkdtm
> >         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> >         # save the config file to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> >    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> > >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> >          |                                     ^
> >    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
> >       72 |         if (no_pac_addr(*ret_addr) == expected)
> >          |             ^~~~~~~~~~~
>
> Hmm. I don't see why this is warning. The macro looks like untagged_addr():
>
> #define untagged_addr(addr)     ({ \
>         u64 __addr = (__force u64)(addr); \
>         __addr &= __untagged_addr(__addr); \
>         (__force __typeof__(addr))__addr; \
> })

The offending macro is:

#define no_pac_addr(addr)      \
          ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))

On 32-bit, addr is a 32-bit pointer, which is cast to a 64-bit integer first,
then to a 32-bit pointer again.
All of these need intermediate casts to uintptr_t.

oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
@ 2022-04-26 13:03     ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2022-04-26 13:03 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3521 bytes --]

Hi Kees,

On Tue, Apr 19, 2022 at 9:20 PM Kees Cook <keescook@chromium.org> wrote:
> On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> > head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> > config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp(a)intel.com/config)

Just received a failure for m68k-allmodconfig on next-20220426:

drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
different size [-Werror=int-to-pointer-cast]
drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
different size [-Werror=int-to-pointer-cast]

> > compiler: sparc-linux-gcc (GCC) 11.2.0
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> >         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
> >         git fetch --no-tags kees for-next/lkdtm
> >         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> >         # save the config file to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> >    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> > >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> >          |                                     ^
> >    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
> >       72 |         if (no_pac_addr(*ret_addr) == expected)
> >          |             ^~~~~~~~~~~
>
> Hmm. I don't see why this is warning. The macro looks like untagged_addr():
>
> #define untagged_addr(addr)     ({ \
>         u64 __addr = (__force u64)(addr); \
>         __addr &= __untagged_addr(__addr); \
>         (__force __typeof__(addr))__addr; \
> })

The offending macro is:

#define no_pac_addr(addr)      \
          ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))

On 32-bit, addr is a 32-bit pointer, which is cast to a 64-bit integer first,
then to a 32-bit pointer again.
All of these need intermediate casts to uintptr_t.

oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert(a)linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
  2022-04-26 13:03     ` Geert Uytterhoeven
@ 2022-04-26 23:56       ` Kees Cook
  -1 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2022-04-26 23:56 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Dan Li, kbuild-all, Linux Kernel Mailing List, kernel test robot

On Tue, Apr 26, 2022 at 03:03:33PM +0200, Geert Uytterhoeven wrote:
> On Tue, Apr 19, 2022 at 9:20 PM Kees Cook <keescook@chromium.org> wrote:
> > On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> > > head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > > commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> > > config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp@intel.com/config)
> 
> Just received a failure for m68k-allmodconfig on next-20220426:
> 
> drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
> different size [-Werror=pointer-to-int-cast]
> drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
> drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
> different size [-Werror=pointer-to-int-cast]
> drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
> 
> > > compiler: sparc-linux-gcc (GCC) 11.2.0
> > > reproduce (this is a W=1 build):
> > >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > >         chmod +x ~/bin/make.cross
> > >         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > >         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
> > >         git fetch --no-tags kees for-next/lkdtm
> > >         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > >         # save the config file to linux build tree
> > >         mkdir build_dir
> > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> > >
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > >    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> > > >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> > >       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> > >          |                                     ^
> > >    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
> > >       72 |         if (no_pac_addr(*ret_addr) == expected)
> > >          |             ^~~~~~~~~~~
> >
> > Hmm. I don't see why this is warning. The macro looks like untagged_addr():
> >
> > #define untagged_addr(addr)     ({ \
> >         u64 __addr = (__force u64)(addr); \
> >         __addr &= __untagged_addr(__addr); \
> >         (__force __typeof__(addr))__addr; \
> > })
> 
> The offending macro is:
> 
> #define no_pac_addr(addr)      \
>           ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> 
> On 32-bit, addr is a 32-bit pointer, which is cast to a 64-bit integer first,
> then to a 32-bit pointer again.
> All of these need intermediate casts to uintptr_t.

As in this?

#define no_pac_addr(addr)      \
	((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET))



-- 
Kees Cook

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

* Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size
@ 2022-04-26 23:56       ` Kees Cook
  0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2022-04-26 23:56 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3480 bytes --]

On Tue, Apr 26, 2022 at 03:03:33PM +0200, Geert Uytterhoeven wrote:
> On Tue, Apr 19, 2022 at 9:20 PM Kees Cook <keescook@chromium.org> wrote:
> > On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm
> > > head:   2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > > commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations
> > > config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp(a)intel.com/config)
> 
> Just received a failure for m68k-allmodconfig on next-20220426:
> 
> drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
> different size [-Werror=pointer-to-int-cast]
> drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
> drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of
> different size [-Werror=pointer-to-int-cast]
> drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
> 
> > > compiler: sparc-linux-gcc (GCC) 11.2.0
> > > reproduce (this is a W=1 build):
> > >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > >         chmod +x ~/bin/make.cross
> > >         # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > >         git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
> > >         git fetch --no-tags kees for-next/lkdtm
> > >         git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25
> > >         # save the config file to linux build tree
> > >         mkdir build_dir
> > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/
> > >
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > >    drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked':
> > > >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> > >       62 |         ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> > >          |                                     ^
> > >    drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr'
> > >       72 |         if (no_pac_addr(*ret_addr) == expected)
> > >          |             ^~~~~~~~~~~
> >
> > Hmm. I don't see why this is warning. The macro looks like untagged_addr():
> >
> > #define untagged_addr(addr)     ({ \
> >         u64 __addr = (__force u64)(addr); \
> >         __addr &= __untagged_addr(__addr); \
> >         (__force __typeof__(addr))__addr; \
> > })
> 
> The offending macro is:
> 
> #define no_pac_addr(addr)      \
>           ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET))
> 
> On 32-bit, addr is a 32-bit pointer, which is cast to a 64-bit integer first,
> then to a 32-bit pointer again.
> All of these need intermediate casts to uintptr_t.

As in this?

#define no_pac_addr(addr)      \
	((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET))



-- 
Kees Cook

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

end of thread, other threads:[~2022-04-26 23:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-16 23:26 [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size kernel test robot
2022-04-18 22:25 ` Kees Cook
2022-04-18 22:25   ` Kees Cook
2022-04-26 13:03   ` Geert Uytterhoeven
2022-04-26 13:03     ` Geert Uytterhoeven
2022-04-26 23:56     ` Kees Cook
2022-04-26 23:56       ` 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.