Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3529637pxb; Tue, 12 Jan 2021 17:43:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/updCRHY+SWeTS9+570PJ8fih+z3VAGOWvuqiOgPI8JxywYDWduIX2GZhiOkwQcqCT8Wr X-Received: by 2002:a17:906:ce3c:: with SMTP id sd28mr1101906ejb.485.1610502204674; Tue, 12 Jan 2021 17:43:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610502204; cv=none; d=google.com; s=arc-20160816; b=n1t7805iQcvX6r2GiXGIK/0BtVv9BG0p0udTGqKg/6WU/+Hyc6jA4pP8lmHz/Vm+TU /F+klDMU9S7HJKTJht8qxJZcF/A0YsThe6g2emhGDBaduSkKdOTkyKbySpyfDM7ERA0O aYyKLVN+US0/xVzxAWNF8VqhbcO2BBvc/s/IWHc0cupJrKfS8dSx/WFsO3yZZeNOXgrX 1c5lV/WVb2aPfcf+3v/njD3uI6zV1PLLI90v9u31EYA3QqjmWKotzRMCjqQ8LaRvW7n9 kRLTSpB/56nVG8aR84qeW//EKxKg9SqfiqQb6GkzkBP0DaSoUy3B0Np7xVpeR4/vd++2 zTJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oGEsxeuBhYqqHsNwxFzdgFhpQp6REHOHOYrb8MsOKgA=; b=YsIGxPEUnvNo2jwBYOlFVEMqK946tX0d+Wd1c46e9BUnM+n67JsgV79ySQWL2s7x41 NQUcmK6FdbsB5lNLy7lbXRCJbVqlFYKfBnfCbR4/qO+x4MeleyaSHNXLefKIY1z8RE90 iw1lEeosG9eF1yAeOapu9fTina1M/AsuZAq1amuYbhSyDPaKhPx1EJwQc+SNa2p6br5X NnPxVSqmx8qOx0KT//BjA5+zYv7gtYAkD3yhatca63dHAn7BohnLdWfshQihmHx0/E+m pK0ZpDsXUs8ZbR6IQ+HNX8Nqf4WSKOj3Aq7bv1X06GQYQT/bFuQZittor43QfHPKJ7xc bwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o4GysrNU; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si224125eji.498.2021.01.12.17.43.01; Tue, 12 Jan 2021 17:43:24 -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=@kernel.org header.s=k20201202 header.b=o4GysrNU; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728772AbhALNQD (ORCPT + 99 others); Tue, 12 Jan 2021 08:16:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:36302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730108AbhALNP2 (ORCPT ); Tue, 12 Jan 2021 08:15:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 096942311B for ; Tue, 12 Jan 2021 13:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610457287; bh=It8hwsp3kwp1MvkNdVmaMkspUPQDFXCoPYoDzNp0vNM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=o4GysrNUvsz6jY7oQOolIbtbyYa48PoscnI2HyAHnhrUQYJT5vZuOsMQWMC/wKIJT e3I2japtQOKmAckkhR5xWb+gmVB3i2ENbhesUp4y4ako8odS8ySND1cRorSaIF2mZT C2C8M100rRnZj8w7As/XK0Sg10+OEyMdmUqt7QYz7b2RaaUuHUonAl9uMSnr6jT0gb vyF2sh4kc+9FYiWNFGJWrhqcX06swnRiJTySHcIWXRkdJbXR/86w6ipzzuxSUf0CvT +Wn6abfsgjIYYXbHZ9IBKrYJHIFyseY1QMGuoTRyPsofWCbD1id2x663Y2/cAMR0ar ZXDwmqhGsmxcQ== Received: by mail-lf1-f52.google.com with SMTP id o17so3308600lfg.4 for ; Tue, 12 Jan 2021 05:14:46 -0800 (PST) X-Gm-Message-State: AOAM531Kkfx7ziMn7uNFOKhVYqxBjyr8bdLrDmi2VSP+LxraN/qPrP7+ 4iti/rN50MrDo+erY1qAV/Mt4YP//Iz+sAfGjsVs4g== X-Received: by 2002:a19:810:: with SMTP id 16mr2237205lfi.233.1610457285057; Tue, 12 Jan 2021 05:14:45 -0800 (PST) MIME-Version: 1.0 References: <20210112123913.2016804-1-jackmanb@google.com> In-Reply-To: <20210112123913.2016804-1-jackmanb@google.com> From: KP Singh Date: Tue, 12 Jan 2021 14:14:33 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next] bpf: Fix a verifier message for alloc size helper arg To: Brendan Jackman Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Florent Revest , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 1:39 PM Brendan Jackman wrote: > > The error message here is misleading, the argument will be rejected > unless it is a known constant. > > Signed-off-by: Brendan Jackman > --- > kernel/bpf/verifier.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index 17270b8404f1..5534e667bdb1 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -4319,7 +4319,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, > err = mark_chain_precision(env, regno); > } else if (arg_type_is_alloc_size(arg_type)) { > if (!tnum_is_const(reg->var_off)) { > - verbose(env, "R%d unbounded size, use 'var &= const' or 'if (var < const)'\n", Can you check if: int var = 1000; var += 1; if (var < 2000) // call helper and then using var in the argument works? If so, the existing error message would be correct. > + verbose(env, "R%d is not a known constant'\n", > regno); > return -EACCES; > } > > base-commit: e22d7f05e445165e58feddb4e40cc9c0f94453bc > -- > 2.30.0.284.gd98b1dd5eaa7-goog >