Re: [PATCH v2 1/2] landlock: Extend documentation for kernel support

2024-03-18 Thread Alejandro Colomar
+[0.00] landlock: Up and running. > > > + > > > +Note that according to the built time kernel configuration, > > > > s/built time/build time/ > > ^ > > OK Here, this should actually be "build-time" since

Re: [PATCH v2 1/2] landlock: Extend documentation for kernel support

2024-03-19 Thread Alejandro Colomar
Hi Mickaël! On Tue, Mar 19, 2024 at 11:46:34AM +0100, Mickaël Salaün wrote: > On Mon, Mar 18, 2024 at 10:50:42AM +0100, Alejandro Colomar wrote: > > Hi Mickaël, Günther, > > > > Sorry for the delay! > > > > On Thu, Mar 07, 2024 at 11:21:57AM +0100, Mickaël Sa

Re: [PATCH v2] EISA: Increase length of device names

2025-04-07 Thread Alejandro Colomar
of "cmd" > to detect changes to the command line used to generate the target, > otherwise devlist.h won't be rebuilt. > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] > Signed-off-by: Kees Cook > --- > Cc: Alejandro Colomar Acked-by: Alejandro C

Re: [PATCH] EISA: Increase length of device names

2025-03-15 Thread Alejandro Colomar
; Cc: Greg Kroah-Hartman > > Cc: Azeem Shaikh > > Cc: Alex Elder > > This was interesting, but based on the bug text I suspect you > meant to address this to Alejandro Colomar, . Thanks! > For what it's worth, it looks fine to me. LGTM too. Assuming that changing

Re: [RFC v1 0/3] Add and use seprintf() instead of less ergonomic APIs

2025-07-08 Thread Alejandro Colomar
Hi Rasmus, On Tue, Jul 08, 2025 at 08:43:57AM +0200, Rasmus Villemoes wrote: > On Sat, Jul 05 2025, Alejandro Colomar wrote: > > > On top of that, I have a question about the functions I'm adding, > > and the existing kernel snprintf(3): The standard snprintf(3) > &

[RFC v2 3/5] mm: Use seprintf() instead of less ergonomic APIs

2025-07-06 Thread Alejandro Colomar
x27; anti-pattern. This is UB, and by using seprintf() we've fixed the bug. Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 24 mm/kmsan/kmsan_test.c | 4 ++-- mm/mempolicy.c | 18 +-

[RFC v2 1/5] vsprintf: Add [v]seprintf(), [v]stprintf()

2025-07-06 Thread Alejandro Colomar
t;=countof(buf), but rather <0). Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 4 ++ lib/vsprintf.c | 109 2 files changed, 113 insertions(+) diff --git a/include/linux/sprintf.h

[RFC v2 2/5] stacktrace, stackdepot: Add seprintf()-like variants of functions

2025-07-06 Thread Alejandro Colomar
be we should make sure to write a '\0' here? Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28 lib/stackdepot.c

[RFC v2 0/5] Add and use seprintf() instead of less ergonomic APIs

2025-07-06 Thread Alejandro Colomar
l send it as is for discussion. When we agree on the specific questions on the code I made in v1, I'll turn it into coding- style compliant. Have a lovely Sun day! Alex Alejandro Colomar (5): vsprintf: Add [v]seprintf(), [v]stprintf() stacktrace, stackdepot: Add seprintf()-like varia

[RFC v2 4/5] array_size.h: Add ENDOF()

2025-07-06 Thread Alejandro Colomar
This macro is useful to calculate the second argument to seprintf(), avoiding off-by-one bugs. Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/array_size.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/array_size.h b/include

[RFC v2 5/5] mm: Fix benign off-by-one bugs

2025-07-06 Thread Alejandro Colomar
7;end' --that is, at most the terminating null byte will be written at 'end-1'--. Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 4 ++-- mm/kmsan/kmsan_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --g

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Marco, On Mon, Jul 07, 2025 at 09:44:09AM +0200, Marco Elver wrote: > On Mon, 7 Jul 2025 at 07:06, Alejandro Colomar wrote: > > > > While doing this, I detected some anomalies in the existing code: > > > > mm/kfence/kfence_test.c: > > > > - The

Re: [RFC v3 5/7] mm: Fix benign off-by-one bugs

