lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <200710150928.56916.arnd@arndb.de> Date: Mon, 15 Oct 2007 09:28:55 +0200 From: Arnd Bergmann <arnd@...db.de> To: linuxppc-dev@...abs.org Cc: Anton Blanchard <anton@...ba.org>, Thomas Gleixner <tglx@...utronix.de>, mingo@...e.hu, linux-kernel@...r.kernel.org Subject: Re: [PATCH] Rework hrtimer_nanosleep to make sys_compat_nanosleep easier On Monday 15 October 2007, Anton Blanchard wrote: > Pull the copy_to_user out of hrtimer_nanosleep and into the callers > (common_nsleep, sys_nanosleep) in preparation for converting > compat_sys_nanosleep to use hrtimers. Looks good, except for two micro-optimization: > Signed-off-by: Anton Blanchard <anton@...ba.org> Acked-by: Arnd Bergmann <arnd@...db.de> > @@ -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 && rmtp) { > + if (copy_to_user(rmtp, &rmt, sizeof(*rmtp))) > + return -EFAULT; > + } > + > + return ret; > } > If it's common to call sys_nanosleep with a NULL rmtp argument, we could save a few cycles using return hrtimer_nanosleep(&tu, rmtp ? &rmp : NULL, HRTIMER_MODE_REL, CLOCK_MONOTONIC); > diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c > index 57efe04..cce8c75 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 && rmtp) { > + if (copy_to_user(rmtp, &rmt, sizeof(*rmtp))) > + return -EFAULT; > + } > + > + return ret; > } I think it would be better here to propagate the move to a kernel *rmtp down to sys_clock_nanosleep so we get the same optimization in compat_sys_clock_nanosleep. That should probably also be a separate patch. I can do one if you don't do it first. Arnd <>< - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists