Skip to contentSkip to conversation

procfs: Fix a locking bug in a vmcore_add_device_dump() error path

PATCH Applied Bart Van Assche 4 participants 7 messages Jan 29, 2025 – Feb 2, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 procfs: Fix a locking bug in a vmcore_add_device_dump() error path

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")
---
 fs/proc/vmcore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/proc/vmcore.c +4 -1
index a00120a3c099..10d01eb09c43 100644
@@ -1524,7 +1524,7 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
 		pr_warn_once("Unexpected adding of device dump\n");
 	if (vmcore_open) {
 		ret = -EBUSY;
-		goto out_err;
+		goto unlock;
 	}
 
 	list_add_tail(&dump->list, &vmcoredd_list);
@@ -1532,6 +1532,9 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
 	mutex_unlock(&vmcore_mutex);
 	return 0;
 
+unlock:
+	mutex_unlock(&vmcore_mutex);
+
 out_err:
 	vfree(buf);
 	vfree(dump);
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")
Quoted 27 lines
---
 fs/proc/vmcore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/proc/vmcore.c +4 -1
index a00120a3c099..10d01eb09c43 100644
@@ -1524,7 +1524,7 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
 		pr_warn_once("Unexpected adding of device dump\n");
 	if (vmcore_open) {
 		ret = -EBUSY;
-		goto out_err;
+		goto unlock;
 	}
 
 	list_add_tail(&dump->list, &vmcoredd_list);
@@ -1532,6 +1532,9 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
 	mutex_unlock(&vmcore_mutex);
 	return 0;
 
+unlock:
+	mutex_unlock(&vmcore_mutex);
+
 out_err:
 	vfree(buf);
 	vfree(dump);
maintainer
#2 lore raw
Quoted 10 lines · On Thu, 30 Jan 2025 02:02:38 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")

This applies to patches which are in linux-next via your tree (I think), so I'll take the above to mean "thanks, applied" ;)

btw, 0f3b1c40c652 doesn't have a Link: tag. Please add to your todo list?

#3 lore raw
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Thu, 30 Jan 2025 02:02:38 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")
Quoted 4 lines
Quoted 1 line

This applies to patches which are in linux-next via your tree (I think), so I'll take the above to mean "thanks, applied" ;)

Is my understanding correct that the commit fixed by this patch made it into Linus' tree a few days ago?

$ git log --after=2025-01-26 --before=2025-01-27 origin/master | \
    grep 0f3b1c40c652
commit 0f3b1c40c65262a216fb459fd375f39442a5138b

Thanks,

Bart.

maintainer
#4 lore raw
Quoted 12 lines · On Thu, 30 Jan 2025 17:02:08 -0800 Bart Van Assche <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Thu, 30 Jan 2025 02:02:38 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

This applies to patches which are in linux-next via your tree (I think), so I'll take the above to mean "thanks, applied" ;)

Is my understanding correct that the commit fixed by this patch made it into Linus' tree a few days ago?

Ah, OK, thanks, grabbed.

(So that's what "git pull" does. I'll have to write that down.)

#5 lore raw
Quoted 19 lines · Andrew Morton
Quoted 17 lines · On Thu, 30 Jan 2025 17:02:08 -0800 Bart Van Assche <[email protected]> wrote:
Quoted 15 lines · Andrew Morton
Quoted 10 lines · On Thu, 30 Jan 2025 02:02:38 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")

This applies to patches which are in linux-next via your tree (I think), so I'll take the above to mean "thanks, applied" ;)

Quoted 7 lines
Quoted 3 lines

Is my understanding correct that the commit fixed by this patch made it into Linus' tree a few days ago?

Ah, OK, thanks, grabbed.

(So that's what "git pull" does. I'll have to write that down.)

:)
Thanks.

Acked-by on v1 1/1
#6 lore raw
In reply to Bart Van Assche
Quoted 16 lines · Bart Van Assche

Unlock vmcore_mutex when returning -EBUSY.

Cc David Hildenbrand <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Fixes 0f3b1c40c652 ("fs/proc/vmcore: disallow vmcore modifications while the vmcore is open")
---
  fs/proc/vmcore.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
fs/proc/vmcore.cfs/proc/vmcore.c renamed from fs/proc/vmcore.c +0 -0
index a00120a3c099..10d01eb09c43 100644

fs/proc/vmcore.cfs/proc/vmcore.c int vmcore_add_device_dump(struct vmcoredd_data *data) · line 1527

Quoted 5 lines
fs/proc/vmcore.cfs/proc/vmcore.c renamed from fs/proc/vmcore.c +1 -1
@@ -1524,7 +1524,7 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
  		pr_warn_once("Unexpected adding of device dump\n");
  	if (vmcore_open) {
  		ret = -EBUSY;
-		goto out_err;
+		goto unlock;

Thanks!

Signature · 3 lines
Cheers,

David / dhildenb