Re: Xinetd /tmp race?

From: Casper Dik (casperat_private)
Date: Sat Nov 14 1998 - 03:27:17 PST

  • Next message: //Stany: "Re: SCO World Script Vulnerabilities"

    >1. I don't think that this is safe over NFS.
    
    Not with NFSv2, but it is safe w/ NFSv3.
    
    >The Linux open(2) manpage says:
    >
    >       O_EXCL When used with O_CREAT, if the file already  exists
    >              it  is  an error and the open will fail.  O_EXCL is
    >              broken on NFS file systems, programs which rely  on
    >              it for performing locking tasks will contain a race
    >              condition.  The solution for performing atomic file
    >              locking using a lockfile is to create a unique file
    >              on the same fs (e.g.,  incorporating  hostname  and
    >              pid),  use  link(2)  to make a link to the lockfile
    >              and use stat(2) on the unique file to check if  its
    >              link  count  has  increased  to  2.  Do not use the
    >              return value of the link() call.
    >
    >2. The current behaviour is to append to an existing file if it
    >exists, or to create a new file if it doesn't. Adding O_EXCL would
    >break this behaviour.
    
    >IMHO, a better approach in this case would be to use a directory which
    >isn't world-writable e.g. /var/run, /var/log etc.
    
    Seconded.
    
    Casper
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:23:21 PDT