lkml.org 
[lkml]   [2017]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] x86/ldt: Rename ldr_struct.size to .n_entries
On Wed, May 31, 2017 at 03:20:01PM -0700, Andy Lutomirski wrote:
> num_bytes, perhaps?

Better idea: entries_size.

I can read it very easily this way:

static int read_ldt(void __user *ptr, unsigned long bytecount)
{
struct mm_struct *mm = current->mm;
unsigned long entries_size;
int retval;

mutex_lock(&mm->context.lock);

if (!mm->context.ldt) {
retval = 0;
goto out_unlock;
}

if (bytecount > LDT_ENTRY_SIZE * LDT_ENTRIES)
bytecount = LDT_ENTRY_SIZE * LDT_ENTRIES;

entries_size = mm->context.ldt->n_entries * LDT_ENTRY_SIZE;
if (entries_size > bytecount)
entries_size = bytecount;

if (copy_to_user(ptr, mm->context.ldt->entries, entries_size)) {
retval = -EFAULT;
goto out_unlock;
}

if (entries_size != bytecount) {
/* Zero-fill the rest and pretend we read bytecount bytes. */
if (clear_user(ptr + entries_size, bytecount - entries_size)) {
retval = -EFAULT;
goto out_unlock;
}
}
retval = bytecount;

out_unlock:
mutex_unlock(&mm->context.lock);
return retval;
}

> > old_ldt = mm->context.ldt;
> > - oldsize = old_ldt ? old_ldt->size : 0;
> > + oldsize = old_ldt ? old_ldt->n_entries : 0;
>
> how about old_n_entries?

Yes, and new_n_entries too:

old_ldt = mm->context.ldt;
old_n_entries = old_ldt ? old_ldt->n_entries : 0;
new_n_entries = max(ldt_info.entry_number + 1, old_n_entries);

Thanks.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

\
 
 \ /
  Last update: 2017-06-01 19:33    [W:0.051 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site