Linux Hardening
 help / color / mirror / Atom feed
From: 15074444048@163.com
To: linux-hardening@vger.kernel.org, kees@kernel.org
Cc: 15074444048@163.com, lihaojie <lihaojie@kylinos.cn>
Subject: [PATCH] fortify: Use __struct_size replace __member_size
Date: Wed,  4 Dec 2024 14:41:49 +0800	[thread overview]
Message-ID: <20241204064149.218136-1-15074444048@163.com> (raw)

From: lihaojie <lihaojie@kylinos.cn>

Use __struct_size get destination size.

Size of destination less of the size to be written will
make buffer overflow, the size of destination should be
complete.

Signed-off-by: lihaojie <lihaojie@kylinos.cn>
---
 include/linux/fortify-string.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h
index 0d99bf11d260..0504b2c8aab7 100644
--- a/include/linux/fortify-string.h
+++ b/include/linux/fortify-string.h
@@ -277,7 +277,7 @@ extern ssize_t __real_strscpy(char *, const char *, size_t) __RENAME(sized_strsc
 __FORTIFY_INLINE ssize_t sized_strscpy(char * const POS p, const char * const POS q, size_t size)
 {
 	/* Use string size rather than possible enclosing struct size. */
-	const size_t p_size = __member_size(p);
+	const size_t p_size = __struct_size(p);
 	const size_t q_size = __member_size(q);
 	size_t len;
 
-- 
2.25.1


             reply	other threads:[~2024-12-04  6:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04  6:41 15074444048 [this message]
2024-12-04  8:18 ` [PATCH] fortify: Use __struct_size replace __member_size Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241204064149.218136-1-15074444048@163.com \
    --to=15074444048@163.com \
    --cc=kees@kernel.org \
    --cc=lihaojie@kylinos.cn \
    --cc=linux-hardening@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox