mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
One cleanup patch from Vlastimil Babka.
Vlastimil Babka (1): tomoyo: replace tomoyo_round2() with kmalloc_size_roundup() security/tomoyo/audit.c | 6 +++--- security/tomoyo/common.c | 2 +- security/tomoyo/common.h | 44 -------------------------------------------- 3 files changed, 4 insertions(+), 48 deletions(-) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJkRlGdAAoJEEJfEo0MZPUqwsoP/24HXdPf4TGUSPAYMjzUaaKo 49KW7AlXlXQfiPEm2kjIsQbWHRi0cXEw7qFsw2B+V/gEBx22IVCDu6l+7im3TsZS CzBK3Crf8F/6FfUcSeL8WCR815iJvmPkGGwwNZlPh8o6KQLvnyZxpafjJXgHl43a JRux9iuKMSW76GFvuRZZjjqwzoMffEa4F4QA68d12P4JaOI2qBAUetZJo3x9fkUo H5UAYo5F3tKojYXKk0Hfap5J9KKGDhN9XMSePrNquoTYaxV9l12SYjFmb11mRDnU 38XQtL+ZBqOoSPhtTMrIPNvnOwgnHMb+7C7HFspK89fKtXWU1H0BXJQSQXhuaztt enXHL2ORQb1UkDKZCF0SWeKYhF6cVtX34eJOJVm25sK08VeANqZgEUnjopZoGQJo 0gx9OKlz+eixEFLtMvxBqI/J5RYyue6BwKgTI4L6ZXWL6KxUWxU6Pf6r7eZ5OE6K 9AARggx3FfEI9Gs1+HdOEvxOqwJpUuvM7aA7bk08Bd8lU6HuF8E3bUX281yWDMwR TE5BqmOQCygyDMmahq+sZVE4mLIZ3xLLv9VuSHhcPprr17RAIjMzVRrdXHCM6Zus Z9L6jvJcYPKkjTnRETc4r1QWB0Myo27Ay7YHeShmHL/6NQV9WlCXhKm8gQq6Z1mO QyVvqLAEl3NYBaRdzIPt =I6oo -----END PGP SIGNATURE----- Merge tag 'tomoyo-pr-20230424' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1 Pull tomoyo update from Tetsuo Handa: "One cleanup patch from Vlastimil Babka" * tag 'tomoyo-pr-20230424' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1: tomoyo: replace tomoyo_round2() with kmalloc_size_roundup()
This commit is contained in:
commit
5af4b523ba
@ -271,7 +271,7 @@ char *tomoyo_init_log(struct tomoyo_request_info *r, int len, const char *fmt,
|
||||
/* +18 is for " symlink.target=\"%s\"" */
|
||||
len += 18 + strlen(symlink);
|
||||
}
|
||||
len = tomoyo_round2(len);
|
||||
len = kmalloc_size_roundup(len);
|
||||
buf = kzalloc(len, GFP_NOFS);
|
||||
if (!buf)
|
||||
goto out;
|
||||
@ -382,12 +382,12 @@ void tomoyo_write_log2(struct tomoyo_request_info *r, int len, const char *fmt,
|
||||
goto out;
|
||||
}
|
||||
entry->log = buf;
|
||||
len = tomoyo_round2(strlen(buf) + 1);
|
||||
len = kmalloc_size_roundup(strlen(buf) + 1);
|
||||
/*
|
||||
* The entry->size is used for memory quota checks.
|
||||
* Don't go beyond strlen(entry->log).
|
||||
*/
|
||||
entry->size = len + tomoyo_round2(sizeof(*entry));
|
||||
entry->size = len + kmalloc_size_roundup(sizeof(*entry));
|
||||
spin_lock(&tomoyo_log_lock);
|
||||
if (tomoyo_memory_quota[TOMOYO_MEMORY_AUDIT] &&
|
||||
tomoyo_memory_used[TOMOYO_MEMORY_AUDIT] + entry->size >=
|
||||
|
@ -2094,7 +2094,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
|
||||
tomoyo_add_entry(r->domain, entry.query);
|
||||
goto out;
|
||||
}
|
||||
len = tomoyo_round2(entry.query_len);
|
||||
len = kmalloc_size_roundup(entry.query_len);
|
||||
entry.domain = r->domain;
|
||||
spin_lock(&tomoyo_query_list_lock);
|
||||
if (tomoyo_memory_quota[TOMOYO_MEMORY_QUERY] &&
|
||||
|
@ -1276,50 +1276,6 @@ static inline struct tomoyo_policy_namespace *tomoyo_current_namespace(void)
|
||||
return tomoyo_domain()->ns;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SLOB)
|
||||
|
||||
/**
|
||||
* tomoyo_round2 - Round up to power of 2 for calculating memory usage.
|
||||
*
|
||||
* @size: Size to be rounded up.
|
||||
*
|
||||
* Returns @size.
|
||||
*
|
||||
* Since SLOB does not round up, this function simply returns @size.
|
||||
*/
|
||||
static inline int tomoyo_round2(size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* tomoyo_round2 - Round up to power of 2 for calculating memory usage.
|
||||
*
|
||||
* @size: Size to be rounded up.
|
||||
*
|
||||
* Returns rounded size.
|
||||
*
|
||||
* Strictly speaking, SLAB may be able to allocate (e.g.) 96 bytes instead of
|
||||
* (e.g.) 128 bytes.
|
||||
*/
|
||||
static inline int tomoyo_round2(size_t size)
|
||||
{
|
||||
#if PAGE_SIZE == 4096
|
||||
size_t bsize = 32;
|
||||
#else
|
||||
size_t bsize = 64;
|
||||
#endif
|
||||
if (!size)
|
||||
return 0;
|
||||
while (size > bsize)
|
||||
bsize <<= 1;
|
||||
return bsize;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* list_for_each_cookie - iterate over a list with cookie.
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
|
Loading…
Reference in New Issue
Block a user