Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp364127pxb; Thu, 31 Mar 2022 07:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGlUfMAx/dVnKQUp7bn+e41EBZdU3nDnRv5DPqeYACz/0IAVKJxGfdCaqJCDE9iglsDGbO X-Received: by 2002:a17:907:1ca5:b0:6e4:8244:81cb with SMTP id nb37-20020a1709071ca500b006e4824481cbmr5047966ejc.199.1648735945574; Thu, 31 Mar 2022 07:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648735945; cv=none; d=google.com; s=arc-20160816; b=XoYCg/GUtKjlxxyynWsWwPuG78VzjOsiMpmfer1cjEmfuRX96+dn6SVEL5PxafJQ/y PHPf0Nv/eY5mV55A/EUSsdPqInh3eVvZVW9rLHbWYYgpzM0EkbbdRgaSOP3NtE7S398a 5d+FUTuFik6DMoTtSNsHdpCi3WLHJRQTGqXBVpeXmgCqwOs3a1qGgF3sLGaslOSXt2qr irgiK5NwYjpPNeY1p0HoUAS6o4pQIRi846rbL8gX1dzjtFsLC/v8h8qgtBEEeu06TUWM PdOTBE2kHu7cf3s4TNl33df7kaiy/c19C6ZzEmvYQrUW9cutT+7SIpLkh0kfAvn5HydW EzSg== 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=JMLH4roAssjYlqt9tXdE/1yhUcCtf54ytNBqcciXIlM=; b=I4bvDtsHwYVnoqrSbMzd5mW7mEVNCp7tqiW0d5tFtfWlx79132bf2Fy4LOXIHHVHH9 IzKlUSb5yHZciB4G65WshYn4aSLjHMHQEQeyXzq6oF8ZLHV2d01ikG79fXVKxcnnVX5S pHwcWWRwUyt+9asENAAP+V4b5lqT0ykk9OCHMnS7SAQTa6EQCki5gF99r2TiQ+twqgYP ffoQGp9xzCWaCgJWjkAw7hbYh5m+6mvtYXvoHzOs7/QT3mnwuwakIOs0fDndnRD4uhfF QiB5ZwqO5dsSohzIvQS9LvvnnTw5Q7afxqdQtqNzOvTXKMx2uuD3HxK9jgL+R6HRBz0+ 3w6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ijUCtOM1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lj19-20020a170906f9d300b006df76385ecfsi23383532ejb.879.2022.03.31.07.11.57; Thu, 31 Mar 2022 07:12:25 -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=@gmail.com header.s=20210112 header.b=ijUCtOM1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235858AbiCaMMU (ORCPT + 99 others); Thu, 31 Mar 2022 08:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234646AbiCaMMT (ORCPT ); Thu, 31 Mar 2022 08:12:19 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 401F61EA289; Thu, 31 Mar 2022 05:10:32 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-df22f50e0cso7853899fac.3; Thu, 31 Mar 2022 05:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JMLH4roAssjYlqt9tXdE/1yhUcCtf54ytNBqcciXIlM=; b=ijUCtOM1m7OVkDb45cGiWdBHuwTxDGwfxBnUwPRC7Q1GuaBWYJJ84njX/3Z25x3GSr YfEYYMSpdZI/Z/eDfTbYg3rOnsgZCm1mXxZFCTLRt82RVayttX4XtuYMNgNGX8kfSdH0 LutWf5upxYJPzKRymQvj9WrsefH68XJtF68wZ8VWkklhRaxoNASjbb2wbLO++plJQToG 3o1gNdNICkrS07zCMwwCiTKMy6SbfeEmu9zRhQNNO+G+nmNRS3kL7db2aPEQrhuHXANd Yk092aFTrKJxizm62StO2coJTxXptU0L9HkdjxFfesC1HC3id8m0pHEYauQfWfFviwmH rXVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JMLH4roAssjYlqt9tXdE/1yhUcCtf54ytNBqcciXIlM=; b=lHXfgI1Y7AnOUZOyJhfQkF8Uf8nlbj/67eyFgQs+DovGwXvUgE9zcukmoIa/oS2HCy 9CL7UWJBBt7h/zMIV17a6Xez/iXbZA1+Iwy7o63AZFnhd0z0ajvw+ySCQsPP3/JZTQWl w66Y17PgnKptixagGWxhuP/cT8eFTaoag8LnUF0QivZBcoYYRHs3uMNvEqbQfg+Qu9Fb XBBwNw3AWsMp+nG7jJLsbzRB29w1AmiGlDkoW9duSBxbTxTutKoczICsRT1OgDCxXuzk WDrJR7HHOLBZ2hcBDiqE05/Chp2pI4AdkU2URUW4tHwfaxPVawSeQwrT8O2bo5qzV1F+ /4Pg== X-Gm-Message-State: AOAM5337YHLGvVN/hVF5GvypCNDgadvM3F79FhcTWFq0EBcaaCIEtm9x O/U5OQG8s1KFAjicm2adFgsHcZYiiHr8yg== X-Received: by 2002:a05:6871:85:b0:d9:ac7a:7a5a with SMTP id u5-20020a056871008500b000d9ac7a7a5amr2499111oaa.9.1648728630062; Thu, 31 Mar 2022 05:10:30 -0700 (PDT) Received: from marsc.168.1.7 ([2804:d57:1500:3a00:7d51:e2a5:f339:2aa7]) by smtp.gmail.com with ESMTPSA id v13-20020a4ae6cd000000b00328882a2388sm2978034oot.14.2022.03.31.05.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 05:10:29 -0700 (PDT) Date: Thu, 31 Mar 2022 09:10:23 -0300 From: Marcelo Schmitt To: Dongliang Mu Cc: Jonathan Corbet , Mauro Carvalho Chehab , dlatypov@google.com, davidgow@google.com, linux-doc@vger.kernel.org, linux-sparse@vger.kernel.org, cocci@inria.fr, smatch@vger.kernel.org, linux-kernel , skhan@linuxfoundation.org, Dan Carpenter , julia.lawall@inria.fr Subject: Re: [PATCH v3 1/2] Documentation: dev-tools: Add a section for static analysis tools Message-ID: References: <7d793c1b9f87d9cb8ac0e858e561e108c2bf0176.1648674305.git.marcelo.schmitt1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Hi Dongliang, On 03/31, Dongliang Mu wrote: > On Thu, Mar 31, 2022 at 12:07 PM Marcelo Schmitt > wrote: > > > > Complement the Kernel Testing Guide documentation page by adding a > > section about static analysis tools. > > > > Signed-off-by: Marcelo Schmitt > > Acked-by: Daniel Latypov > > Acked-by: Dan Carpenter > > Acked-by: Julia Lawall > > Reviewed-by: David Gow > > Reviewed-by: Shuah Khan > > --- > > Change log v2 -> v3: > > - Added Julia's acknowledgment tag > > > > Change log v1 -> v2: > > - Brought generic tool characteristics to the intro paragraph > > - Made explicit that these tools run at compile time > > - Added a note of caution about false positives > > - Updated Coccinelle info to make it sound better and be more skimmable > > > > Documentation/dev-tools/testing-overview.rst | 31 ++++++++++++++++++++ > > 1 file changed, 31 insertions(+) > > > > diff --git a/Documentation/dev-tools/testing-overview.rst b/Documentation/dev-tools/testing-overview.rst > > index 65feb81edb14..b5e02dd3fd94 100644 > > --- a/Documentation/dev-tools/testing-overview.rst > > +++ b/Documentation/dev-tools/testing-overview.rst > > @@ -115,3 +115,34 @@ that none of these errors are occurring during the test. > > Some of these tools integrate with KUnit or kselftest and will > > automatically fail tests if an issue is detected. > > > > +Static Analysis Tools > > +===================== > > + > > +In addition to testing a running kernel, one can also analyze kernel source code > > +directly (**at compile time**) using **static analysis** tools. The tools > > +commonly used in the kernel allow one to inspect the whole source tree or just > > +specific files within it. They make it easier to detect and fix problems during > > +the development process. > > + > > +Sparse can help test the kernel by performing type-checking, lock checking, > > +value range checking, in addition to reporting various errors and warnings while > > +examining the code. See the Documentation/dev-tools/sparse.rst documentation > > +page for details on how to use it. > > + > > +Smatch extends Sparse and provides additional checks for programming logic > > +mistakes such as missing breaks in switch statements, unused return values on > > +error checking, forgetting to set an error code in the return of an error path, > > +etc. Smatch also has tests against more serious issues such as integer > > +overflows, null pointer dereferences, and memory leaks. See the project page at > > +http://smatch.sourceforge.net/. > > + > > +Coccinelle is another static analyzer at our disposal. Coccinelle is often used > > +to aid refactoring and collateral evolution of source code, but it can also help > > +to avoid certain bugs that occur in common code patterns. The types of tests > > +available include API tests, tests for correct usage of kernel iterators, checks > > +for the soundness of free operations, analysis of locking behavior, and further > > +tests known to help keep consistent kernel usage. See the > > +Documentation/dev-tools/coccinelle.rst documentation page for details. > > + > > +Beware, though, that static analysis tools suffer from **false positives**. > > +Errors and warns need to be evaluated carefully before attempting to fix them. > > Hi Marcelo, > > Should we include static analysis tools based on LLVM? For example, > Clang static analysis. I think that would be a good addition. I haven't checked out Clang tools though, so it would take me a bit more time to write something about that. > > > -- > > 2.35.1 > >