From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0E20F9D0D1 for ; Tue, 14 Apr 2026 14:19:38 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fw5y12Mftz2yVL; Wed, 15 Apr 2026 00:19:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.124 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776176377; cv=none; b=Eiz3zA8YZgWrY6nLrFFK4APusBsAxdGgXSJtD1X9plngr08kisKpeGLzwTfIbayE0+mzkbGi1NqprGJyFeNNAorgI/B9NMPt412rR65UY96z/9SXB3+zerw9p3NnsQ8xNzyNm89vDi7zFLn5sE6mu6yX7FUU8Pn4CjTKmuLDMy6uelTtQxsy70UtfTe/Gg5V/eA44MMcKw1w5YPOmf/xbub4i5IZxbGPaLHvwtK8763MhvYzv5cuyeYTHi0edCi+dSX4HIsuhLGm941qs+0tTc/3YjbhFWR3QALlwa3wcWEQ/K780XmlVoufMocJ6b7iEFHVpl3AySI7u1RzCIJ7Pw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776176377; c=relaxed/relaxed; bh=otoATAnx7qhArAffWjEtTUnGtqcy79ewhelw1QrtjLQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jY55pGKILrLb1i79sqB7zxv/GrVhfd2Psm+eZAocfcMxGVRe2WDBel9IxZZ93K9VH7kuOmwBuKWTOcQxU47a32t6Cak/E2MiasQ3Dk7V/pt0jAYQKaTrubgadECEg/ZWeambsczPdmr+7YV6F4RK/eXieoolWFb/8s9Ka8c4Oz5UNFqNzbl61GwDfSryZgKH+qYsZZ+xqWGSVWTBtaRE4tpOtR9FmOaWpep2J9LYfKMVRJTBCA/6D5dyyePHcQweZg/Hpo8UsazpJOfZ0E/HsSDGlFmtn7E/BaBnI8IAblnkFaHAqARhTtX0uyf12lbt4XwcB1PXmQinGeDHIxEKfQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=nSRaf9Om; dkim-atps=neutral; spf=pass (client-ip=115.124.30.124; helo=out30-124.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=nSRaf9Om; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.124; helo=out30-124.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fw5xz3SBfz2ySS for ; Wed, 15 Apr 2026 00:19:34 +1000 (AEST) DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1776176369; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=otoATAnx7qhArAffWjEtTUnGtqcy79ewhelw1QrtjLQ=; b=nSRaf9Oma1Vo22LCTII7I5RoK9syBthhrEJXlat0N3UJB807w1lR2zraAMy76x9JGZVYMB/LqLdSrPLGXaZ4sFG9vkz1TXSCv/s0ujAuGkhPG+EuifEo7f8+8b0wJNPooaYm/esvNaVS3yNtzA5EAXUIekG0vMN15PBWwSkH6vQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0X11g4Jr_1776176366; Received: from 30.41.54.139(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X11g4Jr_1776176366 cluster:ay36) by smtp.aliyun-inc.com; Tue, 14 Apr 2026 22:19:27 +0800 Message-ID: Date: Tue, 14 Apr 2026 22:19:26 +0800 X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] erofs-utils: tar: fix out-of-bounds access when trimming pax path To: Zhan Xusheng Cc: linux-erofs@lists.ozlabs.org, Zhan Xusheng References: <20260414141313.46575-1-zhanxusheng@xiaomi.com> <20260414141313.46575-2-zhanxusheng@xiaomi.com> From: Gao Xiang In-Reply-To: <20260414141313.46575-2-zhanxusheng@xiaomi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 2026/4/14 22:13, Zhan Xusheng wrote: > When a PAX extended header contains a path consisting entirely of '/' > characters (e.g., "path=/"), the trailing-slash trimming loop in > tarerofs_parse_pax_header() decrements j to 0, then accesses > eh->path[-1] which is an out-of-bounds heap read. > > The tar header path trimming had a similar issue fixed by commit > dcd06f421003 ("erofs-utils: mkfs: tar: fix SIGSEGV on `/` entry"), > but the PAX header path trimming was not addressed. > > Add a j > 0 guard to the while condition. > > Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs") > Signed-off-by: Zhan Xusheng That was addressed by others before: I think I will add your `Signed-off-by:` into the original patch. BTW, are you using LLM to discover bugs too? Thanks, Gao Xiang > --- > lib/tar.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/tar.c b/lib/tar.c > index eca29f5..3d92f48 100644 > --- a/lib/tar.c > +++ b/lib/tar.c > @@ -509,7 +509,7 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios, > int j = p - 1 - value; > free(eh->path); > eh->path = strdup(value); > - while (eh->path[j - 1] == '/') > + while (j > 0 && eh->path[j - 1] == '/') > eh->path[--j] = '\0'; > } else if (!strncmp(kv, "linkpath=", > sizeof("linkpath=") - 1)) {