Skip to contentSkip to conversation

raw1394 missing failure handling

PATCH In review Panagiotis Issaris 6 participants 11 messages Mar 2, 2005 – Mar 5, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raw1394 missing failure handling

Hi,

In the raw1394 driver the failure handling for
a __copy_to_user call is missing.

With friendly regards,
Takis

Signature · 2 lines
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/
drivers/ieee1394/raw1394.c +2 -1
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
@@ -443,7 +443,8 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req)))
+                return -EFAULT;
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
#1 lore raw

Hi,

Quoted 2 lines · Panagiotis Issaris

In the raw1394 driver the failure handling for
a __copy_to_user call is missing.

Your patch is obviously incorrect as it doesn't free the request before it returns.

Best regards,

Anton

Signature · 4 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
#2 lore raw

Hi,

Quoted 12 lines · Anton Altaparmakov
Quoted 4 lines · Panagiotis Issaris

In the raw1394 driver the failure handling for
a __copy_to_user call is missing.

Your patch is obviously incorrect as it doesn't free the request before it returns.

Oops. Thanks for replying! Any more problems with the updated patch?

With friendly regards,
Takis

Signature · 2 lines
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/
drivers/ieee1394/raw1394.c +5 -1
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
@@ -443,7 +443,11 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req)))
+        {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
#3 lore raw
Quoted 12 lines · Panagiotis Issaris

Hi,

Quoted 8 lines · Anton Altaparmakov
Quoted 4 lines · Panagiotis Issaris

In the raw1394 driver the failure handling for
a __copy_to_user call is missing.

Quoted 7 lines
Quoted 4 lines

Your patch is obviously incorrect as it doesn't free the request before it returns.

Oops. Thanks for replying! Any more problems with the updated patch?

Formatting... Opening curly brace should go on the same line with "if".

Signature · 1 line
Dmitry
#4 lore raw

Hi,

Quoted 11 lines · Dmitry Torokhov
Quoted 4 lines · Panagiotis Issaris

Oops. Thanks for replying! Any more problems with the updated patch?

Formatting... Opening curly brace should go on the same line with "if".

Thanks. Here's my third try :-)

With friendly regards,
Takis

Signature · 2 lines
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/
drivers/ieee1394/raw1394.c +4 -1
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
@@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req))) {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
#5 lore raw
Quoted 4 lines

Thanks. Here's my third try :-)

With friendly regards,
Takis

I'll apply this to the 1394 tree and send it to Linus after testing if you add a Signed-off-by: line per Documentation/SubmittingPatches . Also, please cc [email protected] with ieee1394 changes.

Thanks,
Jody

Quoted 21 lines
Signature · 6 lines
-- 
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/


diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
drivers/ieee1394/raw1394.c +4 -1
@@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req))) {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
#6 lore raw

Hi,

Quoted 5 lines · Jody McIntyre

I'll apply this to the 1394 tree and send it to Linus after testing if you add a Signed-off-by: line per Documentation/SubmittingPatches . Also, please cc [email protected] with ieee1394 changes.

Sure! Thanks!

Adds the missing failure handling for a __copy_to_user call.

drivers/ieee1394/raw1394.c +4 -1
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
@@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file 
                        req->req.error = RAW1394_ERROR_MEMFAULT;
                }
        }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req))) {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
        free_pending_request(req);
        return sizeof(struct raw1394_request);
Signature · 2 lines
 K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
 http://people.mech.kuleuven.ac.be/~pissaris/
#7 lore raw
In reply to Jody McIntyre

Hi Jody,

My previous e-mail seemed to be messed up by Thunderbird... so now I'm using good old Mutt again.

Quoted 9 lines · Jody McIntyre
Quoted 4 lines

Thanks. Here's my third try :-)

With friendly regards,
Takis

I'll apply this to the 1394 tree and send it to Linus after testing if you add a Signed-off-by: line per Documentation/SubmittingPatches . Also, please cc [email protected] with ieee1394 changes.

Sure! Thanks!

Adds the missing failure handling for a __copy_to_user call.

drivers/ieee1394/raw1394.c +4 -1
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c
@@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req))) {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
Signature · 2 lines
  K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
  http://people.mech.kuleuven.ac.be/~pissaris/
#8 lore raw
Quoted 4 lines · Panagiotis Issaris

Adds the missing failure handling for a __copy_to_user call.

Sorry I didn't notice this sooner, but this was already fixed and has been sent to Linus (hopefully to appear in 2.6.12.)

Jody

Quoted 27 lines

diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c

drivers/ieee1394/raw1394.c +4 -1
@@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req))) {
+                free_pending_request(req);
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
Signature · 9 lines
-- 
  K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
  http://people.mech.kuleuven.ac.be/~pissaris/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#9 lore raw
Quoted 10 lines · Jody McIntyre
Quoted 4 lines · Panagiotis Issaris

Adds the missing failure handling for a __copy_to_user call.

Sorry I didn't notice this sooner, but this was already fixed and has been sent to Linus (hopefully to appear in 2.6.12.)

Jody

Jody, Panagiotis; A much more complete patch is already sitting in the bk queue. This is a relatively small piece of that one. You can get it from:

<ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11/2.6.11-mm1/broken-out>

As the bk-ieee1394.patch you can see there.

Quoted 29 lines
Quoted 29 lines

diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c --- linux-2.6.11/drivers/ieee1394/raw1394.c 2005-03-02 11:44:26.000000000 +0100 +++ linux-2.6.11-pi/drivers/ieee1394/raw1394.c 2005-03-02 15:27:15.000000000 +0100 @@ -443,7 +443,10 @@ static ssize_t raw1394_read(struct file req->req.error = RAW1394_ERROR_MEMFAULT; }

         }
