Add is_userspace_region checks to some socket functions.
Disabled PPPoE and IPv6 completely by default, as not functional. git-svn-id: svn://kolibrios.org@9049 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
eccd8f2198
commit
7b13d5fb4e
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2012-2019. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2012-2021. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; PPPoE.INC ;;
|
;; PPPoE.INC ;;
|
||||||
@ -141,38 +141,41 @@ pppoe_discovery_output:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
|
||||||
|
|
||||||
; Create packet.
|
; Create packet.
|
||||||
push ecx esi
|
stdcall net_buff_alloc, 1514 + NET_BUFF.data
|
||||||
;;;; FIXME stdcall kernel_alloc, 1500
|
|
||||||
pop esi ecx
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .bad
|
jz .bad
|
||||||
|
|
||||||
|
; Net buffer header
|
||||||
|
mov [eax + NET_BUFF.type], NET_BUFF_ETH
|
||||||
|
mov [eax + NET_BUFF.device], ebx
|
||||||
|
mov [eax + NET_BUFF.offset], NET_BUFF.data
|
||||||
|
|
||||||
|
; Packet data
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
mov edi, eax
|
lea edi, [eax + NET_BUFF.data]
|
||||||
rep movsb
|
rep movsb
|
||||||
|
|
||||||
cmp edx, 60 ; Min ETH size
|
; Packet size
|
||||||
|
cmp edx, 60
|
||||||
ja @f
|
ja @f
|
||||||
mov edx, 60
|
mov edx, 60
|
||||||
@@:
|
@@:
|
||||||
|
mov [eax + NET_BUFF.length], edx
|
||||||
|
|
||||||
push edx eax ; size and packet ptr for driver send proc
|
; Overwrite ETH source MAC with our own
|
||||||
|
|
||||||
; Overwrite source MAC and protocol type
|
|
||||||
lea edi, [eax + ETH_header.SrcMAC]
|
|
||||||
lea esi, [ebx + ETH_DEVICE.mac]
|
lea esi, [ebx + ETH_DEVICE.mac]
|
||||||
|
lea edi, [eax + NET_BUFF.data + ETH_header.SrcMAC]
|
||||||
movsd
|
movsd
|
||||||
movsw
|
movsw
|
||||||
cmp word[edi], ETHER_PROTO_PPP_SESSION ; Allow only PPP_discovery, or LCP
|
|
||||||
|
; Allow only PPP_discovery, or LCP
|
||||||
|
cmp word[edi], ETHER_PROTO_PPP_SESSION
|
||||||
je @f
|
je @f
|
||||||
mov ax, ETHER_PROTO_PPP_DISCOVERY
|
mov word[edi], ETHER_PROTO_PPP_DISCOVERY
|
||||||
stosw
|
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; And send the packet
|
; And send the packet
|
||||||
call [ebx + NET_DEVICE.transmit]
|
stdcall [ebx + NET_DEVICE.transmit], eax
|
||||||
|
|
||||||
xor eax, eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.bad:
|
.bad:
|
||||||
|
@ -332,8 +332,8 @@ socket_open:
|
|||||||
cmp ecx, AF_PPP
|
cmp ecx, AF_PPP
|
||||||
jne .no_ppp
|
jne .no_ppp
|
||||||
|
|
||||||
cmp esi, PPP_PROTO_ETHERNET
|
; cmp esi, PPP_PROTO_ETHERNET
|
||||||
je .pppoe
|
; je .pppoe
|
||||||
|
|
||||||
.no_ppp:
|
.no_ppp:
|
||||||
.unsupported:
|
.unsupported:
|
||||||
@ -404,15 +404,15 @@ align 4
|
|||||||
mov [eax + SOCKET.connect_proc], ipv4_connect
|
mov [eax + SOCKET.connect_proc], ipv4_connect
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
;align 4
|
||||||
.pppoe:
|
; .pppoe:
|
||||||
push eax
|
; push eax
|
||||||
init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue
|
; init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue
|
||||||
pop eax
|
; pop eax
|
||||||
|
;
|
||||||
mov [eax + SOCKET.snd_proc], socket_send_pppoe
|
; mov [eax + SOCKET.snd_proc], socket_send_pppoe
|
||||||
mov [eax + SOCKET.rcv_proc], socket_receive_dgram
|
; mov [eax + SOCKET.rcv_proc], socket_receive_dgram
|
||||||
ret
|
; ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
@ -774,7 +774,7 @@ socket_close:
|
|||||||
; ;
|
; ;
|
||||||
; IN: ecx = socket number ;
|
; IN: ecx = socket number ;
|
||||||
; edx = addr to application buffer ;
|
; edx = addr to application buffer ;
|
||||||
; edx = length of application buffer ;
|
; esi = length of application buffer ;
|
||||||
; edi = flags ;
|
; edi = flags ;
|
||||||
; ;
|
; ;
|
||||||
; OUT: eax = number of bytes copied ;
|
; OUT: eax = number of bytes copied ;
|
||||||
@ -792,6 +792,9 @@ socket_receive:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .invalid
|
jz .invalid
|
||||||
|
|
||||||
|
stdcall is_region_userspace, edx, esi
|
||||||
|
jnz .invalid
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
push edi
|
push edi
|
||||||
call [eax + SOCKET.rcv_proc]
|
call [eax + SOCKET.rcv_proc]
|
||||||
@ -998,6 +1001,9 @@ socket_send:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .invalid
|
jz .invalid
|
||||||
|
|
||||||
|
stdcall is_region_userspace, edx, esi
|
||||||
|
jnz .invalid
|
||||||
|
|
||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
mov esi, edx
|
mov esi, edx
|
||||||
|
|
||||||
@ -1080,23 +1086,23 @@ socket_send_icmp:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
align 4
|
;align 4
|
||||||
socket_send_pppoe:
|
;socket_send_pppoe:
|
||||||
|
;
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n"
|
; DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n"
|
||||||
|
;
|
||||||
mov [esp+32], ecx
|
; mov [esp+32], ecx
|
||||||
mov ebx, [eax + SOCKET.device]
|
; mov ebx, [eax + SOCKET.device]
|
||||||
|
;
|
||||||
call pppoe_discovery_output ; FIXME: errorcodes
|
; call pppoe_discovery_output ; FIXME: errorcodes
|
||||||
cmp eax, -1
|
; cmp eax, -1
|
||||||
je .error
|
; je .error
|
||||||
ret
|
; ret
|
||||||
|
;
|
||||||
.error:
|
; .error:
|
||||||
mov dword[esp+32], -1
|
; mov dword[esp+32], -1
|
||||||
mov dword[esp+20], EMSGSIZE
|
; mov dword[esp+20], EMSGSIZE
|
||||||
ret
|
; ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1383,6 +1389,9 @@ socket_debug:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .invalid
|
jz .invalid
|
||||||
|
|
||||||
|
stdcall is_region_userspace, edi, SOCKET_STRUCT_SIZE
|
||||||
|
jnz .invalid
|
||||||
|
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
mov ecx, SOCKET_STRUCT_SIZE/4
|
mov ecx, SOCKET_STRUCT_SIZE/4
|
||||||
rep movsd
|
rep movsd
|
||||||
|
@ -243,11 +243,11 @@ include "queue.inc"
|
|||||||
include "loopback.inc"
|
include "loopback.inc"
|
||||||
include "ethernet.inc"
|
include "ethernet.inc"
|
||||||
|
|
||||||
include "PPPoE.inc"
|
;include "PPPoE.inc"
|
||||||
|
|
||||||
include "ARP.inc"
|
include "ARP.inc"
|
||||||
include "IPv4.inc"
|
include "IPv4.inc"
|
||||||
include "IPv6.inc"
|
;include "IPv6.inc"
|
||||||
|
|
||||||
include "icmp.inc"
|
include "icmp.inc"
|
||||||
include "udp.inc"
|
include "udp.inc"
|
||||||
@ -319,7 +319,7 @@ end if
|
|||||||
|
|
||||||
eth_init
|
eth_init
|
||||||
|
|
||||||
pppoe_init
|
; pppoe_init
|
||||||
|
|
||||||
ipv4_init
|
ipv4_init
|
||||||
; ipv6_init
|
; ipv6_init
|
||||||
@ -828,10 +828,9 @@ sys_network:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.get_dev_name:
|
.get_dev_name:
|
||||||
mov ebx, eax
|
|
||||||
stdcall is_region_userspace, ecx, 64
|
stdcall is_region_userspace, ecx, 64
|
||||||
jnz .bad_buffer
|
jnz .bad_buffer
|
||||||
mov esi, [ebx + NET_DEVICE.name]
|
mov esi, [eax + NET_DEVICE.name]
|
||||||
mov edi, ecx
|
mov edi, ecx
|
||||||
|
|
||||||
mov ecx, 64/4 ; max length
|
mov ecx, 64/4 ; max length
|
||||||
@ -968,11 +967,11 @@ sys_protocols:
|
|||||||
cmp ax, API_ARP
|
cmp ax, API_ARP
|
||||||
je arp_api
|
je arp_api
|
||||||
|
|
||||||
cmp ax, API_PPPOE
|
; cmp ax, API_PPPOE
|
||||||
je pppoe_api
|
; je pppoe_api
|
||||||
|
|
||||||
cmp ax, API_IPv6
|
; cmp ax, API_IPv6
|
||||||
je ipv6_api
|
; je ipv6_api
|
||||||
|
|
||||||
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user