[Devel] [PATCH RHEL10 COMMIT] ms/selftests/mm: fix strncpy() length

Konstantin Khorenko khorenko at virtuozzo.com
Tue Mar 24 19:35:33 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-55.52.1.5.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.52.1.5.11.vz10
------>
commit 0b2ca0b185d219d5d5c9fae941d7dda733100177
Author: Kevin Brodsky <kevin.brodsky at arm.com>
Date:   Mon Mar 23 18:07:32 2026 +0100

    ms/selftests/mm: fix strncpy() length
    
    GCC complains (with -O2) that the length is equal to the destination size,
    which is indeed invalid.  Subtract 1 from the size of the array to leave
    room for '\0'.
    
    Link: https://lkml.kernel.org/r/20241209095019.1732120-4-kevin.brodsky@arm.com
    Signed-off-by: Kevin Brodsky <kevin.brodsky at arm.com>
    Cc: Aruna Ramakrishna <aruna.ramakrishna at oracle.com>
    Cc: Catalin Marinas <catalin.marinas at arm.com>
    Cc: Dave Hansen <dave.hansen at linux.intel.com>
    Cc: Joey Gouly <joey.gouly at arm.com>
    Cc: Keith Lucas <keith.lucas at oracle.com>
    Cc: Ryan Roberts <ryan.roberts at arm.com>
    Cc: Shuah Khan <shuah at kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    
    (cherry picked from commit 5b6b2799f617b3259d551980fa94f290d96bc593)
    Applied cleanly.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-127529
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
    
    Feature: fix selftests
---
 tools/testing/selftests/mm/write_to_hugetlbfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/write_to_hugetlbfs.c b/tools/testing/selftests/mm/write_to_hugetlbfs.c
index 1289d311efd70..34c91f7e6128a 100644
--- a/tools/testing/selftests/mm/write_to_hugetlbfs.c
+++ b/tools/testing/selftests/mm/write_to_hugetlbfs.c
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
 			size = atoi(optarg);
 			break;
 		case 'p':
-			strncpy(path, optarg, sizeof(path));
+			strncpy(path, optarg, sizeof(path) - 1);
 			break;
 		case 'm':
 			if (atoi(optarg) >= MAX_METHOD) {


More information about the Devel mailing list