lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1342045559.19666.28.camel@tucsk.pomaz.szeredi.hu>
Date:	Thu, 12 Jul 2012 00:25:59 +0200
From:	Miklos Szeredi <mszeredi@...e.cz>
To:	Eric Paris <eparis@...hat.com>
Cc:	Miklos Szeredi <miklos@...redi.hu>, viro@...IV.linux.org.uk,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] audit: clean up refcounting in audit-tree

On Fri, 2012-07-06 at 13:51 -0400, Eric Paris wrote:
> On Mon, 2012-06-25 at 19:46 +0200, Miklos Szeredi wrote:
> > From: Miklos Szeredi <mszeredi@...e.cz>
> > 
> > Drop the initial reference by fsnotify_init_mark early instead of
> > audit_tree_freeing_mark() at destroy time.
> > 
> > In the cases we destroy the mark before we drop the initial reference we need to
> > get rid of the get_mark that balances the put_mark in audit_tree_freeing_mark().
> > 
> > Signed-off-by: Miklos Szeredi <mszeredi@...e.cz>
> 
> I don't love this.  The reference from fsnotify_init_mark() should live
> until fsnotify_mark_destroy().  If we need to drop a reference in
> audit_tree_freeing_mark() we should be taking that elsewhere....
> 

There's no point in dropping a ref in ->freeing_mark, as the caller
needs to hold a ref anyways.


Thanks,
Miklos

> > ---
> >  kernel/audit_tree.c |   12 +++++++++---
> >  1 files changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> > index 31fdc48..7b95706 100644
> > --- a/kernel/audit_tree.c
> > +++ b/kernel/audit_tree.c
> > @@ -292,6 +292,7 @@ static void untag_chunk(struct node *p)
> >  	spin_unlock(&hash_lock);
> >  	spin_unlock(&entry->lock);
> >  	fsnotify_destroy_mark(entry);
> > +	fsnotify_put_mark(&new->mark);	/* drop initial reference */
> >  	goto out;
> >  
> >  Fallback:
> > @@ -330,7 +331,6 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
> >  		spin_unlock(&hash_lock);
> >  		chunk->dead = 1;
> >  		spin_unlock(&entry->lock);
> > -		fsnotify_get_mark(entry);
> >  		fsnotify_destroy_mark(entry);
> >  		fsnotify_put_mark(entry);
> >  		return 0;
> > @@ -346,6 +346,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
> >  	insert_hash(chunk);
> >  	spin_unlock(&hash_lock);
> >  	spin_unlock(&entry->lock);
> > +	fsnotify_put_mark(entry);	/* drop initial reference */
> >  	return 0;
> >  }
> >  
> > @@ -411,7 +412,6 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
> >  		spin_unlock(&chunk_entry->lock);
> >  		spin_unlock(&old_entry->lock);
> >  
> > -		fsnotify_get_mark(chunk_entry);
> >  		fsnotify_destroy_mark(chunk_entry);
> >  
> >  		fsnotify_put_mark(chunk_entry);
> > @@ -444,6 +444,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
> >  	spin_unlock(&chunk_entry->lock);
> >  	spin_unlock(&old_entry->lock);
> >  	fsnotify_destroy_mark(old_entry);
> > +	fsnotify_put_mark(chunk_entry);	/* drop initial reference */
> >  	fsnotify_put_mark(old_entry); /* pair to fsnotify_find mark_entry */
> >  	return 0;
> >  }
> > @@ -915,7 +916,12 @@ static void audit_tree_freeing_mark(struct fsnotify_mark *entry, struct fsnotify
> >  	struct audit_chunk *chunk = container_of(entry, struct audit_chunk, mark);
> >  
> >  	evict_chunk(chunk);
> > -	fsnotify_put_mark(entry);
> > +
> > +	/*
> > +	 * We are guaranteed to have at least one reference to the mark from
> > +	 * either the inode or the caller of fsnotify_destroy_mark().
> > +	 */
> > +	BUG_ON(atomic_read(&entry->refcnt) < 1);
> >  }
> >  
> >  static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode,
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