Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10715620ybi; Thu, 11 Jul 2019 09:48:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7PYosU9SUG4Ja+A4jO5J1qQsAfg0AJ7P7NTCPLnScKCPTyyMnCfD6XqAZN0mUf6/tq4xe X-Received: by 2002:a17:90a:4806:: with SMTP id a6mr6016858pjh.38.1562863684050; Thu, 11 Jul 2019 09:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562863684; cv=none; d=google.com; s=arc-20160816; b=dm6NR1gyFgTsprDTfsp1e2m06IpuYCILUXa7SQHcc+rsyaJLMT5HTkzZbNomUCdEMK WKzWjXZpvNdYzFgZ+MAl0TdszCzzfyD64KTzujmedsU6HPKunoSnHJVnFI9FLpmhzAQr 6sFqkL3WcUbuDhq6e71Xwwb9RkBAHwbodOHW3zgihANsq2w60wIv+un+OzBVVN/MwzcE 2ZF8P3F8pNpjrPeNTwRtvX5Ey5kAJyDTAnEpgc1z/2dT8WWKBy+xaQ0gXVYW2kcqtN74 CpsbB9+T9Rg+0fESRkKhWXCP2telYNrUz6VU/TKh5GvhxSJpXi95W0qT1FgcODw/ZLka 5i2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=/Y41Anz4PY8tXUC0/boJ6gxo5N5WIVNf/ILH0pI02U0=; b=ZoZ0rKrHQkKcCCR7wNFQNOP4QM3km/Xx1QVvWeKYFDo1ip3m+GsTWnR4m9t0yvolqW Uda01aiL+/zAqyNU7RKlkoiznYmnClt6E+X1Kv9dWn/zo/kYVxfwibt97AKrKgLHX06s EQn/VzcOSUKuY2cdUDShNAd5nAW+YA36Y5oDFViAdRD8DagHIyDJlfPzdtaDsFKLw4uv 59wVtNzRxtBd/4llafjmTCV+Ng4iKbnKY+9iNsXLzE0ORNM1kisFRhKsa0ZXntJisKok tdhZzo/Nv9gRc8EstZqnmHeIQV8LM81noMQuJA6OzkGv2w3ToR6A79yvo/WDiedoazFC Xn2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si5670629pfa.17.2019.07.11.09.47.48; Thu, 11 Jul 2019 09:48:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728475AbfGKQrO (ORCPT + 99 others); Thu, 11 Jul 2019 12:47:14 -0400 Received: from gateway20.websitewelcome.com ([192.185.63.14]:42264 "EHLO gateway20.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQrO (ORCPT ); Thu, 11 Jul 2019 12:47:14 -0400 X-Greylist: delayed 1465 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 Jul 2019 12:47:14 EDT Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 70946400D3755 for ; Thu, 11 Jul 2019 10:20:02 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id lbq7hQpXW2PzOlbq7hbajw; Thu, 11 Jul 2019 11:22:35 -0500 X-Authority-Reason: nr=8 Received: from cablelink-187-160-61-213.pcs.intercable.net ([187.160.61.213]:24662 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1hlbq6-002Yit-1g; Thu, 11 Jul 2019 11:22:34 -0500 Date: Thu, 11 Jul 2019 11:22:33 -0500 From: "Gustavo A. R. Silva" To: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Lawrence Brakmo Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Kees Cook Subject: [PATCH][bpf-next] bpf: verifier: avoid fall-through warnings Message-ID: <20190711162233.GA6977@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.160.61.213 X-Source-L: No X-Exim-ID: 1hlbq6-002Yit-1g X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cablelink-187-160-61-213.pcs.intercable.net (embeddedor) [187.160.61.213]:24662 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 15 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to enabling -Wimplicit-fallthrough, this patch silences the following warning: kernel/bpf/verifier.c: In function ‘check_return_code’: kernel/bpf/verifier.c:6106:6: warning: this statement may fall through [-Wimplicit-fallthrough=] if (env->prog->expected_attach_type == BPF_CGROUP_UDP4_RECVMSG || ^ kernel/bpf/verifier.c:6109:2: note: here case BPF_PROG_TYPE_CGROUP_SKB: ^~~~ Warning level 3 was used: -Wimplicit-fallthrough=3 Notice that is much clearer to explicitly add breaks in each case statement (that actually contains some code), rather than letting the code to fall through. This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough. Acked-by: Andrii Nakryiko Signed-off-by: Gustavo A. R. Silva --- NOTE: -Wimplicit-fallthrough will be enabled globally in v5.3. So, I suggest you to take this patch for 5.3-rc1. kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index a2e763703c30..44c3b947400e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6106,11 +6106,13 @@ static int check_return_code(struct bpf_verifier_env *env) if (env->prog->expected_attach_type == BPF_CGROUP_UDP4_RECVMSG || env->prog->expected_attach_type == BPF_CGROUP_UDP6_RECVMSG) range = tnum_range(1, 1); + break; case BPF_PROG_TYPE_CGROUP_SKB: if (env->prog->expected_attach_type == BPF_CGROUP_INET_EGRESS) { range = tnum_range(0, 3); enforce_attach_type_range = tnum_range(2, 3); } + break; case BPF_PROG_TYPE_CGROUP_SOCK: case BPF_PROG_TYPE_SOCK_OPS: case BPF_PROG_TYPE_CGROUP_DEVICE: -- 2.21.0