Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1559680rwi; Wed, 19 Oct 2022 12:12:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48kg9WEXHGxG0RFvE8tudxWEycd8h5iQAWPzYqFgclFP+qVXUBOQIEweWNIpYPcxx4TQ5i X-Received: by 2002:a63:cc:0:b0:463:6cb7:4f5d with SMTP id 195-20020a6300cc000000b004636cb74f5dmr8249697pga.489.1666206754512; Wed, 19 Oct 2022 12:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666206754; cv=none; d=google.com; s=arc-20160816; b=xRNGVTVTuWiJ50MhmBFeCe403tdMCXs2ZRXZL9ZAW8FwuO3GMjVW0jajAXv2p/2CYE yiSi+8O6Znvb8ZlZUIZkb3DkBT4FMQ8sFkFa9Q6s4Fm5MJH4aIKFk/jaOeFymHDkPKJu x6Cvs/3ssFo9y0HJ4cr2LEzeQ0CcYyFndtzAwpeFXT5FDjkvoF2kGr6LnU+wzKfLLRce elS06uMKvGgxG7KgkfdKLx7i5apslsguF8cU7XbH0TqhRn4cZBdKxQE++EFcP76yvEEQ Z1PRHWklp3MaJh96WL9WXjIypbWvyF9cvTab4MU2E8P7J0QAhuAlrYZJMbIzHfgVdAMJ Towg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=y8CxBkZb6IhM+m9VFiO2jPrdWrbVMTNRewPIBF3tqkA=; b=wfqAkQKFqhrCrShCbyxVk6i5gGwfYs8LbasmxBspu8NURefzOqZP+1LzhCIS2Uo6bl Pcept+VIf72GTJe6fwQ9TRNpxWZYUyzSMtuR3JusKcvJocIvLrmhcL9Vk7xVPC36BlCT oDLC0m7RX8YxIpxwbl1cEZ8PtLnBXgS8orCfZ8uc3AtFLRGluFi3ZfrsRpAMnjTfCh65 yev51Lmr5Hfcl99wafYMPNlzXRdPmfaI9n7PzyrdqVsShSa8RwUtWDkT7K0TVA8cezkW 7roXuwzertyOiHy6LB8TRItFmXIgQY7WZGA+aALz2WOAIZkvZlXTOF9fiJakJSUcVVxR IxQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="AHNIIr/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a17090a4a8500b002008d0b0838si558335pjh.178.2022.10.19.12.12.21; Wed, 19 Oct 2022 12:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="AHNIIr/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230366AbiJSS4Z (ORCPT + 99 others); Wed, 19 Oct 2022 14:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbiJSS4U (ORCPT ); Wed, 19 Oct 2022 14:56:20 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8560D1998A1 for ; Wed, 19 Oct 2022 11:56:19 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id m81so20319840oia.1 for ; Wed, 19 Oct 2022 11:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=y8CxBkZb6IhM+m9VFiO2jPrdWrbVMTNRewPIBF3tqkA=; b=AHNIIr/yPXz4tPtwy3N0+CS8dtLnS1uko6A/0obc0vzi2BOtldQhySPxD40rDPQWo2 oOiLoggmXtuKbETCejbTtKYbkzVXhkmPLTlKT8Xz5ci/Qnrm/IQu6DMWn6PBLtmzO06C qTvqu1BL4SkqzYZ+SkeI+iq7XwZv3sAUe2RD8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y8CxBkZb6IhM+m9VFiO2jPrdWrbVMTNRewPIBF3tqkA=; b=gSz5ny49gFCiboH74CyXg9yodSDUfxLxoZOvHKVnXE/A1T8VzuqzQsoWI8RvPwhk/M FH7jQj10z7GPTuQ3bCdNg5TWCupb6GqbukhiklAAtx/020RV0XSrudKirdkSVIrzW+kT JY/FbZaMbpP3uLN0C5JEeHJrCRIJXY0an8aQltFodZMHulFMEuBckf2H5K1m4Cv1/YqQ T0avARbTzeyDIYpIAEm7ltPYS602ycip6yGHSFteDLKhHo36b3SAzbuthFA6uezEsZC5 XhpLUV7bgZiTQTZViNEC0hmX3VtlZaDieXUvH7tWkrYSXm8Qb2TeNQc5N5QQhSL4SzId qWqw== X-Gm-Message-State: ACrzQf3E2ELvVxQe6O1Gh1O6ZyKTGkj+CfV2W8c10Az5+toXLLBGIAJl lD63gQHgyfFoH7Q+CEdATvMpFBKKN/4zvA== X-Received: by 2002:a05:6808:1648:b0:347:b631:cc80 with SMTP id az8-20020a056808164800b00347b631cc80mr5031087oib.238.1666205778447; Wed, 19 Oct 2022 11:56:18 -0700 (PDT) Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com. [209.85.161.42]) by smtp.gmail.com with ESMTPSA id r10-20020a4a964a000000b00435a59fba01sm6832068ooi.47.2022.10.19.11.56.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Oct 2022 11:56:17 -0700 (PDT) Received: by mail-oo1-f42.google.com with SMTP id c17-20020a4aa4d1000000b0047653e7c5f3so3672418oom.1 for ; Wed, 19 Oct 2022 11:56:17 -0700 (PDT) X-Received: by 2002:a4a:aeca:0:b0:480:2413:1edc with SMTP id v10-20020a4aaeca000000b0048024131edcmr4334366oon.96.1666205776676; Wed, 19 Oct 2022 11:56:16 -0700 (PDT) MIME-Version: 1.0 References: <20221019162648.3557490-1-Jason@zx2c4.com> <20221019165455.GL25951@gate.crashing.org> <20221019174345.GM25951@gate.crashing.org> In-Reply-To: From: Linus Torvalds Date: Wed, 19 Oct 2022 11:56:00 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: treat char as always signed To: Nick Desaulniers Cc: Segher Boessenkool , "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-toolchains@vger.kernel.org, Masahiro Yamada , Kees Cook , Andrew Morton , Andy Shevchenko , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 19, 2022 at 11:21 AM Nick Desaulniers wrote: > > A few times in the past, we've split a warning flag into a group so > that we could be more specific about distinct cases. Perhaps if > -Wpointer-sign was a group that implied -Wpointer-char-sign, then the > kernel could use -Wpointer-sign -Wno-pointer-char-sign. That might be interesting, just to see how much of the kernel is about 'char *' and how much is other noise. Just for fun (for some definition of "fun") I tried to remove the -Wno-pointer-sign thing, and started building a kernel. After fixing fortify-string.h to not complain (which was indeed about strlen() signedness), it turns out a lot were still about 'char', but not necessarily the functions. We use 'unsigned char *' for our dentry data, for example, and then you get warning: pointer targets in initialization of =E2=80=98const unsigned char *=E2=80=99 from =E2=80=98char *=E2=80=99 differ in signedness when you do something like QSTR_INIT(NULL_FILE_NAME, which is simply doing a regular initializer assignment, and wants to assign a constant string (in this case the constant string "null") to that "const unsigned char *name". That's certainly another example of "why the heck did the compiler warn about that thing". You can literally try to compile this one-liner with gcc: const unsigned char *c =3D "p"; and it will complain. What a hugely pointless warning. BUT. It turns out we have a lot of non-char warnings too. The kernel does all these "generic functions" that are based on size, like atomic_try_cmpxchg_acquire() which are basically defined to be about "int sized object", but with unspecified sign. And the sign is basically pointless. Some people want "unsigned int", others might want a signed int. So from a quick grep, we do have a lot of strlen/strcpy cases, but we also do have a lot of other cases. Hundreds and hundreds of that atomic_try_cmpxchg_acquire(), for example. And they might be trivial to fix (it might be similar to the fortify-string.h one where it's just a header file that generates most of them in one single place), but with all the ones that are just clearly the compiler being silly, they aren't really even worth looking at. Linus