linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Anton Blanchard <anton@samba.org>
Cc: linuxppc-dev@ozlabs.org, mingo@elte.hu,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] Hook compat_sys_nanosleep up to high res timer code
Date: Mon, 15 Oct 2007 08:11:03 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.0.9999.0710150804290.22612@localhost.localdomain> (raw)
In-Reply-To: <20071014231616.GA24519@kryten>

On Sun, 14 Oct 2007, Anton Blanchard wrote:
> Hi Arnd,
>  
> > The code looks correct, but I think it would be nicer to change 
> > hrtimer_nanosleep to take a kernel pointer and have all three
> > callers (common_nsleep, sys_nanosleep and compat_sys_nanosleep)
> > do the copy_to_user/put_compat_timespec in the caller.
> 
> Good idea, I had considered that but thought a larger cleanup might run
> afoul of the merge rules :)

Looks good, except ....
 
> --- a/kernel/compat.c
> +++ b/kernel/compat.c
> @@ -40,62 +40,26 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user
>  			__put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
>  }

Can you put this into a separate patch please ?
  
> --- a/kernel/hrtimer.c
> +++ b/kernel/hrtimer.c
>  	restart = &current_thread_info()->restart_block;
> @@ -1353,7 +1347,8 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
>  asmlinkage long
>  sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
>  {
> -	struct timespec tu;
> +	struct timespec tu, rmt;
> +	int ret;
>  
>  	if (copy_from_user(&tu, rqtp, sizeof(tu)))
>  		return -EFAULT;
> @@ -1361,7 +1356,14 @@ sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
>  	if (!timespec_valid(&tu))
>  		return -EINVAL;
>  
> -	return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
> +	ret = hrtimer_nanosleep(&tu, &rmt, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
> +
> +	if (ret) {

Can you check for rmtp as well ? rmtp is optional and can be NULL

> +		if (copy_to_user(rmtp, &rmt, sizeof(*rmtp)))
> +			return -EFAULT;
> +	}
> +
> +	return ret;
>  }
>  
>  /*
> diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
> index 7a15afb..fc7dac2 100644
> --- a/kernel/posix-timers.c
> +++ b/kernel/posix-timers.c
> @@ -980,9 +980,19 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
>  static int common_nsleep(const clockid_t which_clock, int flags,
>  			 struct timespec *tsave, struct timespec __user *rmtp)
>  {
> -	return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
> +	struct timespec rmt;
> +	int ret;
> +
> +	ret = hrtimer_nanosleep(tsave, &rmt, flags & TIMER_ABSTIME ?
>  				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
>  				 which_clock);
> +
> +	if (ret) {

Ditto.

> +		if (copy_to_user(rmtp, &rmt, sizeof(*rmtp)))
> +			return -EFAULT;
> +	}
> +
> +	return ret;
>  }

Thanks,

	tglx

  reply	other threads:[~2007-10-15  6:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-14 21:54 [PATCH] Hook compat_sys_nanosleep up to high res timer code Anton Blanchard
2007-10-14 22:28 ` Arnd Bergmann
2007-10-14 23:16   ` Anton Blanchard
2007-10-15  6:11     ` Thomas Gleixner [this message]
2007-10-15  6:38       ` [PATCH] Rework hrtimer_nanosleep to make sys_compat_nanosleep easier Anton Blanchard
2007-10-15  6:43         ` [PATCH] Hook compat_sys_nanosleep up to high res timer code Anton Blanchard
2007-10-15  7:28         ` [PATCH] Rework hrtimer_nanosleep to make sys_compat_nanosleep easier Arnd Bergmann
2007-10-15 21:06           ` Anton Blanchard
2007-10-15 21:13           ` [PATCH] Hook compat_sys_nanosleep up to high res timer code Anton Blanchard

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=alpine.LFD.0.9999.0710150804290.22612@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=anton@samba.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mingo@elte.hu \
    /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;
as well as URLs for NNTP newsgroup(s).