From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 25 19:58:40 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5C9D716A4E7; Tue, 25 Jul 2006 19:58:40 +0000 (UTC) (envelope-from scheidell@secnap.net) Received: from scanner.secnap.net (scanner.secnap.net [204.89.241.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1BC2D43D46; Tue, 25 Jul 2006 19:58:40 +0000 (GMT) (envelope-from scheidell@secnap.net) Received: by scanner.secnap.net (Postfix, from userid 1001) id 4E5CF137BB7; Tue, 25 Jul 2006 15:58:39 -0400 (EDT) To: FreeBSD-gnats-submit@freebsd.org From: Michael Scheidell X-send-pr-version: 3.113 X-GNATS-Notify: Message-Id: <20060725195839.4E5CF137BB7@scanner.secnap.net> Date: Tue, 25 Jul 2006 15:58:39 -0400 (EDT) Cc: freebsd-hackers@freebsd.org Subject: FBSD 5.5 broke nanosleep in libc_r X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2006 19:58:40 -0000 >Submitter-Id: current-users >Originator: Michael Scheidel >Organization: SECNAP Network Security >Confidential: >Synopsis: FBSD 5.5 broke nanosleep in libc_r >Severity: serious >Priority: medium >Category: threads >Class: sw-bug >Release: FreeBSD 5.5-RELEASE-p2 i386 >Environment: System: FreeBSD audit18.hackertrap.net 5.5-RELEASE-p2 FreeBSD 5.5-RELEASE-p2 #6: Tue Jul 25 10:34:16 EDT 2006 admin@audit18.hackertrap.net:/usr/obj/usr/src/sys/HACKERTRAP_305 i386 >Description: nanosleep returns after time+delta if wallclock changed with libc_r >How-To-Repeat: 5.4 works, not including libc_r in 5.5 works Given this POC: int main( int argc, char **argv ) { char execs1[256] = "/bin/date +A%Y%m%d%H%M.%S"; char execs2[256] = "/bin/date +B%Y%m%d%H%M.%S"; int a; while ( 1) { system( execs1 ); usleep( 500*1000); system( execs2 ); } return 0; } /* main */ compile with: cc -g -c nanotest.c cc -g -o nanotest nanotest.o -lc_r run it, set clock back 45 seconds, observe 45 second delay >Fix: compile with: cc -g -c nanotest.c cc -g -o nanotest nanotest.o or compile on 5.4 system. (I have only tried compiling and running on 5.4 system. I have not yet tried compiling on 5.4 and running on 5.5 or visa versa) I used ntpdate -su to change clock. (I have an internal system that is 45 seconds behind, just for this test) output with 5.4 or without libc_r shows wallclock 'stepping' when you change time no delay in display. 5.5 with libc_r shows stepping if moving clock head, but if you move wallclock back 45 seconds, display stops for 45 seconds.