From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 3E5DD3A9636 for ; Fri, 7 Aug 2026 11:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102939; cv=none; b=bgKbgGmo4/oluQGXIuU0f43f2aziFJnVrHy+hYzn4tNlOUtniNGuR7SWYiO4Duk0gQpTrVY5PDwyFK6UsQwR4GTatHntwFsZBilv9XZ16CisNgzH6aOsSBzS6C5U2uhLBT82ciJoVA+8JMYxrWtalmoLwVdz686FM2q6Baxvyo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102939; c=relaxed/simple; bh=e+Wi1O5qLB3tdT7qt3lctISNO+5OOpqeS7DJyRa6J0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nfu2w3KiBAq0xdb+5g2s5PaORXG/1+3iNHIFZmlZ8teQ09e2faztxTVTTUaJh4rGnw1RxkrOfBLMKS3773L8lPd1MwHvEvBBULCwxQJws2Nx0F4wQ4bhEKPUgiaUJ+qbBtot+tqehKc/FqkaZKSCB43TZsoELBYI+Wk2LmRsdYg= 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=mWuejuUK; arc=none smtp.client-ip=209.85.216.48 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="mWuejuUK" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so3512837a91.3 for ; Fri, 07 Aug 2026 04:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102921; x=1786707721; 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:content-type; bh=TupgkS5U0yW4ptmWsSaBtKNrGrIzBwiT8uuCtS6g84U=; b=mWuejuUKSseItPsLB4vpEoEN+nekyx1rq2oROib+XeJtogsjpPRz7yWK+5GFMUN3Uz V8cdt65PExDPqk8A04QXzRtAWQux4N05RiSOkjcxuv6QdGP8dd0TtkaoGZFVoXEcNWAb RzwvpoG+HQaCdnnRIp+9YcPDv0FtpeEwSJhvV43DMrn1BGpuIjmTPMlbj21O1dzMl7NH sBQO/fHuMZcfjZXuMZWMDQ9SqvXIyZy27K/alE5it2X34lpfuVBHpZsh2Y1nD9DOpYJv QdPBdJnk/iwSIKatPN76ziYbSnJfcbMl79IBhpo4wXURAFuUt3gn8Lw5D7Jcyh+vtPCC ZZ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102921; x=1786707721; 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:content-type; bh=TupgkS5U0yW4ptmWsSaBtKNrGrIzBwiT8uuCtS6g84U=; b=df7z0jEztMwa1tZ2K9+MKEIjN4yu/H4K9uLJPBYM9cmRMZqoizi9/WvCZBjQC3U8lU pFWvLW86SeI2cB+8VKNh7mTPxLhDjvmoSvPeMJD49ewTU0GRlCS4yijWlWLy0GQMCH1g /HH+/ykc8V4R4O7hVFq3E7BAcNltriiQQRk7b4Bt6WB8j18SYDDq/jYpVAWQdkR3ki4t N9wHEhA3WaCvGdkwvRfAGP+rVcnMy7P1TvsQG0982OtVeVsHZz2SYnvWJe150gvfexMt iu1vNNienalu4ZX6jHgvh58jkPlYgkD7wuPMJBDBUe4PuVNmaVq09toha4jUGj3Pltwv ChMw== X-Forwarded-Encrypted: i=1; AHgh+Rqj9dAJ9sNq+wdfj8WsIRRTixdlsonlVPy3ULfhUJcocWcwkUupXAOT/ai7lLWLnokt6eRMrb9d5K0uAog=@vger.kernel.org X-Gm-Message-State: AOJu0YxvUiFAzlZl1kc/Py3hAqGkttrdlgVc2hQa1Zz5c16TYGxeeWtP qoJBnJtFDexte3u9N19CBgR0wfHwtAsbVdRJAhwAehc1wGRB75GOXGn/jSCmrbwC X-Gm-Gg: AR+sD12+QFNZi1cl3t7OncIGHIQquxNy5SirUlMtKYcco60h3ufz82h0s7WkG33jah3 n0PpJYIv2hiiG9Nay9uEITMefOTmDZ4XckltaewSDjRask5EH3ZYBfHzVU69kajRInavriaE/xe y9fk1ax5fez2N2ftU5rgnj0WhnhfvIoDj29DouXlxPYozaxALYB97BWZ3eyDkeULyo+4vPv89ph DPOOT5hFqObnhyk6n6E9YxQpsIzimkSuXGdGnKVbbUHvTn4BcCR4XN43f1y1PwC/yeXE10LY3MS wDqFx62pxw+5qCaWm3jFjtSlytxNhePbRRmH9ORXGWQCUceoUpw7QK7VJ/zdK/rFw4hD+sKId8h bJguYet5f4SMo1X4bQ/s1/biuzPZLY1mkcCLM2ZmFHP9I90EcPufrVZKrcjhqjfwQrw0gok4re0 ed5NbtDrK2YObBck3COOeHnQhRPqz+IQrBya0YW8ojRLN2nJYHFYvo9qNd0CkWt+X0IfZ+K6xM3 vck9QcTUgM= X-Received: by 2002:a17:90b:2dc1:b0:38f:de97:b06 with SMTP id 98e67ed59e1d1-3903c535d79mr25786746a91.5.1786102921248; Fri, 07 Aug 2026 04:42:01 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:00 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 1/7] ALSA: ump: replace strlcat() with strscpy() Date: Fri, 7 Aug 2026 11:41:33 +0000 Message-ID: <20260807114139.1661-2-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" When several function blocks map to the same group, their names are joined with ", " and the separator was appended with strlcat(). Take the current length of group->name with strlen() and write the separator at that offset with strscpy(), passing the space that is left in the buffer. group->name is NUL-terminated within its array, so the offset is always less than the array size and at least one byte remains for strscpy() to work with. Both functions stop at the end of the buffer, so the string that comes out is the same. Signed-off-by: Mahad Ibrahim --- sound/core/ump.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/core/ump.c b/sound/core/ump.c index 632c13baf21e..c6f55d2b8dc4 100644 --- a/sound/core/ump.c +++ b/sound/core/ump.c @@ -597,8 +597,11 @@ void snd_ump_update_group_attrs(struct snd_ump_endpoin= t *ump) } if (!*fb->info.name) continue; - if (*group->name) - strlcat(group->name, ", ", sizeof(group->name)); + if (*group->name) { + int len =3D strlen(group->name); + + strscpy(group->name + len, ", ", sizeof(group->name) - len); + } safe_append_string(group->name, sizeof(group->name), fb->info.name, sizeof(fb->info.name)); } --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 E91AF3D1AA0 for ; Fri, 7 Aug 2026 11:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102940; cv=none; b=B6fWK/Mtz9Q5s7SVu6gcuMtvBH9shSYXFkGGBhvbdpSCpdMb0VYVV+vT188vvKQ6pwalsKyKWFEwR2/lCNmp8je/NzLuhbwbxQBbTo/2MRtoKbkhreOnknSOImbiW4bKlx+MNX+kQzgAG9hwfee3hYc1cYEsJZxJfFeA3PSXVGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102940; c=relaxed/simple; bh=SW3QQ7TLL2MlBWmSFLXbFPE4nTuOfBcLz7c3BJkp6jc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HAvDON7ybgwjUJcsO/9e+g71QAb2e/dxPSULyy0LBiPuWveIRfLH64j8Hl9OSjzMGZipZIhRfRA2Bh1MXE2HpLguksf+1YObXo2XS0R6U+F4IEIbF6Xb6N6+uEV20qgUwdeDQtFZaIRtQKJoCvExjkvuQvTPFjdFCg9TmXbcrVs= 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=qC9JIg7L; arc=none smtp.client-ip=209.85.210.181 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="qC9JIg7L" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-84e0688b7e8so3132350b3a.1 for ; Fri, 07 Aug 2026 04:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102928; x=1786707728; 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:content-type; bh=O6lR1SogBn9JLBrBLFh5Dez9g6Tr1CXQQppMwm2xDcc=; b=qC9JIg7LJbPyoGFssi/HNtrHcI2V70QyzK/e8fVsyG3hK4JtPgFsLeFWkYu0A/CqLd z7lNCqFdBKE+SedeysAeMJaR/PC+eigrFSVY68OphWfVYTUKIimHl7PnfDO/9U/vk3iz biewQ6iCyIfMCZQCN66Fc8myc/Ld5GixlIjiQP/FAWR5Nhp2qOLBMnAftzRxrZ9W5lQk f/+SfHbeaIODC8Fh0Ys1DdVBXShcjtnHrnStN8KfZh0vSY3fvJsgvdH0/7MQ9iI2Qd2T 0unv1Nj+dT43l3K6PNdo5b0z96Wwu8ISSYroPeWFsb9k1z726ne+o6uEV4fJHLegxm9g AI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102928; x=1786707728; 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:content-type; bh=O6lR1SogBn9JLBrBLFh5Dez9g6Tr1CXQQppMwm2xDcc=; b=ZbBMoxUa/wEN8y/vD4j1HiEYtxS7lTXGt88+lu9UU+BomlVLq6EH2cywwnybDmYNLC WlAHC9DArc61Zq1kouneRiDPHSbFP2YCjoSevGfnnISIMyczDTncKkXt+kfzONFjlEEv ZARm/ie8BNFJ2MwwdX2oXew6iWtCSJlZpYu4/+xF7mxKgPgzNW/yxQUyKtGRWuwKBijl G9tJjRrbY0f/r26NQlCe+y51f0jvrkXjUw0nw/kIz+d5ZIftw0J6gIgKyBaGs+JVUbRW rRgv1mUc/Kn9zcb2le0hVQ5aQnbvIAW0IRYLQIEYFX8y8OLfT9teOaxhUA3fhi6InWwE dwNQ== X-Forwarded-Encrypted: i=1; AHgh+RoShi9coIgvAfWOiLyOfmN6SU7MZ2N2PsgHVBluMwx8LujNisz8JEIHNboYfqWyu3FXXEluaQT4xE0rOGw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3/U0hf/ESJvsPK0rWA62jIymKtA7m0txq5GcnqCPHFCVVWJjd 6muGMiWsiAmp7cSSQP+PqrdAklLHxHYr28cgAmlgFLhDoQw6s5YO8vRm X-Gm-Gg: AR+sD10/5IuC/TxH75OS4M9Xq9JgSwm/Pch9LRDaU19fPficT86gPOTkX/lHeb/QfDJ 8DnLWQQXXHt3zxqeRPJ397HEjLFEu74bKlaea7ywKBCb2kn+uVMX8kivYF5kgQCqOBrpDh65HDv fk5SNcxwmANfWE3OHtDu3OlNWQUwPEjqVzIRckrVq6B15ByKTxhJqYt2ZW8aVaHXpcaBCapkAy4 PG6QOGcOLvcjodLEYAScl7fOBEo7ue3NYl0FdKmnmRQiB1y5/buuRPetvgLJdMZbrPYa/Opjlkp e0s4k8jFk/shNFIlN3coqCIW+8n2LORz9JHVR3fzUyZ0PHljySBv6q0SBvvll77wFXUlCQWdsF7 fBfJ+DmXNlhkutAtSyT/FI0BH7V6IEF3NGJhpU4NgDnKzAxyvwFbD2yOD0w2NXdJkbnP90oZ+Oy Nxl0DFpAWO/LTT9B5N3jxGnodGPxthvhUXbQDZ3+MdCAw3U0LyVmuq7i1XQx4MfdGCaCVWibvyf vSNiHl+PMQ= X-Received: by 2002:a05:6a20:d4b:b0:3c3:8255:8c4a with SMTP id adf61e73a8af0-3cb85ea2ee0mr27242276637.17.1786102927754; Fri, 07 Aug 2026 04:42:07 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:07 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 2/7] ALSA: ac97: replace strlcat() with scnprintf() Date: Fri, 7 Aug 2026 11:41:34 +0000 Message-ID: <20260807114139.1661-3-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" At this point name holds the vendor name written by the earlier strscpy(). A space and then the codec name were appended with two strlcat() calls. The else branch below already took its own offset with strlen() before calling snprintf(). Take that offset once, before the branch, and use it for both. The two appends become a single scnprintf() writing " %s" at the offset, and the else branch uses the same variable instead of computing its own. The bytes written and the point at which the result is truncated are unchanged. Signed-off-by: Mahad Ibrahim --- sound/pci/ac97/ac97_codec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 0bb65be021d9..dfd712ef0c63 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1832,6 +1832,7 @@ void snd_ac97_get_name(struct snd_ac97 *ac97, unsigne= d int id, char *name, size_t maxlen, int modem) { const struct ac97_codec_id *pid; + int len; =20 sprintf(name, "0x%x %c%c%c", id, printable(id >> 24), @@ -1849,9 +1850,9 @@ void snd_ac97_get_name(struct snd_ac97 *ac97, unsigne= d int id, char *name, }=20 =20 pid =3D look_for_codec_id(snd_ac97_codec_ids, id); + len =3D strlen(name); if (pid) { - strlcat(name, " ", maxlen); - strlcat(name, pid->name, maxlen); + scnprintf(name + len, maxlen - len, " %s", pid->name); if (pid->mask !=3D 0xffffffff) sprintf(name + strlen(name), " rev %u", id & ~pid->mask); if (ac97 && pid->patch) { @@ -1860,8 +1861,7 @@ void snd_ac97_get_name(struct snd_ac97 *ac97, unsigne= d int id, char *name, pid->patch(ac97); } } else { - int l =3D strlen(name); - snprintf(name + l, maxlen - l, " id %x", id & 0xff); + snprintf(name + len, maxlen - len, " id %x", id & 0xff); } } =20 --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 1039A47012A for ; Fri, 7 Aug 2026 11:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102943; cv=none; b=J1HHedN1Tdq+Kb22LuAuIgQpC35eJyhQ1q/RCD7iRdbwSKf13knPqf4BZBuAGamDndZp9wwBc46svJ20H3TKbugNqdnAHCn2CtmPk2YF0DH6ZX0q5jLb3xFPDMPFXF7XziOtdF3UJKM8EZMvuHlchzTDHvDGMpdXIZyiZWUDX/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102943; c=relaxed/simple; bh=G7A9VyBzNW+ys4oCdJOqO6Hbk5F6spxIfIbUNWzCj3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BS/7Ixtkx8FwpDtjc6ylN70iXVgIXFA1v+amL7qyqWVu/h/DhgTA5I/yJCJbJ/yDhqBHV3+e54vL7fSEbfP5uKMcB2+JiVESDyXZoHRqNjjmWWv0p5qcUW3cAnXqWPuh7T/0XiZvos0A1Vg/gIifcsJ6S+MUWVWCfjVxTx64v0c= 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=rwlY4ouh; arc=none smtp.client-ip=209.85.216.43 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="rwlY4ouh" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-38511175ad3so2772180a91.2 for ; Fri, 07 Aug 2026 04:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102934; x=1786707734; 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:content-type; bh=0tFaoWtzLU8DJaY4QXu8kIEx2fyiCWG7Fl24BOjON7o=; b=rwlY4ouhlCHd5rNbVTN7xCMxAogISPGbN7q7yOKKj6IFYH5pSPtdzzewkf1ZT1LUF4 UJ2E0NBKhJVF6WGA/fePCxs9xF8j6KjuvSNt+pQ4sQjcc86iBwdJb4ceiKRQqLvB1ac0 YldxprqgyJB847zV91zVMpmWihtBPziqi+lg4fONj0FOTaua2+rqQcUIwh6w/Jo0FhpV cVtjmXSwV7GLNTCcNUMb9X9JhcLl1lDXCoxnjHXTcxgh3NBRVuSZuCfgwYpV2rwpxzca jcm2c6pqrJSvWpDzTHBO6WWESJPLfhbxbBjUAYD9pBUQ+RkeX5YCa13YGcqPEJIeLsdv /DpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102934; x=1786707734; 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:content-type; bh=0tFaoWtzLU8DJaY4QXu8kIEx2fyiCWG7Fl24BOjON7o=; b=dhZelYrLip9D7Gy06YEuNpYGuq+OnUNhFF8jtOrvqFU+c3LnZPKTvAv1APwnXjeHS1 05Sfvx4PAeLBm7alWEZKTw3QZyrysy7epC3YBR9jVJDu1LRqx6dPTEIctiZjZIkScjj0 XQN6GgdiY56hjGE1mNf6Kv3ERuLPWmoHKekYA1myJ/8ZtE3HKXoL6VSyxlMVR6sykfmq CiIw3vQCloVqnMH0H+f8+2yV4CHuIpzMKh3zRCeqfcx2FFPbUOX2R+dIQUnknNjdFixb eThxenEwzvCGQ1uBx423Nx1uGnyv8hWhRKaYwRwjJxn0tQXCeii/ePYMm9ZjNo1/AV6m DtUg== X-Forwarded-Encrypted: i=1; AHgh+Rp2XtAFDIl/KvN87u18sR5esISwIVXM8dqqtoPY2e1xJhTWBwv0MUkMwkmzWW1k7g4igsxH1sK1LmF6D7I=@vger.kernel.org X-Gm-Message-State: AOJu0YxHq1r34Hm7Mzs8wS4kkP894OHkspJQz72WIpZO0zzVC0GE8EXu ERpAiRjUhYU98wudKC2iaP7g/c8k6CdjDjNmbAR9esztBqBH6aGf+yny X-Gm-Gg: AR+sD10mKJcK5Xzs7JseHCeL/RBHiM8mXpWb1hmSlFIVrkTLzy5XG094wIlyLvD2Uhg iY8u7H/j86EsDjJ24HO0hstwFZmhht9qiKlsX4zXZAuGCyvig1ZiiggqN98xDZAiTPFvba/8b1c OjNhCTPt88VghEqpv6hRKp5r4ags0JyxYcG7MLVogWSM4KkVu9557AQ6qZ+Bdpw0cGoXzma7UEu DVwaGqssMykMpQ1uqbjI0jqXiy8TXydPnCPcza39TkLr9NMh5JMp2FNa4l++9ekWqahYufbzrn+ DC/BSyuAnNU/+ajbSB0dt4vHLs3zpAYEcoyCW39B0qYIzNa/upK48AHFU0a260S5QHMHh3NxA6w dlGxAR/TTRdBsfl/W/4DGG8h0Y+4F4xAOmcZ36lOME9w/lExRGt0JzoVUACsVnMGHK3BdlkDlFR eeHAg3x5iTJGcP4EAiiJrcV8uqPEUCunWDyUF/flwqa/MP2BUeeIm1oXT+ss4FeofSij5Wszn1d k+QUh+qeA0= X-Received: by 2002:a17:90b:4b84:b0:38e:8021:2ea9 with SMTP id 98e67ed59e1d1-3903c5f6482mr20137207a91.19.1786102934189; Fri, 07 Aug 2026 04:42:14 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:13 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 3/7] ALSA: cmipci: replace strlcat() with strscpy() Date: Fri, 7 Aug 2026 11:41:35 +0000 Message-ID: <20260807114139.1661-4-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" The "-SWIEC" suffix on card->driver was appended with strlcat(). Take the length of the existing driver name and write the suffix at that offset with strscpy(). This is the same thing the can_multi_ch branch immediately above already does, so both arms of the conditional now build the name the same way. strlcat() and strscpy() both truncate at the end of the buffer, and the suffix is written at the same offset either way. Signed-off-by: Mahad Ibrahim --- sound/pci/cmipci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 9d9f784e3a8c..c8d98d76b689 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2983,8 +2983,12 @@ static int snd_cmipci_create(struct snd_card *card, = struct pci_dev *pci, int l =3D strlen(cm->card->driver); scnprintf(cm->card->driver + l, sizeof(cm->card->driver) - l, "-MC%d", cm->max_channels); - } else if (cm->can_ac3_sw) - strlcat(cm->card->driver, "-SWIEC", sizeof(cm->card->driver)); + } else if (cm->can_ac3_sw) { + int l =3D strlen(cm->card->driver); + + strscpy(cm->card->driver + l, "-SWIEC", + sizeof(cm->card->driver) - l); + } =20 cm->dig_status =3D SNDRV_PCM_DEFAULT_CON_SPDIF; cm->dig_pcm_status =3D SNDRV_PCM_DEFAULT_CON_SPDIF; --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 ED4CB3C4540 for ; Fri, 7 Aug 2026 11:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102951; cv=none; b=eCpAZzIcyEz+xGrMJuGSdPzCx4zviHBgHX64pisuZYIw+ZPCQMMAIR+Frec4C2L1i9zIIF3opVEfMrMy9u7UIzbiMcoo1YU3YAb109jzC2am7NKnCi/xDoWzOJGgt07hAluQ+wmAonqVDTqjSX6UaZbHIoNwN/UNhYdAHbNV1mY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102951; c=relaxed/simple; bh=CtXcqp2VDcddZCiaeG5iiX9IGilWKe8EeVBviDDfLUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sObZ6EKMZliXcmRngLUCzAUMji+Ft+pbMJNg1sKGZKNPLkr/Wg7Mrjm/yZMHQBf7PWcIlPZ5BGbF3QJPwmqHC5Prik8604ILwAx8B6BgBrKoU2d1ewJFlUu16/Co2yK8ys6+ATgrIvzrfgLrW9r5f9Q4yeAfjREq9/MWnsA1BT8= 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=rtLduqUq; arc=none smtp.client-ip=209.85.214.173 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="rtLduqUq" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2cc73e322dbso36744355ad.1 for ; Fri, 07 Aug 2026 04:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102941; x=1786707741; 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:content-type; bh=O2EtTMxFhhlsCKiXUEwoma4Bxj+FDVYnX2c+BIxaQO0=; b=rtLduqUqrqJyaYgdBCR4Bwxo7SEEhUn5JGd+GSUvjhBo7FCfrWB/kaPlriZBGNcG32 FGTTt6T1gRUbvJLOIwBhxoCK8DkmXvFrCRyjMTqa66XoIMi2F6KtAb6lvpXF97sGaoWw sMlDXjXNFBAyuyIfYTUX4b3dTSZVC0/JS8iuwOg+iP01CSm7U4zx5aQWaOhlQtNuDQsU ikhk41EHhhnirdyBa/JD2Smn4kxCOhvlDxH8A6OUY28QtEumqg2rUGN5SNiz3QI1KRge lnzf5USI/5hdHahr9Jc7/U++s4Nun9aj9LpZn5PtfbZrLMPQN70k/Dw3GPQ6Xko35IlZ VP7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102941; x=1786707741; 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:content-type; bh=O2EtTMxFhhlsCKiXUEwoma4Bxj+FDVYnX2c+BIxaQO0=; b=OUvAvBCbHVh39rBCt1XHeI7tZauT8dfQXuHv49SdIlL/7x+SpDsaHf/2lOFjdm/eYa AmH4SJlaU/Al525VzTur531NunrEuMiMCjh0INJRc+SzmFlCcgruvdnCGLUOP8CJe/4Z fWBNetz7HRTgUfYDNFbkhtGIQB9oaDt+TxWPXGowP3tFVCrrsK+gEGYojm8jTD51g+Jw +U2g1HOuA/0pVG8fgAdMMJb4AEsfnhjOnw9SYc0isMUyTk+9YiJu/516zFeT+viOTJnI tgmeAXzcHAXcQMS16nyrHdAKBbew/nVxvxMAf3C+LILm7CuJ0bpH4DKpnOhKJ/rfBRp7 s3ng== X-Forwarded-Encrypted: i=1; AHgh+RonI0J4dRMjXjBHn2xb0aZ7uT/a0Dg/cWSEqqAykf50K7XUoNTP1j8dlWNPEJ0nPyUgvqHsYDWnifgxOMA=@vger.kernel.org X-Gm-Message-State: AOJu0YwbROwX5n0ysfaFwt0PgB5kRJcCnkudu/n6jTsCMdrwhNjueBAf tQVfMX0CLF25LjiHUNoBHQcv6h75zYYoic5ev4IiB1BHT4ykKVBawz+mP9DmdMhS X-Gm-Gg: AR+sD126tBgyriT1JEp6779aTFv3MAbifL0wAr1xBJgbh4WeZmF6gTXI3J8jGSd36j4 /5MHe0Ib2EfF35bpEn2b1u0zoAJTZGK5oiOdppo3XYNrkcrVKEPTveZArn+8GLURbCNLmIjMYBQ DELPMpkZjjzbaskOlSgZuuEvQOksgNGs/39rxVbDYRtP3z3at2rfyuD4W3B4XpNC/w18xyCd/+n Y+eIdEWbAVRQJ1tCn7iFH6kgnTUvMhUXJqRHF6hy048WPU3LeIRhDx7gtcXD0LhwaptECDE6lEU L4dqgOfhiTGotqCky31EupXTnry/rMXWvb1gOcaebeFB58Fh7A/QrREQHToQC03Kb8jNJGBaLd7 ITdgCqZmJlziK00s31RGL+kryPZTttNO9RhWh+ZplS7eHrhljUXcJom91U/lGDwxewTicIBXFHq rmvYq9tUqG6mYGz77QsTwEJEZAcLBZRXwK2gOKg4pTvNAba7lDGOZD+vZVUoJMox7JTrX4YgXZO 8deOdoOY3U= X-Received: by 2002:a05:6a21:685:b0:3b3:1b38:d9c3 with SMTP id adf61e73a8af0-3cb85e99243mr26526592637.4.1786102940555; Fri, 07 Aug 2026 04:42:20 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:20 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 4/7] ALSA: caiaq: replace strlcat() with strscpy() Date: Fri, 7 Aug 2026 11:41:36 +0000 Message-ID: <20260807114139.1661-5-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" usb_make_path() fills cdev->phys with the device path, and "/input0" was then appended with strlcat(). Take the length of the path with strlen() and write the suffix at that offset with strscpy(), passing the remaining space in the buffer. cdev->phys is NUL-terminated by usb_make_path(), so the offset is within the array and the size passed to strscpy() is at least one. The suffix lands in the same place and truncates at the same point. Signed-off-by: Mahad Ibrahim --- sound/usb/caiaq/input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c index 8d924330c54c..fd4c80c7530c 100644 --- a/sound/usb/caiaq/input.c +++ b/sound/usb/caiaq/input.c @@ -604,14 +604,15 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev = *cdev) { struct usb_device *usb_dev =3D cdev->chip.dev; struct input_dev *input; - int i, ret =3D 0; + int i, len, ret =3D 0; =20 input =3D input_allocate_device(); if (!input) return -ENOMEM; =20 usb_make_path(usb_dev, cdev->phys, sizeof(cdev->phys)); - strlcat(cdev->phys, "/input0", sizeof(cdev->phys)); + len =3D strlen(cdev->phys); + strscpy(cdev->phys + len, "/input0", sizeof(cdev->phys) - len); =20 input->name =3D cdev->product_name; input->phys =3D cdev->phys; --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 3C709472F9D for ; Fri, 7 Aug 2026 11:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102962; cv=none; b=rQb0JOnum863vmyzkQDiXoH+oloPqaYKJxJsCC7aTzqNfr3EeS1rA4TaWwWQkFMLx7m+JVas8qB4jQC1Qvo3PPrTrOUrNEtJ7Yxhpzrr6JKSgDYigQVl0ouJZKPzZZ4X9iBO+6nMD/7BBa+DpK0/ZE64EUtKKlK/JB/olMBhou4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102962; c=relaxed/simple; bh=oT5T3dLFneium61Yp5EjmuxugXHqACAQ0RatMGQIiRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IAgmGF0wLcXOUG5ggRblF2W2p1EUXo9eOr8gVB0Atd/DFrrbgzVZ439zkPg6MngEdxMN/Kp6aHAs3d2IEHXhRb1U3T7gRN9AsiEtw5PO3x5cJZRRQHuV2d/01pMU9fMd7dMtZLLa+17l+rUiQDUXTXWVjXjQOaTYAG6I+7TV4XE= 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=sS1pRKWd; arc=none smtp.client-ip=209.85.215.181 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="sS1pRKWd" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-ca7bea5e5b3so2641843a12.1 for ; Fri, 07 Aug 2026 04:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102948; x=1786707748; 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:content-type; bh=djjh8aS+tjNvT4Hn4JXEMFIbSSiOro7lhmqj3kM/upY=; b=sS1pRKWdGrYFU27mdgh53EVy6ttSEHlP/f9BsaiDJPUXPKw7De7ZL60TGoB94V4q6c O8/mpElHzj8erOJI9aoHW6OAG2+yulAYJBx4C0sMZk78QyR32veQk451fktF5V2+TsOf sx+W7L8p5w6/xTQIJAFJaxFoCjOJlDlUSJbSjNqG2Yc5pAVESEhKdDt8+dXpS2Hla1Gu Ze1kPJtbOJ14WEIw2lWTOVmN3kYBQd5v6MQ6WqSBFHLGTJYtOZhFzuTusAd+r5ico+PH zO5Ljz3PKPynwWDOTXAhOeKl1bPscl2ajQkgSkBwJlXlR4cCUECNy/LOrSksLaAeLHwM jhwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102948; x=1786707748; 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:content-type; bh=djjh8aS+tjNvT4Hn4JXEMFIbSSiOro7lhmqj3kM/upY=; b=eXxQkeAwntsZsNxfvxMYmHE+zDvVDphcy8KJjThYUpySbH2/ZjxBdJwCBfENTQ/2VS ceuN8TLyBNVO7/yMoqExAfwwna4K7/JvriTVqnpeb1Vox8y7ytXaYx3P/KE3EcFF5V2Z ykGNjfTsUHGqs8FG9526/lw7udqqSomOsTOXlmFs5kYEA7pkSwpZFDXk8fdx3sVTgwkF WkI+IaVtXkkDDDSHdu5IQ/JYlKMqETMEnKasJiOAPMTD/5AOHTcQI4e+viL4nJ0yMide v8OdV7Q5kNcNsVkmmxqJojPeNgPiLPySs7w2B7xJMrMgrRdK5abJGMz4A64QdZtqKwrx x0Cg== X-Forwarded-Encrypted: i=1; AHgh+RqsnZmyqCd77Fcn7Uf1dCr9OER8SBRFsLIgTtUej/1BZgldilU8EOgzSbHgYlWDW8b5mPZgIze+4H0nJd4=@vger.kernel.org X-Gm-Message-State: AOJu0YxolPAe+ffyH9pU1/F/zOKgL83ElyoPN172KOLaYdOuLbl52d8t Icu7hwi03rGhXFfWwVe0E0ZhtoQ+3UXaIGXFFBCYhIQSBBOZ7oEmB2K+ X-Gm-Gg: AR+sD12f7vNNwAk6enagZ5J03RzPw3/sz7BM4+8aM8X9VuGu+D73UM43qZrC8tV9MA4 uHoiUF+Mf17YstfKGI8EqTs8oaOHQWPy1TKrrfBa43ujgQGHBuugLkTbsk9z23CYQrbwvLTKkhb sBOZqyCwSRE62Ta/3Iv3zC7Ylb459TvDroTGqlH2cOmUFBZt/U/d2ijmbOJQndOIQwKmcydF3H8 /P9q+qqRCdt3dnBsjAX7Lf85o3lDr1JdEjQIeKFHIvnvtpv7RQNFMvALph3F34hoRtHu0qlkm5I XhMSfOSfqALQy9jG6sYmbK3qJuCEeqWN9scgrN0Tslq+SxTnpqB8CBLA505Jwpd2V971wpkp4CZ I+YzQSpAdGWrgCbIZtKiUxP6LrqkBRfpjmMUMZ56OiGYB02blD0pf7/YiwfVS9zrwuAOpRTghxr zOpAZRLn+eKN+iJpNn7kETsi/qU2RBzRDlj6JN8HYxnLd/75gmZiSP+j4Zk8/vVF1SXnm4y+zWD 0da9eidCoNQp4BGzEv8SA== X-Received: by 2002:a05:6a20:7f86:b0:3bf:9c93:ac44 with SMTP id adf61e73a8af0-3cb85ea363cmr20852727637.19.1786102946899; Fri, 07 Aug 2026 04:42:26 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:26 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 5/7] ALSA: usb-audio: replace strlcat() with append_ctl_name() Date: Fri, 7 Aug 2026 11:41:37 +0000 Message-ID: <20260807114139.1661-6-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" append_ctl_name() appended to kctl->id.name with strlcat() and returned its result. build_connector_control() open-coded the same append for the " Jack" suffix rather than calling the helper. Take the length of the existing name and write the suffix at that offset with strscpy(). The return value is rebuilt as the offset plus the length of the appended string, which is what strlcat() returns: the length the caller asked for, whether or not it fit. No caller currently uses it. While here, call append_ctl_name() for the " Jack" suffix instead of repeating the append inline. The name that ends up in kctl->id.name is unchanged, and so is the value returned to callers. Signed-off-by: Mahad Ibrahim --- sound/usb/mixer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 703c118f9d4e..77335bc89aa0 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1748,7 +1748,11 @@ const struct snd_kcontrol_new *snd_usb_feature_unit_= ctl =3D &usb_feature_unit_ctl; */ static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str) { - return strlcat(kctl->id.name, str, sizeof(kctl->id.name)); + size_t len =3D strlen(kctl->id.name); + + strscpy(kctl->id.name + len, str, sizeof(kctl->id.name) - len); + + return len + strlen(str); } =20 /* @@ -2116,7 +2120,7 @@ static void build_connector_control(struct usb_mixer_= interface *mixer, } =20 if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) - strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name)); + append_ctl_name(kctl, " Jack"); else get_connector_control_name(mixer, term, is_input, kctl->id.name, sizeof(kctl->id.name)); --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 5ED06473C81 for ; Fri, 7 Aug 2026 11:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102962; cv=none; b=bmQjMR6LgfTy7D1gz22gUFWszi1Fol5K/VNnpU0lYt8IN2cQRlNZtTARtQDUNH1A6BDQKotn3odMICJ0z4x5vgvwsj+SqOiwA1igYymgV83VAetPxnHLcMwnh8/aDglhjHNRrWWLDm1PB/5Dcx52tgUZD7Bum4vKVLf4mvoBT7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102962; c=relaxed/simple; bh=ztgsF4xlC+/UgNtfKPXec9lw/Y0/M4oYUL4+7ifjbZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lpGdA4F9I2m1SQ9qyfTg/hv0iHGftFoxy7jIx0GAEde4W3kHQCm7Qjbd9sgDSYjYvLHDtOLzEr1hj0+TS0zDFW2NfiiSyLyYkujnbZbX+hcFlZuHrUHzS+A+DIg9xZ4rSzcush9jVR8Y/rFEU4BHDkdpceYpemJzoMsavkvDXM4= 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=DcTY/WU9; arc=none smtp.client-ip=209.85.214.174 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="DcTY/WU9" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2cee9b74ee1so28205985ad.3 for ; Fri, 07 Aug 2026 04:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102953; x=1786707753; 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:content-type; bh=XFU29Mt+4RJ+9zZZmPn+2wKzh7skI+zFObgTR2DLrqc=; b=DcTY/WU9FUkk66U0jvqwGrtXduGttJAAQa/egpEVYRAeuLU4YEnxHzAFRkPFma2ygf b06cJpXjqLuMtb6QBg4RJJJADxwgKohTL1RKW1BzimL+vPryBCQMw3GtpguJqDvwi9Lk aActrR6lYy8vIWlQYacj6tSy7vTO+HVnwNYvFhh1FpjY9nVQc6vZkTs9sjdJRSFB4lLa SAZij0knLzE/0cIeFon1ES8zJbYI9xPVdFY4Rjdx4JmadvKSj5GtYD6uS+HlaHqq/mmW FQd6jDR1jzJRAlQsaOR8Fvq8sXvXH6CNs/dj8vkd89QhOabFGnQPQcm2vcqhGZCzNUrI e0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102953; x=1786707753; 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:content-type; bh=XFU29Mt+4RJ+9zZZmPn+2wKzh7skI+zFObgTR2DLrqc=; b=kXuAdH76A5aWDemKH4pFvdZXzZR3lIczhQ++cD0qpAbjFJETXYQZ6R8mLMgL4yfjOU DwqEgvYWpLGEs9OQthA+Sca6h3S9pdYgshDg9w2EESJABMOVp69yCK65Wg4ix9WgPGUs /V5DItY6nIJaNUWDOQTZ6eRnsRY36rP//VSiG/eHBbTut+j/41DBVjxRMipK7jcWcE5k K9gp2IhLJQiOVlnfAJJQu3sO90YB/KZCMrFKa0qHmU1x1LdDm45LZYGLcwTuOgRyutuS F16p9wVyOaXb+o47V16hgTXFJOGYH138bz5DlKwx3SIJBHc6riK9j018cuqkZQUklSuk 9SSQ== X-Forwarded-Encrypted: i=1; AHgh+Rrz6mI8tfOEL+dg91qvLmUohdTCojo/3v9vIKXPkrDjrzNz453m/8NNQQF5mDS80tGP5MzfNVigGYVxsRE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5KUa73bxNaynO8DSlbB6N3mQ6lSR03vu3v/iXO4/ZKjFaDXuf kAPBw9ib3NfW4dXkp3pk5cLathmUlrdoUmefTjprMvXUV8ujapqEZNav X-Gm-Gg: AR+sD10kEK9eupeRdmG/+p4pzXywxZVbIw1Tz5YpwlTNU3eyKg03+7VrgVIQUBuMR0g qaM6kqCJq/k/cuf+I9w5usVBoolW5zbjyU4nYTqwtAKHlMbo5YNRrUzf1IraBGa8xELxXTqRzyK wi/0MzOYHnEDYSahU/pN6osIdpOx5tVeUal9VsHmDOef+oKlAHGT/Ha0tp1jcXHQ1WaZGTPaFvy UCreotayVu6025oYGkjk2G+HuqU3+qfBuw80IgKUn3KtkU1sylUkeO0wbI3MqcWuJ0z5yMfsrQJ UzFFWZ3+pYcqCdZOBbCcQh8bEMwOxKEXjsbbaa2GK/YwzDNmM46ycoA+jzFGyjMBSYHOHMZ4uHG VK6eF0ydh+rW2ljG1c1SNHSuAulLHwPeC7Hr/GWKx2b8d+nTa2LB874L5Xp48Pu4kx3cmr4x/oq EsqO5uHUEbbd47PzTxF3geKZKloh94CWgFiOR3z6ZsUoZXet7ysNRzI03rGeB2z1Z2eOqbsQjuA ZOdj0rHwck= X-Received: by 2002:a17:902:cccf:b0:2d0:cc92:f7b8 with SMTP id d9443c01a7336-2d0cc9302a7mr259995675ad.2.1786102953464; Fri, 07 Aug 2026 04:42:33 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:33 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 6/7] ALSA: hiface: replace strlcat() with scnprintf() Date: Fri, 7 Aug 2026 11:41:38 +0000 Message-ID: <20260807114139.1661-7-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" card->longname was built with two strlcat() calls, one copying card->shortname and one appending " at ". The return value of the second gave the offset that usb_make_path() writes at. card->longname is empty here. snd_card_new() allocates struct snd_card with kzalloc() and nothing writes longname before this point, so the first strlcat() is really a copy and the two calls collapse into one scnprintf(). len now counts the characters actually written rather than the characters requested, so the bounds check below it is always true and usb_make_path() is reached even when the name was truncated. In that case it is given a size of one and writes only the NUL terminator that scnprintf() already placed there, so longname does not change. Truncation cannot happen in practice anyway: shortname is 32 bytes and longname is 80. Signed-off-by: Mahad Ibrahim --- sound/usb/hiface/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/hiface/chip.c b/sound/usb/hiface/chip.c index bce28f683666..d217fe64eabd 100644 --- a/sound/usb/hiface/chip.c +++ b/sound/usb/hiface/chip.c @@ -70,8 +70,8 @@ static int hiface_chip_create(struct usb_interface *intf, else strscpy(card->shortname, "M2Tech generic audio", sizeof(card->shortname)= ); =20 - strlcat(card->longname, card->shortname, sizeof(card->longname)); - len =3D strlcat(card->longname, " at ", sizeof(card->longname)); + len =3D scnprintf(card->longname, sizeof(card->longname), "%s at ", + card->shortname); if (len < sizeof(card->longname)) usb_make_path(device, card->longname + len, sizeof(card->longname) - len); --=20 2.54.0 From nobody Wed Sep 30 13:53:30 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 9F0D5472F9F for ; Fri, 7 Aug 2026 11:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102973; cv=none; b=ksvC7XspvSfOm1wOW5l3/pcnESkMK0lH09gAlQrU1QGcdb3Sm9km6Lx39PDnZnvxZwxvy6OKxh279z0RnsmpEd/4kSg2MNAGamnDFAr9rzpwsJNnra3x/y7LVT+5OuxjcX+ESJrKdRZzQVMWuV8OBdQ3zgLPuMDc1/ikGSsBpQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786102973; c=relaxed/simple; bh=6vnc70YAJ6OLk1J5alGQJ847XnOiFkHduNWP2sl7tdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r7/04rLKiMXI6FTl/521HeyAQNbpE5cXOgT4KWJVGw7ue+XXP83LhInjzYHctVC44bjRB9rrj9v/YTOVZVFn5tJiK2aJvrN0fbk/Y+ikSF15XLp/BGhzd1OOpkKLC8SocAAMLbPaQkSukQ/ioe0R+5U96sQB7gATZc/+Z4WJNTE= 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=IDirJw0Q; arc=none smtp.client-ip=209.85.214.174 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="IDirJw0Q" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2cc61541f8cso22182495ad.0 for ; Fri, 07 Aug 2026 04:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786102960; x=1786707760; 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:content-type; bh=Z1KI6aLTxpK9OyfSdZpf8ALQPnrnsIJtqqHlV920g9A=; b=IDirJw0QVCfsqiJJche1uiEG/btukFbvJiDq7LLpM+wWZQS+a60MZy8op5kd42mRDH G53psNggZsTqLlJFiCvkkVQugVHQcSj/g74lSFgEW+mYh9pS0HRPOWIGGjyBFN2q2J0i jC4ceJYNxUvgRbOAM82cy6HWrCqg+yr4K5W+P9135DXiIRJLR3vgKSSRA/HzNih9K9IP O1eP5XKUmyvsnry8uSfAcMxtYkpKV7WmaEQ8DFfX/5HmGjRrRx06QZigSi2uPgm3uen0 gFbTiYq5K/37xY2E+2gnTK6umQh8Nw3UTnlFs7fn1glvpV+xlcS4prHR/5El+Ri/GG7C bJeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786102960; x=1786707760; 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:content-type; bh=Z1KI6aLTxpK9OyfSdZpf8ALQPnrnsIJtqqHlV920g9A=; b=s6to6VVCga3fTK5gXXm19ETFONslPByER2s6O7d0TZDPBGxMCqvhgP6XslbMk1TU4f 0PhtcwLiEL8eJv33lQPsesU6uYbtBq8NwQ1OvOrWeI26D8LcymCgmhSFjbmH9bKt1BSX URqzi15sj7SFjKEpbv/2fHdCTYrzoJHksTSJUPErlWTVfHO93+eL/S+66FEb51t0/xic EvrGHn1onZqRp/+T7Fj2kddXdUZQIDNumPB2LJW0usvB+zFGJQTLQ5Zo6tbiORL5F59D Nt8/4mhjazQtiGKet8CAUER3CeETCV8yFi7Fs3vfRVB7Kh1ahNJy8LSr0NO9UgiUS1kS /onQ== X-Forwarded-Encrypted: i=1; AHgh+RphIpx9yMTdgsbk9RFENJaX8Y9XvyXWEVQ0LB2o0Kn8qvTr9ylFVskD5bsPH5B8XVgMQA7jgHuJr/2BB0c=@vger.kernel.org X-Gm-Message-State: AOJu0YyXNfiiJyLFBu3pEWVxMaxZMAt1obEqL4qD+P+O5VGJNKppP+dU pngG0eZOwmX8wQEDFzIH3wzBr9wJIXK3TI90Fh4I4C3xg5D9qf68EAAF X-Gm-Gg: AR+sD11Hs4RTQuhKG07B8TzaVLxvDCAd7X/Avn/HGT3P+XHMrBxNkmf25G01Rewintv u3rmT4vALkXqNKJz4WkWBiNSLWjppWEK/JSCeqDxrHJu2Oygpp6wMd2bNzMjzwSln57/aPmOhA5 QJGWO/gPCSl9KC2NxpkpFpgj6OlFEPKghHhcT0EtUxCHftEZN8zc0IAQDsQ8QZeBX58QXU20pd+ GNTnvuc7sR0GpkoJE1gA4hKswN1MRhGxxf+i36zLIPh0oVrlYMNU1d6ktinU4uhxuix7vVkXLUR FMGezBiHVgcEeUqyupZoQVk59+Hlmu9TtmGaDn90ZSpnnMth+RVYuKopS7ylNDtTrC0Tsk/ZNsi M5WpoR+6t69aFIkXQXoMtX57bPmse96dz4g265/D/HZaYXoqVRSvEqEvC7OB5YysDj3FRTGJGup ayIdlEqNGqgmc9snYQP7DaBeUTmw7ySnb70O7nKdyzv9q7LoGiC26DTWUg5ZQymfpkcOkaOpSq8 paftY1foq8= X-Received: by 2002:a17:903:3885:b0:2cf:af20:4254 with SMTP id d9443c01a7336-2d0f1c0dc3dmr168401505ad.10.1786102959690; Fri, 07 Aug 2026 04:42:39 -0700 (PDT) Received: from localhost.localdomain ([72.255.58.127]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be86d3fcsm6930508eec.4.2026.08.07.04.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 04:42:39 -0700 (PDT) From: Mahad Ibrahim To: Takashi Iwai , Jaroslav Kysela Cc: Kees Cook , Andy Shevchenko , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Mahad Ibrahim Subject: [PATCH 7/7] ALSA: usb-audio: replace strlcat() in longname construction Date: Fri, 7 Aug 2026 11:41:39 +0000 Message-ID: <20260807114139.1661-8-mahad.ibrahim.dev@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260807114139.1661-1-mahad.ibrahim.dev@gmail.com> References: <20260807114139.1661-1-mahad.ibrahim.dev@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: quoted-printable Content-Type: text/plain; charset="utf-8" card->longname was assembled from a chain of strlcat() calls covering the vendor or manufacturer name, the short name, the USB path and the speed suffix. The return value of one of them was reused as the offset for usb_make_path(). Keep the current length in len and write each piece at that offset, with scnprintf() where a format is involved and strscpy() for the plain speed suffixes. len is taken again after strim(), which shortens the string in place, and again after usb_make_path(), which writes into the buffer directly. Both would otherwise leave the offset pointing at the wrong byte. As in the hiface conversion, len now counts characters written rather than requested, so the bounds check before usb_make_path() is always true; in the truncated case it writes only the NUL terminator that is already there. The strings produced for every combination of vendor, manufacturer, short name and link speed are byte for byte the same as before. Signed-off-by: Mahad Ibrahim --- sound/usb/card.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 24112e491779..3c15a6862046 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -651,7 +651,7 @@ static void usb_audio_make_longname(struct usb_device *= dev, struct snd_card *card =3D chip->card; const struct usb_audio_device_name *preset; const char *s =3D NULL; - int len; + int len =3D 0; =20 preset =3D lookup_device_name(chip->usb_id); =20 @@ -675,32 +675,39 @@ static void usb_audio_make_longname(struct usb_device= *dev, =20 if (*card->longname) { strim(card->longname); + len =3D strlen(card->longname); if (*card->longname) - strlcat(card->longname, " ", sizeof(card->longname)); + len +=3D scnprintf(card->longname + len, + sizeof(card->longname) - len, " "); } =20 - strlcat(card->longname, card->shortname, sizeof(card->longname)); - - len =3D strlcat(card->longname, " at ", sizeof(card->longname)); + len +=3D scnprintf(card->longname + len, sizeof(card->longname) - len, + "%s at ", card->shortname); =20 if (len < sizeof(card->longname)) usb_make_path(dev, card->longname + len, sizeof(card->longname) - len); =20 + len =3D strlen(card->longname); switch (snd_usb_get_speed(dev)) { case USB_SPEED_LOW: - strlcat(card->longname, ", low speed", sizeof(card->longname)); + strscpy(card->longname + len, ", low speed", + sizeof(card->longname) - len); break; case USB_SPEED_FULL: - strlcat(card->longname, ", full speed", sizeof(card->longname)); + strscpy(card->longname + len, ", full speed", + sizeof(card->longname) - len); break; case USB_SPEED_HIGH: - strlcat(card->longname, ", high speed", sizeof(card->longname)); + strscpy(card->longname + len, ", high speed", + sizeof(card->longname) - len); break; case USB_SPEED_SUPER: - strlcat(card->longname, ", super speed", sizeof(card->longname)); + strscpy(card->longname + len, ", super speed", + sizeof(card->longname) - len); break; case USB_SPEED_SUPER_PLUS: - strlcat(card->longname, ", super speed plus", sizeof(card->longname)); + strscpy(card->longname + len, ", super speed plus", + sizeof(card->longname) - len); break; default: break; --=20 2.54.0