Skip to content

audit: Fix various races when tagging and untagging mounts

Jan Kara linux-audit 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest14 patches 14 repliesIn review
  2. v311 patches 28 repliesSuperseded
  3. v210 patches 21 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v16 patches19 repliesSuperseded

Changes in v4 from the cover letter

* Renamed mark to amark in alloc_mark()
* Fixed intermediate compilation breakage in one patch
* Fixed possible lockup due to prune_one() racing with audit_tree_freeing_mark() and never making progress
* Simplified locking around untag_chunk()
* Fixed list corruption of chunk->trees list when tag_chunk() added a tree to chunk->trees and then replace_chunk() called list_replace(&old->trees, &chunk->trees);
* I've dropped the patch for audit testsuite from this posting since it didn't change since v2 and Paul picked it up AFAIU.
* Added reviewed-by tags for unchanged patches

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14audit_tree: Remove mark->lock lockingkernel/audit_tree.c+4 -200 replies
2/14audit: Fix possible spurious -ENOSPC errorkernel/audit_tree.c+16 -100 replies
3/14audit: Fix possible tagging failureskernel/audit_tree.c+10 -70 replies
4/14audit: Embed key into chunkkernel/audit_tree.c+8 -190 replies
5/14audit: Make hash table insertion safe against concurrent lookupskernel/audit_tree.c+29 -30 replies
6/14audit: Factor out chunk replacement codekernel/audit_tree.c+40 -466 replies
7/14audit: Remove pointless check in insert_hash()kernel/audit_tree.c+0 -20 replies
8/14audit: Provide helper for dropping mark's chunk referencekernel/audit_tree.c+11 -10 replies
9/14audit: Allocate fsnotify mark independently of chunkkernel/audit_tree.c+50 -140 replies
10/14audit: Guarantee forward progress of chunk untaggingkernel/audit_tree.c+17 -251 reply
11/14audit: Drop all unused chunk nodes during deletionkernel/audit_tree.c+18 -93 replies
12/14audit: Simplify locking around untag_chunk()kernel/audit_tree.c+40 -353 replies
13/14audit: Replace chunk attached to mark instead of replacing markkernel/audit_tree.c+83 -771 reply
14/14audit: Use 'mark' name for fsnotify_mark variableskernel/audit_tree.c+40 -390 replies

Reviews trailers per patch

13 of 14 patches have a Reviewed-by or Acked-by.

PatchRichard Guy Briggs
1/14R-b
2/14R-b
3/14R-b
4/14R-b
5/14R-b
6/14R-b
7/14R-b
8/14R-b
9/14R-b
10/14R-b
11/14R-b
12/14
13/14R-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH 0/14 v4] audit: Fix various races when tagging and untagging mounts

Hello,

this is the fourth revision of the series that addresses problems I have identified when trying to understand how exactly is kernel/audit_tree.c using generic fsnotify framework. I hope I have understood all the interactions right but careful review is certainly welcome.

The patches have been tested by a stress test I have written which mounts & unmounts filesystems in the directory tree while adding and removing audit rules for this tree in parallel and accessing the tree to generate events.

Note that after running the stress test for ~10 hours, the kernel crashed in shmem_evict_inode() but I have tracked that down to an independent bug in fsnotify infrastructure which I'll fix separately and push the fix through my tree.

Changes since v3:
* Renamed mark to amark in alloc_mark()
* Fixed intermediate compilation breakage in one patch
* Fixed possible lockup due to prune_one() racing with audit_tree_freeing_mark() and never making progress
* Simplified locking around untag_chunk()
* Fixed list corruption of chunk->trees list when tag_chunk() added a tree to chunk->trees and then replace_chunk() called list_replace(&old->trees, &chunk->trees);
* I've dropped the patch for audit testsuite from this posting since it didn't change since v2 and Paul picked it up AFAIU.
* Added reviewed-by tags for unchanged patches

Changes since v2:
* Fixed up mark freeing to use proper pointer as pointed out by Amir
* Changed some naming based on Paul's review

Changes since v1:
* Split the last patch to ease review
* Rewrite test script so that it can be included in audit testsuite
* Some cleanups and improvements suggested by Amir

Honza