From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: corbet@lwn.net, mchehab+huawei@kernel.org, dlatypov@google.com,
davidgow@google.com
Cc: linux-doc@vger.kernel.org, linux-sparse@vger.kernel.org,
cocci@inria.fr, smatch@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org
Subject: [cocci] [PATCH] Documentation: dev-tools: Add a section for static analysis tools
Date: Mon, 28 Mar 2022 18:19:56 -0300 [thread overview]
Message-ID: <YkImfPbNOzQBq5ZD@marsc.168.1.7> (raw)
Complement the Kernel Testing Guide documentation page by adding a
section about static analysis tools.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
---
Hey everyone,
I think this patch can be a good addition to the documentation as
discussed in the thread for the testing guide documentation page:
Link: https://lore.kernel.org/linux-doc/CABVgOS=2iYtqTVdxwH=mcFpcSuLP4cpJ4s6PKP4Gc-SH6jidgQ@mail.gmail.com/
If you think it would be worth it, I can try making something more
elaborated. Maybe provide some guidance on when to use each tool.
I've been studying how Linux device drivers are tested.
Here's a post I wrote talking about some testing tools.
Link: https://marcelosc.gitlab.io/how-is-linux-tested/
Best regards,
Marcelo
Documentation/dev-tools/testing-overview.rst | 29 ++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/Documentation/dev-tools/testing-overview.rst b/Documentation/dev-tools/testing-overview.rst
index 65feb81edb14..b00511109a9d 100644
--- a/Documentation/dev-tools/testing-overview.rst
+++ b/Documentation/dev-tools/testing-overview.rst
@@ -115,3 +115,32 @@ 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 may also scout for bugs by
+analyzing the source code semantics. Three tools are well known for serving this
+purpose.
+
+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/.
+
+We also have Coccinelle as an option within static analyzers. Coccinelle is
+often used to aid collateral evolution of source code, but it can also help to
+avoid certain bugs that have been expressed semantically. 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.
+
+These static analysis tools support running tests on the whole source tree or
+over a specific file or directory.
--
2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: corbet@lwn.net, mchehab+huawei@kernel.org, dlatypov@google.com,
davidgow@google.com
Cc: linux-doc@vger.kernel.org, linux-sparse@vger.kernel.org,
cocci@inria.fr, smatch@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org
Subject: [PATCH] Documentation: dev-tools: Add a section for static analysis tools
Date: Mon, 28 Mar 2022 18:19:56 -0300 [thread overview]
Message-ID: <YkImfPbNOzQBq5ZD@marsc.168.1.7> (raw)
Complement the Kernel Testing Guide documentation page by adding a
section about static analysis tools.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
---
Hey everyone,
I think this patch can be a good addition to the documentation as
discussed in the thread for the testing guide documentation page:
Link: https://lore.kernel.org/linux-doc/CABVgOS=2iYtqTVdxwH=mcFpcSuLP4cpJ4s6PKP4Gc-SH6jidgQ@mail.gmail.com/
If you think it would be worth it, I can try making something more
elaborated. Maybe provide some guidance on when to use each tool.
I've been studying how Linux device drivers are tested.
Here's a post I wrote talking about some testing tools.
Link: https://marcelosc.gitlab.io/how-is-linux-tested/
Best regards,
Marcelo
Documentation/dev-tools/testing-overview.rst | 29 ++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/Documentation/dev-tools/testing-overview.rst b/Documentation/dev-tools/testing-overview.rst
index 65feb81edb14..b00511109a9d 100644
--- a/Documentation/dev-tools/testing-overview.rst
+++ b/Documentation/dev-tools/testing-overview.rst
@@ -115,3 +115,32 @@ 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 may also scout for bugs by
+analyzing the source code semantics. Three tools are well known for serving this
+purpose.
+
+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/.
+
+We also have Coccinelle as an option within static analyzers. Coccinelle is
+often used to aid collateral evolution of source code, but it can also help to
+avoid certain bugs that have been expressed semantically. 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.
+
+These static analysis tools support running tests on the whole source tree or
+over a specific file or directory.
--
2.35.1
next reply other threads:[~2022-03-29 7:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 21:19 Marcelo Schmitt [this message]
2022-03-28 21:19 ` [PATCH] Documentation: dev-tools: Add a section for static analysis tools Marcelo Schmitt
2022-03-28 22:36 ` [cocci] " Shuah Khan
2022-03-28 22:36 ` Shuah Khan
2022-03-28 22:37 ` [cocci] " Daniel Latypov
2022-03-28 22:37 ` Daniel Latypov
2022-03-29 9:07 ` [cocci] " Dan Carpenter
2022-03-29 9:07 ` Dan Carpenter
2022-03-29 9:24 ` [cocci] " Julia Lawall
2022-03-29 4:29 ` David Gow
2022-03-29 4:29 ` David Gow
2022-03-29 7:31 ` [cocci] " Julia Lawall
2022-03-29 9:09 ` Dan Carpenter
2022-03-29 9:09 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YkImfPbNOzQBq5ZD@marsc.168.1.7 \
--to=marcelo.schmitt1@gmail.com \
--cc=cocci@inria.fr \
--cc=corbet@lwn.net \
--cc=davidgow@google.com \
--cc=dlatypov@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=smatch@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.