All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] overflow: Fix kern-doc markup for functions
@ 2022-10-17  3:57 Kees Cook
  2022-10-18  1:11 ` Akira Yokosawa
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2022-10-17  3:57 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Kees Cook, Akira Yokosawa, linux-doc, linux-hardening,
	Jens Axboe, Johannes Thumshirn, Matthew Wilcox (Oracle),
	Yanteng Si, Darrick J. Wong, Masahiro Yamada, linux-kernel

Fix the kern-doc markings for several of the overflow helpers and move
their location into the core kernel API documentation, where it belongs
(it's not driver-specific).

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Akira Yokosawa <akiyks@gmail.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 Documentation/core-api/kernel-api.rst |  6 +++++
 Documentation/driver-api/basics.rst   |  3 ---
 include/linux/overflow.h              | 38 +++++++++++----------------
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/Documentation/core-api/kernel-api.rst b/Documentation/core-api/kernel-api.rst
index 0793c400d4b0..06f4ab122697 100644
--- a/Documentation/core-api/kernel-api.rst
+++ b/Documentation/core-api/kernel-api.rst
@@ -118,6 +118,12 @@ Text Searching
 CRC and Math Functions in Linux
 ===============================
 
+Arithmetic Overflow Checking
+----------------------------
+
+.. kernel-doc:: include/linux/overflow.h
+   :internal:
+
 CRC Functions
 -------------
 
diff --git a/Documentation/driver-api/basics.rst b/Documentation/driver-api/basics.rst
index 3e2dae954898..4b4d8e28d3be 100644
--- a/Documentation/driver-api/basics.rst
+++ b/Documentation/driver-api/basics.rst
@@ -107,9 +107,6 @@ Kernel utility functions
 .. kernel-doc:: kernel/panic.c
    :export:
 
-.. kernel-doc:: include/linux/overflow.h
-   :internal:
-
 Device Resource Management
 --------------------------
 
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 19dfdd74835e..1d3be1a2204c 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -51,8 +51,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
 	return unlikely(overflow);
 }
 
-/** check_add_overflow() - Calculate addition with overflow checking
- *
+/**
+ * check_add_overflow() - Calculate addition with overflow checking
  * @a: first addend
  * @b: second addend
  * @d: pointer to store sum
@@ -66,8 +66,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
 #define check_add_overflow(a, b, d)	\
 	__must_check_overflow(__builtin_add_overflow(a, b, d))
 
-/** check_sub_overflow() - Calculate subtraction with overflow checking
- *
+/**
+ * check_sub_overflow() - Calculate subtraction with overflow checking
  * @a: minuend; value to subtract from
  * @b: subtrahend; value to subtract from @a
  * @d: pointer to store difference
@@ -81,8 +81,8 @@ static inline bool __must_check __must_check_overflow(bool overflow)
 #define check_sub_overflow(a, b, d)	\
 	__must_check_overflow(__builtin_sub_overflow(a, b, d))
 
-/** check_mul_overflow() - Calculate multiplication with overflow checking
- *
+/**
+ * check_mul_overflow() - Calculate multiplication with overflow checking
  * @a: first factor
  * @b: second factor
  * @d: pointer to store product
@@ -96,23 +96,24 @@ static inline bool __must_check __must_check_overflow(bool overflow)
 #define check_mul_overflow(a, b, d)	\
 	__must_check_overflow(__builtin_mul_overflow(a, b, d))
 
-/** check_shl_overflow() - Calculate a left-shifted value and check overflow
- *
+/**
+ * check_shl_overflow() - Calculate a left-shifted value and check overflow
  * @a: Value to be shifted
  * @s: How many bits left to shift
  * @d: Pointer to where to store the result
  *
  * Computes *@d = (@a << @s)
  *
- * Returns true if '*d' cannot hold the result or when 'a << s' doesn't
+ * Returns true if '*@d' cannot hold the result or when '@a << @s' doesn't
  * make sense. Example conditions:
- * - 'a << s' causes bits to be lost when stored in *d.
- * - 's' is garbage (e.g. negative) or so large that the result of
- *   'a << s' is guaranteed to be 0.
- * - 'a' is negative.
- * - 'a << s' sets the sign bit, if any, in '*d'.
  *
- * '*d' will hold the results of the attempted shift, but is not
+ * - '@a << @s' causes bits to be lost when stored in *@d.
+ * - '@s' is garbage (e.g. negative) or so large that the result of
+ *   '@a << @s' is guaranteed to be 0.
+ * - '@a' is negative.
+ * - '@a << @s' sets the sign bit, if any, in '*@d'.
+ *
+ * '*@d' will hold the results of the attempted shift, but is not
  * considered "safe for use" if true is returned.
  */
 #define check_shl_overflow(a, s, d) __must_check_overflow(({		\
@@ -129,7 +130,6 @@ static inline bool __must_check __must_check_overflow(bool overflow)
 
 /**
  * size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX
- *
  * @factor1: first factor
  * @factor2: second factor
  *
@@ -149,7 +149,6 @@ static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
 
 /**
  * size_add() - Calculate size_t addition with saturation at SIZE_MAX
- *
  * @addend1: first addend
  * @addend2: second addend
  *
@@ -169,7 +168,6 @@ static inline size_t __must_check size_add(size_t addend1, size_t addend2)
 
 /**
  * size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX
- *
  * @minuend: value to subtract from
  * @subtrahend: value to subtract from @minuend
  *
@@ -192,7 +190,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
 
 /**
  * array_size() - Calculate size of 2-dimensional array.
- *
  * @a: dimension one
  * @b: dimension two
  *
@@ -205,7 +202,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
 
 /**
  * array3_size() - Calculate size of 3-dimensional array.
- *
  * @a: dimension one
  * @b: dimension two
  * @c: dimension three
@@ -220,7 +216,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
 /**
  * flex_array_size() - Calculate size of a flexible array member
  *                     within an enclosing structure.
- *
  * @p: Pointer to the structure.
  * @member: Name of the flexible array member.
  * @count: Number of elements in the array.
@@ -237,7 +232,6 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
 
 /**
  * struct_size() - Calculate size of structure with trailing flexible array.
- *
  * @p: Pointer to the structure.
  * @member: Name of the array member.
  * @count: Number of elements in the array.
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] overflow: Fix kern-doc markup for functions
  2022-10-17  3:57 [PATCH v2] overflow: Fix kern-doc markup for functions Kees Cook
@ 2022-10-18  1:11 ` Akira Yokosawa
  2022-10-18  2:09   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Akira Yokosawa @ 2022-10-18  1:11 UTC (permalink / raw)
  To: Kees Cook, Jonathan Corbet
  Cc: linux-doc, linux-hardening, Jens Axboe, Johannes Thumshirn,
	Matthew Wilcox (Oracle),
	Yanteng Si, Darrick J. Wong, Masahiro Yamada, linux-kernel,
	Akira Yokosawa

