/* * Seccomp BPF helper functions * * Copyright (c) 2012 The Chromium OS Authors * Author: Will Drewry * * The code may be used by anyone for any purpose, * and can serve as a starting point for developing * applications using prctl(PR_ATTACH_SECCOMP_FILTER). */ #include #include #include #include "bpf-helper.h" int bpf_resolve_jumps(struct bpf_labels *labels, struct sock_filter *filter, size_t count) { size_t i; if (count < 1 || count > BPF_MAXINSNS) return -1; /* * Walk it once, backwards, to build the label table and do fixups. * Since backward jumps are disallowed by BPF, this is easy. */ for (i = 0; i < count; ++i) { size_t offset = count - i - 1; struct sock_filter *instr = &filter[offset]; if (instr->code != (BPF_JMP+BPF_JA)) continue; switch ((instr->jt<<8)|instr->jf) { case (JUMP_JT<<8)|JUMP_JF: if (labels->labels[instr->k].location == 0xffffffff) { fprintf(stderr, "Unresolved label: '%s'\n", labels->labels[instr->k].label); return 1; } instr->k = labels->labels[instr->k].location - (offset + 1); instr->jt = 0; instr->jf = 0; continue; case (LABEL_JT<<8)|LABEL_JF: if (labels->labels[instr->k].location != 0xffffffff) { fprintf(stderr, "Duplicate label use: '%s'\n", labels->labels[instr->k].label); return 1; } labels->labels[instr->k].location = offset; instr->k = 0; /* fall through */ instr->jt = 0; instr->jf = 0; continue; } } return 0; } /* Simple lookup table for labels. */ __u32 seccomp_bpf_label(struct bpf_labels *labels, const char *label) { struct __bpf_label *begin = labels->labels, *end; int id; if (labels->count == BPF_LABELS_MAX) { fprintf(stderr, "Too many labels\n"); exit(1); } if (labels->count == 0) { begin->label = label; begin->location = 0xffffffff; labels->count++; return 0; } end = begin + labels->count; for (id = 0; begin < end; ++begin, ++id) { if (!strcmp(label, begin->label)) return id; } begin->label = label; begin->location = 0xffffffff; labels->count++; return id; } void seccomp_bpf_print(struct sock_filter *filter, size_t count) { struct sock_filter *end = filter + count; for ( ; filter < end; ++filter) printf("{ code=%u,jt=%u,jf=%u,k=%u },\n", filter->code, filter->jt, filter->jf, filter->k); } den' name='id' value='e5ff7c4019c6cb6e86bc9d6d16e8a8f921133c70'/>
option value='20'>20
AgeCommit message (Expand)AuthorFilesLines
space:
mode:
authorHoria Geantă <horia.geanta@nxp.com>2016-12-05 11:06:58 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2016-12-07 19:55:17 +0800
commit39eaf759466f4e3fbeaa39075512f4f345dffdc8 (patch)
treedab5cd98db3202110e8e6c11ec4ae0922599feff /drivers/usb/gadget
parent9e5f7a149e00d211177f6de8be427ebc72a1c363 (diff)
crypto: caam - fix pointer size for AArch64 boot loader, AArch32 kernel
Start with a clean slate before dealing with bit 16 (pointer size) of Master Configuration Register. This fixes the case of AArch64 boot loader + AArch32 kernel, when the boot loader might set MCFGR[PS] and kernel would fail to clear it. Cc: <stable@vger.kernel.org> Reported-by: Alison Wang <alison.wang@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Reviewed-By: Alison Wang <Alison.wang@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/usb/gadget')