From patchwork Fri Jun 14 15:37:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698868 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 F303319ADBE; Fri, 14 Jun 2024 15:36:57 +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=1718379419; cv=none; b=XKJlEhjfr1RrR1nu/kg2HF0wdW++7Pw+Jm11bO4GxNTq7th7oDML6GBsaR63aNYfhk5u+LYQ45jRCE+WoxfPYSAvH2iz8czSMpGAFpfg4ZzEAXS/aDLxsEY962OxKi2UvsJ+300ZcffLGTiyxKgy+Vqr0ibmxIZD2EDzbZXk5xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379419; c=relaxed/simple; bh=w/IWp6nSo64sVIfX4UwPn3vOfavqx0Ypo3pzKZ2Tr1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oY/stt9VwMUeVTWQaneeWhjimbn2eoFm8Jx6b1lLSXfoSocYEGLQZ67Cpm3zGuyo/CardxgYpSQhb1edpMsszqT1mBEtqtDuN0zW/dEsWC2F9vdttr6KccU68MgtbxxuchC8fLV5p+P4z9DpVwbGSLfk6T1gvzkEq6feSq2YbDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PY7c0Fuh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UVaQyxYg; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PY7c0Fuh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UVaQyxYg; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PY7c0Fuh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UVaQyxYg"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PY7c0Fuh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UVaQyxYg" 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 C713D2063D; Fri, 14 Jun 2024 15:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379415; 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=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=PY7c0Fuh8G29cw7GcwsqJANWQ2DTrOJ0PgE+blvzxjEZookki8CVSBmHN5pCFMmz40bjUf EPhBv9+XHefyDrXPR33FGhZU/D3pl2ehdJHJksmGdTLBs5IfVeE63gDKDvAR6iCe9P5YbJ sxdVUzEot6t27iflsLCFU5fDM3KC/wM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379415; 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=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=UVaQyxYgaiQIZJXp4zeILPJPpgx5evXZ/Ep/GHuOs8zNf0Ic4ntjparpkL5t4K8eYX3Ei7 YX/XW0q7/It9w5Cg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379415; 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=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=PY7c0Fuh8G29cw7GcwsqJANWQ2DTrOJ0PgE+blvzxjEZookki8CVSBmHN5pCFMmz40bjUf EPhBv9+XHefyDrXPR33FGhZU/D3pl2ehdJHJksmGdTLBs5IfVeE63gDKDvAR6iCe9P5YbJ sxdVUzEot6t27iflsLCFU5fDM3KC/wM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379415; 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=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=UVaQyxYgaiQIZJXp4zeILPJPpgx5evXZ/Ep/GHuOs8zNf0Ic4ntjparpkL5t4K8eYX3Ei7 YX/XW0q7/It9w5Cg== 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 9A15913AB5; Fri, 14 Jun 2024 15:36:55 +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 QAcmJJdjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:55 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 1/6] ALSA: vmaster: Return error for invalid input values Date: Fri, 14 Jun 2024 17:37:10 +0200 Message-ID: <20240614153717.30143-2-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: So far the vmaster code has been tolerant about the input values and accepts any values by correcting internally. But now our own selftest starts complaining about this behavior, so let's be picky and change the behavior to return -EINVAL for invalid input values instead. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/vmaster.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c index 04a57f7be6ea..c657659b236c 100644 --- a/sound/core/vmaster.c +++ b/sound/core/vmaster.c @@ -198,6 +198,12 @@ static int follower_put(struct snd_kcontrol *kcontrol, err = follower_init(follower); if (err < 0) return err; + for (ch = 0; ch < follower->info.count; ch++) { + if (ucontrol->value.integer.value[ch] < follower->info.min_val || + ucontrol->value.integer.value[ch] > follower->info.max_val) + return -EINVAL; + } + for (ch = 0; ch < follower->info.count; ch++) { if (follower->vals[ch] != ucontrol->value.integer.value[ch]) { changed = 1; @@ -365,6 +371,8 @@ static int master_put(struct snd_kcontrol *kcontrol, new_val = ucontrol->value.integer.value[0]; if (new_val == old_val) return 0; + if (new_val < master->info.min_val || new_val > master->info.max_val) + return -EINVAL; err = sync_followers(master, old_val, new_val); if (err < 0) From patchwork Fri Jun 14 15:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698867 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 A6D801802BF; Fri, 14 Jun 2024 15:36:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379419; cv=none; b=nW7z44gPdxM1ySq8k5x8Y4DSOkmzxWgR5Dwpye8+m4f5H9NfQCYU0yYpltQnqa9ENnX4ZF7jHcRdMRQiGGFcVhcyPEw/IE/nbzHz43vPEIj31GSemhtpF5VjPYFHrqCIzOAEJI24mhut6Oodx2xH8Vu82w2HwqcedqqMuuNPfvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379419; c=relaxed/simple; bh=jhHFFFxw+TQY8tMMgflq+/MItjuQAQ7L4GPqyFiQCSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uszRF3XDikOSnPAzBwfEy/T8ki7smWlC6tdf1f87GiPfnFKguVRVqIlSrAtU/a5kojxqWjmnAS+OYOuDqdrvBw576dZSFE+KRfUYfwexwg616h4Qj5HwpdCUlxONZ2qz4vbiHvnBaIK3gG2o9L5JnrVBW1d+DazzNxP2wLhPnwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=P3MtA2ij; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=sn7lEWAs; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=P3MtA2ij; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=sn7lEWAs; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="P3MtA2ij"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="sn7lEWAs"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="P3MtA2ij"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="sn7lEWAs" 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-out1.suse.de (Postfix) with ESMTPS id 0A3752284D; Fri, 14 Jun 2024 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=P3MtA2ijj1QY3WJgG/z/WHWoXG6CDuXDeCeYHIzZtVrIuGg0ggAWcYLlVLIR1bn7K+ShHn 0TorktyCq6RZQFeDWTM+ket//boKo6RbizGK+P/lc7c8oSGNXY3IjcMsVaiTHxHP3I4JsF dQ+1VOuWe2bL9t0J93z4V5ub9s6Jsj8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=sn7lEWAsq54ZoHadxF4lgXw153IHIPt0NTAdVyKzKygRfnr9WpoIYkOt21pruCtF3njObi 4fL/hRJIK2z4HUAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=P3MtA2ijj1QY3WJgG/z/WHWoXG6CDuXDeCeYHIzZtVrIuGg0ggAWcYLlVLIR1bn7K+ShHn 0TorktyCq6RZQFeDWTM+ket//boKo6RbizGK+P/lc7c8oSGNXY3IjcMsVaiTHxHP3I4JsF dQ+1VOuWe2bL9t0J93z4V5ub9s6Jsj8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=sn7lEWAsq54ZoHadxF4lgXw153IHIPt0NTAdVyKzKygRfnr9WpoIYkOt21pruCtF3njObi 4fL/hRJIK2z4HUAg== 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 CCB6613AB1; Fri, 14 Jun 2024 15:36:55 +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 0BPSMJdjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:55 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 2/6] ALSA: hda: Return -EINVAL for invalid volume/switch inputs Date: Fri, 14 Jun 2024 17:37:11 +0200 Message-ID: <20240614153717.30143-3-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; RCVD_TLS_ALL(0.00)[] So far the HD-audio driver has been tolerant about the input values and accepts any values by correcting the amp volume and switch values internally. But now our own selftest starts complaining about this behavior, so let's be picky and change the behavior to return -EINVAL for invalid input values instead. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 325e8f0b99a8..3dd1bda0c5c6 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1496,7 +1496,7 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid, /* ofs = 0: raw max value */ maxval = get_amp_max_value(codec, nid, dir, 0); if (val > maxval) - val = maxval; + return -EINVAL; return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, HDA_AMP_VOLMASK, val); } @@ -1547,13 +1547,21 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, unsigned int ofs = get_amp_offset(kcontrol); long *valp = ucontrol->value.integer.value; int change = 0; + int err; if (chs & 1) { - change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp); + err = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp); + if (err < 0) + return err; + change |= err; valp++; } - if (chs & 2) - change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp); + if (chs & 2) { + err = update_amp_value(codec, nid, 1, dir, idx, ofs, *valp); + if (err < 0) + return err; + change |= err; + } return change; } EXPORT_SYMBOL_GPL(snd_hda_mixer_amp_volume_put); @@ -2149,15 +2157,20 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, int change = 0; if (chs & 1) { + if (*valp < 0 || *valp > 1) + return -EINVAL; change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, HDA_AMP_MUTE, *valp ? 0 : HDA_AMP_MUTE); valp++; } - if (chs & 2) + if (chs & 2) { + if (*valp < 0 || *valp > 1) + return -EINVAL; change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, HDA_AMP_MUTE, *valp ? 0 : HDA_AMP_MUTE); + } hda_call_check_power_status(codec, nid); return change; } From patchwork Fri Jun 14 15:37:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698870 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 232FF19B5A0; Fri, 14 Jun 2024 15:36:58 +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=1718379419; cv=none; b=bAwx2uDIJSrW+3faZc42O/QLBIb14XTpz1ShmfuFZ2i8QpfNjAzD1AndSrb8Z1KCBK+WTFVUWCnsL+0+Jp6wHqKmTiDrmMulPrFdQ15NA9gkLgSADL2U5IMOb5m3r9jUzPiuyEZoFE/adLzVWTCEabbg4JGvyhN/4IUcs6lMKB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379419; c=relaxed/simple; bh=oEXcl7uZTmrbBKkBkSJry3DmM9KI3mi9XsRAkK7VSb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hTi7aEVEfGP+MoEFKLJYkrT+5vSF2MDBNFPMFyRLbM344j1sLMJofNSUIs0JwXNviwKAKQYxfpW4xzQYxhtqhydT7BSpIxcORPl6paOnk+wYrp+Akcy3Y64Z2nPzqgL6CcGCODtU2fVy7fGmtndr4eoas6wLx/RueGnBombagyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=i5Zf9/kL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=saCTgKZd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=i5Zf9/kL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=saCTgKZd; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i5Zf9/kL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="saCTgKZd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i5Zf9/kL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="saCTgKZd" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 433AF2063E; Fri, 14 Jun 2024 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=vKcSdFK/k+y9ps2EP7BQhMbyq7gYbxfGauuX6w+y5Us=; b=i5Zf9/kLjL3c+Pna/IcTlmTV1mJKbqg88tXdoh/dR+OCABE7cGM2nski9557GItgBF+vy5 zItJbVZxtwkgz1nK7t7R8T/WpStgtwsiepcECIXgOuuiHzyYS/oeJcHgftc8HKmB/el4bx Sf1zeolWE4dOpRkI1Lba202IXXytvtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=vKcSdFK/k+y9ps2EP7BQhMbyq7gYbxfGauuX6w+y5Us=; b=saCTgKZd+gdF2FvG0Km1AmwkRXNhkEpOWueAL7p/lbBa4pv1MGaWVHXKoUrT29tJYVxglH Z1nI+6/uq/5t52Ag== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="i5Zf9/kL"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=saCTgKZd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=vKcSdFK/k+y9ps2EP7BQhMbyq7gYbxfGauuX6w+y5Us=; b=i5Zf9/kLjL3c+Pna/IcTlmTV1mJKbqg88tXdoh/dR+OCABE7cGM2nski9557GItgBF+vy5 zItJbVZxtwkgz1nK7t7R8T/WpStgtwsiepcECIXgOuuiHzyYS/oeJcHgftc8HKmB/el4bx Sf1zeolWE4dOpRkI1Lba202IXXytvtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=vKcSdFK/k+y9ps2EP7BQhMbyq7gYbxfGauuX6w+y5Us=; b=saCTgKZd+gdF2FvG0Km1AmwkRXNhkEpOWueAL7p/lbBa4pv1MGaWVHXKoUrT29tJYVxglH Z1nI+6/uq/5t52Ag== 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 0CD8913AB5; Fri, 14 Jun 2024 15:36:56 +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 KHHnAZhjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:56 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 3/6] ALSA: control: Apply sanity check of input values for user elements Date: Fri, 14 Jun 2024 17:37:12 +0200 Message-ID: <20240614153717.30143-4-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 433AF2063E X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: Although we have already a mechanism for sanity checks of input values for control writes, it's not applied unless the kconfig CONFIG_SND_CTL_INPUT_VALIDATION is set due to the performance reason. Nevertheless, it still makes sense to apply the check for user elements despite of its cost, as that's the only way to filter out the invalid values; the user controls are handled solely in ALSA core code, and there is no corresponding driver, after all. This patch enables the input value validation for user control elements no matter whether CONFIG_SND_CTL_INPUT_VALIDATION is set or not. The kselftest will be happier with this change, as the incorrect values will be bailed out now with errors. For other normal controls, the check is applied still only when CONFIG_SND_CTL_INPUT_VALIDATION is set. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Reviewed-by: Mark Brown Signed-off-by: Takashi Iwai Reported-by: Paul Menzel Reviewed-by: Jaroslav Kysela Reviewed-by: Mark Brown Signed-off-by: Takashi Iwai Reviewed-by: Takashi Sakamoto --- sound/core/control.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/control.c b/sound/core/control.c index fb0c60044f7b..50890983d7e2 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1317,7 +1317,8 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, snd_ctl_build_ioff(&control->id, kctl, index_offset); result = snd_power_ref_and_wait(card); /* validate input values */ - if (IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) && !result) { + if ((IS_ENABLED(CONFIG_SND_CTL_INPUT_VALIDATION) || + (vd->access & SNDRV_CTL_ELEM_ACCESS_USER)) && !result) { struct snd_ctl_elem_info info; memset(&info, 0, sizeof(info)); From patchwork Fri Jun 14 15:37:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698869 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 232A81802CF; Fri, 14 Jun 2024 15:36:57 +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=1718379419; cv=none; b=qoI4jGN46g9Kq1A9AKoy/b6TFwr2s14wcAcJhqq2W52r8UeqQngkY4vRIudIECptoexTximO6vgRy9lk0sGZQOaLVkVujAy2+XsQQ+L+VT5HO8aqpdizEbZGTPV2pK//zfBQ+5vVmUA7LTOLS12lDkteoiz0+w1mkmulA8e0zOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379419; c=relaxed/simple; bh=wqmTBb0yg2Iq2mWVJqKWGa3A/CsIyioF8Xc5PzN4kdA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dgls5zazS6rbbLGzo14piv4dx0s0pEPD8o/AstD67sGSlWuRm+vJehZ+K/m9iRtY6PfneSAkYRDwtemZnqDp8uRL5MZ0mpEvNzJNKXjajFvyS84DIZWH8NwIXjx65pQIlRjYi555z/yWFxpIwbu7uIKILYZ3b6WfwXJM3K7qRHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=j/xGVcfI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=p+J8jYVC; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=j/xGVcfI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=p+J8jYVC; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j/xGVcfI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="p+J8jYVC"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j/xGVcfI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="p+J8jYVC" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 753562063F; Fri, 14 Jun 2024 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=NwfK0rqWgBsFgQ4ZXZWrRPfeKLni9Acfbte7VJx00kQ=; b=j/xGVcfIvkiRauLKT7pu1fbGpV+/YooHgmbM0O5lSM/z5pkkJInEz8Onk+Mfzjtswv7N1p d2dv+qBjh1x1V6BBtH9Lly50RU/Pi9LWehuXPmsJKPl1pUhsYQsYVuSNwjJBj17RDRizsi c9CnzpHQBMujXTL5jNiIDL3ROTDPHJ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=NwfK0rqWgBsFgQ4ZXZWrRPfeKLni9Acfbte7VJx00kQ=; b=p+J8jYVCRyyu7dKkZdd25A6a4f4OYKzuWGB1BV9HU4LtnN4gVTj83mTpbxOSMa8asmpohG 3p1/zIDM9SE0boBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="j/xGVcfI"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=p+J8jYVC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=NwfK0rqWgBsFgQ4ZXZWrRPfeKLni9Acfbte7VJx00kQ=; b=j/xGVcfIvkiRauLKT7pu1fbGpV+/YooHgmbM0O5lSM/z5pkkJInEz8Onk+Mfzjtswv7N1p d2dv+qBjh1x1V6BBtH9Lly50RU/Pi9LWehuXPmsJKPl1pUhsYQsYVuSNwjJBj17RDRizsi c9CnzpHQBMujXTL5jNiIDL3ROTDPHJ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=NwfK0rqWgBsFgQ4ZXZWrRPfeKLni9Acfbte7VJx00kQ=; b=p+J8jYVCRyyu7dKkZdd25A6a4f4OYKzuWGB1BV9HU4LtnN4gVTj83mTpbxOSMa8asmpohG 3p1/zIDM9SE0boBQ== 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 47DC613AB1; Fri, 14 Jun 2024 15:36:56 +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 2M1dEJhjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:56 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 4/6] kselftest/alsa: mixer-test: Skip write verification for volatile controls Date: Fri, 14 Jun 2024 17:37:13 +0200 Message-ID: <20240614153717.30143-5-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-3.01 / 50.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]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 753562063F X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: The control elements with volatile flag don't guarantee that the written values are actually saved for the next reads, hence we can't verify the written values reliably. Skip the verification after write tests for those volatile controls for avoiding confusion. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Signed-off-by: Takashi Iwai Reviewed-by: Jaroslav Kysela Reported-by: Paul Menzel Signed-off-by: Takashi Iwai --- tools/testing/selftests/alsa/mixer-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c index 1c04e5f638a0..c98167818319 100644 --- a/tools/testing/selftests/alsa/mixer-test.c +++ b/tools/testing/selftests/alsa/mixer-test.c @@ -616,6 +616,10 @@ static int write_and_verify(struct ctl_data *ctl, if (!snd_ctl_elem_info_is_readable(ctl->info)) return err; + /* Skip the verification for volatile controls, too */ + if (snd_ctl_elem_info_is_volatile(ctl->info)) + return err; + snd_ctl_elem_value_set_id(read_val, ctl->id); err = snd_ctl_elem_read(ctl->card->handle, read_val); From patchwork Fri Jun 14 15:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698871 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 70FDD3B1AB; Fri, 14 Jun 2024 15:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379420; cv=none; b=L04h47PLo8BCbmsW/RzkpVSSnQG8qhPXoLxDU7iRZGTyipxtVucmaia/PhmdN+X1ba1jEqnlGhtNJcRZBXcfGFg0HcH6EkTQ3WlWN4HsS+CTp8wk3ocrLP8nKdUxHuMV0dZzbwoRqcuoh90totEJLC4QH2q/C9AIPQ/N2Y+cxYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379420; c=relaxed/simple; bh=QeO5On+GiAI3IpqJmJUkztuf3OYNJlt8aK69Bq+/pkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qx5ahirZrS013tWDrJki4EcEqBlVKye9gnpOdHh/sxVn3QBzWB/KR+RvNBuBye6MB3iXo7ynKyAAKASusyQOCfPrWc8n6gd1/ieMiSfObhF1pshZnrO53WmAWthnFRQ4CuJR8bTaS3UWLZUizQYhYXODOeTU67aFifAGX7r1IQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mHxKXWxI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=KPecQxBO; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mHxKXWxI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=KPecQxBO; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mHxKXWxI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="KPecQxBO"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mHxKXWxI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="KPecQxBO" 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-out1.suse.de (Postfix) with ESMTPS id AB1DA2285C; Fri, 14 Jun 2024 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=mHxKXWxI+NO6gj9vEGod0VSsnrekrNXy1UdqDWWTwLNuhQgu5cvgvV8uZQZI15eHcZqGvv lyneKV9oIcQUs9CPxG0VSVMuW7vW7nILSLwvF1rcls+uv/A6QwkuU0I8uTdSp9hEhtsXO8 CM7lME8Xn5HkoactmKzDN0/1cE3HwWA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=KPecQxBOEvJg0NjOG+joiqYRVAnz0fTTQ8vd9sjxnRM4gbnOnbzRyugn4Y9M1iRcS+kyIS RvK5woz8vrqxtdCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=mHxKXWxI+NO6gj9vEGod0VSsnrekrNXy1UdqDWWTwLNuhQgu5cvgvV8uZQZI15eHcZqGvv lyneKV9oIcQUs9CPxG0VSVMuW7vW7nILSLwvF1rcls+uv/A6QwkuU0I8uTdSp9hEhtsXO8 CM7lME8Xn5HkoactmKzDN0/1cE3HwWA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=KPecQxBOEvJg0NjOG+joiqYRVAnz0fTTQ8vd9sjxnRM4gbnOnbzRyugn4Y9M1iRcS+kyIS RvK5woz8vrqxtdCQ== 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 7C4B813AB5; Fri, 14 Jun 2024 15:36:56 +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 8E36HJhjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:56 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 5/6] ALSA: chmap: Mark Channel Map controls as volatile Date: Fri, 14 Jun 2024 17:37:14 +0200 Message-ID: <20240614153717.30143-6-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; RCVD_TLS_ALL(0.00)[] The values returned from Playback Channel Map and Capture Channel Map controls may vary dynamically depending on the corresponding PCM stream. Mark those as volatile to indicate the values are unstable and not suitable for testing. Note that we may change the driver to return -EINVAL, but this would bring other side effects, such as "alsactl restore" would start receiving unexpected errors. So we still keep returning 0 for those invalid inputs. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 6f73b3c2c205..071c67cbc479 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2556,6 +2556,7 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, struct snd_kcontrol_new knew = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .access = SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, .info = pcm_chmap_ctl_info, From patchwork Fri Jun 14 15:37:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13698872 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 A18251802DF; Fri, 14 Jun 2024 15:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379420; cv=none; b=lNp3GxWaXVRUbdnjOBsk8jRU0sLDEcRYctT/d8+qzyvAwz2Scvce/p2nSEUMpHisAQHsuxyldOrOV1FRTXi8hwiYWeX2W37ChyyYTsjzrbTdMuMQRnSS/lcAYpWf1acsrA4UfM72ulPIq1shZKcXhzx3QDnpKi6HK0NySu47JeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718379420; c=relaxed/simple; bh=HhL3CaW8fEJwIYD0X/S93jOWGJe5uzjDmfpNmThwKIE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMOeCvuq/n6zg8+mL7eTVT6PA8Ua9sYRAdjUN07FEUDfJuUpvmM7lSHa5QYLLelSaits5nmuSbpXJGZUbCtp03HZqmgGbJJUobpIXUnfVd7G+E+o0nlNmW+Cd4g7nE1GpO5SKSOfXdy4s2KupvwFUAF5mldEFBamU/+ZIstE2Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Ppk1Gk2J; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NBg+3l6r; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Ppk1Gk2J; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NBg+3l6r; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Ppk1Gk2J"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NBg+3l6r"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Ppk1Gk2J"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NBg+3l6r" 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-out1.suse.de (Postfix) with ESMTPS id DD8222286A; Fri, 14 Jun 2024 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=Wi/3TisUivZiOUMMz1zWLCaPn56nPEUqT+yVdSj12tM=; b=Ppk1Gk2JDuZZv2+2XVO7fI2FePwfCsLgKAmrTeqUEhD7bXIYl77oNlfv1UE4VOLVQxjlSW uu+3cAkpeonGvFq2f5nQ3a3sc4kqgh751885Ijij1LMtIieJu2EU39chn1bi2yfiMoAs6J J0baHIUmdL5K4IxhAU/IYM8lfBVEYVU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=Wi/3TisUivZiOUMMz1zWLCaPn56nPEUqT+yVdSj12tM=; b=NBg+3l6rVN2pqHl7OCY3cGjCRS4n7+0vRGJwVcbNhy+pA/vtcAKvgBJ75XK4hrVm+t/NwL lPgIgJWfdkGsRlDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718379416; 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=Wi/3TisUivZiOUMMz1zWLCaPn56nPEUqT+yVdSj12tM=; b=Ppk1Gk2JDuZZv2+2XVO7fI2FePwfCsLgKAmrTeqUEhD7bXIYl77oNlfv1UE4VOLVQxjlSW uu+3cAkpeonGvFq2f5nQ3a3sc4kqgh751885Ijij1LMtIieJu2EU39chn1bi2yfiMoAs6J J0baHIUmdL5K4IxhAU/IYM8lfBVEYVU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718379416; 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=Wi/3TisUivZiOUMMz1zWLCaPn56nPEUqT+yVdSj12tM=; b=NBg+3l6rVN2pqHl7OCY3cGjCRS4n7+0vRGJwVcbNhy+pA/vtcAKvgBJ75XK4hrVm+t/NwL lPgIgJWfdkGsRlDg== 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 AFE1713AB1; Fri, 14 Jun 2024 15:36:56 +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 4JzCKZhjbGZQZAAAD6G6ig (envelope-from ); Fri, 14 Jun 2024 15:36:56 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , linux-kselftest@vger.kernel.org Subject: [PATCH v2 6/6] ALSA: hda: Add input value sanity checks to HDMI channel map controls Date: Fri, 14 Jun 2024 17:37:15 +0200 Message-ID: <20240614153717.30143-7-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614153717.30143-1-tiwai@suse.de> References: <20240614153717.30143-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; 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.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: Add a simple sanity check to HD-audio HDMI Channel Map controls. Although the value might not be accepted for the actual connection, we can filter out some bogus values beforehand, and that should be enough for making kselftest happier. Signed-off-by: Takashi Iwai Reviewed-by: Jaroslav Kysela --- sound/hda/hdmi_chmap.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/hda/hdmi_chmap.c b/sound/hda/hdmi_chmap.c index 5d8e1d944b0a..7b276047f85a 100644 --- a/sound/hda/hdmi_chmap.c +++ b/sound/hda/hdmi_chmap.c @@ -753,6 +753,20 @@ static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } +/* a simple sanity check for input values to chmap kcontrol */ +static int chmap_value_check(struct hdac_chmap *hchmap, + const struct snd_ctl_elem_value *ucontrol) +{ + int i; + + for (i = 0; i < hchmap->channels_max; i++) { + if (ucontrol->value.integer.value[i] < 0 || + ucontrol->value.integer.value[i] > SNDRV_CHMAP_LAST) + return -EINVAL; + } + return 0; +} + static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -764,6 +778,10 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, unsigned char chmap[8], per_pin_chmap[8]; int i, err, ca, prepared = 0; + err = chmap_value_check(hchmap, ucontrol); + if (err < 0) + return err; + /* No monitor is connected in dyn_pcm_assign. * It's invalid to setup the chmap */