linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: kernfs: fix possible null pointer dereferences
@ 2020-04-30 11:20 youngjun
  2020-05-06 12:44 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: youngjun @ 2020-04-30 11:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Tejun Heo, linux-kernel, youngjun

kernfs_path_from_node_locked checks buf is NULL.
But, two cases below are not covered.

if(!kn_to)			<--- case1 (buf can be NULL)
	return strlcpy(buf, "(null)", buflen);

if(kn_from == kn_to)		<--- case2 (buf can be NULL)
	return strlcpy(buf, "/", buflen);

if (!buf)			<--- checked here.
	return -EINVAL;

buf NULL case needs to be checked first.

Signed-off-by: youngjun <her0gyugyu@gmail.com>
---
 fs/kernfs/dir.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 02fb5cc76e33..d802cfceddba 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -128,6 +128,9 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
 	size_t depth_from, depth_to, len = 0;
 	int i, j;
 
+	if (!buf)
+		return -EINVAL;
+
 	if (!kn_to)
 		return strlcpy(buf, "(null)", buflen);
 
@@ -137,9 +140,6 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
 	if (kn_from == kn_to)
 		return strlcpy(buf, "/", buflen);
 
-	if (!buf)
-		return -EINVAL;
-
 	common = kernfs_common_ancestor(kn_from, kn_to);
 	if (WARN_ON(!common))
 		return -EINVAL;
-- 
2.17.1


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

* Re: [PATCH] fs: kernfs: fix possible null pointer dereferences
  2020-04-30 11:20 [PATCH] fs: kernfs: fix possible null pointer dereferences youngjun
@ 2020-05-06 12:44 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-06 12:44 UTC (permalink / raw)
  To: youngjun; +Cc: Tejun Heo, linux-kernel

On Thu, Apr 30, 2020 at 04:20:46AM -0700, youngjun wrote:
> kernfs_path_from_node_locked checks buf is NULL.
> But, two cases below are not covered.
> 
> if(!kn_to)			<--- case1 (buf can be NULL)
> 	return strlcpy(buf, "(null)", buflen);
> 
> if(kn_from == kn_to)		<--- case2 (buf can be NULL)
> 	return strlcpy(buf, "/", buflen);
> 
> if (!buf)			<--- checked here.
> 	return -EINVAL;
> 
> buf NULL case needs to be checked first.
> 
> Signed-off-by: youngjun <her0gyugyu@gmail.com>
> ---
>  fs/kernfs/dir.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

I have 3 patches here from you, with the same subject lines, yet they do
different things.

I'm dropping them all, can you please resend a patch series of the
remaining patches you wish us to review for kernfs?

thanks,

greg k-h

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

end of thread, other threads:[~2020-05-06 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 11:20 [PATCH] fs: kernfs: fix possible null pointer dereferences youngjun
2020-05-06 12:44 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).