lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB0234BBD@AcuExch.aculab.com>
Date:   Mon, 5 Dec 2016 10:51:39 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'David Ahern' <dsa@...ulusnetworks.com>,
        Alexei Starovoitov <alexei.starovoitov@...il.com>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "daniel@...que.org" <daniel@...que.org>, "ast@...com" <ast@...com>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "maheshb@...gle.com" <maheshb@...gle.com>,
        "tgraf@...g.ch" <tgraf@...g.ch>
Subject: RE: [PATCH net-next v6 6/6] samples/bpf: add userspace example for
 prohibiting sockets

From: David Ahern
> Sent: 01 December 2016 15:14
> On 11/30/16 10:59 PM, Alexei Starovoitov wrote:
> > On Wed, Nov 30, 2016 at 10:16:50AM -0800, David Ahern wrote:
> >> Add examples preventing a process in a cgroup from opening a socket
> >> based family, protocol and type.
> >>
> >> Signed-off-by: David Ahern <dsa@...ulusnetworks.com>
> > ...
> >> +++ b/samples/bpf/sock_flags_kern.c
> >> @@ -0,0 +1,37 @@
> >> +#include <uapi/linux/bpf.h>
> >> +#include <linux/socket.h>
> >> +#include "bpf_helpers.h"
> >> +
> >> +SEC("cgroup/sock1")
> >> +int bpf_prog1(struct bpf_sock *sk)
> >> +{
> >> +	char fmt[] = "socket: family %d type %d protocol %d\n";
> >> +
> >> +	bpf_trace_printk(fmt, sizeof(fmt), sk->family, sk->type, sk->protocol);
> >> +
> >> +	/* block PF_INET6, SOCK_RAW, IPPROTO_ICMPV6 sockets
> >> +	 * ie., make ping6 fail
> >> +	 */
> >> +	if (sk->family == PF_INET6 && sk->type == 3 && sk->protocol == 58)
> >> +		return 0;
> >
> > why not to use SOCK_RAW and IPPROTO_ICMPV6 instead of constants?
> 
> header file hell.

You can at least improve the comment.
Or add:
#ifndef SOCK_RAW
#define SPCK_RAW 3
#endif
(etc) at the top of the file.

	David


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