Page MenuHomeFreeBSD
Feed Advanced Search

Dec 5 2024

olce added a comment to D47616: MAC/do: Support multiple users and groups as single rule's targets.

I locally have very small changes to this revision, essentially whitespace fixes and the introduction of a new flag MDF_EXPLICIT_SUPP_MUST as an impact of the update of D47620.

Dec 5 2024, 9:04 PM
olce updated the diff for D47620: MAC/do: Interpret the new rules specification; Monitor setcred().

Rework as to check for explicitly denied or mandatory groups in mac_do_priv_grant(), for reasons explained above.

Dec 5 2024, 8:44 PM
olce added inline comments to D47618: New setcred() system call and associated MAC hooks.
Dec 5 2024, 8:40 PM
olce updated the diff for D47618: New setcred() system call and associated MAC hooks.

Fix the public setcred() prototype.

Dec 5 2024, 8:36 PM
olce updated the diff for D47618: New setcred() system call and associated MAC hooks.

Apply suggestions. Fix some whitespace issues. Remove #if __BSD_VISIBLE.

Dec 5 2024, 8:32 PM
olce added a comment to D47881: syscallsubr.h: Header inclusions: Explicit <sys/types.h>, sort.
In D47881#1091936, @imp wrote:

So if sys/_types.h won't suffice, I'd call out why in the commit message (this file makes no pretense of being namespace clean I think would be the reason.)

Dec 5 2024, 8:08 PM
olce updated the summary of D47881: syscallsubr.h: Header inclusions: Explicit <sys/types.h>, sort.
Dec 5 2024, 8:08 PM
olce added a comment to D47887: style(9): deprecate blank lines without local vars.
In D47887#1092651, @imp wrote:

Yes. A the same time, though, new members have to accept that our culture does have a large element of collective experience (...)

Dec 5 2024, 12:55 PM

Dec 4 2024

olce added a comment to D47618: New setcred() system call and associated MAC hooks.

Looks good! A few quibbles (mostly things that would make things easier for use in CheriBSD), but nothing mandatory.

Dec 4 2024, 8:54 PM
olce added a comment to D47887: style(9): deprecate blank lines without local vars.
In D47887#1092313, @imp wrote:

For what it's worth, we do discuss these things in public all the time.

Dec 4 2024, 8:32 PM
olce added a comment to D47618: New setcred() system call and associated MAC hooks.
In D47618#1091926, @imp wrote:

So about thr_new: Just create a new thr_new and rename the old one. Don't try to make it versioned. That's useless. We have lots of system call numbers and trying to 'repurpose' an old system call in an overly clever way just makes my job at implementing it for bsd-user a lot harder. And it doesn't really help. We've renamed the old system call several times, I suggest you just keep it simple like that.

Dec 4 2024, 6:04 PM
olce updated the diff for D47618: New setcred() system call and associated MAC hooks.

Remove the blank line at start of functions with no local variables added to MAC.

Dec 4 2024, 6:00 PM
olce updated the diff for D47618: New setcred() system call and associated MAC hooks.

Remove the explicit version bits in flags and the _v0 suffix for the setcred()'s structure.

Dec 4 2024, 5:50 PM
olce added inline comments to D47878: MAC: syscalls: mac_label_copyin(): 32-bit compatibility.
Dec 4 2024, 12:00 PM
olce updated the diff for D47878: MAC: syscalls: mac_label_copyin(): 32-bit compatibility.

Apply brooks@'s request and suggestion.

Dec 4 2024, 12:00 PM
olce added a comment to D47887: style(9): deprecate blank lines without local vars.

I thought we'd already went this far

Dec 4 2024, 11:18 AM
olce added a watcher for srcmgr: olce.
Dec 4 2024, 10:29 AM

Dec 3 2024

olce added a comment to D47879: cd9660: Make sure that struct ifid fits in generic filehandle structure.
In D47879#1091920, @kib wrote:

I think more relevant question there are compilers generate proper code to access unaligned ifid_ino and ifid_start on sensitive arches.

