All of lore.kernel.org
 help / color / mirror / Atom feed
* security_file_lock cmd argument
@ 2009-07-09  9:45 Sten Spans
  0 siblings, 0 replies; 4+ messages in thread
From: Sten Spans @ 2009-07-09  9:45 UTC (permalink / raw)
  To: linux-kernel


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:

--- fs/locks.c.orig	2009-07-09 11:26:45.000000000 +0200
+++ fs/locks.c	2009-07-09 11:27:24.000000000 +0200
@@ -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;
 
-- 
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: security_file_lock cmd argument
  2009-07-16  7:41   ` Sten Spans
@ 2009-07-16 22:04     ` James Morris
  0 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2009-07-16 22:04 UTC (permalink / raw)
  To: Sten Spans; +Cc: linux-security-module, linux-kernel

On Thu, 16 Jul 2009, Sten Spans wrote:

> On Thu, Jul 16, 2009 at 10:05:47AM +1000, James Morris wrote:
> > > From: Sten Spans <Sten_Spans@genua.de>
> > 
> > This looks good, but you need to add a signed-off-by line per 
> > Documentation/SubmittingPatches
> > 
> 
> Makes sense, how about:
> 
> Pass posix-translated lock operations to security_file_lock
> when invoked via sys_flock.
> 
> Signed-off-by: Sten Spans <Sten_Spans@genua.de>

Thanks.

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next


-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: security_file_lock cmd argument
  2009-07-16  0:05 ` James Morris
@ 2009-07-16  7:41   ` Sten Spans
  2009-07-16 22:04     ` James Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Sten Spans @ 2009-07-16  7:41 UTC (permalink / raw)
  To: James Morris; +Cc: linux-security-module, linux-kernel

On Thu, Jul 16, 2009 at 10:05:47AM +1000, James Morris wrote:
> > From: Sten Spans <Sten_Spans@genua.de>
> 
> This looks good, but you need to add a signed-off-by line per 
> Documentation/SubmittingPatches
> 

Makes sense, how about:

Pass posix-translated lock operations to security_file_lock
when invoked via sys_flock.

Signed-off-by: Sten Spans <Sten_Spans@genua.de>

--- fs/locks.c.orig	2009-07-09 11:26:45.000000000 +0200
+++ fs/locks.c	2009-07-09 11:27:24.000000000 +0200
@@ -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;
 
-- 
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: security_file_lock cmd argument
       [not found] <alpine.LRH.2.00.0907092031020.4944@tundra.namei.org>
@ 2009-07-16  0:05 ` James Morris
  2009-07-16  7:41   ` Sten Spans
  0 siblings, 1 reply; 4+ messages in thread
From: James Morris @ 2009-07-16  0:05 UTC (permalink / raw)
  To: linux-security-module, Sten Spans; +Cc: linux-kernel

> From: Sten Spans <Sten_Spans@genua.de>

This looks good, but you need to add a signed-off-by line per 
Documentation/SubmittingPatches


> To: linux-kernel@vger.kernel.org
> Subject: 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:
> 
> --- fs/locks.c.orig	2009-07-09 11:26:45.000000000 +0200
> +++ fs/locks.c	2009-07-09 11:27:24.000000000 +0200
> @@ -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;
>  
> -- 
> 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-16 22:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-09  9:45 security_file_lock cmd argument Sten Spans
     [not found] <alpine.LRH.2.00.0907092031020.4944@tundra.namei.org>
2009-07-16  0:05 ` James Morris
2009-07-16  7:41   ` Sten Spans
2009-07-16 22:04     ` James Morris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.