From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AEC024BF35 for ; Fri, 5 Dec 2025 05:34:58 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'lD94A6Pblr3MtXbZQM8aJGZ4NFf+yPcExovwrTzb41E=', expected b'98fLwO2YNpTdwQRZiLYrawss1XgfoxC+mwW30AIeWRo=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1764912878; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=lD94A6Pblr3MtXbZQM8aJGZ4NFf+yPcExovwrTzb41E=; b=ME1HfWpisGizQ106LaDoAkneuvsILDP6nv7cbTr+nOtead2UpaQZPX+9NACZj9Zsd49Zr mRxs5D8ZBcdL7/GUY37LUjG25pbdkKxuI11khQMMTbnZhZMQSg3AqzLeM+8fdkgnej5zFW6 9EwB3v/g6HVAjVEe+f/jNRSXQnGTPbzvZHekPfVmhF6kFlabPqcAE/eLIUORwGWSXyOBZQc k5FGg1jc/nGQdrP3FTHyPyLpHFVC7adWkXqrZ33Fs56nbgvvElJrRvnAi3HssMD2gL4KG+W kb6RPv3QzNlF7pLeLYGBw5X+r62dc6CECVx8pscRyQ0swQTQI7Dp0rKqWPbw== Received: from [172.19.0.3] (unknown [172.19.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 3FDBC690585; Fri, 5 Dec 2025 07:34:38 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1764912843; b=kxWM5pn5wDMfR/4uQmbEos9i3spG1+5cRxJfUyX9XUVU2wf9aLmkXTAu98b3wb3McTvS6 azYRbT9l1gmTaXhir2xu0gaou48k2wnBiLDFraxQ+3Y7qxcyxwQ1l/lkmZQWf41osmNTMMn eF3+RcSB0bDVbYb/ydXcor5HmOSi0kOc9FMfXoecCIdd+oCi/j9ZizYUAFlcSIt/n59pZfS VW3MAaV9EezadC46PYoj92U0aD0YcArHkRxQ8GQ1PglH9yblpkpmSRIXLnbPi1ZKTEdBBMi 3CWVRlQVBsXwyftvpkn5lBOt5ut15xRF9HfUlmPL1hJgtjNs5+7kxgGWNYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1764912843; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=jQ7OWHOKzTq8jMdVxi8VLdR+kDl23XBLUApjNV+eWFg=; b=cWVTYh6jDrvSpYSb3U09ilqU4GAyk2uDmeUsuP0TpDaA/78kksCXUofNfbLSHb1Bf4UPU +Hgwuz3iUF31nLmc+pxlTRLaj00b0u3vQxF+GluOdD3RUd+YkdiUuC51w1hug/5SzGo+DGt H0kUMdZYlvCZgyJcbg/WWSSQQm+qdbIA1in5NN1mFhpAbhIKmizensqGLVPMEbTJDEe/lQC UKdMEkqmb8BKbHULhf9XAJUK3TsdKFA52+COjYG8TnZZ6U+lQKbZelIru+ors5mwQ7+wTkV z85Ak5pAwZHY20SgnF6wKHAeqY2eftDnjd5e55IyE+AZa7l3j0rFS5AOQGgg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1764912830; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=98fLwO2YNpTdwQRZiLYrawss1XgfoxC+mwW30AIeWRo=; b=kFE8aAPlpuhSZl8V/wjry1euS6x7/vK2uDV14055RZ4o+lB9XlG+/8QwZigC+Ak1kRMlS B9SgrajCzz9Lf5CTA3YGOVbyNE578PwIMgo0aNIrAmCYfjPlbUP9fjLWeVxF3GLgi4gk4Ow N7SuEftuQmGO5lPmlBgmKtSLU/iD5cKLDHS6Aw+MaVVNMSu8477fe1WCKpBc3J74MOvK6g8 5W0i7mAxiDHiOpKaoDOBpUL04sW2DYIgDL1QKoyEIJOd1IpboDjCVcHSqMHmFxJL6c6KxTS IqB1Q3X5fgGUYX7KZAJjry/NFQ8pYwPhs09uXNpM3B5cd9ku6Ofyx+XV178g== Received: from 55ca25703178 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id B1644690502 for ; Fri, 5 Dec 2025 07:33:50 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 05 Dec 2025 05:33:50 -0000 Message-ID: <176491283104.39.1723969197932564100@2cb04c0e5124> Message-ID-Hash: RXQOEXMMEWP5IJK5RE6IDMPMR7TL6TUH X-Message-ID-Hash: RXQOEXMMEWP5IJK5RE6IDMPMR7TL6TUH X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avformat/iamf_parse: Fix heap-buffer-overflow (PR #21107) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: oliverchang via ffmpeg-devel Cc: oliverchang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21107 opened by oliverchang URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21107 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21107.patch The ASAN heap-buffer-overflow in `scalable_channel_layout_config` at `libavformat/iamf_parse.c:435` was caused by an unchecked assumption that the channel layout of a scalable audio layer is a superset of the previous layer's channel layout. `scalable_channel_layout_config` constructs a channel layout map by copying channels from the previous layer and adding new ones. The memory allocation is based on the target `loudspeaker_layout`. However, if the target layout doesn't encompass all previous channels (e.g., Mono to Stereo), copying previous channels followed by adding current ones could exceed the allocated size, causing a heap buffer overflow. This commit adds a check to ensure the previous layer's channel layout is a subset of the current layer's layout by comparing their masks. If the condition isn't met, `AVERROR_INVALIDDATA` is returned. Fixes: https://issues.oss-fuzz.com/issues/464965414 >>From 6b353995bea2f39dbb751ba868e156b4dd94e8a8 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Fri, 5 Dec 2025 05:30:29 +0000 Subject: [PATCH] avformat/iamf_parse: Fix heap-buffer-overflow The ASAN heap-buffer-overflow in `scalable_channel_layout_config` at `libavformat/iamf_parse.c:435` was caused by an unchecked assumption that the channel layout of a scalable audio layer is a superset of the previous layer's channel layout. `scalable_channel_layout_config` constructs a channel layout map by copying channels from the previous layer and adding new ones. The memory allocation is based on the target `loudspeaker_layout`. However, if the target layout doesn't encompass all previous channels (e.g., Mono to Stereo), copying previous channels followed by adding current ones could exceed the allocated size, causing a heap buffer overflow. This commit adds a check to ensure the previous layer's channel layout is a subset of the current layer's layout by comparing their masks. If the condition isn't met, `AVERROR_INVALIDDATA` is returned. Fixes: https://issues.oss-fuzz.com/issues/464965414 --- libavformat/iamf_parse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index 597d800be0..3bb55eb0e9 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -399,8 +399,12 @@ static int scalable_channel_layout_config(void *s, AVIOContext *pb, av_channel_layout_copy(&ch_layout, &ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]); } else if (loudspeaker_layout < 10) { av_channel_layout_copy(&ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]); - if (i) - ch_layout.u.mask &= ~av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, UINT64_MAX); + if (i) { + uint64_t mask = av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, UINT64_MAX); + if ((ch_layout.u.mask & mask) != mask) + return AVERROR_INVALIDDATA; + ch_layout.u.mask &= ~mask; + } } else ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC, .nb_channels = substream_count + -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org