From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0AFCBC433EF for ; Wed, 18 May 2022 03:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9cl5f8JZ3PbCmd8npcbzmi1Kiiq5iBCwM5fPLvfwRZQ=; b=pg5CjG2W0u+l5I +n30M7fx+JtHq5nJ/pWDOmP/LCPy1M7xfCkI88wZQh0+wbgMwS9RZ4kJWjb7/xjYVFZ0NwdFDh4qi qsAdDxeLFgw+feuweQytrTy0J4Ei1mZD7bRXFt4ASKd07uaZXzzvpNGh/uty0GvfjZzOKyDPvXdPd EWdRyUPi48e0XfOTy9FiDu6iFQobTUTo4WR3z73dTuCxsKArSWDQJbw2eIReywLIwaoxSnqiQhWb6 +krx6KgD7dr0HjWgZ0DKi+blzcSm+lgO5YbXgdeK7fWeBl+lUO0TYVG+2AOBGB3/FwDR2j+GYuIe2 6mpHKvHe8XoFcAVrJNHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrATe-00Gv0A-QE; Wed, 18 May 2022 03:35:58 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrATa-00GuzS-09 for linux-arm-kernel@lists.infradead.org; Wed, 18 May 2022 03:35:56 +0000 Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L2zB823mRz1JCCQ; Wed, 18 May 2022 11:34:24 +0800 (CST) Received: from [10.67.111.192] (10.67.111.192) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 18 May 2022 11:35:44 +0800 Message-ID: Date: Wed, 18 May 2022 11:35:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH bpf-next v4 3/6] bpf: Move is_valid_bpf_tramp_flags() to the public trampoline code Content-Language: en-US To: Alexei Starovoitov CC: , , , , , Catalin Marinas , Will Deacon , Steven Rostedt , Ingo Molnar , Daniel Borkmann , Alexei Starovoitov , Zi Shen Lim , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Thomas Gleixner , Borislav Petkov , Dave Hansen , , , Shuah Khan , Jakub Kicinski , Jesper Dangaard Brouer , Mark Rutland , Pasha Tatashin , Ard Biesheuvel , Daniel Kiss , Steven Price , Sudeep Holla , Marc Zyngier , Peter Collingbourne , Mark Brown , Delyan Kratunov , Kumar Kartikeya Dwivedi References: <20220517071838.3366093-1-xukuohai@huawei.com> <20220517071838.3366093-4-xukuohai@huawei.com> <20220517155349.4jk5oymnjvrasw2p@MacBook-Pro.local> From: Xu Kuohai In-Reply-To: <20220517155349.4jk5oymnjvrasw2p@MacBook-Pro.local> X-Originating-IP: [10.67.111.192] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220517_203554_413960_BF854021 X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/17/2022 11:53 PM, Alexei Starovoitov wrote: > On Tue, May 17, 2022 at 03:18:35AM -0400, Xu Kuohai wrote: >> >> +static bool is_valid_bpf_tramp_flags(unsigned int flags) >> +{ >> + if ((flags & BPF_TRAMP_F_RESTORE_REGS) && >> + (flags & BPF_TRAMP_F_SKIP_FRAME)) >> + return false; >> + >> + /* BPF_TRAMP_F_RET_FENTRY_RET is only used by bpf_struct_ops, >> + * and it must be used alone. >> + */ >> + if ((flags & BPF_TRAMP_F_RET_FENTRY_RET) && >> + (flags & ~BPF_TRAMP_F_RET_FENTRY_RET)) >> + return false; >> + >> + return true; >> +} >> + >> +int bpf_prepare_trampoline(struct bpf_tramp_image *tr, void *image, >> + void *image_end, const struct btf_func_model *m, >> + u32 flags, struct bpf_tramp_links *tlinks, >> + void *orig_call) >> +{ >> + if (!is_valid_bpf_tramp_flags(flags)) >> + return -EINVAL; >> + >> + return arch_prepare_bpf_trampoline(tr, image, image_end, m, flags, >> + tlinks, orig_call); >> +} > > It's an overkill to introduce a new helper function just to validate > flags that almost compile time constants. > The flags are not user supplied. > Please move /* BPF_TRAMP_F_RET_FENTRY_RET is only used by bpf_struct_ops ... */ > comment to bpf_struct_ops.c right before it calls arch_prepare_bpf_trampoline() > And add a comment to trampoline.c saying that BPF_TRAMP_F_RESTORE_REGS > and BPF_TRAMP_F_SKIP_FRAME should not be set together. > We could add a warn_on there or in arch code, but feels like overkill. > . OK, will fix in next version. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel