Skip to content

Commit d0d845a

Browse files
effective-lightjrjohansen
authored andcommitted
apparmor: use per file locks for transactional queries
As made mention of in commit 1dea3b4 ("apparmor: speed up transactional queries"), a single lock is currently used to synchronize transactional queries. We can, use the lock allocated for each file by VFS instead. Signed-off-by: Hamza Mahfooz <[email protected]> Signed-off-by: John Johansen <[email protected]>
1 parent aa4ceed commit d0d845a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

security/apparmor/apparmorfs.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,6 @@ struct multi_transaction {
811811
};
812812

813813
#define MULTI_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct multi_transaction))
814-
/* TODO: replace with per file lock */
815-
static DEFINE_SPINLOCK(multi_transaction_lock);
816814

817815
static void multi_transaction_kref(struct kref *kref)
818816
{
@@ -846,10 +844,10 @@ static void multi_transaction_set(struct file *file,
846844
AA_BUG(n > MULTI_TRANSACTION_LIMIT);
847845

848846
new->size = n;
849-
spin_lock(&multi_transaction_lock);
847+
spin_lock(&file->f_lock);
850848
old = (struct multi_transaction *) file->private_data;
851849
file->private_data = new;
852-
spin_unlock(&multi_transaction_lock);
850+
spin_unlock(&file->f_lock);
853851
put_multi_transaction(old);
854852
}
855853

@@ -878,9 +876,10 @@ static ssize_t multi_transaction_read(struct file *file, char __user *buf,
878876
struct multi_transaction *t;
879877
ssize_t ret;
880878

881-
spin_lock(&multi_transaction_lock);
879+
spin_lock(&file->f_lock);
882880
t = get_multi_transaction(file->private_data);
883-
spin_unlock(&multi_transaction_lock);
881+
spin_unlock(&file->f_lock);
882+
884883
if (!t)
885884
return 0;
886885

0 commit comments

Comments
 (0)