Dec 3 2024, 7:48 PM
olce added inline comments to D47618: New setcred() system call and associated MAC hooks.
Dec 3 2024, 5:42 PM
olce added a comment to D47618: New setcred() system call and associated MAC hooks.

I like the overall idea.

Dec 3 2024, 5:40 PM
olce updated the diff for D47618: New setcred() system call and associated MAC hooks.

Add missing 32-bit compatibility code.

Dec 3 2024, 5:34 PM
olce requested review of D47881: syscallsubr.h: Header inclusions: Explicit <sys/types.h>, sort.
Dec 3 2024, 4:57 PM
olce accepted D47880: cd9660: Remove some unneeded definitions.
Dec 3 2024, 3:45 PM
olce accepted D47879: cd9660: Make sure that struct ifid fits in generic filehandle structure.

I've checked that nobody takes the address of the unaligned members.

Dec 3 2024, 3:43 PM
olce added inline comments to D47878: MAC: syscalls: mac_label_copyin(): 32-bit compatibility.
Dec 3 2024, 2:59 PM
olce requested review of D47878: MAC: syscalls: mac_label_copyin(): 32-bit compatibility.
Dec 3 2024, 2:55 PM

Dec 2 2024

olce accepted D47839: shm: Handle swap pager allocation failures.
Dec 2 2024, 3:09 PM
olce added reviewers for D47771: MAC/do: Sort header inclusions: bapt, emaste.
Dec 2 2024, 2:53 PM
olce accepted D47839: shm: Handle swap pager allocation failures.

I tend to agree with kib@ for both of its inline comments. The second comment is the second alternative I listed. I'm fine either way.

Dec 2 2024, 1:38 PM
olce added reviewers for D47616: MAC/do: Support multiple users and groups as single rule's targets: emaste, lwhsu.
Dec 2 2024, 8:50 AM

Nov 29 2024

olce added reviewers for D47845: MAC/do: Apply a rule on real UID/GID instead of effective ones: emaste, bapt.
Nov 29 2024, 8:39 PM
olce added a reviewer for D47772: MAC/do: Rename private OSD slot by removing 'mac_do_' prefix: bapt.
Nov 29 2024, 8:38 PM
olce requested review of D47845: MAC/do: Apply a rule on real UID/GID instead of effective ones.
Nov 29 2024, 8:37 PM
olce planned changes to D47620: MAC/do: Interpret the new rules specification; Monitor setcred().

This revision will be reworked. The way that the mac_cred_check_setcred() hook implements active rejection (mandated by target clauses containing -gid=<gid> and/or !gid=<gid>) isn't compatible with inclusive disjunction of several rules. My initial intention in using mac_cred_check_setcred() was that mac_do(4) could restrict transitions that even other MAC modules would have authorized, but I don't think this was a wise choice, as mac_do(4) anyway applies only to a fraction of process (those spawned from /usr/bin/mdo). So, instead of fixing mac_cred_check_setcred(), I'll move the "active rejection of credentials transitions" code into mac_do_priv_grant().

Nov 29 2024, 8:36 PM
olce updated the diff for D47620: MAC/do: Interpret the new rules specification; Monitor setcred().

Fix style (v & FLAG => (v & FLAG) != 0 and similar).

Nov 29 2024, 8:26 PM
olce updated the diff for D47617: MAC/do: Output errors when parsing rules.

Rename alloc_parse_error() to make_parse_error() (as it is a constructor really, not just an allocator).

Nov 29 2024, 8:20 PM
olce added a comment to D47616: MAC/do: Support multiple users and groups as single rule's targets.

Here are some examples:

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=*,+gid=*

Gives UID 10001 the rights to become UID 10002 and become part of any group. This is basically the equivalent of today's sysctl security.mac.do.rules=uid=10001:10002. Both mdo -u 10002 and mdo -u 10002 -i will work.

sysctl security.mac.do.rules=uid=10001:uid=10002

