Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp251955rwe; Tue, 23 Aug 2022 23:39:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR6uFAlyK1A3jFAi8yA5grWF5PNquGwe1wM6GZRIyud3kIrgGP5klLWTBN+xo0KeLqyxwDxB X-Received: by 2002:a05:6402:84d:b0:435:a764:9aad with SMTP id b13-20020a056402084d00b00435a7649aadmr6790454edz.332.1661323141670; Tue, 23 Aug 2022 23:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661323141; cv=none; d=google.com; s=arc-20160816; b=QCXP8n06semfM9Vuv6sY1BHsKlufWZtywBl+XRoKEW4pOi/scuQLaKNJmJ9EJriajQ VTyAedRG3SAp2cvVy7sJFJdf+oopCVdzuZ4Q20I87hmfoAzWF7gGPHPkp7x/uWCUnN5g wMCk32xpsJcCLQVbaCQt7NhellvafXTU6mBx2a9N0zOeU1OPKX/X37woKr/abV/zdM1s TbnlRRuGsZUiFApzSSVt/akpDJSQtV2r7AhaGQxTw3IKW0WCJmXfoN0geDgw32s+5UW7 dsoHXHEM3YUdb7dWnsxoNpuoKHLYSd3cpjQm3n24NwJd2YQD3gWS4Sa/yU/Iu6iDrWSB qChw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IqQH8glAVc4Uz1KdvwFFC42e+CS3+BpGZdq1n3kfHOA=; b=EgxZln5qSUdgDcd3fQYBCr4xtYcjL6YxyDJK5cWkfpdKBtnNYMi6J/Jn6XmHj2pkCD qcMlWB6LmT/8XsOoJM9Mq/0pox/YqQAMDA7uqaPPN/7p8NLvbRcOk4XZMhno2fzhsqbn TtnEbmY4kBStGX9XiSKxbktJIrVsmzdXXnTouN8Xi1J0GZieeTUIs4Da9yJsdkcK1d+Q POXmbfMXg2QXd7UgqjlLPu1lyweg90J3QkqHUOAu1XT+lwL+j80UIxLJdmqLN80sI2Vf OuhJD9cxOmby2guNy+Eve4yGvBXliA4Vnvfgylkix5bdod7o0tU4FAkpFhU75RJB93dN zX5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CDer5OdE; 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 i19-20020a1709064fd300b0073d6911e1absi1355925ejw.530.2022.08.23.23.38.35; Tue, 23 Aug 2022 23:39:01 -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=CDer5OdE; 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 S234677AbiHXF4q (ORCPT + 99 others); Wed, 24 Aug 2022 01:56:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiHXF4n (ORCPT ); Wed, 24 Aug 2022 01:56:43 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B0C89CCA for ; Tue, 23 Aug 2022 22:56:42 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id 2so12642104edx.2 for ; Tue, 23 Aug 2022 22:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=IqQH8glAVc4Uz1KdvwFFC42e+CS3+BpGZdq1n3kfHOA=; b=CDer5OdErg8Gx/O21HaRV2uFcEIz/Tyr7apVmI7Tw5XhFJkDgkbRFgZnRFNJsiAeWi AYUe3M7LzpP46p8VczdGCayqXYEm1VR3I1DrazocSwDdC0LSmEJagG1fElE7pCjBueUH ZT3yxy62CiBxdNmWWEtTiG7otVCcClaBPtDss= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=IqQH8glAVc4Uz1KdvwFFC42e+CS3+BpGZdq1n3kfHOA=; b=N2XturfkraKjvXjcGdGlpCWnixf8LjHNTt+DsURqBRzQ5Lc8omnVQpNA4LAJBMh2s4 Wgw+B32zhIBb6DQP5FnHgyz/f4me8aCIeZLaUXSVN9BVKjZmH1hh0fpcAgPemHq+ZqyZ 7xkB7CsIGcTcyqFA6bTbSSy4QPnpHkReAvJPKlXNgaKDKpxu6J4zPiryiM273o0i0TBQ WyyDEZvICZhrb+XLLtJOU95E1p3XIhrL6RrtNlxeWZvIXmSEB50i6uNmjlswFVi4+VdC vh2pVCUNILi98L6l5rj3xuEicvxTh2I5+gntzb2F8LgDjR0KT8OrJ/3/19vZN2tH1XPA 9/fA== X-Gm-Message-State: ACgBeo1EeA+f7AI9fjltYM6xwJVdLp6RXAolsO5fRl1XPgCze/fc5neA XOpE5Opxvy1AwC66KBn/PVRgdxBKi5f9sPMR X-Received: by 2002:a05:6402:2381:b0:446:7a73:e704 with SMTP id j1-20020a056402238100b004467a73e704mr6304455eda.244.1661320600394; Tue, 23 Aug 2022 22:56:40 -0700 (PDT) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com. [209.85.221.48]) by smtp.gmail.com with ESMTPSA id q4-20020a170906770400b007389c5a45f0sm682585ejm.148.2022.08.23.22.56.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Aug 2022 22:56:39 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id h24so19416668wrb.8 for ; Tue, 23 Aug 2022 22:56:38 -0700 (PDT) X-Received: by 2002:a05:6000:1888:b0:222:ca41:dc26 with SMTP id a8-20020a056000188800b00222ca41dc26mr14194866wri.442.1661320598478; Tue, 23 Aug 2022 22:56:38 -0700 (PDT) MIME-Version: 1.0 References: <20220821000737.328590235@goodmis.org> <20220821000844.510643400@goodmis.org> <5700ac75-f6a9-877e-4011-9b314f12b5ab@acm.org> <02daa3d6-2847-d7e0-e23e-411076c6d4db@rasmusvillemoes.dk> <0163b361-14bf-7b4c-751a-14f1a004b1a9@acm.org> In-Reply-To: From: Linus Torvalds Date: Tue, 23 Aug 2022 22:56:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [for-linus][PATCH 01/10] tracing: Suppress sparse warnings triggered by is_signed_type() To: Al Viro Cc: Bart Van Assche , Rasmus Villemoes , Steven Rostedt , linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Christoph Hellwig , Luc Van Oostenryck , Jens Axboe Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Tue, Aug 23, 2022 at 8:10 PM Al Viro wrote: > > Any operations like ordered comparisons would trigger unrestrict() on > these suckers, which would warn and convert to underlying type. > > Your addition of "ordered comparison with 0 or -1" evades unrestrict(). No. Look. Try this modification to that test, and use './test-linearize' to see what sparse turns it into without my patch to keep the signedness. static long test(void) { return (le32) 0xffffffff; } yes, yes, it warns (twice, actually), but it also then generates ret.64 $-1 for that return. Why? Because it thinks that 'le32' is a signed 32-bit thing due to the clearing of the MOD_UNSIGNED bit, so when it casts it to 'long' it will sign-extend it. So the sign confusion exists and is visible regardless of the added ordered comparison. Now, we normally don't *notice* any of this, because we obviously don't rely on sparse generating any code. And we _do_ cast those bitwise things in many places, although we use "__force" to show that it's intentional. Including, very much, those kinds of widening casts where the signedness matters. See for example very much the csum code: __wsum csum_partial(const void *buff, int len, __wsum wsum) { unsigned int sum = (__force unsigned int)wsum; which is *exactly* that kind of code where it's fundamentally important that 'wsum' is an unsigned type, and casting it to 'unsigned int' does not sign-extend it. So no. This has absolutely nothing to do with the new ordered comparisons. Those bitwise types have always been integers, just with special rules for warning about mis-using them. And the sign handling has always been wrong. It just so happens that me using 'test-linearize' to double-check what sparse does for that signedness check *uncovered* that pre-existing bug. It was not introduced by the new code, and the ordered comparisons are not AT ALL different from the equality comparisons, except for the fact that they actually care about the signedness being right. Linus