Phonet: reject unsupported sendmsg/recvmsg flags

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Rémi Denis-Courmont 2010-01-04 02:02:49 +00:00 committed by David S. Miller
parent fea93ecef6
commit 82ecbcb9c6
2 changed files with 13 additions and 3 deletions

View File

@ -75,7 +75,8 @@ static int pn_sendmsg(struct kiocb *iocb, struct sock *sk,
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
if (msg->msg_flags & MSG_OOB) if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL|
MSG_CMSG_COMPAT))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (msg->msg_name == NULL) if (msg->msg_name == NULL)
@ -119,7 +120,8 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
int rval = -EOPNOTSUPP; int rval = -EOPNOTSUPP;
int copylen; int copylen;
if (flags & MSG_OOB) if (flags & ~(MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_NOSIGNAL|
MSG_CMSG_COMPAT))
goto out_nofree; goto out_nofree;
if (addr_len) if (addr_len)

View File

@ -860,7 +860,9 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk,
int flags = msg->msg_flags; int flags = msg->msg_flags;
int err, done; int err, done;
if (msg->msg_flags & MSG_OOB || !(msg->msg_flags & MSG_EOR)) if ((msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL|
MSG_CMSG_COMPAT)) ||
!(msg->msg_flags & MSG_EOR))
return -EOPNOTSUPP; return -EOPNOTSUPP;
skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len, skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len,
@ -981,6 +983,10 @@ static int pep_recvmsg(struct kiocb *iocb, struct sock *sk,
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
if (flags & ~(MSG_OOB|MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_WAITALL|
MSG_NOSIGNAL|MSG_CMSG_COMPAT))
return -EOPNOTSUPP;
if (unlikely(1 << sk->sk_state & (TCPF_LISTEN | TCPF_CLOSE))) if (unlikely(1 << sk->sk_state & (TCPF_LISTEN | TCPF_CLOSE)))
return -ENOTCONN; return -ENOTCONN;
@ -988,6 +994,8 @@ static int pep_recvmsg(struct kiocb *iocb, struct sock *sk,
/* Dequeue and acknowledge control request */ /* Dequeue and acknowledge control request */
struct pep_sock *pn = pep_sk(sk); struct pep_sock *pn = pep_sk(sk);
if (flags & MSG_PEEK)
return -EOPNOTSUPP;
skb = skb_dequeue(&pn->ctrlreq_queue); skb = skb_dequeue(&pn->ctrlreq_queue);
if (skb) { if (skb) {
pep_ctrlreq_error(sk, skb, PN_PIPE_NO_ERROR, pep_ctrlreq_error(sk, skb, PN_PIPE_NO_ERROR,