sys_bind question

karsten (kernel@mluwis17.wiwi.uni-halle.de)
Mon, 3 Jan 2000 14:01:21 +0200


Hello,

I have a question to sys_bind, first i want to explain what i've done:

I've done a quick hack to create some sort of different "processrooms".
That means i splitted the 32768 available PIDs into 8 or 16 "Subsystems",
each Subsystem has 4096 or 2048 available PIDs. I also modified sys_fork.
With a call to this function the forked PID is in the same Subsystem as
the parent PID. Only a modified new systemcall (sys_create_ss) allows it
to fork in specific subsystems (this calls are only possible from
Subsystem 0, where the highest bits in the PID [3 or 4] are zero). With
this in mind i can do a simple form of "authorization". I use this to
influence the behavior of bind, if a caller from a subsystem wants to bind
to 0.0.0.0, i look up into a translationtable and let it only bind to a
specific address listed in this table. This table can be set through
another new systemcall (sys_set_ss_ip). All this works fine under my
modified kernel 2.2.11

Now my question, the next aim is to translate such a bind(0.0.0.0) to more
than only one ip-addresses. I think this mofication can't be done in
sys_bind. Maybe in some of the ipv4 Lowlevel-binds, but i don't know how.

I made this hack, because i want to run some really old applications on
one server, which only use bind(0.0.0.0) but use the same port, and the
second reason i want to learn more about linux-kernel-internals.

The modified sys_bind looks like this

#define GET_SUB_SYSTEM ((current->pid & SUB_SYSTEM_AND_MASK) >> SUB_SYSTEM_SHIFT)

asmlinkage int sys_bind(int fd, struct sockaddr *umyaddr, int addrlen)
{
struct socket *sock;
char address[MAX_SOCK_ADDR];
int err = 0;

lock_kernel();
if((sock = sockfd_lookup(fd,&err))!=NULL)
{
if (umyaddr->sa_family == AF_INET)
{
unsigned char sub_system = GET_SUB_SYSTEM;

if (ss_ip_address[sub_system][0] != 0)
{
umyaddr->sa_data[2] =
ss_ip_address[sub_system][1];
umyaddr->sa_data[3] =
ss_ip_address[sub_system][2];
umyaddr->sa_data[4] =
ss_ip_address[sub_system][3];
umyaddr->sa_data[5] =
ss_ip_address[sub_system][4];
}
else if (sub_system != 0) printk(KERN_INFO
"sys_bind: Subsystem %d binds WITHOUT IP Address Translation\n$
}
if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0)
err = sock->ops->bind(sock, (struct sockaddr *)address,
addrlen);
sockfd_put(sock);
}
unlock_kernel();
return err;
}

Thanks.

karsten

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/