* [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro
@ 2026-05-06 11:04 Tudor Ambarus
2026-05-06 22:24 ` Randy Dunlap
2026-05-11 20:08 ` Kees Cook
0 siblings, 2 replies; 3+ messages in thread
From: Tudor Ambarus @ 2026-05-06 11:04 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Kees Cook, Gustavo A. R. Silva
Cc: linux-kernel, linux-doc, linux-hardening, peter.griffin,
andre.draszik, willmcvicker, jyescas, krzk, kernel-team,
Tudor Ambarus
The `__counted_by_ptr` macro was recently introduced [1] to extend
bounds checking semantics to standard dynamically allocated pointers.
However, the new Python implementation of kernel-doc does not currently
recognize it as a compiler attribute. When kernel-doc encounters a
struct member annotated with this macro, it fails to parse the variable
name correctly, resulting in false-positive warnings like:
Warning: ... struct member '__counted_by_ptr(cmdcnt' not described
Add `__counted_by_ptr` to the `struct_xforms` regex list so it gets
safely stripped out during the parsing phase, mirroring the existing
behavior for `__counted_by`. Update the corresponding unit tests.
Link: https://git.kernel.org/torvalds/c/150a04d817d8 [1]
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
tools/lib/python/kdoc/xforms_lists.py | 1 +
tools/unittests/test_cmatch.py | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
index f6ea9efb11ae..118156ea8cd2 100644
--- a/tools/lib/python/kdoc/xforms_lists.py
+++ b/tools/lib/python/kdoc/xforms_lists.py
@@ -29,6 +29,7 @@ class CTransforms:
(CMatch("__aligned"), ""),
(CMatch("__counted_by"), ""),
(CMatch("__counted_by_(le|be)"), ""),
+ (CMatch("__counted_by_ptr"), ""),
(CMatch("__guarded_by"), ""),
(CMatch("__pt_guarded_by"), ""),
(CMatch("__packed"), ""),
diff --git a/tools/unittests/test_cmatch.py b/tools/unittests/test_cmatch.py
index 7b996f83784d..109141cd2ab8 100755
--- a/tools/unittests/test_cmatch.py
+++ b/tools/unittests/test_cmatch.py
@@ -320,6 +320,7 @@ class TestSubWithLocalXforms(TestCaseDiff):
(CMatch('__aligned'), ' '),
(CMatch('__counted_by'), ' '),
(CMatch('__counted_by_(le|be)'), ' '),
+ (CMatch('__counted_by_ptr'), ' '),
(CMatch('__guarded_by'), ' '),
(CMatch('__pt_guarded_by'), ' '),
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260506-kdoc-__counted_by_ptr-1e206f3f1dc1
Best regards,
--
Tudor Ambarus <tudor.ambarus@linaro.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro
2026-05-06 11:04 [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro Tudor Ambarus
@ 2026-05-06 22:24 ` Randy Dunlap
2026-05-11 20:08 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2026-05-06 22:24 UTC (permalink / raw)
To: Tudor Ambarus, Mauro Carvalho Chehab, Kees Cook,
Gustavo A. R. Silva
Cc: linux-kernel, linux-doc, linux-hardening, peter.griffin,
andre.draszik, willmcvicker, jyescas, krzk, kernel-team
On 5/6/26 4:04 AM, Tudor Ambarus wrote:
> The `__counted_by_ptr` macro was recently introduced [1] to extend
> bounds checking semantics to standard dynamically allocated pointers.
>
> However, the new Python implementation of kernel-doc does not currently
> recognize it as a compiler attribute. When kernel-doc encounters a
> struct member annotated with this macro, it fails to parse the variable
> name correctly, resulting in false-positive warnings like:
>
> Warning: ... struct member '__counted_by_ptr(cmdcnt' not described
>
> Add `__counted_by_ptr` to the `struct_xforms` regex list so it gets
> safely stripped out during the parsing phase, mirroring the existing
> behavior for `__counted_by`. Update the corresponding unit tests.
>
> Link: https://git.kernel.org/torvalds/c/150a04d817d8 [1]
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
> ---
> tools/lib/python/kdoc/xforms_lists.py | 1 +
> tools/unittests/test_cmatch.py | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py
> index f6ea9efb11ae..118156ea8cd2 100644
> --- a/tools/lib/python/kdoc/xforms_lists.py
> +++ b/tools/lib/python/kdoc/xforms_lists.py
> @@ -29,6 +29,7 @@ class CTransforms:
> (CMatch("__aligned"), ""),
> (CMatch("__counted_by"), ""),
> (CMatch("__counted_by_(le|be)"), ""),
> + (CMatch("__counted_by_ptr"), ""),
> (CMatch("__guarded_by"), ""),
> (CMatch("__pt_guarded_by"), ""),
> (CMatch("__packed"), ""),
> diff --git a/tools/unittests/test_cmatch.py b/tools/unittests/test_cmatch.py
> index 7b996f83784d..109141cd2ab8 100755
> --- a/tools/unittests/test_cmatch.py
> +++ b/tools/unittests/test_cmatch.py
> @@ -320,6 +320,7 @@ class TestSubWithLocalXforms(TestCaseDiff):
> (CMatch('__aligned'), ' '),
> (CMatch('__counted_by'), ' '),
> (CMatch('__counted_by_(le|be)'), ' '),
> + (CMatch('__counted_by_ptr'), ' '),
> (CMatch('__guarded_by'), ' '),
> (CMatch('__pt_guarded_by'), ' '),
>
>
> ---
> base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
> change-id: 20260506-kdoc-__counted_by_ptr-1e206f3f1dc1
>
> Best regards,
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro
2026-05-06 11:04 [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro Tudor Ambarus
2026-05-06 22:24 ` Randy Dunlap
@ 2026-05-11 20:08 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2026-05-11 20:08 UTC (permalink / raw)
To: Tudor Ambarus
Cc: Mauro Carvalho Chehab, Gustavo A. R. Silva, linux-kernel,
linux-doc, linux-hardening, peter.griffin, andre.draszik,
willmcvicker, jyescas, krzk, kernel-team
On Wed, May 06, 2026 at 11:04:12AM +0000, Tudor Ambarus wrote:
> The `__counted_by_ptr` macro was recently introduced [1] to extend
> bounds checking semantics to standard dynamically allocated pointers.
>
> However, the new Python implementation of kernel-doc does not currently
> recognize it as a compiler attribute. When kernel-doc encounters a
> struct member annotated with this macro, it fails to parse the variable
> name correctly, resulting in false-positive warnings like:
>
> Warning: ... struct member '__counted_by_ptr(cmdcnt' not described
>
> Add `__counted_by_ptr` to the `struct_xforms` regex list so it gets
> safely stripped out during the parsing phase, mirroring the existing
> behavior for `__counted_by`. Update the corresponding unit tests.
>
> Link: https://git.kernel.org/torvalds/c/150a04d817d8 [1]
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 11:04 [PATCH] docs: kernel-doc: python: strip __counted_by_ptr macro Tudor Ambarus
2026-05-06 22:24 ` Randy Dunlap
2026-05-11 20:08 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox