Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp4624885rwp; Sun, 16 Jul 2023 07:18:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlFEpdJiSRVDAb73fP5xZjs2sxKFdZIGjzENwptMtRl8BGQM9AOcvI+t/hXhPJIHSvBRuo8k X-Received: by 2002:a17:902:da85:b0:1b8:9fc4:2733 with SMTP id j5-20020a170902da8500b001b89fc42733mr5534626plx.3.1689517098739; Sun, 16 Jul 2023 07:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689517098; cv=none; d=google.com; s=arc-20160816; b=kAHBIcYP4leDPZLW8fzf71nQRoR6m49NK0cr9bQLh07cLai2JnGTS4any3444Dmkzu /J1xMVpReBlYrhYCUYEnBNc96IIkaQqhsLxcaJCpBRil4hFrRPhPGDZ1Dl4LnQL/ytm5 t8aH8Snfu/ElSRv3bLVKbM4w+NRldzzj3xphH3p+eVPmr4goeWpzWqFzKD3sFx9kV0Nr kKKGHUjO2TDfBwnu0d9Riw7x+pEub1hzLgPxg4tODVAzJmpBA8lDj/8yeH4HO/FxV1hF 3yw15OEspBkbj6d0CgAGs/LHUz7J5DIqY1ecM40NXY5zDBJamThZ4nC7gvc+byirlI28 cOAw== 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=7AtYK9H6OEFphuJ+7xGg8FXecY+/gGpOOXHIVq4Nm0Y=; fh=YoBQtDqXaFEZ5OnViB0xn8DLzPJnrklCK8HDs2jgWww=; b=p+CgCqNMf+z7EEg+TF15KXrJEhfban/SMOH9gvmC/DeN9UzuZspcGgFd2wb6czexYy OFa4Mkz0RFJZuKz2JDtb7TL7uXsOIxxaLvIwrNbk22GtyAqc6WfMgC3qZlcazhG7ijvB JQy0bNNtPJ73SCchonBcGIO/7RpbwJFEacbgT6SDYLL3MHZj6mK4dBifMhThBxQ3ZXac yKb3TWxA96Ye6Unldw/Zc2iZgd6W41ArgKzcemveP30hfnMlTO14/kzqjBPStdsxnp9B p4iNAJrm6JWF6maHCjb7544Lwp9ue0La6mpie8ySj9ViX+RKPXF8iQjJp+OeJumx9nKT QGdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hQ3EqsRw; dkim=neutral (no key) header.i=@suse.de header.b=p4paIBZq; 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 z6-20020a170903018600b001b8a2a800dasi8738976plg.131.2023.07.16.07.18.05; Sun, 16 Jul 2023 07:18:18 -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=hQ3EqsRw; dkim=neutral (no key) header.i=@suse.de header.b=p4paIBZq; 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 S229658AbjGPNH2 (ORCPT + 99 others); Sun, 16 Jul 2023 09:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGPNH0 (ORCPT ); Sun, 16 Jul 2023 09:07:26 -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 B50CE1AA for ; Sun, 16 Jul 2023 06:07:25 -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 30A8A218F2; Sun, 16 Jul 2023 13:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689512844; 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=7AtYK9H6OEFphuJ+7xGg8FXecY+/gGpOOXHIVq4Nm0Y=; b=hQ3EqsRwAhiMBD02CyvRlJD10ouY1Gg7CTjKztqt3HmuqJdPadnsfF5rIIxLzqNx9qMfdq 52NHfjiOTnGMzhefq2LRccYKaazu5394f45vmpGtpsTVoD5luiQPMHiPE+kgn9EeTNjRV3 l6pttHqRko0QCWUXAKldY/Tf3P0j8cg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689512844; 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=7AtYK9H6OEFphuJ+7xGg8FXecY+/gGpOOXHIVq4Nm0Y=; b=p4paIBZq6Eq6jnI8esXqfm/daNrNu+5LvAY9EcswEOpkFVjsHrUIjZrogi64S83jLkwAGI LBMUAzEO1E68RpBw== 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 097C113252; Sun, 16 Jul 2023 13:07:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ndCCAYzrs2T2fwAAMHmgww (envelope-from ); Sun, 16 Jul 2023 13:07:24 +0000 Date: Sun, 16 Jul 2023 15:07:23 +0200 Message-ID: <87v8ekattg.wl-tiwai@suse.de> From: Takashi Iwai To: syzbot Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, perex@perex.cz, syzkaller-bugs@googlegroups.com, tiwai@suse.com Subject: Re: [syzbot] [alsa?] memory leak in snd_seq_create_port In-Reply-To: <00000000000098ed3a0600965f89@google.com> References: <00000000000098ed3a0600965f89@google.com> 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Sun, 16 Jul 2023 10:21:49 +0200, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: 3f01e9fed845 Merge tag 'linux-watchdog-6.5-rc2' of git://w.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14b07344a80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=75da4f0a455bdbd3 > dashboard link: https://syzkaller.appspot.com/bug?extid=cf8e7fa4eeec59b3d485 > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15877dc2a80000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12905004a80000 > > Downloadable assets: > disk image: https://storage.googleapis.com/syzbot-assets/441fb7ea58b8/disk-3f01e9fe.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/8fa7790ba0c3/vmlinux-3f01e9fe.xz > kernel image: https://storage.googleapis.com/syzbot-assets/5e7a6471dadf/bzImage-3f01e9fe.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+cf8e7fa4eeec59b3d485@syzkaller.appspotmail.com > > Warning: Permanently added '10.128.1.1' (ED25519) to the list of known hosts. > executing program > executing program > BUG: memory leak > unreferenced object 0xffff888100877000 (size 512): > comm "syz-executor257", pid 5012, jiffies 4294941742 (age 12.790s) > hex dump (first 32 bytes): > 80 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] kzalloc include/linux/slab.h:703 [inline] > [] snd_seq_create_port+0x78/0x300 sound/core/seq/seq_ports.c:135 > [] snd_seq_ioctl_create_port+0xe1/0x2a0 sound/core/seq/seq_clientmgr.c:1324 > [] snd_seq_ioctl+0x13e/0x290 sound/core/seq/seq_clientmgr.c:2327 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd > > BUG: memory leak > unreferenced object 0xffff888106742c00 (size 512): > comm "syz-executor257", pid 5013, jiffies 4294942276 (age 7.450s) > hex dump (first 32 bytes): > 80 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] kzalloc include/linux/slab.h:703 [inline] > [] snd_seq_create_port+0x78/0x300 sound/core/seq/seq_ports.c:135 > [] snd_seq_ioctl_create_port+0xe1/0x2a0 sound/core/seq/seq_clientmgr.c:1324 > [] snd_seq_ioctl+0x13e/0x290 sound/core/seq/seq_clientmgr.c:2327 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd Likely a forgotten kfree() at the error path. The patch below should fix it. Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: seq: Fix memory leak at error path in snd_seq_create_port() We forgot to release a newly allocated item at the error path in snd_seq_create_port(). This patch fixes it. Reported-by: syzbot+cf8e7fa4eeec59b3d485@syzkaller.appspotmail.com Closes: https://lore.kernel.org/r/00000000000098ed3a0600965f89@google.com Cc: Signed-off-by: Takashi Iwai --- sound/core/seq/seq_ports.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 9b80f8275026..f3f14ff0f80f 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -149,6 +149,7 @@ int snd_seq_create_port(struct snd_seq_client *client, int port, write_lock_irq(&client->ports_lock); list_for_each_entry(p, &client->ports_list_head, list) { if (p->addr.port == port) { + kfree(new_port); num = -EBUSY; goto unlock; } -- 2.35.3