All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value
@ 2018-12-05 15:29 Philippe Gerum
  2018-12-05 16:17 ` Jan Kiszka
  2018-12-06  7:04 ` Jan Kiszka
  0 siblings, 2 replies; 7+ messages in thread
From: Philippe Gerum @ 2018-12-05 15:29 UTC (permalink / raw)
  To: xenomai; +Cc: Jan Kiszka, Philippe Gerum

In order to prevent unexpected truncation of pointer args in userland
with the LP64 data model, libcobalt's fcntl() wrapper should accept a
long (3rd) argument.

Anticipate this change in the corresponding syscall implementation in
the Cobalt core.  The updated ABI remains backward-compatible for
current users.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/cobalt/posix/io.c | 2 +-
 kernel/cobalt/posix/io.h | 2 +-
 kernel/cobalt/rtdm/fd.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index ef4a0fea2..f35aaf8cd 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -53,7 +53,7 @@ COBALT_SYSCALL(close, lostage, (int fd))
 	return rtdm_fd_close(fd, 0);
 }
 
-COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
+COBALT_SYSCALL(fcntl, current, (int fd, int cmd, long arg))
 {
 	return rtdm_fd_fcntl(fd, cmd, arg);
 }
diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
index 647f7f3e9..6f20dbedd 100644
--- a/kernel/cobalt/posix/io.h
+++ b/kernel/cobalt/posix/io.h
@@ -37,7 +37,7 @@ COBALT_SYSCALL_DECL(socket,
 
 COBALT_SYSCALL_DECL(close, (int fd));
 
-COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, int arg));
+COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, long arg));
 
 COBALT_SYSCALL_DECL(ioctl,
 		    (int fd, unsigned int request, void __user *arg));
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index 807a11eae..f3b6444c3 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -371,7 +371,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
 {
 	struct rtdm_fd *fd;
 	va_list ap;
-	int arg;
+	long arg;
 	int ret;
 
 	fd = rtdm_fd_get(ufd, 0);
@@ -379,7 +379,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
 		return PTR_ERR(fd);
 
 	va_start(ap, cmd);
-	arg = va_arg(ap, int);
+	arg = va_arg(ap, long);
 	va_end(ap);
 
 	switch (cmd) {
-- 
2.17.2



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

* Re: [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value
  2018-12-05 15:29 [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Philippe Gerum
@ 2018-12-05 16:17 ` Jan Kiszka
  2018-12-05 16:29   ` Philippe Gerum
  2018-12-06  7:04 ` Jan Kiszka
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Kiszka @ 2018-12-05 16:17 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 05.12.18 16:29, Philippe Gerum wrote:
> In order to prevent unexpected truncation of pointer args in userland
> with the LP64 data model, libcobalt's fcntl() wrapper should accept a
> long (3rd) argument.
> 
> Anticipate this change in the corresponding syscall implementation in
> the Cobalt core.  The updated ABI remains backward-compatible for
> current users.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>   kernel/cobalt/posix/io.c | 2 +-
>   kernel/cobalt/posix/io.h | 2 +-
>   kernel/cobalt/rtdm/fd.c  | 4 ++--
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
> index ef4a0fea2..f35aaf8cd 100644
> --- a/kernel/cobalt/posix/io.c
> +++ b/kernel/cobalt/posix/io.c
> @@ -53,7 +53,7 @@ COBALT_SYSCALL(close, lostage, (int fd))
>   	return rtdm_fd_close(fd, 0);
>   }
>   
> -COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
> +COBALT_SYSCALL(fcntl, current, (int fd, int cmd, long arg))
>   {
>   	return rtdm_fd_fcntl(fd, cmd, arg);
>   }
> diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
> index 647f7f3e9..6f20dbedd 100644
> --- a/kernel/cobalt/posix/io.h
> +++ b/kernel/cobalt/posix/io.h
> @@ -37,7 +37,7 @@ COBALT_SYSCALL_DECL(socket,
>   
>   COBALT_SYSCALL_DECL(close, (int fd));
>   
> -COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, int arg));
> +COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, long arg));
>   
>   COBALT_SYSCALL_DECL(ioctl,
>   		    (int fd, unsigned int request, void __user *arg));
> diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
> index 807a11eae..f3b6444c3 100644
> --- a/kernel/cobalt/rtdm/fd.c
> +++ b/kernel/cobalt/rtdm/fd.c
> @@ -371,7 +371,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>   {
>   	struct rtdm_fd *fd;
>   	va_list ap;
> -	int arg;
> +	long arg;
>   	int ret;
>   
>   	fd = rtdm_fd_get(ufd, 0);
> @@ -379,7 +379,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>   		return PTR_ERR(fd);
>   
>   	va_start(ap, cmd);
> -	arg = va_arg(ap, int);
> +	arg = va_arg(ap, long);
>   	va_end(ap);
>   
>   	switch (cmd) {
> 

And we no longer need to do anything for compat?

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


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

* Re: [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value
  2018-12-05 16:17 ` Jan Kiszka
@ 2018-12-05 16:29   ` Philippe Gerum
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2018-12-05 16:29 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On 12/5/18 5:17 PM, Jan Kiszka wrote:
> On 05.12.18 16:29, Philippe Gerum wrote:
>> In order to prevent unexpected truncation of pointer args in userland
>> with the LP64 data model, libcobalt's fcntl() wrapper should accept a
>> long (3rd) argument.
>>
>> Anticipate this change in the corresponding syscall implementation in
>> the Cobalt core.  The updated ABI remains backward-compatible for
>> current users.
>>
>> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
>> ---
>>   kernel/cobalt/posix/io.c | 2 +-
>>   kernel/cobalt/posix/io.h | 2 +-
>>   kernel/cobalt/rtdm/fd.c  | 4 ++--
>>   3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
>> index ef4a0fea2..f35aaf8cd 100644
>> --- a/kernel/cobalt/posix/io.c
>> +++ b/kernel/cobalt/posix/io.c
>> @@ -53,7 +53,7 @@ COBALT_SYSCALL(close, lostage, (int fd))
>>       return rtdm_fd_close(fd, 0);
>>   }
>>   -COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
>> +COBALT_SYSCALL(fcntl, current, (int fd, int cmd, long arg))
>>   {
>>       return rtdm_fd_fcntl(fd, cmd, arg);
>>   }
>> diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
>> index 647f7f3e9..6f20dbedd 100644
>> --- a/kernel/cobalt/posix/io.h
>> +++ b/kernel/cobalt/posix/io.h
>> @@ -37,7 +37,7 @@ COBALT_SYSCALL_DECL(socket,
>>     COBALT_SYSCALL_DECL(close, (int fd));
>>   -COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, int arg));
>> +COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, long arg));
>>     COBALT_SYSCALL_DECL(ioctl,
>>               (int fd, unsigned int request, void __user *arg));
>> diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
>> index 807a11eae..f3b6444c3 100644
>> --- a/kernel/cobalt/rtdm/fd.c
>> +++ b/kernel/cobalt/rtdm/fd.c
>> @@ -371,7 +371,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>>   {
>>       struct rtdm_fd *fd;
>>       va_list ap;
>> -    int arg;
>> +    long arg;
>>       int ret;
>>         fd = rtdm_fd_get(ufd, 0);
>> @@ -379,7 +379,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>>           return PTR_ERR(fd);
>>         va_start(ap, cmd);
>> -    arg = va_arg(ap, int);
>> +    arg = va_arg(ap, long);
>>       va_end(ap);
>>         switch (cmd) {
>>
> 
> And we no longer need to do anything for compat?
> 

Nope, implicit arg conversion to the long register size in
XENOMAI_SYSCALL() should do the job. Cobalt only implements a single
fcntl request using the argument, and it does so as an int value.

-- 
Philippe.


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

* Re: [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value
  2018-12-05 15:29 [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Philippe Gerum
  2018-12-05 16:17 ` Jan Kiszka
@ 2018-12-06  7:04 ` Jan Kiszka
  2018-12-10  9:51   ` About mayday question duanwujie
  2019-01-08 17:18   ` [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Lange Norbert
  1 sibling, 2 replies; 7+ messages in thread
From: Jan Kiszka @ 2018-12-06  7:04 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 05.12.18 16:29, Philippe Gerum wrote:
> In order to prevent unexpected truncation of pointer args in userland
> with the LP64 data model, libcobalt's fcntl() wrapper should accept a
> long (3rd) argument.
> 
> Anticipate this change in the corresponding syscall implementation in
> the Cobalt core.  The updated ABI remains backward-compatible for
> current users.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>   kernel/cobalt/posix/io.c | 2 +-
>   kernel/cobalt/posix/io.h | 2 +-
>   kernel/cobalt/rtdm/fd.c  | 4 ++--
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
> index ef4a0fea2..f35aaf8cd 100644
> --- a/kernel/cobalt/posix/io.c
> +++ b/kernel/cobalt/posix/io.c
> @@ -53,7 +53,7 @@ COBALT_SYSCALL(close, lostage, (int fd))
>   	return rtdm_fd_close(fd, 0);
>   }
>   
> -COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
> +COBALT_SYSCALL(fcntl, current, (int fd, int cmd, long arg))
>   {
>   	return rtdm_fd_fcntl(fd, cmd, arg);
>   }
> diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
> index 647f7f3e9..6f20dbedd 100644
> --- a/kernel/cobalt/posix/io.h
> +++ b/kernel/cobalt/posix/io.h
> @@ -37,7 +37,7 @@ COBALT_SYSCALL_DECL(socket,
>   
>   COBALT_SYSCALL_DECL(close, (int fd));
>   
> -COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, int arg));
> +COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, long arg));
>   
>   COBALT_SYSCALL_DECL(ioctl,
>   		    (int fd, unsigned int request, void __user *arg));
> diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
> index 807a11eae..f3b6444c3 100644
> --- a/kernel/cobalt/rtdm/fd.c
> +++ b/kernel/cobalt/rtdm/fd.c
> @@ -371,7 +371,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>   {
>   	struct rtdm_fd *fd;
>   	va_list ap;
> -	int arg;
> +	long arg;
>   	int ret;
>   
>   	fd = rtdm_fd_get(ufd, 0);
> @@ -379,7 +379,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
>   		return PTR_ERR(fd);
>   
>   	va_start(ap, cmd);
> -	arg = va_arg(ap, int);
> +	arg = va_arg(ap, long);
>   	va_end(ap);
>   
>   	switch (cmd) {
> 

Applied to next.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


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

* About mayday question
  2018-12-06  7:04 ` Jan Kiszka
@ 2018-12-10  9:51   ` duanwujie
  2018-12-10  9:54     ` Jan Kiszka
  2019-01-08 17:18   ` [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Lange Norbert
  1 sibling, 1 reply; 7+ messages in thread
From: duanwujie @ 2018-12-10  9:51 UTC (permalink / raw)
  To: xenomai; +Cc: Philippe Gerum, Jan Kiszka

/Hi Philippe and Jan, I want to test //mayday mechanism,but we can't find any smoke test case about it.where 
can i find it? /


-- 
*Linx Software Corportaion Sichuan Branch
Name:wujie duan
Tel:028-65182023-6202
E-mail: wjduan@linx-info.com
*

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

* Re: About mayday question
  2018-12-10  9:51   ` About mayday question duanwujie
@ 2018-12-10  9:54     ` Jan Kiszka
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2018-12-10  9:54 UTC (permalink / raw)
  To: duanwujie, xenomai

On 10.12.18 10:51, duanwujie wrote:
> /Hi Philippe and Jan, I want to test //mayday mechanism,but we can't find any smoke test case about it.where can i 
> find it? /
> 

The sigdebug test in smokey stresses that path. It makes the watchdog fire by 
running an RT thread in a userspace-only loop.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


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

* RE: [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value
  2018-12-06  7:04 ` Jan Kiszka
  2018-12-10  9:51   ` About mayday question duanwujie
@ 2019-01-08 17:18   ` Lange Norbert
  1 sibling, 0 replies; 7+ messages in thread
From: Lange Norbert @ 2019-01-08 17:18 UTC (permalink / raw)
  To: Xenomai (xenomai@xenomai.org)

Added patch for userspace (hope our benevolent IT does not garble whitespaces).

It is now using  'long' for the argument instead of 'void *' - as requested.
What sticks out to me,
looking a few lines below the changes in rtdm.c the ioctl implementation uses 'void *'.

kind regards, Norbert Lange




> -----Original Message-----
> From: Xenomai <xenomai-bounces@xenomai.org> On Behalf Of Jan Kiszka
> via Xenomai
> Sent: Donnerstag, 6. Dezember 2018 08:04
> To: Philippe Gerum <rpm@xenomai.org>; xenomai@xenomai.org
> Subject: Re: [PATCH] cobalt/posix: fcntl: turn the generic argument into a
> long value
>
> E-MAIL FROM A NON-ANDRITZ SOURCE: AS A SECURITY MEASURE, PLEASE
> EXERCISE CAUTION WITH E-MAIL CONTENT AND ANY LINKS OR
> ATTACHMENTS.
>
>
> On 05.12.18 16:29, Philippe Gerum wrote:
> > In order to prevent unexpected truncation of pointer args in userland
> > with the LP64 data model, libcobalt's fcntl() wrapper should accept a
> > long (3rd) argument.
> >
> > Anticipate this change in the corresponding syscall implementation in
> > the Cobalt core.  The updated ABI remains backward-compatible for
> > current users.
> >
> > Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> > ---
> >   kernel/cobalt/posix/io.c | 2 +-
> >   kernel/cobalt/posix/io.h | 2 +-
> >   kernel/cobalt/rtdm/fd.c  | 4 ++--
> >   3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c index
> > ef4a0fea2..f35aaf8cd 100644
> > --- a/kernel/cobalt/posix/io.c
> > +++ b/kernel/cobalt/posix/io.c
> > @@ -53,7 +53,7 @@ COBALT_SYSCALL(close, lostage, (int fd))
> >       return rtdm_fd_close(fd, 0);
> >   }
> >
> > -COBALT_SYSCALL(fcntl, current, (int fd, int cmd, int arg))
> > +COBALT_SYSCALL(fcntl, current, (int fd, int cmd, long arg))
> >   {
> >       return rtdm_fd_fcntl(fd, cmd, arg);
> >   }
> > diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h index
> > 647f7f3e9..6f20dbedd 100644
> > --- a/kernel/cobalt/posix/io.h
> > +++ b/kernel/cobalt/posix/io.h
> > @@ -37,7 +37,7 @@ COBALT_SYSCALL_DECL(socket,
> >
> >   COBALT_SYSCALL_DECL(close, (int fd));
> >
> > -COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, int arg));
> > +COBALT_SYSCALL_DECL(fcntl, (int fd, int cmd, long arg));
> >
> >   COBALT_SYSCALL_DECL(ioctl,
> >                   (int fd, unsigned int request, void __user *arg));
> > diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c index
> > 807a11eae..f3b6444c3 100644
> > --- a/kernel/cobalt/rtdm/fd.c
> > +++ b/kernel/cobalt/rtdm/fd.c
> > @@ -371,7 +371,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
> >   {
> >       struct rtdm_fd *fd;
> >       va_list ap;
> > -     int arg;
> > +     long arg;
> >       int ret;
> >
> >       fd = rtdm_fd_get(ufd, 0);
> > @@ -379,7 +379,7 @@ int rtdm_fd_fcntl(int ufd, int cmd, ...)
> >               return PTR_ERR(fd);
> >
> >       va_start(ap, cmd);
> > -     arg = va_arg(ap, int);
> > +     arg = va_arg(ap, long);
> >       va_end(ap);
> >
> >       switch (cmd) {
> >
>
> Applied to next.
>
> Thanks,
> Jan
>
> --
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate
> Competence Center Embedded Linux

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cobalt-fix-fcntl-to-forward-a-long-argument.patch
Type: application/octet-stream
Size: 1248 bytes
Desc: cobalt-fix-fcntl-to-forward-a-long-argument.patch
URL: <http://xenomai.org/pipermail/xenomai/attachments/20190108/8a7a1681/attachment.obj>

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

end of thread, other threads:[~2019-01-08 17:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-05 15:29 [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Philippe Gerum
2018-12-05 16:17 ` Jan Kiszka
2018-12-05 16:29   ` Philippe Gerum
2018-12-06  7:04 ` Jan Kiszka
2018-12-10  9:51   ` About mayday question duanwujie
2018-12-10  9:54     ` Jan Kiszka
2019-01-08 17:18   ` [PATCH] cobalt/posix: fcntl: turn the generic argument into a long value Lange Norbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.