From: Rodolfo Giometti <giometti@enneenne.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] LinuxPPS (with new syscalls API)
Date: Wed, 27 Jun 2007 19:45:40 +0200 [thread overview]
Message-ID: <20070627174537.GM13886@enneenne.com> (raw)
In-Reply-To: <1182960660.1170.12.camel@pmac.infradead.org>
[-- Attachment #1: Type: text/plain, Size: 812 bytes --]
On Wed, Jun 27, 2007 at 05:11:00PM +0100, David Woodhouse wrote:
> No, because you're passing a _kernel_ pointer to sys_time_pps_fetch()
> where it expects a userspace pointer. Use compat_alloc_user_space() to
> find somewhere to put it in user space, instead. Or change your internal
> __sys_time_pps_fetch() function to take a number of ticks instead of a
> pointer to a timespec, then call that directly with appropriate
> arguments, from both the normal and compat syscall routines.
Ok. Please see the attached patch.
Thanks a lot,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti@enneenne.com
Linux Device Driver giometti@gnudd.com
Embedded Systems giometti@linux.it
UNIX programming phone: +39 349 2432127
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2818 bytes --]
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index befe292..820cc9a 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -26,6 +26,7 @@
#include <linux/init.h>
#include <linux/linkage.h>
#include <linux/sched.h>
+#include <linux/compat.h>
#include <linux/pps.h>
#include <asm/uaccess.h>
@@ -284,13 +285,12 @@ sys_time_pps_getcap_exit:
return ret;
}
-asmlinkage long sys_time_pps_fetch(int source, const int tsformat,
+static long __sys_time_pps_fetch(int source, const int tsformat,
struct pps_info __user *info,
- const struct timespec __user *timeout)
+ const struct timespec *timeout)
{
unsigned long ticks;
struct pps_info pi;
- struct timespec to;
int ret;
pps_dbg("%s: source %d", __FUNCTION__, source);
@@ -317,24 +317,19 @@ asmlinkage long sys_time_pps_fetch(int source, const int tsformat,
pps_source[source].go = 0;
/* Manage the timeout */
- if (timeout) {
- ret = copy_from_user(&to, timeout, sizeof(struct timespec));
- if (ret)
- goto sys_time_pps_fetch_exit;
- if (to.tv_sec != -1) {
- pps_dbg("timeout %ld.%09ld", to.tv_sec, to.tv_nsec);
- ticks = to.tv_sec * HZ;
- ticks += to.tv_nsec / (NSEC_PER_SEC / HZ);
-
- if (ticks != 0) {
- ret = wait_event_interruptible_timeout(
- pps_source[source].queue,
- pps_source[source].go, ticks);
- if (ret == 0) {
- pps_dbg("timeout expired");
- ret = -ETIMEDOUT;
- goto sys_time_pps_fetch_exit;
- }
+ if (timeout->tv_sec != -1) {
+ pps_dbg("timeout %ld.%09ld", timeout->tv_sec, timeout->tv_nsec);
+ ticks = timeout->tv_sec * HZ;
+ ticks += timeout->tv_nsec / (NSEC_PER_SEC / HZ);
+
+ if (ticks != 0) {
+ ret = wait_event_interruptible_timeout(
+ pps_source[source].queue,
+ pps_source[source].go, ticks);
+ if (ret == 0) {
+ pps_dbg("timeout expired");
+ ret = -ETIMEDOUT;
+ goto sys_time_pps_fetch_exit;
}
}
} else
@@ -362,6 +357,44 @@ sys_time_pps_fetch_exit:
return ret;
}
+asmlinkage long sys_time_pps_fetch(int source, const int tsformat,
+ struct pps_info __user *info,
+ const struct timespec __user *timeout)
+{
+ int ret;
+ struct timespec to;
+
+ if (timeout) {
+ ret = copy_from_user(&to, timeout, sizeof(struct timespec));
+ if (ret)
+ return ret;
+ }
+ else
+ to.tv_sec = -1;
+
+ return __sys_time_pps_fetch(source, tsformat, info, timeout);
+}
+
+#ifdef CONFIG_COMPAT
+asmlinkage long compat_sys_time_pps_fetch(int source, const int tsformat,
+ struct pps_info __user *info,
+ const struct compat_timespec __user *timeout)
+{
+ int ret;
+ struct timespec to;
+
+ if (timeout) {
+ ret = get_compat_timespec(&to, timeout);
+ if (ret)
+ return -EFAULT;
+ }
+ else
+ to.tv_sec = -1;
+
+ return __sys_time_pps_fetch(source, tsformat, info, &to);
+}
+#endif
+
/*
* Module staff
*/
next prev parent reply other threads:[~2007-06-27 17:44 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 10:06 [PATCH] LinuxPPS (with new syscalls API) Rodolfo Giometti
2007-06-26 10:57 ` David Woodhouse
2007-06-26 17:06 ` Rodolfo Giometti
2007-06-26 17:38 ` David Woodhouse
2007-06-26 18:13 ` Rodolfo Giometti
2007-06-26 18:20 ` David Woodhouse
2007-06-27 10:14 ` Rodolfo Giometti
2007-06-27 10:18 ` David Woodhouse
2007-06-27 12:58 ` Rodolfo Giometti
2007-06-27 16:11 ` David Woodhouse
2007-06-27 17:45 ` Rodolfo Giometti [this message]
2007-06-27 17:49 ` David Woodhouse
2007-06-27 22:46 ` Rodolfo Giometti
2007-06-28 8:08 ` David Woodhouse
2007-06-28 8:15 ` Rodolfo Giometti
2007-06-28 8:31 ` David Woodhouse
2007-06-28 8:40 ` Rodolfo Giometti
2007-06-28 11:44 ` David Woodhouse
2007-06-28 14:15 ` Rodolfo Giometti
2007-06-28 16:14 ` [PATCH] LinuxPPS (with new syscalls API) - new version Rodolfo Giometti
2007-06-29 11:38 ` David Woodhouse
2007-06-29 15:08 ` Rodolfo Giometti
2007-06-29 15:25 ` David Woodhouse
2007-06-29 15:38 ` Rodolfo Giometti
2007-06-29 15:41 ` David Woodhouse
2007-06-29 16:23 ` Rodolfo Giometti
2007-06-29 16:23 ` David Woodhouse
2007-06-29 16:36 ` Rodolfo Giometti
2007-06-29 16:38 ` David Woodhouse
2007-06-29 15:55 ` David Woodhouse
2007-06-29 16:34 ` Rodolfo Giometti
2007-06-29 16:40 ` David Woodhouse
2007-06-30 17:13 ` Rodolfo Giometti
2007-07-01 7:13 ` Stephen Rothwell
2007-07-01 19:24 ` Rodolfo Giometti
2007-07-10 16:01 ` Lennart Sorensen
2007-07-10 16:36 ` Rodolfo Giometti
2007-07-10 16:36 ` David Woodhouse
2007-07-10 16:44 ` Rodolfo Giometti
2007-07-10 22:03 ` Lennart Sorensen
2007-07-11 8:06 ` Rodolfo Giometti
2007-07-11 15:22 ` Lennart Sorensen
2007-07-11 16:32 ` Rodolfo Giometti
2007-07-11 1:18 ` Roman Zippel
2007-07-11 15:24 ` Lennart Sorensen
2007-07-11 16:35 ` Rodolfo Giometti
2007-07-11 17:34 ` Roman Zippel
2007-07-01 12:03 ` David Woodhouse
2007-07-01 19:27 ` Rodolfo Giometti
2007-07-03 9:48 ` Rodolfo Giometti
2007-07-03 13:09 ` David Woodhouse
2007-07-03 13:21 ` Rodolfo Giometti
2007-07-09 13:19 ` Rodolfo Giometti
2007-07-10 16:05 ` David Woodhouse
2007-07-10 16:38 ` Rodolfo Giometti
2007-07-11 9:17 ` David Woodhouse
2007-07-11 10:46 ` Rodolfo Giometti
2007-06-30 8:38 ` Christoph Hellwig
2007-06-30 17:06 ` Rodolfo Giometti
2007-07-08 9:05 ` Oleg Verych
2007-07-09 9:16 ` Rodolfo Giometti
2007-07-09 10:56 ` Makefiles for GNU make (Re: [PATCH] LinuxPPS (with new syscalls API) - new version) Oleg Verych
2007-07-09 10:57 ` Rodolfo Giometti
[not found] <fa.KzVWiacZsGdGiMxLldFOOPOdIEw@ifi.uio.no>
[not found] ` <fa.TdDfr0FpGG8OjqtqWj6RNRusuU0@ifi.uio.no>
[not found] ` <fa.qT2j8q7/hQ2xVpeJCg7VGv+FvpI@ifi.uio.no>
[not found] ` <fa.RLNIoDXtVxFnlYMPJh2Q2+yDDOk@ifi.uio.no>
2007-06-26 23:33 ` [PATCH] LinuxPPS (with new syscalls API) Robert Hancock
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=20070627174537.GM13886@enneenne.com \
--to=giometti@enneenne.com \
--cc=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--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