* [MPTCP][PATCH net 0/2] fix static checker warnings in
@ 2020-11-09 13:59 Geliang Tang
2020-11-09 13:59 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Geliang Tang
0 siblings, 1 reply; 11+ messages in thread
From: Geliang Tang @ 2020-11-09 13:59 UTC (permalink / raw)
To: Mat Martineau, Matthieu Baerts, David S. Miller, Jakub Kicinski,
Paolo Abeni
Cc: Geliang Tang, netdev, mptcp, linux-kernel
This patchset fixed static checker warnings in mptcp_pm_add_timer and
mptcp_pm_alloc_anno_list.
Geliang Tang (2):
mptcp: fix static checker warnings in mptcp_pm_add_timer
mptcp: cleanup for mptcp_pm_alloc_anno_list
net/mptcp/pm_netlink.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 13:59 [MPTCP][PATCH net 0/2] fix static checker warnings in Geliang Tang
@ 2020-11-09 13:59 ` Geliang Tang
2020-11-09 13:59 ` [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list Geliang Tang
2020-11-09 16:28 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Matthieu Baerts
0 siblings, 2 replies; 11+ messages in thread
From: Geliang Tang @ 2020-11-09 13:59 UTC (permalink / raw)
To: Mat Martineau, Matthieu Baerts, David S. Miller, Jakub Kicinski,
Paolo Abeni
Cc: Geliang Tang, netdev, mptcp, linux-kernel, Dan Carpenter
Fix the following Smatch complaint:
net/mptcp/pm_netlink.c:213 mptcp_pm_add_timer()
warn: variable dereferenced before check 'msk' (see line 208)
net/mptcp/pm_netlink.c
207 struct mptcp_sock *msk = entry->sock;
208 struct sock *sk = (struct sock *)msk;
209 struct net *net = sock_net(sk);
^^
"msk" dereferenced here.
210
211 pr_debug("msk=%p", msk);
212
213 if (!msk)
^^^^
Too late.
214 return;
215
Fixes: 93f323b9cccc ("mptcp: add a new sysctl add_addr_timeout")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/mptcp/pm_netlink.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 6180a8b39a3f..03f2c28f11f5 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -206,7 +206,6 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
struct mptcp_pm_add_entry *entry = from_timer(entry, timer, add_timer);
struct mptcp_sock *msk = entry->sock;
struct sock *sk = (struct sock *)msk;
- struct net *net = sock_net(sk);
pr_debug("msk=%p", msk);
@@ -235,7 +234,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
if (entry->retrans_times < ADD_ADDR_RETRANS_MAX)
sk_reset_timer(sk, timer,
- jiffies + mptcp_get_add_addr_timeout(net));
+ jiffies + mptcp_get_add_addr_timeout(sock_net(sk)));
spin_unlock_bh(&msk->pm.lock);
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list
2020-11-09 13:59 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Geliang Tang
@ 2020-11-09 13:59 ` Geliang Tang
2020-11-09 16:35 ` Matthieu Baerts
2020-11-09 16:28 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Matthieu Baerts
1 sibling, 1 reply; 11+ messages in thread
From: Geliang Tang @ 2020-11-09 13:59 UTC (permalink / raw)
To: Mat Martineau, Matthieu Baerts, David S. Miller, Jakub Kicinski,
Paolo Abeni
Cc: Geliang Tang, netdev, mptcp, linux-kernel, Dan Carpenter
This patch added NULL pointer check for mptcp_pm_alloc_anno_list, and
avoided similar static checker warnings in mptcp_pm_add_timer.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/mptcp/pm_netlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 03f2c28f11f5..dfc1bed4a55f 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -266,7 +266,9 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
{
struct mptcp_pm_add_entry *add_entry = NULL;
struct sock *sk = (struct sock *)msk;
- struct net *net = sock_net(sk);
+
+ if (!msk)
+ return false;
if (lookup_anno_list_by_saddr(msk, &entry->addr))
return false;
@@ -283,7 +285,7 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0);
sk_reset_timer(sk, &add_entry->add_timer,
- jiffies + mptcp_get_add_addr_timeout(net));
+ jiffies + mptcp_get_add_addr_timeout(sock_net(sk)));
return true;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 13:59 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Geliang Tang
2020-11-09 13:59 ` [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list Geliang Tang
@ 2020-11-09 16:28 ` Matthieu Baerts
2020-11-09 18:34 ` Dan Carpenter
2020-11-09 20:57 ` Jakub Kicinski
1 sibling, 2 replies; 11+ messages in thread
From: Matthieu Baerts @ 2020-11-09 16:28 UTC (permalink / raw)
To: Geliang Tang, Mat Martineau, David S. Miller, Jakub Kicinski,
Paolo Abeni
Cc: netdev, mptcp, linux-kernel, Dan Carpenter
Hi Geliang, Dan,
On 09/11/2020 14:59, Geliang Tang wrote:
> Fix the following Smatch complaint:
Thanks for the report and the patch!
> net/mptcp/pm_netlink.c:213 mptcp_pm_add_timer()
> warn: variable dereferenced before check 'msk' (see line 208)
>
> net/mptcp/pm_netlink.c
> 207 struct mptcp_sock *msk = entry->sock;
> 208 struct sock *sk = (struct sock *)msk;
> 209 struct net *net = sock_net(sk);
> ^^
> "msk" dereferenced here.
>
> 210
> 211 pr_debug("msk=%p", msk);
> 212
> 213 if (!msk)
> ^^^^
> Too late.
>
> 214 return;
> 215
>
> Fixes: 93f323b9cccc ("mptcp: add a new sysctl add_addr_timeout")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
A small detail (I think): the Signed-off-by of the sender (Geliang)
should be the last one in the list if I am not mistaken.
But I guess this is not blocking.
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list
2020-11-09 13:59 ` [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list Geliang Tang
@ 2020-11-09 16:35 ` Matthieu Baerts
0 siblings, 0 replies; 11+ messages in thread
From: Matthieu Baerts @ 2020-11-09 16:35 UTC (permalink / raw)
To: Geliang Tang, Mat Martineau, David S. Miller, Jakub Kicinski,
Paolo Abeni
Cc: netdev, mptcp, linux-kernel, Dan Carpenter
Hi Geliang,
On 09/11/2020 14:59, Geliang Tang wrote:
> This patch added NULL pointer check for mptcp_pm_alloc_anno_list, and
> avoided similar static checker warnings in mptcp_pm_add_timer.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
I think Dan reviewed the v1 of your patch -- without some modifications
below -- but not the v2 nor this one.
> ---
> net/mptcp/pm_netlink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 03f2c28f11f5..dfc1bed4a55f 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -266,7 +266,9 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
> {
> struct mptcp_pm_add_entry *add_entry = NULL;
> struct sock *sk = (struct sock *)msk;
> - struct net *net = sock_net(sk);
> +
> + if (!msk)
> + return false;
As Dan mentioned on MPTCP ML, this check is not required: "msk" cannot
be NULL here.
We can maybe keep the cleanup (only move sock_net() below) but I don't
think we need or want this in -net.
I am not even sure we want it in net-next but why not :)
This could also be part of other refactors.
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 16:28 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Matthieu Baerts
@ 2020-11-09 18:34 ` Dan Carpenter
2020-11-09 20:56 ` Jakub Kicinski
2020-11-09 20:57 ` Jakub Kicinski
1 sibling, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2020-11-09 18:34 UTC (permalink / raw)
To: Matthieu Baerts
Cc: Geliang Tang, Mat Martineau, David S. Miller, Jakub Kicinski,
Paolo Abeni, netdev, mptcp, linux-kernel
On Mon, Nov 09, 2020 at 05:28:54PM +0100, Matthieu Baerts wrote:
> Hi Geliang, Dan,
>
> On 09/11/2020 14:59, Geliang Tang wrote:
> > Fix the following Smatch complaint:
>
> Thanks for the report and the patch!
>
> > net/mptcp/pm_netlink.c:213 mptcp_pm_add_timer()
> > warn: variable dereferenced before check 'msk' (see line 208)
> >
> > net/mptcp/pm_netlink.c
> > 207 struct mptcp_sock *msk = entry->sock;
> > 208 struct sock *sk = (struct sock *)msk;
> > 209 struct net *net = sock_net(sk);
> > ^^
> > "msk" dereferenced here.
> >
> > 210
> > 211 pr_debug("msk=%p", msk);
> > 212
> > 213 if (!msk)
> > ^^^^
> > Too late.
> >
> > 214 return;
> > 215
> >
> > Fixes: 93f323b9cccc ("mptcp: add a new sysctl add_addr_timeout")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> > Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> A small detail (I think): the Signed-off-by of the sender (Geliang) should
> be the last one in the list if I am not mistaken.
> But I guess this is not blocking.
Generally, I like them to be in chronological order. For other tags like
here it doesn't matter, but for signed-off-bys they only make sense in
chronological order.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 18:34 ` Dan Carpenter
@ 2020-11-09 20:56 ` Jakub Kicinski
0 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2020-11-09 20:56 UTC (permalink / raw)
To: Dan Carpenter
Cc: Matthieu Baerts, Geliang Tang, Mat Martineau, David S. Miller,
Paolo Abeni, netdev, mptcp, linux-kernel
On Mon, 9 Nov 2020 21:34:19 +0300 Dan Carpenter wrote:
> Generally, I like them to be in chronological order.
+1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 16:28 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Matthieu Baerts
2020-11-09 18:34 ` Dan Carpenter
@ 2020-11-09 20:57 ` Jakub Kicinski
2020-11-09 21:23 ` Matthieu Baerts
1 sibling, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2020-11-09 20:57 UTC (permalink / raw)
To: Matthieu Baerts
Cc: Geliang Tang, Mat Martineau, David S. Miller, Paolo Abeni,
netdev, mptcp, linux-kernel, Dan Carpenter
On Mon, 9 Nov 2020 17:28:54 +0100 Matthieu Baerts wrote:
> A small detail (I think): the Signed-off-by of the sender (Geliang)
> should be the last one in the list if I am not mistaken.
> But I guess this is not blocking.
>
> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
I take it you'd like me to apply patch 1 directly to net?
Or do you prefer to take it into mptcp tree first?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 20:57 ` Jakub Kicinski
@ 2020-11-09 21:23 ` Matthieu Baerts
2020-11-09 22:20 ` Jakub Kicinski
0 siblings, 1 reply; 11+ messages in thread
From: Matthieu Baerts @ 2020-11-09 21:23 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Geliang Tang, Mat Martineau, David S. Miller, Paolo Abeni,
netdev, mptcp, linux-kernel, Dan Carpenter
Hi Jakub,
09 Nov 2020 21:57:05 Jakub Kicinski <kuba@kernel.org>:
> On Mon, 9 Nov 2020 17:28:54 +0100 Matthieu Baerts wrote:
>> A small detail (I think): the Signed-off-by of the sender (Geliang)
>> should be the last one in the list if I am not mistaken.
>> But I guess this is not blocking.
>>
>> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
>
> I take it you'd like me to apply patch 1 directly to net?
Sorry, I didn't know it was OK to apply only one patch of the series.
Then yes, if you don't mind, please apply this patch :)
Cheers,
Matt
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 21:23 ` Matthieu Baerts
@ 2020-11-09 22:20 ` Jakub Kicinski
2020-11-12 2:36 ` Geliang Tang
0 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2020-11-09 22:20 UTC (permalink / raw)
To: Matthieu Baerts
Cc: Geliang Tang, Mat Martineau, David S. Miller, Paolo Abeni,
netdev, mptcp, linux-kernel, Dan Carpenter
On Mon, 9 Nov 2020 21:23:33 +0000 (UTC) Matthieu Baerts wrote:
> 09 Nov 2020 21:57:05 Jakub Kicinski <kuba@kernel.org>:
> > On Mon, 9 Nov 2020 17:28:54 +0100 Matthieu Baerts wrote:
> >> A small detail (I think): the Signed-off-by of the sender (Geliang)
> >> should be the last one in the list if I am not mistaken.
> >> But I guess this is not blocking.
> >>
> >> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> >
> > I take it you'd like me to apply patch 1 directly to net?
>
> Sorry, I didn't know it was OK to apply only one patch of the series.
> Then yes, if you don't mind, please apply this patch :)
Not really, I was just establishing ownership ;)
Geliang Tang, please rebase on net and repost just the first patch.
It does not apply to net as is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer
2020-11-09 22:20 ` Jakub Kicinski
@ 2020-11-12 2:36 ` Geliang Tang
0 siblings, 0 replies; 11+ messages in thread
From: Geliang Tang @ 2020-11-12 2:36 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Matthieu Baerts, Mat Martineau, David S. Miller, Paolo Abeni,
netdev, mptcp,
To: Phillip Lougher <phillip@squashfs.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Kees Cook <keescook@chromium.org>,
Coly Li <colyli@suse.de>, linux-fsdevel@vger.kernel.org,,
Dan Carpenter
Hi Jakub, Matt,
Jakub Kicinski <kuba@kernel.org> 于2020年11月10日周二 上午6:20写道:
>
> On Mon, 9 Nov 2020 21:23:33 +0000 (UTC) Matthieu Baerts wrote:
> > 09 Nov 2020 21:57:05 Jakub Kicinski <kuba@kernel.org>:
> > > On Mon, 9 Nov 2020 17:28:54 +0100 Matthieu Baerts wrote:
> > >> A small detail (I think): the Signed-off-by of the sender (Geliang)
> > >> should be the last one in the list if I am not mistaken.
> > >> But I guess this is not blocking.
> > >>
> > >> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> > >
> > > I take it you'd like me to apply patch 1 directly to net?
> >
> > Sorry, I didn't know it was OK to apply only one patch of the series.
> > Then yes, if you don't mind, please apply this patch :)
>
> Not really, I was just establishing ownership ;)
>
> Geliang Tang, please rebase on net and repost just the first patch.
> It does not apply to net as is.
v2 of this patch had been sent out.
http://patchwork.ozlabs.org/project/netdev/patch/078a2ef5bdc4e3b2c25ef852461692001f426495.1604976945.git.geliangtang@gmail.com/
This patch should be applied to net-next, not -net. Since commit "mptcp:
add a new sysctl add_addr_timeout" is not applied to -net yet.
-Geliang
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-11-12 5:32 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 13:59 [MPTCP][PATCH net 0/2] fix static checker warnings in Geliang Tang
2020-11-09 13:59 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Geliang Tang
2020-11-09 13:59 ` [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list Geliang Tang
2020-11-09 16:35 ` Matthieu Baerts
2020-11-09 16:28 ` [MPTCP][PATCH net 1/2] mptcp: fix static checker warnings in mptcp_pm_add_timer Matthieu Baerts
2020-11-09 18:34 ` Dan Carpenter
2020-11-09 20:56 ` Jakub Kicinski
2020-11-09 20:57 ` Jakub Kicinski
2020-11-09 21:23 ` Matthieu Baerts
2020-11-09 22:20 ` Jakub Kicinski
2020-11-12 2:36 ` Geliang Tang
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).