Page MenuHomeFreeBSD

Add O_RBENEATH and AT_RBENEATH to mimic Linux' RESOLVE_BENEATH
Needs ReviewPublic

Authored by kib on Wed, Jul 29, 11:31 PM.

Details

Reviewers
emaste
markj
Group Reviewers
capsicum
Summary

It is like O_BENEATH, but disables to walk out of the subtree rooted in the starting directory. O_BENEATH does not care if path walks out if it returned.

PR: 248335

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 32753

Event Timeline

kib created this revision.Wed, Jul 29, 11:31 PM
kib requested review of this revision.Wed, Jul 29, 11:31 PM
kib updated this revision to Diff 75213.Fri, Jul 31, 2:19 PM
kib edited the summary of this revision. (Show Details)

Fix definition of AT_RBENEATH.

This patch survived simple testing.

markj added a comment.Tue, Aug 4, 2:44 PM

I like the at2cnpf() function, I guess it can be committed separately.

So we permit the combination of O_BENEATH and O_RBENEATH, and it is the same as only O_RBENEATH?

sys/kern/vfs_lookup.c
1378–1380

I believe style prefers uint64_t to u_int64_t.

sys/kern/vfs_syscalls.c
117

uint64_t

118

at2cnpflags() might be more clear to a casual reader.

sys/sys/namei.h
137

Why does the mask have to be split?

kib marked 4 inline comments as done.Tue, Aug 4, 4:27 PM

So we permit the combination of O_BENEATH and O_RBENEATH, and it is the same as only O_RBENEATH?

No, look at the chunk in vfs_lookup.c.

sys/kern/vfs_lookup.c
420

This check disallows BENEATH | RBENEATH, both for O_ and AT cases.

sys/kern/vfs_syscalls.c
117

I kept the type of ck_flags. I think this should be same even syntaxically.

OTOH, I can change all of them.

sys/sys/namei.h
137

There is no more bits in the MODMASK. Layout it: 2 bits for op, then 7 bits for modmask, then 22 bits parameters descriptors (see below).

I do not want to break this KBI (again).

kib updated this revision to Diff 75380.Tue, Aug 4, 5:35 PM
kib marked 2 inline comments as done.

at2cnpflags, use uint64_t.

The patch is not against HEAD, I will rebase later.