Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3991330rwd; Tue, 23 May 2023 01:12:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hExEVWQ3K0HcH1SX8XQXnGAMVPaUgwfUN/VGNEQyZELOJd8dAWmBZhi1RqS0q48Bx/haF X-Received: by 2002:a17:902:778c:b0:1ac:6d4c:c265 with SMTP id o12-20020a170902778c00b001ac6d4cc265mr12857051pll.28.1684829557715; Tue, 23 May 2023 01:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684829557; cv=none; d=google.com; s=arc-20160816; b=m238Mw2wT+vgWOg1Y+B3qoUgIrrTYQNSdcIme08XutdUQTDZC1mn3c4V8pHiY9BL+I ksnqKDfTC8knhz6uzVvU6WG3jke0tJlEsJD/maDUWngkrzL38rA974shhS2Yw4K+WVB6 MftIH8Cz7jI7hCDLEWeH7SSv6t11HNG2SQNomJ4gJfJ7KrrU83rGAYjFLw0I77u1ObWe 8/K7LokPFTS02gAS2QQfQ2NX7m8wZ8YLQrlWqCaeNtQyMJ1NWOku/PC8ryqmqH7JGFMR QNdUdDORfoQyp+1U+he8eI4ZwfSS4UKkBBKmKW4lh+L2mjwByMRZkK46e7UkGlNO6BVH Zo/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=uMzBP59J7x7TxGFaxuEDckjn0BZosp/WXU2Nz5BQgbk=; b=hnB/6q8UnZGLTYBd+P3T16mEmgHhPwNMIBOtRPhRjWLGR5GcF4AdqGevB1J1Aa9BET o1C2Px/C/Ug6wDJLC4gP1JHAWftsxlPeHwRpW1uJP4JPMUaFbnen3Ta/rECoRh07y0z1 bUsDcYzstTjPgFcpZ/n6NW9KMZ268D0l8PR08cWI+yjCjX2jDg2VC0JOX8mucGj+sGhw cVfQvSQqkohHiaOXvMDDj/RBPaEPRk44Ev0gtZ3Kl+u/YPcS2hfaGmpdEeFrOmGvYlAY toM8DWHzzFukaJMFdVjtPxH1dF+TPuukBck3cyV6Heir1vmKHUFL7sz8b7AP0jeWoEQU YFNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MxFbxoWd; dkim=neutral (no key) header.i=@suse.de header.b=QLtWeTZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a170902a3c800b001ae7f85061bsi1391364plb.609.2023.05.23.01.12.25; Tue, 23 May 2023 01:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MxFbxoWd; dkim=neutral (no key) header.i=@suse.de header.b=QLtWeTZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235927AbjEWH4T (ORCPT + 99 others); Tue, 23 May 2023 03:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236203AbjEWHzf (ORCPT ); Tue, 23 May 2023 03:55:35 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5C4110D2 for ; Tue, 23 May 2023 00:55:11 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F30D021976; Tue, 23 May 2023 07:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684828448; 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=uMzBP59J7x7TxGFaxuEDckjn0BZosp/WXU2Nz5BQgbk=; b=MxFbxoWdt43CnWdWmOn3iq6Bc3CSpCRFqENLliyU0THhGtYaOK8XYj+J5LjqHUUe/ChdSl KUUH2pIBQYaMRwo26/j3MBL7ODQIZnSqVCzteVe6vaXTE0tlFPcNzPIWuqgojhgPPgB2jY TDyP8ld4FFcxud1cV1BpznNXMZODPsw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684828448; 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=uMzBP59J7x7TxGFaxuEDckjn0BZosp/WXU2Nz5BQgbk=; b=QLtWeTZE8e4awLgLDbzJ8+2XjVLrtRiXEdyEnSMUpcDqXTUTMjCS7X73C1oRFh51qPstpZ ttNfnL/Y//C0hZDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B2F2613A1A; Tue, 23 May 2023 07:54:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8AyuJx9xbGT4KgAAMHmgww (envelope-from ); Tue, 23 May 2023 07:54:07 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 17/37] ALSA: seq: Clear padded bytes at expanding events Date: Tue, 23 May 2023 09:53:38 +0200 Message-Id: <20230523075358.9672-18-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230523075358.9672-1-tiwai@suse.de> References: <20230523075358.9672-1-tiwai@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There can be a small memory hole that may not be cleared at expanding an event with the variable length type. Make sure to clear it. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/seq/seq_memory.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index 47ef6bc30c0e..c8d26bce69ff 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -152,12 +152,16 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char return -EINVAL; if (copy_from_user(buf, (void __force __user *)event->data.ext.ptr, len)) return -EFAULT; - return newlen; + } else { + err = snd_seq_dump_var_event(event, + in_kernel ? seq_copy_in_kernel : seq_copy_in_user, + &buf); + if (err < 0) + return err; } - err = snd_seq_dump_var_event(event, - in_kernel ? seq_copy_in_kernel : seq_copy_in_user, - &buf); - return err < 0 ? err : newlen; + if (len != newlen) + memset(buf + len, 0, newlen - len); + return newlen; } EXPORT_SYMBOL(snd_seq_expand_var_event); -- 2.35.3