linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Malaterre <malat@debian.org>
To: Christophe LEROY <christophe.leroy@c-s.fr>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	LKML <linux-kernel@vger.kernel.org>,
	Paul Mackerras <paulus@samba.org>, Jiri Slaby <jslaby@suse.com>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok
Date: Mon, 26 Feb 2018 18:50:11 +0100	[thread overview]
Message-ID: <CA+7wUsx047shRJ92PJ+cvg24HNhMnYzM0t5zUdEOaSE00sXkSg@mail.gmail.com> (raw)
In-Reply-To: <CA+7wUswNE1ydgeESpG8Dqtz4SGFjZZJJiPp+SHN8Z1qtBtPLLQ@mail.gmail.com>

On Mon, Feb 26, 2018 at 8:44 AM, Mathieu Malaterre <malat@debian.org> wrote:
> On Mon, Feb 26, 2018 at 7:50 AM, Christophe LEROY
> <christophe.leroy@c-s.fr> wrote:
>>
>>
>> Le 26/02/2018 à 07:34, Christophe LEROY a écrit :
>>>
>>>
>>>
>>> Le 25/02/2018 à 18:22, Mathieu Malaterre a écrit :
>>>>
>>>> Rewrite check size - 1 <= Y as size < Y since `size` is unsigned value.
>>>> Fix warning (treated as error in W=1):
>>>>
>>>>    CC      arch/powerpc/kernel/signal_32.o
>>>> In file included from ./include/linux/uaccess.h:14:0,
>>>>                   from ./include/asm-generic/termios-base.h:8,
>>>>                   from ./arch/powerpc/include/asm/termios.h:20,
>>>>                   from ./include/uapi/linux/termios.h:6,
>>>>                   from ./include/linux/tty.h:7,
>>>>                   from arch/powerpc/kernel/signal_32.c:36:
>>>> ./include/asm-generic/termios-base.h: In function
>>>> ‘user_termio_to_kernel_termios’:
>>>> ./arch/powerpc/include/asm/uaccess.h:52:35: error: comparison of unsigned
>>>> expression >= 0 is always true [-Werror=type-limits]
>>>>     (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
>>>>                                     ^
>>>> ./arch/powerpc/include/asm/uaccess.h:58:3: note: in expansion of macro
>>>> ‘__access_ok’
>>>>     __access_ok((__force unsigned long)(addr), (size), get_fs()))
>>>>     ^~~~~~~~~~~
>>>> ./arch/powerpc/include/asm/uaccess.h:262:6: note: in expansion of macro
>>>> ‘access_ok’
>>>>    if (access_ok(VERIFY_READ, __gu_addr, (size)))   \
>>>>        ^~~~~~~~~
>>>> ./arch/powerpc/include/asm/uaccess.h:80:2: note: in expansion of macro
>>>> ‘__get_user_check’
>>>>    __get_user_check((x), (ptr), sizeof(*(ptr)))
>>>>    ^~~~~~~~~~~~~~~~
>>>> ./include/asm-generic/termios-base.h:36:6: note: in expansion of macro
>>>> ‘get_user’
>>>>    if (get_user(termios->c_line, &termio->c_line) < 0)
>>>>        ^~~~~~~~
>>>> [...]
>>>> cc1: all warnings being treated as errors
>>>>
>>>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>>>> ---
>>>>   arch/powerpc/include/asm/uaccess.h | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/powerpc/include/asm/uaccess.h
>>>> b/arch/powerpc/include/asm/uaccess.h
>>>> index 51bfeb8777f0..fadc406bd39d 100644
>>>> --- a/arch/powerpc/include/asm/uaccess.h
>>>> +++ b/arch/powerpc/include/asm/uaccess.h
>>>> @@ -49,7 +49,7 @@
>>>>   #define __access_ok(addr, size, segment)    \
>>>>       (((addr) <= (segment).seg) &&        \
>>>> -     (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
>>>> +     (((size) == 0) || ((size) < ((segment).seg - (addr)))))
>>>
>>>
>>> IIUC, ((2 - 1) <= 1) is the same as (2 < 1) ?????
>>
>
> The whole series was pretty mediocre, but this one was actually pretty
> destructive. Thanks for catching this.
>
>>
>> Note that I already try to submit a fix for this warning 3 years ago
>> (https://patchwork.ozlabs.org/patch/418075/) and it was rejected with the
>> following comment:

Tested again today with gcc 6.3.0 and gcc is still producing the
original warning (treated as error).

>> Again, I don't think Linux enables this warning.  What did you do to
>> produce this?  In any case, it's a bad warning that doesn't take macros
>> into account, and the answer is not to make the code less clear by hiding
>> the fact that zero is a special case.
>
> Right. I'll try to see how to make W=1 run without error with an
> alternate solution.

So the other alternative is to update a bunch of ppc32 defconfig(s)
with: CONFIG_PPC_DISABLE_WERROR=y.

Would that be preferable ?

>> Christophe
>>
>>
>>>
>>> Christophe
>>>
>>>>   #endif
>>>>
>>

  reply	other threads:[~2018-02-26 17:50 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-25 17:22 [PATCH 00/21] powerpc/gamecube: make W=1 compilation errors free Mathieu Malaterre
2018-02-25 17:22 ` [PATCH 01/21] powerpc: Remove warning on array size when empty Mathieu Malaterre
2018-02-25 18:53   ` Segher Boessenkool
2018-02-26 14:44   ` Andy Shevchenko
2018-02-26 14:45     ` Andy Shevchenko
2018-02-27  7:25       ` Mathieu Malaterre
2018-02-27  7:33         ` Christophe LEROY
2018-02-27  7:44           ` Mathieu Malaterre
2018-02-27 15:52             ` Andy Shevchenko
2018-02-27 17:25               ` Mathieu Malaterre
2018-02-27 20:42               ` Segher Boessenkool
2018-02-28 15:50                 ` Andy Shevchenko
2018-03-01  2:55   ` Michael Ellerman
2018-03-01  7:01     ` Mathieu Malaterre
2018-03-01  9:33       ` Michael Ellerman
2018-03-02 19:49   ` [PATCH v2 " Mathieu Malaterre
2018-03-14  9:28     ` [v2,01/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 02/21] powerpc: Move the inline keyword at the beginning of function declaration Mathieu Malaterre
2018-03-14  9:27   ` [02/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 03/21] powerpc: Mark the variable earlycon_acpi_spcr_enable maybe_unused Mathieu Malaterre
2018-03-04 10:54   ` Michael Ellerman
2018-03-10 18:08     ` Mathieu Malaterre
2018-02-25 17:22 ` [PATCH 04/21] powerpc: Mark both tmp variables as unused Mathieu Malaterre
2018-03-14  9:27   ` [04/21] " Michael Ellerman
2018-03-14 10:38   ` [PATCH 04/21] " Christophe LEROY
2018-03-16 14:08     ` Michael Ellerman
2018-02-25 17:22 ` [PATCH 05/21] powerpc: Avoid comparison of unsigned long >= 0 in pfn_valid Mathieu Malaterre
2018-02-26  6:32   ` Christophe LEROY
2018-02-26  7:49     ` Mathieu Malaterre
2018-02-26  8:46     ` Segher Boessenkool
2018-03-02 19:54       ` Mathieu Malaterre
2018-03-03  7:45         ` christophe leroy
2018-03-04 10:55   ` Michael Ellerman
2018-03-04 19:46     ` christophe leroy
2018-03-07 20:34   ` [PATCH v2 " Mathieu Malaterre
2018-03-14  9:28     ` [v2, " Michael Ellerman
2018-02-25 17:22 ` [PATCH 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok Mathieu Malaterre
2018-02-26  6:34   ` Christophe LEROY
2018-02-26  6:50     ` Christophe LEROY
2018-02-26  7:44       ` Mathieu Malaterre
2018-02-26 17:50         ` Mathieu Malaterre [this message]
2018-02-26 20:00           ` christophe leroy
2018-02-26 22:17             ` Segher Boessenkool
2018-03-02 19:50   ` [PATCH v2 " Mathieu Malaterre
2018-03-03  7:44     ` christophe leroy
2018-03-14  9:28     ` [v2, " Michael Ellerman
2018-02-25 17:22 ` [PATCH 07/21] powerpc: Make functions flipper_pic_init & ug_udbg_putc static Mathieu Malaterre
2018-03-14  9:27   ` [07/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 08/21] powerpc: Make function __giveup_fpu static Mathieu Malaterre
2018-03-14  9:28   ` [08/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 09/21] powerpc: Make function save_all static Mathieu Malaterre
2018-02-25 17:22 ` [PATCH 10/21] powerpc: Add missing prototype for slb_miss_bad_addr Mathieu Malaterre
2018-03-14  9:27   ` [10/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 11/21] powerpc: Add missing prototype for hdec_interrupt Mathieu Malaterre
2018-03-14  9:27   ` [11/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 12/21] powerpc: Add missing prototype for time_init Mathieu Malaterre
2018-03-14  9:27   ` [12/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 13/21] powerpc: Add missing prototype for arch_dup_task_struct Mathieu Malaterre
2018-03-14  9:27   ` [13/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 14/21] powerpc: Add missing prototype for arch_irq_work_raise Mathieu Malaterre
2018-03-14  9:27   ` [14/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 15/21] powerpc: Add missing prototype for MMU_setup Mathieu Malaterre
2018-03-04 10:54   ` Michael Ellerman
2018-03-07 20:32   ` [PATCH v2 15/21] powerpc: Make function MMU_setup static Mathieu Malaterre
2018-03-14  9:28     ` [v2,15/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 16/21] powerpc: Add missing prototype for init_IRQ Mathieu Malaterre
2018-03-14  9:28   ` [16/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 17/21] powerpc: Add missing prototype for sys_debug_setcontext Mathieu Malaterre
2018-03-04 10:54   ` Michael Ellerman
2018-03-07 20:37     ` Mathieu Malaterre
2018-03-08 10:36       ` Michael Ellerman
2018-03-26 18:56         ` Mathieu Malaterre
2018-03-27  8:50           ` Michael Ellerman
2018-03-14  9:28   ` [17/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 18/21] powerpc: Add missing prototypes for sys_sigreturn & sys_rt_sigreturn Mathieu Malaterre
2018-03-14  9:28   ` [18/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 19/21] powerpc: Add missing prototypes for hw_breakpoint_handler & arch_unregister_hw_breakpoint Mathieu Malaterre
2018-03-14  9:28   ` [19/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 20/21] powerpc: Add missing prototypes for ppc_select & ppc_fadvise64_64 Mathieu Malaterre
2018-03-14  9:28   ` [20/21] " Michael Ellerman
2018-02-25 17:22 ` [PATCH 21/21] powerpc: Add missing prototypes in setup_32.c Mathieu Malaterre
2018-03-08 11:44   ` Michael Ellerman
2018-03-14  9:28   ` [21/21] " Michael Ellerman

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=CA+7wUsx047shRJ92PJ+cvg24HNhMnYzM0t5zUdEOaSE00sXkSg@mail.gmail.com \
    --to=malat@debian.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).