kern/127213: sendfile on tmpfs data corruption

Anton Yuzhaninov citrin at citrin.ru
Mon Sep 8 17:50:03 UTC 2008


>Number:         127213
>Category:       kern
>Synopsis:       sendfile on tmpfs data corruption
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 08 17:50:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Anton Yuzhaninov
>Release:        FreeBSD 7.1-PRERELEASE amd64
>Organization:
Rambler
>Environment:
System: FreeBSD mx3.rambler.ru 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #1: Fri Sep 5 21:15:43 MSD 2008 root at mx3.rambler.ru:/usr/obj/usr/src/sys/MAIL amd64

>Description:
sendfile(2) currupts data for files on tmpfs
>How-To-Repeat:
1. Create tmpfs and write test file

# mount -t tmpfs tmpfs /spool/tmpfs
# echo 'this is test file' > /spool/tmpfs/tt
# cat /spool/tmpfs/tt
this is test file

2. Transfer this file using sendfile. E. g. using web server from port www/nginx

# cat nginx.conf
events {
    worker_connections  1024;
}

http {
    default_type  application/octet-stream;
    access_log off;
    sendfile   on;

    server {
        listen       8081;
        location / {
            root   /spool/tmpfs;
        }
    }
}

# nginx -c nginx.conf

Content of fetched file will be different garbage on each request:

# fetch -qo - http://127.0.0.1:8081/tt | hd
00000000  d4 98 7a 00 08 00 00 00  dc 98 7a 00 08 00 00 00  |Ԙz.....ܘz.....|
00000010  e4 98                                             |ä˜|
00000012

# fetch -qo - http://127.0.0.1:8081/tt | md5
ff035bff2dcf972ee7dfd023455997ef
# fetch -qo - http://127.0.0.1:8081/tt | md5
bb07cd1a0ede3c7af24e4a86a14b0493
# fetch -qo - http://127.0.0.1:8081/tt | md5
e84539257c2650da866a186435acc93d

With sendfile disbled in nginx.conf file is not corrupted,
but we need sendfile support for other application (where only sendfile supported).

>Fix:
Not known.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list