mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chris@wirex.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.5.26 sys_stime() cleanup
Date: Fri, 19 Jul 2002 19:02:53 -0700	[thread overview]
Message-ID: <20020719190253.A10120@figure1.int.wirex.com> (raw)

Hi,

sys_stime() currently sets time directly without using the existing helper
functions.  This patch changes sys_stime() to use these functions which
helps LSM place only one security check in do_sys_settimeofday().

Using the helper functions changes this in two ways.  First,
last_time_offset is no longer zeroed.  This doesn't appear to be an
issue, since last_time_offset is used primarily on IA64, and sys_stime()
is not compiled for IA64.  Second, the gettimeofday offset is now accounted
for by moving to the helper function.  Does anyone see problems with
this change?

I've tested this patch, and it works for me.

thanks,
-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

===== time.c 1.6 vs edited =====
--- 1.6/kernel/time.c	Sun Jun  2 11:44:56 2002
+++ edited/time.c	Fri Jul 19 17:58:57 2002
@@ -41,6 +41,8 @@
 extern rwlock_t xtime_lock;
 extern unsigned long last_time_offset;
 
+int do_sys_settimeofday(struct timeval *tv, struct timezone *tz);
+
 #if !defined(__alpha__) && !defined(__ia64__)
 
 /*
@@ -75,21 +77,13 @@
 asmlinkage long sys_stime(int * tptr)
 {
 	int value;
+	struct timeval tv;
 
-	if (!capable(CAP_SYS_TIME))
-		return -EPERM;
 	if (get_user(value, tptr))
 		return -EFAULT;
-	write_lock_irq(&xtime_lock);
-	xtime.tv_sec = value;
-	xtime.tv_usec = 0;
-	last_time_offset = 0;
-	time_adjust = 0;	/* stop active adjtime() */
-	time_status |= STA_UNSYNC;
-	time_maxerror = NTP_PHASE_LIMIT;
-	time_esterror = NTP_PHASE_LIMIT;
-	write_unlock_irq(&xtime_lock);
-	return 0;
+	tv.tv_sec = value;
+	tv.tv_usec = 0;
+	return do_sys_settimeofday(&tv, NULL);
 }
 
 #endif

                 reply	other threads:[~2002-07-20  1:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020719190253.A10120@figure1.int.wirex.com \
    --to=chris@wirex.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome