Commit 04ae288a authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

x86, tls: read no more than saved TLS entries

  While writing this, I somehow managed to miss the check of
how many entries were saved in core image.
So it may dereference here bs.

Fixes: #228
Fixes: commit 6fde3b8c27db ("x86: restore TLS")

travis-ci: success for x86, tls: read no more than saved TLS entries
Cc: Andrei Vagin <avagin@virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent efc87fce
...@@ -31,12 +31,22 @@ ...@@ -31,12 +31,22 @@
static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls)
{ {
ThreadInfoX86 *ti = pcore->thread_info; ThreadInfoX86 *ti = pcore->thread_info;
int i; size_t i;
for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) { for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) {
user_desc_t *to = &ptls->desc[i]; user_desc_t *to = &ptls->desc[i];
UserDescT *from = ti->tls[i]; UserDescT *from;
/*
* If proto image has lesser TLS entries,
* mark them as not present (and thus skip restore).
*/
if (i >= ti->n_tls) {
to->seg_not_present = 1;
continue;
}
from = ti->tls[i];
#define COPY_TLS(field) to->field = from->field #define COPY_TLS(field) to->field = from->field
COPY_TLS(entry_number); COPY_TLS(entry_number);
COPY_TLS(base_addr); COPY_TLS(base_addr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment