Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2214752rwd; Fri, 19 May 2023 02:33:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wJVFUX+aX6yU1IWvdjR3ZTvtjekUZZYISCS6+kgCRQFwBPKk/h1OIhk58qrKfGsV8Y0rc X-Received: by 2002:a17:902:c402:b0:1ac:b259:87ea with SMTP id k2-20020a170902c40200b001acb25987eamr3407191plk.0.1684488830114; Fri, 19 May 2023 02:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684488830; cv=none; d=google.com; s=arc-20160816; b=u4Jb2YcMtqXDfnzjiQpxE6hVAnYV8Ph9RjXY8NbtPXm15QYFpc8E00o2Yfut3qqPrx Ekbfu9yehGSH96dDFFhDdEAG7+C9E4rbJixC6dGwHntNmmKImKErHWy2nftWStdqLHXm nW5BmLA3vnvYVbqOVYdWbccsjeLVOL6Yw3XED9ijj13F6QTyWEJ34aUTcTOozZ6i8Jpt UdEaJQWFQTDLoumMKSKrFTqhSodFlPUyWw88REeEw+owffoG9NWrms8C4joM9e33N9Dj HDRaNLIaYvKMHgnUXa4ipJagYqRklFHac9OibkwiHi6m2Ip4FNcv/TeEHoovv1v1OajD DInQ== 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=NcafucgcxTqZeZeiPExPE8Xrdw3TdNFdLqfYPg++GvE=; b=nj9y+EdHLf8K8aYIP4xhSqGqnK8b89iB/l90pVEcOSSk5SVb7uu6J8TRFPXGUemTJJ zRcVn+YLGaqh7fIlge8l6jrRz/e8e9lMylWuYhG9pgMCPtguQM3ylqKjuqmatIYYbWdI fYcqAKn4n4B600f5/LARhsJqEQsMQjYxsJiB3H0THPyvn0JLyWWJI3Bo0n5w9BbZnM29 cCkSNfNMDv1I0rUl55t1lXl8zphdZajDi1DPGcxpV4uL1/PGp0tizXiiqjYwWIiipbN9 /Vx7tRPeKuAZYnIvCBLijcu7RPVg/VHwnbUpIJgyT1y6ud2Lvw4bcMcVEWUFIyKsk9PD sz0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="oxtSs/AL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 jg12-20020a17090326cc00b001a637201992si3062757plb.488.2023.05.19.02.33.37; Fri, 19 May 2023 02:33:50 -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="oxtSs/AL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S231552AbjESJcY (ORCPT + 99 others); Fri, 19 May 2023 05:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbjESJbm (ORCPT ); Fri, 19 May 2023 05:31:42 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E1010C6 for ; Fri, 19 May 2023 02:31:41 -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-out2.suse.de (Postfix) with ESMTPS id B53F31FE3F; Fri, 19 May 2023 09:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684488699; 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=NcafucgcxTqZeZeiPExPE8Xrdw3TdNFdLqfYPg++GvE=; b=oxtSs/ALtpLVgWEWNJuz2y20qkf0gtOtYz7XyvX3qPIIpPP3AOfGyL1+s0PKmKZcTFKrKk yqGtk5N9sW2qKKpAZ+1KYTINr4sSY1oOiZwCLVcKTVl+aD3baa9ORRGT47ItXTgk022Pyl +WI3vjzfgYprHuGdpcu50HpnvOaycUU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684488699; 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=NcafucgcxTqZeZeiPExPE8Xrdw3TdNFdLqfYPg++GvE=; b=cIMkAkUHAE0x/CPu6ovTjm4Z2Q9mv6qQEw/bLMwiPzgnuuU+hck8W+P74ITEqoo2UjxaO7 PkM6owc0jQY6VUBA== 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 956B213A12; Fri, 19 May 2023 09:31:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ELyhI/tBZ2RXJAAAMHmgww (envelope-from ); Fri, 19 May 2023 09:31:39 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 16/36] ALSA: seq: Clear padded bytes at expanding events Date: Fri, 19 May 2023 11:30:54 +0200 Message-Id: <20230519093114.28813-17-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230519093114.28813-1-tiwai@suse.de> References: <20230519093114.28813-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. 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