[Devel] [PATCH rh7] fs/fuse kio: add a sanity check on statistic inc

Kirill Tkhai ktkhai at virtuozzo.com
Wed Aug 21 14:00:39 MSK 2019


On 21.08.2019 13:38, Konstantin Khorenko wrote:
> As there are still possible cases when we expect code to work without
> statistic inited, it's theoretically possible some day we again get an
> update request for non-inited stat struct, and corrupt stack-protector
> cookie and who knows what alse.
> 
> So add a sanity check to prevent it.
> 
> https://jira.sw.ru/browse/PSBM-96128
> 
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>

> ---
>  fs/fuse/kio/pcs/fuse_stat.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c
> index b57be607f5e1..c91bfe8b3bf7 100644
> --- a/fs/fuse/kio/pcs/fuse_stat.c
> +++ b/fs/fuse/kio/pcs/fuse_stat.c
> @@ -31,6 +31,12 @@ static u64 lat_oreder_list[] = {
>  
>  static inline void fuse_val_stat_update(struct fuse_val_stat *s, u64 val)
>  {
> +	/*
> +	 * Sanity check. In case s == NULL, stack protector cookie is
> +	 * corrupted, quite difficult to debug.
> +	 */
> +	BUG_ON(!s);
> +
>  	preempt_disable();
>  	if (!__this_cpu_read(s->events)) {
>  		__this_cpu_write(s->val_min, val);
> @@ -48,6 +54,11 @@ void fuse_latency_update(struct fuse_lat_stat *s, u64 val)
>  {
>  	int i;
>  
> +	/*
> +	 * Sanity check. In case s == NULL, stack protector cookie is
> +	 * corrupted, quite difficult to debug.
> +	 */
> +	BUG_ON(!s);
>  	this_cpu_inc(s->count);
>  	for (i = LAT_ORDER1; i <= LAT_ORDER5; i++) {
>  		if (likely(val <= lat_oreder_list[i])) {
> 



More information about the Devel mailing list