From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 56AF045502; Thu, 27 Jun 2024 13:58:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 078B0410EA; Thu, 27 Jun 2024 13:58:30 +0200 (CEST) Received: from forward502b.mail.yandex.net (forward502b.mail.yandex.net [178.154.239.146]) by mails.dpdk.org (Postfix) with ESMTP id 678A040B8F; Thu, 27 Jun 2024 13:55:46 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net [IPv6:2a02:6b8:c23:222b:0:640:695f:0]) by forward502b.mail.yandex.net (Yandex) with ESMTPS id B66AC5FB42; Thu, 27 Jun 2024 14:55:45 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id YtPWcA4Mi8c0-MXVccofh; Thu, 27 Jun 2024 14:55:45 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1719489345; bh=faUsiXsF7FpF8Yi738zLkkv1kHHZeMgqSFf73HPGZHo=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=a2YCh+hPKlsLTKK6AtERfRqb420MT0Nvt2cSm1xvV9YhV6XngmMTPsdTuGhLRjtHv nauBlKtB038MOzO2GArqiKcaEvaoavPXQKHCVFiqCaRunfB4J3W3V4roQpr04JiMtS 8x6ZvAQqugL3o6hf7duVaE/ZB/PcMr4E6C49mtrE= Authentication-Results: mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Konstantin Ananyev To: dev@dpdk.org Cc: stephen@networkplumber.org, Konstantin Ananyev , stable@dpdk.org Subject: [PATCH 1/3] bfp: fix MOV instruction evaluation Date: Thu, 27 Jun 2024 12:55:29 +0100 Message-Id: <20240627115531.1440-2-konstantin.v.ananyev@yandex.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240627115531.1440-1-konstantin.v.ananyev@yandex.ru> References: <20240627115531.1440-1-konstantin.v.ananyev@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Konstantin Ananyev Verifier might left some register-state values uninitialized while evaluating MOV instructions. Add explicit initialization. Fixes: 8021917293d0 ("bpf: add extra validation for input BPF program") Cc: stable@dpdk.org Signed-off-by: Konstantin Ananyev --- lib/bpf/bpf_validate.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c index 79be5e917d..11344fff4d 100644 --- a/lib/bpf/bpf_validate.c +++ b/lib/bpf/bpf_validate.c @@ -636,14 +636,14 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins) { uint64_t msk; uint32_t op; - size_t opsz; + size_t opsz, sz; const char *err; struct bpf_eval_state *st; struct bpf_reg_val *rd, rs; - opsz = (BPF_CLASS(ins->code) == BPF_ALU) ? + sz = (BPF_CLASS(ins->code) == BPF_ALU) ? sizeof(uint32_t) : sizeof(uint64_t); - opsz = opsz * CHAR_BIT; + opsz = sz * CHAR_BIT; msk = RTE_LEN2MASK(opsz, uint64_t); st = bvf->evst; @@ -652,8 +652,10 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins) if (BPF_SRC(ins->code) == BPF_X) { rs = st->rv[ins->src_reg]; eval_apply_mask(&rs, msk); - } else + } else { + rs = (struct bpf_reg_val){.v = {.size = sz,},}; eval_fill_imm(&rs, msk, ins->imm); + } eval_apply_mask(rd, msk); -- 2.35.3