Hi,

On Sun, 16 Oct 2022 20:57:32 -0700, Kees Cook wrote:
> Fix the kern-doc markings for several of the overflow helpers and move
> their location into the core kernel API documentation, where it belongs
> (it's not driver-specific).
> 
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Akira Yokosawa <akiyks@gmail.com>
LGTM,

Reviewed-by: Akira Yokosawa <akiyks@gmail.com>

Kees, which tree do you expect this one to go through?

        Thanks, Akira

> Cc: linux-doc@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  Documentation/core-api/kernel-api.rst |  6 +++++
>  Documentation/driver-api/basics.rst   |  3 ---
>  include/linux/overflow.h              | 38 +++++++++++----------------
>  3 files changed, 22 insertions(+), 25 deletions(-)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] overflow: Fix kern-doc markup for functions
  2022-10-18  1:11 ` Akira Yokosawa
@ 2022-10-18  2:09   ` Kees Cook
  2022-10-18 13:48     ` Jonathan Corbet
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2022-10-18  2:09 UTC (permalink / raw)
  To: Akira Yokosawa
  Cc: Jonathan Corbet, linux-doc, linux-hardening, Jens Axboe,
	Johannes Thumshirn, Matthew Wilcox (Oracle),
	Yanteng Si, Darrick J. Wong, Masahiro Yamada, linux-kernel

On Tue, Oct 18, 2022 at 10:11:43AM +0900, Akira Yokosawa wrote:
> Hi,
> 
> On Sun, 16 Oct 2022 20:57:32 -0700, Kees Cook wrote:
> > Fix the kern-doc markings for several of the overflow helpers and move
> > their location into the core kernel API documentation, where it belongs
> > (it's not driver-specific).
> > 
> > Cc: Jonathan Corbet <corbet@lwn.net>
> > Cc: Akira Yokosawa <akiyks@gmail.com>
> LGTM,
> 
> Reviewed-by: Akira Yokosawa <akiyks@gmail.com>

Thanks!

> Kees, which tree do you expect this one to go through?

If the Documentation/* changes look okay, I'd rather carry it in my tree
since I'm going to be poking at more functions in there soon.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] overflow: Fix kern-doc markup for functions
  2022-10-18  2:09   ` Kees Cook
@ 2022-10-18 13:48     ` Jonathan Corbet
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Corbet @ 2022-10-18 13:48 UTC (permalink / raw)
  To: Kees Cook, Akira Yokosawa
  Cc: linux-doc, linux-hardening, Jens Axboe, Johannes Thumshirn,
	Matthew Wilcox (Oracle),
	Yanteng Si, Darrick J. Wong, Masahiro Yamada, linux-kernel

Kees Cook <keescook@chromium.org> writes:

> If the Documentation/* changes look okay, I'd rather carry it in my tree
> since I'm going to be poking at more functions in there soon.

That seems like as good a path for it as any.  Feel free to add

Acked-by: Jonathan Corbet <corbet@lwn.net>

...if you want.

Thanks,

jon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-18 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17  3:57 [PATCH v2] overflow: Fix kern-doc markup for functions Kees Cook
2022-10-18  1:11 ` Akira Yokosawa
2022-10-18  2:09   ` Kees Cook
2022-10-18 13:48     ` Jonathan Corbet

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.