Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp686840rwi; Wed, 26 Oct 2022 06:08:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4CUl4kauGAdAdmhZ1lJgxVtnLET3aJ0TBy+0yjKzlZJN6VQviFpxPx6p9PUnPaLidMnrua X-Received: by 2002:a17:902:b907:b0:178:2898:8084 with SMTP id bf7-20020a170902b90700b0017828988084mr43215780plb.140.1666789704832; Wed, 26 Oct 2022 06:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666789704; cv=none; d=google.com; s=arc-20160816; b=mOqw2R6vRGGKL0xb505UbmsLNxtQJJ/9qcBnK8KbbaI67aGQD4XoRpjhcvHVKrcLj7 UlBKCpTqfbvqgIZSTLscH7WMcJVogx94e7w+kxu8+mukJwcVRXnoa588B/fGUqSPZNzV mAAF0Kp6KBER5J/dtDYFyk9e6ba0G7qp7F7ZOM/2ci+tq5XaHI3P4cZ8SOh77Mh0JRC6 TtSIKPzAisqWqJ0KTiViWmUsAbLwPhybIldZz49NM8IQGruL7OaWBeYrOroOvGPHNY+Q hZPihZK85rFFJ7JjDBMiT2FunMFZdhWDkNL2k/pEcL/FQrU2fYjzQLBx3MjvVTXAEU81 sUmQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nCEjyF4eeUdu2SGiHo/u6gxWDuuFvR0oywxSo4xTaE4=; b=K0L0KriStFKy0KhhlTdFg2f1QyvmZR/9jZ8tOWs5rtYGePyywZQWdkd+n7fi9CQAUG I+GZ3PaL8Vkv5neIsy9nDAalsNorC7ulMX3uHN2XOaEn2ZPZ67bBnx55Ztm/SfOHjgMB JK2U9jLE6c5ByRDyI65th1JQYuA8G3k5FJhwG/uuDRsZGwx6ViFI+TbRH9+zE36+IOXZ k82AWVTUeWFz5qzosExeuve20bRs06zU32+CjntRQ8+ErG2BEOfeMEtx2UZVakTll5Q+ R3rnP6mBllGq5A3KaO6nf918IvKF+A8xEjE+za2in4WK1NuxAVIWZP/B4k1yrvOo4t7w wTtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=Gkw7X8XF; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090332c900b0017e22aeca47si7584873plr.552.2022.10.26.06.08.12; Wed, 26 Oct 2022 06:08:24 -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=@zx2c4.com header.s=20210105 header.b=Gkw7X8XF; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233401AbiJZM6o (ORCPT + 99 others); Wed, 26 Oct 2022 08:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233512AbiJZM6m (ORCPT ); Wed, 26 Oct 2022 08:58:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB4D1F63C2; Wed, 26 Oct 2022 05:58:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4AD4F61EBB; Wed, 26 Oct 2022 12:58:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9CFFC433C1; Wed, 26 Oct 2022 12:58:39 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="Gkw7X8XF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1666789117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nCEjyF4eeUdu2SGiHo/u6gxWDuuFvR0oywxSo4xTaE4=; b=Gkw7X8XFs5wZwIyVAA/OlHPNfvcvma8qpkZTuOrtLdOtLXEREYRyEbP7TT4Oe8qi1TT5s1 DyaTa94c8ILXgCb40n4ePKMo5zfm+BoHmDM7CbTubM/SBhoFGTI+8uUQ40dJ6DDtUSxUpV /MU/yosRl5pfdP0cTO20yH1XVE9BOTE= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 6ebb8279 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 26 Oct 2022 12:58:37 +0000 (UTC) Date: Wed, 26 Oct 2022 14:58:34 +0200 From: "Jason A. Donenfeld" To: Kees Cook , cocci@inria.fr Cc: Linus Torvalds , Alexey Dobriyan , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, mm-commits@vger.kernel.org, masahiroy@kernel.org, gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, Stephen Rothwell Subject: Re: [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array Message-ID: References: <20221020000356.177CDC433C1@smtp.kernel.org> <202210201151.ECC19BC97A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 26, 2022 at 03:50:25AM +0200, Jason A. Donenfeld wrote: > The traditional objdump comparison does work, though. It produces a good Another thing that appears to work well is just using Coccinelle scripts. I've had some success just scrolling through the results of: @@ char c; expression E; @@ ( * E > c | * E >= c | * E < c | * E <= c ) That also triggers on explicitly signed chars, and examining those reveals that quite a bit of code in the tree already does do the right thing, which is good. From looking at this and objdump output, it looks like most naked-char usage that isn't for strings is actually already assuming it's unsigned, using it as a byte. I'll continue to churn, and I'm sure I'll miss a few things here and there, but all and all, I don't think this is looking as terrible as I initially feared. I'm CC'ing the Coccinelle people to see if they have any nice ideas on improvements. Specifically, the thing we're trying to identify is: - Usage of vanilla `char`, without a `signed` or `unsigned` qualifier, where: - It's not being used for characters; and - It's doing something that assumes it is signed, such as various types of comparisons or decrements. LWN wrote a summary of the general problem, in case that helps describe what would be useful: https://lwn.net/SubscriberLink/911914/f90c2ed1af23cbc4/ Any nice Cocci tricks for this? Jason