[PATCH] D96308: [llvm-objcopy] Avoid rename if input filename = output filename

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 14:01:43 PST 2021


jcai19 added a comment.

Thanks for this patch.  You mentioned the following issue in one of your comments on https://reviews.llvm.org/D93881. IIUC, this patch seems to not have taken care of this issue.

< I have mentioned that the GNU objcopy/strip smart_rename still has vulnerability and the owner preservation does not work for non-root (CAP_CHOWN) users.

< chmod o+wx .
< sudo chown mail a.o
< sudo -u bin strip a.o  # owner becomes bin. llvm-strip has the same behavior.



================
Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:334
+      // overwrite cannot be used.
+      MemBuffer MB(Config.OutputFilename);
+      if (Error E = executeObjcopyOnBinary(Config,
----------------
Are there any particular reasons we need to use memory buffer instead of creating a temporary file? Will this be a problem for large binary files?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96308/new/

https://reviews.llvm.org/D96308



More information about the llvm-commits mailing list