Received: by 10.223.185.116 with SMTP id b49csp4145808wrg; Mon, 26 Feb 2018 12:01:25 -0800 (PST) X-Google-Smtp-Source: AH8x224Du/KeiwbTs/CQLy7POfZGgIdZKVacaMV/m7fBXhyGd1dLEIaPbM/6xFKxApDYNIYTwl3d X-Received: by 2002:a17:902:bcc5:: with SMTP id o5-v6mr11265282pls.86.1519675284987; Mon, 26 Feb 2018 12:01:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519675284; cv=none; d=google.com; s=arc-20160816; b=rr+AMrIRDuAbt3d6WRPsYPpvx2bY2psztUB+3+mQSVpqYhLxNKeUcl9e5Gp/MFn0o7 PnNFCnpoyzc8pe8nwEZQOsR3c1aj6qSIOkAwb4196romSEcqJNyYqCqY2hGT1nsrybly +a27m/I2qDtM+m0oo70zNJisaa0DkXzPfdrq4dvunSieLBq4XoKdl1RBi7CRbEh+pDuz s/rjjb+IMVHAkwEccpY6MXhaOi3P1VmDVOH+L0kUWaJxiKBxprclVcZZkCjtYu1F9I+D 04uX2akg684KMl23qYMdUE7cFJRXm0W0RFOpZp1WRkH/gng8LS59qYTB34/cTpO7wy2p RWWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=sRpUJ0xOlIlYkLOJpQrfE0IzJu3lOU9/AwTFdVTccK8=; b=dmbk6j2Jftj2Ns/aeaQLYz7peq0wLXzLwZfho/vRElXpoP+V50ZWJXsfZitAXvSCza iqZ8HrPxpPy8BXIvpwUZbBjHKBv06pSiNMERw23hRj/EN1quypLnwo54jURmEJ5akVTn bMjws2rvEKyNLDU3H8bERuNSLJWhPGUbBwuk+VWjJcYe43uuNHX73tRoAIofjDS9fK6s KJ4TXk+Z0gu8Pyqn7jqTmBCCvcFjeqTmvFudF9wj0xALdOrM+XQ/9g0kPc9tXpr1k/Rg 7g8qZSpAa3r/35LzFN9cz/nIQ8286AO2oMvU8i0XZc8J3h67Xhy/2AyMhvQlaIhpOGrx nUoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si7023623plr.335.2018.02.26.12.01.06; Mon, 26 Feb 2018 12:01:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbeBZUAQ (ORCPT + 99 others); Mon, 26 Feb 2018 15:00:16 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:38983 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbeBZUAP (ORCPT ); Mon, 26 Feb 2018 15:00:15 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 3zqt3C69Glz9ttS1; Mon, 26 Feb 2018 21:00:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id vJuhcPI9SImv; Mon, 26 Feb 2018 21:00:07 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 3zqt3C5P7dz9ttRn; Mon, 26 Feb 2018 21:00:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1893A8B8E8; Mon, 26 Feb 2018 21:00:14 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id HK-EsKGqZSuE; Mon, 26 Feb 2018 21:00:13 +0100 (CET) Received: from [192.168.232.53] (unknown [192.168.232.53]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6030C8B8D9; Mon, 26 Feb 2018 21:00:13 +0100 (CET) Subject: Re: [PATCH 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok To: Mathieu Malaterre , Segher Boessenkool Cc: Michael Ellerman , LKML , Paul Mackerras , Jiri Slaby , linuxppc-dev References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-7-malat@debian.org> <8862c1e1-d161-3410-1b2a-502ad06cef57@c-s.fr> <6cba215c-127e-f3eb-b525-773b6aed0eb7@c-s.fr> From: christophe leroy Message-ID: <4ddba8bc-b1e5-24a0-602e-672e7b51b203@c-s.fr> Date: Mon, 26 Feb 2018 21:00:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 180226-4, 26/02/2018), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/02/2018 à 18:50, Mathieu Malaterre a écrit : > On Mon, Feb 26, 2018 at 8:44 AM, Mathieu Malaterre wrote: >> On Mon, Feb 26, 2018 at 7:50 AM, Christophe LEROY >> 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 >>>>> --- >>>>> 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). That's right, it seems that recent versions of gcc are not happy anymore with that change. Maybe Segher has a suggestion for that one ? > >>> 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 ? No I don't think it is the solution. PPC is built with WERROR in order to catch warnings on real problems. You could disable it selectively when you want to run 'make W=1' and see all possible warnings, then select by yourself which warnings are worth fixing up. Christophe > >>> Christophe >>> >>> >>>> >>>> Christophe >>>> >>>>> #endif >>>>> >>> --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus