From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (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 D738631A06C for ; Sat, 14 Mar 2026 18:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773512569; cv=none; b=qkhhYmyrzf3SEYoAyVPCnc10ee9pIceRr3lo/cDS/dD4lfj6jVNMH/H0x/MCtYyxsKD3se9VKzN3MbC7VBd3BkNnu5FIkN8PXwWgHP/X52PbQUUWugg6mVnjnT5P0BF+Moygv/bK5C4VO96AD0Q3jSb6AoA97t93r5Y6SMMIf0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773512569; c=relaxed/simple; bh=MdmXY2GXew3PZuMW9rQw+epMoKON3b5tfGh93QdDJkM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CjB/IVhD3ekZqUBrFyHz9p7BPU64BxBzwdUclwXOFDuiWBOoQm/c7D5SGiyvu1UCrLpjDLmO9BCkhV6M6nVZl2WJCl9PjvSeYsjxFOYyxMIvF9egzjXONqIm422FRHal80NEzyTjvM5PD7ZQeSqwAukqN58qsQK2G322+J1pfZI= 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=X+1/y/GS; arc=none smtp.client-ip=74.125.82.50 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="X+1/y/GS" Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-128b9b7e3edso1837996c88.0 for ; Sat, 14 Mar 2026 11:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773512567; x=1774117367; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=NZy4YaOyfC8HFH6Zek8NYX9XPjKHBMRjSMS52NotXW0=; b=X+1/y/GSYGygcvV+QVm8woFRFuPszmxCQF71E3wFg30OUUj6zEf3feTy1EFWTUL51T 0SfB6JBO3Em7ol9bFGviF+exu+YnPUfaGXbDtr1elyZhdSCpEOCMOAmsKRK3qYooXiGa Ft4U4DzW0aFic8re5RT/4wEU6pOgGJI+N2heOrYoTFzBoDx1OIF+OEJE/vByFm7ozlsW utBkbw/UDSWF7JJAkdrmWa5GpvGfk9NSpogWwf6UP6ZeF15LCFcim2vjlrMs3jwAV3X4 udEKJ8TrMjTHhyUF2r1amhKuyWhxkMvjuwob8itSEck0LHuQnARgyobMBtvXLyN2RnH6 CBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773512567; x=1774117367; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NZy4YaOyfC8HFH6Zek8NYX9XPjKHBMRjSMS52NotXW0=; b=bDSf9zSYz98kI1MnIffZw+ftHTUn29R1qqfDoe90woJoSmp5L1x5MOEEm+zbvatq15 Wtx/Ei/018OqMr1TEthALGcv6k9cn/B0y6UBaj/+NzKWZ28Isl7Bi3tBe+V5Tyi7D8Je UAHTAm2CKM5ZM1V2OCYWCXJ2Y3coOqFq2rwMRN/Fow/m4DLjuvw7icd9VQGcOwqQ6cpm 450pZXRHxny6LU+qpT1Swz0+XLYLC5J6AHpc7GaERaTNtCVaHuyPbgKIqpTj3O5ISre/ A2OkZJdYjcYPioAJXSVJGyILmu+zQlvfeD+UpIxTTMARhxzDWbiQ6XzzMAE35HhMrBhL s+4A== X-Forwarded-Encrypted: i=1; AJvYcCVs1+lskHMKO8h47p8ZqV7XbiOJoWO6vyQfpYM9E9+WI6Qh6FhniZqTRM7pi2JYSOq34jd1DhSZqkZF33Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwF0IXQe2EpdbI77623i1Zw2YFv4NTl85G3ZMTiC5ZdMwyXi4/a yt2mEot/ch3VWqVbVS0yls6SWT/4CoapsE9iFGMKcFW5mZck9pDBi3mK X-Gm-Gg: ATEYQzwcXTPAb61/8lv00CT2svClF8VcQnqvm2VjksBHBkJiPWA4Fj6KtNfLeb5+mU0 l45745n2NDnyXYqC6QJa5v1QKU2aJbgidHcih/UKUVWMIjR2z3Hm7b8hGPemZBofWQf55jukN33 hzKGhMMwQ5H3ocq1stNW3pi5H/b4xWeHvyy8Aad/77oG11EBEg5KGNTwMkAWCJdJxfLmsdq5cOI iv4ufYBqG/sHRfVvKWDJVuU0nvcvvfjYaZ+E6y9g2+NCE6NfZBcG/l/cdh52qZHA7hFeNxt20g/ rMnIpfLEk9j8P7QjFhbBW0CuNSPOezwx6vE2Yvad3bofDGtWewdFjvWLqPWUT+gJxC/LmiNzgxq GXttmCdtug/k4tZ7zWSq4VyqDWWXQxQaUU2DEjtXL2wGgM2OV1qNhclwaclqhZyM31VpJqFhPMB Z9oL8nOr7b/poG93WWOfEu4EwZlAGf39KEUAaSxYOOTkf3wKO0g1ICnQnYs7/moTpdB5yl9rsPo rcSjhYm X-Received: by 2002:a05:7022:684:b0:124:9e46:82d6 with SMTP id a92af1059eb24-128f3dc59dfmr3469949c88.25.1773512566456; Sat, 14 Mar 2026 11:22:46 -0700 (PDT) Received: from localhost (177-4-161-109.user3p.v-tal.net.br. [177.4.161.109]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2beab3a156bsm7615443eec.4.2026.03.14.11.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2026 11:22:45 -0700 (PDT) Date: Sat, 14 Mar 2026 15:22:41 -0300 From: =?utf-8?Q?C=C3=A1ssio?= Gabriel To: Takashi Iwai Cc: Takashi Iwai , Jaroslav Kysela , Mark Brown , Greg Kroah-Hartman , linux-sound@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: usb-audio: validate full match when resolving quirk aliases Message-ID: References: <20260314-alsa-usb-fix-quirk-alias-v1-1-3269998f7ada@gmail.com> <87sea2a5hz.wl-tiwai@suse.de> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87sea2a5hz.wl-tiwai@suse.de> On Sat, Mar 14, 2026 at 02:46:16PM +0100, Takashi Iwai wrote: > On Sat, 14 Mar 2026 04:34:46 +0100, > Cássio Gabriel wrote: > > > > get_alias_quirk() resolves a quirk for an aliased USB ID by scanning > > usb_audio_ids[], but it currently checks only the vendor/product pair. > > > > This can make an aliased ID pick the first entry with a matching > > vid:pid even when that entry also depends on interface descriptor > > fields that do not match the actual device or interface. > > > > Fix it by re-checking each aliased candidate with usb_match_one_id() > > against the real interface before returning the quirk. > > > > Signed-off-by: Cássio Gabriel > > --- > > sound/usb/card.c | 21 ++++++++++++++++----- > > 1 file changed, 16 insertions(+), 5 deletions(-) > > > > diff --git a/sound/usb/card.c b/sound/usb/card.c > > index 270dad84d825..ff4418017763 100644 > > --- a/sound/usb/card.c > > +++ b/sound/usb/card.c > > @@ -870,17 +870,28 @@ static void find_last_interface(struct snd_usb_audio *chip) > > > > /* look for the corresponding quirk */ > > static const struct snd_usb_audio_quirk * > > -get_alias_quirk(struct usb_device *dev, unsigned int id) > > +get_alias_quirk(struct usb_interface *intf, unsigned int id) > > { > > const struct usb_device_id *p; > > + struct usb_device_id id_alias; > > > > for (p = usb_audio_ids; p->match_flags; p++) { > > - /* FIXME: this checks only vendor:product pair in the list */ > > if ((p->match_flags & USB_DEVICE_ID_MATCH_DEVICE) == > > USB_DEVICE_ID_MATCH_DEVICE && > > p->idVendor == USB_ID_VENDOR(id) && > > - p->idProduct == USB_ID_PRODUCT(id)) > > - return (const struct snd_usb_audio_quirk *)p->driver_info; > > + p->idProduct == USB_ID_PRODUCT(id)) { > > + /* > > + * Re-check the aliased entry against the actual > > + * interface descriptors instead of matching only > > + * the vendor/product pair. > > + */ > > + id_alias = *p; > > + id_alias.idVendor = USB_ID_VENDOR(id); > > + id_alias.idProduct = USB_ID_PRODUCT(id); > > + > > + if (usb_match_one_id(intf, &id_alias)) > > Hmm, is this really a correct logic? > > In this case, USB_ID_VENDOR(id) and USB_ID_PRODUCT(id) are very same > as p->idVendor and p->idProduct, hence id_alias and *p are identical, > i.e. you're basically comparing against *p. > > I suppose you wanted to substitute the original device vendor/product > IDs there instead? Hi, Yes, what I actually wanted was to keep the alias lookup by vid:pid, but validate the additional match fields from the candidate entry against the real device and interface descriptors. I was thinking of keeping the initial lookup by the aliased vid:pid and then explicitly checking only the remaining match bits, such as DEV_CLASS, DEV_SUBCLASS, DEV_PROTOCOL, INT_CLASS, INT_SUBCLASS, INT_PROTOCOL, INT_NUMBER, and bcdDevice_lo/hi. Another option would be to build the match object from the original device ID instead of the aliased one. I think the first option would be simpler and more direct here, since the problem is that the current code resolves the alias only by vendor/product, even though some quirk table entries also depend on extra descriptor fields. The quirk table already has such entries, for example USB_DEVICE_VENDOR_SPEC() and USB_AUDIO_DEVICE(), so explicitly checking those extra fields in get_alias_quirk() seems to fit the intended logic better.