From: Paolo Abeni <pabeni@redhat•com>
To: Matthew Dawson <matthew@mjdsystems•ca>
Cc: netdev@vger•kernel.org, "Macieira,
Thiago" <thiago.macieira@intel•com>,
willemdebruijn.kernel@gmail•com
Subject: Re: [PATCH net v2] datagram: When peeking datagrams with offset < 0 don't skip empty skbs
Date: Fri, 18 Aug 2017 19:42:48 +0200 [thread overview]
Message-ID: <1503078168.3344.54.camel@redhat.com> (raw)
In-Reply-To: <1789862.HUSStbeWG9@ring00>
On Fri, 2017-08-18 at 12:39 -0400, Matthew Dawson wrote:
> On Friday, August 18, 2017 10:05:18 AM EDT Paolo Abeni wrote:
> > On Thu, 2017-08-17 at 22:11 -0400, Matthew Dawson wrote:
> > > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> > > index 7b52a380d710..be8982b4f8c0 100644
> > > --- a/net/unix/af_unix.c
> > > +++ b/net/unix/af_unix.c
> > > @@ -2304,10 +2304,7 @@ static int unix_stream_read_generic(struct
> > > unix_stream_read_state *state,>
> > > */
> > >
> > > mutex_lock(&u->iolock);
> > >
> > > - if (flags & MSG_PEEK)
> > > - skip = sk_peek_offset(sk, flags);
> > > - else
> > > - skip = 0;
> > > + skip = max(sk_peek_offset(sk, flags), 0);
> > >
> > > do {
> > >
> > > int chunk;
> >
> > later we have:
> >
> > chunk = min_t(unsigned int, unix_skb_len(skb) - skip, size);
> >
> > without any call to __skb_try_recv_from_queue(), so we will get
> > bad/unexpected values from the above assignment when 'skip' is
> > negative.
>
> The assignment to skip should ensure it is never less then zero, thanks to the
> max(sk...(), 0). Thus that shouldn't be an issue?
Right, I missed the max() call. Thanks for pointing it out.
I'm fine with the above.
> >
> > Overall I still think that adding/using an explicit MSG_PEEK_OFF bit
> > would produce a simpler code, but is just a personal preference.
>
> I don't mind either way, that just seemed to be the preference I saw from the
> discussion around the patch. I think either way will work, so whatever the
> list prefers I'm happy with.
I'm ok either way. Probably it's worth continue this way.
Paolo
next prev parent reply other threads:[~2017-08-18 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 2:11 [PATCH net v2] datagram: When peeking datagrams with offset < 0 don't skip empty skbs Matthew Dawson
2017-08-18 14:05 ` Paolo Abeni
2017-08-18 16:39 ` Matthew Dawson
2017-08-18 17:42 ` Paolo Abeni [this message]
2017-08-18 17:52 ` Willem de Bruijn
2017-08-18 17:56 ` Willem de Bruijn
2017-08-18 17:52 ` Willem de Bruijn
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=1503078168.3344.54.camel@redhat.com \
--to=pabeni@redhat$(echo .)com \
--cc=matthew@mjdsystems$(echo .)ca \
--cc=netdev@vger$(echo .)kernel.org \
--cc=thiago.macieira@intel$(echo .)com \
--cc=willemdebruijn.kernel@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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