The original post: /r/linux by /u/micahwelf on 2025-01-21 10:31:43.

Original Title: Hard, Uncommon Question: Can a file name be created with overlong characters and contain a solidus “/” or other forbidden character? Eventually, I will post results if I can test this soon enough. Related to security/functionality testing.


I’m programming with various text encodings and realized how one issues has been left unexplained is most of my historical reading. Web protocols and certain high security standards forbid invalid UTF-8, but I have not read of such limits in direct system calls to Linux or in their filesystems. Even though it was forbidden in MS Windows, years ago it was possible to use a solidus in a file-name because it only accepted the reverse-solidus. Now MS Windows is more Unix/keyboard friendly and more strictly limits the solidus to an alternate form of reverse-solidus. On Linux, however, filenames are generally stored in UTF8, which has many possible tweaks, including overlong encoding. Does the Linux kernel (or supported filesystems) control encoding in a way that allows for expoiting overlong character encoding?

I think it would be amusing and potentially useful for security/testing/hacking purposes to use this for filenames if it is allowed. It is an old issue that most programs making file related calls won’t run into, but if a filename could contain control characters or a solidus… what could happen? I’m not willing to test this on my main system and don’t have time yet to set up a dedicated system for testing this. If I don’t get an answer, I will, of course eventually test this, but I assume other Linux experts have thought of this and might know the answer. Eventually, if I test it out soon-ish, I will post the results here. I’m guessing I will have to test with several filesystems to determine if any discovered limitations exist in the kernel or the filesystem support specifically - if the filesystem crashes, but the operations are allowed, then it would be an interesting discovery at the least for how reliable certain filesystems are.