On Fri, 2022-11-18 at 10:14 +0100, Roberto Sassu wrote: > >> +static int security_check_compact_xattrs(struct xattr *xattrs, > >> + int num_xattrs, int *checked_xattrs) > > > > Perhaps the variable naming is off, making it difficult to read. So > > although this is a static function, which normally doesn't require a > > comment, it's definitely needs one. > > Ok, will improve it. > > >> +{ > >> + int i; > >> + > >> + for (i = *checked_xattrs; i < num_xattrs; i++) { > > > > If the number of "checked" xattrs was kept up to date, removing the > > empty xattr gaps wouldn't require a loop. Is the purpose of this loop > > to support multiple per LSM xattrs? > > An LSM might reserve one or more xattrs, but not set it/them (for > example because it is not initialized). In this case, removing the gaps > is needed for all subsequent LSMs. Including this sort of info in the function description or as a comment in the code would definitely simplify review. security_check_compact_xattrs() is called in the loop after getting each LSM's xattr(s). Only the current LSMs xattrs need to be compressed, yet the loop goes to the maximum number of xattrs each time. Just wondering if there is a way of improving it. -- thanks, Mimi