Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'stable-4.10' of git://git.infradead.org/users/pcmoore/audit

Pull audit fixes from Paul Moore:
"Two small fixes relating to audit's use of fsnotify.

The first patch plugs a leak and the second fixes some lock
shenanigans. The patches are small and I banged on this for an
afternoon with our testsuite and didn't see anything odd"

* 'stable-4.10' of git://git.infradead.org/users/pcmoore/audit:
audit: Fix sleep in atomic
fsnotify: Remove fsnotify_duplicate_mark()

+14 -18
-12
fs/notify/mark.c
··· 510 510 } 511 511 } 512 512 513 - void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old) 514 - { 515 - assert_spin_locked(&old->lock); 516 - new->inode = old->inode; 517 - new->mnt = old->mnt; 518 - if (old->group) 519 - fsnotify_get_group(old->group); 520 - new->group = old->group; 521 - new->mask = old->mask; 522 - new->free_mark = old->free_mark; 523 - } 524 - 525 513 /* 526 514 * Nothing fancy, just initialize lists and locks and counters. 527 515 */
-2
include/linux/fsnotify_backend.h
··· 323 323 extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode); 324 324 /* find (and take a reference) to a mark associated with group and vfsmount */ 325 325 extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt); 326 - /* copy the values from old into new */ 327 - extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old); 328 326 /* set the ignored_mask of a mark */ 329 327 extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask); 330 328 /* set the mask of a mark (might pin the object into memory */
+14 -4
kernel/audit_tree.c
··· 231 231 if (size) 232 232 new = alloc_chunk(size); 233 233 234 + mutex_lock(&entry->group->mark_mutex); 234 235 spin_lock(&entry->lock); 235 236 if (chunk->dead || !entry->inode) { 236 237 spin_unlock(&entry->lock); 238 + mutex_unlock(&entry->group->mark_mutex); 237 239 if (new) 238 240 free_chunk(new); 239 241 goto out; ··· 253 251 list_del_rcu(&chunk->hash); 254 252 spin_unlock(&hash_lock); 255 253 spin_unlock(&entry->lock); 254 + mutex_unlock(&entry->group->mark_mutex); 256 255 fsnotify_destroy_mark(entry, audit_tree_group); 257 256 goto out; 258 257 } ··· 261 258 if (!new) 262 259 goto Fallback; 263 260 264 - fsnotify_duplicate_mark(&new->mark, entry); 265 - if (fsnotify_add_mark(&new->mark, new->mark.group, new->mark.inode, NULL, 1)) { 261 + if (fsnotify_add_mark_locked(&new->mark, entry->group, entry->inode, 262 + NULL, 1)) { 266 263 fsnotify_put_mark(&new->mark); 267 264 goto Fallback; 268 265 } ··· 296 293 owner->root = new; 297 294 spin_unlock(&hash_lock); 298 295 spin_unlock(&entry->lock); 296 + mutex_unlock(&entry->group->mark_mutex); 299 297 fsnotify_destroy_mark(entry, audit_tree_group); 300 298 fsnotify_put_mark(&new->mark); /* drop initial reference */ 301 299 goto out; ··· 313 309 put_tree(owner); 314 310 spin_unlock(&hash_lock); 315 311 spin_unlock(&entry->lock); 312 + mutex_unlock(&entry->group->mark_mutex); 316 313 out: 317 314 fsnotify_put_mark(entry); 318 315 spin_lock(&hash_lock); ··· 391 386 392 387 chunk_entry = &chunk->mark; 393 388 389 + mutex_lock(&old_entry->group->mark_mutex); 394 390 spin_lock(&old_entry->lock); 395 391 if (!old_entry->inode) { 396 392 /* old_entry is being shot, lets just lie */ 397 393 spin_unlock(&old_entry->lock); 394 + mutex_unlock(&old_entry->group->mark_mutex); 398 395 fsnotify_put_mark(old_entry); 399 396 free_chunk(chunk); 400 397 return -ENOENT; 401 398 } 402 399 403 - fsnotify_duplicate_mark(chunk_entry, old_entry); 404 - if (fsnotify_add_mark(chunk_entry, chunk_entry->group, chunk_entry->inode, NULL, 1)) { 400 + if (fsnotify_add_mark_locked(chunk_entry, old_entry->group, 401 + old_entry->inode, NULL, 1)) { 405 402 spin_unlock(&old_entry->lock); 403 + mutex_unlock(&old_entry->group->mark_mutex); 406 404 fsnotify_put_mark(chunk_entry); 407 405 fsnotify_put_mark(old_entry); 408 406 return -ENOSPC; ··· 421 413 chunk->dead = 1; 422 414 spin_unlock(&chunk_entry->lock); 423 415 spin_unlock(&old_entry->lock); 416 + mutex_unlock(&old_entry->group->mark_mutex); 424 417 425 418 fsnotify_destroy_mark(chunk_entry, audit_tree_group); 426 419 ··· 454 445 spin_unlock(&hash_lock); 455 446 spin_unlock(&chunk_entry->lock); 456 447 spin_unlock(&old_entry->lock); 448 + mutex_unlock(&old_entry->group->mark_mutex); 457 449 fsnotify_destroy_mark(old_entry, audit_tree_group); 458 450 fsnotify_put_mark(chunk_entry); /* drop initial reference */ 459 451 fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */