All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH]media:dvb: add compat_ioctl def for dmx_dvr
       [not found]   ` <CAHoAvW8k77_ckRdAGGTsu4ALhw4=TUPa27knK3x9zR3bjvjbUw@mail.gmail.com>
@ 2021-01-18  7:38     ` Arnd Bergmann
  2021-01-18 10:34       ` root jason
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-01-18  7:38 UTC (permalink / raw)
  To: root jason
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Arnd Bergmann,
	Hans Verkuil

On Mon, Jan 18, 2021 at 7:21 AM root jason <jason.root.w@gmail.com> wrote:
> From: jason.wang <jason.root.w@gmail.com>
>
> add compat_ioctl define for dmx_dvr to handle ioctl when CONFIG_COMPAT is enable.
>
> Signed-off-by: .jason.wang <jason.root.w@gmail.com>
> ---
>  drivers/media/dvb-core/dmxdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
> index f14a872d1268..4a9e027de827 100644
> --- a/drivers/media/dvb-core/dmxdev.c
> +++ b/drivers/media/dvb-core/dmxdev.c
> @@ -1393,6 +1393,7 @@ static const struct file_operations dvb_dvr_fops = {
>         .read = dvb_dvr_read,
>         .write = dvb_dvr_write,
>         .unlocked_ioctl = dvb_dvr_ioctl,
> +       .compat_ioctl = dvb_dvr_ioctl,
>         .open = dvb_dvr_open,
>         .release = dvb_dvr_release,
>         .poll = dvb_dvr_poll,

This is correct for DMX_SET_BUFFER_SIZE, which takes an integer
argument, but not strictly correct for the other ones that take a pointer
argument and need a compat_ptr() conversion.

You could do it by either passing both the 'unsigned long arg'
and the 'void __user *argp' pointer to dvb_usercopy(), with the
pointer coming from compat_ptr() in case of compat, or you
add something like

         if (in_compat_syscall())
                   arg = compat_ptr(unsigned long arg);

in the function itself. I checked the DVB ioctls to make sure that
no other ioctl commands need any special handling, and found
that DMX_SET_BUFFER_SIZE is the only one.

          Arnd

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

* Re: [PATCH]media:dvb: add compat_ioctl def for dmx_dvr
  2021-01-18  7:38     ` [PATCH]media:dvb: add compat_ioctl def for dmx_dvr Arnd Bergmann
@ 2021-01-18 10:34       ` root jason
  0 siblings, 0 replies; 2+ messages in thread
From: root jason @ 2021-01-18 10:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Arnd Bergmann,
	Hans Verkuil

Arnd Bergmann <arnd@kernel.org> 于2021年1月18日周一 下午3:38写道:
>
> On Mon, Jan 18, 2021 at 7:21 AM root jason <jason.root.w@gmail.com> wrote:
> > From: jason.wang <jason.root.w@gmail.com>
> >
> > add compat_ioctl define for dmx_dvr to handle ioctl when CONFIG_COMPAT is enable.
> >
> > Signed-off-by: .jason.wang <jason.root.w@gmail.com>
> > ---
> >  drivers/media/dvb-core/dmxdev.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
> > index f14a872d1268..4a9e027de827 100644
> > --- a/drivers/media/dvb-core/dmxdev.c
> > +++ b/drivers/media/dvb-core/dmxdev.c
> > @@ -1393,6 +1393,7 @@ static const struct file_operations dvb_dvr_fops = {
> >         .read = dvb_dvr_read,
> >         .write = dvb_dvr_write,
> >         .unlocked_ioctl = dvb_dvr_ioctl,
> > +       .compat_ioctl = dvb_dvr_ioctl,
> >         .open = dvb_dvr_open,
> >         .release = dvb_dvr_release,
> >         .poll = dvb_dvr_poll,
>
> This is correct for DMX_SET_BUFFER_SIZE, which takes an integer
> argument, but not strictly correct for the other ones that take a pointer
> argument and need a compat_ptr() conversion.
>
> You could do it by either passing both the 'unsigned long arg'
> and the 'void __user *argp' pointer to dvb_usercopy(), with the
> pointer coming from compat_ptr() in case of compat, or you
> add something like
>
>          if (in_compat_syscall())
>                    arg = compat_ptr(unsigned long arg);
>
> in the function itself. I checked the DVB ioctls to make sure that
> no other ioctl commands need any special handling, and found
> that DMX_SET_BUFFER_SIZE is the only one.
>
>           Arnd

hi Arnd,
     thank you for your quick comment.

     I upload this change is because if not compt_ioctl dvr_ioctl can
not be invoked
     I checked my local kernel code about compt_ioctl call flow.
     I figure out that my local kernel version is 5.4.70.
     if compat_ioctl is not defined, ioctl cmd need to add into the
array(ioctl_pointer),
     otherwise, unlocked_ioctl will not be called.

     and I check latest kernel version. the logic about this part is
changed.  no need to
     add ioctl cmd into that array.
     for the latest kernel, it should be ok.

    anyway, .thank you for your reply.

jason.wang

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

end of thread, other threads:[~2021-01-18 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAHoAvW8+1jAirPQPQ-WYYD5fyngckrXA+dLTX+H2ysGzOKUZRg@mail.gmail.com>
     [not found] ` <CAHoAvW_Cju=0svzAExJDuXP9NBnz34Lut8M2+Y9RHUtMXfxJqg@mail.gmail.com>
     [not found]   ` <CAHoAvW8k77_ckRdAGGTsu4ALhw4=TUPa27knK3x9zR3bjvjbUw@mail.gmail.com>
2021-01-18  7:38     ` [PATCH]media:dvb: add compat_ioctl def for dmx_dvr Arnd Bergmann
2021-01-18 10:34       ` root jason

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.