/* * AppArmor security module * * This file contains AppArmor policy loading interface function definitions. * * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. * * Fns to provide a checksum of policy that has been loaded this can be * compared to userspace policy compiles to check loaded policy is what * it should be. */ #include <crypto/hash.h> #include "include/apparmor.h" #include "include/crypto.h" static unsigned int apparmor_hash_size; static struct crypto_shash *apparmor_tfm; unsigned int aa_hash_size(void) { return apparmor_hash_size; } int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start, size_t len) { struct { struct shash_desc shash; char ctx[crypto_shash_descsize(apparmor_tfm)]; } desc; int error = -ENOMEM; u32 le32_version = cpu_to_le32(version); if (!aa_g_hash_policy) return 0; if (!apparmor_tfm) return 0; profile->hash = kzalloc(apparmor_hash_size, GFP_KERNEL); if (!profile->hash) goto fail; desc.shash.tfm = apparmor_tfm; desc.shash.flags = 0; error = crypto_shash_init(&desc.shash); if (error) goto fail; error = crypto_shash_update(&desc.shash, (u8 *) &le32_version, 4); if (error) goto fail; error = crypto_shash_update(&desc.shash, (u8 *) start, len); if (error) goto fail; error = crypto_shash_final(&desc.shash, profile->hash); if (error) goto fail; return 0; fail: kfree(profile->hash); profile->hash = NULL; return error; } static int __init init_profile_hash(void) { struct crypto_shash *tfm; if (!apparmor_initialized) return 0; tfm = crypto_alloc_shash("sha1", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) { int error = PTR_ERR(tfm); AA_ERROR("failed to setup profile sha1 hashing: %d\n", error); return error; } apparmor_tfm = tfm; apparmor_hash_size = crypto_shash_digestsize(apparmor_tfm); aa_info_message("AppArmor sha1 policy hashing enabled"); return 0; } late_initcall(init_profile_hash); hipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/drivers/usb/chipidea/udc.c'> <input type='hidden' name='id' value='252bf9f4c43fd58f96587a97866cb7cc980e7544'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/commit/?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>drivers</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>usb</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/chipidea?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>chipidea</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>udc.c</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='252bf9f4c43fd58f96587a97866cb7cc980e7544'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'> <tr><th>author</th><td>Linus Torvalds <torvalds@linux-foundation.org></td><td class='right'>2017-02-04 10:38:09 -0800</td></tr> <tr><th>committer</th><td>Linus Torvalds <torvalds@linux-foundation.org></td><td class='right'>2017-02-04 10:38:09 -0800</td></tr> <tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>252bf9f4c43fd58f96587a97866cb7cc980e7544</a> (<a href='/cgit.cgi/linux/net-next.git/patch/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>patch</a>)</td></tr> <tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>aeff11933ae538381392f91ec10da99e49c61c91</a> /<a href='/cgit.cgi/linux/net-next.git/tree/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>drivers/usb/chipidea/udc.c</a></td></tr> <tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/chipidea/udc.c?id=8fcdcc42a5268f298ac91962a5e816294435006f'>8fcdcc42a5268f298ac91962a5e816294435006f</a> (<a href='/cgit.cgi/linux/net-next.git/diff/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544&id2=8fcdcc42a5268f298ac91962a5e816294435006f'>diff</a>)</td></tr><tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/chipidea/udc.c?id=b17c1bba9cec1727451b906d9a0c209774624873'>b17c1bba9cec1727451b906d9a0c209774624873</a> (<a href='/cgit.cgi/linux/net-next.git/diff/drivers/usb/chipidea/udc.c?id=252bf9f4c43fd58f96587a97866cb7cc980e7544&id2=b17c1bba9cec1727451b906d9a0c209774624873'>diff</a>)</td></tr></table> <div class='commit-subject'>Merge tag 'staging-4.10-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging</div><div class='commit-msg'>Pull staging/IIO fixes from Greg KH: "Here are a few small IIO and one staging driver fix for 4.10-rc7. They fix some reported issues with the drivers. All of them have been in linux-next for a week or so with no reported issues" * tag 'staging-4.10-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: greybus: timesync: validate platform state callback iio: dht11: Use usleep_range instead of msleep for start signal iio: adc: palmas_gpadc: retrieve a valid iio_dev in suspend/resume iio: health: max30100: fixed parenthesis around FIFO count check iio: health: afe4404: retrieve a valid iio_dev in suspend/resume iio: health: afe4403: retrieve a valid iio_dev in suspend/resume </div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=252bf9f4c43fd58f96587a97866cb7cc980e7544'>Diffstat</a> (limited to 'drivers/usb/chipidea/udc.c')</div><table summary='diffstat' class='diffstat'>