Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47983
b: refs/heads/master
c: bcdb81a
h: refs/heads/master
i:
  47981: daa249e
  47979: b0a4c75
  47975: 8687f6d
  47967: b037f3a
v: v3
  • Loading branch information
Chuck Lever authored and Linus Torvalds committed Feb 12, 2007
1 parent b55ebf1 commit d441655
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b92503b25c3f794cff5f96626ea3ecba8d10d254
refs/heads/master: bcdb81ae29091f6a66369aabfd8324e4a53d05dc
21 changes: 18 additions & 3 deletions trunk/net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,22 @@ svc_tcp_data_ready(struct sock *sk, int count)
wake_up_interruptible(sk->sk_sleep);
}

static inline int svc_port_is_privileged(struct sockaddr *sin)
{
switch (sin->sa_family) {
case AF_INET:
return ntohs(((struct sockaddr_in *)sin)->sin_port)
< PROT_SOCK;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
return ntohs(((struct sockaddr_in6 *)sin)->sin6_port)
< PROT_SOCK;
#endif
default:
return 0;
}
}

/*
* Accept a TCP connection
*/
Expand Down Expand Up @@ -984,7 +1000,7 @@ svc_tcp_accept(struct svc_sock *svsk)
* hosts here, but when we get encryption, the IP of the host won't
* tell us anything. For now just warn about unpriv connections.
*/
if (ntohs(sin.sin_port) >= 1024) {
if (!svc_port_is_privileged((struct sockaddr *) &sin)) {
dprintk(KERN_WARNING
"%s: connect from unprivileged port: %s\n",
serv->sv_name,
Expand Down Expand Up @@ -1334,7 +1350,6 @@ int
svc_recv(struct svc_rqst *rqstp, long timeout)
{
struct svc_sock *svsk = NULL;
struct sockaddr_in *sin = svc_addr_in(rqstp);
struct svc_serv *serv = rqstp->rq_server;
struct svc_pool *pool = rqstp->rq_pool;
int len, i;
Expand Down Expand Up @@ -1431,7 +1446,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
svsk->sk_lastrecv = get_seconds();
clear_bit(SK_OLD, &svsk->sk_flags);

rqstp->rq_secure = ntohs(sin->sin_port) < PROT_SOCK;
rqstp->rq_secure = svc_port_is_privileged(svc_addr(rqstp));
rqstp->rq_chandle.defer = svc_defer;

if (serv->sv_stats)
Expand Down

0 comments on commit d441655

Please sign in to comment.