Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2503091pxu; Mon, 7 Dec 2020 08:12:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOPzkS/nkjgNeeoUKKgNh7LSVs5G+aTSEnFYdI6QPYLfOtj5rduQDhCoezsET/a85ZvbFX X-Received: by 2002:a17:906:d8a1:: with SMTP id qc1mr18989875ejb.294.1607357553350; Mon, 07 Dec 2020 08:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607357553; cv=none; d=google.com; s=arc-20160816; b=c/7ppeh+MruQTB2diuQEqEJ15HRjuvwTo35Z+qxdyghHIq3i6MH97Z1aoPAHPpvQxN OStTlkFr1lHVhajcJQkId38306/1k4KS6HDiYf/Ws4bx2eaGtpJffSKmK7YObax21/3P j4ZOm3z15s23HYBfLYB+4EKFMOxN1KiufUHhXpPs5U010YnaHdvvRtwtlSLnVbmsmFFL NU4E8uv+HrVjZuFZvjRgM4vfEm79NqVc1lA2Z5u02sShAv/rBpL+YZJIs+YRY/yQZdle ms6xzvFhc4MHJIc7az5GMSRhf0VXG2KMd9f2LAON/g2dfht4RqJzImyhcDwgITe2F3Ey X3cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=JZuzlSoAjz7FNG/xXGP3ldQQuwguOauM6X/0+9EKmts=; b=PEWs/OltCrliodpmhWKCN0ODKhagxPdX0HZTwQRIj2LVrl0Nz119uU9JrGQz1PE4uN B78Xojqa9GtpBisH4BQUpBSRbFcNv3ASBV05kA2wilDriFV/0se/poSERzG/OWBwObSf eHdqyusDgTvUr3c56Ggc6D/4kL2hdw2TzSgn5lh5kifGFaLMH4LQ+zINfxzuwSkHMGEL qSXFJj8uMjk5dfGj+57la4EI5GyExI2znhW/cGpythMo52wFGNYmu+NXM4dnLPAWoK1r jRlpyGItm3YMIoox4PCvq5nrdBKytrMWQ8MLIKA0UCdhgHx07ZFxHF0mvbrX2s3adSXP aJ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kuioVJ08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs8si7120412ejc.113.2020.12.07.08.12.08; Mon, 07 Dec 2020 08:12:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kuioVJ08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbgLGQJQ (ORCPT + 99 others); Mon, 7 Dec 2020 11:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbgLGQJQ (ORCPT ); Mon, 7 Dec 2020 11:09:16 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A19C0611CD for ; Mon, 7 Dec 2020 08:08:24 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id l7so2914682qvp.15 for ; Mon, 07 Dec 2020 08:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=JZuzlSoAjz7FNG/xXGP3ldQQuwguOauM6X/0+9EKmts=; b=kuioVJ08vE6S92h1R7I+//XBgajY7a4JuolHp1x7PP/9tTSoDEAegDUB0lnCtg+9IU 83o+z7wxxstyNeMJ7k/YSey5qJwIYiPu3zTHU7IgZWkPEEoLk9wGTVu1OqV564qw1M0K u/hOtMqnBsjxUqmHYG/iH6E/gJnSyCaMq5DAlV2HPRku0AyWU4HDXzSRk1TsjkEYvHrf coy+QV/Ukb2hzYnrRqThYLE4IpcWL/G2g5smexbzzK9176PFP9uon4J4qJE/jzRPt8Pl Qd0rXkSHrjYCTE2wwYgu0rFpI5p7+sPJw4X+GmUbbSpfydGiQel9ghKwDYjSVXCuTXbo Ri6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=JZuzlSoAjz7FNG/xXGP3ldQQuwguOauM6X/0+9EKmts=; b=kU3oidgRWmcnm171yKNc7ZDkTdvgRSTpWqcEbVuSkS0pvGbqIPYQZrdMIoE3LN/7jQ y6K+GcM+yXOwsbgr7zftYGZouVBw4dH7HgpmmZC0/hEDAO0TmCbr0tl34/oROR5BWqd8 FnT3eu1UbJBeIJWuHnEgiDrVqgTM3OvWLkBouvMtNDUExQ9uUEpWe4Q7aod7GAXCxNcF Q7zohyJi+khV6Ewb12W+kwzUY8Uodh+b1O33obgIM7vjS2qWK2Khy82P9Tvk3JgbrODR 9D2115bygur6Wg7ejx0w4+6OY+VJFPaAv+8UGi6fjHO6r8tEjcLSBvGx/cfKs4Bin+Ac jKcA== X-Gm-Message-State: AOAM532V1rkAzAnY7ArY7tvQm08SC/0pBpCTHqXlWZbkDGFjg86pS9lO bUv/OnA7eh6EUZ8J9tf/LDXZAfo8W2g3rA== Sender: "jackmanb via sendgmr" X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:ad4:5bcd:: with SMTP id t13mr21906474qvt.7.1607357303539; Mon, 07 Dec 2020 08:08:23 -0800 (PST) Date: Mon, 7 Dec 2020 16:07:28 +0000 In-Reply-To: <20201207160734.2345502-1-jackmanb@google.com> Message-Id: <20201207160734.2345502-6-jackmanb@google.com> Mime-Version: 1.0 References: <20201207160734.2345502-1-jackmanb@google.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH bpf-next v4 05/11] bpf: Move BPF_STX reserved field check into BPF_STX verifier code From: Brendan Jackman To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Yonghong Song , Daniel Borkmann , KP Singh , Florent Revest , linux-kernel@vger.kernel.org, Jann Horn , Brendan Jackman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I can't find a reason why this code is in resolve_pseudo_ldimm64; since I'll be modifying it in a subsequent commit, tidy it up. Signed-off-by: Brendan Jackman --- kernel/bpf/verifier.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 615be10abd71..745c53df0485 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -9527,6 +9527,12 @@ static int do_check(struct bpf_verifier_env *env) } else if (class == BPF_STX) { enum bpf_reg_type *prev_dst_type, dst_reg_type; + if (((BPF_MODE(insn->code) != BPF_MEM && + BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) { + verbose(env, "BPF_STX uses reserved fields\n"); + return -EINVAL; + } + if (BPF_MODE(insn->code) == BPF_ATOMIC) { err = check_atomic(env, env->insn_idx, insn); if (err) @@ -9939,13 +9945,6 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env) return -EINVAL; } - if (BPF_CLASS(insn->code) == BPF_STX && - ((BPF_MODE(insn->code) != BPF_MEM && - BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) { - verbose(env, "BPF_STX uses reserved fields\n"); - return -EINVAL; - } - if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) { struct bpf_insn_aux_data *aux; struct bpf_map *map; -- 2.29.2.576.ga3fc446d84-goog