Skip to content

Commit 4c494bd

Browse files
author
Miklos Szeredi
committed
ovl: document permission model
Add missing piece of documentation regarding how permissions are checked in overlayfs. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 62c832e commit 4c494bd

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Documentation/filesystems/overlayfs.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,50 @@ overlay filesystem (though an operation on the name of the file such as
248248
rename or unlink will of course be noticed and handled).
249249

250250

251+
Permission model
252+
----------------
253+
254+
Permission checking in the overlay filesystem follows these principles:
255+
256+
1) permission check SHOULD return the same result before and after copy up
257+
258+
2) task creating the overlay mount MUST NOT gain additional privileges
259+
260+
3) non-mounting task MAY gain additional privileges through the overlay,
261+
compared to direct access on underlying lower or upper filesystems
262+
263+
This is achieved by performing two permission checks on each access
264+
265+
a) check if current task is allowed access based on local DAC (owner,
266+
group, mode and posix acl), as well as MAC checks
267+
268+
b) check if mounting task would be allowed real operation on lower or
269+
upper layer based on underlying filesystem permissions, again including
270+
MAC checks
271+
272+
Check (a) ensures consistency (1) since owner, group, mode and posix acls
273+
are copied up. On the other hand it can result in server enforced
274+
permissions (used by NFS, for example) being ignored (3).
275+
276+
Check (b) ensures that no task gains permissions to underlying layers that
277+
the mounting task does not have (2). This also means that it is possible
278+
to create setups where the consistency rule (1) does not hold; normally,
279+
however, the mounting task will have sufficient privileges to perform all
280+
operations.
281+
282+
Another way to demonstrate this model is drawing parallels between
283+
284+
mount -t overlay overlay -olowerdir=/lower,upperdir=/upper,... /merged
285+
286+
and
287+
288+
cp -a /lower /upper
289+
mount --bind /upper /merged
290+
291+
The resulting access permissions should be the same. The difference is in
292+
the time of copy (on-demand vs. up-front).
293+
294+
251295
Multiple lower layers
252296
---------------------
253297

0 commit comments

Comments
 (0)