Drop unneeded patches, added fixes for hardlink checks

This commit is contained in:
Denis Silakov 2014-11-11 07:14:33 -05:00
parent 114148eb8b
commit 7737044bfe
11 changed files with 197 additions and 171 deletions

View file

@ -1,32 +0,0 @@
--- rpm-5.3.12/lib/rpmds.c.55810~ 2011-07-12 11:54:08.000000000 +0200
+++ rpm-5.3.12/lib/rpmds.c 2011-07-13 16:51:59.699924504 +0200
@@ -4333,9 +4333,10 @@ assert((rpmdsFlags(B) & RPMSENSE_SENSEMA
case 'D': ix = RPMEVR_D; /*@switchbreak@*/break;
}
#if defined(RPM_VENDOR_MANDRIVA) /* mdvbz#55810 */
- if(ix == RPMEVR_R && (bFlags & (~RPMSENSE_GREATER & RPMSENSE_EQUAL))
- && *(b->F[ix]) == '\0')
- break;
+ if(ix >= RPMEVR_R && (bFlags & (~RPMSENSE_GREATER & RPMSENSE_EQUAL))
+ && !(ix == RPMEVR_D && (bFlags & RPMSENSE_LESS))
+ && *(b->F[ix]) == '\0')
+ break;
if (a->F[ix] && b->F[ix])
#else
if (a->F[ix] && *a->F[ix] && b->F[ix] && *b->F[ix])
--- rpm-5.3.12/rpmdb/rpmevr.c.55810~ 2011-07-12 11:54:27.000000000 +0200
+++ rpm-5.3.12/rpmdb/rpmevr.c 2011-07-13 16:51:59.700924519 +0200
@@ -286,9 +286,10 @@ assert(b->F[RPMEVR_D] != NULL);
case 'D': ix = RPMEVR_D; /*@switchbreak@*/break;
}
#if defined(RPM_VENDOR_MANDRIVA) /* mdvbz#55810 */
- if(ix == RPMEVR_R && (b->Flags & (~RPMSENSE_GREATER & RPMSENSE_EQUAL))
- && *(b->F[ix]) == '\0')
- break;
+ if(ix >= RPMEVR_R && (b->Flags & (~RPMSENSE_GREATER & RPMSENSE_EQUAL))
+ && !(ix == RPMEVR_D && (b->Flags & RPMSENSE_LESS))
+ && *(b->F[ix]) == '\0')
+ break;
#endif
rc = compare_values(a->F[ix], b->F[ix]);

View file

@ -1,14 +0,0 @@
--- rpm-5.3.12/macros/mandriva.in.loop_warning~ 2011-07-12 12:35:08.465808221 +0200
+++ rpm-5.3.12/macros/mandriva.in 2011-07-12 12:35:34.313207285 +0200
@@ -75,9 +75,9 @@ end\
%__xar %{_bindir}/xar
# mdvbz#61851
-%__tar_wildcards --wildcards
+%__tar_wildcards --wildcards
-%_loop_detection_loglevel 3
+%_loop_detection_loglevel 4
# mdvbz#62741
# standard systemd directories

View file

