2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

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: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Dmitry Safonov
2016-10-20 15:31:00 +03:00
committed by Andrei Vagin
parent efc87fce32
commit 04ae288af3

View File

@@ -31,12 +31,22 @@
static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls)
{
ThreadInfoX86 *ti = pcore->thread_info;
int i;
size_t i;
for (i = 0; i < GDT_ENTRY_TLS_NUM; 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
COPY_TLS(entry_number);
COPY_TLS(base_addr);