Subject: Re: [PATCH net] net: devlink: fix UAF in devlink_compat_running_version()

From: Jiri Pirko <[email-masked]>
Date: Mon, 28 Nov 2022 11:01:45 +0100

Tue, Nov 22, 2022 at 01:10:48PM CET, [email-masked] wrote:

[...]

>
>Fixes: a62fdbbe9403 ("netdevsim: implement ndo_get_devlink_port")
>Reported-by: Zhengchao Shao <[email-masked]>
>Signed-off-by: Yang Yingliang <[email-masked]>
>---
> net/core/devlink.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/net/core/devlink.c b/net/core/devlink.c
>index 89baa7c0938b..6453ac0558fb 100644
>--- a/net/core/devlink.c
>+++ b/net/core/devlink.c
>@@ -250,6 +250,9 @@ void devlink_put(struct devlink *devlink)
> 
> struct devlink *__must_check devlink_try_get(struct devlink *devlink)
> {
>+	 if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED))

        ^
You have an extra space here. Checkpatch would warn you.

>+		return NULL;
>+
> 	if (refcount_inc_not_zero(&devlink->refcount))
> 		return devlink;
> 	return NULL;
>-- 
>2.25.1
>