Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1655615
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH] x86/ldt: Rename ldr_struct.size to .n_entries |
| Date | 2017-06-01 19:30 +0200 |
| Message-ID | <tNC53-5xP-1@gated-at.bofh.it> (permalink) |
| References | <tNfrQ-7Ij-13@gated-at.bofh.it> <tNkhQ-2yk-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[RFC PATCH] x86/ldt: Rename ldr_struct.size to .n_entries Borislav Petkov <bp@alien8.de> - 2017-05-31 19:20 +0200
Re: [RFC PATCH] x86/ldt: Rename ldr_struct.size to .n_entries Andy Lutomirski <luto@kernel.org> - 2017-06-01 00:30 +0200
Re: [RFC PATCH] x86/ldt: Rename ldr_struct.size to .n_entries Borislav Petkov <bp@alien8.de> - 2017-06-01 19:30 +0200
csiph-web