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: <aHAE103XZl8yqDuo@quatroqueijos.cascardo.eti.br>
Date: Thu, 10 Jul 2025 15:22:15 -0300
From: Thadeu Lima de Souza Cascardo <cascardo@...lia.com>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: Arnd Bergmann <arnd@...db.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
	Helge Deller <deller@....de>,
	"David S. Miller" <davem@...emloft.net>,
	Andreas Larsson <andreas@...sler.com>, linux-kernel@...r.kernel.org,
	linux-parisc@...r.kernel.org, sparclinux@...r.kernel.org,
	Zijun Hu <zijun.hu@....qualcomm.com>
Subject: Re: [PATCH v5 6/8] char: misc: Does not request module for
 miscdevice with dynamic minor

On Thu, Jul 10, 2025 at 07:56:49PM +0800, Zijun Hu wrote:
> From: Zijun Hu <zijun.hu@....qualcomm.com>
> 
> misc_open() may request module for miscdevice with dynamic minor, which
> is meaningless since:
> 
> - The dynamic minor allocated is unknown in advance without registering
>   miscdevice firstly.
> - Macro MODULE_ALIAS_MISCDEV() is not applicable for dynamic minor.
> 
> Fix by only requesting module for miscdevice with fixed minor.
> 
> Signed-off-by: Zijun Hu <zijun.hu@....qualcomm.com>
> ---
>  drivers/char/misc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index 96ed343cf5c8509a09855020049a9af82a3ede95..a0aae0fc792666a7bdc0ba00da9dc02ff9cead42 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -132,7 +132,8 @@ static int misc_open(struct inode *inode, struct file *file)
>  		break;
>  	}
>  
> -	if (!new_fops) {
> +	/* Only request module for fixed minor code */
> +	if (!new_fops && minor < MISC_DYNAMIC_MINOR) {
>  		mutex_unlock(&misc_mtx);
>  		request_module("char-major-%d-%d", MISC_MAJOR, minor);
>  		mutex_lock(&misc_mtx);
> @@ -144,10 +145,11 @@ static int misc_open(struct inode *inode, struct file *file)
>  			new_fops = fops_get(iter->fops);
>  			break;
>  		}
> -		if (!new_fops)
> -			goto fail;
>  	}
>  
> +	if (!new_fops)
> +		goto fail;
> +
>  	/*
>  	 * Place the miscdevice in the file's
>  	 * private_data so it can be used by the
> 
> -- 
> 2.34.1
> 

Given this should not break any code, as there should be no legit drivers
requesting a minor >= 255,

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@...lia.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