The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y
git checkout FETCH_HEAD
git cherry-pick -x 57e2c2f2d94cfd551af91cedfa1af6d972487197
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072126-unread-chokehold-f312@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^..
Possible dependencies:
57e2c2f2d94c ("fs: dlm: fix mismatch of plock results from userspace")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
b065b23d3c3b ("dt-bindings: clock: Add ipq9574 clock and reset definitions")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57e2c2f2d94cfd551af91cedfa1af6d972487197 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Wed, 24 May 2023 12:02:04 -0400
Subject: [PATCH] fs: dlm: fix mismatch of plock results from userspace
When a waiting plock request (F_SETLKW) is sent to userspace
for processing (dlm_controld), the result is returned at a
later time. That result could be incorrectly matched to a
different waiting request in cases where the owner field is
the same (e.g. different threads in a process.) This is fixed
by comparing all the properties in the request and reply.
The results for non-waiting plock requests are now matched
based on list order because the results are returned in the
same order they were sent.
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index c9e1d5f54194..70a4752ed913 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -395,7 +395,7 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
if (op->info.flags & DLM_PLOCK_FL_CLOSE)
list_del(&op->list);
else
- list_move(&op->list, &recv_list);
+ list_move_tail(&op->list, &recv_list);
memcpy(&info, &op->info, sizeof(info));
}
spin_unlock(&ops_lock);
@@ -433,20 +433,52 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
if (check_version(&info))
return -EINVAL;
+ /*
+ * The results for waiting ops (SETLKW) can be returned in any
+ * order, so match all fields to find the op. The results for
+ * non-waiting ops are returned in the order that they were sent
+ * to userspace, so match the result with the first non-waiting op.
+ */
spin_lock(&ops_lock);
- list_for_each_entry(iter, &recv_list, list) {
- if (iter->info.fsid == info.fsid &&
- iter->info.number == info.number &&
- iter->info.owner == info.owner) {
- list_del_init(&iter->list);
- memcpy(&iter->info, &info, sizeof(info));
- if (iter->data)
- do_callback = 1;
- else
- iter->done = 1;
- op = iter;
- break;
+ if (info.wait) {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (iter->info.fsid == info.fsid &&
+ iter->info.number == info.number &&
+ iter->info.owner == info.owner &&
+ iter->info.pid == info.pid &&
+ iter->info.start == info.start &&
+ iter->info.end == info.end &&
+ iter->info.ex == info.ex &&
+ iter->info.wait) {
+ op = iter;
+ break;
+ }
}
+ } else {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (!iter->info.wait) {
+ op = iter;
+ break;
+ }
+ }
+ }
+
+ if (op) {
+ /* Sanity check that op and info match. */
+ if (info.wait)
+ WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK);
+ else
+ WARN_ON(op->info.fsid != info.fsid ||
+ op->info.number != info.number ||
+ op->info.owner != info.owner ||
+ op->info.optype != info.optype);
+
+ list_del_init(&op->list);
+ memcpy(&op->info, &info, sizeof(info));
+ if (op->data)
+ do_callback = 1;
+ else
+ op->done = 1;
}
spin_unlock(&ops_lock);
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkout FETCH_HEAD
git cherry-pick -x 57e2c2f2d94cfd551af91cedfa1af6d972487197
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072125-irk-garbage-a1fb@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..
Possible dependencies:
57e2c2f2d94c ("fs: dlm: fix mismatch of plock results from userspace")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57e2c2f2d94cfd551af91cedfa1af6d972487197 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Wed, 24 May 2023 12:02:04 -0400
Subject: [PATCH] fs: dlm: fix mismatch of plock results from userspace
When a waiting plock request (F_SETLKW) is sent to userspace
for processing (dlm_controld), the result is returned at a
later time. That result could be incorrectly matched to a
different waiting request in cases where the owner field is
the same (e.g. different threads in a process.) This is fixed
by comparing all the properties in the request and reply.
The results for non-waiting plock requests are now matched
based on list order because the results are returned in the
same order they were sent.
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index c9e1d5f54194..70a4752ed913 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -395,7 +395,7 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
if (op->info.flags & DLM_PLOCK_FL_CLOSE)
list_del(&op->list);
else
- list_move(&op->list, &recv_list);
+ list_move_tail(&op->list, &recv_list);
memcpy(&info, &op->info, sizeof(info));
}
spin_unlock(&ops_lock);
@@ -433,20 +433,52 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
if (check_version(&info))
return -EINVAL;
+ /*
+ * The results for waiting ops (SETLKW) can be returned in any
+ * order, so match all fields to find the op. The results for
+ * non-waiting ops are returned in the order that they were sent
+ * to userspace, so match the result with the first non-waiting op.
+ */
spin_lock(&ops_lock);
- list_for_each_entry(iter, &recv_list, list) {
- if (iter->info.fsid == info.fsid &&
- iter->info.number == info.number &&
- iter->info.owner == info.owner) {
- list_del_init(&iter->list);
- memcpy(&iter->info, &info, sizeof(info));
- if (iter->data)
- do_callback = 1;
- else
- iter->done = 1;
- op = iter;
- break;
+ if (info.wait) {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (iter->info.fsid == info.fsid &&
+ iter->info.number == info.number &&
+ iter->info.owner == info.owner &&
+ iter->info.pid == info.pid &&
+ iter->info.start == info.start &&
+ iter->info.end == info.end &&
+ iter->info.ex == info.ex &&
+ iter->info.wait) {
+ op = iter;
+ break;
+ }
}
+ } else {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (!iter->info.wait) {
+ op = iter;
+ break;
+ }
+ }
+ }
+
+ if (op) {
+ /* Sanity check that op and info match. */
+ if (info.wait)
+ WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK);
+ else
+ WARN_ON(op->info.fsid != info.fsid ||
+ op->info.number != info.number ||
+ op->info.owner != info.owner ||
+ op->info.optype != info.optype);
+
+ list_del_init(&op->list);
+ memcpy(&op->info, &info, sizeof(info));
+ if (op->data)
+ do_callback = 1;
+ else
+ op->done = 1;
}
spin_unlock(&ops_lock);
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 57e2c2f2d94cfd551af91cedfa1af6d972487197
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072125-convent-backshift-8f6a@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
57e2c2f2d94c ("fs: dlm: fix mismatch of plock results from userspace")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57e2c2f2d94cfd551af91cedfa1af6d972487197 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Wed, 24 May 2023 12:02:04 -0400
Subject: [PATCH] fs: dlm: fix mismatch of plock results from userspace
When a waiting plock request (F_SETLKW) is sent to userspace
for processing (dlm_controld), the result is returned at a
later time. That result could be incorrectly matched to a
different waiting request in cases where the owner field is
the same (e.g. different threads in a process.) This is fixed
by comparing all the properties in the request and reply.
The results for non-waiting plock requests are now matched
based on list order because the results are returned in the
same order they were sent.
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index c9e1d5f54194..70a4752ed913 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -395,7 +395,7 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
if (op->info.flags & DLM_PLOCK_FL_CLOSE)
list_del(&op->list);
else
- list_move(&op->list, &recv_list);
+ list_move_tail(&op->list, &recv_list);
memcpy(&info, &op->info, sizeof(info));
}
spin_unlock(&ops_lock);
@@ -433,20 +433,52 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
if (check_version(&info))
return -EINVAL;
+ /*
+ * The results for waiting ops (SETLKW) can be returned in any
+ * order, so match all fields to find the op. The results for
+ * non-waiting ops are returned in the order that they were sent
+ * to userspace, so match the result with the first non-waiting op.
+ */
spin_lock(&ops_lock);
- list_for_each_entry(iter, &recv_list, list) {
- if (iter->info.fsid == info.fsid &&
- iter->info.number == info.number &&
- iter->info.owner == info.owner) {
- list_del_init(&iter->list);
- memcpy(&iter->info, &info, sizeof(info));
- if (iter->data)
- do_callback = 1;
- else
- iter->done = 1;
- op = iter;
- break;
+ if (info.wait) {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (iter->info.fsid == info.fsid &&
+ iter->info.number == info.number &&
+ iter->info.owner == info.owner &&
+ iter->info.pid == info.pid &&
+ iter->info.start == info.start &&
+ iter->info.end == info.end &&
+ iter->info.ex == info.ex &&
+ iter->info.wait) {
+ op = iter;
+ break;
+ }
}
+ } else {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (!iter->info.wait) {
+ op = iter;
+ break;
+ }
+ }
+ }
+
+ if (op) {
+ /* Sanity check that op and info match. */
+ if (info.wait)
+ WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK);
+ else
+ WARN_ON(op->info.fsid != info.fsid ||
+ op->info.number != info.number ||
+ op->info.owner != info.owner ||
+ op->info.optype != info.optype);
+
+ list_del_init(&op->list);
+ memcpy(&op->info, &info, sizeof(info));
+ if (op->data)
+ do_callback = 1;
+ else
+ op->done = 1;
}
spin_unlock(&ops_lock);
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 57e2c2f2d94cfd551af91cedfa1af6d972487197
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072124-delicacy-thrower-2b56@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
57e2c2f2d94c ("fs: dlm: fix mismatch of plock results from userspace")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57e2c2f2d94cfd551af91cedfa1af6d972487197 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Wed, 24 May 2023 12:02:04 -0400
Subject: [PATCH] fs: dlm: fix mismatch of plock results from userspace
When a waiting plock request (F_SETLKW) is sent to userspace
for processing (dlm_controld), the result is returned at a
later time. That result could be incorrectly matched to a
different waiting request in cases where the owner field is
the same (e.g. different threads in a process.) This is fixed
by comparing all the properties in the request and reply.
The results for non-waiting plock requests are now matched
based on list order because the results are returned in the
same order they were sent.
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index c9e1d5f54194..70a4752ed913 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -395,7 +395,7 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
if (op->info.flags & DLM_PLOCK_FL_CLOSE)
list_del(&op->list);
else
- list_move(&op->list, &recv_list);
+ list_move_tail(&op->list, &recv_list);
memcpy(&info, &op->info, sizeof(info));
}
spin_unlock(&ops_lock);
@@ -433,20 +433,52 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
if (check_version(&info))
return -EINVAL;
+ /*
+ * The results for waiting ops (SETLKW) can be returned in any
+ * order, so match all fields to find the op. The results for
+ * non-waiting ops are returned in the order that they were sent
+ * to userspace, so match the result with the first non-waiting op.
+ */
spin_lock(&ops_lock);
- list_for_each_entry(iter, &recv_list, list) {
- if (iter->info.fsid == info.fsid &&
- iter->info.number == info.number &&
- iter->info.owner == info.owner) {
- list_del_init(&iter->list);
- memcpy(&iter->info, &info, sizeof(info));
- if (iter->data)
- do_callback = 1;
- else
- iter->done = 1;
- op = iter;
- break;
+ if (info.wait) {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (iter->info.fsid == info.fsid &&
+ iter->info.number == info.number &&
+ iter->info.owner == info.owner &&
+ iter->info.pid == info.pid &&
+ iter->info.start == info.start &&
+ iter->info.end == info.end &&
+ iter->info.ex == info.ex &&
+ iter->info.wait) {
+ op = iter;
+ break;
+ }
}
+ } else {
+ list_for_each_entry(iter, &recv_list, list) {
+ if (!iter->info.wait) {
+ op = iter;
+ break;
+ }
+ }
+ }
+
+ if (op) {
+ /* Sanity check that op and info match. */
+ if (info.wait)
+ WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK);
+ else
+ WARN_ON(op->info.fsid != info.fsid ||
+ op->info.number != info.number ||
+ op->info.owner != info.owner ||
+ op->info.optype != info.optype);
+
+ list_del_init(&op->list);
+ memcpy(&op->info, &info, sizeof(info));
+ if (op->data)
+ do_callback = 1;
+ else
+ op->done = 1;
}
spin_unlock(&ops_lock);
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y
git checkout FETCH_HEAD
git cherry-pick -x 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072107-badass-icky-d7c8@gregkh' --subject-prefix 'PATCH 4.14.y' HEAD^..
Possible dependencies:
0f2b1cb89ccd ("fs: dlm: make F_SETLK use unkillable wait_event")
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:27 -0400
Subject: [PATCH] fs: dlm: make F_SETLK use unkillable wait_event
While a non-waiting posix lock request (F_SETLK) is waiting for
user space processing (in dlm_controld), wait for that processing
to complete with an unkillable wait_event(). This makes F_SETLK
behave the same way for F_RDLCK, F_WRLCK and F_UNLCK. F_SETLKW
continues to use wait_event_killable().
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 31bc601ee3d8..c9e1d5f54194 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,25 +155,29 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_killable(recv_wq, (op->done != 0));
- if (rv == -ERESTARTSYS) {
- spin_lock(&ops_lock);
- /* recheck under ops_lock if we got a done != 0,
- * if so this interrupt case should be ignored
- */
- if (op->done != 0) {
+ if (op->info.wait) {
+ rv = wait_event_killable(recv_wq, (op->done != 0));
+ if (rv == -ERESTARTSYS) {
+ spin_lock(&ops_lock);
+ /* recheck under ops_lock if we got a done != 0,
+ * if so this interrupt case should be ignored
+ */
+ if (op->done != 0) {
+ spin_unlock(&ops_lock);
+ goto do_lock_wait;
+ }
+ list_del(&op->list);
spin_unlock(&ops_lock);
- goto do_lock_wait;
- }
- list_del(&op->list);
- spin_unlock(&ops_lock);
- log_debug(ls, "%s: wait interrupted %x %llx pid %d",
- __func__, ls->ls_global_id,
- (unsigned long long)number, op->info.pid);
- do_unlock_close(&op->info);
- dlm_release_plock_op(op);
- goto out;
+ log_debug(ls, "%s: wait interrupted %x %llx pid %d",
+ __func__, ls->ls_global_id,
+ (unsigned long long)number, op->info.pid);
+ do_unlock_close(&op->info);
+ dlm_release_plock_op(op);
+ goto out;
+ }
+ } else {
+ wait_event(recv_wq, (op->done != 0));
}
do_lock_wait:
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkout FETCH_HEAD
git cherry-pick -x 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072105-snowshoe-snowman-0ea9@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..
Possible dependencies:
0f2b1cb89ccd ("fs: dlm: make F_SETLK use unkillable wait_event")
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:27 -0400
Subject: [PATCH] fs: dlm: make F_SETLK use unkillable wait_event
While a non-waiting posix lock request (F_SETLK) is waiting for
user space processing (in dlm_controld), wait for that processing
to complete with an unkillable wait_event(). This makes F_SETLK
behave the same way for F_RDLCK, F_WRLCK and F_UNLCK. F_SETLKW
continues to use wait_event_killable().
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 31bc601ee3d8..c9e1d5f54194 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,25 +155,29 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_killable(recv_wq, (op->done != 0));
- if (rv == -ERESTARTSYS) {
- spin_lock(&ops_lock);
- /* recheck under ops_lock if we got a done != 0,
- * if so this interrupt case should be ignored
- */
- if (op->done != 0) {
+ if (op->info.wait) {
+ rv = wait_event_killable(recv_wq, (op->done != 0));
+ if (rv == -ERESTARTSYS) {
+ spin_lock(&ops_lock);
+ /* recheck under ops_lock if we got a done != 0,
+ * if so this interrupt case should be ignored
+ */
+ if (op->done != 0) {
+ spin_unlock(&ops_lock);
+ goto do_lock_wait;
+ }
+ list_del(&op->list);
spin_unlock(&ops_lock);
- goto do_lock_wait;
- }
- list_del(&op->list);
- spin_unlock(&ops_lock);
- log_debug(ls, "%s: wait interrupted %x %llx pid %d",
- __func__, ls->ls_global_id,
- (unsigned long long)number, op->info.pid);
- do_unlock_close(&op->info);
- dlm_release_plock_op(op);
- goto out;
+ log_debug(ls, "%s: wait interrupted %x %llx pid %d",
+ __func__, ls->ls_global_id,
+ (unsigned long long)number, op->info.pid);
+ do_unlock_close(&op->info);
+ dlm_release_plock_op(op);
+ goto out;
+ }
+ } else {
+ wait_event(recv_wq, (op->done != 0));
}
do_lock_wait:
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y
git checkout FETCH_HEAD
git cherry-pick -x 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072106-okay-bovine-e4dd@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^..
Possible dependencies:
0f2b1cb89ccd ("fs: dlm: make F_SETLK use unkillable wait_event")
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:27 -0400
Subject: [PATCH] fs: dlm: make F_SETLK use unkillable wait_event
While a non-waiting posix lock request (F_SETLK) is waiting for
user space processing (in dlm_controld), wait for that processing
to complete with an unkillable wait_event(). This makes F_SETLK
behave the same way for F_RDLCK, F_WRLCK and F_UNLCK. F_SETLKW
continues to use wait_event_killable().
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 31bc601ee3d8..c9e1d5f54194 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,25 +155,29 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_killable(recv_wq, (op->done != 0));
- if (rv == -ERESTARTSYS) {
- spin_lock(&ops_lock);
- /* recheck under ops_lock if we got a done != 0,
- * if so this interrupt case should be ignored
- */
- if (op->done != 0) {
+ if (op->info.wait) {
+ rv = wait_event_killable(recv_wq, (op->done != 0));
+ if (rv == -ERESTARTSYS) {
+ spin_lock(&ops_lock);
+ /* recheck under ops_lock if we got a done != 0,
+ * if so this interrupt case should be ignored
+ */
+ if (op->done != 0) {
+ spin_unlock(&ops_lock);
+ goto do_lock_wait;
+ }
+ list_del(&op->list);
spin_unlock(&ops_lock);
- goto do_lock_wait;
- }
- list_del(&op->list);
- spin_unlock(&ops_lock);
- log_debug(ls, "%s: wait interrupted %x %llx pid %d",
- __func__, ls->ls_global_id,
- (unsigned long long)number, op->info.pid);
- do_unlock_close(&op->info);
- dlm_release_plock_op(op);
- goto out;
+ log_debug(ls, "%s: wait interrupted %x %llx pid %d",
+ __func__, ls->ls_global_id,
+ (unsigned long long)number, op->info.pid);
+ do_unlock_close(&op->info);
+ dlm_release_plock_op(op);
+ goto out;
+ }
+ } else {
+ wait_event(recv_wq, (op->done != 0));
}
do_lock_wait:
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072105-unsmooth-laboring-3769@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
0f2b1cb89ccd ("fs: dlm: make F_SETLK use unkillable wait_event")
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:27 -0400
Subject: [PATCH] fs: dlm: make F_SETLK use unkillable wait_event
While a non-waiting posix lock request (F_SETLK) is waiting for
user space processing (in dlm_controld), wait for that processing
to complete with an unkillable wait_event(). This makes F_SETLK
behave the same way for F_RDLCK, F_WRLCK and F_UNLCK. F_SETLKW
continues to use wait_event_killable().
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 31bc601ee3d8..c9e1d5f54194 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,25 +155,29 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_killable(recv_wq, (op->done != 0));
- if (rv == -ERESTARTSYS) {
- spin_lock(&ops_lock);
- /* recheck under ops_lock if we got a done != 0,
- * if so this interrupt case should be ignored
- */
- if (op->done != 0) {
+ if (op->info.wait) {
+ rv = wait_event_killable(recv_wq, (op->done != 0));
+ if (rv == -ERESTARTSYS) {
+ spin_lock(&ops_lock);
+ /* recheck under ops_lock if we got a done != 0,
+ * if so this interrupt case should be ignored
+ */
+ if (op->done != 0) {
+ spin_unlock(&ops_lock);
+ goto do_lock_wait;
+ }
+ list_del(&op->list);
spin_unlock(&ops_lock);
- goto do_lock_wait;
- }
- list_del(&op->list);
- spin_unlock(&ops_lock);
- log_debug(ls, "%s: wait interrupted %x %llx pid %d",
- __func__, ls->ls_global_id,
- (unsigned long long)number, op->info.pid);
- do_unlock_close(&op->info);
- dlm_release_plock_op(op);
- goto out;
+ log_debug(ls, "%s: wait interrupted %x %llx pid %d",
+ __func__, ls->ls_global_id,
+ (unsigned long long)number, op->info.pid);
+ do_unlock_close(&op->info);
+ dlm_release_plock_op(op);
+ goto out;
+ }
+ } else {
+ wait_event(recv_wq, (op->done != 0));
}
do_lock_wait:
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072104-legal-expediter-256e@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
0f2b1cb89ccd ("fs: dlm: make F_SETLK use unkillable wait_event")
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
c847f4e20304 ("fs: dlm: fix cleanup pending ops when interrupted")
b92a4e3f86b1 ("fs: dlm: change posix lock sigint handling")
4d413ae9ced4 ("fs: dlm: use dlm_plock_info for do_unlock_close")
ea06d4cabf52 ("fs: dlm: change plock interrupted message to debug again")
19d7ca051d30 ("fs: dlm: add pid to debug log")
dc1acd5c9469 ("dlm: replace usage of found with dedicated list iterator variable")
bcfad4265ced ("dlm: improve plock logging if interrupted")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
a559790caa1c ("dlm: replace sanity checks with WARN_ON")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0f2b1cb89ccdbdcedf7143f4153a4da700a05f48 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:27 -0400
Subject: [PATCH] fs: dlm: make F_SETLK use unkillable wait_event
While a non-waiting posix lock request (F_SETLK) is waiting for
user space processing (in dlm_controld), wait for that processing
to complete with an unkillable wait_event(). This makes F_SETLK
behave the same way for F_RDLCK, F_WRLCK and F_UNLCK. F_SETLKW
continues to use wait_event_killable().
Cc: stable(a)vger.kernel.org
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 31bc601ee3d8..c9e1d5f54194 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,25 +155,29 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_killable(recv_wq, (op->done != 0));
- if (rv == -ERESTARTSYS) {
- spin_lock(&ops_lock);
- /* recheck under ops_lock if we got a done != 0,
- * if so this interrupt case should be ignored
- */
- if (op->done != 0) {
+ if (op->info.wait) {
+ rv = wait_event_killable(recv_wq, (op->done != 0));
+ if (rv == -ERESTARTSYS) {
+ spin_lock(&ops_lock);
+ /* recheck under ops_lock if we got a done != 0,
+ * if so this interrupt case should be ignored
+ */
+ if (op->done != 0) {
+ spin_unlock(&ops_lock);
+ goto do_lock_wait;
+ }
+ list_del(&op->list);
spin_unlock(&ops_lock);
- goto do_lock_wait;
- }
- list_del(&op->list);
- spin_unlock(&ops_lock);
- log_debug(ls, "%s: wait interrupted %x %llx pid %d",
- __func__, ls->ls_global_id,
- (unsigned long long)number, op->info.pid);
- do_unlock_close(&op->info);
- dlm_release_plock_op(op);
- goto out;
+ log_debug(ls, "%s: wait interrupted %x %llx pid %d",
+ __func__, ls->ls_global_id,
+ (unsigned long long)number, op->info.pid);
+ do_unlock_close(&op->info);
+ dlm_release_plock_op(op);
+ goto out;
+ }
+ } else {
+ wait_event(recv_wq, (op->done != 0));
}
do_lock_wait:
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y
git checkout FETCH_HEAD
git cherry-pick -x 59e45c758ca1b9893ac923dd63536da946ac333b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable(a)vger.kernel.org>' --in-reply-to '2023072153-strongbox-spoon-5731@gregkh' --subject-prefix 'PATCH 4.14.y' HEAD^..
Possible dependencies:
59e45c758ca1 ("fs: dlm: interrupt posix locks only when process is killed")
a800ba77fd28 ("dlm: rearrange async condition return")
bcbb4ba6c9ba ("dlm: cleanup plock_op vs plock_xop")
42252d0d2aa9 ("dlm: fix plock invalid read")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 59e45c758ca1b9893ac923dd63536da946ac333b Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo(a)redhat.com>
Date: Fri, 19 May 2023 11:21:26 -0400
Subject: [PATCH] fs: dlm: interrupt posix locks only when process is killed
If a posix lock request is waiting for a result from user space
(dlm_controld), do not let it be interrupted unless the process
is killed. This reverts commit a6b1533e9a57 ("dlm: make posix locks
interruptible"). The problem with the interruptible change is
that all locks were cleared on any signal interrupt. If a signal
was received that did not terminate the process, the process
could continue running after all its dlm posix locks had been
cleared. A future patch will add cancelation to allow proper
interruption.
Cc: stable(a)vger.kernel.org
Fixes: a6b1533e9a57 ("dlm: make posix locks interruptible")
Signed-off-by: Alexander Aring <aahringo(a)redhat.com>
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index fea2157fac5b..31bc601ee3d8 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -155,7 +155,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
send_op(op);
- rv = wait_event_interruptible(recv_wq, (op->done != 0));
+ rv = wait_event_killable(recv_wq, (op->done != 0));
if (rv == -ERESTARTSYS) {
spin_lock(&ops_lock);
/* recheck under ops_lock if we got a done != 0,