2025-07-07 Thread Alejandro Colomar
Hi Michal, On Mon, Jul 07, 2025 at 09:53:31AM +0200, Michal Hocko wrote: > On Mon 07-07-25 09:46:12, Marco Elver wrote: > > On Mon, 7 Jul 2025 at 07:06, Alejandro Colomar wrote: > > > > > > We were wasting a byte due to an off-by-one bug. s[c]nprintf() > > &

Re: [RFC v1 1/3] vsprintf: Add [v]seprintf(), [v]stprintf()

2025-07-07 Thread Alejandro Colomar
Hi Alexander, On Mon, Jul 07, 2025 at 11:47:43AM +0200, Alexander Potapenko wrote: > > +/** > > + * vseprintf - Format a string and place it in a buffer > > + * @p: The buffer to place the result into > > + * @end: A pointer to one past the last character in the buffer > > + * @fmt: The format str

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Marco, On Mon, Jul 07, 2025 at 04:58:53PM +0200, Marco Elver wrote: > Feel free to make it warning-free, I guess that's useful. Thanks! > > > Did you run the tests? Do they pass? > > > > I don't know how to run them. I've only built the kernel. If you point > > me to instructions on how to

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
On Mon, Jul 07, 2025 at 11:06:06PM +0200, Alejandro Colomar wrote: > > I stand by my "let's not add random letters to existing functions that > > are already too confusing". If the name is your main concern, we can discuss a more explicit name in the kernel. I

Re: [RFC v3 5/7] mm: Fix benign off-by-one bugs

2025-07-07 Thread Alejandro Colomar
Hi Michal, On Mon, Jul 07, 2025 at 05:12:00PM +0200, Michal Hocko wrote: > > For the dead code, I can remove the fixes tags, and even the changes > > themselves, since there are good reasons to keep the dead code > > (consistency, and avoiding a future programmer forgetting to add it back > > when

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Linus, On Mon, Jul 07, 2025 at 12:17:11PM -0700, Linus Torvalds wrote: > On Sun, 6 Jul 2025 at 22:06, Alejandro Colomar wrote: > > > > - p += snprintf(p, ID_STR_LENGTH - (p - name), "%07u", s->size); > > + p = seprintf(p, e, "%07u"

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Marco, On Mon, Jul 07, 2025 at 09:08:29PM +0200, Marco Elver wrote: > > > > > Did you run the tests? Do they pass? > > > > > > > > I don't know how to run them. I've only built the kernel. If you point > > > > me to instructions on how to run them, I'll do so. Thanks! > > > > > > Should just

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Linus, On Mon, Jul 07, 2025 at 01:49:20PM -0700, Linus Torvalds wrote: > On Mon, 7 Jul 2025 at 13:29, Alejandro Colomar wrote: > > > > I am in the C Committee, and have proposed this API for standardization. > > I have a feeling that the committee might be open to it. >

[RFC v3 7/7] mm: Use [V]STPRINTF() to avoid specifying the array size

2025-07-06 Thread Alejandro Colomar
Signed-off-by: Alejandro Colomar --- mm/backing-dev.c| 2 +- mm/cma.c| 4 ++-- mm/cma_debug.c | 2 +- mm/hugetlb.c| 3 +-- mm/hugetlb_cgroup.c | 2 +- mm/hugetlb_cma.c| 2 +- mm/kasan/report.c | 3 +-- mm/memblock.c | 4 ++-- mm/percpu.c | 2

[RFC v3 0/7] Add and use seprintf() instead of less ergonomic APIs

2025-07-06 Thread Alejandro Colomar
age in a moment, as I believe it will be interesting for linux-hardening@. Have a lovely night! Alex Alejandro Colomar (7): vsprintf: Add [v]seprintf(), [v]stprintf() stacktrace, stackdepot: Add seprintf()-like variants of functions mm: Use seprintf() instead of less ergonomic APIs array_size

[RFC v3 1/7] vsprintf: Add [v]seprintf(), [v]stprintf()

2025-07-06 Thread Alejandro Colomar
t;=countof(buf), but rather <0). Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 4 ++ lib/vsprintf.c | 109 2 files changed, 113 insertions(+) diff --git a/include/linux/sprintf.h

[RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-06 Thread Alejandro Colomar
ot;) [alx: that commit changed p+=sprintf() into p+=snprintf(), which is still UB] Cc: Kees Cook Cc: Christopher Bazley Cc: Sven Schnelle Cc: Marco Elver Cc: Heiko Carstens Cc: Tvrtko Ursulin Cc: "Huang, Ying" Cc: Andrew Morton Cc: Lee Schermerhorn Cc: Lin

[RFC v3 2/7] stacktrace, stackdepot: Add seprintf()-like variants of functions

2025-07-06 Thread Alejandro Colomar
be we should make sure to write a '\0' here? Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28 lib/stackdepot.c

[RFC v3 5/7] mm: Fix benign off-by-one bugs

2025-07-06 Thread Alejandro Colomar
Potapenko Cc: Marco Elver Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Jann Horn Cc: Andrew Morton Cc: Linus Torvalds Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 4 ++-- mm/kmsan/kmsan_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kfenc

[RFC v3 6/7] sprintf: Add [V]STPRINTF()

2025-07-06 Thread Alejandro Colomar
-argument version of strscpy(), but with a formatted string. Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 4 1 file changed, 4 insertions(+) diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h index c3dbfd2efd2b..6080d3732055 100644 --- a/include/linux/sprintf.h

[RFC v3 4/7] array_size.h: Add ENDOF()

2025-07-06 Thread Alejandro Colomar
This macro is useful to calculate the second argument to seprintf(), avoiding off-by-one bugs. Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/array_size.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/array_size.h b/include

Re: [RFC v3 0/7] Add and use seprintf() instead of less ergonomic APIs

2025-07-06 Thread Alejandro Colomar
On Mon, Jul 07, 2025 at 07:06:06AM +0200, Alejandro Colomar wrote: > I've written an analysis of snprintf(3), why it's dangerous, and how > these APIs address that, and will present it as a proposal for > standardization of these APIs in ISO C2y. I'll send that as a repl

Re: [RFC v3 3/7] mm: Use seprintf() instead of less ergonomic APIs

2025-07-07 Thread Alejandro Colomar
Hi Linus, On Mon, Jul 07, 2025 at 03:17:50PM -0700, Linus Torvalds wrote: > On Mon, 7 Jul 2025 at 14:27, Alejandro Colomar wrote: > > > > If the name is your main concern, we can discuss a more explicit name in > > the kernel. > > So as they say: "There are on

Re: [RFC v1 0/3] Add and use seprintf() instead of less ergonomic APIs

2025-07-08 Thread Alejandro Colomar
Hi Rasmus, On Tue, Jul 08, 2025 at 03:51:10PM +0200, Rasmus Villemoes wrote: > > However, there's the early return due to size>INT_MAX || size==0, > > which > > First of all, there's no early return for size==0, that's absolutely > supported and the standard way for the caller to figure out how m

[RFC v4 0/7] Add and use sprintf_end() instead of less ergonomic APIs

2025-07-09 Thread Alejandro Colomar
ttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=108036> It would be interesting to ask GCC to fix that bug. (Added relevant GCC maintainers and contributors to CC in this cover letter.) Have a lovely night! Alex Alejandro Colomar (7): vsprintf: Add [v]sprintf_end() stacktrace, stackde

alx-0049r2 - add seprintf()

2025-07-09 Thread Alejandro Colomar
rdize existing libc APIs Author Alejandro Colomar Cc: Christopher Bazley History <https://www.alejandro-colomar.es/src/alx/alx/wg14/alx-0049.git/> r0 (2025-07-06): - Initial draft. r1 (2025-07-06): - wfix. - tfix. -

[RFC v4 1/7] vsprintf: Add [v]sprintf_end()

2025-07-09 Thread Alejandro Colomar
: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 2 ++ lib/vsprintf.c | 59 + 2 files changed, 61 insertions(+) diff --git a/include/linux/spr

[RFC v4 2/7] stacktrace, stackdepot: Add sprintf_end()-like variants of functions

2025-07-09 Thread Alejandro Colomar
Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28

[RFC v4 3/7] mm: Use sprintf_end() instead of less ergonomic APIs

2025-07-09 Thread Alejandro Colomar
yeonggon Yoo <42.hye...@gmail.com> Cc: Chao Yu Cc: Vlastimil Babka Cc: Rasmus Villemoes Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 24 mm/kmsan/kmsan_test.c | 4 ++-- mm/mempolicy.c | 18 +--

[RFC v4 7/7] mm: Use [V]SPRINTF_END() to avoid specifying the array size

2025-07-09 Thread Alejandro Colomar
Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/backing-dev.c| 2 +- mm/cma.c| 4 ++-- mm/cma_debug.c | 2 +- mm/hugetlb.c| 3 +-- mm/hugetlb_cgroup.c | 2 +- mm/hugetlb_cma.c| 2

[RFC v4 6/7] sprintf: Add [V]SPRINTF_END()

2025-07-09 Thread Alejandro Colomar
as the 2-argument version of strscpy(), but with a formatted string, and returning a pointer to the terminating '\0' (or NULL, on error). Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/spr

[RFC v4 5/7] mm: Fix benign off-by-one bugs

2025-07-09 Thread Alejandro Colomar
emoes Cc: Marco Elver Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 4 ++-- mm/kmsan/kmsan_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index bae382eca4ab..c635aa9d4

[RFC v4 4/7] array_size.h: Add ENDOF()

2025-07-09 Thread Alejandro Colomar
This macro is useful to calculate the second argument to sprintf_end(), avoiding off-by-one bugs. Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/array_size.h | 6

[RFC v5 0/7] Add and use sprintf_{end,array}() instead of less ergonomic APIs

2025-07-10 Thread Alejandro Colomar
the thread, sprintf_end() will be proposed for standardization soon as seprintf(): <https://lore.kernel.org/linux-hardening/20250710024745.143955-1-...@kernel.org/T/#u> Have a lovely night! Alex Alejandro Colomar (7): vsprintf: Add [v]sprintf_end() stacktrace, stackdepot: Add sprintf_end()

[RFC v5 1/7] vsprintf: Add [v]sprintf_end()

2025-07-10 Thread Alejandro Colomar
: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 2 ++ lib/vsprintf.c | 59 + 2 files changed, 61 insertions(+) diff --git a/include/linux/spr

[RFC v5 7/7] mm: Use [v]sprintf_array() to avoid specifying the array size

2025-07-10 Thread Alejandro Colomar
Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/backing-dev.c| 2 +- mm/cma.c| 4 ++-- mm/cma_debug.c | 2 +- mm/hugetlb.c| 3 +-- mm/hugetlb_cgroup.c | 2 +- mm/hugetlb_cma.c| 2

[RFC v5 5/7] mm: Fix benign off-by-one bugs

2025-07-10 Thread Alejandro Colomar
s Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 4 ++-- mm/kmsan/kmsan_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index bae382eca

[RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-10 Thread Alejandro Colomar
as the 2-argument version of strscpy(), but with a formatted string, and returning a pointer to the terminating '\0' (or NULL, on error). Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/spr

[RFC v5 3/7] mm: Use sprintf_end() instead of less ergonomic APIs

2025-07-10 Thread Alejandro Colomar
yeonggon Yoo <42.hye...@gmail.com> Cc: Chao Yu Cc: Vlastimil Babka Cc: Rasmus Villemoes Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 24 mm/kmsan/kmsan_test.c | 4 ++-- mm/mempolicy.c | 18 +--

[RFC v5 2/7] stacktrace, stackdepot: Add sprintf_end()-like variants of functions

2025-07-10 Thread Alejandro Colomar
Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28

[RFC v5 4/7] array_size.h: Add ENDOF()

2025-07-10 Thread Alejandro Colomar
This macro is useful to calculate the second argument to sprintf_end(), avoiding off-by-one bugs. Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/array_size.h | 6

Re: [RFC v4 6/7] sprintf: Add [V]SPRINTF_END()

2025-07-10 Thread Alejandro Colomar
Hi Linus, On Thu, Jul 10, 2025 at 08:52:13AM -0700, Linus Torvalds wrote: > On Wed, 9 Jul 2025 at 19:49, Alejandro Colomar wrote: > > > > +#define SPRINTF_END(a, fmt, ...) sprintf_end(a, ENDOF(a), fmt, > > ##__VA_ARGS__) > > +#define VSPRINTF_END(a, fmt, ap) vsprin

[RFC v6 0/8] Add and use sprintf_{end,trunc,array}() instead of less ergonomic APIs

2025-07-10 Thread Alejandro Colomar
on soon as seprintf(): <https://lore.kernel.org/linux-hardening/20250710024745.143955-1-...@kernel.org/T/#u> Have a lovely night! Alex Alejandro Colomar (8): vsprintf: Add [v]sprintf_trunc() vsprintf: Add [v]sprintf_end() sprintf: Add [v]sprintf_array() stacktrace, stackdepot: Add sprintf_e

Re: [RFC v4 6/7] sprintf: Add [V]SPRINTF_END()

2025-07-10 Thread Alejandro Colomar
Hi Linus, On Thu, Jul 10, 2025 at 08:30:59PM +0200, Alejandro Colomar wrote: > > IOW, why isn't this just > > > > #define sprintf_array(a,...) snprintf(a, ARRAY_SIZE(a), __VA_ARGS__) > > Agree. This is a better name for the kernel. Oops, I misread. I though

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-10 Thread Alejandro Colomar
Hi Linus, [I'll reply to both of your emails at once] On Thu, Jul 10, 2025 at 02:58:24PM -0700, Linus Torvalds wrote: > You took my suggestion, and then you messed it up. > > Your version of sprintf_array() is broken. It evaluates 'a' twice. > Because unlike ARRAY_SIZE(), your broken ENDOF() mac

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-10 Thread Alejandro Colomar
On Fri, Jul 11, 2025 at 01:23:56AM +0200, Alejandro Colomar wrote: > Hi Linus, > > [I'll reply to both of your emails at once] > > On Thu, Jul 10, 2025 at 02:58:24PM -0700, Linus Torvalds wrote: > > You took my suggestion, and then you messed it up. > > > &

[RFC v6 2/8] vsprintf: Add [v]sprintf_end()

2025-07-10 Thread Alejandro Colomar
: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 2 ++ lib/vsprintf.c | 54 + 2 files changed, 56 insertions(+) diff --git a/include/linux/spr

[RFC v6 4/8] stacktrace, stackdepot: Add sprintf_end()-like variants of functions

2025-07-10 Thread Alejandro Colomar
Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28

[RFC v6 1/8] vsprintf: Add [v]sprintf_trunc()

2025-07-10 Thread Alejandro Colomar
Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 2 ++ lib/vsprintf.c | 53 + 2 files changed, 55 insertions(+) diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h index 51cab2def9ec..5ea6ec9c2e59 100644

[RFC v6 3/8] sprintf: Add [v]sprintf_array()

2025-07-10 Thread Alejandro Colomar
as the 2-argument version of strscpy(), but with a formatted string. Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/sprintf.h | 4 1 file changed, 4 insertions(+) diff --git a/include/linux

[RFC v6 6/8] array_size.h: Add ENDOF()

2025-07-10 Thread Alejandro Colomar
This macro is useful to calculate the second argument to sprintf_end(), avoiding off-by-one bugs. Cc: Kees Cook Cc: Christopher Bazley Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- include/linux/array_size.h | 6

[RFC v6 5/8] mm: Use sprintf_end() instead of less ergonomic APIs

2025-07-10 Thread Alejandro Colomar
yeonggon Yoo <42.hye...@gmail.com> Cc: Chao Yu Cc: Vlastimil Babka Cc: Rasmus Villemoes Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 24 mm/kmsan/kmsan_test.c | 4 ++-- mm/mempolicy.c | 18 +--

[RFC v6 8/8] mm: Use [v]sprintf_array() to avoid specifying the array size

2025-07-10 Thread Alejandro Colomar
Cc: Rasmus Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Linus Torvalds Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/backing-dev.c| 2 +- mm/cma.c| 4 ++-- mm/cma_debug.c | 2 +- mm/hugetlb.c| 3 +-- mm/hugetlb_cgroup.c | 2 +- mm/hugetlb_cma.c| 2

[RFC v6 7/8] mm: Fix benign off-by-one bugs

2025-07-10 Thread Alejandro Colomar
s Villemoes Cc: Marco Elver Cc: Michal Hocko Cc: Al Viro Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 4 ++-- mm/kmsan/kmsan_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index bae382eca

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-10 Thread Alejandro Colomar
On Fri, Jul 11, 2025 at 01:23:56AM +0200, Alejandro Colomar wrote: > Hi Linus, > > [I'll reply to both of your emails at once] > > On Thu, Jul 10, 2025 at 02:58:24PM -0700, Linus Torvalds wrote: > > You took my suggestion, and then you messed it up. > > > &

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-11 Thread Alejandro Colomar
Hi David, On Fri, Jul 11, 2025 at 06:43:43PM +0100, David Laight wrote: > On Fri, 11 Jul 2025 01:23:49 +0200 > Alejandro Colomar wrote: > > > Hi Linus, > > > > [I'll reply to both of your emails at once] > > > > On Thu, Jul 10, 2025 at 02:58:24PM -0

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-11 Thread Alejandro Colomar
On Fri, Jul 11, 2025 at 09:17:28PM +0200, Alejandro Colomar wrote: > Hi David, > > On Fri, Jul 11, 2025 at 06:43:43PM +0100, David Laight wrote: > > On Fri, 11 Jul 2025 01:23:49 +0200 > > Alejandro Colomar wrote: > > > > > Hi Linus, > > > >

[RFC v1 1/3] vsprintf: Add [v]seprintf(), [v]stprintf()

2025-07-05 Thread Alejandro Colomar
t;=countof(buf), but rather <0). Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- lib/vsprintf.c | 109 + 1 file changed, 109 insertions(+) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 01699852f30c..a3efa

[RFC v1 2/3] stacktrace, stackdepot: Add seprintf()-like variants of functions

2025-07-05 Thread Alejandro Colomar
be we should make sure to write a '\0' here? Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- include/linux/stackdepot.h | 13 + include/linux/stacktrace.h | 3 +++ kernel/stacktrace.c| 28 lib/stackdepot.c

[RFC v1 0/3] Add and use seprintf() instead of less ergonomic APIs

2025-07-05 Thread Alejandro Colomar
code of the implementation asking for that.) What do you think? Alejandro Colomar (3): vsprintf: Add [v]seprintf(), [v]stprintf() stacktrace, stackdepot: Add seprintf()-like variants of functions mm: Use seprintf() instead of less ergonomic APIs include/linux/stackdepot.h | 13 + in

[RFC v1 3/3] mm: Use seprintf() instead of less ergonomic APIs

2025-07-05 Thread Alejandro Colomar
e fixed the bug. Cc: Kees Cook Cc: Christopher Bazley Signed-off-by: Alejandro Colomar --- mm/kfence/kfence_test.c | 24 mm/kmsan/kmsan_test.c | 4 ++-- mm/mempolicy.c | 18 +- mm/page_owner.c | 32 +--- mm/

Re: [RFC v1 1/3] vsprintf: Add [v]seprintf(), [v]stprintf()

2025-07-05 Thread Alejandro Colomar
On Sat, Jul 05, 2025 at 10:33:49PM +0200, Alejandro Colomar wrote: > seprintf() > == > > seprintf() is a function similar to stpcpy(3) in the sense that it > returns a pointer that is suitable for chaining to other copy > operations. > > It takes a pointer to th

Re: [RFC v1 3/3] mm: Use seprintf() instead of less ergonomic APIs

2025-07-05 Thread Alejandro Colomar
On Sat, Jul 05, 2025 at 10:33:53PM +0200, Alejandro Colomar wrote: > While doing this, I detected some anomalies in the existing code: > > mm/kfence/kfence_test.c: > > The last call to scnprintf() did increment 'cur', but it's > unused after that, s

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-15 Thread Alejandro Colomar
Hi Kees, On Mon, Jul 14, 2025 at 10:19:39PM -0700, Kees Cook wrote: > On Fri, Jul 11, 2025 at 10:58:56AM -0700, Linus Torvalds wrote: > > struct seq_buf s; > > seq_buf_init(&s, buf, szie); > > And because some folks didn't like this "declaration that requires a > function call", w

Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array()

2025-07-17 Thread Alejandro Colomar
Hi Kees, On Thu, Jul 17, 2025 at 04:47:04PM -0700, Kees Cook wrote: > On Tue, Jul 15, 2025 at 09:08:14AM +0200, Alejandro Colomar wrote: > > Hi Kees, > > > > On Mon, Jul 14, 2025 at 10:19:39PM -0700, Kees Cook wrote: > > > On Fri, Jul 11, 2025 at 10:58:56