]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
x86: Implement array_index_mask_nospec
authorDan Williams <dan.j.williams@intel.com>
Tue, 30 Jan 2018 01:02:28 +0000 (17:02 -0800)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Feb 2018 03:08:35 +0000 (21:08 -0600)
commitc933d8c703a662b8968a35112c788834bda60ff8
tree0c91d63b11e3fde6d9e3882082e59997ff30521b
parent5fa4e2ce0df946862315680f7bd987ca92590d41
x86: Implement array_index_mask_nospec

BugLink: http://bugs.launchpad.net/bugs/1748072
commit babdde2698d482b6c0de1eab4f697cf5856c5859

array_index_nospec() uses a mask to sanitize user controllable array
indexes, i.e. generate a 0 mask if 'index' >= 'size', and a ~0 mask
otherwise. While the default array_index_mask_nospec() handles the
carry-bit from the (index - size) result in software.

The x86 array_index_mask_nospec() does the same, but the carry-bit is
handled in the processor CF flag without conditional instructions in the
control flow.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: kernel-hardening@lists.openwall.com
Cc: gregkh@linuxfoundation.org
Cc: alan@linux.intel.com
Link: https://lkml.kernel.org/r/151727414808.33451.1873237130672785331.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
arch/x86/include/asm/barrier.h