From owner-svn-src-head@freebsd.org Wed Apr 17 21:17:28 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2D3F1579F25; Wed, 17 Apr 2019 21:17:27 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 47EFC943D8; Wed, 17 Apr 2019 21:17:26 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id x3HLHIx9060586 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 17 Apr 2019 14:17:18 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id x3HLHIxr060585; Wed, 17 Apr 2019 14:17:18 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Wed, 17 Apr 2019 14:17:18 -0700 From: Gleb Smirnoff To: Kristof Provost 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> References: <201904171642.x3HGgslA075253@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201904171642.x3HGgslA075253@repo.freebsd.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Rspamd-Queue-Id: 47EFC943D8 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.988,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Apr 2019 21:17:28 -0000 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