]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
osd/ClassHandler.cc: move stat into error handling
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 7 Jan 2015 08:34:07 +0000 (09:34 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 7 Jan 2015 09:14:13 +0000 (10:14 +0100)
commitb99508b30cd53716e15d5464136a841c9a66a56f
tree07bcb317bbd29d42980229b7ef1bb4e7c1095765
parentfd4ac46b07649cbd5f65e4b661c1a94474bf0c97
osd/ClassHandler.cc: move stat into error handling

There is no security advantage to check if the class file
exists before opening it but the file could be removed or
exchanged between the stat and open. Instead directly open
it and fail. Check if the file was missing afterwards
for debug messages and error codes.

Make sure cls->status is set if the class open call fails.

To solve Coverity issue:

CID 743419 (#1 of 1): Time of check time of use (TOCTOU)
 fs_check_call: Calling function stat to perform check on fname.

743419 Time of check time of use
 An attacker could change the filename's file association or
 other attributes between the check and use.

 In ClassHandler::_load_class(ClassHandler::ClassData *): A check
 occurs on a file's attributes before the file is used in a
 privileged operation, but things may have changed (CWE-367)

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/osd/ClassHandler.cc