From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB9772417D9 for ; Tue, 21 Apr 2026 13:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776779810; cv=none; b=XpLBNTs2EvN04d8ICSQGPWPESTBcDivZGBKU6bJrS529JUK/9fMVA0pUYRTeeL/8mc9tyfCc2abrgcp4s2/1mbkSwsjA2evZ9yVtT+XNlmtUYPHmPwuKItvxgvNGFyjRhAGFjt/3wxw8JtRCDX5CH/jicbZj4KS7EPqJxR3MgVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776779810; c=relaxed/simple; bh=xRR4YXHdNTwyaJomNKqEyxWDMa347weKXyNstaeXji0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VhKYkEhwRNK+5EZnDvra71beO1KkayJcPb0zvG2X357DtAvREwqoIlz4aFHPaStxeWJ7tx8Kisq8Fe0YuOC4SUF8Q/IrbSDQCp8KD90VMf3C0bWcfSGYj75aJ8nfLzXFN3bkK+jerFYXRVgYHhJK8TMjObqr6ikDY1yHvZ5I2NY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dUqiSiTV; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dUqiSiTV" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-8ee62a19730so68182885a.3 for ; Tue, 21 Apr 2026 06:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776779808; x=1777384608; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YpRWGV/9h2J0e2y4smv95jEfx6BRtkOqUuKuvF+USRA=; b=dUqiSiTVJLFNcIZJS9f3M9GROVSh0fq3yXxyAktO+Bkrm48rhDyLlx3YC0YE310mYJ pqG69K9VEpGhWylwLTvvOhZ0SchIhA1IV4o3obyKghiKwC4i4W8TqFKLVHaJT8p16aL0 Uyji6AMUf3kVPerUTCf2j435+M95U/XuppBSOV7bjDRyiBz7gDYfq4hzwu+AZxJXJqwH dCD8BlWpBPC23iltp6BuEIlgfhoJxM3K7wBwM+N31/v45p76ys9YhXhqF6LHi52HWj/3 0c5MiloTaqtUtrxHx7luFfj16M4zDDGkG0CxzI7oBUmmZyZIHfX6PoQaUZCWsh2IgK+p bDVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776779808; x=1777384608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YpRWGV/9h2J0e2y4smv95jEfx6BRtkOqUuKuvF+USRA=; b=YOoVSOj5xHAu8Av6a21wJAFI3KxH4+kfa+yy4FwQ2Y1xX03WTLqc3G21bnUBcO2Y76 lffCeJ7cF115y+sj+USADU9FTJ2a/Prmedag33qCeEq7z6GzPiF5hZCp00Z76igIu0dg aml66ErcSNTvTFx4imC2IpGiC1l4qvmV6KLHLo56DH+7ICVB16646KRFbdFIyiS4kfsf oR/y7zTyjPfGiIfUflUSARNqrRqi1UYxvmDxsUEKHWZ/lM+xzaLBlY41f3bPTfxtW36A 3JrayU6dTjGGc4uV6XbsOhMNNgHfrgUGnWO3AfG67XyftP+h9ExxpNhQFnOgkdF+tdV5 gv4g== X-Forwarded-Encrypted: i=1; AFNElJ/m1V2qPdU/a2C5ipLcF+VL5Usr0KReiIsuPwksLXe2DGWNhD2utiwZJ6O1PTJ6UqgwjmqG0QNbUxCnmCQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwQbP0/ryA17MtKT/P3gkt4P3vurIExV2lwdI7zhXjjdCYgk+V0 pJmTFm3ca9mLj74HVvSEyWABAt2NmFqrVs0yntE1YMdVXfdDfN7DyEfL X-Gm-Gg: AeBDieuQneU3quqEQTbVdAKmMlQyvdcgYsnn6PqBSYZQ/MLrWRd3CuuZhgP29kGCgB/ kYeJssH4+dpane1hD3++DnnIsi97zG93ON7wsXDaPjyPLPW6XclQbmfgZjhK9tTYhACkU64uDRx MXVsgU8qvSIryo5OZKnqc4EIXATaNeaOX0CcKoRh3SdHK6ob4K7JdycwiGWTME6jCgEa2JV71tX HwFeqrmytnR/zjAWs3bSGSlZhIq8jsU7MgWefkY0en0W64KygHn8qEvPmSdifMEmWYtgnou71XU fy4D7V9JGaEQDbVaZ9xhLjvjC3JhqeZZjNSa6PZjjesv708H9AJbU2GZAcEj2R7SwmFtQESZI/9 mWmc9BtRShksZ8ar7fxrtHS9MaGviqe2C3lQLheFk39AjuHIOrxk5BEcXOe5zvtJqYCRQDm+qBf SsKxTgQvky2Vy/rCVtdATfvU0Xs4D55KYoCL0KgMlb5EMTF+5yNI4+oLEAlHE6K1PnWeULtc8DX 1IOECCo+CtjycjJAp5DGzfg9PC0jzMA3bSa2PrZtQ== X-Received: by 2002:a05:620a:6ccd:b0:8d0:ad0:c026 with SMTP id af79cd13be357-8e78fd1ee3dmr2532149385a.21.1776779807613; Tue, 21 Apr 2026 06:56:47 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8e7d69ad48asm1033231385a.19.2026.04.21.06.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 06:56:46 -0700 (PDT) From: Michael Bommarito To: Marcel Holtmann , Luiz Augusto von Dentz Cc: Mat Martineau , Hyunwoo Kim , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 0/2] Bluetooth: L2CAP: fix zero txwin_size handling and repeated CONFIG_RSP re-init Date: Tue, 21 Apr 2026 09:56:37 -0400 Message-ID: <20260421135639.3185653-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <20260417221628.1674866-1-michael.bommarito@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Luiz, Thanks for the review. v1 mixed the original zero-txwin fix with a defensive l2cap_seq_list_init(size == 0) error return. Re-checking that path made it clear the reroll should be split: 1. keep the original report focused on zero txwin_size, but fix it by normalizing zero window values at the actual inputs to the ERTM state machine and by making sequence-list teardown idempotent, rather than by introducing a new init-time failure path 2. handle the separate repeated-CONFIG_RSP ERTM re-init bug in its own patch, matching the BT_CONNECTED guard that commit 25f420a0d4cf already added on the CONFIG_REQ side While auditing the Sashiko comments, I also checked the claimed CONF_EWS_RECV bypass. I did not carry that theory into v2: in this tree CONF_EWS_RECV is declared but never set, so the concrete zero-window paths are the plain RFC option, the local L2CAP_OPTIONS socket setting, and the CONFIG_RSP / conf_rfc_get negotiation state. To make sure the reroll covered all the zero-entry sites (and only the zero-entry sites), I enumerated every assignment to tx_win / ack_win / remote_tx_win / txwin_size in net/bluetooth/l2cap_core.c and confirmed patch 1 normalizes the four reachable input paths -- the local L2CAP_OPTIONS setsockopt, l2cap_txwin_setup() on the outgoing RFC, the L2CAP_MODE_ERTM branch of l2cap_parse_conf_req(), and the EWS / RFC branches of l2cap_parse_conf_rsp() and l2cap_conf_rfc_get(). The only other writers are the channel-create defaults in l2cap_chan_create() (hard-coded to L2CAP_DEFAULT_TX_WINDOW) and the outgoing rfc.txwin_size = 0 assignments in L2CAP_MODE_BASIC / L2CAP_MODE_STREAMING branches, where a zero is spec-correct and never feeds ack_win. l2cap_seq_list_free()'s callers are l2cap_chan_del() (channel teardown) and l2cap_ertm_init()'s error path; clearing the list metadata after kfree() is safe for both and is what makes the partially-initialized re-entry in the failure path no longer a double-free source. For patch 2, the BT_CONNECTED guard added to l2cap_config_rsp() mirrors the existing one in l2cap_config_req() (lines 4339..4348 in this tree) so both sides of the CONFIG exchange now refuse to re-enter l2cap_ertm_init() once the channel is already connected. I did not pin down a single introducing commit for the CONFIG_RSP side during this pass, so patch 2 keeps Cc: stable@ without a speculative Fixes: tag; happy to add one if you'd prefer a specific reference. Changes since v1 ---------------- - Split the reroll into two patches: the zero-txwin fix and the separate repeated-CONFIG_RSP ERTM re-init fix. - Dropped the v1 l2cap_seq_list_init(size == 0) -> -EINVAL defence and instead normalize zero tx window values where they enter negotiated ERTM state. - Clamp the local L2CAP_OPTIONS txwin_size = 0 case back to L2CAP_DEFAULT_TX_WINDOW. - Normalize zero tx window values seen during CONFIG_RSP / RFC parsing so ack_win does not collapse to 0. - Make l2cap_seq_list_free() clear list metadata after kfree so later teardown cannot trip over a previously freed list. Michael Bommarito (2): Bluetooth: L2CAP: handle zero txwin_size in ERTM RFC option Bluetooth: L2CAP: skip ERTM re-init on repeated CONFIG_RSP net/bluetooth/l2cap_core.c | 39 +++++++++++++++++++++++++++----------- net/bluetooth/l2cap_sock.c | 3 +++ 2 files changed, 31 insertions(+), 11 deletions(-) -- 2.53.0