[PATCH] cobalt/posix: fcntl: turn the generic argument into a long value

Lange Norbert norbert.lange at andritz.com
Tue Jan 8 18:18:27 CET 2019


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 at xenomai.org> On Behalf Of Jan Kiszka
> via Xenomai
> Sent: Donnerstag, 6. Dezember 2018 08:04
> To: Philippe Gerum <rpm at xenomai.org>; xenomai at 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 at 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>


More information about the Xenomai mailing list