From 9c7f1ae01d2294b79bc57dff1f29ac9b813d6172 Mon Sep 17 00:00:00 2001 From: Jerry Jelinek Date: Mon, 14 May 2018 13:14:00 -0400 Subject: [PATCH] 9061 ofdlock(): assertion failed: lckdat->l_start == 0 Reviewed by: Cody Mello Reviewed by: John Levon Reviewed by: Richard Lowe Approved by: Dan McDonald --- .../test/os-tests/tests/file-locking/runtests.c | 30 +++++++++++++++++++++- usr/src/test/os-tests/tests/file-locking/util.c | 10 +++++++- usr/src/uts/common/syscall/fcntl.c | 5 ++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/usr/src/test/os-tests/tests/file-locking/runtests.c b/usr/src/test/os-tests/tests/file-locking/runtests.c index 0a1a4d9976..0d92d7e638 100644 --- a/usr/src/test/os-tests/tests/file-locking/runtests.c +++ b/usr/src/test/os-tests/tests/file-locking/runtests.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2016 Joyent, Inc. + * Copyright 2018 Joyent, Inc. */ /* @@ -60,6 +60,8 @@ static void flock_cleanup_child(pid_t, int []); static void flock_test_invalid(lockinfo_t *, int, short, short, off_t, off_t); +static void flock_test_invalid64(lockinfo_t *, int, short, short, + off_t, off_t); static void flock_test_exclusive(lock_style_t, lock_style_t, lockinfo_t *, lockinfo_t *, boolean_t); static void flock_test_shared(lock_style_t, lock_style_t, lockinfo_t *, @@ -80,6 +82,10 @@ static short cmds[8] = { F_FLOCK, F_FLOCKW }; +static short cmds64[3] = { + F_OFD_SETLK64, F_OFD_SETLKW64, F_OFD_GETLK64 +}; + static void flock_kill(pid_t pid) @@ -411,6 +417,23 @@ flock_test_invalid(lockinfo_t *lf, int cmd, short l_type, short l_whence, flock_log(" ok\n"); } +static void +flock_test_invalid64(lockinfo_t *lf, int cmd, short l_type, short l_whence, + off_t l_start, off_t l_len) +{ + struct flock64 fl = { + .l_type = l_type, + .l_whence = l_whence, + .l_start = l_start, + .l_len = l_len + }; + + flock_log("fcntl(fd, %s, { %hd, %hd, %ld, %ld, ... })...", + flock_cmdname(cmd), l_type, l_whence, l_start, l_len); + VERIFY3S(fcntl(lf->lf_fd, cmd, &fl), ==, -1); + VERIFY3U(errno, ==, EINVAL); + flock_log(" ok\n"); +} static void flock_test_exclusive(lock_style_t styleA, lock_style_t styleB, @@ -602,6 +625,11 @@ flock_runtests(void) flock_test_invalid(&flock_fileA, cmds[i], F_WRLCK, 0, 1, 0); flock_test_invalid(&flock_fileA, cmds[i], F_WRLCK, 0, 0, 1); } + for (i = 0; i < sizeof (cmds64) / sizeof (short); i++) { + flock_test_invalid64(&flock_fileA, cmds64[i], F_WRLCK, 1, 0, 0); + flock_test_invalid64(&flock_fileA, cmds64[i], F_WRLCK, 0, 1, 0); + flock_test_invalid64(&flock_fileA, cmds64[i], F_WRLCK, 0, 0, 1); + } flock_log("# Testing that multiple OFD locks work in a process\n"); flock_test_ofd_sameproc(); diff --git a/usr/src/test/os-tests/tests/file-locking/util.c b/usr/src/test/os-tests/tests/file-locking/util.c index ad171840ae..b178e8a405 100644 --- a/usr/src/test/os-tests/tests/file-locking/util.c +++ b/usr/src/test/os-tests/tests/file-locking/util.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2016 Joyent, Inc. + * Copyright 2018 Joyent, Inc. */ /* @@ -168,6 +168,14 @@ flock_cmdname(int cmd) return ("F_FLOCK"); case F_FLOCKW: return ("F_FLOCKW"); +#if !defined(_LP64) + case F_OFD_SETLK64: + return ("F_OFD_SETLK64"); + case F_OFD_SETLKW64: + return ("F_OFD_SETLKW64"); + case F_OFD_GETLK64: + return ("F_OFD_GETLK64"); +#endif default: abort(); return (""); diff --git a/usr/src/uts/common/syscall/fcntl.c b/usr/src/uts/common/syscall/fcntl.c index e9a97da97c..7b787a4acb 100644 --- a/usr/src/uts/common/syscall/fcntl.c +++ b/usr/src/uts/common/syscall/fcntl.c @@ -22,7 +22,7 @@ /* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. - * Copyright 2015, Joyent, Inc. + * Copyright 2018, Joyent, Inc. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -717,7 +717,8 @@ fcntl(int fdes, int cmd, intptr_t arg) } } - if (cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW) { + if (cmd == F_OFD_GETLK || cmd == F_OFD_SETLK || + cmd == F_OFD_SETLKW) { /* * TBD OFD-style locking is currently limited to * covering the entire file. -- 2.11.4.GIT