πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1910

[PATCH 0/2] tree-walk: use size_t for tree sizes

#1910
From: Elia Pinto
Date: Fri, 30 Oct 2026 10:58
42 lines
12001 bytes
struct tree_desc keeps the size of the tree buffer in an "unsigned
int", so a tree object of 4GiB or more is truncated on all platforms,
and struct tree adds another truncation on Windows, where "long" is
32 bits. The walk then sees only a prefix of the tree: it never reads
past the buffer, but when the cut falls between two entries the rest
of the tree silently disappears, both for commands like "git ls-tree"
and for the checks in fsck_tree().

Trees that large are not something one creates by accident, but they
can be crafted, and fsck is what is supposed to look at every entry
of them.

 1/2 moves struct tree_desc and the functions that set it up to
     size_t; this is the part that matters on all platforms.
 2/2 does the same for struct tree and parse_tree_buffer().

There is no test, as it would need a tree larger than 4GiB in memory;
1/2 describes how I checked the effect with a simulated 16-bit size.

This comes from the same search for truncated sizes as:

  https://lore.kernel.org/git/cover.1793352943.git.gitter.spiros@gmail.com/
  https://lore.kernel.org/git/cover.1793355390.git.gitter.spiros@gmail.com/

It is independent of both and merges cleanly with them. The series is
based on master (b9e5cff180).

Elia Pinto (2):
  tree-walk: use size_t for the size of tree buffers
  tree: use size_t for the size of parsed trees

 tree-walk.c | 14 +++++++-------
 tree-walk.h |  6 +++---
 tree.c      |  2 +-
 tree.h      |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)


base-commit: b9e5cff1803ab24582201ef059516eb16014b9d9
-- 
2.53.0
Technical Details
Message-ID: <cover.1793357680.git.gitter.spiros@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73895-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73895-linux-kernel-git=dewy.ru
From: gitter.spiros@gmail.com (Elia Pinto)
Newsgroups: linux.kernel.git
Subject: [PATCH 0/2] tree-walk: use size_t for tree sizes
Date: Fri, 30 Oct 2026 11:58:21 +0100
Organization: Usenet Network
Message-ID: <cover.1793357680.git.gitter.spiros@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2217730"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CpDTYVH45Q2IgmuJPHYXbfETQH4= sha256:r3FcMH5w+QOyDa5hjLy4quJvbd4IoskieNslhCx5lYI=
	sha1:FsF0x1UsqE5XKoLni5d7UuTdKr4= sha256:ZGJ1nMdcZTXOV/+Rs7IdVWytZSib+xWBJz0/TgoB4f4=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 9A85E125C92; Fri, 30 Oct 2026 14:06:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8uEV7QiYR3zY;
	Fri, 30 Oct 2026 14:06:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-73895-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id D07EA125C8E; Fri, 30 Oct 2026 14:06:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 943B8608DD3; Fri, 30 Oct 2026 11:00:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793357910;
	b=VmgTMVyNsySY+ggA4FADonmPKw49uyQ2MQ7gYcJzy4q9gDBCYX0PjU3EqPRPI3/gbqJw
	 3sfdlp9/gMTkqnKuDUM0e2zjmbHcKUo0rrUgMTdrfX+2bPKY44m9KvOk2ZKueBlrUUYhm
	 7SV/W2QG3j0cK2gBCjC8qUZFzCU+Ex/HFQV+nP3ZiLpDi/+0fjPldBonpoq8959N+oYz6
	 AnYv1nADsWDGMqkUq75h7DdwPnfymAIF4DoT47cUTlt44n9AFu9wcjVUkvExoKc4EgJoC
	 aTQe4qRm2pOCnIqzQEB1rn5XYOYVhJcODPUSQ3HtTh2ZBMQJI6fv2y00RKT6D/2xDgw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793357910;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=yL/5fW2Db3fIuMACRqg1UmbT1Nel4XMx5gC9KO6biTk=;
	b=QXsKz3xRai6tKDU+sTO8en9ZLLCBdXGp6clYv0M/WA2P9dEP8G9mdlCjf6CFVLlj/Jt3
	 P3Mq6FHMcpyywXAQhdOH4ATGtU9QkoVUluR/7wnqbZ9VBKDf6P/9k+WMsiNLekWcBsH9b
	 /LY3YgdsKoQ8Jfp1Io2Ki4rx2qJlbStF/EqPAZdMVIZjj9kdI6jmVUE03gwxhbxXWvQhg
	 s5D6JpX/dArVU3gQrdurPZt/db+YHL1TNH/x59kWupIg5M7pcR8ezNcVvDVtoj59MAaTu
	 F/A/FQ+dO+nnS+kr/K7/7YbiQjDeezL+MxOX2MDT2xlf9d/gLThoGUzPwxsD4x6idQw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zdkz7imo;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EBA3606B979;
	Fri, 30 Oct 2026 10:58:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zdkz7imo
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793357909;
	b=pE1omNN9zR59HmF14IiVsRUdblQ7nYjJLpoaOnNnKpz+meLApCBNprf5rI8a5L/Pl4o/
	 JRXgcfjuKzDqod8pAShp80sA4dHBlvb/76ZcO6pAmxdYf6PkKim8gVqLzMElL5iyUg7Pt
	 5qHOlJBdjJrQu1+j37KpkPRUVqpPr+zTnyfwUjC+ICyL4VSxzMqOsIC+mPu6Qcle7FOsf
	 7N5xIe+PXlqcKlU/DsJHrUJLP7kC/zytd+Rj/UnurHPKBsGCf1HqP2k5kc70XFKhOSCTy
	 +SQNQqTFi/PaFrH1dqyvD7siAkWXmK1FuMm5c7bXa4w171KzizSHHhJm+ilR0/Pm9Lg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793357909;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=yL/5fW2Db3fIuMACRqg1UmbT1Nel4XMx5gC9KO6biTk=;
	b=SmvVFCBH+IeCXXI8sBhRtToDArv6U2VEt934ag/MpoCdcsfHT5niRw/ZS1S2PdUJvzv3
	 5+enbXO0jZsj9Dx+sU5LbouEvnUxwMGQGHd7pXpVx9FfC1XtkLGgywO1HYPBZsNiAZJjh
	 T72us5Ju9ZDsb4a4p6KpzMTAmlfDCASjxiIQWNt60Y5uVlf/tUgi2/m2IRN2IW2eA3TPf
	 6CWs85Z3BXhBT8c0TJVdmUCZ5Vx+JjDXdVqGLSR8BXHgT/We8UTgolxpDsiwhBYQOG3Fz
	 6ryBSwbd2FHg/f16W+CVm+9gCZRDzCI+Q44aTCsPHDmvN7xO1JbnroUrOHpIsa0BFPw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Zdkz7imo;
	arc=none smtp.remote-ip=209.85.128.50
