NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/47980: NFS over-quota not detected if utimes() called before fsync()/close()

>Number:         47980
>Category:       kern
>Synopsis:       NFS over-quota not detected if utimes() called before 
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 01 11:40:00 +0000 2013
>Originator:     Edgar Fuß <>
>Release:        NetBSD 6.1
        Mathematisches Institut der Uni Bonn
System: NetBSD 6.1 NetBSD 6.1 (MI12serv) #17: Sun May 19 
18:22:29 CEST 2013
Architecture: x86_64
Machine: amd64
        On an NFS-mounted file system, when you try to write to a file and are
        over-quota, the write() succeeds, but a following fsync() or close() 
        However, when you insert a utimes() or futimes() call after the write(),
        the fsync() or close() succeed and you end up with a zero-length file.

        The effect for us is dovecot's LDA not bouncing mail for users having 
        their mail quota, but reporting successful delivery and losing mail.
        Run this (compiled with either -DUTIMES or -DFUTIMES) with an argument
        naming a file on an NFS:
        #include <unistd.h>
        #include <err.h>
        #include <fcntl.h>
        #include <sys/time.h>

        int main(int argc, char *argv[]) {
                int fd;
                if (argc != 2) errx(1, "argc");
                if (!*argv[1]) errx(1, "argv");
                if ((fd = open(argv[1], O_RDWR | O_CREAT, 0666)) < 0) err(1, 
                if (write(fd, &fd, 1) != 1) err(1, "write");
        #ifdef UTIMES
                if (utimes(argv[1], NULL) < 0) err(1, "utimes");
        #ifdef FUTIMES
                if (futimes(fd, NULL) < 0) err(1, "futimes");
        #ifdef FSYNC
                if (fsync(fd) < 0) err(1, "fsync");
                if (close(fd) < 0) err(1, "close");

Home | Main Index | Thread Index | Old Index