/* * Intel Memory Protection Keys management * Copyright (c) 2015, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. */ #include /* mm_struct, vma, etc... */ #include /* PKEY_* */ #include #include /* boot_cpu_has, ... */ #include /* vma_pkey() */ #include /* fpregs_active() */ int __execute_only_pkey(struct mm_struct *mm) { int ret; /* * We do not want to go through the relatively costly * dance to set PKRU if we do not need to. Check it * first and assume that if the execute-only pkey is * write-disabled that we do not have to set it * ourselves. We need preempt off so that nobody * can make fpregs inactive. */ preempt_disable(); if (fpregs_active() && !__pkru_allows_read(read_pkru(), PKEY_DEDICATED_EXECUTE_ONLY)) { preempt_enable(); return PKEY_DEDICATED_EXECUTE_ONLY; } preempt_enable(); ret = arch_set_user_pkey_access(current, PKEY_DEDICATED_EXECUTE_ONLY, PKEY_DISABLE_ACCESS); /* * If the PKRU-set operation failed somehow, just return * 0 and effectively disable execute-only support. */ if (ret) return 0; return PKEY_DEDICATED_EXECUTE_ONLY; } static inline bool vma_is_pkey_exec_only(struct vm_area_struct *vma) { /* Do this check first since the vm_flags should be hot */ if ((vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) != VM_EXEC) return false; if (vma_pkey(vma) != PKEY_DEDICATED_EXECUTE_ONLY) return false; return true; } /* * This is only called for *plain* mprotect calls. */ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot, int pkey) { /* * Is this an mprotect_pkey() call? If so, never * override the value that came from the user. */ if (pkey != -1) return pkey; /* * Look for a protection-key-drive execute-only mapping * which is now being given permissions that are not * execute-only. Move it back to the default pkey. */ if (vma_is_pkey_exec_only(vma) && (prot & (PROT_READ|PROT_WRITE))) { return 0; } /* * The mapping is execute-only. Go try to get the * execute-only protection key. If we fail to do that, * fall through as if we do not have execute-only * support. */ if (prot == PROT_EXEC) { pkey = execute_only_pkey(vma->vm_mm); if (pkey > 0) return pkey; } /* * This is a vanilla, non-pkey mprotect (or we failed to * setup execute-only), inherit the pkey from the VMA we * are working on. */ return vma_pkey(vma); } e2ce59c25ab66e47ab1f0'>soc/intel/boards/bytcr_rt5640.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-08 11:42:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-08 11:42:04 -0800
commit83280e90ef001f77a64e2ce59c25ab66e47ab1f0 (patch)
treeec0a5842e2fbc0f4abaff55299acac397b8da5c3 /sound/soc/intel/boards/bytcr_rt5640.c
parentcc250e267bd56c531b0bee455fc724d50af83fac (diff)
parent0a8fd1346254974c3a852338508e4a4cddbb35f1 (diff)
Merge tag 'usb-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a bunch of USB fixes for 4.10-rc3. Yeah, it's a lot, an artifact of the holiday break I think. Lots of gadget and the usual XHCI fixups for reported issues (one day that driver will calm down...) Also included are a bunch of usb-serial driver fixes, and for good measure, a number of much-reported MUSB driver issues have finally been resolved. All of these have been in linux-next with no reported issues" * tag 'usb-4.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (72 commits) USB: fix problems with duplicate endpoint addresses usb: ohci-at91: use descriptor-based gpio APIs correctly usb: storage: unusual_uas: Add JMicron JMS56x to unusual device usb: hub: Move hub_port_disable() to fix warning if PM is disabled usb: musb: blackfin: add bfin_fifo_offset in bfin_ops usb: musb: fix compilation warning on unused function usb: musb: Fix trying to free already-free IRQ 4 usb: musb: dsps: implement clear_ep_rxintr() callback usb: musb: core: add clear_ep_rxintr() to musb_platform_ops USB: serial: ti_usb_3410_5052: fix NULL-deref at open USB: serial: spcp8x5: fix NULL-deref at open USB: serial: quatech2: fix sleep-while-atomic in close USB: serial: pl2303: fix NULL-deref at open USB: serial: oti6858: fix NULL-deref at open USB: serial: omninet: fix NULL-derefs at open and disconnect USB: serial: mos7840: fix misleading interrupt-URB comment USB: serial: mos7840: remove unused write URB USB: serial: mos7840: fix NULL-deref at open USB: serial: mos7720: remove obsolete port initialisation USB: serial: mos7720: fix parallel probe ...
Diffstat (limited to 'sound/soc/intel/boards/bytcr_rt5640.c')