From owner-freebsd-current@freebsd.org Tue Dec 8 16:12: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 E8BBF4A5414 for ; Tue, 8 Dec 2020 16:12:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4Cr4vp5DwMz4Zdx for ; Tue, 8 Dec 2020 16:12:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id B39334A4FED; Tue, 8 Dec 2020 16:12:38 +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 B35AD4A5143 for ; Tue, 8 Dec 2020 16:12:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 4Cr4vp4Xxvz4ZXW; Tue, 8 Dec 2020 16:12:38 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x430.google.com with SMTP id 91so12862207wrj.7; Tue, 08 Dec 2020 08:12:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EB0RxophiXZ9vXGD3jxDtthzjaQNHkqoV+npizz6be4=; b=IP28YhHTWQAIZZHFNZaPfE/tSmOSr/FCbaiXLIqQd1Qhx9vL7B4fXXXMBkP/Pfq3GW LtMB5mMKpyubOzPHSI0Dx0KfWT23wxbNlfhoEbOFL8DPcGiKN5zyolaHoewNlkemJ9GQ aQQkCzTdbnHfTPJj3CcCvOFcTd7bBBlbw51OCpU/59Z/Aw3nUflzAfDp7NlVk3lECXgY Wl74ABZv8AOtrsIERBQHiP8STuhYNt+OidOfKDcwk7bSwMX1LORKf0K/1OP76aBYc0pI lPmjoAGKcCbgd6oK1SnLETDR26FP+zERve+xK4V465ZCoE6pnDZqg+8aI2k7UWaWiDBf BfhQ== X-Gm-Message-State: AOAM532voqi1Pzy/kxSUff/TYBwJDP8ULn0lA6FQ3iXXX3OnXjcWtq3q sVpLeSDJKwzOLcB54fJ7RAWM6Ijbd01vj3oto90+NB38POY= X-Google-Smtp-Source: ABdhPJx6XjCZGCBaxK9n/+REaEX1xspcHmvXeZ/f4B3n/c4XkzcNKC72ilH8aTNknWaMg0Oqi3ArdmzacsG2/u+Ung0= X-Received: by 2002:a5d:5146:: with SMTP id u6mr27196284wrt.66.1607443956951; Tue, 08 Dec 2020 08:12:36 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:4d47:0:0:0:0:0 with HTTP; Tue, 8 Dec 2020 08:12:35 -0800 (PST) In-Reply-To: References: <20201208114718.GA33199@x8.osted.lan> From: Mateusz Guzik Date: Tue, 8 Dec 2020 17:12:35 +0100 Message-ID: Subject: Re: panic: general protection fault from uipc_sockaddr+0x4c To: Mark Johnston Cc: Peter Holm , current@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Cr4vp4Xxvz4ZXW 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:12:39 -0000 On 12/8/20, Mark Johnston wrote: > 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. > Oh I forgot consumers keep checking for fd_refcount. In that case probably would be best to add sx_wait_unlocked. >> 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. > -- Mateusz Guzik