@@ -126,6 +126,6 @@ int reginfo_dump(struct reginfo *ri, FILE * f);
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
/* return size of reginfo */
-const int reginfo_size(void);
+int reginfo_size(struct reginfo *ri);
#endif /* RISU_H */
@@ -125,7 +125,7 @@ static RisuResult send_register_info(void *uc)
case OP_TESTEND:
case OP_COMPARE:
case OP_SIGILL:
- header.size = reginfo_size();
+ header.size = reginfo_size(&ri[MASTER]);
extra = &ri[MASTER];
break;
case OP_COMPAREMEM:
@@ -209,7 +209,12 @@ static RisuResult recv_register_info(struct reginfo *ri)
return RES_BAD_SIZE;
}
respond(RES_OK);
- return read_buffer(ri, header.size);
+ res = read_buffer(ri, header.size);
+ if (res == RES_OK && header.size != reginfo_size(ri)) {
+ /* The payload size is not self-consistent with the data. */
+ return RES_BAD_SIZE;
+ }
+ return res;
case OP_COMPAREMEM:
if (header.size != MEMBLOCKLEN) {
@@ -69,7 +69,7 @@ void process_arch_opt(int opt, const char *arg)
#endif
}
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
{
int size = offsetof(struct reginfo, simd.end);
#ifdef SVE_MAGIC
@@ -194,7 +194,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
{
- return memcmp(r1, r2, reginfo_size()) == 0;
+ return memcmp(r1, r2, reginfo_size(r1)) == 0;
}
#ifdef SVE_MAGIC
@@ -36,9 +36,9 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
{
- return sizeof(struct reginfo);
+ return sizeof(*ri);
}
static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc)
@@ -74,9 +74,9 @@ void process_arch_opt(int opt, const char *arg)
}
}
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
{
- return sizeof(struct reginfo);
+ return sizeof(*ri);
}
static void *xsave_feature_buf(struct _xstate *xs, int feature)
@@ -23,9 +23,9 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
{
- return sizeof(struct reginfo);
+ return sizeof(*ri);
}
/* reginfo_init: initialize with a ucontext */
@@ -32,9 +32,9 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
-const int reginfo_size(void)
+int reginfo_size(struct reginfo *ri)
{
- return sizeof(struct reginfo);
+ return sizeof(*ri);
}
/* reginfo_init: initialize with a ucontext */
This will allow dumping of SVE frames without having to know the SVE vector length beforehand. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- risu.h | 2 +- risu.c | 9 +++++++-- risu_reginfo_aarch64.c | 4 ++-- risu_reginfo_arm.c | 4 ++-- risu_reginfo_i386.c | 4 ++-- risu_reginfo_m68k.c | 4 ++-- risu_reginfo_ppc64.c | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-)