From: "Dong Feng" <middle.fengdong@gmail.com>
To: "Nick Piggin" <nickpiggin@yahoo.com.au>
Cc: "Christoph Lameter" <clameter@sgi.com>, "Andi Kleen" <ak@suse.de>,
"Arjan van de Ven" <arjan@infradead.org>,
"Paul Mackerras" <paulus@samba.org>,
"David Howells" <dhowells@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: How is Code in do_sys_settimeofday() safe in case of SMP and Nest Kernel Path?
Date: Sun, 1 Oct 2006 00:09:24 +0800 [thread overview]
Message-ID: <a2ebde260609300909l5f33c152xa331f7600be67f6b@mail.gmail.com> (raw)
In-Reply-To: <451E8143.5030300@yahoo.com.au>
On Sat, 30 Sep 2006, Nick Piggin wrote
>
> You should write a patch and send it to Mister Morton.
>
> --
> SUSE Labs, Novell Inc.
> Send instant messages to your online friends http://au.messenger.yahoo.com
>
>
This is a patch for your review.
--- kernel/time.c.orig 2006-09-30 23:21:29.000000000 +0800
+++ kernel/time.c 2006-09-30 23:38:18.000000000 +0800
@@ -107,7 +107,16 @@ asmlinkage long sys_gettimeofday(struct
return -EFAULT;
}
if (unlikely(tz != NULL)) {
- if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
+ struct timezone ktz;
+ unsigned long seq;
+
+ do {
+ seq = read_seqbegin(&xtime_lock);
+ ktz.tz_minuteswest = sys_tz.tz_minuteswest;
+ ktz.tz_dsttime = sys_tz.tz_dsttime;
+ } while (unlikely(read_seqretry(&xtime_lock, seq)));
+
+ if (copy_to_user(tz, &ktz, sizeof(ktz)))
return -EFAULT;
}
return 0;
@@ -164,12 +173,16 @@ int do_sys_settimeofday(struct timespec
if (tz) {
/* SMP safe, global irq locking makes it work. */
- sys_tz = *tz;
- if (firsttime) {
- firsttime = 0;
- if (!tv)
- warp_clock();
+ write_seqlock_irq(&xtime_lock);
+ {
+ sys_tz = *tz;
+ if (firsttime) {
+ firsttime = 0;
+ if (!tv)
+ warp_clock();
+ }
}
+ write_sequnlock_irq(&xtime_lock);
}
if (tv)
{
next prev parent reply other threads:[~2006-09-30 16:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-29 14:33 Dong Feng
2006-09-29 16:05 ` Christoph Lameter
2006-09-29 16:16 ` Dong Feng
2006-09-30 14:37 ` Nick Piggin
2006-09-30 15:03 ` Andi Kleen
2006-09-30 17:13 ` Christoph Lameter
2006-10-02 10:08 ` Samuel Tardieu
2006-10-03 8:03 ` Pavel Machek
2006-10-03 10:03 ` Andi Kleen
2006-09-30 16:09 ` Dong Feng [this message]
2006-09-30 17:26 ` Christoph Lameter
2006-10-01 3:48 ` Nick Piggin
2006-10-01 12:22 ` Dong Feng
2006-10-02 10:12 ` Samuel Tardieu
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=a2ebde260609300909l5f33c152xa331f7600be67f6b@mail.gmail.com \
--to=middle.fengdong@gmail.com \
--cc=ak@suse.de \
--cc=arjan@infradead.org \
--cc=clameter@sgi.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=paulus@samba.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