From: Florian Westphal <fw@strlen.de>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, johannes@sipsolutions.net
Subject: Re: [PATCH 5/5] net: sock_aio_write: set CMSG_MSG_COMPAT flag if is_compat_task
Date: Fri, 26 Feb 2010 11:03:05 +0100 [thread overview]
Message-ID: <20100226100305.GA16504@Chamillionaire.breakpoint.cc> (raw)
In-Reply-To: <20100226.011646.257642830.davem@davemloft.net>
David Miller <davem@davemloft.net> wrote:
> From: Florian Westphal <fwestphal@astaro.com>
> Date: Fri, 19 Feb 2010 13:41:47 +0100
>
> > some programs (e.g. pluto ike daemon), send netlink data to the
> > kernel via write().
> >
> > So far, the CMSG_MSG_COMPAT flag is not set in this case, which
> > results in the kernel interpreting the netlink data the wrong way.
> >
> > An alternative solution is to switch userspace to sendmsg() when
> > using netlink sockets.
> >
> > Cc: Johannes Berg <johannes@sipsolutions.net>
> > Signed-off-by: Florian Westphal <fwestphal@astaro.com>
>
> I was about to apply this entire patch set, but thinking about this
> one patch we have to do it differently:
>
> > @@ -837,6 +837,10 @@ static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb,
> > msg->msg_iov = (struct iovec *)iov;
> > msg->msg_iovlen = nr_segs;
> > msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0;
> > +#ifdef CONFIG_COMPAT
> > + if (is_compat_task())
> > + msg->msg_flags |= MSG_CMSG_COMPAT;
> > +#endif
> > if (sock->type == SOCK_SEQPACKET)
> > msg->msg_flags |= MSG_EOR;
> >
>
> What if the kernel itself does a socket write, say from a software
> interrupt or to generate events in response to a user event,
> and the current process happens to be a compat task?
>
> I think this could even occur for NFS perhaps?
I do not know. But it certainly shows that this patch should not be
applied.
> Anyways, that isn't going to work properly.
>
> We might need to add ->compat_write to file operations to do
> it properly.
Fair enough.
If its necessary to set MSG_CMSG_COMPAT properly for plain
write() as well to have the patch set merged then
I'll see about adding such a ->compat_write and will resubmit
the entire set again once net-next opens again for 2.6.35.
Thanks,
Florian
next prev parent reply other threads:[~2010-02-26 10:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 12:41 [PATCH v2 0/5] xfrm: add x86 CONFIG_COMPAT support Florian Westphal
2010-02-19 12:41 ` [PATCH 1/5] netlink: append NLMSG_DONE to compatskb, too Florian Westphal
2010-02-19 12:41 ` [PATCH 2/5] netlink: store MSG_CMSG_COMPAT flag in netlink_skb_parms Florian Westphal
2010-02-19 12:49 ` Johannes Berg
2010-02-19 13:34 ` Florian Westphal
2010-02-19 12:41 ` [PATCH 3/5] xfrm: split nlmsg allocation and data copying Florian Westphal
2010-02-19 12:41 ` [PATCH 4/5] xfrm: CONFIG_COMPAT support for x86 architecture Florian Westphal
2010-02-19 12:41 ` [PATCH 5/5] net: sock_aio_write: set CMSG_MSG_COMPAT flag if is_compat_task Florian Westphal
2010-02-26 9:16 ` David Miller
2010-02-26 9:17 ` David Miller
2010-02-26 10:03 ` Florian Westphal [this message]
2010-02-26 10:06 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2010-02-15 16:46 xfrm: add x86 CONFIG_COMPAT support Florian Westphal
2010-02-15 16:46 ` [PATCH 5/5] net: sock_aio_write: set CMSG_MSG_COMPAT flag if is_compat_task Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100226100305.GA16504@Chamillionaire.breakpoint.cc \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=johannes@sipsolutions.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).