From patchwork Wed Jan 16 18:43:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Oskolkov X-Patchwork-Id: 1026111 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="VnqFpY/k"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43fx0s4nPzz9sLt for ; Thu, 17 Jan 2019 05:43:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729360AbfAPSnH (ORCPT ); Wed, 16 Jan 2019 13:43:07 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:41290 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728621AbfAPSnH (ORCPT ); Wed, 16 Jan 2019 13:43:07 -0500 Received: by mail-yw1-f73.google.com with SMTP id q185so3428633ywf.8 for ; Wed, 16 Jan 2019 10:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=G1U6oHEJ9qoVCJYEyAowKy1w3Xv+3l2a/k9lJkmpv0M=; b=VnqFpY/kaUKt1ck0Z2DTWg2sbIFrAWg76aZhp9bLjZ1VCBPpaxIOFCxdrXnpQAyXkY D/Qp8w7RBNmzHAvCf5YHGP4tD/YLg69PP6a0wFLeDGPxsVgtzvTLgg3kLyHcSf0TMVjQ rwZCFkLUZGFNwpqWIrLwgRWjQI8ah7HP0Zu/cJzW3NYkD36Z7EJZHcqcDIoFh5/IEF2T 6aQ4jKZa686BI3+M1eBnvkN/zOtKNd+A0B8/tvs1yarKoP3tCdTQAYPrm8IwN901c3PR 5h875QsKUMHFw7Mm05KKnTWj8ppMjjBd3Zgybca324cLs5cO1bUxXswgCxzAxIz9mo5K vVdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=G1U6oHEJ9qoVCJYEyAowKy1w3Xv+3l2a/k9lJkmpv0M=; b=Rdi6Gcz3Nu/4vGM3H7E0Z5pSwXCzq2FpHa8AwOxJejsHaA7xZLr5VeQvG9vQxoD/ox Lv6Ym7yOKRUNfsmT9jS7ZHOKvh8wNUUlK7cMTJCEvCpvKwtvAzXLoyK+cnxqw5h5zPhw SuM4tyEGvF9dMMhv/C8hiHhLnCN3HeoFTngKVSmSHvdEPpMm9I7cfShkFmYto12TD5Po s/HVmW3uzKxAobOLRROFgYrBuRpUSEBIZzcQk+5/yH2CuM2jt4FZBwSVBtHtk8LoF3pT 7mdkzzc6bdFSBVaD2LviFIYDuO053NYkxjvIXhTn2DOt1ppQlIjjBIpSN+g+TfFvIlcB c6eg== X-Gm-Message-State: AJcUukeWHpSesy8QglgoRC19uT+ozrPmY2uzny9klj5gy/0f/qCML71Q FkRPN9aMrA+eEGXuoxAiaCsS+c80 X-Google-Smtp-Source: ALg8bN46X2Sg4QICg1qzIwquazHm53xjU7OJZOdoLve2gVEDGccewkKlZdQCWllug7c0NwaDOXv4eaS/ X-Received: by 2002:a81:6fd6:: with SMTP id k205mr4440699ywc.23.1547664186716; Wed, 16 Jan 2019 10:43:06 -0800 (PST) Date: Wed, 16 Jan 2019 10:43:01 -0800 Message-Id: <20190116184301.218106-1-posk@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog Subject: [PATCH bpf-next v2] bpf: fix a (false) compiler warning From: Peter Oskolkov To: Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org Cc: Peter Oskolkov , Martin KaFai Lau , Peter Oskolkov Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An older GCC compiler complains: kernel/bpf/verifier.c: In function 'bpf_check': kernel/bpf/verifier.c:4***:13: error: 'prev_offset' may be used uninitialized in this function [-Werror=maybe-uninitialized] } else if (krecord[i].insn_offset <= prev_offset) { ^ kernel/bpf/verifier.c:4***:38: note: 'prev_offset' was declared here u32 i, nfuncs, urec_size, min_size, prev_offset; Although the compiler is wrong here, the patch makes sure that prev_offset is always initialized, just to silence the warning. v2: fix a spelling error in the commit message. Signed-off-by: Peter Oskolkov Acked-by: Martin KaFai Lau --- kernel/bpf/verifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 56674a7c3778..ce87198ecd01 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -4997,13 +4997,14 @@ static int check_btf_func(struct bpf_verifier_env *env, const union bpf_attr *attr, union bpf_attr __user *uattr) { - u32 i, nfuncs, urec_size, min_size, prev_offset; + u32 i, nfuncs, urec_size, min_size; u32 krec_size = sizeof(struct bpf_func_info); struct bpf_func_info *krecord; const struct btf_type *type; struct bpf_prog *prog; const struct btf *btf; void __user *urecord; + u32 prev_offset = 0; int ret = 0; nfuncs = attr->func_info_cnt;