From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 B248D379EF5 for ; Tue, 23 Jun 2026 23:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782257935; cv=none; b=tyHBzkCk17dViymfXO29NPXarMXPQlzYLM2Cfl+hA5geZZyZMQItyLlHGOhGnz3pwPBoDRb+FMUUCkVK42eCXrrVARgE32R10zK9IO+c9gUlOxF6eJCgei/2Qof/cJzW8mj1N2Pb8N7y2VO3lqRFuBgE8ATDJiNXV4YjwNQ/O44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782257935; c=relaxed/simple; bh=anz1ToNpFKVzUDh7jTcBYy8XV/g88YgN/mz66Rdp+is=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ArV2qe1Gjp+DZQ8a4meCfRxAlIn/NrH8TbiNxUpTPCeWph742L9uEVT9Jeu1RYbikiRFcKfE8JrasxCWImhYwWF0gHXhMcm+mEkWEf1AqLeKpurQXfE640JzBTFX46nJmgS9Fv0ThonT9aRa+fHCsKgICoy4f3NgotZrcEL5lcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UU12PTIu; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UU12PTIu" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-37c8e7c8137so378563a91.1 for ; Tue, 23 Jun 2026 16:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782257934; x=1782862734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Fw6+3fh/QLPaU0s83lcitL0HJwJ4R/4raPAKb7sIerQ=; b=UU12PTIuTkt9361I5MS3m8DEAXydtZEozHHYwC68MlioIftlRs6xuGJxvd3FmgGm4/ DP04PK2uSrVgkfXPALSrpD06ou1Rc0ib9yYMcbWRpsJxT5PdNUUodbvwb09Y0hPRzM+D ghU0CcwcQIf9IHfbcxqivdu52TcRiEYLT6mJSr8mawjCyZjnYNaLFAiVITKG7Z95N7L1 MERnxf+11Cns3HAow31iozyPGvEe6dgymPrUKoVDTeUHOEbTF47NjDGlAM3HEYjcoNDx ZSZwSQH6hmzV7No/TetCdKnwpFXvOdkweGhNZ1g8mYHmrDxxZjerX6w1ePsjjBgS9AAo h2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782257934; x=1782862734; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Fw6+3fh/QLPaU0s83lcitL0HJwJ4R/4raPAKb7sIerQ=; b=W2W64JhtDUuDXnaNrGPkEZJRVM2WvXCdWiU+qGgw+czSOX6+2zp7VK4R9769y0+4gz nEmQLjukOfP5AfTIGA/WkBJyu1SN8g/v/1V/sE7rsnEoOC/lwOGpo3gkNmd+kDJ5MWX1 Qj3ehiQ3lElKe8pzgndwiib5HrzKvmq0Qb4AU4J2jWQhAm8zkaIvd4M4NIUgp0kdSQ+i OPPXvqQteA0pFcrsPzd07DpHhWqmX/8Aeiim8PUAclPUzBBffcmMjgDZ0EB+eZTuWz3O rtke0+JwONha2gZ/QyQPp/1zYvb2yoE0IMK42I6Nh8Mh+KxXsEAO5SIn51Ble7pO2bL8 Hz0g== X-Forwarded-Encrypted: i=1; AHgh+Rp2sCLZo6ep5wpHOZCdg35HbDgC49HiQAjpXG4GU93zaGXIN8kOT4u8zs3c09UpLSCzkrHivh1fRtpssl0=@vger.kernel.org X-Gm-Message-State: AOJu0YyGYzW4SCbIqFVtgh/qgAMdFyd8tGscsjHBFf+tOAgLfa/DQYv+ eZVL9GNK2iR2J4KQGRAo3hi3tKoN5uMX+FODFqN7/ZvZ4LNhPeD5M8ly X-Gm-Gg: AfdE7cmR/iyyscdfsNuLAN2zjMeS5xVRftikB6UZsVILqBCeHGfqYSXvx6YcvQ9DqAX 1xhAPkqatlvjfaH0Uc6e4yN2Yn5zQcuT8ISMYVH8dzpPgc6kZkZunlhT3JYz1vjBJBHqskV7+Mg uTINhBocYFEWaFzC/45CxLUfyxqnccXiSdsyjYj48pHf2Ch4Q5BZt6+e0PnHrIHuV//TFuFwvty PgQy2KSEVR/eL4C5kEpquhS5pcdmqLkxmSy17XrtUuAK5fwaj/pHuOK8o8KuNJPBJ56Nrg+lzBG 4SnQog+3c9toYH2XCz2jGJpbNx9z9bhye75rMDD2/bR+jBW0AaKQn0PUxo+O1ie4wZc0zMx+uJ2 ZgBmqKZNOyZZXPtNODh701zC82g7CMwBhHZPhY39QTtoyI8Fmd0bg12f36c9rJKV1Bu3BrST0il 9mOfcVD47YL8/+XHIfJS7gNkkurPLREGtr62eT0GPFjnrfDAypLXa4AxPe42lPxFpN0uiSQfxn5 NwdXQ== X-Received: by 2002:a17:903:3bc7:b0:2c4:608:167c with SMTP id d9443c01a7336-2c7c759693bmr52363295ad.6.1782257933696; Tue, 23 Jun 2026 16:38:53 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7436d6c16sm119647755ad.23.2026.06.23.16.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 16:38:51 -0700 (PDT) From: HyeongJun An To: Takashi Iwai , Jaroslav Kysela Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, HyeongJun An , stable@vger.kernel.org Subject: [PATCH] ALSA: seq: Fix uninitialised heap leak in snd_seq_event_dup() Date: Wed, 24 Jun 2026 08:38:40 +0900 Message-ID: <20260623233841.853326-1-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit snd_seq_event_dup() copies an incoming event into a pool cell and, in the UMP-enabled build, clears the trailing cell->ump.raw.extra word that the memcpy() did not cover. The guard deciding whether to clear it compares the copied size against sizeof(cell->event): memcpy(&cell->ump, event, size); if (size < sizeof(cell->event)) cell->ump.raw.extra = 0; For a legacy (non-UMP) event, size == sizeof(struct snd_seq_event) == sizeof(cell->event), so the condition is false and the extra word keeps stale data. The cell pool is allocated with kvmalloc() (not zeroed) and cells are reused via a free list, so that word holds uninitialised heap or leftover event data. When such a cell is delivered to a UMP client (client->midi_version > 0) that set SNDRV_SEQ_FILTER_NO_CONVERT -- so the legacy event reaches it unconverted -- snd_seq_read() reads it out as the larger struct snd_seq_ump_event and copies the stale word to user space, a 4-byte kernel heap infoleak to an unprivileged /dev/snd/seq client. Compare against sizeof(cell->ump) instead, so the trailing word is zeroed for every event shorter than the UMP cell. Fixes: 46397622a3fa ("ALSA: seq: Add UMP support") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: HyeongJun An --- sound/core/seq/seq_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index ca9f6db0022c..209b08c2a940 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -364,7 +364,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, size = snd_seq_event_packet_size(event); memcpy(&cell->ump, event, size); #if IS_ENABLED(CONFIG_SND_SEQ_UMP) - if (size < sizeof(cell->event)) + if (size < sizeof(cell->ump)) cell->ump.raw.extra = 0; #endif -- 2.43.0