Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4221456pxb; Tue, 10 Nov 2020 10:44:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxb+9joIdRRmWnyz5odaNEEZw324ox5AHELM+Nrq0lEFjpS3OinlBekLnDEqb4vcobOqBpw X-Received: by 2002:a17:906:5841:: with SMTP id h1mr20945183ejs.342.1605033894810; Tue, 10 Nov 2020 10:44:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605033894; cv=none; d=google.com; s=arc-20160816; b=gtmZ+57l+X3Qh1xNtTCWoDuXH8+1g81qmtN7s5LyvyjKMOqMf5vum14j8+PvwIZ/Bs 5m0qdAQDP9ZziXqkFL7YpGJiYMgpQMVStg2Y89jS1P1e45BrmbIjk13SiBm1oGoWPCyF NuqcgbNJWSzYbj0VMSBvrs1JfT0lbz8d657qnH/5ZmswC5Zo+TxeFo91jynniFQ0dB1Z k9gVCW3eaFK0TBilBIJ+sTrRLT8p0FYCVBmy9IK6y2xS5M7RRqQMD8G6bmyBqXy0qGFs SeNM9MFnjzMTYPSHXP5zVrpcsRAgGszOWqL0YIzm+tyBF+Xp64hvguzknlhwPKiERntL /mfQ== 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=wpJ5lPaXtgiF4jb8/8Ul562NL/AWQ6eFgS7XO9bceks=; b=jCH1cqPB2RFNAneIk9DrAH6WF9GqOAxUIQgi4uk56OpFeTMwdRBkT7Zy3CsNOwEp/V DEM6d0V+p9cw9lS2TTXsYH2te5LjdefakgvtQl72l5YSGvCQ6xd1U+CdzQcDMZd4mbtg efCCezOvkvNnRWZuUUruICi9tl9oochbxyC2ebjPzpKpMK9W4tcRP3mTsLtqt93gnM4a LgdeWZlFDNE0X4pnmvgGr8X2qz5/V2Dc9k3LGXRa56ooETEaovYW8eP15ZNGLWYGa1Az eCCFapbi/w95OLLnJGfnWg4BXFicKEB27wKj1zKhHpJrHojW9yFP7IoSVyhrkAKj8S3q MBJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="RUT1/dsG"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si7266368ejr.580.2020.11.10.10.44.31; Tue, 10 Nov 2020 10:44:54 -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=@gmail.com header.s=20161025 header.b="RUT1/dsG"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbgKJSlY (ORCPT + 99 others); Tue, 10 Nov 2020 13:41:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgKJSlX (ORCPT ); Tue, 10 Nov 2020 13:41:23 -0500 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11414C0613D1; Tue, 10 Nov 2020 10:41:22 -0800 (PST) Received: by mail-yb1-xb42.google.com with SMTP id t33so285041ybd.0; Tue, 10 Nov 2020 10:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wpJ5lPaXtgiF4jb8/8Ul562NL/AWQ6eFgS7XO9bceks=; b=RUT1/dsGddDLZa8O7Lq0juEg8peHH5XcGzBzWdLs34c6F0zj0kiTRxktHDdyPhNrwa BvBVz0d+vyLRXhkGNy9P9MapxdSbt26mPeIUhhkMxxL9oJDZnHep3rPkY7/aaLo1ZtWS HbOVkEsxgIjjkZOvoWCf85lUzoVKe+f1zMvKTIZdA2TjbdUbKZ5Yaq7TUO/1Kziya0Gv omGaOpVFUov/1t19chQRY/j3nq7b7hcjo4f3hi/IvAIK5mUmfNcwP2R+O+mZbmp5AlvO wwIVGpRV6s7UvHa7LM/Y+JIMWP+VdfKoRzZmAL3+yGgo5Ng6a+MTocgRsxY+VUCFGzER qAFg== 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=wpJ5lPaXtgiF4jb8/8Ul562NL/AWQ6eFgS7XO9bceks=; b=FYq+PsNCBwLboVLqsCSQ+gWDWM+Zs3WOdC2jYUWpiEShy+3jiXjBYUKGi9uzt/sunQ tNJJX4vqGLERjdqiIt/KRJmFj0aTmKWZAQLid4dzr/BDPq8Xrcr/OQWFAAdZI6HqrdFO 5la0QnH/JsAw8y1BY0vMhVbZuPHf0BRaEyF4c5/YS0VdcYyhaHlb3a4H7ZtJIqaRpXKy CpPccQE8OxzB7c+0YS5L/+iTRxZlfX8b6NDVpJ+oSAWhhnjXZd36QV/8SxNN5xQMswLc yeGZytGhRIuujZV2iOm/yoyBw/+iIg7hcrBN5foChL7MZ6qy1V9GM4B65fa1mDg6Wpfk vj8g== X-Gm-Message-State: AOAM532xuELJ66ekKhcVrVShJ3u1km7Wt278NHd1W4WcHHu668JRpskJ Rx/2fXQn19O5Tkg/Cs0oux40fmm2Pij0Msq3RnM= X-Received: by 2002:a25:e701:: with SMTP id e1mr3977083ybh.510.1605033681253; Tue, 10 Nov 2020 10:41:21 -0800 (PST) MIME-Version: 1.0 References: <1605009019-22310-1-git-send-email-kaixuxia@tencent.com> In-Reply-To: <1605009019-22310-1-git-send-email-kaixuxia@tencent.com> From: Andrii Nakryiko Date: Tue, 10 Nov 2020 10:41:10 -0800 Message-ID: Subject: Re: [PATCH] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id To: xiakaixu1987@gmail.com Cc: Alexei Starovoitov , Daniel Borkmann , Martin Lau , Song Liu , Yonghong Song , Andrii Nakryiko , john fastabend , KP Singh , Networking , bpf , open list , Kaixu Xia Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 3:50 AM wrote: > > From: Kaixu Xia > > The unsigned variable datasec_id is assigned a return value from the call > to check_pseudo_btf_id(), which may return negative error code. > > Fixes coccicheck warning: > > ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0 > > Reported-by: Tosk Robot > Signed-off-by: Kaixu Xia > --- > 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 6200519582a6..e9d8d4309bb4 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -9572,7 +9572,7 @@ static int check_pseudo_btf_id(struct bpf_verifier_env *env, > struct bpf_insn *insn, > struct bpf_insn_aux_data *aux) > { > - u32 datasec_id, type, id = insn->imm; > + s32 datasec_id, type, id = insn->imm; you are changing types for type and id variables here, so split out datasec_id definition into a separate line > const struct btf_var_secinfo *vsi; > const struct btf_type *datasec; > const struct btf_type *t; > -- > 2.20.0 >