Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2682477pxj; Mon, 31 May 2021 08:09:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJfsMK5/aSGakQ8fwrp7T7ejUugh9ks/4WY4fDi2N5mE4lJR1pUyoIDQvxbhQuxS0WeGEi X-Received: by 2002:a6b:8e04:: with SMTP id q4mr17537098iod.54.1622473789865; Mon, 31 May 2021 08:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622473789; cv=none; d=google.com; s=arc-20160816; b=qSJSWynAbYc3pUhUJ9ju8ny7172Ma7YdADQzyFHZfx3MPz9QhBwATHtEQAUvsnNH1i klIS4zacel6nv+PGCraySe9yAW2iLc0aBCEnlQsoadg8q2dqgRy+UfxldYaIGP/rf0zY Ho0llc3Dq3JiI9+buuCM9HVdEvszczWh+phzRzNQ9FL2GcZkTiWcvMzd21aXbNKXZt/I ThyaRJ3svXyGB37n8l6Cuo3daFP6KWaFwcsqHmaiHsdyJPjtu0FgYgut1tu0WJ6ey5zx wJROqQZNF8i+aI1OtCY+cQTf7JQIj2a8P5LFjOM4eFjAIEH7APi4Zkkg7ec6MY39ey+/ EZGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4y6e9cnBA1cANpIYv3K510ElYrYrmGUwoljYLy/BGcw=; b=cYJ2OI83XZKtXS+3zAI0UaxtIFEgjLagSccNqf+DHtlO9tXnizvGIz1mUV3CFlxqE7 bGh09Q3vN3bjRN/R0eHGVKdKVJAKxAGIU1RQa+MafwXkq/JD3yPLQFI/smTE6z/NZohR VbJ0k55muD6DTIbutWjrG/gLokXttbkN2MIDPqhf5l8ObEiZqfa8K5HIsn2aFmiuZRX3 SxWNyTu1lbLBnqBfL5EiGF6o5afdm+4hayQcLyVOAPcT3u5Svg8lmO9EotWEOHtrfp+q SXfXA2LeX4qLWGZlQSFMsTELI756TyijWuSz0S6GQXVVP2W1cQWzWh9AEcVTKnf302p+ F7aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dNFZ9kpc; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si13925020ilu.19.2021.05.31.08.09.35; Mon, 31 May 2021 08:09:49 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=dNFZ9kpc; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbhEaPJF (ORCPT + 99 others); Mon, 31 May 2021 11:09:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:40230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbhEaOJf (ORCPT ); Mon, 31 May 2021 10:09:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A74F6145D; Mon, 31 May 2021 13:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468418; bh=vr+9+jsiYpW3YsbM/MgBIgOYXGIxH+DtsokFt9Z/obs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNFZ9kpcPmXnXIOiGDOYPaT8RZbKD9Jboqq7S9SyIFqug4do7xes/nCOg/kCRMBQD FFeYGTbu+fWGtwwAuXyHmSTwoXNhnIWDcRXWFS+B5jR494SNKDtt8RdyADjINO4q1F jisJarSz5iDM7bKsUQ5Le6EpLxfWonXvuuA+Oheg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yinjun Zhang , Simon Horman , Daniel Borkmann , Song Liu , Sasha Levin Subject: [PATCH 5.10 228/252] bpf, offload: Reorder offload callback prepare in verifier Date: Mon, 31 May 2021 15:14:53 +0200 Message-Id: <20210531130705.746716479@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yinjun Zhang [ Upstream commit ceb11679d9fcf3fdb358a310a38760fcbe9b63ed ] Commit 4976b718c355 ("bpf: Introduce pseudo_btf_id") switched the order of resolve_pseudo_ldimm(), in which some pseudo instructions are rewritten. Thus those rewritten instructions cannot be passed to driver via 'prepare' offload callback. Reorder the 'prepare' offload callback to fix it. Fixes: 4976b718c355 ("bpf: Introduce pseudo_btf_id") Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman Signed-off-by: Daniel Borkmann Acked-by: Song Liu Link: https://lore.kernel.org/bpf/20210520085834.15023-1-simon.horman@netronome.com Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 364b9760d1a7..4f50d6f128be 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -12364,12 +12364,6 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, if (is_priv) env->test_state_freq = attr->prog_flags & BPF_F_TEST_STATE_FREQ; - if (bpf_prog_is_dev_bound(env->prog->aux)) { - ret = bpf_prog_offload_verifier_prep(env->prog); - if (ret) - goto skip_full_check; - } - env->explored_states = kvcalloc(state_htab_size(env), sizeof(struct bpf_verifier_state_list *), GFP_USER); @@ -12393,6 +12387,12 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, if (ret < 0) goto skip_full_check; + if (bpf_prog_is_dev_bound(env->prog->aux)) { + ret = bpf_prog_offload_verifier_prep(env->prog); + if (ret) + goto skip_full_check; + } + ret = check_cfg(env); if (ret < 0) goto skip_full_check; -- 2.30.2