From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Ignatov Subject: [PATCH bpf-next 0/5] bpf: Hooks for sys_sendmsg Date: Fri, 18 May 2018 19:21:08 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Cc: Andrey Ignatov , , , , To: Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:59160 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbeESCVo (ORCPT ); Fri, 18 May 2018 22:21:44 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4J2JGeB022800 for ; Fri, 18 May 2018 19:21:43 -0700 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2j27wb8ape-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 18 May 2018 19:21:43 -0700 Sender: netdev-owner@vger.kernel.org List-ID: This path set adds BPF hooks for sys_sendmsg similar to existing hooks for sys_bind and sys_connect. Hooks allow to override source IP (including the case when it's set via cmsg(3)) and destination IP:port for unconnected UDP (slow path). TCP and connected UDP (fast path) are not affected. This makes UDP support complete: connected UDP is handled by sys_connect hooks, unconnected by sys_sendmsg ones. Similar to sys_connect hooks, sys_sendmsg ones can be used to make system calls such as sendmsg(2) and sendto(2) return EPERM. Please see patch 0001 for more details. Andrey Ignatov (5): bpf: Hooks for sys_sendmsg bpf: Sync bpf.h to tools/ libbpf: Support guessing sendmsg{4,6} progs selftests/bpf: Prepare test_sock_addr for extension selftests/bpf: Selftest for sys_sendmsg hooks include/linux/bpf-cgroup.h | 23 +- include/linux/filter.h | 1 + include/uapi/linux/bpf.h | 8 + kernel/bpf/cgroup.c | 11 +- kernel/bpf/syscall.c | 8 + net/core/filter.c | 39 + net/ipv4/udp.c | 20 +- net/ipv6/udp.c | 17 + tools/include/uapi/linux/bpf.h | 8 + tools/lib/bpf/libbpf.c | 2 + tools/testing/selftests/bpf/Makefile | 3 +- tools/testing/selftests/bpf/sendmsg4_prog.c | 49 ++ tools/testing/selftests/bpf/sendmsg6_prog.c | 60 ++ tools/testing/selftests/bpf/test_sock_addr.c | 1118 +++++++++++++++++++++----- 14 files changed, 1171 insertions(+), 196 deletions(-) create mode 100644 tools/testing/selftests/bpf/sendmsg4_prog.c create mode 100644 tools/testing/selftests/bpf/sendmsg6_prog.c -- 2.9.5