Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3124882pxb; Tue, 12 Jan 2021 06:59:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxTl9LDzAGjRG564T0yXYEyNT2BrzXJNdIwwEqk65ceknpF5/IUSzMU4jNP5uA/9wSUWtj X-Received: by 2002:a17:906:2898:: with SMTP id o24mr3473878ejd.215.1610463581088; Tue, 12 Jan 2021 06:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610463581; cv=none; d=google.com; s=arc-20160816; b=uytbEJ+q5JWT3qckXnev1PqBgS0AelukDNMI6OFEPNfaH7qyEgG5mbNDOvkRPet8Dm ycl+cYFcwOSbU2G7Bk5PLfCl7FRGvTMUKDABWxqQ0B/EylUlgPDsQXwcx41+ARJ3OT9g kUJaWg+sB7vQtXgR6GK7fn7sxbNyWcOq2tMh8dFrLI2G8OA5oesdPM1CvqAzaek7c7B/ LCtqJHHk2gEoo7oCIB9+tdUaqZemCgnrIPGX8fO9c8/FrVt9WgOWA8qwTXCGettg4J19 /qRQRfDkqfV4eM0GmooYqdGWd5+qdv4rSc++LsxAgdW/1ecEBnewMYkYG8qB986ExHq4 8MZQ== 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=QDvvMWx616tK9iO3ucvHylGVi9etvk47ivicHsgpugs=; b=k7lmLCsa3kyp4y6vjAjM3zjXbGxvChpjLJcSMrALB90Jg36fzaRDJ7U7J0l7/tFo2H BSNc74PwPZeo0l4POP5xYwLIW31Cnf7W8Z5lB6itzf6MYLHL6X4EwwNnZFCUTT2t0GOk C8SaveMueY1pIWAdh4lotLDdzr9R9Dzn4l6MxftAaCieb4dOAJqAmywV236p4tGVmigL 3G5N4/KWHkk0g5zhyAG+18E/2iPe6Cbz5Ct2fKv9wBw8eRv22CFxAxgLTrzhBA2rx8+1 kV+UXmGqcwG3zF2Yej5u3fc8fV34pMTK0COMRcQgHilqF4K7V4uqfLOt1bhiNtBVNBAa 0UGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HwpmcAFh; 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 he34si928939ejc.729.2021.01.12.06.59.15; Tue, 12 Jan 2021 06:59:41 -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=HwpmcAFh; 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 S2388824AbhALO4q (ORCPT + 99 others); Tue, 12 Jan 2021 09:56:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbhALO4q (ORCPT ); Tue, 12 Jan 2021 09:56:46 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBEE8C061786 for ; Tue, 12 Jan 2021 06:56:05 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id r9so4607727ioo.7 for ; Tue, 12 Jan 2021 06:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QDvvMWx616tK9iO3ucvHylGVi9etvk47ivicHsgpugs=; b=HwpmcAFhmQFCHZJ6csLxF4mY8cL2dq0owVZR1ohjtymwUP8rMvihFXlKVXQ9rp/n3k jW6UQuECsvPBvn9NKphG6k1eh0NL89x5rvrSrlUVN6Kt2HQZDkPOn+VRQtYuo3LmK/yU fbo7SCQFOoVPrE0Po0Ck2A25MKhRmrI4/9jXicTn4GGqeuuRxEAY4cxYojA4FxV7kx54 JRf/clYk9Wv92D43EgK6HjU6KhoeMYRRv7IjAexId7q5SM9Z21qrpg9eCGm8Nn1lauu2 THJx8PkGdHFbuWFjOj/eYzs2iCZM/f9tyEV2z7TYz/Oh/ZCjQXjd5dNmQEI/xrQjBHxS dbZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QDvvMWx616tK9iO3ucvHylGVi9etvk47ivicHsgpugs=; b=XSRVSYuYP2lTmFyXrxL+5+OfYlDa7XBKHYCQ7EYnZduh3JPh6Qf9Yj3wKYwacaqFH+ l5glRuU5nK7HnHb1Ofqm8ynRRx2hfZz9ouTOJWZ3f+jxGrThf9jI+nYd7Q1VEmJSgUEC /0uPi/mZHDSVf2HjR9Yzn2OklC1X695L/0yS/1yqXiJ1mFDr85G2LwHdTkWKtjhcqbKI rekXguy+ICfRrrvuRODjTlmykJed9o/gKhYmqUcJqC77Y2KGJavO9C8EbmBJZ+qLoDBg ODsh3pGWAQFjJ9uHx0394m9VIpkEe8Bx0IGsPqZzBgRli2UWUB4X51iJBRgFqwIhakvy yrng== X-Gm-Message-State: AOAM5317iGKe7Y10dTBxM4kS+FsjecCAXy2P8Zpj3Xc+J3kvrJXXPpOB mq0RsD+h+nwkyWY8Ka3bNiUm64c/XS99WeFestfLtg== X-Received: by 2002:a6b:e805:: with SMTP id f5mr3582199ioh.199.1610463364992; Tue, 12 Jan 2021 06:56:04 -0800 (PST) MIME-Version: 1.0 References: <20210112123913.2016804-1-jackmanb@google.com> In-Reply-To: From: Brendan Jackman Date: Tue, 12 Jan 2021 15:55:54 +0100 Message-ID: Subject: Re: [PATCH bpf-next] bpf: Fix a verifier message for alloc size helper arg To: KP Singh 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 Sorry, duplicate - seems I had my mail client in HTML mode the first time around. On Tue, 12 Jan 2021 at 14:14, KP Singh wrote: > > 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. I think that would work because var is already a known constant before the conditional.. but the error message is still wrong, the `if (var < 2000)` is irrelevant. If var was not already a known constant (e.g. came from the return value of a bpf_probe_read_kernel_str) it would fail verification.