[RHEL7,COMMIT] fs/fuse kio_pcs: fix out of bounds roles_str[] array access

Submitted by Konstantin Khorenko on June 15, 2018, 12:01 p.m.

Details

Message ID 201806151201.w5FC1w35010071@finist_ce7.work
State New
Series "fs/fuse kio_pcs: fix out of bounds roles_str[] array access"
Headers show

Commit Message

Konstantin Khorenko June 15, 2018, 12:01 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.9
------>
commit a62c232469cbd17da8ff1cf72b8c15d6074c0c06
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Fri Jun 15 15:01:58 2018 +0300

    fs/fuse kio_pcs: fix out of bounds roles_str[] array access
    
    The array roles_str[] can be accessed at index PCS_NODE_ROLES_, which is out of
    bounds. (Actually it's not very dangerous because index PCS_NODE_ROLES_ always
    points to the end of the array - NULL, but anyway it should be fixed).
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_rpc_prot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_rpc_prot.h b/fs/fuse/kio/pcs/pcs_rpc_prot.h
index 594670e9ead6..e32e7912943e 100644
--- a/fs/fuse/kio/pcs/pcs_rpc_prot.h
+++ b/fs/fuse/kio/pcs/pcs_rpc_prot.h
@@ -80,7 +80,7 @@  static inline const char *pcs_role_to_str(u8 role)
 		"TEST", "CN", "CS", "MDS", "TOOL", "SVC"
 	};
 
-	if (role > PCS_NODE_ROLES_)
+	if (role >= PCS_NODE_ROLES_)
 		return "Unknown";
 	return roles_str[role];
 }