Skip to content

Commit

Permalink
objtool: Use O_CREAT with explicit mode mask
Browse files Browse the repository at this point in the history
Recent Ubuntu enforces 3-argument open() with O_CREAT:

      CC      /home/mingo/tip/tools/objtool/builtin-check.o
    In file included from /usr/include/fcntl.h:341,
                     from builtin-check.c:9:
    In function ‘open’,
        inlined from ‘copy_file’ at builtin-check.c:201:11:
    /usr/include/x86_64-linux-gnu/bits/fcntl2.h:52:11: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
       52 |           __open_missing_mode ();
          |           ^~~~~~~~~~~~~~~~~~~~~~

Use 0400 as the most restrictive mode for the new file.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
  • Loading branch information
Ingo Molnar committed Mar 17, 2025
1 parent 3679906 commit 7307046
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/objtool/builtin-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static int copy_file(const char *src, const char *dst)
return 1;
}

dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC);
dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, 0400);
if (dst_fd == -1) {
ERROR("can't open '%s' for writing", dst);
return 1;
Expand Down

0 comments on commit 7307046

Please sign in to comment.