Page MenuHomeFreeBSD

settimeofday system call panic.
ClosedPublic

Authored by dchagin on Dec 26 2015, 9:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 29, 5:13 AM
Unknown Object (File)
Sat, Dec 7, 8:23 PM
Unknown Object (File)
Fri, Dec 6, 1:24 PM
Unknown Object (File)
Nov 28 2024, 11:32 PM
Unknown Object (File)
Nov 23 2024, 4:50 AM
Unknown Object (File)
Nov 19 2024, 4:56 PM
Unknown Object (File)
Nov 18 2024, 7:01 AM
Unknown Object (File)
Oct 29 2024, 6:57 AM
Subscribers

Details

Summary

Fix a kernel panic in case when the incorrect of seconds specified for settimeofday() and clock_settime() system calls.

Test Plan

#include <sys/time.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[])
{
struct timeval now;
struct timeval was;
int rc;

rc = gettimeofday(&was, NULL);
if (rc != 0) {

		printf("gettimeofday() failed, errno = %d\n", errno);
		return (-1);

}

now.tv_sec = -11111111111111;
now.tv_usec = 290944;

rc = settimeofday(&now, NULL);
if (rc == 0)

		printf("settimeofday() successful.\n");

else {

		printf("settimeofday() failed, errno = %d\n", errno);
		return (-1);

}

rc = settimeofday(&was, NULL);

return (0);
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1840
Build 1847: arc lint + arc unit

Event Timeline

dchagin retitled this revision from to settimeofday system call panic. Fix a kernel panic in case when the incorrect of seconds specified for settimeofday() and clock_settime() system calls..
dchagin updated this object.
dchagin edited the test plan for this revision. (Show Details)
dchagin edited edge metadata.
bjk added inline comments.
lib/libc/sys/clock_gettime.2
144

"The supplied timespec"

lib/libc/sys/gettimeofday.2
120

"The supplied timeval"

dchagin retitled this revision from settimeofday system call panic. Fix a kernel panic in case when the incorrect of seconds specified for settimeofday() and clock_settime() system calls. to settimeofday system call panic..
dchagin edited the test plan for this revision. (Show Details)
dchagin updated this object.

man changes.

kib edited edge metadata.

Well, as the immediate relief, the change is fine. But the real cause is in clock_ts_to_ct(), I think.

sys/kern/kern_time.c
401

Style: put '||' at the first if() line, we usually split long lines after the operator, not before.

This revision is now accepted and ready to land.Dec 27 2015, 10:27 AM
In D4714#99743, @kib wrote:

Well, as the immediate relief, the change is fine. But the real cause is in clock_ts_to_ct(), I think.

Thank you, Kostya!

I think that clock_ts_to_ct() should be rewritten to correctly handle the negative tv_sec value.
But by design settimeofday() and clock_settime() is not intended to take negative tv_sec, is why I suggest this fix.

This revision was automatically updated to reflect the committed changes.