Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5836748rwj; Wed, 21 Dec 2022 07:37:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKumyi6JalQHOoMIObpTpbWwMizZDVmAouojMA3rxhnPwVoLXCV+/MpNKfECftK+2dGC6J X-Received: by 2002:a05:6a21:6da8:b0:af:d295:e2f0 with SMTP id wl40-20020a056a216da800b000afd295e2f0mr26439607pzb.27.1671637068424; Wed, 21 Dec 2022 07:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671637068; cv=none; d=google.com; s=arc-20160816; b=Bf0ow3M9XlGOqErh24wVCL90ua+6r3nkmxKT+oLRaXD0nj8MIM7BtEmvdXYHQPKCH9 OCx+GNux5IS2yX4MfnkUO+6hC+wAuPcgbUFJgeSt2AyvrYf7ud4vKssfbWIvM2fGvYA2 /T+PS+dCxB2nmz1GWwfaTBXucetn/Ck7La8Kygt2c1dpA1Q5CySH4mjOm3m/icmnk5DF MviWfTwDFwZ1d4FAZZdvdh+g1ecvKQKDqUXg+Y8l1QMMTRP7jT/3/IVpqAP9QXrThPaj siIDzlvp+tth8w6lmD82s9DxSITwwE8ZatG0nAZ3nqsYqDahUaN3fwyUkh19gGh10CzL EoVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=vAbeixt0uJZ/ZtL8e7tbr2BILgwudnmu8+lBsU8ZDYM=; b=GbYnYtUSXYuN+iuWtI6PNGmoHBd+oa4QolPHTnb/zLR5/vkyJXV6HClqOXkOtZ4JbX 8fftDx+k7q8na1cz1WOzCc9VQWcLmfQn6er/CZHWFC+S5zyexJF1X+m0U6/edGF/+W+D LEeUUimq7pP/I4ccBwP/rX08by1rIt0GiffM/OG+hIOhXnvgYVe5o6Oer0+i59ghH54X 7RQF1FwxV55n/WBWg/c//je8ABurAzmXuVQ61w9tlNyb0qQNbjl2GJtmmpukujXKScXa xVwkg1FrYQruC1aa0X3xb/9e3HaGRPdCUDKS6IE7B+/iyVQ9/NAE8uUBJcPGyfYk25Ze 5BgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ws4TLLPl; 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 l7-20020a635b47000000b004791b52757csi17025317pgm.136.2022.12.21.07.37.39; Wed, 21 Dec 2022 07:37:48 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=Ws4TLLPl; 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 S234565AbiLUPXH (ORCPT + 69 others); Wed, 21 Dec 2022 10:23:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiLUPXF (ORCPT ); Wed, 21 Dec 2022 10:23:05 -0500 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8018022299; Wed, 21 Dec 2022 07:23:04 -0800 (PST) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-143ffc8c2b2so19526063fac.2; Wed, 21 Dec 2022 07:23:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=vAbeixt0uJZ/ZtL8e7tbr2BILgwudnmu8+lBsU8ZDYM=; b=Ws4TLLPl33Vj1O35MNzOh4l13iO+hsE9JYHKBYbr211PI1V6Uaa6//ZYGV4pl+KgcG MbaTROiSvSHcf/+ourGFKwJ1F/1PzSI6yD8TFMj9+cQiwzdqYDfIFm2Mgdq6TAHzWgmO 2GGOP+NRUtX7OpoYsCKU6tRJoOjYDeCppvj2QGpIZKdDal11EJRJRO0mMGCosG+BL/re eTY5xJNhhA21szPCW7/AHSKTpcZ2cnV+b0RbWKUn6NLajMepf0PiXH+bbCzD4SecF9VS 6ESg5yZ4GM/q3tccWS8ZygdyWi9cRBoDS4JhgQdn+iyX0Q6y/oAWvDoXT6QzlEmu/3+W I/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vAbeixt0uJZ/ZtL8e7tbr2BILgwudnmu8+lBsU8ZDYM=; b=Idw8gi7LI50Rskrk67QDLNF1AYlfEJhCrN6IK4YpxQ/Tk1QMlhsEU2RpHO5Ea98gtu t7MMLec3pola0b1BPTqjIzJ/LWG2eMnrCthImax25UsPVY1/wsjyOm1M5sLDu1uXNS+Q R+iwB2yghtYLShpSzUzmuiH9jctDqhM+UUpO+3Y9expPE9gb5azb0vJ+YgHWGNczbL6/ RUT8u/013Vp9yiACJxSoz2YJm+j6AT8erodHyiN89MqkU3NlOhg7FNJbGSOzKWogDivt gpQ3IUMd4OrqRf+NZqLRyJI1t51eToGeyu+yGasxxwwxnLY39r4tgyBgVLjSXEaRpQT6 lgLw== X-Gm-Message-State: AFqh2kpWyrhU+hXJlOCMCgSjgkUwVIVyAjMyUk2xMkmAAM4n51sn6XXP Br+KPt0mz1Lm4LLDCFaDvE8= X-Received: by 2002:a05:6870:f699:b0:148:41a7:eb35 with SMTP id el25-20020a056870f69900b0014841a7eb35mr7708587oab.12.1671636182930; Wed, 21 Dec 2022 07:23:02 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h21-20020a4abb95000000b0049f8b4b2095sm6195278oop.44.2022.12.21.07.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 07:23:02 -0800 (PST) Sender: Guenter Roeck Date: Wed, 21 Dec 2022 07:23:00 -0800 From: Guenter Roeck To: Geert Uytterhoeven Cc: "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 , Linus Torvalds , Andy Shevchenko , Greg Kroah-Hartman , linux-m68k@lists.linux-m68k.org Subject: Re: [PATCH v2] kbuild: treat char as always unsigned Message-ID: <20221221152300.GA2468105@roeck-us.net> References: <20221019203034.3795710-1-Jason@zx2c4.com> <20221221145332.GA2399037@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,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, Dec 21, 2022 at 04:05:45PM +0100, Geert Uytterhoeven wrote: > Hi G?nter, > > On Wed, Dec 21, 2022 at 3:54 PM Guenter Roeck wrote: > > On Wed, Oct 19, 2022 at 02:30:34PM -0600, Jason A. Donenfeld wrote: > > > Recently, some compile-time checking I added to the clamp_t family of > > > functions triggered a build error when a poorly written driver was > > > compiled on ARM, because the driver assumed that the naked `char` type > > > is signed, but ARM treats it as unsigned, and the C standard says it's > > > architecture-dependent. > > > > > > I doubt this particular driver is the only instance in which > > > unsuspecting authors make assumptions about `char` with no `signed` or > > > `unsigned` specifier. We were lucky enough this time that that driver > > > used `clamp_t(char, negative_value, positive_value)`, so the new > > > checking code found it, and I've sent a patch to fix it, but there are > > > likely other places lurking that won't be so easily unearthed. > > > > > > So let's just eliminate this particular variety of heisensign bugs > > > entirely. Set `-funsigned-char` globally, so that gcc makes the type > > > unsigned on all architectures. > > > > > > This will break things in some places and fix things in others, so this > > > will likely cause a bit of churn while reconciling the type misuse. > > > > > > > There is an interesting fallout: When running the m68k:q800 qemu emulation, > > there are lots of warning backtraces. > > > > WARNING: CPU: 0 PID: 23 at crypto/testmgr.c:5724 alg_test.part.0+0x7c/0x326 > > testmgr: alg_test_descs entries in wrong order: 'adiantum(xchacha12,aes)' before 'adiantum(xchacha20,aes)' > > ------------[ cut here ]------------ > > WARNING: CPU: 0 PID: 23 at crypto/testmgr.c:5724 alg_test.part.0+0x7c/0x326 > > testmgr: alg_test_descs entries in wrong order: 'adiantum(xchacha20,aes)' before 'aegis128' > > > > and so on for pretty much every entry in the alg_test_descs[] array. > > > > Bisect points to this patch, and reverting it fixes the problem. > > > > It looks like the problem is that arch/m68k/include/asm/string.h > > uses "char res" to store the result of strcmp(), and char is now > > unsigned - meaning strcmp() will now never return a value < 0. > > Effectively that means that strcmp() is broken on m68k if > > CONFIG_COLDFIRE=n. > > > > The fix is probably quite simple. > > > > diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h > > index f759d944c449..b8f4ae19e8f6 100644 > > --- a/arch/m68k/include/asm/string.h > > +++ b/arch/m68k/include/asm/string.h > > @@ -42,7 +42,7 @@ static inline char *strncpy(char *dest, const char *src, size_t n) > > #define __HAVE_ARCH_STRCMP > > static inline int strcmp(const char *cs, const char *ct) > > { > > - char res; > > + signed char res; > > > > asm ("\n" > > "1: move.b (%0)+,%2\n" /* get *cs */ > > > > Does that make sense ? If so I can send a patch. > > Thanks, been there, done that > https://lore.kernel.org/all/bce014e60d7b1a3d1c60009fc3572e2f72591f21.1671110959.git.geert@linux-m68k.org > > Note that we detected other issues with the m68k strcmp(), so > probably that patch wouldn't go in as-is. > So anything non-Coldfire is and will remain broken on m68k for the time being ? Wouldn't it be better to fix the acute problem now and address the long-standing problem(s) separately ? Thanks, Guenter