Project

General

Profile

Bug #2691

pcfs creates too big inode numbers, causing readdir() to fail

Added by Hans Rosenfeld about 8 years ago.

Status:
New
Priority:
Normal
Category:
kernel
Start date:
2012-05-06
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:

Description

There is this code in usr/src/uts/common/sys/fs/pc_node.h, which is used to create inode numbers for pcfs:

/*
 * Make a unique integer for a file
 */
#define    pc_makenodeid(BN, OFF, ATTR, SCLUSTER, ENTPS) \
    (ino_t)((ATTR) & PCA_DIR ?          \
        ((uint32_t)-(SCLUSTER) - 1) : \
        ((BN) * (ENTPS)) + ((OFF) / sizeof (struct pcdir)))

I've seen this to create inode numbers that are greater than a 32bit SIZE_MAX for files. This will cause readdir() to lose because of this check in usr/src/lib/libc/port/gen/readdir.c:

        /*
         * Make sure that the offset fits in 32 bits.
         */
        if (((off_t)dp64->d_off != dp64->d_off &&
            (uint64_t)dp64->d_off > (uint64_t)UINT32_MAX) ||
            dp64->d_ino > SIZE_MAX) {
                errno = EOVERFLOW;
                return (NULL);
        }

Because of this, a 32bit program without largefile support will fail to read directories correctly on such filesystems. It will correctly read all the directories and then fail on the first regular file. I have observed this with a gtk1 program and with a simple readdir test program.

Extending the cast to uint32_t to not only cover inodes for directories, but for all file types, seems to fix this. I don't think that this change will have negative side effects, but I'm not sure.


Files

pc_node.diff (534 Bytes) pc_node.diff Hans Rosenfeld, 2012-05-06 07:55 PM

Also available in: Atom PDF