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
| ||
|
Date: Sun, 30 Nov 2014 18:52:05 -0800 From: Omar Sandoval <osandov@...ndov.com> To: Pranith Kumar <bobby.prani@...il.com> Cc: Chris Mason <clm@...com>, Josef Bacik <jbacik@...com>, Joe Perches <joe@...ches.com>, "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>, Josh Triplett <josh@...htriplett.org>, Steven Rostedt <rostedt@...dmis.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, LKML <linux-kernel@...r.kernel.org>, linux-btrfs@...r.kernel.org Subject: Re: [PATCH 3/3] btrfs: refactor btrfs_device->name updates On Sun, Nov 30, 2014 at 10:26:43AM -0500, Pranith Kumar wrote: > On Sun, Nov 30, 2014 at 3:26 AM, Omar Sandoval <osandov@...ndov.com> wrote: > > The rcu_string API introduced some new sparse errors but also revealed existing > > ones. First of all, the name in struct btrfs_device should be annotated as > > __rcu to prevent unsafe reads. Additionally, updates should go through > > rcu_dereference_protected to make it clear what's going on. This introduces > > some helper functions that factor out this functionality. > > > > Signed-off-by: Omar Sandoval <osandov@...ndov.com> > > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > > index 6e04f27..2298a70 100644 > > --- a/fs/btrfs/volumes.h > > +++ b/fs/btrfs/volumes.h > > @@ -54,7 +54,7 @@ struct btrfs_device { > > > > struct btrfs_root *dev_root; > > > > - struct rcu_string *name; > > + struct rcu_string __rcu *name; > > > > u64 generation; > > > > Since rcu_strings are rcu specific, why not annotate the char pointer > in 'struct rcu_string' with __rcu annotation? That should catch all > error-prone users of rcu_string. > Because the whole structure is RCU'd, not just the str part of it. If str is annotated as __rcu, when we (correctly) rcu_dereference an rcu_string and then access the str member, we'll still get sparse warnings. In any case, the above code does what I want it to do. See the following (non-sense but illustrative) example: #include <linux/rcustring.h> static void example_func(void) { struct rcu_string __rcu *example; char *str; str = example->str; } CHECK /home/osandov/linux/example/example.c /home/osandov/linux/example/example.c:7:13: warning: incorrect type in assignment (different address spaces) /home/osandov/linux/example/example.c:7:13: expected char *str /home/osandov/linux/example/example.c:7:13: got char [noderef] <asn:4>*<noident> -- Omar -- 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