Allow UID 10001 to switch to UID 10002, but only keeping the exact groups he's already in. So, mdo -u 10002 -i will work, but not mdo -u 10002 (unless UID 10002's groups are exactly UID 10001's groups, or that of the current process if they were modified).

sysctl security.mac.do.rules=uid=10001:uid=10002,uid=10003

Same, but also allows to switch to UID 10003 instead.

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002

Same, but the new primary groups must be set to 10002, and no supplementary groups should be set. In particular, mdo -u 10002 will work (if UID 10002's primary group specification is GID 10002, and only if /etc/group doesn't enroll 10002 into any supplementary group), whereas mdo -u 10002 -i will not (unless UID 10001 is also member of the single (primary) group 10002).

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,+gid=.

Same as the previous, but allows to retain any current supplementary groups. mdo -u 10002 -i will work, and mdo -u 10002 also (unless UID 10002 has a different primary group than 10002 or is part of supplementary groups that are not already current).

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,!gid=.

Same as the previous, but *must* retain exactly all current supplementary groups. Compared to the previous example, this will cause mdo -u 10002 to fail unless UID 10002's supplementary groups are exactly those currently in force.

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,+gid=.,-gid=10001

Same as sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,+gid=. above, but 10001 cannot be retained as a supplementary group. mdo -u 10002 -i will work but only if 10001 is not present as a supplementary group, and mdo -u 10002 will work (unless UID 10002 has a different primary group than 10002 or is part of supplementary groups that are not already current).

sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,+gid=.,!gid=10003

Same as sysctl security.mac.do.rules=uid=10001:uid=10002,gid=10002,+gid=. above, with the additional constraint that 10003 must appear in the supplementary groups. Both mdo -u 10002 -i and mdo -u 10002 will continue to work as explained for that previous case, but only if, respectively, 10003 is a supplementary group of the current process and UID 10002's is in supplementary group 10003 (according to /etc/group).

sysctl security.mac.do.rules=gid=100000:uid=0

Makes 100000 a wheel group on steroid, allowing to switch to root without password (with the current state of mdo(1); we could modify the latter to request passwords in some cases, in which case security is weakened as this check would be performed by userland and not mac_do(4), but this is probably perfectly acceptable in less strong, common threat models).


The following transitions, as they only involve GID changes, cannot currently be required through mdo(1), but I think would be valuable to support:

sysctl security.mac.do.rules=gid=10001:gid=10002

Allow users of GID 10001 to enter GID 10002 as a primary group, but only if giving up all their supplementary groups.

sysctl security.mac.do.rules=gid=10001:gid=10002,+gid=.

Same as the previous, but allows to retain any current supplementary groups.

sysctl security.mac.do.rules=gid=10001:gid=10002,!gid=.

Same as the previous, but *must* retain exactly all current supplementary groups.

Nov 29 2024, 8:15 PM
olce added a comment to D47616: MAC/do: Support multiple users and groups as single rule's targets.

I read the commit message and haven't finished the code. The GID rules seems having much more features and I would like to know more. Do you think you can share some use scenarios and how to config the rule? I believe it would also be useful to have these in mac_do(4).

Nov 29 2024, 8:14 PM
olce updated the diff for D47616: MAC/do: Support multiple users and groups as single rule's targets.

Style fixes (v & FLAG => (v & FLAG) != 0 and related), add missing
redundancy check for UIDs (no UID can appear twice or more in target clauses).

Nov 29 2024, 8:14 PM
olce added inline comments to D47839: shm: Handle swap pager allocation failures.
Nov 29 2024, 6:35 PM
olce added inline comments to D47839: shm: Handle swap pager allocation failures.
Nov 29 2024, 4:02 PM

Nov 27 2024

olce updated the diff for D47616: MAC/do: Support multiple users and groups as single rule's targets.

Move some not-directly-related change to other revisions (existing ones, and a new one, D47772).

Nov 27 2024, 2:38 PM
olce updated the diff for D47614: MAC/do: Better parsing for IDs (strtoui_strict()).

Remove a redundant check that was forgotten in the previous update.

