LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[lvs-devel] [patch] ipvs: Fix error handling in sysctl handlers

To: lvs-devel@xxxxxxxxxxxxxxxxxxxxxx
Subject: [lvs-devel] [patch] ipvs: Fix error handling in sysctl handlers
Cc: Wensong Zhang <wensong@xxxxxxxxxxxx>, Julian Anastasov <ja@xxxxxx>
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 14 Nov 2007 11:20:47 -0800 (PST)
Fix error handling in sysctl handlers

* If proc_dointvec fails then there is no point in trying
  to inteprate values it may have retrieved
* If the values outside the acceptable range then return an error
  rather than failing silently.

Interested parties, please review this patch.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: net-2.6/net/ipv4/ipvs/ip_vs_ctl.c
===================================================================
--- net-2.6.orig/net/ipv4/ipvs/ip_vs_ctl.c      2007-11-14 11:18:54.000000000 
-0800
+++ net-2.6/net/ipv4/ipvs/ip_vs_ctl.c   2007-11-14 11:19:21.000000000 -0800
@@ -1385,16 +1385,20 @@ proc_do_defense_mode(ctl_table *table, i
        int val = *valp;
        int rc;
 
-       rc = proc_dointvec(table, write, filp, buffer, lenp, ppos);
+       if ( (rc = proc_dointvec(table, write, filp, buffer, lenp, ppos)) ) {
+               /* Restore the correct value */
+               *valp = val;
+               return rc;
+       }
        if (write && (*valp != val)) {
                if ((*valp < 0) || (*valp > 3)) {
                        /* Restore the correct value */
                        *valp = val;
-               } else {
-                       update_defense_level();
+                       return -EINVAL;
                }
+               update_defense_level();
        }
-       return rc;
+       return 0;
 }
 
 
@@ -1409,12 +1413,17 @@ proc_do_sync_threshold(ctl_table *table,
        /* backup the value first */
        memcpy(val, valp, sizeof(val));
 
-       rc = proc_dointvec(table, write, filp, buffer, lenp, ppos);
+       if ( (rc = proc_dointvec(table, write, filp, buffer, lenp, ppos)) ) {
+               /* Restore the correct value */
+               memcpy(valp, val, sizeof(val));
+               return rc;
+       }
        if (write && (valp[0] < 0 || valp[1] < 0 || valp[0] >= valp[1])) {
                /* Restore the correct value */
                memcpy(valp, val, sizeof(val));
+               return -EINVAL;
        }
-       return rc;
+       return 0;
 }
 
 

LVS Development mailing list - lvs-devel@xxxxxxxxxxxxxxxxxxxxxx
Send requests to lvs-devel-request@xxxxxxxxxxxxxxxxxxxxxx
or go to http://lists.graemef.net/mailman/listinfo/lvs-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [lvs-devel] [patch] ipvs: Fix error handling in sysctl handlers, Simon Horman <=