From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 0ED201E572F for ; Sun, 28 Dec 2025 09:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766913372; cv=none; b=iwvqz11CGKYSF08e5Gk/AOqF84zVoHjJ9ix10MgbBIyb0feS+Z9Xi/PTQeU3fPljLr61C/KR9qtgudDq7BRapNKgG87UZxI56GxDir/fAUcBtkFT8epi04tAXfkAdSgcCAm6cXi6H/6PtCaJs0/hLJ8XlIeuZx5HIll8IJd+N2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766913372; c=relaxed/simple; bh=nbWeBZR6XGVP524Smmctu9vgqAt5Q8hidLuEr/btmkk=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=jsBYPueqNE4IPu7guEPEoVEeJ15HojXBYrxX5nySJ6jRtaN+73Vm9y9xKsIOOgGGZVSQAcLcfRvBYrTNFyEdyrkjtZ83tCBptodEhuXpb4IXLgNrqgclHqBhTzQGcTbGIs93HfWZa/E4XbjR2keunLUG7O1g+cUFx1VJjJtSPPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DyERl40H; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=MSPFrPvr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DyERl40H"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="MSPFrPvr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766913368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vF17mDmjfT93oq9WAWMjwFVEZthCFBo8FRT7pwicBMM=; b=DyERl40HFQDZWCCrh1IfclDcTJKAHYVBoNFv1JPKwwsIWkkHXmv0rrTElLgd7C08n8CdOg jwcrMfpyYnbhHQ0mi9LBeRh7KZviuJdSeyGP00WYPNON9Ijo743cMQhkX7mXox/gXI0eU9 E2WnVglQB/sBzO/Irm9f0STTxNDtJzE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-ro-8HuKrPmKzdEUKQ6lDHA-1; Sun, 28 Dec 2025 04:16:06 -0500 X-MC-Unique: ro-8HuKrPmKzdEUKQ6lDHA-1 X-Mimecast-MFC-AGG-ID: ro-8HuKrPmKzdEUKQ6lDHA_1766913365 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-47d40e8a588so14213205e9.3 for ; Sun, 28 Dec 2025 01:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766913365; x=1767518165; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=vF17mDmjfT93oq9WAWMjwFVEZthCFBo8FRT7pwicBMM=; b=MSPFrPvrE4v2c2UpchBm0vWkmM5wkaBABcFezaTPG9W9yl68ViqBATTmPNRWYS/YWi 6Ew1xBmu3fh0jw88syyTDDUn/fOJQpbK/pm0+x0bhUwxVjngpQzaXhi6HfU4210+9RR4 IZ1YRjzgRL0DaT0DojZM1tZD7M83A8yD00wxGFw79nBkwzUHJXo9EgpdqvJhgbnGiAQZ ybrTcZEB6YdaN6NaQ3zZWRyXdzcNFiW9kyEVhyFXJd2SmwE2BWJ6MgWMdlUko7zqxykr upJfcWHRlxMj4OgJ1aM7+ysd+L6J7e5YplAxbMLY56+RicvdJWp/8skK6HI3xGHlPv07 h/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766913365; x=1767518165; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vF17mDmjfT93oq9WAWMjwFVEZthCFBo8FRT7pwicBMM=; b=d0p5jrYrs4kbHk9jvPNONAvg5cq0MEGBkXcGmzcl5BQ/LuxCPluvx9jzTrQjMDDfoJ HtsAtNJ8Jc2fmEucg4aB4yOqUbTAg7IZMCJ+uzlbNdw+l1nq9kZna25QTBJcnzjMo1rO NtXtrw5lkbtC7RLtowGf8xGe58EJG6uWBiMi0K1kMdvX7JXBnIQSCYZbcXnjlxpkr7MJ RxXHm3S9X/wXUeu0BzwUqja62ReSWS8RCnCL/i6eYLQB+gSuaTuHcsiLUG5aqKwGlbaW pd6E3/TLvdZLRomOkJTG+MmERff4rSQ8GGhABfXifw446WJvTCh1CAR2dyitbJvGWV0a h8Yw== X-Forwarded-Encrypted: i=1; AJvYcCW4XiYzQFVfdhCyHJ8zvkZq/Iu1SAGmHsVL96D6xZ3JiYk6nE4H1dLUWnJivdzN58LoGIo14/P66p0latQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxx/GDs0kHAGe+WkJPW6GKnG3rHvg2bTJNicA07LqYZe47S/G/b 6WGKUE96RxgCM0eA9/Ros7Dz82Fv3C4MlTCHSSbhxekEAycZMbzhgZG8C9H9oRJjwq+n67z3i7Q 0GyKQqHWnlguJkjfW68MzLq/qCgnaqK6b/xL0QvWHDSW0ZQWu+KZdMjphDxXBA802wg== X-Gm-Gg: AY/fxX7j//+pEDeVqTO6eeFJXY8vHR3Dt7mEqQEiLC+XM3b5Yx9l2tWrRG5RKehnNMa 3ECWqsriCDDZArYjSxAaBbo2hoqmVjaXf5YiquHsALUz6Nl6tFidWhimWjDuocrB7xwX/hzWPE/ 3sT+6LQ/cNGc2xHu5wsqUVlfqR6ogPvgRSOwR6ExAeYvqQmmioHyCXODRYZW3ETnXoTNtEC+Sv6 vWEVZ7weyAsnQuz+hYorqf56XWauwACZfkMFTZIIM68YpcIw1wKeSldaEMXDn+GcTt1377b/t5Z bo8oFeQ58lVixtcuxbKMsjZldpiNwnBQJUylH57v31zEaub8P/Ums0+9KRdbRiCCS5s+vp7Bnw+ YNdYzj4sAPVcRaA== X-Received: by 2002:a05:600c:46ce:b0:477:fcb:226b with SMTP id 5b1f17b1804b1-47d1953c020mr273497975e9.2.1766913365018; Sun, 28 Dec 2025 01:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1b7xKiUe0L9lJ/v6U9MSi8Fz0dXWgM5S/Kld+WqDKFXo/imkAnCu4ZFS2hAooiiE7pN9jOg== X-Received: by 2002:a05:600c:46ce:b0:477:fcb:226b with SMTP id 5b1f17b1804b1-47d1953c020mr273497725e9.2.1766913364558; Sun, 28 Dec 2025 01:16:04 -0800 (PST) Received: from [192.168.88.32] ([169.155.232.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be2724fe8sm627616145e9.1.2025.12.28.01.16.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Dec 2025 01:16:04 -0800 (PST) Message-ID: <88741cf8-7649-49e1-8d82-5440fccd618f@redhat.com> Date: Sun, 28 Dec 2025 10:16:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] nfc: llcp: avoid double release/put on LLCP_CLOSED in nfc_llcp_recv_disc() From: Paolo Abeni To: Qianchang Zhao , netdev@vger.kernel.org Cc: Krzysztof Kozlowski , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Simon Horman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Zhitong Liu References: <20251218025923.22101-1-pioooooooooip@gmail.com> <20251218025923.22101-2-pioooooooooip@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/28/25 10:02 AM, Paolo Abeni wrote: > On 12/18/25 3:59 AM, Qianchang Zhao wrote: >> nfc_llcp_sock_get() takes a reference on the LLCP socket via sock_hold(). >> >> In nfc_llcp_recv_disc(), when the socket is already in LLCP_CLOSED state, >> the code used to perform release_sock() and nfc_llcp_sock_put() in the >> CLOSED branch but then continued execution and later performed the same >> cleanup again on the common exit path. This results in refcount imbalance >> (double put) and unbalanced lock release. >> >> Remove the redundant CLOSED-branch cleanup so that release_sock() and >> nfc_llcp_sock_put() are performed exactly once via the common exit path, >> while keeping the existing DM_DISC reply behavior. >> >> Fixes: d646960f7986 ("NFC: Initial LLCP support") >> Cc: stable@vger.kernel.org >> Signed-off-by: Qianchang Zhao >> --- >> net/nfc/llcp_core.c | 5 ----- >> 1 file changed, 5 deletions(-) >> >> diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c >> index beeb3b4d2..ed37604ed 100644 >> --- a/net/nfc/llcp_core.c >> +++ b/net/nfc/llcp_core.c >> @@ -1177,11 +1177,6 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, >> >> nfc_llcp_socket_purge(llcp_sock); >> >> - if (sk->sk_state == LLCP_CLOSED) { >> - release_sock(sk); >> - nfc_llcp_sock_put(llcp_sock); > > To rephrase Krzysztof concernt, this does not looks like the correct > fix: later on nfc_llcp_recv_disc() will try a send over a closed socket, > which looks wrong. Instead you could just return after > nfc_llcp_sock_put(), or do something alike: > > if (sk->sk_state == LLCP_CLOSED) > goto cleanup; > > // ... > > > cleanup: > release_sock(sk); > nfc_llcp_sock_put(llcp_sock); > } I'm sorry for the confusing feedback above. I read the comments on patch 2/2 only after processing this one. Indeed following the half-interrupted discussion on old revision, with bad patch splitting is quite difficult. @Qianchang Zhao: my _guess_ is that on LLCP_CLOSED the code has to release the final sk reference... In any case discussion an a patch series revision is not concluded until the reviewer agrees on that. @Krzysztof: ... but still it looks like in the current code there is a double release on the sk socket lock, which looks wrong, what am I missing here? /P