Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6977869rwb; Tue, 22 Nov 2022 23:47:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7M3JxcDqgGdpbvoVLByYXEcYbgevV/zNCjF/vARBLAItiHz407htab6vgofM6g8yIsEzP0 X-Received: by 2002:a17:902:ce06:b0:188:fd3f:cb06 with SMTP id k6-20020a170902ce0600b00188fd3fcb06mr7526593plg.23.1669189679364; Tue, 22 Nov 2022 23:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669189679; cv=none; d=google.com; s=arc-20160816; b=PsdYf7L27PD7tHYtQoYDyr6QUmtE6De0hxj+HVhkyyzc7hf//iC34l3glG0OD5pBBo 8W0DghgGDc+hcw6Jp5qOyqU4ZrsaOJzByM5/4YF2AxTjQPCOs8582QIZPIXFa5Gy2ODv +MWFLioPs25RqXYSGhVZVdFgMw8Y4fdjvcLdpXkCCoUuZzHw9sg1mIW0YGt9lT/0wuBZ HQv6fHsh/xoOQxVqiYbyLOah63yQw16eelm50otMsc+JHo+jciNGym1iLeuvwxFjhVUZ nP5XufaNslLTtJbranVc14zdwWp8fUx9U3Qz7uTETJd/rUXQi2kqsr2A2Zi/GnMPpTtl OkDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=qoVSvB0KJ1pA3zQh2W2ESlJGILDsMMP8nb+gJVT4lCQ=; b=k1OoqKNlRHaTfXucJtaREGcPnoxhkLReU2tatTzh+bA+1DKC89MdSoVIU/mHBe1cap a7kZDNtZhoarnft6mH/KCtZJJIvPcRbVgOqqLFVgj7CoFcbGeiYbYT1eO05CCBxRSYK5 hOGyJydzECUoY5+Vf73SDAW/q9t6omj9nK1mX/wU/5J/Ocsxjhflr0VlqjRux/0LTyE8 8YA0OcTXV5DAHLxOFDVhhQioLS6kqsLCmPHYfixyUf8aYVbtLdl4dJZrzzqKJ/YDVgsr 7/997WBVgQCXuclI20ivirETaFnXQk43vYXj8MB/MPa6x0pgtjr4D5aa22obzooMZX5T /BfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ygCYA+01; dkim=neutral (no key) header.i=@suse.de; 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 il13-20020a17090b164d00b001fd70129092si1294178pjb.15.2022.11.22.23.47.48; Tue, 22 Nov 2022 23:47:59 -0800 (PST) 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=ygCYA+01; dkim=neutral (no key) header.i=@suse.de; 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 S236262AbiKWHRH (ORCPT + 89 others); Wed, 23 Nov 2022 02:17:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236244AbiKWHRF (ORCPT ); Wed, 23 Nov 2022 02:17:05 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22DADF8031 for ; Tue, 22 Nov 2022 23:17:04 -0800 (PST) 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 B93A6220D7; Wed, 23 Nov 2022 07:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669187822; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qoVSvB0KJ1pA3zQh2W2ESlJGILDsMMP8nb+gJVT4lCQ=; b=ygCYA+01JE4GASflQeWe0R/6OgIzb3da3m3lrzkBtlj8/CreGe48dEv4He6hXHoErrxOp9 YYiuypwv3OblM9Nc0ErcR5F/dcCszPY1UGqrvtlPfv0c5Fg0iqVfw5ynCwT+uUuuzflsK0 kFEI4AAeYvf5j0yEyKXbS1guMW5LjDs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669187822; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qoVSvB0KJ1pA3zQh2W2ESlJGILDsMMP8nb+gJVT4lCQ=; b=5IhFYKDF0THPEwEd8+xT+s+kuASgvoIHLvKMahDxuqW7URJWNBI1hlnRFishpj6JXGIb+a LSSC8DjuUw6VLqBg== 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 90CC413A37; Wed, 23 Nov 2022 07:17:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YRJnIu7IfWMFTwAAMHmgww (envelope-from ); Wed, 23 Nov 2022 07:17:02 +0000 Date: Wed, 23 Nov 2022 08:17:02 +0100 Message-ID: <87ilj65edt.wl-tiwai@suse.de> From: Takashi Iwai To: butt3rflyh4ck Cc: perex@perex.cz, tiwai@suse.com, baolin.wang@linux.alibaba.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64 In-Reply-To: References: <20221123050911.1045190-1-butterflyhuangxx@gmail.com> <87mt8i5fcz.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII 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 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 On Wed, 23 Nov 2022 08:06:16 +0100, butt3rflyh4ck wrote: > > Hi, the compat_status structure is struct compat_snd_rawmidi_status64 { > s32 stream; > u8 rsvd[4]; /* alignment */ > s64 tstamp_sec; > s64 tstamp_nsec; > u32 avail; > u32 xruns; > unsigned char reserved[16]; > } __attribute__((packed)); > The rsvd[4] and reserved[16] are not initialized. Other members are initialized with zero. https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html Takashi > > > Regards, > butt3rflyh4ck. > > On Wed, Nov 23, 2022 at 2:55 PM Takashi Iwai wrote: > > > > On Wed, 23 Nov 2022 06:09:11 +0100, > > Xiaolong Huang wrote: > > > > > > The compat_status is declared off of the stack, so it needs to > > > be zeroed out before copied back to userspace to prevent any > > > unintentional data leakage. > > > > > > Fixes: d9e5582c4bb2 ("ALSA: Avoid using timespec for struct snd_rawmidi_status") > > > Signed-off-by: Xiaolong Huang > > > > > > --- > > > > > > Reason for resend: > > > 1. add Fixes line. > > > --- > > > sound/core/rawmidi_compat.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c > > > index 68a93443583c..6afa68165b17 100644 > > > --- a/sound/core/rawmidi_compat.c > > > +++ b/sound/core/rawmidi_compat.c > > > @@ -80,6 +80,7 @@ static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile, > > > if (err < 0) > > > return err; > > > > > > + memset(&compat_status, 0, sizeof(compat_status)); > > > compat_status = (struct compat_snd_rawmidi_status64) { > > > .stream = status.stream, > > > .tstamp_sec = status.tstamp_sec, > > > > Here at the line just after your addition, compat_status is fully > > initialized by substitution, so I believe the memset is superfluous. > > > > Or have you verified that it really leaks the uninitialized memory? > > > > > > thanks, > > > > Takashi > > > > -- > Active Defense Lab of Venustech >