Messages in this thread | | | Date | Fri, 19 Nov 2004 03:23:50 +0000 | From | Ross Kendall Axe <> | Subject | Re: [PATCH] linux 2.9.10-rc1: Fix oops in unix_dgram_sendmsg when using SELinux and SOCK_SEQPACKET |
| |
Chris Wright wrote: > > Why not make a unix_seq_sendmsg, which is a very small wrapper? > e.g. > static int unix_seq_sendmsg(struct kiocb *kiocb, struct socket *sock, > struct msghdr *msg, size_t len) > { > struct sock *sk = sock->sk; > > if (sk->sk_type == SOCK_SEQPACKET && sk->sk_state != TCP_ESTABLISHED) > return -ENOTCONN; > if (msg->msg_name || msg->msg_namelen) > return -EINVAL; > return unix_dgram_sendmsg(kiocb, sock, msg, len); > } > > > -chris
Taking this idea further, couldn't we split unix_dgram_sendmsg into 2 functions, do_unix_dgram_sendmsg and do_unix_connectionless_sendmsg (and similarly for unix_stream_sendmsg), then all we'd need is:
<pseudocode> static int do_unix_dgram_sendmsg(...); static int do_unix_stream_sendmsg(...); static int do_unix_connectionless_sendmsg(...); static int do_unix_connectional_sendmsg(...);
static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, struct msghdr *msg, size_t len) { return do_unix_connectionless_sendmsg(kiocb, sock, msg, len, do_unix_dgram_sendmsg); } static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, struct msghdr *msg, size_t len) { return do_unix_connectional_sendmsg(kiocb, sock, msg, len, do_unix_stream_sendmsg); } static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock, struct msghdr *msg, size_t len) { return do_unix_connectional_sendmsg(kiocb, sock, msg, len, do_unix_dgram_sendmsg); } </pseudocode>
What do we think?
Ross
[unhandled content-type:application/pgp-signature] | |