From da180fe136c5156784cf30a72b7d060b47494474 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 21 2020 19:19:36 +0000 Subject: import util-linux-2.32.1-17.el8 --- diff --git a/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch b/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch new file mode 100644 index 0000000..1c2f1c8 --- /dev/null +++ b/SOURCES/0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch @@ -0,0 +1,87 @@ +From e431bfeca0f3e7be2eba30be83260f20976f871d Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 31 Jul 2019 16:18:27 +0200 +Subject: [PATCH 23/24] libblkid: fix file descriptor leak in blkid_verify() + +The function blkid_verify() uses private device file descriptor and +uses blkid_probe_set_device() to assign the descriptor to low-level +probing code. Unfortunately, close() in this case is not enough as the +prober can internally open whole-disk device too. + +The library API has been extended so blkid_probe_set_device() +deallocates and close previously used prober for whole-disk. This new +functionality is used in blkid_verify() now. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734553 +Upstream: http://github.com/karelzak/util-linux/commit/c4d6d1c54dcd0eff701236d396d88b1fc6251768 +Signed-off-by: Karel Zak +--- + libblkid/src/probe.c | 19 ++++++++++++++++--- + libblkid/src/verify.c | 4 +++- + 2 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 647ae416a..a6dc8416a 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -848,10 +848,15 @@ failed: + * @off: begin of probing area + * @size: size of probing area (zero means whole device/file) + * +- * Assigns the device to probe control struct, resets internal buffers and +- * resets the current probing. ++ * Assigns the device to probe control struct, resets internal buffers, resets ++ * the current probing, and close previously associated device (if open by ++ * libblkid). + * +- * Returns: -1 in case of failure, or 0 on success. ++ * If @fd is < 0 than only resets the prober and returns 1. Note that ++ * blkid_reset_probe() keeps the device associated with the prober, but ++ * blkid_probe_set_device() does complete reset. ++ * ++ * Returns: -1 in case of failure, 0 on success and 1 on reset. + */ + int blkid_probe_set_device(blkid_probe pr, int fd, + blkid_loff_t off, blkid_loff_t size) +@@ -866,6 +871,11 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0) + close(pr->fd); + ++ if (pr->disk_probe) { ++ blkid_free_probe(pr->disk_probe); ++ pr->disk_probe = NULL; ++ } ++ + pr->flags &= ~BLKID_FL_PRIVATE_FD; + pr->flags &= ~BLKID_FL_TINY_DEV; + pr->flags &= ~BLKID_FL_CDROM_DEV; +@@ -881,6 +891,9 @@ int blkid_probe_set_device(blkid_probe pr, int fd, + pr->wipe_size = 0; + pr->wipe_chain = NULL; + ++ if (fd < 0) ++ return 1; ++ + #if defined(POSIX_FADV_RANDOM) && defined(HAVE_POSIX_FADVISE) + /* Disable read-ahead */ + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM); +diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c +index 7f44f5497..750378f8c 100644 +--- a/libblkid/src/verify.c ++++ b/libblkid/src/verify.c +@@ -184,9 +184,11 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) + dev->bid_name, (long long)st.st_rdev, dev->bid_type)); + } + +- blkid_reset_probe(cache->probe); ++ /* reset prober */ + blkid_probe_reset_superblocks_filter(cache->probe); ++ blkid_probe_set_device(cache->probe, -1, 0, 0); + close(fd); ++ + return dev; + } + +-- +2.21.0 + diff --git a/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch b/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch new file mode 100644 index 0000000..f0ed8c8 --- /dev/null +++ b/SOURCES/0024-findmnt-verify-ignore-passno-for-XFS.patch @@ -0,0 +1,73 @@ +From 3f6de92999cf63e234265f51d6ee02134bc75ac3 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 12 Jun 2019 11:02:51 +0200 +Subject: [PATCH 24/24] findmnt: (verify) ignore passno for XFS + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1719069 +Upstream: http://github.com/karelzak/util-linux/commit/f5b7bf155b9881de5b99cc0a23b4dccf9a2d4af3 +Signed-off-by: Karel Zak +--- + misc-utils/findmnt-verify.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/misc-utils/findmnt-verify.c b/misc-utils/findmnt-verify.c +index 1cc62def9..73e44a418 100644 +--- a/misc-utils/findmnt-verify.c ++++ b/misc-utils/findmnt-verify.c +@@ -28,7 +28,8 @@ struct verify_context { + int nwarnings; + int nerrors; + +- unsigned int target_printed : 1; ++ unsigned int target_printed : 1, ++ no_fsck : 1; + }; + + static void verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap) +@@ -408,6 +409,8 @@ static int verify_fstype(struct verify_context *vfy) + isauto = 1; + else if (strcmp(type, "swap") == 0) + isswap = 1; ++ else if (strcmp(type, "xfs") == 0) ++ vfy->no_fsck = 1; + + if (!isswap && !isauto && !none && !is_supported_filesystem(vfy, type)) + verify_warn(vfy, _("%s seems unsupported by the current kernel"), type); +@@ -422,6 +425,7 @@ static int verify_fstype(struct verify_context *vfy) + + if (realtype) { + isswap = strcmp(realtype, "swap") == 0; ++ vfy->no_fsck = strcmp(realtype, "xfs") == 0; + + if (type && !isauto && strcmp(type, realtype) != 0) + return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype); +@@ -440,7 +444,7 @@ static int verify_passno(struct verify_context *vfy) + int passno = mnt_fs_get_passno(vfy->fs); + const char *tgt = mnt_fs_get_target(vfy->fs); + +- if (tgt && strcmp("/", tgt) == 0 && passno != 1) ++ if (tgt && strcmp("/", tgt) == 0 && passno != 1 && !vfy->no_fsck) + return verify_warn(vfy, _("recommended root FS passno is 1 (current is %d)"), passno); + + return 0; +@@ -463,7 +467,7 @@ static int verify_filesystem(struct verify_context *vfy) + if (!rc) + rc = verify_fstype(vfy); + if (!rc) +- rc = verify_passno(vfy); ++ rc = verify_passno(vfy); /* depends on verify_fstype() */ + + return rc; + } +@@ -492,6 +496,8 @@ int verify_table(struct libmnt_table *tb) + + while (rc == 0 && (vfy.fs = get_next_fs(tb, itr))) { + vfy.target_printed = 0; ++ vfy.no_fsck = 0; ++ + if (check_order) + rc = verify_order(&vfy); + if (!rc) +-- +2.21.0 + diff --git a/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch b/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch new file mode 100644 index 0000000..0afeed4 --- /dev/null +++ b/SOURCES/0025-partx-don-t-report-ENXIO-as-error-on-d.patch @@ -0,0 +1,41 @@ +From be5e6b14db3cdd09dab711572116d7ee39344875 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 21 Aug 2019 10:51:18 +0200 +Subject: [PATCH 25/26] partx: don't report ENXIO as error on -d + +The errno ENXIO should be ignored, unfortunately the current code uses +variable 'rc' for ioctl return code as well as for final del_parts() +return value. So, failed ioctl (which should be ignored) affects all +del_parts() status. + + # modprobe scsi_debug dev_size_mb=100 + # partx -d --nr 1-1024 /dev/sdc; echo $? + 1 + +The device dos not contains any partitions, so 0 return code is +expected in this case. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 +Upstream: http://github.com/karelzak/util-linux/commit/53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555 +Signed-off-by: Karel Zak +--- + disk-utils/partx.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/disk-utils/partx.c b/disk-utils/partx.c +index e3443ea80..f3dcc9007 100644 +--- a/disk-utils/partx.c ++++ b/disk-utils/partx.c +@@ -327,8 +327,7 @@ static int del_parts(int fd, const char *device, dev_t devno, + } + + for (i = lower; i <= upper; i++) { +- rc = partx_del_partition(fd, i); +- if (rc == 0) { ++ if (partx_del_partition(fd, i) == 0) { + if (verbose) + printf(_("%s: partition #%d removed\n"), device, i); + continue; +-- +2.21.0 + diff --git a/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch b/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch new file mode 100644 index 0000000..33b50ff --- /dev/null +++ b/SOURCES/0026-partx-document-d-vs.-nr-and-fix-test.patch @@ -0,0 +1,59 @@ +From 5a9269c019f9cb0b2d54444501beb74663670693 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 21 Aug 2019 13:42:22 +0200 +Subject: [PATCH 26/26] partx: document -d vs. --nr and fix test + +The commit ab025087f91b66ee8e23a16bc49eb0d9bd421d65 has disabled error +message, but unfortunately it keeps wrong return code. This has been fixed +by commit 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555. + +This commit add hit about it to docs and fix regression test too. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 +Upstream: http://github.com/karelzak/util-linux/commit/5200aa99d27e084b514e8b035db32f39b49562a3 +Signed-off-by: Karel Zak +--- + disk-utils/partx.8 | 5 ++++- + tests/ts/partx/partx | 9 +++++++-- + 2 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/disk-utils/partx.8 b/disk-utils/partx.8 +index af7313cb9..c6bbbae42 100644 +--- a/disk-utils/partx.8 ++++ b/disk-utils/partx.8 +@@ -53,7 +53,10 @@ Add the specified partitions, or read the disk and add all partitions. + Print the SIZE column in bytes rather than in human-readable format. + .TP + .BR \-d , " \-\-delete" +-Delete the specified partitions or all partitions. ++Delete the specified partitions or all partitions. It is not error to ++remove non-existing partitions, so this option is possible to use together with ++large \fB\-\-nr\fR ranges without care about the current partitions set on ++the device. + .TP + .BR \-g , " \-\-noheadings" + Do not print a header line with \fB\-\-show\fR or \fB\-\-raw\fR. +diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx +index b21dc44ef..84c286a94 100755 +--- a/tests/ts/partx/partx ++++ b/tests/ts/partx/partx +@@ -137,9 +137,14 @@ udevadm settle + ts_init_subtest "delete-non-existent" + #attempt to remove it again + { ++ # remove non-existing partitions (ENXIO) is not error ++ # ++ # see ab025087f91b66ee8e23a16bc49eb0d9bd421d65 and ++ # 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555 ++ # + $TS_CMD_PARTX -d --nr $PARTS $TS_DEVICE && +- echo "partx failed: removed non-existing partition" || +- echo "partx: OK" ++ echo "partx: OK" || ++ echo "partx failed: removed non-existing partition" + } >$TS_OUTPUT 2>&1 + ts_finalize_subtest + +-- +2.21.0 + diff --git a/SOURCES/0027-libmount-improve-mountinfo-reliability.patch b/SOURCES/0027-libmount-improve-mountinfo-reliability.patch new file mode 100644 index 0000000..c78f9ad --- /dev/null +++ b/SOURCES/0027-libmount-improve-mountinfo-reliability.patch @@ -0,0 +1,396 @@ +From 32fe4f1dd8fbc104bd848e24de613122947f095a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 28 Aug 2019 15:47:16 +0200 +Subject: [PATCH] libmount: improve mountinfo reliability +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The standard way how we read mount table is not reliable because +during the read() syscalls the table may be modified by some another +process. The changes in the table is possible to detect by poll() +event, and in this case it seems better to lseek to the begin of the file +and read it again. It's expensive, but better than races... + +This patch does not modify mountinfo parser, but it reads all file to +memory (by read()+poll()) and than it creates memory stream +from the buffer and use it rather than a regular file stream. + +It means the parser is still possible to use for normal files +(e.g. fstab) as well as for mountinfo and it's also portable to +systems where for some reason is no fmemopen(). + +Addresses: https://github.com/systemd/systemd/issues/10872 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1751447 +Upstream: http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb +Upstream: http://github.com/karelzak/util-linux/commit/ee551c909f95437fd9fcd162f398c069d0ce9720 +Reported-by: Zbigniew Jędrzejewski-Szmek +Signed-off-by: Karel Zak +--- + configure.ac | 1 + + libmount/src/mountP.h | 2 + + libmount/src/tab_parse.c | 87 +++++++++++++++++---- + libmount/src/utils.c | 158 +++++++++++++++++++++++++++++++++++++++ + 4 files changed, 233 insertions(+), 15 deletions(-) + +diff --git a/configure.ac b/configure.ac +index a05a294ad..245004890 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -456,6 +456,7 @@ AC_CHECK_FUNCS([ \ + err \ + errx \ + explicit_bzero \ ++ fmemopen \ + fsync \ + utimensat \ + getdomainname \ +diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h +index d47d26442..52a238ef3 100644 +--- a/libmount/src/mountP.h ++++ b/libmount/src/mountP.h +@@ -93,6 +93,7 @@ extern int mnt_valid_tagname(const char *tagname); + extern int append_string(char **a, const char *b); + + extern const char *mnt_statfs_get_fstype(struct statfs *vfs); ++extern int is_procfs_fd(int fd); + extern int is_file_empty(const char *name); + + extern int mnt_is_readonly(const char *path) +@@ -118,6 +119,7 @@ extern void mnt_free_filesystems(char **filesystems); + extern char *mnt_get_kernel_cmdline_option(const char *name); + extern int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path); + extern int mnt_stat_mountpoint(const char *target, struct stat *st); ++extern FILE *mnt_get_procfs_memstream(int fd, char **membuf); + + /* tab.c */ + extern int is_mountinfo(struct libmnt_table *tb); +diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c +index 3ed84ebc2..10fc68279 100644 +--- a/libmount/src/tab_parse.c ++++ b/libmount/src/tab_parse.c +@@ -603,15 +603,7 @@ static int kernel_fs_postparse(struct libmnt_table *tb, + return rc; + } + +-/** +- * mnt_table_parse_stream: +- * @tb: tab pointer +- * @f: file stream +- * @filename: filename used for debug and error messages +- * +- * Returns: 0 on success, negative number in case of error. +- */ +-int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) ++static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) + { + int rc = -1; + int flags = 0; +@@ -685,6 +677,40 @@ err: + return rc; + } + ++/** ++ * mnt_table_parse_stream: ++ * @tb: tab pointer ++ * @f: file stream ++ * @filename: filename used for debug and error messages ++ * ++ * Returns: 0 on success, negative number in case of error. ++ */ ++int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename) ++{ ++ int fd, rc; ++ FILE *memf = NULL; ++ char *membuf = NULL; ++ ++ /* ++ * For /proc/#/{mountinfo,mount} we read all file to memory and use it ++ * as memory stream. For more details see mnt_read_procfs_file(). ++ */ ++ if ((fd = fileno(f)) >= 0 ++ && (tb->fmt == MNT_FMT_GUESS || ++ tb->fmt == MNT_FMT_MOUNTINFO || ++ tb->fmt == MNT_FMT_MTAB) ++ && is_procfs_fd(fd) ++ && (memf = mnt_get_procfs_memstream(fd, &membuf))) { ++ ++ rc = __table_parse_stream(tb, memf, filename); ++ fclose(memf); ++ free(membuf); ++ } else ++ rc = __table_parse_stream(tb, f, filename); ++ ++ return rc; ++} ++ + /** + * mnt_table_parse_file: + * @tb: tab pointer +@@ -700,18 +726,49 @@ err: + int mnt_table_parse_file(struct libmnt_table *tb, const char *filename) + { + FILE *f; +- int rc; ++ int rc, fd = -1; + + if (!filename || !tb) + return -EINVAL; + +- f = fopen(filename, "r" UL_CLOEXECSTR); ++ /* ++ * Try to use read()+poll() to realiably read all ++ * /proc/#/{mount,mountinfo} file to memory ++ */ ++ if (tb->fmt != MNT_FMT_SWAPS ++ && strncmp(filename, "/proc/", 6) == 0) { ++ ++ FILE *memf; ++ char *membuf = NULL; ++ ++ fd = open(filename, O_RDONLY|O_CLOEXEC); ++ if (fd < 0) { ++ rc = -errno; ++ goto done; ++ } ++ memf = mnt_get_procfs_memstream(fd, &membuf); ++ if (memf) { ++ rc = __table_parse_stream(tb, memf, filename); ++ ++ fclose(memf); ++ free(membuf); ++ close(fd); ++ goto done; ++ } ++ /* else fallback to fopen/fdopen() */ ++ } ++ ++ if (fd >= 0) ++ f = fdopen(fd, "r" UL_CLOEXECSTR); ++ else ++ f = fopen(filename, "r" UL_CLOEXECSTR); ++ + if (f) { +- rc = mnt_table_parse_stream(tb, f, filename); ++ rc = __table_parse_stream(tb, f, filename); + fclose(f); + } else + rc = -errno; +- ++done: + DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc)); + return rc; + } +@@ -768,7 +825,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) + + f = fopen_at(dd, d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); + if (f) { +- mnt_table_parse_stream(tb, f, d->d_name); ++ __table_parse_stream(tb, f, d->d_name); + fclose(f); + } + } +@@ -809,7 +866,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) + f = fopen_at(dirfd(dir), d->d_name, + O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); + if (f) { +- mnt_table_parse_stream(tb, f, d->d_name); ++ __table_parse_stream(tb, f, d->d_name); + fclose(f); + } + } +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index c36187c07..f7d85d124 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + + #include "strutils.h" +@@ -408,6 +409,12 @@ const char *mnt_statfs_get_fstype(struct statfs *vfs) + return NULL; + } + ++int is_procfs_fd(int fd) ++{ ++ struct statfs sfs; ++ ++ return fstatfs(fd, &sfs) == 0 && sfs.f_type == STATFS_PROC_MAGIC; ++} + + /** + * mnt_match_fstype: +@@ -1117,8 +1124,158 @@ done: + return 1; + } + ++#if defined(HAVE_FMEMOPEN) || defined(TEST_PROGRAM) ++ ++/* ++ * This function tries to minimize possible races when we read ++ * /proc/#/{mountinfo,mount} files. ++ * ++ * The idea is to minimize number of read()s and check by poll() that during ++ * the read the mount table has not been modified. If yes, than re-read it ++ * (with some limitations to avoid never ending loop). ++ * ++ * Returns: <0 error, 0 success, 1 too many attempts ++ */ ++static int read_procfs_file(int fd, char **buf, size_t *bufsiz) ++{ ++ size_t bufmax = 0; ++ int rc = 0, tries = 0, ninters = 0; ++ char *bufptr = NULL;; ++ ++ assert(buf); ++ assert(bufsiz); ++ ++ *bufsiz = 0; ++ *buf = NULL; ++ ++ do { ++ ssize_t ret; ++ ++ if (!bufptr || bufmax == *bufsiz) { ++ char *tmp; ++ ++ bufmax = bufmax ? bufmax * 2 : (16 * 1024); ++ tmp = realloc(*buf, bufmax); ++ if (!tmp) ++ break; ++ *buf = tmp; ++ bufptr = tmp + *bufsiz; ++ } ++ ++ errno = 0; ++ ret = read(fd, bufptr, bufmax - *bufsiz); ++ ++ if (ret < 0) { ++ /* error */ ++ if ((errno == EAGAIN || errno == EINTR) && (ninters++ < 5)) { ++ xusleep(200000); ++ continue; ++ } ++ break; ++ ++ } else if (ret > 0) { ++ /* success -- verify no event during read */ ++ struct pollfd fds[] = { ++ { .fd = fd, .events = POLLPRI } ++ }; ++ ++ rc = poll(fds, 1, 0); ++ if (rc < 0) ++ break; /* poll() error */ ++ if (rc > 0) { ++ /* event -- read all again */ ++ if (lseek(fd, 0, SEEK_SET) != 0) ++ break; ++ *bufsiz = 0; ++ bufptr = *buf; ++ tries++; ++ ++ if (tries > 10) ++ /* busy system? -- wait */ ++ xusleep(10000); ++ continue; ++ } ++ ++ /* successful read() without active poll() */ ++ (*bufsiz) += (size_t) ret; ++ bufptr += ret; ++ tries = ninters = 0; ++ } else { ++ /* end-of-file */ ++ goto success; ++ } ++ } while (tries <= 100); ++ ++ rc = errno ? -errno : 1; ++ free(*buf); ++ return rc; ++ ++success: ++ return 0; ++} ++ ++/* ++ * Create FILE stream for data from read_procfs_file() ++ */ ++FILE *mnt_get_procfs_memstream(int fd, char **membuf) ++{ ++ FILE *memf; ++ size_t sz = 0; ++ off_t cur; ++ ++ /* in case of error, rewind to the original position */ ++ cur = lseek(fd, 0, SEEK_CUR); ++ ++ if (read_procfs_file(fd, membuf, &sz) == 0 ++ && sz > 0 ++ && (memf = fmemopen(*membuf, sz, "r"))) ++ return memf; ++ ++ /* error */ ++ lseek(fd, cur, SEEK_SET); ++ return NULL; ++} ++#else ++FILE *mnt_get_procfs_memstream(int fd __attribute((__unused__)), ++ char **membuf __attribute((__unused__))) ++{ ++ return NULL; ++} ++#endif /* HAVE_FMEMOPEN */ ++ + + #ifdef TEST_PROGRAM ++static int test_proc_read(struct libmnt_test *ts, int argc, char *argv[]) ++{ ++ char *buf = NULL; ++ char *filename = argv[1]; ++ size_t bufsiz = 0; ++ int rc = 0, fd = open(filename, O_RDONLY); ++ ++ if (fd <= 0) { ++ warn("%s: cannot open", filename); ++ return -errno; ++ } ++ ++ rc = read_procfs_file(fd, &buf, &bufsiz); ++ close(fd); ++ ++ switch (rc) { ++ case 0: ++ fwrite(buf, 1, bufsiz, stdout); ++ free(buf); ++ break; ++ case 1: ++ warnx("too many attempts"); ++ break; ++ default: ++ warn("%s: cannot read", filename); ++ break; ++ } ++ ++ return rc; ++} ++ + static int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[]) + { + char *type = argv[1]; +@@ -1300,6 +1457,7 @@ int main(int argc, char *argv[]) + { "--guess-root", test_guess_root, "[]" }, + { "--mkdir", test_mkdir, "" }, + { "--statfs-type", test_statfs_type, "" }, ++ { "--read-procfs", test_proc_read, "" }, + + { NULL } + }; +-- +2.21.0 + diff --git a/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch b/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch new file mode 100644 index 0000000..e356bf4 --- /dev/null +++ b/SOURCES/0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch @@ -0,0 +1,53 @@ +From d9fe56d8da9015694fcba5f3dd850becff677ab5 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 20 Sep 2019 13:00:19 +0200 +Subject: [PATCH] libmount: use fmemopen() in more robust way [coverity scan] + +Upstream: http://github.com/karelzak/util-linux/commit/026f7d302066a4e6f5a69dc9818ec3180939f4a3 +Upstream: http://github.com/karelzak/util-linux/commit/bc747dfccf511419312ec872cefa90e25d83136a +Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1751447 +Signed-off-by: Karel Zak +--- + libmount/src/utils.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index f7d85d124..04e79f53f 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -1219,20 +1219,26 @@ success: + */ + FILE *mnt_get_procfs_memstream(int fd, char **membuf) + { +- FILE *memf; + size_t sz = 0; + off_t cur; + ++ *membuf = NULL; ++ + /* in case of error, rewind to the original position */ + cur = lseek(fd, 0, SEEK_CUR); + +- if (read_procfs_file(fd, membuf, &sz) == 0 +- && sz > 0 +- && (memf = fmemopen(*membuf, sz, "r"))) +- return memf; ++ if (read_procfs_file(fd, membuf, &sz) == 0 && sz > 0) { ++ FILE *memf = fmemopen(*membuf, sz, "r"); ++ if (memf) ++ return memf; /* success */ ++ ++ free(*membuf); ++ *membuf = NULL; ++ } + + /* error */ +- lseek(fd, cur, SEEK_SET); ++ if (cur != (off_t) -1) ++ lseek(fd, cur, SEEK_SET); + return NULL; + } + #else +-- +2.21.0 + diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index fe20771..cf2d224 100644 --- a/SPECS/util-linux.spec +++ b/SPECS/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 11%{?dist} +Release: 17%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -37,6 +37,13 @@ Buildrequires: libuser-devel BuildRequires: libcap-ng-devel BuildRequires: %{pypkg}-devel BuildRequires: gcc +%ifarch ppc64le +BuildRequires: librtas-devel +%endif +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: bison ### Sources Source0: ftp://ftp.kernel.org/pub/linux/utils/util-linux/v%{upstream_major}/util-linux-%{upstream_version}.tar.xz @@ -130,6 +137,17 @@ Patch19: 0019-tests-add-noskip-commands.patch Patch20: 0020-tests-add-missing-program-checks.patch Patch21: 0021-tests-check-for-tar-and-b-g-zip.patch Patch22: 0022-tests-make-mount-oloop-use-more-robust.patch +# 1734553 - RHEL-8: blkid_get_dev() leak file descriptor to underlying block device +Patch23: 0023-libblkid-fix-file-descriptor-leak-in-blkid_verify.patch +# 1719069 - Findmnt warning "recommended root FS passno is 1" for XFS +Patch24: 0024-findmnt-verify-ignore-passno-for-XFS.patch +# 1739179 - partx failed on nvme devices with exit code 1 +Patch25: 0025-partx-don-t-report-ENXIO-as-error-on-d.patch +Patch26: 0026-partx-document-d-vs.-nr-and-fix-test.patch +# 1751447 - improve /proc/self/mountinfo reliability +Patch27: 0027-libmount-improve-mountinfo-reliability.patch +Patch28: 0028-libmount-use-fmemopen-in-more-robust-way-coverity-sc.patch + %description The util-linux package contains a large variety of low-level system @@ -316,6 +334,12 @@ chfn and chsh utilities with dependence on libuser %build unset LINGUAS || : +# unfortunately, we did changes to build-system +./autogen.sh + +# if we modify .po files by RHEL patches +rm -f po/stamp* + export CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS" export SUID_CFLAGS="-fpie" export SUID_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" @@ -989,6 +1013,25 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Sat Sep 21 2019 Karel Zak 2.32.1-17 +- fix error path in mountinfo patch (#1751447) + +* Fri Sep 20 2019 Karel Zak 2.32.1-16 +- cleanup mountinfo libmount patch (#1751447) + +* Mon Sep 16 2019 Karel Zak 2.32.1-15 +- fix #1751447 - improve /proc/self/mountinfo reliability + +* Tue Sep 03 2019 Karel Zak 2.32.1-14 +- fix #1739179 - partx failed on nvme devices with exit code 1 + +* Mon Aug 05 2019 Karel Zak 2.32.1-13 +- fix #1734553 - blkid_get_dev() leak file descriptor to underlying block device +- fix #1719069 - findmnt warning "recommended root FS passno is 1" for XFS + +* Tue Jul 30 2019 Karel Zak 2.32.1-12 +- fix #1732769 - lscpu not showing Physical socket, chips information + * Tue Jun 04 2019 Karel Zak 2.32.1-11 - fix #1681062 - improve loopdev use in gating tests