lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 12 Jun 2018 13:10:15 +0000
From:   bugzilla-daemon@...zilla.kernel.org
To:     linux-ext4@...nel.org
Subject: [Bug 200043] New: lseek returns negative and inconsistent positions
 for directories on ext4 fs

https://bugzilla.kernel.org/show_bug.cgi?id=200043

            Bug ID: 200043
           Summary: lseek returns negative and inconsistent positions for
                    directories on ext4 fs
           Product: File System
           Version: 2.5
    Kernel Version: v4.17
          Hardware: All
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: ext4
          Assignee: fs_ext4@...nel-bugs.osdl.org
          Reporter: anatoly.trosinenko@...il.com
        Regression: No

When used on a directory FD residing on Ext4 FS, lseek with SEEK_END (and maybe
other whence-s) can return negative numbers and leave errno = 0. These numbers
in case of SEEK_END are (-1 - offset) and do not accumulate.

Reading the lseek(2) man page, I'm not absolutely sure it is a bug, but this
seems to be quite strange behavior.

How to reproduce:
1. Compile the following code:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[]) {
  int fd = open(argv[1], O_RDONLY);
  printf("fd = %d\n", fd);
  int res = lseek(fd, -10, SEEK_END);
  printf("lseek returned: %d (errno = %d)\n", res, errno);
  res = lseek(fd, -1, SEEK_END);
  printf("lseek returned: %d (errno = %d)\n", res, errno);
  res = lseek(fd, 0, SEEK_END);
  printf("lseek returned: %d (errno = %d)\n", res, errno);
  res = lseek(fd, -11, SEEK_SET);
  printf("lseek returned: %d (errno = %d)\n", res, errno);
  return 0;
}

2. Run it:

# ./lseek_negative /tmp # Suppose the tmpfs is mounted there
fd = 3
lseek returned -1 (errno = 22)
lseek returned -1 (errno = 22)
lseek returned -1 (errno = 22)
lseek returned -1 (errno = 22)
# ./lseek_negative / # Suppose the / is ext4
fd = 3
lseek returned -11 (errno = 0)
lseek returned -2 (errno = 0)
lseek returned -1 (errno = 0)    <-- Look at the errno value
lseek returned -1 (errno = 22)

-- 
You are receiving this mail because:
You are watching the assignee of the bug.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