This is an archive of the discontinued LLVM Phabricator instance.

Report EISDIR when opening a directory on AIX
Needs ReviewPublic

Authored by azhan92 on Aug 1 2023, 7:23 AM.

Details

Reviewers
jhenderson
Summary

Created by mistake, please refer here: https://reviews.llvm.org/D151567

Diff Detail

Event Timeline

azhan92 created this revision.Aug 1 2023, 7:23 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: hiraditya. · View Herald Transcript
azhan92 requested review of this revision.Aug 1 2023, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2023, 7:23 AM
aaron.ballman requested changes to this revision.Aug 1 2023, 7:49 AM
aaron.ballman added a subscriber: aaron.ballman.

Please add comments to the patch description explaining what's changing and why (this helps reviewers as well as during code archeology after the changes land).

llvm/lib/Support/Unix/Path.inc
17
1017–1024

This introduces a TOCTOU issue with the code -- there's now a window where stat will return the status of the file but that status can change before the call to open.

This revision now requires changes to proceed.Aug 1 2023, 7:49 AM
azhan92 changed the visibility from "Public (No Login Required)" to "azhan92 (Alison Zhang)".
This revision now requires review to proceed.Aug 1 2023, 7:55 AM
azhan92 retitled this revision from Check if directory before opening file to Testing revisions .Aug 1 2023, 8:02 AM
azhan92 updated this revision to Diff 546075.Aug 1 2023, 8:14 AM
azhan92 retitled this revision from Testing revisions to Testing revisions.

Check if file is directory before opening for read.

azhan92 retitled this revision from Testing revisions to Test.Aug 3 2023, 7:31 AM
azhan92 changed the visibility from "azhan92 (Alison Zhang)" to "Public (No Login Required)".
azhan92 removed projects: Restricted Project, Restricted Project.
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
MaskRay added inline comments.Aug 3 2023, 7:51 AM
llvm/lib/Support/Unix/Path.inc
1017–1024

I think non-AIX non-MVS systems don't want to introduce this behavior (TOCTOU).

azhan92 edited the summary of this revision. (Show Details)Aug 3 2023, 7:55 AM
azhan92 retitled this revision from Test to Report EISDIR when opening a directory on AIX.Aug 3 2023, 7:58 AM
hubert.reinterpretcast added inline comments.
llvm/lib/Support/Unix/Path.inc
1017–1024

Presumably the open call can be made first and fstat can then be used.