[patch] Raw sockets in jails

From: Christian S.J. Peron (maneo_at_bsdpro.com)
Date: 04/20/04

  • Next message: Poul-Henning Kamp: "Re: [patch] Raw sockets in jails"
    Date: Tue, 20 Apr 2004 01:56:38 +0000
    To: freebsd-hackers@FreeBSD.org
    
    

            Although RAW sockets can be used when specifying the source
            address of packets (defeating one of the aspects of the jail)
            some people may find it usefull to use utilities like ping(8)
            or traceroute(8) from inside jails.

            Enclosed is a patch I have written which gives you the option
            of allowing prison-root to create raw sockets inside the prison,
            so that programs various network debugging programs like ping
            and traceroute etc can be used.

            This patch will create the security.jail.allow_raw_sockets sysctl
            MIB. I would appriciate any feed-back from testers

            See PR #:
            http://www.freebsd.org/cgi/query-pr.cgi?pr=65800

    -------------------- SNIP SNIP ------------------------

    --- sys/kern/kern_jail.c.bak Mon Apr 19 16:55:40 2004
    +++ sys/kern/kern_jail.c Mon Apr 19 17:56:03 2004
    @@ -53,6 +53,11 @@
         &jail_sysvipc_allowed, 0,
         "Processes in jail can use System V IPC primitives");
     
    +int jail_allow_raw_sockets = 0;
    +SYSCTL_INT(_security_jail, OID_AUTO, allow_raw_sockets, CTLFLAG_RW,
    + &jail_allow_raw_sockets, 0,
    + "Prison root can create raw sockets");
    +
     /* allprison, lastprid, and prisoncount are protected by allprison_mtx. */
     struct prisonlist allprison;
     struct mtx allprison_mtx;
    --- sys/netinet/raw_ip.c.b Mon Apr 19 16:23:57 2004
    +++ sys/netinet/raw_ip.c Mon Apr 19 17:55:08 2004
    @@ -40,6 +40,7 @@
     #include "opt_random_ip_id.h"
     
     #include <sys/param.h>
    +#include <sys/jail.h>
     #include <sys/kernel.h>
     #include <sys/lock.h>
     #include <sys/mac.h>
    @@ -505,6 +506,7 @@
             }
     }
     
    +extern int jail_allow_raw_sockets;
     u_long rip_sendspace = RIPSNDQ;
     u_long rip_recvspace = RIPRCVQ;
     
    @@ -527,7 +529,11 @@
                     INP_INFO_WUNLOCK(&ripcbinfo);
                     return EINVAL;
             }
    - if (td && (error = suser(td)) != 0) {
    + if (td && jailed(td->td_ucred) && !jail_allow_raw_sockets) {
    + INP_INFO_WUNLOCK(&ripcbinfo);
    + return (EPERM);
    + }
    + if (td && (error = suser_cred(td->td_ucred, PRISON_ROOT)) != 0) {
                     INP_INFO_WUNLOCK(&ripcbinfo);
                     return error;
             }
    _______________________________________________
    freebsd-security@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-security
    To unsubscribe, send any mail to "freebsd-security-unsubscribe@freebsd.org"


  • Next message: Poul-Henning Kamp: "Re: [patch] Raw sockets in jails"

    Relevant Pages

    • [patch] Raw sockets in jails
      ... "Prison root can create raw sockets"); ... +extern int jail_allow_raw_sockets; ... To unsubscribe, ...
      (freebsd-hackers)
    • Re: Http server implementation for Windows Media Server
      ... On that level that already extra raw data even not ... similar problem applies to me as would happen with raw sockets. ... I'm assuming you are using a raw TCP ... the packets aren't ACKed because ...
      (microsoft.public.win32.programmer.networks)
    • Re: Error in send, while using IP_HDRINCL
      ... > Arkady Frenkel wrote: ... >>> And MS could do exactly the same precautions for an app that uses raw ... >>> sockets. ...
      (microsoft.public.win32.programmer.networks)
    • Raw Socket Sender
      ... I must say I'm new to these Raw sockets in C# and unfortunantly I haven't met ... I set up my packet reciever which recieves RAW IP packets and dumps ... A blocking operation was interrupted by a call to ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Error in send, while using IP_HDRINCL
      ... > Arkady Frenkel wrote: ... >>> And MS could do exactly the same precautions for an app that uses raw ... >> network students move to linux", at the end they leave the UDP ... BTW the Sudesh wrote that they can't read with raw sockets and that due to ...
      (microsoft.public.win32.programmer.networks)