Lecture 17 - Network File System (NFS) Continued and Security

December 8, 2014

Table of Contents

  1. Network File System
    1. Some New Problems With NFS
    2. NFS Security: What Can Go Wrong?
  2. Security

Author: Amy Drafahl


Network File System Continued

Instead of having the client open the file itself to read and write, the kernel uses NFS for the client in order to use files.

Unmodified Client Code:
fd=open("foo", O_RDONLY)
read(fd, buf, sizeof(buf))
write(fd, buf, sizeof(buf))

Kernel using NFS

Some New Problems With NFS

  1. Performance
    • There are extra layers before reaching the files because it has to go through the network. Client and Server Responses
    • The hard disk can take around 20 ms for a write so it is tempting to "cheat" with the client or server by putting the write inside a buffer without writing yet and sending back a response as if it were written.
      • It is normal for the client to "cheat" this way with file systems and it can always use fsync if it needs to clear the buffers.
      • Servers do not hold any information about the client's state because NFS is a stateless protocal. So server crashes and reboots won't effect the client but the buffer holding any writes will be lost. In order to cheat, the server will need flash memory and a log so that it can recover the writes.
    • Peformance benchmark
      • Using SPEC SFS 2014 Benchmark for NFS or CIFS with cluster FS on vanilla hardware. 96 disks with 600 GB at 10 KRPM, infiniband 2.5 GB/port, 26 TB disk and three 54 GiB RAM network. Client and Server Responses
  2. Sending file descriptors without knowing the client state
    • NFS uses a file handle which uniquely identifies the file on the file server and persists across reboot. It is an integer containing the inode number.
    • If there are multiple file systems, the file handle also contains the device number. The server then looks at the mount table to resolve the device number.
    • Note that if you remove a file that is still being read then the file will not show up anymore but it will still exist in the system. NFS renames the file into a ".nfs" file and when the kernel of the client sees that it is done being used, it will unlink the file.
  3. Messages lost
    • One example of a lost message is if the server response is lost. In this case the client might resend the request which could result in an error.
      • One solution is to use an idempotent cache. If the same request is sent from the client to the server then the server will resend the same response as previously.
      • client code: if ( (unlink() != 0) && (errno != ENOENF) )
                       error;
    • Another example is if the server reuses inode numbers which is common. Reuse of Inode Numbers
      • One solution is to add a serial number to the file number. Every create file adds one to the serial number so that each file has a different number.
  4. Some other client deletes .nfs files
    • If NFS can't find the file for the client trying to access it, it will report an error ESTALE for having a stale file handle.
  5. NFS doesn't promise read after write consistency No Read After Write Consistency
    • Clock skew also worsens this. This can create an inaccurate timestamp for files because the client and server clocks can be different from each other.
  6. NFS clients cache writes
    • Example:
      ssh x create foo
      ssh y use foo
      This last command can't see foo in order to use it correctly.
    • One solution is to have NFS guarentee that when the client closes the file, NFS will flush all the write buffers and make sure it works. Only then will it return to the client. So close() can be slow and can also fail.

NFS Security: What Can Go Wrong?

Security


References

  1. Doen et al. Lecture 17 Fall 2010
    This was used to get an idea on how to use HTML for the notes.