lkml.org 
[lkml]   [2004]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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]
\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.358 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site