Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
authorDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2020 02:52:37 +0000 (19:52 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2020 02:52:37 +0000 (19:52 -0700)
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
1  2 
MAINTAINERS
include/linux/bpf.h
include/linux/netdevice.h
include/uapi/linux/if_link.h
init/Kconfig
kernel/bpf/btf.c
kernel/bpf/cgroup.c
kernel/bpf/syscall.c
kernel/trace/bpf_trace.c
net/core/dev.c
net/ipv4/bpf_tcp_ca.c
net/ipv4/udp.c
tools/include/uapi/linux/if_link.h

diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc init/Kconfig
Simple merge
Simple merge
index 4f1472409ef8f18cc5965a7f1822b88d5d91aceb,80676fc00d81984c48ad3bf0c72ec3e5201a8e95..cb305e71e7deb9201d8fb94173a567b1e286ed81
@@@ -305,10 -418,9 +421,9 @@@ int __cgroup_bpf_attach(struct cgroup *
        u32 saved_flags = (flags & (BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI));
        struct list_head *progs = &cgrp->bpf.progs[type];
        struct bpf_prog *old_prog = NULL;
 -      struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE],
 -              *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {NULL};
 +      struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {};
 +      struct bpf_cgroup_storage *old_storage[MAX_BPF_CGROUP_STORAGE_TYPE] = {};
-       struct bpf_prog_list *pl, *replace_pl = NULL;
-       enum bpf_cgroup_storage_type stype;
+       struct bpf_prog_list *pl;
        int err;
  
        if (((flags & BPF_F_ALLOW_OVERRIDE) && (flags & BPF_F_ALLOW_MULTI)) ||
index f00c00b942dfc4646a9ba553ceb51ea468c60b59,e0a3b34d70396a81ca089aed5d7393176e0a057f..64783da342020212f12a1a57212b16e330786b5f
@@@ -3564,9 -3550,107 +3560,107 @@@ err_put
        return err;
  }
  
+ #define BPF_LINK_CREATE_LAST_FIELD link_create.flags
+ static int link_create(union bpf_attr *attr)
+ {
+       enum bpf_prog_type ptype;
+       struct bpf_prog *prog;
+       int ret;
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+       if (CHECK_ATTR(BPF_LINK_CREATE))
+               return -EINVAL;
+       ptype = attach_type_to_prog_type(attr->link_create.attach_type);
+       if (ptype == BPF_PROG_TYPE_UNSPEC)
+               return -EINVAL;
+       prog = bpf_prog_get_type(attr->link_create.prog_fd, ptype);
+       if (IS_ERR(prog))
+               return PTR_ERR(prog);
+       ret = bpf_prog_attach_check_attach_type(prog,
+                                               attr->link_create.attach_type);
+       if (ret)
+               goto err_out;
+       switch (ptype) {
+       case BPF_PROG_TYPE_CGROUP_SKB:
+       case BPF_PROG_TYPE_CGROUP_SOCK:
+       case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
+       case BPF_PROG_TYPE_SOCK_OPS:
+       case BPF_PROG_TYPE_CGROUP_DEVICE:
+       case BPF_PROG_TYPE_CGROUP_SYSCTL:
+       case BPF_PROG_TYPE_CGROUP_SOCKOPT:
+               ret = cgroup_bpf_link_attach(attr, prog);
+               break;
+       default:
+               ret = -EINVAL;
+       }
+ err_out:
+       if (ret < 0)
+               bpf_prog_put(prog);
+       return ret;
+ }
+ #define BPF_LINK_UPDATE_LAST_FIELD link_update.old_prog_fd
+ static int link_update(union bpf_attr *attr)
+ {
+       struct bpf_prog *old_prog = NULL, *new_prog;
+       struct bpf_link *link;
+       u32 flags;
+       int ret;
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+       if (CHECK_ATTR(BPF_LINK_UPDATE))
+               return -EINVAL;
+       flags = attr->link_update.flags;
+       if (flags & ~BPF_F_REPLACE)
+               return -EINVAL;
+       link = bpf_link_get_from_fd(attr->link_update.link_fd);
+       if (IS_ERR(link))
+               return PTR_ERR(link);
+       new_prog = bpf_prog_get(attr->link_update.new_prog_fd);
+       if (IS_ERR(new_prog))
+               return PTR_ERR(new_prog);
+       if (flags & BPF_F_REPLACE) {
+               old_prog = bpf_prog_get(attr->link_update.old_prog_fd);
+               if (IS_ERR(old_prog)) {
+                       ret = PTR_ERR(old_prog);
+                       old_prog = NULL;
+                       goto out_put_progs;
+               }
+       }
+ #ifdef CONFIG_CGROUP_BPF
+       if (link->ops == &bpf_cgroup_link_lops) {
+               ret = cgroup_bpf_replace(link, old_prog, new_prog);
+               goto out_put_progs;
+       }
+ #endif
+       ret = -EINVAL;
+ out_put_progs:
+       if (old_prog)
+               bpf_prog_put(old_prog);
+       if (ret)
+               bpf_prog_put(new_prog);
+       return ret;
+ }
  SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
  {
 -      union bpf_attr attr = {};
 +      union bpf_attr attr;
        int err;
  
        if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN))
Simple merge
diff --cc net/core/dev.c
Simple merge
Simple merge
diff --cc net/ipv4/udp.c
Simple merge
Simple merge