@ -1,9 +0,0 @@
--- rpm-5.3.8/macros/mandriva.in.dep_whiteout~ 2011-01-09 07:19:01.000000000 +0100
+++ rpm-5.3.8/macros/mandriva.in 2011-01-13 21:55:16.000000000 +0100
@@ -66,4 +66,6 @@ end\
# mdvbz#61851
%__tar_wildcards --wildcards
+%_loop_detection_loglevel 3
+
%{load:/etc/rpm/macros.d/*.macros}

View file

@ -1,21 +0,0 @@
--- rpm-5.3.8/rpmdb/rpmdb.c.distpatt~ 2011-01-09 07:25:35.000000000 +0100
+++ rpm-5.3.8/rpmdb/rpmdb.c 2011-02-25 08:03:31.073663026 +0100
@@ -2441,6 +2446,18 @@ assert(keylen == sizeof(hdrNum));
/* XXX Special case #4: gather primary keys with patterns. */
rpmRC rc;
+ /* ugly hack to workaround disttag/distepoch pattern matching issue */
+ const char *tmp = strstr(keyp, "-mdv2011.0");
+ if(tmp) {
+ const char *origkeyp = keyp;
+ size_t klen = strlen(keyp);
+ keyp = alloca(klen);
+ memset((void*)keyp, klen, 0);
+ klen = tmp-origkeyp+1;
+ snprintf((char*)keyp, klen, "%s", origkeyp);
+ if(strlen(tmp) > sizeof("-mdv2011.0")-1)
+ stpcpy((char*)keyp+(klen-1), &tmp[sizeof("-mdv2011.0")-1]);
+ }
rc = dbiFindMatches(dbi, keyp, &set);
if ((rc && rc != RPMRC_NOTFOUND) || set == NULL || set->count < 1) { /* error or empty set */

View file

@ -1,11 +0,0 @@
--- rpm-5.3.8/macros/mandriva.in.distsuffix~ 2011-01-22 23:54:04.320131003 +0100
+++ rpm-5.3.8/macros/mandriva.in 2011-01-23 00:09:48.251131004 +0100
@@ -31,7 +31,7 @@
# %release with such.
%evr_tuple_select 1234
%evr_tuple_order EVRD
-%disttag mdv
+%disttag %{!?distsuffix:mdv}%{?distsuffix}
%distepoch %(sed -e 's#.*release\\ \\(\\S*\\).*#\\1#' /etc/release)
# Dynamic EVRD tags macro for use with versioned provides/requires in place of

View file

@ -1,22 +0,0 @@
--- rpm-5.3.8/rpmdb/db3.c.set_lg_dir~ 2011-01-25 15:52:56.000000000 +0100
+++ rpm-5.3.8/rpmdb/db3.c 2011-01-25 16:20:29.860333978 +0100
@@ -920,6 +920,19 @@ static int db_init(dbiIndex dbi, const c
}
/* ==== Logging: */
+ const char *logdir;
+
+ logdir = rpmGetPath(dbhome, "/", "log", NULL);
+ /*
+ * Create the /var/lib/rpm/log directory if it doesn't exist (root only).
+ */
+ rpmioMkpath(logdir, 0755, getuid(), getgid());
+
+ xx = dbenv->set_lg_dir(dbenv, logdir);
+ xx = cvtdberr(dbi, "dbenv->set_lg_dir", xx, _debug);
+
+ _free(logdir);
+
/* ==== Memory pool: */
if (eflags & DB_INIT_MPOOL) {

View file

@ -0,0 +1,43 @@
We need to sanity check that the nlink size and our linksLeft counter
do match. If an rpm is badly constructed with identical inode values
for multiple hardlinked files, such an rpm will otherwise access memory
out of array bounds and cause memory corruption and crashes.
The fix is to add in the sanity check and exit if bad circumstances
are found. We need to fix the caller to check the return code too.
RP 2014/6/10
Upstream-Status: Pending
Index: rpm-5.4.9/lib/fsm.c
===================================================================
--- rpm-5.4.9.orig/lib/fsm.c 2014-06-10 10:54:08.601049402 +0000
+++ rpm-5.4.9/lib/fsm.c 2014-06-10 10:55:45.633046077 +0000
@@ -495,6 +495,11 @@
}
if (fsm->goal == IOSM_PKGBUILD) --fsm->li->linksLeft;
+ if (fsm->li->linksLeft > st->st_nlink) {
+ rpmlog(RPMLOG_ERR, _("Corrupted hardlinks found (count %d does not match %d), exiting.\n"), fsm->li->linksLeft, st->st_nlink);
+ return -1;
+ }
+
fsm->li->filex[fsm->li->linksLeft] = fsm->ix;
/*@-observertrans -dependenttrans@*/
fsm->li->nsuffix[fsm->li->linksLeft] = fsm->nsuffix;
@@ -1876,8 +1881,13 @@
fsm->postpone = iosmFileActionSkipped(fsm->action);
if (fsm->goal == IOSM_PKGINSTALL || fsm->goal == IOSM_PKGBUILD) {
/*@-evalorder@*/ /* FIX: saveHardLink can modify fsm */
- if (S_ISREG(st->st_mode) && st->st_nlink > 1)
+ if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
fsm->postpone = saveHardLink(fsm);
+ if (fsm->postpone < 0) {
+ rc = RPMRC_FAIL;
+ break;
+ }
+ }
/*@=evalorder@*/
}
if (fsmGetFi(fsm)->mapflags & IOSM_PAYLOAD_LIST) fsm->postpone = 1;

View file

@ -0,0 +1,144 @@
If we run builds on a filesystem with 64 bit inodes like XFS, we need to
map the inode numbers to something 32 bit since the cpio header only allows
for 32 bit inode values. If we don't do this:
#define SET_NUM_FIELD(phys, val, space) \
sprintf(space, "%8.8lx", (unsigned long) (val)); \
memcpy(phys, space, 8)
from cpio.c will print larger that 8 character values and then truncate the
LSBs. This generates cpio files where hardlinked files may have the same
inode number. The resulting rpms are then corrupted.
There is a separate patch for the crash the identical inode numbers causes
when extracting the rpm.
Patch taken from http://git.pld-linux.org/?p=packages/rpm.git;a=commitdiff;h=10526c23aac60b7b636e4c93862887dbef8e8f15
RP 2014/6/10
Upstream-Status: Pending
diff -ur rpm-5.4.10/build/files.c rpm-5.4.10-collision/build/files.c
--- rpm-5.4.10/build/files.c 2013-03-17 13:17:38.233358389 +0100
+++ rpm-5.4.10-collision/build/files.c 2013-03-17 13:07:37.468483625 +0100
@@ -1323,6 +1323,26 @@
return dalgo;
}
+static int isHardLink(FileListRec flp, FileListRec tlp)
+{
+ return ((S_ISREG(flp->fl_mode) && S_ISREG(tlp->fl_mode)) &&
+ ((flp->fl_nlink > 1) && (flp->fl_nlink == tlp->fl_nlink)) &&
+ (flp->fl_ino == tlp->fl_ino) &&
+ (flp->fl_dev == tlp->fl_dev));
+}
+
+static int seenHardLink(FileList fl, FileListRec flp, ino_t *fileid)
+{
+ FileListRec ilp;
+ for (ilp = fl->fileList; ilp < flp; ilp++) {
+ if (isHardLink(flp, ilp)) {
+ *fileid = ilp - fl->fileList;
+ return 1;
+ }
+ }
+ return 0;
+}
+
/**
* Add file entries to header.
* @todo Should directories have %doc/%config attributes? (#14531)
@@ -1370,6 +1390,7 @@
for (i = 0, flp = fl->fileList; i < fl->fileListRecsUsed; i++, flp++) {
const char *s;
+ ino_t fileid = flp - fl->fileList;
/* Merge duplicate entries. */
while (i < (fl->fileListRecsUsed - 1) &&
@@ -1437,6 +1458,13 @@
/* Leave room for both dirname and basename NUL's */
dpathlen += (strlen(flp->diskURL) + 2);
+ /* Excludes and dupes have been filtered out by now. */
+ if (S_ISREG(flp->fl_mode)) {
+ if (flp->fl_nlink == 1 || !seenHardLink(fl, flp, &fileid)) {
+ fl->totalFileSize += flp->fl_size;
+ }
+ }
+
/*
* Make the header, the OLDFILENAMES will get converted to a
* compressed file list write before we write the actual package to
@@ -1519,7 +1547,11 @@
/* XXX Hash instead of 64b->32b truncate to prevent aliasing. */
{ ino_t _ino = flp->fl_ino;
- ui32 = hashFunctionString(0, &_ino, sizeof(_ino));
+ /* don't use hash here, as hash collisions which happen on large packages
+ cause bus errors in rpmbuild
+ ui32 = hashFunctionString(0, &_ino, sizeof(_ino));
+ */
+ ui32 = fileid + 1;
}
he->tag = RPMTAG_FILEINODES;
he->t = RPM_UINT32_TYPE;
@@ -1752,39 +1780,6 @@
IOSM_MAP_TYPE | IOSM_MAP_MODE | IOSM_MAP_UID | IOSM_MAP_GID;
if (isSrc)
fi->fmapflags[i] |= IOSM_FOLLOW_SYMLINKS;
-
- if (S_ISREG(flp->fl_mode)) {
- int bingo = 1;
- /* Hard links need be tallied only once. */
- if (flp->fl_nlink > 1) {
- FileListRec jlp = flp + 1;
- int j = i + 1;
- for (; (unsigned)j < fi->fc; j++, jlp++) {
- /* follow outer loop logic */
- while (((jlp - fl->fileList) < (fl->fileListRecsUsed - 1)) &&
- !strcmp(jlp->fileURL, jlp[1].fileURL))
- jlp++;
- if (jlp->flags & RPMFILE_EXCLUDE) {
- j--;
- /*@innercontinue@*/ continue;
- }
- if (jlp->flags & RPMFILE_GHOST)
- /*@innercontinue@*/ continue;
- if (!S_ISREG(jlp->fl_mode))
- /*@innercontinue@*/ continue;
- if (flp->fl_nlink != jlp->fl_nlink)
- /*@innercontinue@*/ continue;
- if (flp->fl_ino != jlp->fl_ino)
- /*@innercontinue@*/ continue;
- if (flp->fl_dev != jlp->fl_dev)
- /*@innercontinue@*/ continue;
- bingo = 0; /* don't tally hardlink yet. */
- /*@innerbreak@*/ break;
- }
- }
- if (bingo)
- fl->totalFileSize += flp->fl_size;
- }
}
ui32 = fl->totalFileSize;
--- rpm-5.4.10/lib/fsm.c~
+++ rpm-5.4.10/lib/fsm.c
@@ -898,6 +898,7 @@ int fsmMapAttrs(IOSM_t fsm)
if (fi && i >= 0 && i < (int) fi->fc) {
mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms);
+ ino_t finalInode = (fi->finodes ? (ino_t)fi->finodes[i] : 0);
mode_t finalMode = (fi->fmodes ? (mode_t)fi->fmodes[i] : perms);
dev_t finalRdev = (dev_t)(fi->frdevs ? fi->frdevs[i] : 0);
rpmuint32_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0);
@@ -937,6 +938,7 @@ int fsmMapAttrs(IOSM_t fsm)
if ((S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
&& st->st_nlink == 0)
st->st_nlink = 1;
+ st->st_ino = finalInode;
st->st_rdev = finalRdev;
st->st_mtime = finalMtime;
}

