[GIT PULL] SafeSetID LSM changes for 5.4

Ingo Molnar mingo at kernel.org
Mon Oct 21 06:58:11 UTC 2019


* Paul E. McKenney <paulmck at kernel.org> wrote:

> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -383,20 +383,22 @@ do {									      \
>  } while (0)
>  
>  /**
> - * rcu_swap_protected() - swap an RCU and a regular pointer
> - * @rcu_ptr: RCU pointer
> + * rcu_replace() - replace an RCU pointer, returning its old value
> + * @rcu_ptr: RCU pointer, whose old value is returned
>   * @ptr: regular pointer
> - * @c: the conditions under which the dereference will take place
> + * @c: the lockdep conditions under which the dereference will take place
>   *
> - * Perform swap(@rcu_ptr, @ptr) where @rcu_ptr is an RCU-annotated pointer and
> - * @c is the argument that is passed to the rcu_dereference_protected() call
> - * used to read that pointer.
> + * Perform a replacement, where @rcu_ptr is an RCU-annotated
> + * pointer and @c is the lockdep argument that is passed to the
> + * rcu_dereference_protected() call used to read that pointer.  The old
> + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr.
>   */
> -#define rcu_swap_protected(rcu_ptr, ptr, c) do {			\
> +#define rcu_replace(rcu_ptr, ptr, c)					\
> +({									\
>  	typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c));	\
>  	rcu_assign_pointer((rcu_ptr), (ptr));				\
> -	(ptr) = __tmp;							\
> -} while (0)
> +	__tmp;								\
> +})

One small suggestion, would it make sense to name it "rcu_replace_pointer()"?

This would make it fit into the pointer handling family of RCU functions: 
rcu_assign_pointer(), rcu_access_pointer(), RCU_INIT_POINTER() et al?

rcu_swap() would also look a bit weird if used in MM code. ;-)

Thanks,

	Ingo



More information about the Linux-security-module-archive mailing list