On 2019-11-29 Gilbert E. Detillieux wrote:
The fact that there's different behaviour between the two openat calls, and the fact that you're getting EACCES when uid==0 (which should almost never happen, especially on file access), and the fact that this is a new error, suggests a kernel bug to me.
Yes, I noticed the O_CREAT difference in the bash strace too. Very interesting.
I should have mentioned, selinux is in disabled mode on this box (and confirmed with selinuxenabled command) so that's eliminated.
I agree that EACCES should not be a thing when running as root. In fact, I'm a firm believer in "root being able to do everything" on Linux and always hate it when they move more towards Windows "Administrator can't always do everything" model. (Like they did with some of the new capabilities a while ago.) Adam vehemently argues the opposite :-)
I'll file a kernel bug and hit up the mailing list now that you've provided a second sober opinion confirming my suspicions.
Thanks!!