Skip to content

Some object db protection when add_submodule_odb is used

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest8 patches 5 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8sha1_file: allow to select pack origin when looking up an objectcache.h fast-import.c pack-check.c +2 more+141 -611 reply
2/8sha1_file: keep track of alternate source of objectsbuiltin/index-pack.c cache.h fast-import.c +1 more+13 -90 replies
3/8sha1_file: mark alt object database from add_submodule_odb()cache.h environment.c sha1_file.c +1 more+34 -111 reply
4/8sha1_file: new object source for submodule's alt object databasecache.h git.c sha1_file.c +1 more+28 -101 reply
5/8commit.c: refuse to write commits referring to external objectscache.h commit.c sha1_file.c+17 -00 replies
6/8cache-tree.c: refuse to write trees referring to external objectscache-tree.c+2 -10 replies
7/8mktag: refuse to write tags referring to external objectsbuiltin/mktag.c+4 -10 replies
8/8sha1_file: do write objects even if found in ODB_EXTALT databasesha1_file.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] Some object db protection when add_submodule_odb is used

The idea behind this series is, after add_submodule_odb, odb may have new temporary objects that only appear after the call. These temporary objects may lead to repo corruption (e.g. some new objects are created and point to these temporary objects). This series attempts to catch those cases. It would make it safer to dig deeper into submodule's odb, e.g. to implement unified git-diff.

Previous approach [1] is record the odb source, then check if the source is from submodule's odb. But that means we rely on the lookup order in sha1_file.c. This approach instead allows the caller to select what odb sources it wants to look up from.

The checks are also less drastic than before. Checks are now done at higher level, e.g. commit_tree(), instead of at write_sha1_file, because we do allow to write objects that point to nowhere.

Another new thing from previous round is I completely forbid the use of add_submodule_odb in security sensitive commands like index-pack or rev-list. We could loosen up later if we need to.

For fun, I set object_database_contaminated to 1 by default and ran the test suite. It passed :)

[1] http://thread.gmane.org/gmane.comp.version-control.git/214412/focus=214417

Nguyễn Thái Ngọc Duy (8):
sha1_file: allow to select pack origin when looking up an object
sha1_file: keep track of alternate source of objects
sha1_file: mark alt object database from add_submodule_odb()
sha1_file: new object source for submodule's alt object database commit.c: refuse to write commits referring to external objects cache-tree.c: refuse to write trees referring to external objects
mktag: refuse to write tags referring to external objects
sha1_file: do write objects even if found in ODB_EXTALT database

 builtin/index-pack.c |   2 +-
 builtin/mktag.c      |   5 +-
 cache-tree.c         |   3 +-
 cache.h              |  38 +++++++--
 commit.c             |   9 ++
 environment.c        |   2 +
 fast-import.c        |   4 +-
 git.c                |  10 ++-
 pack-check.c         |   2 +-
 sha1_file.c          | 236 ++++++++++++++++++++++++++++++++++++---------------
 streaming.c          |   4 +-
 submodule.c          |   5 +-
 12 files changed, 233 insertions(+), 87 deletions(-)
Signature · 1 line
1.8.2.83.gc99314b