From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kuba@kernel.org>
Cc: <bspencer@blackberry.com>, <christophe-h.ricard@st.com>,
<davem@davemloft.net>, <dsahern@gmail.com>, <edumazet@google.com>,
<johannes.berg@intel.com>, <kaber@trash.net>,
<kuni1840@gmail.com>, <kuniyu@amazon.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>,
<pablo@netfilter.org>
Subject: Re: [PATCH v1 net] netlink: Use copy_to_user() for optval in netlink_getsockopt().
Date: Wed, 19 Apr 2023 20:40:50 -0700 [thread overview]
Message-ID: <20230420034050.48415-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20230419160908.5469e9bf@kernel.org>
From: Jakub Kicinski <kuba@kernel.org>
Date: Wed, 19 Apr 2023 16:09:08 -0700
> On Wed, 19 Apr 2023 09:17:37 +0200 Johannes Berg wrote:
> > > @@ -1754,39 +1754,17 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
> > >
> > > switch (optname) {
> > > case NETLINK_PKTINFO:
> > > - if (len < sizeof(int))
> > > - return -EINVAL;
> > > - len = sizeof(int);
> >
> > On the other hand, this is actually accepting say a u64 now, and then
> > sets only 4 bytes of it, though at least it also sets the size to what
> > it wrote out.
> >
> > So I guess here we can argue either
> > 1) keep writing len to 4 and set 4 bytes of the output
> > 2) keep the length as is and set all bytes of the output
> >
> > but (2) gets confusing if you say used 6 bytes buffer as input? I mean,
> > yeah, I'd really hope nobody does that.
> >
> > If Jakub is feeling adventurous maybe we should attempt to see if we
> > break anything by accepting only == sizeof(int) rather than >= ... :-)
>
> Can't think of a strong reason either way, so I'd keep the check
> and len setting as is.
Ok, I'll respin v2 with the existing check and len setting.
Thank you, Johannes and Jakub!
next prev parent reply other threads:[~2023-04-20 3:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 0:42 [PATCH v1 net] netlink: Use copy_to_user() for optval in netlink_getsockopt() Kuniyuki Iwashima
2023-04-19 3:33 ` Jakub Kicinski
2023-04-19 17:50 ` Kuniyuki Iwashima
2023-04-19 7:17 ` Johannes Berg
2023-04-19 17:52 ` Kuniyuki Iwashima
2023-04-19 19:46 ` Johannes Berg
2023-04-19 19:47 ` Johannes Berg
[not found] ` <20230419160908.5469e9bf@kernel.org>
2023-04-20 3:40 ` Kuniyuki Iwashima [this message]
2023-04-20 7:04 ` Johannes Berg
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=20230420034050.48415-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=bspencer@blackberry.com \
--cc=christophe-h.ricard@st.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=edumazet@google.com \
--cc=johannes.berg@intel.com \
--cc=kaber@trash.net \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.