Date: Tue, 21 Jul 2009 21:52:23 GMT From: Aragon Gouveia <aragon@phat.za.net> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/136971: [patch] devel/ccache mmap fix for 8.0-BETA2 Message-ID: <200907212152.n6LLqNc5098376@www.freebsd.org> Resent-Message-ID: <200907212200.n6LM0GnM066046@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 136971 >Category: ports >Synopsis: [patch] devel/ccache mmap fix for 8.0-BETA2 >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jul 21 22:00:16 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Aragon Gouveia >Release: 8.0-BETA2 >Organization: >Environment: FreeBSD fuzz.geek.sh 8.0-BETA2 FreeBSD 8.0-BETA2 #0: Tue Jul 21 00:28:37 SAST 2009 root@fuzz.geek.sh:/usr/obj/usr/src/sys/FUZZ amd64 >Description: devel/ccache has a bug in its use of mmap() that reveals itself since a recent change in 8-CURRENT discussed here: http://lists.freebsd.org/pipermail/freebsd-hackers/2009-July/029064.html Mel Flynn later posted a ccache patch: http://lists.freebsd.org/pipermail/freebsd-hackers/2009-July/029141.html I've tested Mel's fix and can confirm it fixes ccache for me. I've repackaged his work as a diff against files/patch-md4 and it's attached. >How-To-Repeat: >Fix: Patch attached with submission follows: --- files/patch-md4.orig 2004-10-13 05:36:42.000000000 +0200 +++ files/patch-md4 2009-07-21 23:43:36.000000000 +0200 @@ -17,8 +17,8 @@ void cc_log(const char *format, ...); void fatal(const char *msg); ---- hash.c.orig Wed Sep 8 21:36:22 2004 -+++ hash.c Wed Sep 8 21:36:25 2004 +--- hash.c.orig 2004-09-13 12:38:30.000000000 +0200 ++++ hash.c 2009-07-21 23:37:00.000000000 +0200 @@ -20,17 +20,22 @@ */ @@ -46,7 +46,7 @@ } void hash_string(const char *s) -@@ -46,35 +51,40 @@ +@@ -46,35 +51,44 @@ /* add contents of a file to the hash */ void hash_file(const char *fname) { @@ -72,12 +72,16 @@ + close(fd); + fatal(__FUNCTION__); + } -+ buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0); -+ if (buf == MAP_FAILED) { -+ cc_log("Failed to mmap %s\n", fname); -+ close(fd); -+ fatal(__FUNCTION__); -+ } ++ if( stats.st_size == 0 ) ++ buf = NULL; ++ else { ++ buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0); ++ if (buf == MAP_FAILED) { ++ cc_log("Failed to mmap %s\n", fname); ++ close(fd); ++ fatal(__FUNCTION__); ++ } ++ } + + hash_buffer(buf, stats.st_size); close(fd); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907212152.n6LLqNc5098376>