Nov 27 2024, 2:24 PM
olce updated the diff for D47614: MAC/do: Better parsing for IDs (strtoui_strict()).

This is a followup to the change in D47613 (u_int used for IDs). Took the
occasion to provide a better implementation that supports negative number
specifications (as strtou*() standard functions do).

Nov 27 2024, 1:58 PM
olce updated the diff for D47613: MAC/do: 'struct rule': IDs and types as 'u_int', rename fields.

Use u_int instead of int, as uid_t and gid_t are in fact unsigned integers, and not signed ones as I initially assumed. (Since we are compiling with -fwrapv, this doesn't matter for correctness of execution, but is conceptually wrong.)

Nov 27 2024, 10:12 AM

Nov 26 2024

olce updated the summary of D47772: MAC/do: Rename private OSD slot by removing 'mac_do_' prefix.
Nov 26 2024, 6:38 PM
olce updated the summary of D47771: MAC/do: Sort header inclusions.
Nov 26 2024, 6:38 PM
olce requested review of D47772: MAC/do: Rename private OSD slot by removing 'mac_do_' prefix.
Nov 26 2024, 6:37 PM
olce requested review of D47771: MAC/do: Sort header inclusions.
Nov 26 2024, 6:37 PM
olce updated the summary of D47612: MAC/do: parse_rule_element(): Bug in parsing the origin ID.
Nov 26 2024, 2:30 PM
olce updated the summary of D47594: MAC/do: Rename internal mac_do_rule_find() => find_rules().
Nov 26 2024, 2:15 PM
olce updated the summary of D47593: MAC/do: Rename private struct 'mac_do_rule' => 'rules'.
Nov 26 2024, 2:14 PM
olce updated the summary of D47591: MAC/do: parse_rules(): Copy input string on its own.
Nov 26 2024, 2:12 PM

Nov 25 2024

olce added inline comments to D47610: MAC/do: jail_check()/jail_set(): Revamp.
Nov 25 2024, 9:19 AM

Nov 21 2024

olce added a comment to D46870: (draft) conf: GENERIC: Add a disclaimer on customized kernel configurations.

Ping?

Nov 21 2024, 10:02 AM

Nov 20 2024

olce updated the summary of D47622: MAC/do: toast_rules(): Minor simplification.
Nov 20 2024, 4:52 PM
olce added a comment to D47622: MAC/do: toast_rules(): Minor simplification.

Slightly more efficient at the cost of being inconsistent during the deletion; no objection from me.

Yes, but the inconsistency can only be observed by concurrent accesses which are not meant to happen, and if they still did because of improper locking, the initial version is not safe either as TAILQ_REMOVE() is not atomic.

Nov 20 2024, 4:24 PM
olce added a comment to D47624: MAC/do: Convert internal TAILQs to STAILQs.

It's worth expanding the commit message - even if there's no functional change intended we should say why we're bothering with the change. Presumably it is because we only ever iterate over these in the forward direction so we can avoid the additional overhead.

But, LGTM.

Nov 20 2024, 4:14 PM
olce updated the summary of D47624: MAC/do: Convert internal TAILQs to STAILQs.
Nov 20 2024, 4:14 PM
olce added a comment to D47622: MAC/do: toast_rules(): Minor simplification.

Slightly more efficient at the cost of being inconsistent during the deletion; no objection from me.

Nov 20 2024, 3:15 PM
olce added a comment to D47594: MAC/do: Rename internal mac_do_rule_find() => find_rules().

same about the commit message

Nov 20 2024, 3:01 PM
olce added a comment to D47593: MAC/do: Rename private struct 'mac_do_rule' => 'rules'.

the commit message, should clarify the consistency purpose imho.

Nov 20 2024, 2:54 PM
olce added inline comments to D47616: MAC/do: Support multiple users and groups as single rule's targets.
Nov 20 2024, 2:51 PM
olce added inline comments to D47616: MAC/do: Support multiple users and groups as single rule's targets.
Nov 20 2024, 1:45 PM
olce added inline comments to D47613: MAC/do: 'struct rule': IDs and types as 'u_int', rename fields.
Nov 20 2024, 1:22 PM
olce added inline comments to D47610: MAC/do: jail_check()/jail_set(): Revamp.
Nov 20 2024, 1:06 PM
olce added inline comments to D47608: MAC/do: Sysctl knobs/jail parameters under MAC's common nodes.
Nov 20 2024, 12:38 PM
olce added inline comments to D47599: MAC/do: Remove PR_METHOD_REMOVE method.
Nov 20 2024, 12:22 PM
olce added a comment to D47598: MAC/do: Allocate/deallocate rules as a whole.

I can see now the comment from D47598 is now useless :D

Nov 20 2024, 12:17 PM
olce added inline comments to D47597: MAC/do: Factor out setting/destroying rule structures.
Nov 20 2024, 12:16 PM
olce added a comment to D47595: MAC/do: Use prison_lock()/prison_unlock().

No concern, we should just be (eventually) consistent and either prefer and use these here and in general, or if we don't prefer them we should abandon this review.

I have the same thought. Although these two functions are trivial, I like its encapsulation and think it should be used in general when possible. It seems we have many mtx_{,un}lock wraps in the code, although mostly in the form of macro, and seems limited to the scope of a single driver.

Nov 20 2024, 12:11 PM

Nov 19 2024

olce updated the summary of D47592: MAC/do: Rename rule_is_valid() => rule_applies().
Nov 19 2024, 8:06 AM
olce added a comment to D47592: MAC/do: Rename rule_is_valid() => rule_applies().

Commit message should explain why something was done not (just) what; in this case it the reason is fairly clear from context but still needs the reader to look at the change and understand.

Nov 19 2024, 8:04 AM

Nov 18 2024

olce added a comment to D47591: MAC/do: parse_rules(): Copy input string on its own.

Note 0 and \0. I believe the later is better.

Nov 18 2024, 8:01 PM
olce updated subscribers of D47624: MAC/do: Convert internal TAILQs to STAILQs.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47622: MAC/do: toast_rules(): Minor simplification.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47623: MAC/do: parse_rules(): Tolerate blanks around tokens.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47621: mdo(1): Use setcred() to change credentials.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47620: MAC/do: Interpret the new rules specification; Monitor setcred().
Nov 18 2024, 8:51 AM
olce updated subscribers of D47619: MAC/do: Introduce rules reference counting.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47618: New setcred() system call and associated MAC hooks.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47617: MAC/do: Output errors when parsing rules.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47616: MAC/do: Support multiple users and groups as single rule's targets.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47615: MAC/do: Ease input/output of ID types.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47614: MAC/do: Better parsing for IDs (strtoui_strict()).
Nov 18 2024, 8:51 AM
olce updated subscribers of D47613: MAC/do: 'struct rule': IDs and types as 'u_int', rename fields.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47612: MAC/do: parse_rule_element(): Bug in parsing the origin ID.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47611: MAC/do: parse_rule_element(): Style, more clarity.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47610: MAC/do: jail_check()/jail_set(): Revamp.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47609: MAC/do: Fix jail_get() (PR_METHOD_GET).
Nov 18 2024, 8:51 AM
olce updated subscribers of D47608: MAC/do: Sysctl knobs/jail parameters under MAC's common nodes.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47607: MAC/do: Prefix internal functions used as hooks/callbacks.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47606: MAC/do: Re-order jail methods more logically, rename.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47605: MAC/do: parse_rule_element(): Fix a panic, harden, simplify.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47604: MAC/do: Move destroy() to a better place.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47603: MAC/do: Remove the 'prison0' special cases in the common paths.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47602: MAC/do: Enable changing 'security.mac.do.rules' from a jail.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47601: MAC/do: sysctl_rules(): Set the requesting's thread's jail's rules.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47600: MAC/do: sysctl_rules(): Always copy the rules specification string.
Nov 18 2024, 8:51 AM
olce updated subscribers of D47599: MAC/do: Remove PR_METHOD_REMOVE method.
Nov 18 2024, 8:51 AM