diff --git a/0834-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch b/0834-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch new file mode 100644 index 0000000000000000000000000000000000000000..c24ff51b30e4680359dc8d8fbb5684337b68e7dc --- /dev/null +++ b/0834-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch @@ -0,0 +1,66 @@ +From b877c3b06f15a025748b9f09621ddf1bd00cacce Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 20 Dec 2019 17:58:03 +0100 +Subject: [PATCH] umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed + success + +Fixes: #14410 +Replaces: #14386 + +--- + systemd-239/src/core/umount.c | 29 ++++++++++++++++++++++------- + 1 file changed, 22 insertions(+), 7 deletions(-) + +diff --git a/src/core/umount.c b/src/core/umount.c +index 241fe6f..4400b3c 100644 +--- a/src/core/umount.c ++++ b/src/core/umount.c +@@ -334,23 +334,38 @@ static int dm_list_get(MountPoint **head) { + + static int delete_loopback(const char *device) { + _cleanup_close_ int fd = -1; +- int r; ++ struct loop_info64 info; + + assert(device); + + fd = open(device, O_RDONLY|O_CLOEXEC); + if (fd < 0) + return errno == ENOENT ? 0 : -errno; ++ ++ if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { ++ if (errno == ENXIO) /* Nothing bound, didn't do anything */ ++ return 0; ++ ++ return -errno; ++ } + +- r = ioctl(fd, LOOP_CLR_FD, 0); +- if (r >= 0) ++ if (ioctl(fd, LOOP_GET_STATUS64, &info) < 0) { ++ /* If the LOOP_CLR_FD above succeeded we'll see ENXIO here. */ ++ if (errno == ENXIO) ++ log_debug("Successfully detached loopback device %s.", device); ++ else ++ log_debug_errno(errno, "Failed to invoke LOOP_GET_STATUS64 on loopback device %s, ignoring: %m", device); /* the LOOP_CLR_FD at least worked, let's hope for the best */ + return 1; ++ } + +- /* ENXIO: not bound, so no error */ +- if (errno == ENXIO) +- return 0; ++ /* Linux makes LOOP_CLR_FD succeed whenever LO_FLAGS_AUTOCLEAR is set without actually doing ++ * anything. Very confusing. Let's hence not claim we did anything in this case. */ ++ if (FLAGS_SET(info.lo_flags, LO_FLAGS_AUTOCLEAR)) ++ log_debug("Successfully called LOOP_CLR_FD on a loopback device %s with autoclear set, which is a NOP.", device); ++ else ++ log_debug("Weird, LOOP_CLR_FD succeeded but the device is still attached on %s.", device); + +- return -errno; ++ return -EBUSY; /* Nothing changed, the device is still attached, hence it apparently is still busy */; + } + + static int delete_dm(dev_t devnum) { +-- +2.31.1 + diff --git a/systemd.spec b/systemd.spec index 00e16e343cd40dd60e6a02815abfd549125c7102..4e8faeec78969495b6aee430dc3c415099bf1b4d 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 #global gitcommit 10e465b5321bd53c1fc59ffab27e724535c6bc0f %{?gitcommit:%global gitcommitshort %(c=%{gitcommit}; echo ${c:0:7})} @@ -884,6 +884,7 @@ Patch0830: 0830-logind-add-option-to-stop-idle-sessions-after-specif.patch Patch0831: 0831-logind-schedule-idle-check-full-interval-from-now-if.patch Patch0832: 0832-time-util-fix-buffer-over-run.patch Patch0833: 0833-core-move-reset_arguments-to-the-end-of-main-s-finis.patch +Patch0834: 0834-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch Patch10000: 10000-core-fix-a-null-reference-case-in-load_from_path.patch Patch10001: 10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch Patch10002: 10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch @@ -1526,6 +1527,9 @@ fi %files tests -f .file-list-tests %changelog +* Mon Mar 06 2023 yuanhui - 239-68.0.2.1 +- umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success + * Wed Feb 01 2023 Yuanhong Peng - 239-68.0.1.1 - core: fix a null reference case in load_from_path() - sysctl: Don't pass null directive argument to '%s'