Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

overflow: Fix kern-doc markup for functions

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: linux-doc@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
Reviewed-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>

+22 -25
+6
Documentation/core-api/kernel-api.rst
··· 118 118 CRC and Math Functions in Linux 119 119 =============================== 120 120 121 + Arithmetic Overflow Checking 122 + ---------------------------- 123 + 124 + .. kernel-doc:: include/linux/overflow.h 125 + :internal: 126 + 121 127 CRC Functions 122 128 ------------- 123 129
-3
Documentation/driver-api/basics.rst
··· 107 107 .. kernel-doc:: kernel/panic.c 108 108 :export: 109 109 110 - .. kernel-doc:: include/linux/overflow.h 111 - :internal: 112 - 113 110 Device Resource Management 114 111 -------------------------- 115 112
+16 -22
include/linux/overflow.h
··· 51 51 return unlikely(overflow); 52 52 } 53 53 54 - /** check_add_overflow() - Calculate addition with overflow checking 55 - * 54 + /** 55 + * check_add_overflow() - Calculate addition with overflow checking 56 56 * @a: first addend 57 57 * @b: second addend 58 58 * @d: pointer to store sum ··· 66 66 #define check_add_overflow(a, b, d) \ 67 67 __must_check_overflow(__builtin_add_overflow(a, b, d)) 68 68 69 - /** check_sub_overflow() - Calculate subtraction with overflow checking 70 - * 69 + /** 70 + * check_sub_overflow() - Calculate subtraction with overflow checking 71 71 * @a: minuend; value to subtract from 72 72 * @b: subtrahend; value to subtract from @a 73 73 * @d: pointer to store difference ··· 81 81 #define check_sub_overflow(a, b, d) \ 82 82 __must_check_overflow(__builtin_sub_overflow(a, b, d)) 83 83 84 - /** check_mul_overflow() - Calculate multiplication with overflow checking 85 - * 84 + /** 85 + * check_mul_overflow() - Calculate multiplication with overflow checking 86 86 * @a: first factor 87 87 * @b: second factor 88 88 * @d: pointer to store product ··· 96 96 #define check_mul_overflow(a, b, d) \ 97 97 __must_check_overflow(__builtin_mul_overflow(a, b, d)) 98 98 99 - /** check_shl_overflow() - Calculate a left-shifted value and check overflow 100 - * 99 + /** 100 + * check_shl_overflow() - Calculate a left-shifted value and check overflow 101 101 * @a: Value to be shifted 102 102 * @s: How many bits left to shift 103 103 * @d: Pointer to where to store the result 104 104 * 105 105 * Computes *@d = (@a << @s) 106 106 * 107 - * Returns true if '*d' cannot hold the result or when 'a << s' doesn't 107 + * Returns true if '*@d' cannot hold the result or when '@a << @s' doesn't 108 108 * make sense. Example conditions: 109 - * - 'a << s' causes bits to be lost when stored in *d. 110 - * - 's' is garbage (e.g. negative) or so large that the result of 111 - * 'a << s' is guaranteed to be 0. 112 - * - 'a' is negative. 113 - * - 'a << s' sets the sign bit, if any, in '*d'. 114 109 * 115 - * '*d' will hold the results of the attempted shift, but is not 110 + * - '@a << @s' causes bits to be lost when stored in *@d. 111 + * - '@s' is garbage (e.g. negative) or so large that the result of 112 + * '@a << @s' is guaranteed to be 0. 113 + * - '@a' is negative. 114 + * - '@a << @s' sets the sign bit, if any, in '*@d'. 115 + * 116 + * '*@d' will hold the results of the attempted shift, but is not 116 117 * considered "safe for use" if true is returned. 117 118 */ 118 119 #define check_shl_overflow(a, s, d) __must_check_overflow(({ \ ··· 130 129 131 130 /** 132 131 * size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX 133 - * 134 132 * @factor1: first factor 135 133 * @factor2: second factor 136 134 * ··· 149 149 150 150 /** 151 151 * size_add() - Calculate size_t addition with saturation at SIZE_MAX 152 - * 153 152 * @addend1: first addend 154 153 * @addend2: second addend 155 154 * ··· 168 169 169 170 /** 170 171 * size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX 171 - * 172 172 * @minuend: value to subtract from 173 173 * @subtrahend: value to subtract from @minuend 174 174 * ··· 190 192 191 193 /** 192 194 * array_size() - Calculate size of 2-dimensional array. 193 - * 194 195 * @a: dimension one 195 196 * @b: dimension two 196 197 * ··· 202 205 203 206 /** 204 207 * array3_size() - Calculate size of 3-dimensional array. 205 - * 206 208 * @a: dimension one 207 209 * @b: dimension two 208 210 * @c: dimension three ··· 216 220 /** 217 221 * flex_array_size() - Calculate size of a flexible array member 218 222 * within an enclosing structure. 219 - * 220 223 * @p: Pointer to the structure. 221 224 * @member: Name of the flexible array member. 222 225 * @count: Number of elements in the array. ··· 232 237 233 238 /** 234 239 * struct_size() - Calculate size of structure with trailing flexible array. 235 - * 236 240 * @p: Pointer to the structure. 237 241 * @member: Name of the array member. 238 242 * @count: Number of elements in the array.