int xt_compat_check_entry_offsets(const void *base, const char *elems,
				  unsigned int target_offset,
				  unsigned int next_offset)
{
	long size_of_base_struct = elems - (const char *)base;
	const struct compat_xt_entry_target *t;
	const char *e = base;

	if (target_offset < size_of_base_struct)
		return -EINVAL;

	if (target_offset + sizeof(*t) > next_offset)
		return -EINVAL;

	t = (void *)(e + target_offset);
	if (t->u.target_size < sizeof(*t))
		return -EINVAL;

	if (target_offset + t->u.target_size > next_offset)
		return -EINVAL;

	if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0) {
		const struct compat_xt_standard_target *st = (const void *)t;

		if (COMPAT_XT_ALIGN(target_offset + sizeof(*st)) != next_offset)
			return -EINVAL;

		if (!verdict_ok(st->verdict))
			return -EINVAL;
	} else if (strcmp(t->u.user.name, XT_ERROR_TARGET) == 0) {
		const struct compat_xt_error_target *et = (const void *)t;

		if (!error_tg_ok(t->u.target_size, sizeof(*et),
				 et->errorname, sizeof(et->errorname)))
			return -EINVAL;
	}

	/* compat_xt_entry match has less strict alignment requirements,
	 * otherwise they are identical.  In case of padding differences
	 * we need to add compat version of xt_check_entry_match.
	 */
	BUILD_BUG_ON(sizeof(struct compat_xt_entry_match) != sizeof(struct xt_entry_match));

	return xt_check_entry_match(elems, base + target_offset,
				    __alignof__(struct compat_xt_entry_match));
}
int xt_compat_check_entry_offsets(const void *base, const char *elems,
				  unsigned int target_offset,
				  unsigned int next_offset)
{
	long size_of_base_struct = elems - (const char *)base;
	const struct compat_xt_entry_target *t;
	const char *e = base;

	if (target_offset < size_of_base_struct)
		return -EINVAL;

	if (target_offset + sizeof(*t) > next_offset)
		return -EINVAL;

	t = (void *)(e + target_offset);
	if (t->u.target_size < sizeof(*t))
		return -EINVAL;

	if (target_offset + t->u.target_size > next_offset)
		return -EINVAL;

	if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0) {
		const struct compat_xt_standard_target *st = (const void *)t;

		if (COMPAT_XT_ALIGN(target_offset + sizeof(*st)) != next_offset)
			return -EINVAL;

		if (!verdict_ok(st->verdict))
			return -EINVAL;
	} else if (strcmp(t->u.user.name, XT_ERROR_TARGET) == 0) {
		const struct compat_xt_error_target *et = (const void *)t;

		if (!error_tg_ok(t->u.target_size, sizeof(*et),
				 et->errorname, sizeof(et->errorname)))
			return -EINVAL;
	}

	 
	BUILD_BUG_ON(sizeof(struct compat_xt_entry_match) != sizeof(struct xt_entry_match));

	return xt_check_entry_match(elems, base + target_offset,
				    __alignof__(struct compat_xt_entry_match));
}