Subject: Re: linux-next: build warnings after merge of the kspp-gustavo tree

From: "Aithal, Srikanth" <[email-masked]>
Date: Wed, 22 Nov 2023 10:21:27 +0530

On 11/22/2023 9:18 AM, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the kspp-gustavo tree, today's linux-next build (sparc64
> defconfig) produced these warnings:
> 
> mm/mempolicy.c: In function 'mpol_parse_str':
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:3005:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3005 |                 *--nodelist = ':';
>        |                 ~~~~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:3005:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3005 |                 *--nodelist = ':';
>        |                 ~~~~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
> mm/mempolicy.c:3007:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>   3007 |                 *--flags = '=';
>        |                 ~~~~~~~~~^~~~~
> mm/mempolicy.c:2890:26: note: destination object 'str' of size [0, 9223372036854775807]
>   2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
>        |                    ~~~~~~^~~
> 
> This is using gcc v11.1.0
> 
On AMD x86_64 platform with attached KVM guest, I am seeing build errors:

lib/vsprintf.c: In function ‘vsnprintf’:
lib/vsprintf.c:2894:33: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  2894 |                         end[-1] = '\0';
       |                         ~~~~~~~~^~~~~~
lib/vsprintf.c:2749:21: note: at offset [-9223372036854775808, 
9223372036854775806] into destination object ‘buf’ of size [0, 
9223372036854775807]
  2749 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list 
args)
       |               ~~~~~~^~~
lib/vsprintf.c: In function ‘bstr_printf’:
lib/vsprintf.c:3392:33: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3392 |                         end[-1] = '\0';
       |                         ~~~~~~~~^~~~~~
lib/vsprintf.c:3213:23: note: at offset [-9223372036854775808, 
9223372036854775806] into destination object ‘buf’ of size [0, 
9223372036854775807]
  3213 | int bstr_printf(char *buf, size_t size, const char *fmt, const 
u32 *bin_buf)
       |                 ~~~~~~^~~
cc1: all warnings being treated as errors
make[3]: *** [scripts/Makefile.build:243: lib/vsprintf.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:480: lib] Error 2
make[2]: *** Waiting for unfinished jobs....
mm/mempolicy.c: In function ‘mpol_parse_str’:
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
mm/mempolicy.c:3007:26: error: writing 1 byte into a region of size 0 
[-Werror=stringop-overflow=]
  3007 |                 *--flags = '=';
       |                 ~~~~~~~~~^~~~~
mm/mempolicy.c:2890:26: note: destination object ‘str’ of size [0, 
9223372036854775807]
  2890 | int mpol_parse_str(char *str, struct mempolicy **mpol)
       |                    ~~~~~~^~~
cc1: all warnings being treated as errors
make[3]: *** [scripts/Makefile.build:243: mm/mempolicy.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:480: mm] Error 2
make[1]: *** [guest_kernel/Makefile:1914: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

@Gustavo I see you have mentioned it as gcc issue. I was not hitting 
this until yesterdays linux-next build. I am on latest gcc which RHEL 
9.x provides,
gcc --version
gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)

which version of gcc resolves this issue?

Thanks and Regards,
Srikanth Aithal