[patch] adjtimex() modes argument checking
From: Michael Kerrisk
Date: Mon Jun 23 2008 - 04:18:53 EST
Hi Roman,
I see you added a number of new modes to adtimex() in 2.6.26-rc.
Since these are userspace-visible changes, please CC me, so
that they stand a chance of getting documented in man-pages.
(I discovered these changes only by accident.)
I also have some changes to suggest for argument checking, which,
if I understand the code correctly, prevent obvious screw-ups by
callers of adjtimex(). What do you think of the patch below?
Cheers,
Michael
--- linux-2.6.26-rc6/kernel/time/ntp.c 2008-06-22 09:05:05.000000000 +0200
+++ linux-2.6.26-rc6-p/kernel/time/ntp.c 2008-06-22 09:04:31.000000000 +0200
@@ -292,6 +292,16 @@
return -EINVAL;
}
+ /* These modes are the converse of one another */
+
+ if ((txc->modes & ADJ_MICRO) && (txc->modes & ADJ_NANO))
+ return -EINVAL;
+
+ /* Both of the following want to use txc->constant */
+
+ if ((txc->modes & ADJ_TIMECONST) && (txc->modes & ADJ_TAI))
+ return -EINVAL;
+
/* if the quartz is off by more than 10% something is VERY wrong ! */
if (txc->modes & ADJ_TICK)
if (txc->tick < 900000/USER_HZ ||
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/