diff mbox series

[SRU,I/F,1/1] xfrm: fix the if_id check in changelink

Message ID 20220412071734.11252-2-stefan.bader@canonical.com
State New
Headers show
Series Fix xfrm interface no longer changeable | expand

Commit Message

Stefan Bader April 12, 2022, 7:17 a.m. UTC
From: Antony Antony <antony.antony@secunet.com>

BugLink: https://bugs.launchpad.net/bugs/1968591

if_id will be always 0, because it was not yet initialized.

Fixes: 8dce43919566 ("xfrm: interface with if_id 0 should return error")
Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

(cherry picked from commit 6d0d95a1c2b07270870e7be16575c513c29af3f1)
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 net/xfrm/xfrm_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kleber Sacilotto de Souza April 12, 2022, 7:40 a.m. UTC | #1
On 12.04.22 09:17, Stefan Bader wrote:
> From: Antony Antony <antony.antony@secunet.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1968591
> 
> if_id will be always 0, because it was not yet initialized.
> 
> Fixes: 8dce43919566 ("xfrm: interface with if_id 0 should return error")
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> 
> (cherry picked from commit 6d0d95a1c2b07270870e7be16575c513c29af3f1)
> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Thanks

> ---
>   net/xfrm/xfrm_interface.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
> index 57448fc519fc..4e3c62d1ad9e 100644
> --- a/net/xfrm/xfrm_interface.c
> +++ b/net/xfrm/xfrm_interface.c
> @@ -673,12 +673,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[],
>   	struct net *net = xi->net;
>   	struct xfrm_if_parms p = {};
>   
> +	xfrmi_netlink_parms(data, &p);
>   	if (!p.if_id) {
>   		NL_SET_ERR_MSG(extack, "if_id must be non zero");
>   		return -EINVAL;
>   	}
>   
> -	xfrmi_netlink_parms(data, &p);
>   	xi = xfrmi_locate(net, &p);
>   	if (!xi) {
>   		xi = netdev_priv(dev);
diff mbox series

Patch

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 57448fc519fc..4e3c62d1ad9e 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -673,12 +673,12 @@  static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[],
 	struct net *net = xi->net;
 	struct xfrm_if_parms p = {};
 
+	xfrmi_netlink_parms(data, &p);
 	if (!p.if_id) {
 		NL_SET_ERR_MSG(extack, "if_id must be non zero");
 		return -EINVAL;
 	}
 
-	xfrmi_netlink_parms(data, &p);
 	xi = xfrmi_locate(net, &p);
 	if (!xi) {
 		xi = netdev_priv(dev);