CSE Roadmap

Common tier · about 3 hours · 7 parts

Part 6 of 7 · 4 min read

The checklist

The checklist

Think of a doctor with a fixed list of questions for a patient with a fever: the throat, the chest, the ears, the recent travel. The list is short, and it is worth following in order because each answer removes some causes. The analogy stops in one place: a patient can have two illnesses at once, and a path can be blocked by two rules at once, so a fix of one may show the other.

In plain words: When the path and mode check passes and the access still fails, the next causes come from the other parts of this level. This checklist runs from the cheapest test to the most unusual.

Step Command or field Cause it finds
1 Read the error: strace -e trace=openat Which family of cause (section 1)
2 namei -l PATH A directory without x, or a wrong owner or mode
3 /proc/PID/status: Uid, Gid, Groups The process is not the user or group assumed
4 getfacl PATH An access list that denies the user (a rule beyond page 2's mode bits)
5 CapEff, NoNewPrivs, Seccomp A missing capability, or a filter (EPERM)
6 /proc/PID/root, /proc/PID/ns/mnt The path means another file, or none (ENOENT), in the process's view
7 mount, findmnt A read-only mount, or a noexec or nosuid option
8 ulimit -n, /proc/PID/limits A resource limit (EMFILE)
9 /sys/kernel/security/lsm, audit log SELinux or AppArmor denied it (mandatory access control, page 6)

A worked example. The report job still fails after the fix in section 4, but only when started by systemd, not from the shell. Step 3 shows Uid: 998, not 65534, so the unit file names a service user that was never given access. The fix is in the unit's User= line or in the group of private, not in the modes. Step 3 found it before any other step needed to run.

The key lines. The checklist saves time because most cases end at step 2 or 3, and the rare ones (steps 6, 7 and 9) are easy to forget. Test in the same environment as the service, and keep a note of which step found the cause for the next report.

Access path check

An access path check is the ordered set of tests that the kernel applies to a file access: the lookup of each name on the path, the permission bits and lists on the file, the capabilities of the process, the file view of its mount namespace, and any security policy. A refusal comes from the first test that fails.

Example: a file read can fail because of the second directory on its path, long before the file's own mode is looked at.

Interview angle

A common question is "A service gets Permission denied on a file that looks readable. How do you debug it?" A good answer reads the error code, runs namei -l on the path, checks the process's real user, groups and capabilities in /proc, then considers filters, mount options, the file view and SELinux, and ends with the smallest fix and a test that confirms it.

Check yourself: 1. Which two steps usually find the cause? 2. What does a Uid that differs from the shell's tell? 3. Why test in the same environment as the service?

Words you will meet

Word Meaning
errno The number that names why a system call failed.
Search permission The x bit on a directory, needed to look up names in it.
Effective user ID The ID used in permission checks.
Smallest sufficient change The narrowest fix that makes the access work.
Access path check The ordered tests applied to one file access.

Quick notes

  • Read the error first: EACCES is a mode, list or policy refusal; EPERM a capability or a filter; ENOENT a missing name in this view; EMFILE a limit.
  • A world-readable file is unreachable if one directory on its path lacks x for the process's class.
  • namei -l shows every component of a path. /proc/PID/status shows the process's real identity.
  • Compare the failing process with the shell used for tests. They can differ.
  • Fix with the narrowest change. Then test a pass and a still-fail.