Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Apr 2019 14:17:18 -0700
From:      Gleb Smirnoff <glebius@freebsd.org>
To:        Kristof Provost <kp@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r346319 - head/sys/netpfil/pf
Message-ID:  <20190417211718.GX1243@FreeBSD.org>
In-Reply-To: <201904171642.x3HGgslA075253@repo.freebsd.org>
References:  <201904171642.x3HGgslA075253@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
  Kristof,

On Wed, Apr 17, 2019 at 04:42:54PM +0000, Kristof Provost wrote:
K> Modified: head/sys/netpfil/pf/pf_ioctl.c
K> ==============================================================================
K> --- head/sys/netpfil/pf/pf_ioctl.c	Wed Apr 17 16:31:30 2019	(r346318)
K> +++ head/sys/netpfil/pf/pf_ioctl.c	Wed Apr 17 16:42:54 2019	(r346319)
K> @@ -3103,24 +3103,24 @@ DIOCCHANGEADDR_error:
K>  			break;
K>  		}
K>  
K> -		PF_RULES_WLOCK();
K> +		PF_RULES_RLOCK();
K>  		n = pfr_table_count(&io->pfrio_table, io->pfrio_flags);
K>  		io->pfrio_size = min(io->pfrio_size, n);
K> +		PF_RULES_RUNLOCK();
K>  
K>  		totlen = io->pfrio_size * sizeof(struct pfr_table);
K>  		pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table),
K>  		    M_TEMP, M_NOWAIT);
K>  		if (pfrts == NULL) {
K>  			error = ENOMEM;
K> -			PF_RULES_WUNLOCK();
K>  			break;
K>  		}
K>  		error = copyin(io->pfrio_buffer, pfrts, totlen);
K>  		if (error) {
K>  			free(pfrts, M_TEMP);
K> -			PF_RULES_WUNLOCK();
K>  			break;
K>  		}
K> +		PF_RULES_WLOCK();
K>  		error = pfr_set_tflags(pfrts, io->pfrio_size,
K>  		    io->pfrio_setflag, io->pfrio_clrflag, &io->pfrio_nchange,
K>  		    &io->pfrio_ndel, io->pfrio_flags | PFR_FLAG_USERIOCTL);

Couple comments:

1) Now we can malloc with M_WAITOK.
2) Are we sure that table count won't change while we dropped the lock?

-- 
Gleb Smirnoff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190417211718.GX1243>