History

audit: use fsnotify group lock helpers

audit inode marks pin the inode so there is no need to set the FSNOTIFY_GROUP_NOFS flag.

Amir Goldstein committed 4 years ago

Commit 960bdff1 parent 642054b1 file · +16 −16Browse files

Unified · Split

kernel/audit_tree.c+16−16
@@ -351,7 +351,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct fsnotify_mark *mark) · 350 unmodified lines
351351 struct audit_chunk *new;
352352 int size;
353353
354− mutex_lock(&audit_tree_group->mark_mutex);
354+ fsnotify_group_lock(audit_tree_group);
355355 /*
356356 * mark_mutex stabilizes chunk attached to the mark so we can check
357357 * whether it didn't change while we've dropped hash_lock.
@@ -368,7 +368,7 @@ static void untag_chunk(struct audit_chunk *chunk, struct fsnotify_mark *mark) · 10 unmodified lines
368368 replace_mark_chunk(mark, NULL);
369369 spin_unlock(&hash_lock);
370370 fsnotify_detach_mark(mark);
371− mutex_unlock(&audit_tree_group->mark_mutex);
371+ fsnotify_group_unlock(audit_tree_group);
372372 audit_mark_put_chunk(chunk);
373373 fsnotify_free_mark(mark);
374374 return;
@@ -385,12 +385,12 @@ static void untag_chunk(struct audit_chunk *chunk, struct fsnotify_mark *mark) · 10 unmodified lines
385385 */
386386 replace_chunk(new, chunk);
387387 spin_unlock(&hash_lock);
388− mutex_unlock(&audit_tree_group->mark_mutex);
388+ fsnotify_group_unlock(audit_tree_group);
389389 audit_mark_put_chunk(chunk);
390390 return;
391391
392392 out_mutex:
393− mutex_unlock(&audit_tree_group->mark_mutex);
393+ fsnotify_group_unlock(audit_tree_group);
394394 }
395395
396396 /* Call with group->mark_mutex held, releases it */
@@ -400,19 +400,19 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) · 3 unmodified lines
400400 struct audit_chunk *chunk = alloc_chunk(1);
401401
402402 if (!chunk) {
403− mutex_unlock(&audit_tree_group->mark_mutex);
403+ fsnotify_group_unlock(audit_tree_group);
404404 return -ENOMEM;
405405 }
406406
407407 mark = alloc_mark();
408408 if (!mark) {
409− mutex_unlock(&audit_tree_group->mark_mutex);
409+ fsnotify_group_unlock(audit_tree_group);
410410 kfree(chunk);
411411 return -ENOMEM;
412412 }
413413
414414 if (fsnotify_add_inode_mark_locked(mark, inode, 0)) {
415− mutex_unlock(&audit_tree_group->mark_mutex);
415+ fsnotify_group_unlock(audit_tree_group);
416416 fsnotify_put_mark(mark);
417417 kfree(chunk);
418418 return -ENOSPC;
@@ -422,7 +422,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) · 3 unmodified lines
422422 if (tree->goner) {
423423 spin_unlock(&hash_lock);
424424 fsnotify_detach_mark(mark);
425− mutex_unlock(&audit_tree_group->mark_mutex);
425+ fsnotify_group_unlock(audit_tree_group);
426426 fsnotify_free_mark(mark);
427427 fsnotify_put_mark(mark);
428428 kfree(chunk);
@@ -444,7 +444,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) · 15 unmodified lines
444444 */
445445 insert_hash(chunk);
446446 spin_unlock(&hash_lock);
447− mutex_unlock(&audit_tree_group->mark_mutex);
447+ fsnotify_group_unlock(audit_tree_group);
448448 /*
449449 * Drop our initial reference. When mark we point to is getting freed,
450450 * we get notification through ->freeing_mark callback and cleanup
@@ -462,7 +462,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 11 unmodified lines
462462 struct audit_node *p;
463463 int n;
464464
465− mutex_lock(&audit_tree_group->mark_mutex);
465+ fsnotify_group_lock(audit_tree_group);
466466 mark = fsnotify_find_mark(&inode->i_fsnotify_marks, audit_tree_group);
467467 if (!mark)
468468 return create_chunk(inode, tree);
@@ -478,7 +478,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 9 unmodified lines
478478 for (n = 0; n < old->count; n++) {
479479 if (old->owners[n].owner == tree) {
480480 spin_unlock(&hash_lock);
481− mutex_unlock(&audit_tree_group->mark_mutex);
481+ fsnotify_group_unlock(audit_tree_group);
482482 fsnotify_put_mark(mark);
483483 return 0;
484484 }
@@ -487,7 +487,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 2 unmodified lines
487487
488488 chunk = alloc_chunk(old->count + 1);
489489 if (!chunk) {
490− mutex_unlock(&audit_tree_group->mark_mutex);
490+ fsnotify_group_unlock(audit_tree_group);
491491 fsnotify_put_mark(mark);
492492 return -ENOMEM;
493493 }
@@ -495,7 +495,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 1 unmodified line
495495 spin_lock(&hash_lock);
496496 if (tree->goner) {
497497 spin_unlock(&hash_lock);
498− mutex_unlock(&audit_tree_group->mark_mutex);
498+ fsnotify_group_unlock(audit_tree_group);
499499 fsnotify_put_mark(mark);
500500 kfree(chunk);
501501 return 0;
@@ -515,7 +515,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 13 unmodified lines
515515 */
516516 replace_chunk(chunk, old);
517517 spin_unlock(&hash_lock);
518− mutex_unlock(&audit_tree_group->mark_mutex);
518+ fsnotify_group_unlock(audit_tree_group);
519519 fsnotify_put_mark(mark); /* pair to fsnotify_find_mark */
520520 audit_mark_put_chunk(old);
521521
@@ -1044,12 +1044,12 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *mark, · 522 unmodified lines
10441044 {
10451045 struct audit_chunk *chunk;
10461046
1047− mutex_lock(&mark->group->mark_mutex);
1047+ fsnotify_group_lock(mark->group);
10481048 spin_lock(&hash_lock);
10491049 chunk = mark_chunk(mark);
10501050 replace_mark_chunk(mark, NULL);
10511051 spin_unlock(&hash_lock);
1052− mutex_unlock(&mark->group->mark_mutex);
1052+ fsnotify_group_unlock(mark->group);
10531053 if (chunk) {
10541054 evict_chunk(chunk);
10551055 audit_mark_put_chunk(chunk);