Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp705128rwi; Wed, 26 Oct 2022 06:20:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5d0GLsPtg+L4faZEL0lqhSo1gwhh8Ez8w2LOdS7bugcEzlGdmI3zNpJ16z2qt6KQGbnz0s X-Received: by 2002:aa7:810a:0:b0:55b:674d:d123 with SMTP id b10-20020aa7810a000000b0055b674dd123mr45104631pfi.52.1666790417087; Wed, 26 Oct 2022 06:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666790417; cv=none; d=google.com; s=arc-20160816; b=CVs6rRMkkt6RBwHkWfVDzNbzv06lSveGFJbpcznzHWj/MD7skW+X11gRtTOjthNpX1 pc3gZx5nyJwnvq0NFmV1mT8V458OnsNnnp1IDCVpLJnxgAoRt1C9BPsuLOZ04nIoyOu4 BxohALFXolswEmzloeCsPAzwIawlzmOL84o1ZV4hxLV4QKZ3yaCy93oGfKAALenqJIc1 RuXBw18RUpWMaBLkyOz7QB1oKq23LYx/mIE96Wbrhb1dga1/soQ+GGOQA+pMjOuQQj3+ ghSp2Z2GI4Mmo6cMsPCXMCLj13CELQ/X9LknQ9z1AdB85P6Vz/0JKhfJQGFoYKIS8rts LRdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HOXeMERZiIWatd6+bU1vv+JXuqML/2GyixOeq4YxUes=; b=SQiEolzz1CPAHqmT/FKUblZuVW6yf4drEHwswwH1infcxFABoVbh02NEVT7liN7bGH p2pV5Clq8yr8HCpY3IyklRc8H9Mj7rU7/tV7Clyo5WY98FaWVCzP4RccHvH52Eeza4zc FnLADW9q7fQquyefGJ9gYSFPv5uV68QYy0LVA8z6tLvm6IZ4iHg8Q9s1Au355wbNjYkL cM1xBUJdGq8VG7TF3qwbNzYB4vJYuntyx3NXSST2nNIjBAveMv1vigZee5APYXqM5ghj 4Ab1RlzfjSg060gzsTF9e2seUUmGzbYhvHdZrMCPThJCxWTUCz2chPmO4LEO71d/pdwk TnZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MIjeZ4Zy; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj12-20020a170903048c00b00176e85e5ceasi6075460plb.405.2022.10.26.06.20.04; Wed, 26 Oct 2022 06:20:17 -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=@intel.com header.s=Intel header.b=MIjeZ4Zy; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232733AbiJZNSd (ORCPT + 99 others); Wed, 26 Oct 2022 09:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233983AbiJZNSJ (ORCPT ); Wed, 26 Oct 2022 09:18:09 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3D2A103DB2; Wed, 26 Oct 2022 06:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666790236; x=1698326236; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hIbMjk472qjMcR6jrGfkylFFiMP/jDat0gI5PwpO4rw=; b=MIjeZ4ZyFKsTzLBq4Pq6STvwJaE4Yr/xWOZYOiHgBMUNsVxbXDIhpnhs G2s3ENh+t8qmJtWwpcBTJ1owPgc2a6SpoqWgIk+dYNBilpVLFciHCd5jm tXrJi8z6lRiqde6VAs8oGOI4TBR7LiqdNH0QUIKdp/q2dDK0QrTAW0Alj x/lVJ/xdLJ0uwcqjkZ4ioBjABTgIxTJQr6naXR1YU2CrJSWh0/yEa0LsD Pt4qlEibg7AfOp1kqqkCdbM/uBv9X1ZP2g4+qjYN1NvE5s1frKRZymnXh 1wmYEVTwr8B7s5CYGRw6zCJ8Yn8lAM94FW1DrQzdrgjSEGDtHWbuPOoNt Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="307935495" X-IronPort-AV: E=Sophos;i="5.95,214,1661842800"; d="scan'208";a="307935495" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 06:17:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="632000787" X-IronPort-AV: E=Sophos;i="5.95,214,1661842800"; d="scan'208";a="632000787" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 26 Oct 2022 06:17:07 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1ongHJ-002f4J-0g; Wed, 26 Oct 2022 16:17:05 +0300 Date: Wed, 26 Oct 2022 16:17:04 +0300 From: Andy Shevchenko To: "Jason A. Donenfeld" , Rasmus Villemoes Cc: Kees Cook , cocci@inria.fr, Linus Torvalds , Alexey Dobriyan , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, mm-commits@vger.kernel.org, masahiroy@kernel.org, gregkh@linuxfoundation.org, 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=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,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 +Cc: Rasmus as he has done a lot regarding library stuff and optimizations and he knows Coccinelle (to some extent as far as I can tell). On Wed, Oct 26, 2022 at 02:58:34PM +0200, Jason A. Donenfeld wrote: > 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? -- With Best Regards, Andy Shevchenko