From patchwork Mon Mar 31 13:25:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 877666 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 3476B211299 for ; Mon, 31 Mar 2025 13:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743427581; cv=none; b=pBsQ3FC94Sns7fayP5IkggOpa0j3ns2eY+KzeenPZc+MY5NDABmvxOw1QSgZGo402VS16hOH2DvKbxvftUZRQzSmy4yUlVaAJjXQCmAa345DDK2Dgmswpv9752gy4n8E+Rdqb1O0KlhrTtTFHUxNWldnupa92J4YvZAeKq5JY1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743427581; c=relaxed/simple; bh=HrGKD0KbZmhm6DKZt5OMcxAy1MWarDSf6WaP2/wp06Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k6WAW891C5xgE2fxR8xA4DFO0RMcH4cJ4dpcKiIuH9J6wKiiyC6Yv40HtfKxpzdBrvoMnQ4shzmXrU8bRzkCKtSquE0u8f4HJRc+PcfpMC3Jzeim9ilp2mNbjSoV602U8rcVEus+sgHwwycTVga3GpOJrVIBzf07JPaycwZj300= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=TKRtfVRh; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=TKRtfVRh; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="TKRtfVRh"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="TKRtfVRh" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2DBD51F456; Mon, 31 Mar 2025 13:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1743427577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qjSnAYDRUpOAk4hdheIUEiWeZ1WwxhmbKrlRr2urYws=; b=TKRtfVRhtAmJTtTvIdzhIm1Y7eede7SdNcl7tQ38ICgzuBxHkBGJe9UrFALLWNpape6Eov 941tQV6FZ1VK6iwNlmhNVq0sY+AYKH7zX4DtIuEf5+pHgLqTEWApt/FA6aGcw1GDnUk7wf nqYv+B4kJ9Bjk3iHG0uAIKA1lZAQ3+Q= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1743427577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qjSnAYDRUpOAk4hdheIUEiWeZ1WwxhmbKrlRr2urYws=; b=TKRtfVRhtAmJTtTvIdzhIm1Y7eede7SdNcl7tQ38ICgzuBxHkBGJe9UrFALLWNpape6Eov 941tQV6FZ1VK6iwNlmhNVq0sY+AYKH7zX4DtIuEf5+pHgLqTEWApt/FA6aGcw1GDnUk7wf nqYv+B4kJ9Bjk3iHG0uAIKA1lZAQ3+Q= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 012FB13A1F; Mon, 31 Mar 2025 13:26:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UN+9OviX6meJIQAAD6G6ig (envelope-from ); Mon, 31 Mar 2025 13:26:16 +0000 From: Oliver Neukum To: gregkh@linuxfoundation.org, bjorn@mork.no, loic.poulain@linaro.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH 2/4] USB: wdm: close race between wdm_open and wdm_wwan_port_stop Date: Mon, 31 Mar 2025 15:25:02 +0200 Message-ID: <20250331132614.51902-3-oneukum@suse.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331132614.51902-1-oneukum@suse.com> References: <20250331132614.51902-1-oneukum@suse.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -6.80 X-Spam-Flag: NO Clearing WDM_WWAN_IN_USE must be the last action or we can open a chardev whose URBs are still poisoned Fixes: cac6fb015f71 ("usb: class: cdc-wdm: WWAN framework integration") Signed-off-by: Oliver Neukum --- drivers/usb/class/cdc-wdm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 12038aa43942..e67844618da6 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -870,8 +870,9 @@ static void wdm_wwan_port_stop(struct wwan_port *port) poison_urbs(desc); desc->manage_power(desc->intf, 0); clear_bit(WDM_READ, &desc->flags); - clear_bit(WDM_WWAN_IN_USE, &desc->flags); unpoison_urbs(desc); + /* this must be last lest we open a poisoned device */ + clear_bit(WDM_WWAN_IN_USE, &desc->flags); } static void wdm_wwan_port_tx_complete(struct urb *urb)