linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] eventfs: Directly return NULL to avoid null point dereferenced
@ 2024-05-11  2:42 hao.ge
  2024-05-12 17:12 ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: hao.ge @ 2024-05-11  2:42 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers
  Cc: linux-kernel, linux-trace-kernel, Hao Ge

From: Hao Ge <gehao@kylinos.cn>

When the condition ei->is_free holds,we return NULL directly to
avoid update_events_attr to use NULL point about ei.

Fixes: 8186fff7ab64 ("tracefs/eventfs: Use root and instance inodes as default ownership")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
 fs/tracefs/event_inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index a878cea70f4c..da2827c6acc2 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -346,8 +346,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
 		 * doesn't matter.
 		 */
 		if (ei->is_freed) {
-			ei = NULL;
-			break;
+			return NULL;
 		}
 		// Walk upwards until you find the events inode
 	} while (!ei->is_events);
-- 
2.25.1


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

* Re: [PATCH] eventfs: Directly return NULL to avoid null point dereferenced
  2024-05-11  2:42 [PATCH] eventfs: Directly return NULL to avoid null point dereferenced hao.ge
@ 2024-05-12 17:12 ` Markus Elfring
  2024-05-13  3:25   ` Hao Ge
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-05-12 17:12 UTC (permalink / raw)
  To: Hao Ge, linux-trace-kernel, kernel-janitors, Masami Hiramatsu,
	Mathieu Desnoyers, Steven Rostedt
  Cc: LKML, Hao Ge

> When the condition ei->is_free holds,we return NULL directly to
> avoid update_events_attr to use NULL point about ei.

* Please avoid typos in the summary phrase and the commit message.

* Would you like to use an imperative wording for an improved change description?
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc7#n94> +++ b/fs/tracefs/event_inode.c
> @@ -346,8 +346,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
>  		 * doesn't matter.
>  		 */
>  		if (ei->is_freed) {
> -			ei = NULL;
> -			break;
> +			return NULL;
>  		}
…

How do you think about to omit curly brackets here?

Regards,
Markus

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

* Re: [PATCH] eventfs: Directly return NULL to avoid null point dereferenced
  2024-05-12 17:12 ` Markus Elfring
@ 2024-05-13  3:25   ` Hao Ge
  2024-05-13  5:33     ` [PATCH v2] eventfs: Fix a possible null pointer dereference in eventfs_find_events hao.ge
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Ge @ 2024-05-13  3:25 UTC (permalink / raw)
  To: Markus Elfring, Hao Ge, linux-trace-kernel, kernel-janitors,
	Masami Hiramatsu, Mathieu Desnoyers, Steven Rostedt
  Cc: LKML

Hi Markus


Thanks for your review.


在 5/13/24 01:12, Markus Elfring 写道:
>> When the condition ei->is_free holds,we return NULL directly to
>> avoid update_events_attr to use NULL point about ei.
> * Please avoid typos in the summary phrase and the commit message.
>
> * Would you like to use an imperative wording for an improved change description?
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc7#n94
>
>
> …
OK, I'll study it,
>> +++ b/fs/tracefs/event_inode.c
>> @@ -346,8 +346,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
>>   		 * doesn't matter.
>>   		 */
>>   		if (ei->is_freed) {
>> -			ei = NULL;
>> -			break;
>> +			return NULL;
>>   		}
> …
>
> How do you think about to omit curly brackets here?
You are right, I will make changes to it in future versions
>
> Regards,
> Markus

Best Regards

Hao


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

* [PATCH v2] eventfs: Fix a possible null pointer dereference in eventfs_find_events
  2024-05-13  3:25   ` Hao Ge
@ 2024-05-13  5:33     ` hao.ge
  0 siblings, 0 replies; 4+ messages in thread
From: hao.ge @ 2024-05-13  5:33 UTC (permalink / raw)
  To: rostedt, mhiramat, mathieu.desnoyers
  Cc: linux-kernel, linux-trace-kernel, hao.ge, Hao Ge

From: Hao Ge <gehao@kylinos.cn>

In function eventfs_find_events,there is a potential null pointer
that may be caused by calling update_events_attr which will perform
some operations on the members of the ei struct when ei is NULL.

Hence,When ei->is_freed is set,return NULL directly.

Fixes: 8186fff7ab64 ("tracefs/eventfs: Use root and instance inodes as default ownership")
Signed-off-by: Hao Ge <gehao@kylinos.cn>

---
v2:
- adjust title and commit message
- omit curly brackets
---
 fs/tracefs/event_inode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index a878cea70f4c..0256afdd4acf 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -345,10 +345,9 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
 		 * If the ei is being freed, the ownership of the children
 		 * doesn't matter.
 		 */
-		if (ei->is_freed) {
-			ei = NULL;
-			break;
-		}
+		if (ei->is_freed)
+			return NULL;
+
 		// Walk upwards until you find the events inode
 	} while (!ei->is_events);
 
-- 
2.25.1


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

end of thread, other threads:[~2024-05-13  5:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-11  2:42 [PATCH] eventfs: Directly return NULL to avoid null point dereferenced hao.ge
2024-05-12 17:12 ` Markus Elfring
2024-05-13  3:25   ` Hao Ge
2024-05-13  5:33     ` [PATCH v2] eventfs: Fix a possible null pointer dereference in eventfs_find_events hao.ge

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).