On Fri, 2021-03-05 at 15:42 +0800, chensong wrote:
> 
> > > > 
> > > > +COBALT_SYSCALL(sem_timedwait_time64, primary,
> > > > +              (struct cobalt_sem_shadow __user *u_sem,
> > > > +               const struct __kernel_timespec __user *u_ts))
> > > > +{
> > > > +       struct timespec64 ts64;
> > > > +
> > > > +       if (get_timespec64(&ts64, u_ts))
> > > 
> > > get_timespec64 didn't exist until kernel 4.13, shall we take care of this?
> > > get_timespec64 uses copy_from_user, is  there any side effect?
> > 
> > Yes and yes. I already noticed it but did not send out v2 due to some
> > other this I have to address first. Still trying to find a way that
> > allows us to prevent duplication all the necessary helpers...
> 
> Or we don't use helpers, like this
> struct __kernel_timespec kts;
> struct timespec64 ts64;
> 
> cobalt_copy_from_user(&kts, u_ts, sizeof(kts));
> 
> ts64.tv_sec = kts.tv_sec;
> 
> i'm working on clock.c, and will submit patches, please review.

This is not correct in case of a compat syscall. We have different
padding between kernel and application which needs to be addressed.
That can be done nicely in a helper which can check the context it is
being called in. (See get_timespec64() of a kernel that has it)

As you pointed out we can not use get_timespec64() as is, we need a
cobalt version of it.

Please wait for v2, you will see...


> 

Reply via email to