Skip to content

AIX doesn't provide fstatat64() - #1795

Open
mehendarkarprajwal wants to merge 1 commit into
Cisco-Talos:mainfrom
mehendarkarprajwal:main
Open

AIX doesn't provide fstatat64()#1795
mehendarkarprajwal wants to merge 1 commit into
Cisco-Talos:mainfrom
mehendarkarprajwal:main

Conversation

@mehendarkarprajwal

@mehendarkarprajwal mehendarkarprajwal commented Aug 11, 2026

Copy link
Copy Markdown

AIX exposes stat64at() as the 64-bit directory-relative stat call
instead of fstatat64(). Add a defined(_AIX) guard ahead of the
existing HAVE_STAT64 branch so that stat64at() is called on AIX.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcb802013c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread common/actions.c Outdated
* that slip through capture remain in the private directory until
* cleanup — they are never lost or permanently removed.
*/
logg(LOGG_DEBUG, "traverse_unlink: No-replace rename unavailable on AIX; proceeding with linkat()-based restore for regular file '%s'.\n", target);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep refusing captures without atomic directory restore

On AIX when quarantining/removing a validated regular file from a directory that another process can write to, this branch still leaves a race after the current_stat check and before the plain renameat(): the basename can be swapped to a directory, renameat() moves that directory into the private dir, and because supports_noreplace_restore is false, action_restore_captured_unlink_target() cannot restore it. The cleanup path only attempts to rmdir the private dir, so it fails once that captured directory is inside, leaving the replacement hidden and reintroducing the guarantee the non-AIX path preserves by bailing out.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _AIX bypass has been removed. Only the fstatat/stat64at fix remains in the PR.

@mehendarkarprajwal

Copy link
Copy Markdown
Author

Can someone please take a look at this.

@val-ms val-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also verify that testing passes for AIX on your side since we don't have a system to test with.

Comment thread common/actions.c
Comment on lines +447 to 453
/* AIX: fstatat64 does not exist. Use stat64at which takes struct stat64*
* and is the 64-bit equivalent of fstatat. */
rc = stat64at(dirfd, path, st, flags);
#elif defined(HAVE_STAT64) && STAT64_OK
rc = fstatat64(dirfd, path, st, flags);
#else
rc = fstatat(dirfd, path, st, flags);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the stat64 guard is still needed.
Note: I also removed the comment in my proposed change, as it seems obvious.

Suggested change
/* AIX: fstatat64 does not exist. Use stat64at which takes struct stat64*
* and is the 64-bit equivalent of fstatat. */
rc = stat64at(dirfd, path, st, flags);
#elif defined(HAVE_STAT64) && STAT64_OK
rc = fstatat64(dirfd, path, st, flags);
#else
rc = fstatat(dirfd, path, st, flags);
#if defined(HAVE_STAT64) && STAT64_OK && defined(_AIX)
rc = stat64at(dirfd, path, st, flags);
#elif defined(HAVE_STAT64) && STAT64_OK
rc = fstatat64(dirfd, path, st, flags);
#else
rc = fstatat(dirfd, path, st, flags);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants