lkml.org 
[lkml]   [2009]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 6/9] Simplify bound checks in cifs for copy_from_user
From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH 6/9] Simplify bound checks in cifs for copy_from_user
CC: Steve French <sfrench@samba.org>

The CIFS code unfortunately hits a missed optimization in gcc
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41477)
where gcc can't prove to itself that count will not be larger than 11.

This patch simplifies the expression so that GCC does realize this,
giving slightly better code soon when copy_from_user() grows some checks.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>

diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 42cec2a..94b86da 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -732,11 +732,13 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
char flags_string[12];
char c;

- if ((count < 1) || (count > 11))
- return -EINVAL;
-
memset(flags_string, 0, 12);

+ if (count < 1)
+ return -EINVAL;
+ if (count > 11)
+ return -EINVAL;
+
if (copy_from_user(flags_string, buffer, count))
return -EFAULT;



--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org


\
 
 \ /
  Last update: 2009-09-26 21:01    [W:0.116 / U:10.964 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site