This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)


On 04/04/2018 11:26 PM, Adhemerval Zanella wrote:
@@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...)
cmd = FCNTL_ADJUST_CMD (cmd); - if (cmd == F_SETLKW || cmd == F_SETLKW64)
-    return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg);
-
-  return fcntl_common (fd, cmd, arg);
+  switch (cmd)
+    {
+      case F_SETLKW:
+	return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
+      case F_GETLK64:
+      case F_OFD_GETLK:
+	{
+	  struct flock *flk = (struct flock *) arg;
+	  struct flock64 flk64 = flock_to_flock64 (flk);
+	  int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64);
+	  if (ret == -1)
+	    return -1;
+	  flk->l_type = flk64.l_type;
+	  flk->l_whence = flk64.l_whence;
+	  flk->l_start = flk64.l_start;
+	  flk->l_len = flk64.l_len;
+	  flk->l_pid = flk64.l_pid;
+	  return ret;

Doesn't this need an overflow check?

I think you should mention somewhere that this introduces new cancellation points.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]