mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Use after free in drivers/media/video/videodev.c
@ 2003-08-30 19:55 Kronos
  2003-08-30 22:21 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Kronos @ 2003-08-30 19:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox, kraxel

Hi,
I think that there's a bug in videdev.c. Look at
video_unregister_device:

void video_unregister_device(struct video_device *vfd) {
        [...]
        class_device_unregister(&vfd->class_dev);
        devfs_remove(vfd->devfs_name);
        video_device[vfd->minor]=NULL;
}

The class_device_unregister will  call video_release. This function will
call  a  ->release callback. As  far  as  I  can  see drivers  do  their
own cleanup  outside video_unregister_device so there is no problem.

However,  if  a  driver  switch to  dynamically  allocated  video_device
this  ->release  callback  will   free  the  struct  video_device  (look
at   video_device_release)   and   possibly  its   container. So   after
class_device_unregister vfd may be a pointer to deallocated memory.

I think that class_device_unregister should be moved down:

--- 2.6.0.orig/drivers/media/video/videodev.c	Tue Aug 12 17:02:29 2003
+++ 2.6.0/drivers/media/video/videodev.c	Sat Aug 30 21:13:29 2003
@@ -349,9 +349,9 @@
 	if(video_device[vfd->minor]!=vfd)
 		panic("videodev: bad unregister");
 
-	class_device_unregister(&vfd->class_dev);
 	devfs_remove(vfd->devfs_name);
 	video_device[vfd->minor]=NULL;
+	class_device_unregister(&vfd->class_dev);
 	up(&videodev_lock);
 }
 

Luca
-- 
Reply-To: kronos@kronoz.cjb.net
Home: http://kronoz.cjb.net
The trouble with computers is that they do what you tell them,
not what you want.
D. Cohen

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

* Re: [PATCH] Use after free in drivers/media/video/videodev.c
  2003-08-30 19:55 [PATCH] Use after free in drivers/media/video/videodev.c Kronos
@ 2003-08-30 22:21 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2003-08-30 22:21 UTC (permalink / raw)
  To: kronos; +Cc: linux-kernel, alan, kraxel

Kronos <kronos@kronoz.cjb.net> wrote:
>
> --- 2.6.0.orig/drivers/media/video/videodev.c	Tue Aug 12 17:02:29 2003
>  +++ 2.6.0/drivers/media/video/videodev.c	Sat Aug 30 21:13:29 2003
>  @@ -349,9 +349,9 @@
>   	if(video_device[vfd->minor]!=vfd)
>   		panic("videodev: bad unregister");
>   
>  -	class_device_unregister(&vfd->class_dev);
>   	devfs_remove(vfd->devfs_name);
>   	video_device[vfd->minor]=NULL;
>  +	class_device_unregister(&vfd->class_dev);
>   	up(&videodev_lock);
>   }

Yes.  I already have this fix (from gregkh) queued up.

There are around 150 bugfixes in -mm at present.  It is worth
checking there first...

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

end of thread, other threads:[~2003-08-30 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-30 19:55 [PATCH] Use after free in drivers/media/video/videodev.c Kronos
2003-08-30 22:21 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®