Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp40893rdh; Mon, 18 Dec 2023 10:56:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzKJyobVcJpT43Jn3xLFgW7a/5Q9BUIS3tx+sQ3rvtslCeRE6izi35o8yK8OVySVRYm2fN X-Received: by 2002:a50:99cf:0:b0:553:34b1:1130 with SMTP id n15-20020a5099cf000000b0055334b11130mr1016471edb.58.1702925809326; Mon, 18 Dec 2023 10:56:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702925809; cv=pass; d=google.com; s=arc-20160816; b=NAipj3A+pFAb1F0JYAoKc2GpHe/9xtt/ARLBaVCJKj8AxtOc4zmTis/ZV02RkWeq9L pGTRxNz2DPbatkpwMyiGIPLZmBmh/q7rznhby99S0BfS3mbVQOa5ekmJdOdY5IvVvJlZ hIs6rVwVdJEiA5hk/x96hdvqyHs/cp7oN2NAZ5vIVRRX5Rdfouf0Z9W+Y9AwSEF/f1C3 7d3pwbfcPEjvH/v8So5rYz/UqUOSkMkBmUMYCdVITAs5J8HoIYtQEuiNeB2ps6doS5oW n1xuw2IMkm0+p/FSzaZi3N1AMl+dBoJnqXK9toeo8DV3IHoQ1JPODdz1GSLWiGjCCaJ7 M3ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:importance:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=U66pKooJUfR7TnaJpMLRYIeBDW23xBDJpRAZey+fgdc=; fh=MWDP0/IABKBkNAWrXQs51gY7IfeuDrtGxzy1OCCOGoQ=; b=0mnva3B09MnD6rKIuNuG85ByxseyZs7o/n9p9QcN7ZvTTWXfMD0Oy297+bpuz74aBl x4Wkp44oxkVgb+ZALZD5Ju3h8GFp5rAfwTiUVvm06DcCHL9ONA6htIyx8zSCZthIsGmU +jXFXPEON6SMj/w90uyFO4yoQPj4MltV4Uvq5udA8LRg1xbF9Y1AFBvWtgd82aFv8O/b yzrkOr1pgPKzWIFU7bgChEcxHe+5KHP2yU2PchHyHzMqlBGvffwNy6stLIdyDMZUbNly 67hl2Kys32U1Orr5kYx7W0CptsxMQTU6jwYUKVQf1tRvNw94pE2x8Iiw7SGUcx/KfbxP Mz5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=YeyPUT89; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel+bounces-4265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r5-20020a50d685000000b005530ec1b918si2106225edi.603.2023.12.18.10.56.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:56:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=YeyPUT89; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel+bounces-4265-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EE5F91F23053 for ; Mon, 18 Dec 2023 18:56:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0F245D74B; Mon, 18 Dec 2023 18:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siddh.me header.i=code@siddh.me header.b="YeyPUT89" X-Original-To: linux-kernel@vger.kernel.org Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 853201EB24; Mon, 18 Dec 2023 18:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=siddh.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=siddh.me ARC-Seal: i=1; a=rsa-sha256; t=1702925748; cv=none; d=zohomail.in; s=zohoarc; b=D+FmKTCl43bfhfUKQmCUxHOQTjaAXyP/W5ffXJWbfaxcgQB/Opu/E19h3mTIqqYWPo5T9+RJnRcu/B8vf7tHwSAnlY7UOkqGkdU4Cs49aG9Op1nMGQqQOgjPDzOIg3X3LkUkjQQtzPQKt1+pk69LtTJ5cHncUngMOfWA1YZvdNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1702925748; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=U66pKooJUfR7TnaJpMLRYIeBDW23xBDJpRAZey+fgdc=; b=GVvbEJseT0kebZPXxsw7+wdSWlxZv5kXEnr9OSmrUGYWOm4DX5BRqWiB8jYRPWCpRiXiPy1hF+9gIGpfN+SkLnRzwioIcpsQXvG61/aDnK4bolZuk0Q/OVWkx0bLMG9Q5H7QnZngoikq7Vr4MNJsrAwyvbTt7NS2BNjvGwBSIks= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1702925748; s=zmail; d=siddh.me; i=code@siddh.me; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=U66pKooJUfR7TnaJpMLRYIeBDW23xBDJpRAZey+fgdc=; b=YeyPUT89Msd3TQhtUSVEOVig93P0jLiNesER9OZuP4tRriHJVfbxnkhGSRFPogAD ibBqva0KEsYUmHq2e00ax1zcRwnqkfqmFj6JuzuFXsUN7jrKSR0dNJwxIwtz90aTKqr qOHmRnv052/n9pzdkwq5sVB67M9Je+wsLuZV0dQA= Received: from mail.zoho.in by mx.zoho.in with SMTP id 1702925716591727.0450941163903; Tue, 19 Dec 2023 00:25:16 +0530 (IST) Date: Tue, 19 Dec 2023 00:25:16 +0530 From: Siddh Raman Pant To: "Krzysztof Kozlowski" Cc: "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Suman Ghosh" , "netdev" , "linux-kernel" , "syzbot+bbe84a4010eeea00982d" Message-ID: <18c7e484c46.35167daf376072.28325334020826186@siddh.me> In-Reply-To: <6160aa1e-5f77-4d7d-aafd-e1ac7606bf06@linaro.org> References: <0d812b9aae2f16691d373460b06c5f3e098ed2a6.1702816635.git.code@siddh.me> <6160aa1e-5f77-4d7d-aafd-e1ac7606bf06@linaro.org> Subject: Re: [PATCH net-next v6 1/2] nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail On Mon, 18 Dec 2023 15:09:00 +0530, Krzysztof Kozlowski wrote: > On 17/12/2023 14:11, Siddh Raman Pant wrote: > > static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, > > @@ -959,8 +974,18 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, > > } > > > > new_sock = nfc_llcp_sock(new_sk); > > - new_sock->dev = local->dev; > > + > > new_sock->local = nfc_llcp_local_get(local); > > + if (!new_sock->local) { > > + reason = LLCP_DM_REJ; > > + release_sock(&sock->sk); > > + sock_put(&sock->sk); > > + sock_put(&new_sock->sk); > > Why is this needed? Which part earlier gets the reference? Thanks for pointing out. sk_init sets refcount to 1. Actually on a further look, the next line shouldn't be there as nfc_llcp_sock_free() is already called in sk->sk_destruct (== llcp_sock_destruct()), which is called via __sk_destruct(). As sock_put() -> sk_free() -> __sk_destruct() -> sk_prot_free(), so we need to put. TBH really don't know why nfc_llcp_sock_free() is not static. > > + nfc_llcp_sock_free(new_sock); > > This order is still wrong. Unwinding is almost always done in reversed > order, for good reasons. Why do you unwind in other order? Oops, extremely sorry about that :( I reverted back to wrong ordering from an older local commit and didn't check. I'll send the fixed one. Thanks, Siddh