lkml.org 
[lkml]   [2019]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch V2 14/16] x86/iopl: Restrict iopl() permission scope

* Thomas Gleixner <tglx@linutronix.de> wrote:

> --- a/arch/x86/kernel/ioport.c
> +++ b/arch/x86/kernel/ioport.c
> @@ -18,12 +18,15 @@ static atomic64_t io_bitmap_sequence;
>
> void io_bitmap_share(struct task_struct *tsk)
> {
> - /*
> - * Take a refcount on current's bitmap. It can be used by
> - * both tasks as long as none of them changes the bitmap.
> - */
> - refcount_inc(&current->thread.io_bitmap->refcnt);
> - tsk->thread.io_bitmap = current->thread.io_bitmap;
> + /* Can be NULL when current->thread.iopl_emul == 3 */
> + if (current->thread.io_bitmap) {
> + /*
> + * Take a refcount on current's bitmap. It can be used by
> + * both tasks as long as none of them changes the bitmap.
> + */
> + refcount_inc(&current->thread.io_bitmap->refcnt);
> + tsk->thread.io_bitmap = current->thread.io_bitmap;
> + }

Minor side note: whitespace damage managed to slip in that code, see the
fix below.

Thanks,

Ingo

arch/x86/kernel/ioport.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index f87844e22ec9..ee37a1c25ecc 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -17,16 +17,16 @@
static atomic64_t io_bitmap_sequence;

void io_bitmap_share(struct task_struct *tsk)
- {
- /* Can be NULL when current->thread.iopl_emul == 3 */
- if (current->thread.io_bitmap) {
- /*
- * Take a refcount on current's bitmap. It can be used by
- * both tasks as long as none of them changes the bitmap.
- */
- refcount_inc(&current->thread.io_bitmap->refcnt);
- tsk->thread.io_bitmap = current->thread.io_bitmap;
- }
+{
+ /* Can be NULL when current->thread.iopl_emul == 3 */
+ if (current->thread.io_bitmap) {
+ /*
+ * Take a refcount on current's bitmap. It can be used by
+ * both tasks as long as none of them changes the bitmap.
+ */
+ refcount_inc(&current->thread.io_bitmap->refcnt);
+ tsk->thread.io_bitmap = current->thread.io_bitmap;
+ }
set_tsk_thread_flag(tsk, TIF_IO_BITMAP);
}

\
 
 \ /
  Last update: 2019-11-12 07:33    [W:0.115 / U:5.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site