(quoted diff) +1 -1
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req)))

{ + free_pending_request(req);

drivers/ieee1394/raw1394.c +2 -1
+                return -EFAULT;
+        }
 
         free_pending_request(req);
         return sizeof(struct raw1394_request);
 
 
--
  K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research

Group http://people.mech.kuleuven.ac.be/~pissaris/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 8 lines
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
99.34% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attorneys please note, additions to this message
by Gene Heskett are:
Copyright 2005 by Maurice Eugene Heskett, all rights reserved.
#10 lore raw
In reply to Panagiotis Issaris
Quoted 17 lines · On Wed, 02 Mar 2005 12:10:50 +0100 Panagiotis Issaris wrote:

In the raw1394 driver the failure handling for
a __copy_to_user call is missing.

With friendly regards,
Takis

Signature · 7 lines
  K.U.Leuven, Mechanical Eng.,  Mechatronics & Robotics Research Group
  http://people.mech.kuleuven.ac.be/~pissaris/



[pi-20050302T114855-linux_2_6_11-raw1394_copy_to_user_failure_handling.diff  text/x-patch (922 bytes)]
diff -pruN linux-2.6.11/drivers/ieee1394/raw1394.c linux-2.6.11-pi/drivers/ieee1394/raw1394.c

drivers/ieee1394/raw1394.c static ssize_t raw1394_read(struct file · line 447

Quoted 6 lines
drivers/ieee1394/raw1394.c +2 -1
@@ -443,7 +443,8 @@ static ssize_t raw1394_read(struct file 
                         req->req.error = RAW1394_ERROR_MEMFAULT;
                 }
         }
-        __copy_to_user(buffer, &req->req, sizeof(req->req));
+        if (__copy_to_user(buffer, &req->req, sizeof(req->req)))
+                return -EFAULT;

Bug: "req" is not freed in the failure case.

Quoted 4 lines
drivers/ieee1394/raw1394.c +0 -0
         free_pending_request(req);
         return sizeof(struct raw1394_request);