X-Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59607606A31C
	for <git@vger.kernel.org>; Fri, 30 Oct 2026 10:58:29 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 59607606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4a5087a5348so3923415e9.0
        for <git@vger.kernel.org>; Fri, 30 Oct 2026 03:58:29 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793357908; x=1793962708; 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:content-type;
        bh=yL/5fW2Db3fIuMACRqg1UmbT1Nel4XMx5gC9KO6biTk=;
        b=Zdkz7imovt/dIVVSsiaP68XuSfKO+gCUuKIMOknqX3BEGLN934OTDIiLJsx35qRyVO
         92jy1eOlqzVl/VYPHcr3wgPl5viLMoMHClqgSRy1iumXCn6bg1EvqIxgjIfvPjyHfdRl
         bcrLY+Y+JqOcHOwjCL6YkzUWhGJQxFhW7/6OLq5AI1eQoP8yDWEav/sWTLhnWPwS7fSp
         F3KvPbZkKPapVT+5cr6r6qEJ4N1rnywXJqbHOUeONSDcZW3XwOZDQknhk08KnD3GYZNw
         8Yc8eIxfK6EPauGmVsoBLG/oyheHdjfrkm8T6/8AQd05Hj3B10M86laTe2FtGXCiEbxG
         eh7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793357908; x=1793962708;
        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:content-type;
        bh=yL/5fW2Db3fIuMACRqg1UmbT1Nel4XMx5gC9KO6biTk=;
        b=iGLuU5I5IuITXnDVGKU3S5CPxynmfLl6uAQwlLiE31OnXZSMHkVSBc3NrYf5T3rk0H
         3Zng0VrtSbjnwzfarUCGVlUBnHxxOxcalOld/P5caq+SczWgvL0le7dkCla5hAu384/z
         N1kyunAb7X7Cb8F+bkJ6dfDR4C2Mz6e+qiBYccMrmblNFwHMVNYOPeGRI0/Xz15sk59Q
         SZcx72yKWQm0//qkmk0W3cMN772+TBf+JwwMBSRxwYrGx93g6xLuRGXNUsozL3Aio5oT
         fLNu/BBrTyQgYik3Ulo6wZ28YzeNOL0+Ckx7I/qfhClQdev6LgCzzQUWOKr45LM0b7SY
         OWpA==
X-Gm-Message-State: AFq9FYIw9ePXELiDT2hBFZn6tPucyW9lo8zeqY4PCFg6cV8WAxlI4Fvv
	6h7y4A8wmq3fh2cfFW7TCBy0J/gRD4wLLBBQdzU0XANPOJ+J0D39/Vr6+AMAPg==
X-Gm-Gg: AYBFou2dmKsGo9B2UJuxTB4cUzxxhgAOxrl9RnCTcE309r/zfA11zlJE3bEaRvB/CMr
	0DPl+pZGXxPMdKv3PGMrmjbNwdYrHYuasFuvBWAnNVTHi5ResZEch5WNjHvaci1r/J/y7HREmqk
	7wIzEnKYMmn6qlFC1nkxzh1rOkf1dqN0N6E+bvxzaoJBc2h/XTQq5jzXDUi8L65bfl/TPXD4+Kz
	EfXxcwOKdkxqKUesI6VfB6VHl1XW5ku2AeJslY32zkYqrtufsltmFpjLqiWcYGBSRrDuX5MoYWY
	RbVn0ZVzU+dCvBwUvRH1JmhPMB0qoa+FZgpSX9SW5PlaCJLjPDEEDBL2djivCfq4216AVRXjehq
	RgXUK1lfJX5ENVVfT7YG5kE/roidDH5Cf2mzdYiUxX6UJqYPwAHcZVjjR2lUNGto25BqCHUORzN
	NmIrS5qGlW016XtDdcvYIvZNXvnEzVuHpeYWbuqlTgqz4ipTECabkHR9T1mCYKTBVFRxqR/C0v9
	4Vpwy0Bo0k1bkPcuiTWesC97FDJM5DLjz4y+0QmsWPTTbcCgjQsk7GHbLDd5pY3Lyrz1SqqTgaL
	AYA+2G4+8Z+40yfkq6I5gtkAnfqzyEqVm2rbYBBFPw9B1QZaVJo=
X-Received: by 2002:a05:600c:19c8:b0:4a3:59c9:a743 with SMTP id 5b1f17b1804b1-4ac1913ef8fmr39982865e9.27.1793357907622;
        Fri, 30 Oct 2026 03:58:27 -0700 (PDT)
X-Received: from ubuntu26lts1.example.com ([205.147.30.18])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b727c6sm2677980f8f.16.2026.10.30.03.58.26
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 30 Oct 2026 03:58:27 -0700 (PDT)
X-Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elia Pinto <gitter.spiros@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jeff King <peff@peff.net>,
	RenΓ© Scharfe <l.s.r@web.de>,
	"Eric W. Biederman" <ebiederm@xmission.com>
X-Mailer: git-send-email 2.53.0
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list