security_file_lock cmd argument
I was playing around with the security_file_lock hook which is invoked from fs/locks.c. The desciption in include/linux/security.h states the following:
* @file_lock:
* Check permission before performing file locking operations. * Note: this hook mediates both flock and fcntl style locks. * @file contains the file structure. * @cmd contains the posix-translated lock operation to perform * (e.g. F_RDLCK, F_WRLCK).
However when invoked via sys_flock:
SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) {
..
error = security_file_lock(filp, cmd);
Which results in passing flock style arguments (LOCK_*) rather than fcntl (F_*LCK). This also is inconsistent with the two other security_file_lock invocations in the same file. This one-liner fixes the issue:
locks.c renamed from locks.c.orig +1 -1
@@ -1590,7 +1590,7 @@if (can_sleep) lock->fl_flags |=FL_SLEEP ; - error =security_file_lock (filp, cmd); + error =security_file_lock (filp, lock->fl_type);if (error) goto out_free;
Signature · 6 lines
GeNUA Gesellschaft für Netzwerk - und Unix-Administration mbH Domagkstr. 7, D-85551 Kirchheim. http://www.genua.de Tel: (089) 99 19 50-0, Fax: (089) 99 19 50 - 999 Geschäftsführer: Dr. Magnus Harlander, Dr. Michaela Harlander, Bernhard Schneck. Amtsgericht München HRB 98238