public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* question about prctl return value type
@ 2019-07-24 10:01 Yang Xu
  2019-07-24 10:48 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Xu @ 2019-07-24 10:01 UTC (permalink / raw)
  To: libc-help

Hi All

Since kernel syscall use long value for return, why we set int in sys/prctl.h(glibc). as below:

/include/sys/prctl.h

   1 #ifndef _SYS_PRCTL_H
   2 #include_next <sys/prctl.h>
   3 
   4 # ifndef _ISOMAC
   5 
   6 extern int __prctl (int __option, ...);
   7 
   8 # endif /* !_ISOMAC */
   9 #endif

If we calling prctl(PR_SET_TIMERSLACK, ULONG_MAX) and then calling prctl(PR_GET_TIMERSLACK), the value
will be truncated into INT_MAX(or convered into unsinged,it is UINT_MAX) on 64bit machine. Or, this is a 
glibc limitation for prctl interfaces?

ps:After kernel commit da8b44d5a9f ("timer: convert timer_slack_ns from unsigned long to u64"),
we limit under ULONG_MAX when calling PR_GET_TIMERSLACK. I think we can use long instead of int in sys/prctl.h.

Thanks
Yang Xu 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about prctl return value type
  2019-07-24 10:01 question about prctl return value type Yang Xu
@ 2019-07-24 10:48 ` Florian Weimer
  2019-07-25  7:53   ` Yang Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2019-07-24 10:48 UTC (permalink / raw)
  To: Yang Xu; +Cc: libc-help

* Yang Xu:

> Since kernel syscall use long value for return, why we set int in
> sys/prctl.h(glibc). as below:
>
> /include/sys/prctl.h
>
>    1 #ifndef _SYS_PRCTL_H
>    2 #include_next <sys/prctl.h>
>    3 
>    4 # ifndef _ISOMAC
>    5 
>    6 extern int __prctl (int __option, ...);
>    7 
>    8 # endif /* !_ISOMAC */
>    9 #endif

Note that the actual user-visible header is
sysdeps/unix/sysv/linux/sys/prctl.h, but it has the same issue.

> If we calling prctl(PR_SET_TIMERSLACK, ULONG_MAX) and then calling prctl(PR_GET_TIMERSLACK), the value
> will be truncated into INT_MAX(or convered into unsinged,it is UINT_MAX) on 64bit machine. Or, this is a 
> glibc limitation for prctl interfaces?

I think this is a glibc limitation/bug.  The return type should probably
be __register_t (a type that is currently woefully underused).  We
cannot simply change the return time because once applications are built
against the new prototype, we need to ensure that they also use the new
glibc.

Would you please file a bug for this?
<https://sourceware.org/bugzilla/> is our bug tracker.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about prctl return value type
  2019-07-24 10:48 ` Florian Weimer
@ 2019-07-25  7:53   ` Yang Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Yang Xu @ 2019-07-25  7:53 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-help

on 2019/07/24 18:48, Florian Weimer wrote:

> * Yang Xu:
>
>> Since kernel syscall use long value for return, why we set int in
>> sys/prctl.h(glibc). as below:
>>
>> /include/sys/prctl.h
>>
>>    1 #ifndef _SYS_PRCTL_H
>>    2 #include_next <sys/prctl.h>
>>    3 
>>    4 # ifndef _ISOMAC
>>    5 
>>    6 extern int __prctl (int __option, ...);
>>    7 
>>    8 # endif /* !_ISOMAC */
>>    9 #endif
> Note that the actual user-visible header is
> sysdeps/unix/sysv/linux/sys/prctl.h, but it has the same issue.
>
>> If we calling prctl(PR_SET_TIMERSLACK, ULONG_MAX) and then calling prctl(PR_GET_TIMERSLACK), the value
>> will be truncated into INT_MAX(or convered into unsinged,it is UINT_MAX) on 64bit machine. Or, this is a 
>> glibc limitation for prctl interfaces?
> I think this is a glibc limitation/bug.  The return type should probably
> be __register_t (a type that is currently woefully underused).  We
> cannot simply change the return time because once applications are built
> against the new prototype, we need to ensure that they also use the new
> glibc.
>
> Would you please file a bug for this?
> <https://sourceware.org/bugzilla/> is our bug tracker.

Hi Florian

I create a bug and cc you, url as below:
https://sourceware.org/bugzilla/show_bug.cgi?id=24850


Thanks 
Yang Xu

> Thanks,
> Florian
>
>
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-25  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 10:01 question about prctl return value type Yang Xu
2019-07-24 10:48 ` Florian Weimer
2019-07-25  7:53   ` Yang Xu

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 read-only IMAP folder(s) and NNTP newsgroup(s).