From owner-freebsd-current@freebsd.org Tue Dec 8 16:05:38 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1732F4A4B79 for ; Tue, 8 Dec 2020 16:05:38 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4Cr4lj5DQdz4Ych for ; Tue, 8 Dec 2020 16:05:37 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id B2FAE4A49D9; Tue, 8 Dec 2020 16:05:37 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B23D04A4A61 for ; Tue, 8 Dec 2020 16:05:37 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cr4lj3yYjz4YZC; Tue, 8 Dec 2020 16:05:37 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf31.google.com with SMTP id dm12so8437180qvb.3; Tue, 08 Dec 2020 08:05:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=tUZBUyJwHlSoMpmE43+Eu4h2PtjZWNGD+V8anci4IZQ=; b=gBzoJOQxfozo5+2kt6AffW8cZuAnZGPTJDvk1X+ifTzJSfVADLgNjwSgmIF9gNPBhI dtwyztW1z9Aci5pxtjPyTA5OPiLKv4345WQ2IXekMPv9WFKkAX5QUbWb8fPmshWafnpY nkss3XbdkYDeBs3c0A/Jp9y25C3ll5jJATXLBqXnvwiYd5dwQjjsNi7LpKWos2LGf8Ct Bq4jbcMMMfMXxM9wBvpk6A7Qa5fWTxoxZF8FdBdwX1qjKTMoN70+4ZBLBZTT/AJePJFx SfPolO3c+Nq1jpmZv1LrzjY5VVSiqdL0jC/iH895K34bsBql9dWHRrNz4vzVHvKXYb7l vBwA== X-Gm-Message-State: AOAM532xPyVtew2MccNQoqIp4F3rsA+rsDEI6DYZXo4OZiWF05tD3/MJ HfUh7Vifniv85XO8o+ocg1I= X-Google-Smtp-Source: ABdhPJyil2hno+S+pE0c7aqwShOrfAkJk9AiLvRUe4eQ5Hc8fOTSHebEMYGpePDuoMLjHP2GhEsGjA== X-Received: by 2002:a0c:d68d:: with SMTP id k13mr28391150qvi.62.1607443536495; Tue, 08 Dec 2020 08:05:36 -0800 (PST) Received: from raichu ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id a3sm13684591qtp.63.2020.12.08.08.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 08:05:35 -0800 (PST) Sender: Mark Johnston Date: Tue, 8 Dec 2020 11:05:33 -0500 From: Mark Johnston To: Mateusz Guzik Cc: Peter Holm , current@freebsd.org Subject: Re: panic: general protection fault from uipc_sockaddr+0x4c Message-ID: References: <20201208114718.GA33199@x8.osted.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4Cr4lj3yYjz4YZC X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2020 16:05:38 -0000 On Tue, Dec 08, 2020 at 04:40:16PM +0100, Mateusz Guzik wrote: > I think this is a long standing bug against exiting processes. > > filedesc_out only increments *hold* count, but that does not prevent > fdescfree_fds from progressing and freeing everything without any > locks held. I think it is fallout from r367777: before that, fdescfree() acquired and released the exclusive fd table lock between decrementing fdp->fd_refcount and calling fdescfree_fds(). This would serialize with the loop in kern_proc_fildesc_out(), which checks fdp->fd_refcount > 0 at the beginning of each iteration. Now there is no serialization and they can race. > A hotfix (for mfc) would add locking around it, but a long term fix > should wait for hold count to drain. By that point there can't be any > new arrivals due to: > > PROC_LOCK(p); > p->p_fd = NULL; > PROC_UNLOCK(p); > > I'll code both later today.