From patchwork Mon Jul 8 12:57:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168638 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp6516421ock; Mon, 8 Jul 2019 05:58:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqk2iOeA0fwRWObM1H9SMqkXZ5ptpVecbPUFVb7UcZbtqVR6Ouos8QuH5ZinJbXW/gSrK4 X-Received: by 2002:a65:4347:: with SMTP id k7mr23854423pgq.253.1562590688855; Mon, 08 Jul 2019 05:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562590688; cv=none; d=google.com; s=arc-20160816; b=XfL3fhazZG7oOcl1QuNvCBc/ggsVsHnxEB9R6ezLZ65cUWfB6KrGmZooUsU3I8dweH P0OZXpaoKTFZIzIM85QRlqKY9irURuYpjU/hG7AyAGRNdw+6IHe20G7kraCwBSARcgmN D/lZlEQ16aokIzRXPKuiJaW9au20kFpGsmpIsK2y9ET1YkRsragmQjuTg8nrqSDiyh/6 2mcVB5KQ8NC0uaVraMC1lrEGjQqHM68wZOXwc9pCbNd1/HwPDXxl8jjgZtgrIrHS/Lj8 cxXunRb8cNxsayH+qujuCsi0WjNT+zx/uqBWawUaxjSfXhOQXGKyzrQZEE1xsUkA+XvX Ppww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Z9Nmqecwk14B3eH6P7ej9QysW7aOnUar421XcxTW6r8=; b=B8f0TiczsuMvkLf5Ug7+YrAFSjYUY90+Rro77gP2BqwrL8G0WJeqOoLqXcShybAwxg 1o0PjlXnJcUZW7iCf0glE4ReTou1qEygfgPVy3xIlh+C2YZjy188CDq0HKLLsgIG3cri R4R6KgPMInbBLuKaOHGOp7pWMd2XVfbP31jgXwtl/Cse5AKAGkh57e5FvzYTWmhyPSDa jhvd8JUvO1fiTIgeBNVwpqLTJQWeJnwOs2ptowzGk/D0v8NLM6DB4rSgHqNM4wd5kWK1 AOJVChbIFojvddj0x7/raR7EhJERohFrGYqMH8nEMR0xoINFqWj44EKWgH8B4aEErG+A yJyA== 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 b20si19602088pfo.108.2019.07.08.05.58.08; Mon, 08 Jul 2019 05:58:08 -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 S1731142AbfGHM6G (ORCPT + 30 others); Mon, 8 Jul 2019 08:58:06 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:37735 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731040AbfGHM6G (ORCPT ); Mon, 8 Jul 2019 08:58:06 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mum6l-1iaeG21g8p-00rq0e; Mon, 08 Jul 2019 14:57:37 +0200 From: Arnd Bergmann To: Alexei Starovoitov , Daniel Borkmann Cc: Arnd Bergmann , Andrii Nakryiko , Martin Lau , Stanislav Fomichev , Song Liu , Yonghong Song , Mauricio Vasquez B , Roman Gushchin , Matt Mullins , Willem de Bruijn , Andrey Ignatov , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/2] bpf: skip sockopt hooks without CONFIG_NET Date: Mon, 8 Jul 2019 14:57:20 +0200 Message-Id: <20190708125733.3944836-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:VrGP90r317E+s+6oz2WhDCGWJPQqPhdlxp6EpqxIk9C3kEmwIzs nLRM3xVjN7Zuqn+sBWKdmizbsrCbzbKwwOqlaljyycaUGCNzy9rV6hV9Bx+j37Iwt/XN27b Bw/44BXMzSEKz7UopYgpb8dNFsSi8O4W/NnTshCXfLeVLG/Y6KvaxAh7yKH+S6kXkt31Tl3 Dxlpi23Syxtz7fBjE4xXQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:bL4qJrT3mgk=:RQAROGmY0HunZUona7GTgx uLRbBC8O2LoUaRweQqa28Eh5usWoDfAPA1c5eorEgkv+b/Z38FjfdbqJvaxr9UPzvvAiiAwRi yn8wzn9w0vzTTjW5QvTNORYJ4TvC/neGLWMzLr5C/VV74iPsyn5r7vtBdfsZ/YqhnFusxhE4Y qjFgEykkP7QY9l7mp77MbTE+fwS3o3Lf//wraNloFVvsbvUsVB+lGcBgNUcBjBa0beSAKxZEu TS8g75zsKJ6OyECzrxHY83bgw02K9CaaRKoeqSFWiV5nr/RlMx1rdZgdvkghd2NSUhp1iW741 SrmL9fZTS0XJhVBn4DiHCr6PpNIXVNpR26ZIbn4i3Ou00ATjKEkHBRSOj85JY+7+j7FALf4Fq jHPpyLsQCpChXIpo7RLfO4FROIGHtsjhl5UJgCHixdIhpA4yNG8T5kSY4lxqQNdMaJWXYc820 8YjopQY6IuZ3M5su8Pw8mBfOyRjyetWRr5F5aJ/cuZtkMMHAnRwl+d4kEOnKcA7xGlSQ6z8QG xfnFSKzbhPTAV2B4f4hH0TDWNjKybnpwDFUQa9fmTRhCxx1EHz/r5pOmXpAMz8aibDC1R1ZNQ rBGRhCip+M+DUFqolTaI3cuuZtnyf5oTsJZ3V3e3q4RpqLJ+VBkQdWw00XqVmQcU2ypaZQoir /5btpBE1w4cgnfiJzodR7bv5DaDkxu2BzxZWeLXzceapDBdG0zRPE4Ic/oDkrKv9+pNLv3W/l s5CXgjbL8gOk7o1S3a3McrEEQtDaWdjqRtJyfQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_NET is disabled, we get a link error: kernel/bpf/cgroup.o: In function `__cgroup_bpf_run_filter_setsockopt': cgroup.c:(.text+0x3010): undefined reference to `lock_sock_nested' cgroup.c:(.text+0x3258): undefined reference to `release_sock' kernel/bpf/cgroup.o: In function `__cgroup_bpf_run_filter_getsockopt': cgroup.c:(.text+0x3568): undefined reference to `lock_sock_nested' cgroup.c:(.text+0x3870): undefined reference to `release_sock' kernel/bpf/cgroup.o: In function `cg_sockopt_func_proto': cgroup.c:(.text+0x41d8): undefined reference to `bpf_sk_storage_delete_proto' None of this code is useful in this configuration anyway, so we can simply hide it in an appropriate #ifdef. Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks") Signed-off-by: Arnd Bergmann --- include/linux/bpf_types.h | 2 ++ kernel/bpf/cgroup.c | 6 ++++++ 2 files changed, 8 insertions(+) -- 2.20.0 diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h index eec5aeeeaf92..3c7222b2db96 100644 --- a/include/linux/bpf_types.h +++ b/include/linux/bpf_types.h @@ -30,8 +30,10 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, raw_tracepoint_writable) #ifdef CONFIG_CGROUP_BPF BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_DEVICE, cg_dev) BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SYSCTL, cg_sysctl) +#ifdef CONFIG_NET BPF_PROG_TYPE(BPF_PROG_TYPE_CGROUP_SOCKOPT, cg_sockopt) #endif +#endif #ifdef CONFIG_BPF_LIRC_MODE2 BPF_PROG_TYPE(BPF_PROG_TYPE_LIRC_MODE2, lirc_mode2) #endif diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 76fa0076f20d..7be44460bd93 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -590,6 +590,7 @@ int cgroup_bpf_prog_query(const union bpf_attr *attr, return ret; } +#ifdef CONFIG_NET /** * __cgroup_bpf_run_filter_skb() - Run a program for packet filtering * @sk: The socket sending or receiving traffic @@ -750,6 +751,7 @@ int __cgroup_bpf_run_filter_sock_ops(struct sock *sk, return ret == 1 ? 0 : -EPERM; } EXPORT_SYMBOL(__cgroup_bpf_run_filter_sock_ops); +#endif int __cgroup_bpf_check_dev_permission(short dev_type, u32 major, u32 minor, short access, enum bpf_attach_type type) @@ -939,6 +941,7 @@ int __cgroup_bpf_run_filter_sysctl(struct ctl_table_header *head, } EXPORT_SYMBOL(__cgroup_bpf_run_filter_sysctl); +#ifdef CONFIG_NET static bool __cgroup_bpf_prog_array_is_empty(struct cgroup *cgrp, enum bpf_attach_type attach_type) { @@ -1120,6 +1123,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, return ret; } EXPORT_SYMBOL(__cgroup_bpf_run_filter_getsockopt); +#endif static ssize_t sysctl_cpy_dir(const struct ctl_dir *dir, char **bufp, size_t *lenp) @@ -1382,6 +1386,7 @@ const struct bpf_verifier_ops cg_sysctl_verifier_ops = { const struct bpf_prog_ops cg_sysctl_prog_ops = { }; +#ifdef CONFIG_NET static const struct bpf_func_proto * cg_sockopt_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) { @@ -1531,3 +1536,4 @@ const struct bpf_verifier_ops cg_sockopt_verifier_ops = { const struct bpf_prog_ops cg_sockopt_prog_ops = { }; +#endif