The fbdev code uses compat_alloc_user_space in a few of its
compat_ioctl handlers, which tends to be a bit more complicated
and error-prone than calling the underlying handlers directly,
so I would like to remove it completely.
This modifies two such functions in fbdev, and removes another
one that is completely unused.
Arnd
Arnd Bergmann (3):
fbdev: simplify fb_getput_cmap()
fbdev: sbuslib: remove unused FBIOSCURSOR32 helper
fbdev: sbuslib: remove compat_alloc_user_space usage
drivers/video/fbdev/core/fbmem.c | 44 +++++------
drivers/video/fbdev/sbuslib.c | 124 ++++++++++++++++++-------------
2 files changed, 90 insertions(+), 78 deletions(-)
--
2.27.0
This function is one of the remaining users of compat_alloc_user_space()
and copy_in_user().
Clean it up by copying to a local data structure copy instead,
which also leads to more readable code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/video/fbdev/core/fbmem.c | 44 ++++++++++++++------------------
1 file changed, 19 insertions(+), 25 deletions(-)
No driver implements FBIOSCURSOR, so this function has no purpose
and can be removed. Apparently it was added in linux-2.1.44 to handle
compatibility for drivers/sbus/char/sunfb.c but lost its purpose when
that driver got rewritten in linux-2.5.63.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/video/fbdev/sbuslib.c | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
@@ -214,32 +214,6 @@ static int fbiogetputcmap(struct fb_info *info, unsigned int cmd, unsigned long(unsignedlong)p);}-staticintfbiogscursor(structfb_info*info,unsignedlongarg)-{-structfbcursor__user*p=compat_alloc_user_space(sizeof(*p));-structfbcursor32__user*argp=(void__user*)arg;-compat_uptr_taddr;-intret;--ret=copy_in_user(p,argp,-2*sizeof(short)+2*sizeof(structfbcurpos));-ret|=copy_in_user(&p->size,&argp->size,sizeof(structfbcurpos));-ret|=copy_in_user(&p->cmap,&argp->cmap,2*sizeof(int));-ret|=get_user(addr,&argp->cmap.red);-ret|=put_user(compat_ptr(addr),&p->cmap.red);-ret|=get_user(addr,&argp->cmap.green);-ret|=put_user(compat_ptr(addr),&p->cmap.green);-ret|=get_user(addr,&argp->cmap.blue);-ret|=put_user(compat_ptr(addr),&p->cmap.blue);-ret|=get_user(addr,&argp->mask);-ret|=put_user(compat_ptr(addr),&p->mask);-ret|=get_user(addr,&argp->image);-ret|=put_user(compat_ptr(addr),&p->image);-if(ret)-return-EFAULT;-returninfo->fbops->fb_ioctl(info,FBIOSCURSOR,(unsignedlong)p);-}-intsbusfb_compat_ioctl(structfb_info*info,unsignedintcmd,unsignedlongarg){switch(cmd){
@@ -248,6 +222,7 @@ int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arcaseFBIOGATTR:caseFBIOSVIDEO:caseFBIOGVIDEO:+caseFBIOSCURSOR32:caseFBIOGCURSOR32:/* This is not implemented yet.Lateritshouldbeconverted...*/caseFBIOSCURPOS:
@@ -258,8 +233,6 @@ int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arreturnfbiogetputcmap(info,cmd,arg);caseFBIOGETCMAP32:returnfbiogetputcmap(info,cmd,arg);-caseFBIOSCURSOR32:-returnfbiogscursor(info,arg);default:return-ENOIOCTLCMD;}
This is one of the last users of compat_alloc_user_space()
and copy_in_user(). The actual handler is implemented in the
same file and could be shared, but as I couldn't test this
properly I leave the native case alone and just make a straight
copy of it for the compat case, with a minimum set of
modifications.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/video/fbdev/sbuslib.c | 95 ++++++++++++++++++++++++++---------
1 file changed, 70 insertions(+), 25 deletions(-)
@@ -192,28 +192,6 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,EXPORT_SYMBOL(sbusfb_ioctl_helper);#ifdef CONFIG_COMPAT-staticintfbiogetputcmap(structfb_info*info,unsignedintcmd,unsignedlongarg)-{-structfbcmap32__user*argp=(void__user*)arg;-structfbcmap__user*p=compat_alloc_user_space(sizeof(*p));-u32addr;-intret;--ret=copy_in_user(p,argp,2*sizeof(int));-ret|=get_user(addr,&argp->red);-ret|=put_user(compat_ptr(addr),&p->red);-ret|=get_user(addr,&argp->green);-ret|=put_user(compat_ptr(addr),&p->green);-ret|=get_user(addr,&argp->blue);-ret|=put_user(compat_ptr(addr),&p->blue);-if(ret)-return-EFAULT;-returninfo->fbops->fb_ioctl(info,-(cmd=FBIOPUTCMAP32)?-FBIOPUTCMAP_SPARC:FBIOGETCMAP_SPARC,-(unsignedlong)p);-}-intsbusfb_compat_ioctl(structfb_info*info,unsignedintcmd,unsignedlongarg){switch(cmd){
@@ -230,9 +208,76 @@ int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arcaseFBIOGCURMAX:returninfo->fbops->fb_ioctl(info,cmd,arg);caseFBIOPUTCMAP32:-returnfbiogetputcmap(info,cmd,arg);-caseFBIOGETCMAP32:-returnfbiogetputcmap(info,cmd,arg);+caseFBIOPUTCMAP_SPARC:{+structfbcmap32c;+structfb_cmapcmap;+u16red,green,blue;+u8red8,green8,blue8;+unsignedchar__user*ured;+unsignedchar__user*ugreen;+unsignedchar__user*ublue;+unsignedinti;++if(copy_from_user(&c,compat_ptr(arg),sizeof(c)))+return-EFAULT;+ured=compat_ptr(c.red);+ugreen=compat_ptr(c.green);+ublue=compat_ptr(c.blue);++cmap.len=1;+cmap.red=&red;+cmap.green=&green;+cmap.blue=&blue;+cmap.transp=NULL;+for(i=0;i<c.count;i++){+interr;++if(get_user(red8,&ured[i])||+get_user(green8,&ugreen[i])||+get_user(blue8,&ublue[i]))+return-EFAULT;++red=red8<<8;+green=green8<<8;+blue=blue8<<8;++cmap.start=c.index+i;+err=fb_set_cmap(&cmap,info);+if(err)+returnerr;+}+return0;+}+caseFBIOGETCMAP32:{+structfbcmap32c;+unsignedchar__user*ured;+unsignedchar__user*ugreen;+unsignedchar__user*ublue;+structfb_cmap*cmap=&info->cmap;+unsignedintindex,i;+u8red,green,blue;++if(copy_from_user(&c,compat_ptr(arg),sizeof(c)))+return-EFAULT;+index=c.index;+ured=compat_ptr(c.red);+ugreen=compat_ptr(c.green);+ublue=compat_ptr(c.blue);++if(index>cmap->len||c.count>cmap->len-index)+return-EINVAL;++for(i=0;i<c.count;i++){+red=cmap->red[index+i]>>8;+green=cmap->green[index+i]>>8;+blue=cmap->blue[index+i]>>8;+if(put_user(red,&ured[i])||+put_user(green,&ugreen[i])||+put_user(blue,&ublue[i]))+return-EFAULT;+}+return0;+}default:return-ENOIOCTLCMD;}
From: Daniel Vetter <hidden> Date: 2020-09-18 12:48:21
On Fri, Sep 18, 2020 at 12:08:10PM +0200, Arnd Bergmann wrote:
The fbdev code uses compat_alloc_user_space in a few of its
compat_ioctl handlers, which tends to be a bit more complicated
and error-prone than calling the underlying handlers directly,
so I would like to remove it completely.
This modifies two such functions in fbdev, and removes another
one that is completely unused.
Arnd
Arnd Bergmann (3):
fbdev: simplify fb_getput_cmap()
fbdev: sbuslib: remove unused FBIOSCURSOR32 helper
fbdev: sbuslib: remove compat_alloc_user_space usage
Looks all good, but we're also kinda looking for a new volunteer for
handling fbdev patches ... drm-misc commit rights, still not interested?
-Daniel
From: Sam Ravnborg <hidden> Date: 2020-09-24 20:54:42
Hi Daniel/Arnd.
On Fri, Sep 18, 2020 at 02:48:08PM +0200, Daniel Vetter wrote:
On Fri, Sep 18, 2020 at 12:08:10PM +0200, Arnd Bergmann wrote:
quoted
The fbdev code uses compat_alloc_user_space in a few of its
compat_ioctl handlers, which tends to be a bit more complicated
and error-prone than calling the underlying handlers directly,
so I would like to remove it completely.
This modifies two such functions in fbdev, and removes another
one that is completely unused.
Arnd
Arnd Bergmann (3):
fbdev: simplify fb_getput_cmap()
fbdev: sbuslib: remove unused FBIOSCURSOR32 helper
fbdev: sbuslib: remove compat_alloc_user_space usage
Looks all good, but we're also kinda looking for a new volunteer for
handling fbdev patches ... drm-misc commit rights, still not interested?
Hi Daniel - I read the above as an a-b. And Arnd did not take the bait
it seems.
Hi Arnd. checkpatch complained about some whitespace, which I fixed
while applying.
Will push to drm-misc-next tomorrow unless I hear anything else.
Sam
On Thu, Sep 24, 2020 at 10:54 PM Sam Ravnborg [off-list ref] wrote:
Hi Daniel/Arnd.
On Fri, Sep 18, 2020 at 02:48:08PM +0200, Daniel Vetter wrote:
quoted
On Fri, Sep 18, 2020 at 12:08:10PM +0200, Arnd Bergmann wrote:
quoted
The fbdev code uses compat_alloc_user_space in a few of its
compat_ioctl handlers, which tends to be a bit more complicated
and error-prone than calling the underlying handlers directly,
so I would like to remove it completely.
This modifies two such functions in fbdev, and removes another
one that is completely unused.
Arnd
Arnd Bergmann (3):
fbdev: simplify fb_getput_cmap()
fbdev: sbuslib: remove unused FBIOSCURSOR32 helper
fbdev: sbuslib: remove compat_alloc_user_space usage
Looks all good, but we're also kinda looking for a new volunteer for
handling fbdev patches ... drm-misc commit rights, still not interested?
Hi Daniel - I read the above as an a-b. And Arnd did not take the bait
it seems.
Ah right, I meant to reply but then forgot about it.
I don't really want commit access, thanks for the offer.
Hi Arnd. checkpatch complained about some whitespace, which I fixed
while applying.
Will push to drm-misc-next tomorrow unless I hear anything else.
From: Sam Ravnborg <hidden> Date: 2020-09-25 14:39:46
On Fri, Sep 25, 2020 at 01:31:51PM +0200, Arnd Bergmann wrote:
On Thu, Sep 24, 2020 at 10:54 PM Sam Ravnborg [off-list ref] wrote:
quoted
Hi Daniel/Arnd.
On Fri, Sep 18, 2020 at 02:48:08PM +0200, Daniel Vetter wrote:
quoted
On Fri, Sep 18, 2020 at 12:08:10PM +0200, Arnd Bergmann wrote:
quoted
The fbdev code uses compat_alloc_user_space in a few of its
compat_ioctl handlers, which tends to be a bit more complicated
and error-prone than calling the underlying handlers directly,
so I would like to remove it completely.
This modifies two such functions in fbdev, and removes another
one that is completely unused.
Arnd
Arnd Bergmann (3):
fbdev: simplify fb_getput_cmap()
fbdev: sbuslib: remove unused FBIOSCURSOR32 helper
fbdev: sbuslib: remove compat_alloc_user_space usage
Looks all good, but we're also kinda looking for a new volunteer for
handling fbdev patches ... drm-misc commit rights, still not interested?
Hi Daniel - I read the above as an a-b. And Arnd did not take the bait
it seems.
Ah right, I meant to reply but then forgot about it.
I don't really want commit access, thanks for the offer.
quoted
Hi Arnd. checkpatch complained about some whitespace, which I fixed
while applying.
Will push to drm-misc-next tomorrow unless I hear anything else.