netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: fix nla_strcmp to handle more then one trailing null character
@ 2021-05-05 16:58 Maciej Żenczykowski
  2021-05-05 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej Żenczykowski @ 2021-05-05 16:58 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller
  Cc: Linux Network Development Mailing List, Nucca Chen, Cong Wang,
	David Ahern, Jakub Kicinski, Jamal Hadi Salim, Jiri Pirko,
	Jiri Pirko

From: Maciej Żenczykowski <maze@google.com>

Android userspace has been using TCA_KIND with a char[IFNAMESIZ]
many-null-terminated buffer containing the string 'bpf'.

This works on 4.19 and ceases to work on 5.10.

I'm not entirely sure what fixes tag to use, but I think the issue
was likely introduced in the below mentioned 5.4 commit.

Reported-by: Nucca Chen <nuccachen@google.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Fixes: 62794fc4fbf5 ("net_sched: add max len check for TCA_KIND")
Change-Id: I66dc281f165a2858fc29a44869a270a2d698a82b
---
 lib/nlattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/nlattr.c b/lib/nlattr.c
index 5b6116e81f9f..1d051ef66afe 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -828,7 +828,7 @@ int nla_strcmp(const struct nlattr *nla, const char *str)
 	int attrlen = nla_len(nla);
 	int d;
 
-	if (attrlen > 0 && buf[attrlen - 1] == '\0')
+	while (attrlen > 0 && buf[attrlen - 1] == '\0')
 		attrlen--;
 
 	d = attrlen - len;
-- 
2.31.1.527.g47e6f16901-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: fix nla_strcmp to handle more then one trailing null character
  2021-05-05 16:58 [PATCH] net: fix nla_strcmp to handle more then one trailing null character Maciej Żenczykowski
@ 2021-05-05 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-05 19:50 UTC (permalink / raw)
  To: =?utf-8?q?Maciej_=C5=BBenczykowski_=3Czenczykowski=40gmail=2Ecom=3E?=
  Cc: maze, davem, netdev, nuccachen, xiyou.wangcong, dsahern,
	jakub.kicinski, jhs, jiri, jiri

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Wed,  5 May 2021 09:58:31 -0700 you wrote:
> From: Maciej Żenczykowski <maze@google.com>
> 
> Android userspace has been using TCA_KIND with a char[IFNAMESIZ]
> many-null-terminated buffer containing the string 'bpf'.
> 
> This works on 4.19 and ceases to work on 5.10.
> 
> [...]

Here is the summary with links:
  - net: fix nla_strcmp to handle more then one trailing null character
    https://git.kernel.org/netdev/net/c/2c16db6c92b0

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-05 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-05 16:58 [PATCH] net: fix nla_strcmp to handle more then one trailing null character Maciej Żenczykowski
2021-05-05 19:50 ` patchwork-bot+netdevbpf

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).