lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4DFE07D7-B041-4C1C-8182-020066D4A5C2@microgate.com>
Date:   Mon, 14 Nov 2022 08:47:13 -0800
From:   Paul Fulghum <paulkf@...rogate.com>
To:     Zhengchao Shao <shaozhengchao@...wei.com>
Cc:     linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
        jirislaby@...nel.org, akpm@...ux-foundation.org,
        weiyongjun1@...wei.com, yuehaibing@...wei.com
Subject: Re: [PATCH] tty: synclink_gt: release resources when synclink_gt
 driver open failed

This patch identifies two problems in the error path of hdlcdev_open():

1. module_get/put pairing
2. hdlc_open/close pairing

The module_get/put calls are not necessary. The synclink_gt driver is pinned on hardware enumeration which happens before registering as a generic hdlc device. I think this is cruft leftover from ancient code. The only other generic hdlc (network) driver I still see doing it is farsync.c.

The best solution is removing the module_get/put calls and balancing hdlc_open() with hdlc_close() in the error path of hdlcdev_open(). I will submit a patch to do so after I’ve had a chance to test it.





> On Nov 13, 2022, at 5:07 PM, Zhengchao Shao <shaozhengchao@...wei.com> wrote:
> 
> When synclink_gt driver open failed, it doesn't release resources. Compile
> tested only.
> 
> Fixes: d4c63b7c7450 ("synclink_gt fix module reference")
> Fixes: 705b6c7b34f2 ("[PATCH] new driver synclink_gt")
> Signed-off-by: Zhengchao Shao <shaozhengchao@...wei.com>
> ---
> drivers/tty/synclink_gt.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
> index 25e9befdda3a..4dea52486410 100644
> --- a/drivers/tty/synclink_gt.c
> +++ b/drivers/tty/synclink_gt.c
> @@ -1441,14 +1441,15 @@ static int hdlcdev_open(struct net_device *dev)
> 	/* generic HDLC layer open processing */
> 	rc = hdlc_open(dev);
> 	if (rc)
> -		return rc;
> +		goto err_open;
> 
> 	/* arbitrate between network and tty opens */
> 	spin_lock_irqsave(&info->netlock, flags);
> 	if (info->port.count != 0 || info->netcount != 0) {
> 		DBGINFO(("%s hdlc_open busy\n", dev->name));
> 		spin_unlock_irqrestore(&info->netlock, flags);
> -		return -EBUSY;
> +		rc = -EBUSY;
> +		goto err_open_busy;
> 	}
> 	info->netcount=1;
> 	spin_unlock_irqrestore(&info->netlock, flags);
> @@ -1458,7 +1459,7 @@ static int hdlcdev_open(struct net_device *dev)
> 		spin_lock_irqsave(&info->netlock, flags);
> 		info->netcount=0;
> 		spin_unlock_irqrestore(&info->netlock, flags);
> -		return rc;
> +		goto err_open_busy;
> 	}
> 
> 	/* assert RTS and DTR, apply hardware settings */
> @@ -1478,6 +1479,12 @@ static int hdlcdev_open(struct net_device *dev)
> 	else
> 		netif_carrier_off(dev);
> 	return 0;
> +
> +err_open_busy:
> +	hdlc_close(dev);
> +err_open:
> +	module_put(THIS_MODULE);
> +	return rc;
> }
> 
> /**
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