From 1ee02c9c7954b4239ba4394af085047c0df34a6d Mon Sep 17 00:00:00 2001 From: zhangyaqi Date: Mon, 29 Sep 2025 10:26:36 +0800 Subject: [PATCH] backport two patches from upstream --- 0012-nfsidmap-Fix-a-memory-leak.patch | 29 ++++++++++ ...-rpcdebug-fix-memory-allocation-size.patch | 55 +++++++++++++++++++ nfs-utils.spec | 7 ++- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 0012-nfsidmap-Fix-a-memory-leak.patch create mode 100644 0013-rpcdebug-fix-memory-allocation-size.patch diff --git a/0012-nfsidmap-Fix-a-memory-leak.patch b/0012-nfsidmap-Fix-a-memory-leak.patch new file mode 100644 index 0000000..a6a0af2 --- /dev/null +++ b/0012-nfsidmap-Fix-a-memory-leak.patch @@ -0,0 +1,29 @@ +From 131ec613bab84b7894e428375cc360bb82a336a3 Mon Sep 17 00:00:00 2001 +From: Steve Dickson +Date: Tue, 23 Jul 2024 12:06:28 -0400 +Subject: [PATCH] nfsidmap: Fix a memory leak + +Reported-by: Zhang Yaqi +Signed-off-by: Steve Dickson + +Reference:https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=patch;h=131ec613bab84b7894e428375cc360bb82a336a3 + +--- + support/nfsidmap/umich_ldap.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/support/nfsidmap/umich_ldap.c b/support/nfsidmap/umich_ldap.c +index 1aa2af4..0f88ba4 100644 +--- a/support/nfsidmap/umich_ldap.c ++++ b/support/nfsidmap/umich_ldap.c +@@ -200,6 +200,7 @@ static int set_krb5_ccname(const char *krb5_ccache_name) + IDMAP_LOG(5, ("Failed to set creds cache for kerberos, err(%d)", + retval)); + } ++ free(env); + #endif /* else HAVE_GSS_KRB5_CCACHE_NAME */ + out: + return retval; +-- +2.27.0 + diff --git a/0013-rpcdebug-fix-memory-allocation-size.patch b/0013-rpcdebug-fix-memory-allocation-size.patch new file mode 100644 index 0000000..ccd8a42 --- /dev/null +++ b/0013-rpcdebug-fix-memory-allocation-size.patch @@ -0,0 +1,55 @@ +From bdf9a974fce8b12da6d65b47841b3ced2da4868d Mon Sep 17 00:00:00 2001 +From: Olga Kornievskaia +Date: Fri, 16 Aug 2024 09:46:33 -0400 +Subject: [PATCH] rpcdebug: fix memory allocation size + +Memory isn't allocated enough to hold the null terminator. + +Valgring complains about invalid memory access: + +[aglo@localhost rpcdebug]$ valgrind ./rpcdebug +==222602== Memcheck, a memory error detector +==222602== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al. +==222602== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info +==222602== Command: ./rpcdebug +==222602== +==222602== Invalid write of size 1 +==222602== at 0x4871218: strcpy (vg_replace_strmem.c:564) +==222602== by 0x400CA3: main (rpcdebug.c:62) +==222602== Address 0x4a89048 is 0 bytes after a block of size 8 alloc'd +==222602== at 0x4868388: malloc (vg_replace_malloc.c:446) +==222602== by 0x400C77: main (rpcdebug.c:57) +==222602== +==222602== Invalid read of size 1 +==222602== at 0x48710E4: __GI_strlen (vg_replace_strmem.c:506) +==222602== by 0x492FA7F: __vfprintf_internal (vfprintf-internal.c:1647) +==222602== by 0x49302F3: buffered_vfprintf (vfprintf-internal.c:2296) +==222602== by 0x492F21F: __vfprintf_internal (vfprintf-internal.c:1377) +==222602== by 0x491BC93: fprintf (fprintf.c:32) +==222602== by 0x40103F: main (rpcdebug.c:100) +==222602== Address 0x4a89048 is 0 bytes after a block of size 8 alloc'd +==222602== at 0x4868388: malloc (vg_replace_malloc.c:446) + +Signed-off-by: Olga Kornievskaia +Signed-off-by: Steve Dickson +Reference:https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=patch;h=bdf9a974fce8b12da6d65b47841b3ced2da4868d +--- + tools/rpcdebug/rpcdebug.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/rpcdebug/rpcdebug.c b/tools/rpcdebug/rpcdebug.c +index ec05179..1f93522 100644 +--- a/tools/rpcdebug/rpcdebug.c ++++ b/tools/rpcdebug/rpcdebug.c +@@ -54,7 +54,7 @@ main(int argc, char **argv) + char * module = NULL; + int c; + +- cdename = malloc(strlen(basename(argv[0]))); ++ cdename = malloc(strlen(basename(argv[0])) + 1); + if (cdename == NULL) { + fprintf(stderr, "failed in malloc\n"); + exit(1); +-- +2.27.0 + diff --git a/nfs-utils.spec b/nfs-utils.spec index d024c57..5ff9539 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -4,7 +4,7 @@ Name: nfs-utils Version: 2.6.3 -Release: 4 +Release: 5 Epoch: 2 Summary: The Linux NFS userland utility package License: MIT and GPLv2 and GPLv2+ and BSD @@ -24,6 +24,8 @@ Patch8: 0008-fixed-a-regression-in-the-junction-code.patch Patch9: 0009-libnfsidmap-try-to-get-the-domain-directly-from-host.patch Patch10: 0010-nfsdcld-fix-a-memory-leak.patch Patch11: 0011-gssd-fix-the-possible-buffer-overflow-in-get_full_hostname.patch +Patch12: 0012-nfsidmap-Fix-a-memory-leak.patch +Patch13: 0013-rpcdebug-fix-memory-allocation-size.patch BuildRequires: libevent-devel,libcap-devel, libtirpc-devel libblkid-devel BuildRequires: krb5-libs >= 1.4 autoconf >= 2.57 openldap-devel >= 2.2 @@ -296,6 +298,9 @@ fi %{_mandir}/*/* %changelog +* Mon Sep 29 2025 zhangyaqi - 2:2.6.3-5 +- backport two patches from upstream + * Tue Aug 26 2025 zhangjian - 2:2.6.3-4 - backport two patches from upstream -- Gitee