View file

@ -1,12 +0,0 @@
--- rpm-5.4.5/lib/Makefile.am.libsql~ 2011-08-15 22:33:15.000000000 +0200
+++ rpm-5.4.5/lib/Makefile.am 2012-02-20 13:33:03.143259035 +0100
@@ -88,7 +88,9 @@ librpm.la: $(librpm_la_OBJECTS) $(librpm
$(librpm_la_LINK) -rpath $(usrlibdir) $(librpm_la_OBJECTS) $(librpm_la_LIBADD)
libsql_la_SOURCES = libsql.c
+if WITH_DBSQL
libsql_la_LIBADD = librpm.la $(RPMDB_LDADD_COMMON)
+endif
install-data-hook:
if !ENABLE_BUILD_LAFILES

View file

@ -1,18 +0,0 @@
--- rpm-5.4.7/lib/rpmds.c.soname_only~ 2012-03-10 21:25:25.174794826 +0100
+++ rpm-5.4.7/lib/rpmds.c 2012-03-10 21:25:42.414809878 +0100
@@ -3472,6 +3472,7 @@ assert(s != NULL);
}
#endif
+#if !defined(RPM_VENDOR_MANDRIVA)
/* For DSO's, provide the basename of the file if DT_SONAME not found. */
if (!skipP && isDSO && !gotDEBUG && !gotSONAME) {
s = strrchr(fn, '/');
@@ -3489,6 +3490,7 @@ assert(s != NULL);
(void)rpmdsFree(ds);
ds = NULL;
}
+#endif
exit:
soname = _free(soname);

