From 00e3e0e9b6aa354981a645527c2cb97fac118228 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 5 Apr 2011 11:50:10 -0400 Subject: [PATCH] Add patch to limit database expansion, was causing OOMs in SSSD in some extreme situations. --- libtdb.spec | 8 +++++++- tdb-1.2.9-limit-tdb_expand.patch | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tdb-1.2.9-limit-tdb_expand.patch diff --git a/libtdb.spec b/libtdb.spec index 3a821f6..1bf58ba 100644 --- a/libtdb.spec +++ b/libtdb.spec @@ -6,7 +6,7 @@ Name: libtdb Version: 1.2.9 -Release: 9%{?dist} +Release: 10%{?dist} Group: System Environment/Daemons Summary: The tdb library License: LGPLv3+ @@ -21,6 +21,7 @@ BuildRequires: python-devel # Patches Patch0001: 0001-Install-python-bindings-in-the-arch-specific-locatio.patch +Patch0002: tdb-1.2.9-limit-tdb_expand.patch %description A library that implements a trivial database. @@ -53,6 +54,7 @@ Python bindings for libtdb %prep %setup -q -n tdb-%{version} %patch0001 -p1 +%patch0002 -p1 %build ./autogen.sh @@ -107,6 +109,10 @@ rm -rf $RPM_BUILD_ROOT %postun -n python-tdb -p /sbin/ldconfig %changelog +* Tue Apr 5 2011 Simo Sorce - 1.2.9-9 +- Add patch to limit database expansion, was causing OOMs in SSSD in some + extreme situations. + * Tue Feb 08 2011 Fedora Release Engineering - 1.2.9-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild diff --git a/tdb-1.2.9-limit-tdb_expand.patch b/tdb-1.2.9-limit-tdb_expand.patch new file mode 100644 index 0000000..71e0895 --- /dev/null +++ b/tdb-1.2.9-limit-tdb_expand.patch @@ -0,0 +1,34 @@ +diff -uPpr tdb-1.2.9/common/io.c tdb-1.2.9.fix/common/io.c +--- tdb-1.2.9/common/io.c 2010-10-13 21:08:49.000000000 -0400 ++++ tdb-1.2.9.fix/common/io.c 2011-04-05 11:47:14.761341926 -0400 +@@ -299,7 +299,7 @@ static int tdb_expand_file(struct tdb_co + int tdb_expand(struct tdb_context *tdb, tdb_off_t size) + { + struct tdb_record rec; +- tdb_off_t offset, new_size; ++ tdb_off_t offset, new_size, top_size; + + if (tdb_lock(tdb, -1, F_WRLCK) == -1) { + TDB_LOG((tdb, TDB_DEBUG_ERROR, "lock failed in tdb_expand\n")); +@@ -309,10 +309,18 @@ int tdb_expand(struct tdb_context *tdb, + /* must know about any previous expansions by another process */ + tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1); + ++ /* limit size in order to avoid using up huge amounts of memory for ++ * in memory tdbs if an oddball huge record creeps in */ ++ if (size > 100 * 1024) { ++ top_size = size * 2; ++ } else { ++ top_size = size * 100; ++ } ++ + /* always make room for at least 100 more records, and at +- least 25% more space. Round the database up to a multiple +- of the page size */ +- new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25); ++ least 25% more space. Round the database up to a multiple ++ of the page size */ ++ new_size = MAX(tdb->map_size + top_size, tdb->map_size * 1.25); + size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size; + + if (!(tdb->flags & TDB_INTERNAL))