Re: [PATCH v3 1/2] x86: Add strlcat() to compressed kernel

From: baskov
Date: Wed May 25 2022 - 01:18:35 EST


Sorry for delayed reply.

On 2022-05-12 14:10, Borislav Petkov wrote:
On Thu, May 05, 2022 at 01:32:23PM +0300, Baskov Evgeniy wrote:
Subject: Re: [PATCH v3 1/2] x86: Add strlcat() to compressed kernel

The tip tree preferred format for patch subject prefixes is
'subsys/component:', e.g. 'x86/apic:', 'x86/mm/fault:', 'sched/fair:',
'genirq/core:'. Please do not use file names or complete file paths as
prefix. 'git log path/to/file' should give you a reasonable hint in most
cases.

The condensed patch description in the subject line should start with a
uppercase letter and should be written in imperative tone.

In your case, that would be x86/boot: Add...

Thank you, I'll fix that in v4.


You can add the BUG_ON() check from the kernel proper version like this:

diff --git a/arch/x86/boot/compressed/string.c
b/arch/x86/boot/compressed/string.c
index b0635539b6f6..643fcd957527 100644
--- a/arch/x86/boot/compressed/string.c
+++ b/arch/x86/boot/compressed/string.c
@@ -46,6 +46,10 @@ size_t strlcat(char *dest, const char *src, size_t count)
size_t len = strlen(src);
size_t res = dsize + len;

+ /* This would be a bug */
+ if (dsize >= count)
+ error("strlcat(): destination too big\n");
+
dest += dsize;
count -= dsize;
if (len >= count)
diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c
index 7558139920f8..65f0cedb65ae 100644
--- a/arch/x86/purgatory/purgatory.c
+++ b/arch/x86/purgatory/purgatory.c
@@ -57,3 +57,4 @@ void purgatory(void)
* arch/x86/boot/compressed/string.c
*/
void warn(const char *msg) {}
+void error(char *m) {}

Ok, will do.