View file

@ -60,7 +60,7 @@ Summary: The RPM package management system
Name: rpm
Epoch: 1
Version: %{libver}.%{minorver}
Release: %{?prereldate:0.%{prereldate}.}46
Release: %{?prereldate:0.%{prereldate}.}47
License: LGPLv2.1+
Group: System/Configuration/Packaging
Url: http://rpm5.org/
@ -77,8 +77,6 @@ Source2: rpm.rpmlintrc
Source3: cpu-os-macros.tar.gz
Source4: legacy_compat.macros
Source5: RPMBDB-0.1.tar.xz
# already merged upstream
Patch0: rpm-5.3.8-set-default-bdb-log-dir.patch
# TODO: should be disable for cooker, packaging needs to be fixed (enable for legacy compatibility)
# status: to be removed later..
Patch1: rpm-5.3.8-dependency-whiteout.patch
@ -87,13 +85,6 @@ Patch1: rpm-5.3.8-dependency-whiteout.patch
Patch2: rpm-5.4.9-non-pre-scripts-dont-fail.patch
# status: to be removed later
Patch3: rpm-5.4.9-no-doc-conflicts.patch
# if distsuffix is defined, use it for disttag (from Anssi)
# status: merged upstream IIRC, could probably be dropped
Patch4: rpm-5.3.8-disttag-distsuffix-fallback.patch
# ugly hack to workaround disttag/distepoch pattern matching issue to buy some
# time to come up with better pattern fix..
# status: needs to be fixed properly, but can be merged upstream
Patch5: rpm-5.3.8-distepoch-pattern-hack.patch
# fixes a typo in russian translation (#62333)
# status: needs to be pushed back to the Russian i18n project
Patch11: rpm-5.4.9-fix-russian-typo.patch
@ -103,9 +94,6 @@ Patch11: rpm-5.4.9-fix-russian-typo.patch
Patch15: rpm-5.3.8-fire-file-triggers-only-once.patch
# status: keep as mandriva specific for now
Patch21: rpm-5.3.12-change-dep-loop-errors-to-warnings.patch
# status: need to be revisited and made sure that we get the correct behaviour,
# regression tests certainly required
Patch22: rpm-5.3.12-55810-rpmevrcmp-again-grf.patch
# status: ready to merge, it's already been merged on HEAD, so commiting it to rpm-5_4
# would basically just mean backporting it..
Patch29: rpm-5.4.4-add-_specfile-macro.patch
@ -182,8 +170,6 @@ Patch78: rpm-5.4.9-ruby1.9-fixes.patch
# mdvbz#65269
# status: same as for other dependency generation patches
Patch79: rpm-5.4.4-dont-consider-ranged-dependencies-as-overlapping-for-removal.patch
# status: ignoree for now
Patch81: rpm-5.4.5-libsql-conditional.patch
# status: same as for other dependency generation patches
Patch85: rpm-5.4.5-fix-removal-of-overlapping-dependencies-for-internal-dependency-generator.patch
# this updates to using the dependency generator shipped with mono, it has some
@ -204,8 +190,6 @@ Patch91: rpm-5.4.9-update-rpmfc-when-removing-dependencies-on-self.patch
Patch92: rpm-5.4.9-rpmfc-extract-dependencies-for-all-files.patch
# status: ready for merge
Patch93: rpm-5.4.5-rubygems-add-missing-newline.patch
# Superseeded by haskell-scripts
# Patch94: rpm-5.4.9-generate-haskell-dependencies.patch
# status: same as for other dep gen patches
Patch95: rpm-5.4.5-drop-some-interpreter-deps.patch
# status: probably okay to merge..
@ -249,8 +233,6 @@ Patch115: rpm-5.4.7-rpmfc-fix-invalid-free-if-not-_defaultdocdir-set.patch
Patch116: rpm-5.4.10-dont-try-generate-rpmfc-dependencies-from-doc-files.patch
# status: ready to merge
Patch117: rpm-5.4.7-only-generate-ruby-and-python-deps-for-executables-and-modules.patch
# status: same as for other dep gen patches
Patch118: rpm-5.4.7-dont-generate-soname-provides-for-dsos-with-no-soname.patch
# status: ready
Patch119: rpm-5.4.7-fix-generation-of-ruby-abi-provides.patch
# status: same as for other dep gen patches
@ -502,6 +484,12 @@ Patch509: rpm-5.4.10-fat-lto-objects.patch
# -fno-delete-null-pointer-checks by default
Patch510: rpm-5.4.10-no-delete-null-pointer-checks.patch
# stop rpm crashing when accessing a broken binary rpm (with inode collisions)
Patch512: rpm-5.4.10-hardlink-segfault-fix.patch
# don't use hashes for inodes to avoid hash collisions on large packages
Patch513: rpm-5.4.10-payload-no-hashed-inode.patch
BuildRequires: autoconf >= 2.57
BuildRequires: bzip2-devel
BuildRequires: automake >= 1.8
@ -757,23 +745,12 @@ This package contains the RPM API documentation generated in HTML format.
%prep
%setup -q -a5
%patch111 -p1 -b .script_macros~
# These patches has been commited hastily upstream for review,
# keeping them around here for now untill finished...
%if 0
%patch0 -p1 -b .set_lg_dir~
%patch1 -p1 -b .dep_whiteout~
%endif
%patch2 -p1 -b .scriptlet~
%patch3 -p1 -b .doc_conflicts~
%patch11 -p1 -b .ru~
%if 0
%patch4 -p1 -b .distsuffix~
%patch5 -p1 -b .distpatt~
%patch15 -p1 -b .trigger_once~
%endif
#%%patch21 -p1 -b .loop_warnings~
#%%patch22 -p1 -b .55810~
#patch27 -p1 -b .mdv~
%patch29 -p1 -b .specfile~
%patch31 -p1 -b .rpm_qa~
#%%patch32 -p1 -b .clean~
@ -799,7 +776,6 @@ This package contains the RPM API documentation generated in HTML format.
%patch77 -p1 -b .db52~
%patch78 -p1 -b .ruby19~
%patch79 -p1 -b .range_nooverlap~
#patch81 -p1 -b .libsql~
%patch85 -p1 -b .int_gen_overlap~
%patch86 -p1 -b .mono_deps_new~
%patch87 -p1 -b .php_dep_gen~
@ -830,7 +806,6 @@ This package contains the RPM API documentation generated in HTML format.
%patch115 -p1 -b .free~
%patch116 -p1 -b .skip_doc~
%patch117 -p1 -b .exec_modules~
#patch118 -p1 -b .soname_only~
%patch119 -p1 -b .rubyabi_prov~
%patch120 -p1 -b .filedep_origins~
%patch121 -p1 -b .equal_overlaps~
@ -922,6 +897,9 @@ This package contains the RPM API documentation generated in HTML format.
%patch509 -p1 -b .fat_lto_cpu_os_macros~
%patch510 -p1 -b .no-delete-null-pointer-checks~
%patch512 -p1 -b .hardlink-segfault-fix
%patch513 -p1 -b .payload-no-hashed-inode
#required by P55, P80, P81, P94..
./autogen.sh