[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200513210311.GA1822@duo.ucw.cz>
Date: Wed, 13 May 2020 23:03:11 +0200
From: Pavel Machek <pavel@...x.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Xiyu Yang <xiyuyang19@...an.edu.cn>,
Xin Tan <tanxin.ctf@...il.com>,
Sven Eckelmann <sven@...fation.org>,
Simon Wunderlich <sw@...onwunderlich.de>
Subject: Re: [PATCH 4.19 35/48] batman-adv: Fix refcnt leak in
batadv_store_throughput_override
Hi!
> From: Xiyu Yang <xiyuyang19@...an.edu.cn>
>
> commit 6107c5da0fca8b50b4d3215e94d619d38cc4a18c upstream.
>
> batadv_show_throughput_override() invokes batadv_hardif_get_by_netdev(),
> which gets a batadv_hard_iface object from net_dev with increased refcnt
> and its reference is assigned to a local pointer 'hard_iface'.
>
> When batadv_store_throughput_override() returns, "hard_iface" becomes
> invalid, so the refcount should be decreased to keep refcount balanced.
>
> The issue happens in one error path of
> batadv_store_throughput_override(). When batadv_parse_throughput()
> returns NULL, the refcnt increased by batadv_hardif_get_by_netdev() is
> not decreased, causing a refcnt leak.
>
> Fix this issue by jumping to "out" label when batadv_parse_throughput()
> returns NULL.
Ok, this fixes the issue, but it brings up a question:
> --- a/net/batman-adv/sysfs.c
> +++ b/net/batman-adv/sysfs.c
> @@ -1093,7 +1093,7 @@ static ssize_t batadv_store_throughput_o
> ret = batadv_parse_throughput(net_dev, buff, "throughput_override",
> &tp_override);
> if (!ret)
> - return count;
> + goto out;
>
If parsing of value from userspace failed we are currently returning
success. That seems wrong. Should we return -EINVAL instead?
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists