diff --git a/6000-lib-talloc-Fix-undefined-behavior-in-talloc_memdup.patch b/6000-lib-talloc-Fix-undefined-behavior-in-talloc_memdup.patch new file mode 100644 index 0000000000000000000000000000000000000000..dab574c9ef4842aa3cdea565f1b668dcaad3433b --- /dev/null +++ b/6000-lib-talloc-Fix-undefined-behavior-in-talloc_memdup.patch @@ -0,0 +1,39 @@ +From eabe6d534c5c8c6ca38f3dc846f17aad6395da8c Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Thu, 22 Nov 2018 16:10:39 +0100 +Subject: [PATCH 09/28] lib:talloc: Fix undefined behavior in talloc_memdup + +lib/talloc/talloc.c:2419: runtime error: null pointer passed as argument +2, which is declared to never be null + +Signed-off-by: Andreas Schneider +Reviewed-by: Volker Lendecke +Signed-off-by: root +--- + talloc.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/talloc.c b/talloc.c +index 54be63495ae..073a3e50d4b 100644 +--- a/talloc.c ++++ b/talloc.c +@@ -2413,9 +2413,14 @@ _PUBLIC_ void *_talloc_zero(const void *ctx, size_t size, const char *name) + */ + _PUBLIC_ void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name) + { +- void *newp = _talloc_named_const(t, size, name); ++ void *newp = NULL; + +- if (likely(newp)) { ++ if (likely(size > 0) && unlikely(p == NULL)) { ++ return NULL; ++ } ++ ++ newp = _talloc_named_const(t, size, name); ++ if (likely(newp != NULL) && likely(size > 0)) { + memcpy(newp, p, size); + } + +-- +2.19.1 + diff --git a/6000-talloc-test-leak.patch b/6000-talloc-test-leak.patch deleted file mode 100644 index 0da674246be4aff17750045e0a05ac6ec3df8906..0000000000000000000000000000000000000000 --- a/6000-talloc-test-leak.patch +++ /dev/null @@ -1,222 +0,0 @@ -From 616646a0c4c5709ab334a11907642e710f912697 Mon Sep 17 00:00:00 2001 -From: Swen Schillig -Date: Thu, 15 Aug 2019 14:22:46 +0200 -Subject: [PATCH 1/5] talloc: ASAN fix for test_realloc_on_destructor_parent -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Direct leak of 96 byte(s) in 1 object(s) allocated from: - #0 0x7fd52c00dc08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08) - #1 0x7fd52befec45 in __talloc_with_prefix ../../talloc.c:782 - #2 0x7fd52befec45 in __talloc ../../talloc.c:824 - #3 0x7fd52befec45 in _talloc_named_const ../../talloc.c:981 - #4 0x7fd52befec45 in talloc_named_const ../../talloc.c:1748 - #5 0x4099bd in test_realloc_on_destructor_parent ../../testsuite.c:1000 - #6 0x4099bd in torture_local_talloc ../../testsuite.c:2129 - #7 0x402603 in main ../../testsuite_main.c:32 - #8 0x7fd52bcb8412 in __libc_start_main (/lib64/libc.so.6+0x24412) - -Signed-off-by: Swen Schillig -Reviewed-by: Andrew Bartlett -Reviewed-by: Matthias Dieter Wallnöfer ---- - testsuite.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/testsuite.c b/testsuite.c -index a76a64716c8f5378c96c606d12c4e9deb691d94a..9e340827e88e7779b24b65dffd0e2d8d4f9a46f0 100644 ---- a/testsuite.c -+++ b/testsuite.c -@@ -1035,6 +1035,8 @@ static bool test_realloc_on_destructor_parent(void) - - - printf("success: free_for_exit\n"); -+ talloc_free(top); /* make ASAN happy */ -+ - return true; - } - --- -2.23.0.rc2 - - -From 878e804df6377ffa120ae62b9abb182c957c10a6 Mon Sep 17 00:00:00 2001 -From: Swen Schillig -Date: Thu, 15 Aug 2019 14:33:32 +0200 -Subject: [PATCH 2/5] talloc: ASAN fix for test_talloc_free_in_destructor -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Indirect leak of 104 byte(s) in 1 object(s) allocated from: - #0 0x7f06393dfc08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08) - #1 0x7f06392d0c45 in __talloc_with_prefix ../../talloc.c:782 - #2 0x7f06392d0c45 in __talloc ../../talloc.c:824 - #3 0x7f06392d0c45 in _talloc_named_const ../../talloc.c:981 - #4 0x7f06392d0c45 in talloc_named_const ../../talloc.c:1748 - #5 0x409edd in test_talloc_free_in_destructor ../../testsuite.c:1256 - #6 0x409edd in torture_local_talloc ../../testsuite.c:2138 - #7 0x402603 in main ../../testsuite_main.c:32 - #8 0x7f063908a412 in __libc_start_main (/lib64/libc.so.6+0x24412) - -Signed-off-by: Swen Schillig -Reviewed-by: Andrew Bartlett -Reviewed-by: Matthias Dieter Wallnöfer ---- - testsuite.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/testsuite.c b/testsuite.c -index 9e340827e88e7779b24b65dffd0e2d8d4f9a46f0..c119884fd55391d90e74f60322c78776f9730609 100644 ---- a/testsuite.c -+++ b/testsuite.c -@@ -1266,6 +1266,8 @@ static bool test_talloc_free_in_destructor(void) - - talloc_free(level0); - -+ talloc_free(level3); /* make ASAN happy */ -+ - printf("success: free_in_destructor\n"); - return true; - } --- -2.23.0.rc2 - - -From 6c3e8a0a9f0636467af5678c04d5aecc9c3dbf7a Mon Sep 17 00:00:00 2001 -From: Swen Schillig -Date: Thu, 15 Aug 2019 14:36:59 +0200 -Subject: [PATCH 3/5] talloc: ASAN fix for test_pool_nest -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Direct leak of 96 byte(s) in 1 object(s) allocated from: - #0 0x7f06393dfc08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08) - #1 0x7f06392d0c45 in __talloc_with_prefix ../../talloc.c:782 - #2 0x7f06392d0c45 in __talloc ../../talloc.c:824 - #3 0x7f06392d0c45 in _talloc_named_const ../../talloc.c:981 - #4 0x7f06392d0c45 in talloc_named_const ../../talloc.c:1748 - #5 0x40901e in test_pool_nest ../../testsuite.c:1451 - #6 0x40901e in torture_local_talloc ../../testsuite.c:2096 - #7 0x402603 in main ../../testsuite_main.c:32 - #8 0x7f063908a412 in __libc_start_main (/lib64/libc.so.6+0x24412) - -Signed-off-by: Swen Schillig -Reviewed-by: Andrew Bartlett -Reviewed-by: Matthias Dieter Wallnöfer ---- - testsuite.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/testsuite.c b/testsuite.c -index c119884fd55391d90e74f60322c78776f9730609..d936d18c2ae434686a29e58bff308afc1bc51133 100644 ---- a/testsuite.c -+++ b/testsuite.c -@@ -1468,6 +1468,8 @@ static bool test_pool_nest(void) - - talloc_free(p1); - -+ talloc_free(e); /* make ASAN happy */ -+ - return true; - } - --- -2.23.0.rc2 - - -From d0933ec62c113a6da5209a556fad8819febe4ec2 Mon Sep 17 00:00:00 2001 -From: Swen Schillig -Date: Thu, 15 Aug 2019 14:39:58 +0200 -Subject: [PATCH 4/5] talloc: ASAN fix for test_rusty -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Direct leak of 100 byte(s) in 1 object(s) allocated from: - #0 0x7f06393dfc08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08) - #1 0x7f06392d1af3 in __talloc_with_prefix ../../talloc.c:782 - #2 0x7f06392d1af3 in __talloc ../../talloc.c:824 - #3 0x7f06392d1af3 in __talloc_strlendup ../../talloc.c:2455 - #4 0x7f06392d1af3 in talloc_strdup ../../talloc.c:2471 - #5 0x40b4f0 in test_rusty ../../testsuite.c:1543 - #6 0x40b4f0 in torture_local_talloc ../../testsuite.c:2146 - #7 0x402603 in main ../../testsuite_main.c:32 - #8 0x7f063908a412 in __libc_start_main (/lib64/libc.so.6+0x24412) - -Signed-off-by: Swen Schillig -Reviewed-by: Andrew Bartlett -Reviewed-by: Matthias Dieter Wallnöfer ---- - testsuite.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/testsuite.c b/testsuite.c -index d936d18c2ae434686a29e58bff308afc1bc51133..ffede68f52a1d3ffb535ea7bab2825483ec2b470 100644 ---- a/testsuite.c -+++ b/testsuite.c -@@ -1540,7 +1540,7 @@ static bool test_free_ref_null_context(void) - static bool test_rusty(void) - { - void *root; -- const char *p1; -+ char *p1; - - talloc_enable_null_tracking(); - root = talloc_new(NULL); -@@ -1549,6 +1549,8 @@ static bool test_rusty(void) - talloc_report_full(root, stdout); - talloc_free(root); - CHECK_BLOCKS("null_context", NULL, 2); -+ talloc_free(p1); /* make ASAN happy */ -+ - return true; - } - --- -2.23.0.rc2 - - -From fc4ad5b6dfdcfb859f92dcca868a043e31a051b0 Mon Sep 17 00:00:00 2001 -From: Swen Schillig -Date: Thu, 15 Aug 2019 14:43:22 +0200 -Subject: [PATCH 5/5] talloc: ASAN fix for test_magic_protection -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Direct leak of 1152 byte(s) in 1 object(s) allocated from: - #0 0x7f06393dfc08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08) - #1 0x7f06392cfd59 in __talloc_with_prefix ../../talloc.c:782 - #2 0x7f06392cfd59 in _talloc_pool ../../talloc.c:837 - #3 0x7f06392cfd59 in talloc_pool ../../talloc.c:859 - #4 0x40b83c in test_magic_protection ../../testsuite.c:1960 - #5 0x40b83c in torture_local_talloc ../../testsuite.c:2164 - #6 0x402603 in main ../../testsuite_main.c:32 - #7 0x7f063908a412 in __libc_start_main (/lib64/libc.so.6+0x24412) - -Signed-off-by: Swen Schillig -Reviewed-by: Andrew Bartlett -Reviewed-by: Matthias Dieter Wallnöfer ---- - testsuite.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/testsuite.c b/testsuite.c -index ffede68f52a1d3ffb535ea7bab2825483ec2b470..aa5c771ea31e524c93fd42d97304b025f172b684 100644 ---- a/testsuite.c -+++ b/testsuite.c -@@ -1999,6 +1999,8 @@ static bool test_magic_protection(void) - - while (wait(&exit_status) != pid); - -+ talloc_free(pool); /* make ASAN happy */ -+ - if (!WIFEXITED(exit_status)) { - printf("Child exited through unexpected abnormal means\n"); - return false; --- -2.23.0.rc2 - diff --git a/6001-talloc-Fix-alignment-issues-for-casting-pointers.patch b/6001-talloc-Fix-alignment-issues-for-casting-pointers.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9b20389b4a22cbe9c15faa366b5741ff137e6a1 --- /dev/null +++ b/6001-talloc-Fix-alignment-issues-for-casting-pointers.patch @@ -0,0 +1,106 @@ +From b2c2c4c3e6c4538c62cbcf03923bd7536292f7e9 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Fri, 12 Oct 2018 11:58:26 +0200 +Subject: [PATCH 16/28] talloc: Fix alignment issues for casting pointers + +warning: cast from 'char *' to 'struct talloc_chunk *' increases required +alignment from 1 to 8 + +Signed-off-by: Andreas Schneider +Reviewed-by: Volker Lendecke + +Autobuild-User(master): Andreas Schneider +Autobuild-Date(master): Tue Mar 19 12:38:50 UTC 2019 on sn-devel-144 + +Signed-off-by: root +--- + talloc.c | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +diff --git a/talloc.c b/talloc.c +index 073a3e50d4b..518ffbdbfdf 100644 +--- a/talloc.c ++++ b/talloc.c +@@ -317,6 +317,11 @@ struct talloc_chunk { + struct talloc_pool_hdr *pool; + }; + ++union talloc_chunk_cast_u { ++ uint8_t *ptr; ++ struct talloc_chunk *chunk; ++}; ++ + /* 16 byte alignment seems to keep everyone happy */ + #define TC_ALIGN16(s) (((s)+15)&~15) + #define TC_HDR_SIZE TC_ALIGN16(sizeof(struct talloc_chunk)) +@@ -611,16 +616,25 @@ struct talloc_pool_hdr { + size_t poolsize; + }; + ++union talloc_pool_hdr_cast_u { ++ uint8_t *ptr; ++ struct talloc_pool_hdr *hdr; ++}; ++ + #define TP_HDR_SIZE TC_ALIGN16(sizeof(struct talloc_pool_hdr)) + + static inline struct talloc_pool_hdr *talloc_pool_from_chunk(struct talloc_chunk *c) + { +- return (struct talloc_pool_hdr *)((char *)c - TP_HDR_SIZE); ++ union talloc_chunk_cast_u tcc = { .chunk = c }; ++ union talloc_pool_hdr_cast_u tphc = { tcc.ptr - TP_HDR_SIZE }; ++ return tphc.hdr; + } + + static inline struct talloc_chunk *talloc_chunk_from_pool(struct talloc_pool_hdr *h) + { +- return (struct talloc_chunk *)((char *)h + TP_HDR_SIZE); ++ union talloc_pool_hdr_cast_u tphc = { .hdr = h }; ++ union talloc_chunk_cast_u tcc = { .ptr = tphc.ptr + TP_HDR_SIZE }; ++ return tcc.chunk; + } + + static inline void *tc_pool_end(struct talloc_pool_hdr *pool_hdr) +@@ -668,6 +682,7 @@ static inline struct talloc_chunk *tc_alloc_pool(struct talloc_chunk *parent, + size_t size, size_t prefix_len) + { + struct talloc_pool_hdr *pool_hdr = NULL; ++ union talloc_chunk_cast_u tcc; + size_t space_left; + struct talloc_chunk *result; + size_t chunk_size; +@@ -698,7 +713,10 @@ static inline struct talloc_chunk *tc_alloc_pool(struct talloc_chunk *parent, + return NULL; + } + +- result = (struct talloc_chunk *)((char *)pool_hdr->end + prefix_len); ++ tcc = (union talloc_chunk_cast_u) { ++ .ptr = ((uint8_t *)pool_hdr->end) + prefix_len ++ }; ++ result = tcc.chunk; + + #if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED) + VALGRIND_MAKE_MEM_UNDEFINED(pool_hdr->end, chunk_size); +@@ -750,7 +768,8 @@ static inline void *__talloc_with_prefix(const void *context, + } + + if (tc == NULL) { +- char *ptr; ++ uint8_t *ptr = NULL; ++ union talloc_chunk_cast_u tcc; + + /* + * Only do the memlimit check/update on actual allocation. +@@ -764,7 +783,8 @@ static inline void *__talloc_with_prefix(const void *context, + if (unlikely(ptr == NULL)) { + return NULL; + } +- tc = (struct talloc_chunk *)(ptr + prefix_len); ++ tcc = (union talloc_chunk_cast_u) { .ptr = ptr + prefix_len }; ++ tc = tcc.chunk; + tc->flags = talloc_magic; + tc->pool = NULL; + +-- +2.19.1 + diff --git a/libtalloc.spec b/libtalloc.spec index 505275a44f89df2c89a1c67b1fce5947b4998e3e..393b3dcd7bb6e8551caecfcc85c105fc84911455 100644 --- a/libtalloc.spec +++ b/libtalloc.spec @@ -1,20 +1,17 @@ Name: libtalloc -Version: 2.3.0 -Release: 0 +Version: 2.1.14 +Release: 4 Summary: A memory pool system License: LGPLv3+ URL: https://talloc.samba.org/talloc/doc/html/index.html Source: https://www.samba.org/ftp/talloc/talloc-%{version}.tar.gz -Patch6000: 6000-talloc-test-leak.patch +Patch6000: 6000-lib-talloc-Fix-undefined-behavior-in-talloc_memdup.patch +Patch6001: 6001-talloc-Fix-alignment-issues-for-casting-pointers.patch -BuildRequires: gcc git docbook-style-xsl python3-devel doxygen +BuildRequires: gcc git docbook-style-xsl python2-devel python3-devel doxygen Provides: bundled(libreplace) -Provides: python2-talloc%{?_isa} python2-talloc -Obsoletes: python2-talloc -Provides: python2-talloc-devel%{?_isa} python2-talloc-devel -Obsoletes: python2-talloc-devel # Patches @@ -35,6 +32,29 @@ Requires: man %description help This contains man files for the using of libtalloc + +%package -n python2-talloc +Summary: Provide the python rely for libtalloc +Requires: libtalloc = %{version}-%{release} +Provides: pytalloc%{?_isa} = %{version}-%{release} +Provides: pytalloc = %{version}-%{release} +Obsoletes: pytalloc < 2.1.3 +%{?python_provide:%python_provide python2-talloc} + +%description -n python2-talloc +Provide the python 2 when using the libtalloc + +%package -n python2-talloc-devel +Summary: Files for python2-talloc development +Requires: python2-talloc = %{version}-%{release} +Provides: pytalloc-devel%{?_isa} = %{version}-%{release} +Provides: pytalloc-devel = %{version}-%{release} +Obsoletes: pytalloc-devel < 2.1.3 +%{?python_provide:%python_provide python2-talloc-devel} + +%description -n python2-talloc-devel +Files for python2-talloc development + %package -n python3-talloc Summary: Provide the python rely for libtalloc Requires: libtalloc = %{version}-%{release} @@ -57,11 +77,14 @@ Files for python3-talloc development %build export python_LDFLAGS="" +pathfix.py -n -p -i %{__python2} buildtools/bin/waf + %configure --disable-rpath \ --disable-rpath-install \ --bundled-libraries=NONE \ --builtin-libraries=replace \ - --disable-silent-rules + --disable-silent-rules \ + --extra-python=%{__python3} %make_build V=1 doxygen doxy.config @@ -92,6 +115,15 @@ cp -a doc/man/* $RPM_BUILD_ROOT/%{_mandir} %files help %{_mandir}/man3/* +%files -n python2-talloc +%{_libdir}/libpytalloc-util.so.* +%{python2_sitearch}/talloc.so + +%files -n python2-talloc-devel +%{_includedir}/pytalloc.h +%{_libdir}/pkgconfig/pytalloc-util.pc +%{_libdir}/libpytalloc-util.so + %files -n python3-talloc %{_libdir}/libpytalloc-util.cpython*.so.* %{python3_sitearch}/talloc.cpython*.so @@ -102,15 +134,12 @@ cp -a doc/man/* $RPM_BUILD_ROOT/%{_mandir} %{_libdir}/libpytalloc-util.cpython*.so %ldconfig_scriptlets + +%ldconfig_scriptlets -n python2-talloc + %ldconfig_scriptlets -n python3-talloc %changelog -* Mon Feb 10 2020 Ruijun Ge - 2.3.0-0 -- Type:enhancement -- ID:NA -- SUG:NA -- DESC:update package - * Tue Sep 3 2019 shidongdong - 2.1.14-4 - Type:enhancement - ID:NA diff --git a/talloc-2.1.14.tar.gz b/talloc-2.1.14.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8591a716b06c6ec5ff04c6b266e74edac41eaf88 Binary files /dev/null and b/talloc-2.1.14.tar.gz differ diff --git a/talloc-2.3.0.tar.gz b/talloc-2.3.0.tar.gz deleted file mode 100644 index 9af2a409465bfde80c7008bb7265e0f2ec2ff761..0000000000000000000000000000000000000000 Binary files a/talloc-2.3.0.tar.gz and /dev/null differ