From c92b994e8927316dfde1701a342e8ba502a422b1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 5 Jul 2022 08:02:04 +0200 Subject: [PATCH] 4.14-stable patches added patches: ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch sit-use-min.patch --- ...ix-ipip6_tunnel_get_prl-return-value.patch | 62 +++++++++++++++++++ queue-4.14/series | 2 + queue-4.14/sit-use-min.patch | 34 ++++++++++ 3 files changed, 98 insertions(+) create mode 100644 queue-4.14/ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch create mode 100644 queue-4.14/sit-use-min.patch diff --git a/queue-4.14/ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch b/queue-4.14/ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch new file mode 100644 index 00000000000..c0c05c14203 --- /dev/null +++ b/queue-4.14/ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch @@ -0,0 +1,62 @@ +From adabdd8f6acabc0c3fdbba2e7f5a2edd9c5ef22d Mon Sep 17 00:00:00 2001 +From: katrinzhou +Date: Tue, 28 Jun 2022 11:50:30 +0800 +Subject: ipv6/sit: fix ipip6_tunnel_get_prl return value + +From: katrinzhou + +commit adabdd8f6acabc0c3fdbba2e7f5a2edd9c5ef22d upstream. + +When kcalloc fails, ipip6_tunnel_get_prl() should return -ENOMEM. +Move the position of label "out" to return correctly. + +Addresses-Coverity: ("Unused value") +Fixes: 300aaeeaab5f ("[IPV6] SIT: Add SIOCGETPRL ioctl to get/dump PRL.") +Signed-off-by: katrinzhou +Reviewed-by: Eric Dumazet +Reviewed-by: David Ahern +Link: https://lore.kernel.org/r/20220628035030.1039171-1-zys.zljxml@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/ipv6/sit.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -308,8 +308,6 @@ static int ipip6_tunnel_get_prl(struct i + kcalloc(cmax, sizeof(*kp), GFP_KERNEL | __GFP_NOWARN) : + NULL; + +- rcu_read_lock(); +- + ca = min(t->prl_count, cmax); + + if (!kp) { +@@ -325,7 +323,7 @@ static int ipip6_tunnel_get_prl(struct i + } + } + +- c = 0; ++ rcu_read_lock(); + for_each_prl_rcu(t->prl) { + if (c >= cmax) + break; +@@ -337,7 +335,7 @@ static int ipip6_tunnel_get_prl(struct i + if (kprl.addr != htonl(INADDR_ANY)) + break; + } +-out: ++ + rcu_read_unlock(); + + len = sizeof(*kp) * c; +@@ -346,7 +344,7 @@ out: + ret = -EFAULT; + + kfree(kp); +- ++out: + return ret; + } + diff --git a/queue-4.14/series b/queue-4.14/series index 91a97acdea1..b9be46df780 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -17,3 +17,5 @@ nfc-nxp-nci-don-t-issue-a-zero-length-i2c_master_read.patch xen-gntdev-avoid-blocking-in-unmap_grant_pages.patch hwmon-ibmaem-don-t-call-platform_device_del-if-platf.patch net-dsa-bcm_sf2-force-pause-link-settings.patch +sit-use-min.patch +ipv6-sit-fix-ipip6_tunnel_get_prl-return-value.patch diff --git a/queue-4.14/sit-use-min.patch b/queue-4.14/sit-use-min.patch new file mode 100644 index 00000000000..e91b5b8b8f9 --- /dev/null +++ b/queue-4.14/sit-use-min.patch @@ -0,0 +1,34 @@ +From 284fda1eff8a8b27d2cafd7dc8fb423d13720f21 Mon Sep 17 00:00:00 2001 +From: kernel test robot +Date: Sat, 27 Mar 2021 10:29:32 +0100 +Subject: sit: use min + +From: kernel test robot + +commit 284fda1eff8a8b27d2cafd7dc8fb423d13720f21 upstream. + +Opportunity for min() + +Generated by: scripts/coccinelle/misc/minmax.cocci + +CC: Denis Efremov +Reported-by: kernel test robot +Signed-off-by: kernel test robot +Reviewed-by: David Ahern +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/ipv6/sit.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/ipv6/sit.c ++++ b/net/ipv6/sit.c +@@ -310,7 +310,7 @@ static int ipip6_tunnel_get_prl(struct i + + rcu_read_lock(); + +- ca = t->prl_count < cmax ? t->prl_count : cmax; ++ ca = min(t->prl_count, cmax); + + if (!kp) { + /* We don't try hard to allocate much memory for -- 2.47.3