Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp477561pxb; Thu, 14 Jan 2021 10:22:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwm4Wp5zgbwBc0Qd1N5wSFJJ3oyMdh3In++jKOYcG1km6VniERj3iNTAkWa7B3iryqhG1Rw X-Received: by 2002:a05:6402:1352:: with SMTP id y18mr6634624edw.178.1610648523596; Thu, 14 Jan 2021 10:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610648523; cv=none; d=google.com; s=arc-20160816; b=zyobUX3TuN+1F+pKxJbZHAQWSWO2Yeopawk184pcf4xIP4w50e6F/349hzdlMDDhWt Nq523DOCchiO9s1MK0tOV92rhpMJM3lLtCqOVhBKtDMcTlBrHSPW9N8z8VbftZJbPWii Ghgot3TzlTmr6w5XOaZdlzQZR+sQMwt3ZTN02+kJ11LGqPPcvzcoanmtYRBIY8AKU6gE PG61LFzFQWhRlCgkMvq5C76Fl6KsPgHw+6HzO7vICOJtJz4BrupHCB56T2DOqlxzB1km QUvty5NsorjHZX+tT0gMEQmtErnkpHluCu+CCE4IEV4sPBam6COjm5FUa7yrX6opMSY0 mxmg== 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=fUuyMVv5zUjRbWSI86/K8i8mxU4aDwFKnpIfaPRRyd0=; b=XAphncO2A+JAiNkIeAtVkdpcvpNy/9tZv/zmZE+EG4wUB0loFhZRTZHNAUvByL6Zkk z2caePqwAljmWfo8PdXc5qT2ovYBg4uos5JsCmfJse4jWdFKu1HdGbM+TBqj+Jqvw12L l3fA0GXRfC5gXCO1J9Obh4PSCjLmYB1VsROcZngGszYqNXPRhEVMHM/CugDWibOKbsFc weA9GKunE5iYbcdFFBhO+h8cdx/pTTY825H+LiUkUnlBmkS8m26HqhD/GN8/ooz4LHBc gedZ7vDHcDKcG0joV1wOs1AefbWDHYDHbF5wAhbq5iuoUgtg2PX8ZPZxJixP8IlfucY2 OyUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UxKmx5GK; 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 f1si2728430ejd.696.2021.01.14.10.21.40; Thu, 14 Jan 2021 10:22:03 -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=UxKmx5GK; 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 S1729860AbhANSUN (ORCPT + 99 others); Thu, 14 Jan 2021 13:20:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbhANSTa (ORCPT ); Thu, 14 Jan 2021 13:19:30 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AAE4C061796 for ; Thu, 14 Jan 2021 10:18:18 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id g16so2979204wrv.1 for ; Thu, 14 Jan 2021 10:18:18 -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=fUuyMVv5zUjRbWSI86/K8i8mxU4aDwFKnpIfaPRRyd0=; b=UxKmx5GKbSUh2YzKDNgLB+yoQc0VYtJXqfXrEJvBaORIrIwrD7P/C7L8B4HuMSCHjw 1QdUiERxokUmKAWJtx87gAUZa534PT32Kf5GigRCtc75hal3MQuTeczSbG6M2mlY074x ecOL4I6dexen0dApNr4AIxEzFo/8BgLRzN5quXgBDmD16SjhSKo6/2C3ASiICnJdV3oR BGcIZWYYbVIelQPeYdgjVSKKO5o4AMiPHwj6MxO45/iilBN3QR4pafJH+P1MD1ckxc+E cvRj9zD0IJg1Ow78mSdxb1/zPfh1dp0z8yBF5uHc9VxgI2zxVBYppAOgehzgVNpZIBat S83w== 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=fUuyMVv5zUjRbWSI86/K8i8mxU4aDwFKnpIfaPRRyd0=; b=aEUOZqDXdPujqdypjGkQjgU1xJcQuzFHppt9nE6djTt927aAz9TkiGJgFE8qFK4iyQ X/LfhE3cQKPl164AY3zjnvkUPqe5RGNbYNaiLxQeTzoZjUTv3s0XGApXewt6X4MA6+HS swSIVerMq0TkrzduE26KcrHLdrZaDXPVHPIX7iZJd2v/QEZbzUe0tLY/EHMXzDDCfuYW lemQmkqZ81I6vIdNQB0DounKwY3E6MBBC0wu4rUvLeHx7ggBWr9w+doS1pCmhoIsuHiN 1E/lyZ643+thVxcfAKJsWcBeTxalmiDrpaqC2+RTvWGrYZAYfU1eIJ9uZR48xMkSz89z TVsg== X-Gm-Message-State: AOAM533IzQrVS1lIq6gMwcnkz4EQQKBlZ8APT0aT5Rm8Fw8i1ZnAUlCE JTw/aSPBPEi8hHrppGp/VImFyIz7MGrCPw== 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:a1c:b78a:: with SMTP id h132mr5017956wmf.141.1610648296771; Thu, 14 Jan 2021 10:18:16 -0800 (PST) Date: Thu, 14 Jan 2021 18:17:45 +0000 In-Reply-To: <20210114181751.768687-1-jackmanb@google.com> Message-Id: <20210114181751.768687-6-jackmanb@google.com> Mime-Version: 1.0 References: <20210114181751.768687-1-jackmanb@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH bpf-next v7 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 , Daniel Borkmann , Andrii Nakryiko , KP Singh , Florent Revest , linux-kernel@vger.kernel.org, "=?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?=" , John Fastabend , Yonghong Song , 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 Acked-by: Yonghong Song Acked-by: John Fastabend --- 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 cfc137b81ac6..d8a85f4e5b95 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -9528,6 +9528,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) @@ -10012,13 +10018,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.30.0.284.gd98b1dd5eaa7-goog