summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2019-05-11 08:18:52 +0000
committeranton <anton@cvs.openbsd.org>2019-05-11 08:18:52 +0000
commita1066169bd94f8936aeb0e705ccfdbe6938f8cca (patch)
tree484a173d2f094bc40ef599fb2af3824bcfebe74c /sys
parentee0b8c22b04f226d8eff2ad95e5bcd193547e190 (diff)
Restore previous behavior of limiting deadlock detection to posix-style
locks. ok jturner@ visa@ Reported-by: syzbot+f9f13034fd656af6c48f@syzkaller.appspotmail.com
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_lockf.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/kern/vfs_lockf.c b/sys/kern/vfs_lockf.c
index 62fba11bef9..b32631cf81f 100644
--- a/sys/kern/vfs_lockf.c
+++ b/sys/kern/vfs_lockf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_lockf.c,v 1.41 2019/05/08 16:24:48 anton Exp $ */
+/* $OpenBSD: vfs_lockf.c,v 1.42 2019/05/11 08:18:51 anton Exp $ */
/* $NetBSD: vfs_lockf.c,v 1.7 1996/02/04 02:18:21 christos Exp $ */
/*
@@ -355,10 +355,9 @@ lf_setlock(struct lockf *lock)
/*
* Lock is blocked, check for deadlock before proceeding.
* Note: flock style locks cover the whole file, there is no
- * chance for deadlock. But for simplicity, all types of locks
- * are checked.
+ * chance for deadlock.
*/
- if (lf_deadlock(lock)) {
+ if ((lock->lf_flags & F_POSIX) && lf_deadlock(lock)) {
lf_free(lock);
return (EDEADLK);
}
@@ -844,7 +843,11 @@ lf_deadlock(struct lockf *lock)
struct lockf *block, *lf, *pending;
lf = TAILQ_FIRST(&lock->lf_state->ls_locks);
- while ((block = lf_getblock(lf, lock)) != NULL) {
+ for (; (block = lf_getblock(lf, lock)) != NULL;
+ lf = TAILQ_NEXT(block, lf_entry)) {
+ if ((block->lf_flags & F_POSIX) == 0)
+ continue;
+
TAILQ_FOREACH(pending, &lock->lf_state->ls_pending, lf_entry) {
if (pending->lf_blk == NULL)
continue; /* lock already unblocked */
@@ -853,8 +856,6 @@ lf_deadlock(struct lockf *lock)
pending->lf_blk->lf_pid == lock->lf_pid)
return (1);
}
-
- lf = TAILQ_NEXT(lf, lf_entry);
}
return (0);