Date: Wed, 9 Jun 2021 16:16:44 GMT From: David Bright <dab@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 80a5d786a3cd - stable/12 - libsa: Fix infinite loop in bzipfs & gzipfs Message-ID: <202106091616.159GGiCe044446@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by dab: URL: https://cgit.FreeBSD.org/src/commit/?id=80a5d786a3cdee6b6d2dbf6c2d8037a19d2fd9be commit 80a5d786a3cdee6b6d2dbf6c2d8037a19d2fd9be Author: David Bright <dab@FreeBSD.org> AuthorDate: 2021-05-24 17:12:15 +0000 Commit: David Bright <dab@FreeBSD.org> CommitDate: 2021-06-09 16:15:33 +0000 libsa: Fix infinite loop in bzipfs & gzipfs A bug in the loader's bzipfs & gzipfs filesystems caused compressed kernel and modules not to work on EFI systems with a veriexec-enabled loader. Since the size of files in these filesystems are not known _a priori_ `stat` would initialize the size to -1 and the loader would then hang in an infinite loop while trying to seek (read) to the end of file since the loop termination condition compares the current offset to that negative target position. Sponsored by: Dell EMC Isilon (cherry picked from commit 3df4c387d2e3ca4c2391fb837540b048f60a11c2) --- stand/libsa/bzipfs.c | 3 +++ stand/libsa/gzipfs.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/stand/libsa/bzipfs.c b/stand/libsa/bzipfs.c index 47380ae72e5e..bb67bda2aa19 100644 --- a/stand/libsa/bzipfs.c +++ b/stand/libsa/bzipfs.c @@ -340,6 +340,9 @@ bzf_seek(struct open_file *f, off_t offset, int where) target - bzf->bzf_bzstream.total_out_lo32), NULL); if (errno) return(-1); + /* Break out of loop if end of file has been reached. */ + if (bzf->bzf_endseen) + break; } /* This is where we are (be honest if we overshot) */ return(bzf->bzf_bzstream.total_out_lo32); diff --git a/stand/libsa/gzipfs.c b/stand/libsa/gzipfs.c index 39e2f98eb1e0..8154b0f95a9a 100644 --- a/stand/libsa/gzipfs.c +++ b/stand/libsa/gzipfs.c @@ -315,6 +315,9 @@ zf_seek(struct open_file *f, off_t offset, int where) target - zf->zf_zstream.total_out), NULL); if (errno) return(-1); + /* Break out of loop if end of file has been reached. */ + if (zf->zf_endseen) + break; } /* This is where we are (be honest if we overshot) */ return(zf->zf_zstream.total_out);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106091616.159GGiCe044446>