public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: uacce - add the null check for the input pointer and its pointer members
@ 2024-03-29  6:26 Chenghai Huang
  2024-03-29  6:34 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Chenghai Huang @ 2024-03-29  6:26 UTC (permalink / raw)
  To: gregkh, zhangfei.gao, wangzhou1
  Cc: linux-kernel, linux-crypto, fanghao11, shenyang39, liulongfang,
	qianweili

The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
pointer verification is added on the pointer type input parameter and its
pointer members.

Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
 drivers/misc/uacce/uacce.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
index bdc2e6fda782..964f1a6a16e0 100644
--- a/drivers/misc/uacce/uacce.c
+++ b/drivers/misc/uacce/uacce.c
@@ -514,6 +514,9 @@ struct uacce_device *uacce_alloc(struct device *parent,
 	struct uacce_device *uacce;
 	int ret;
 
+	if (!parent || !interface || !interface->ops)
+		return ERR_PTR(-EINVAL);
+
 	uacce = kzalloc(sizeof(struct uacce_device), GFP_KERNEL);
 	if (!uacce)
 		return ERR_PTR(-ENOMEM);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: uacce - add the null check for the input pointer and its pointer members
  2024-03-29  6:26 [PATCH] misc: uacce - add the null check for the input pointer and its pointer members Chenghai Huang
@ 2024-03-29  6:34 ` Greg KH
       [not found]   ` <d6890b98-2f75-4077-b7bc-e995e9901574@huawei.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2024-03-29  6:34 UTC (permalink / raw)
  To: Chenghai Huang
  Cc: zhangfei.gao, wangzhou1, linux-kernel, linux-crypto, fanghao11,
	shenyang39, liulongfang, qianweili

On Fri, Mar 29, 2024 at 02:26:55PM +0800, Chenghai Huang wrote:
> The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
> pointer verification is added on the pointer type input parameter and its
> pointer members.

I do not understand, why does the export type matter?  Just fix any
callers to use this properly and send proper parameters.  What in-tree
caller needs this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: uacce - add the null check for the input pointer and its pointer members
       [not found]   ` <d6890b98-2f75-4077-b7bc-e995e9901574@huawei.com>
@ 2024-03-30  7:01     ` Greg KH
  2024-03-30  7:10       ` huangchenghai
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2024-03-30  7:01 UTC (permalink / raw)
  To: huangchenghai
  Cc: zhangfei.gao, wangzhou1, linux-kernel, linux-crypto, fanghao11,
	shenyang39, liulongfang, qianweili

On Sat, Mar 30, 2024 at 11:34:24AM +0800, huangchenghai wrote:
> 
> On Fri, Mar 29, 2024 at2:34PM, Greg KH wrote:
> 
> > On Fri, Mar 29, 2024 at 02:26:55PM +0800, Chenghai Huang wrote:
> > > The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
> > > pointer verification is added on the pointer type input parameter and its
> > > pointer members.
> > I do not understand, why does the export type matter?  Just fix any
> > callers to use this properly and send proper parameters.  What in-tree
> > caller needs this?
> > 
> > thanks,
> > 
> > greg k-h
> 
> The interface defined by the export type seems important and the input
> parameters need to be verified.

The export type does not matter at all.

> But I understand from your mail that this is the job of the caller.

Exactly.

> By the way, I still have a confusion. Interfaces like ioctrl, debugfs, read,
> or write require parameter validation. so what kind of kernel interfaces require
> parameter validation? Is there a definition?

Some do, some do not, it depends on the situation.  If data comes from
an untrusted source (i.e. outside the kernel), then it MUST be validated
(remember "all input is evil"), but if it's from within the kernel,
usually it does not.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: uacce - add the null check for the input pointer and its pointer members
  2024-03-30  7:01     ` Greg KH
@ 2024-03-30  7:10       ` huangchenghai
  0 siblings, 0 replies; 4+ messages in thread
From: huangchenghai @ 2024-03-30  7:10 UTC (permalink / raw)
  To: Greg KH
  Cc: zhangfei.gao, wangzhou1, linux-kernel, linux-crypto, fanghao11,
	shenyang39, liulongfang, qianweili


在 2024/3/30 15:01, Greg KH 写道:
> On Sat, Mar 30, 2024 at 11:34:24AM +0800, huangchenghai wrote:
>> On Fri, Mar 29, 2024 at2:34PM, Greg KH wrote:
>>
>>> On Fri, Mar 29, 2024 at 02:26:55PM +0800, Chenghai Huang wrote:
>>>> The uacce_alloc() is the member of the EXPORT_SYMBOL_GPL. Therefore, null
>>>> pointer verification is added on the pointer type input parameter and its
>>>> pointer members.
>>> I do not understand, why does the export type matter?  Just fix any
>>> callers to use this properly and send proper parameters.  What in-tree
>>> caller needs this?
>>>
>>> thanks,
>>>
>>> greg k-h
>> The interface defined by the export type seems important and the input
>> parameters need to be verified.
> The export type does not matter at all.
>
>> But I understand from your mail that this is the job of the caller.
> Exactly.
>
>> By the way, I still have a confusion. Interfaces like ioctrl, debugfs, read,
>> or write require parameter validation. so what kind of kernel interfaces require
>> parameter validation? Is there a definition?
> Some do, some do not, it depends on the situation.  If data comes from
> an untrusted source (i.e. outside the kernel), then it MUST be validated
> (remember "all input is evil"), but if it's from within the kernel,
> usually it does not.
>
> thanks,
>
> greg k-h

I get it, thank you very much.

thanks,

Chenghai


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-30  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29  6:26 [PATCH] misc: uacce - add the null check for the input pointer and its pointer members Chenghai Huang
2024-03-29  6:34 ` Greg KH
     [not found]   ` <d6890b98-2f75-4077-b7bc-e995e9901574@huawei.com>
2024-03-30  7:01     ` Greg KH
2024-03-30  7:10       ` huangchenghai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox