Skip to contentSkip to conversation

fail_function: remove a redundant mutex unlock

PATCH In review Luo Meng 4 participants 6 messages Nov 10, 2020 – Nov 19, 2020 BPF

lore
Share & tools
lore

Luo Meng

author
#0 lore raw

PATCH 1/1 fail_function: remove a redundant mutex unlock

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")
---
 kernel/fail_function.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/fail_function.c +3 -2
index 63b349168da7..b0b1ad93fa95 100644
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
 	if (copy_from_user(buf, buffer, count)) {
 		ret = -EFAULT;
-		goto out;
+		goto out_free;
 	}
 	buf[count] = '\0';
 	sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 		ret = count;
 	}
 out:
-	kfree(buf);
 	mutex_unlock(&fei_lock);
+out_free:
+	kfree(buf);
 	return ret;
 }
 
Signature · 1 line
2.25.4
Acked-by on v1 1/1
#1 lore raw

Hi Luo,

Quoted 2 lines · On Tue, 10 Nov 2020 16:42:45 +0800 Luo Meng <[email protected]> wrote:

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Oops, thank you for the fix.

Quoted 35 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")
---
 kernel/fail_function.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/fail_function.c +3 -2
index 63b349168da7..b0b1ad93fa95 100644
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
 	if (copy_from_user(buf, buffer, count)) {
 		ret = -EFAULT;
-		goto out;
+		goto out_free;
 	}
 	buf[count] = '\0';
 	sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 		ret = count;
 	}
 out:
-	kfree(buf);
 	mutex_unlock(&fei_lock);
+out_free:
+	kfree(buf);
 	return ret;
 }
 
Signature · 1 line
2.25.4
Signature · 1 line
Masami Hiramatsu <[email protected]>
#2 lore raw
Quoted 6 lines · Masami Hiramatsu

Hi Luo,

On Tue, 10 Nov 2020 16:42:45 +0800
Luo Meng <[email protected]> wrote:

Quoted 6 lines
Quoted 2 lines

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Oops, thank you for the fix.

Did anyone pick this up?
If not, please resend cc-ing bpf@vger so it can get into patchwork and be processed by bpf maintainers.

Thanks!

Quoted 39 lines
Quoted 33 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")
---
 kernel/fail_function.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/fail_function.c +3 -3
index 63b349168da7..b0b1ad93fa95 100644
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
      if (copy_from_user(buf, buffer, count)) {
              ret = -EFAULT;
-             goto out;
+             goto out_free;
      }
      buf[count] = '\0';
      sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
              ret = count;
      }
 out:
-     kfree(buf);
      mutex_unlock(&fei_lock);
+out_free:
+     kfree(buf);
      return ret;
 }
 
--
Quoted 2 lines

2.25.4

--
Masami Hiramatsu <[email protected]>

#3 lore raw

Hi,

Quoted 10 lines · On Tue, 17 Nov 2020 20:08:08 -0800 Alexei Starovoitov…
Quoted 9 lines · Masami Hiramatsu

Hi Luo,

Quoted 2 lines · On Tue, 10 Nov 2020 16:42:45 +0800 Luo Meng <[email protected]> wrote:

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Quoted 7 lines
Quoted 3 lines

Oops, thank you for the fix.

Did anyone pick this up?
If not, please resend cc-ing bpf@vger so it can get into patchwork and be processed by bpf maintainers.

OK, I'll resend this to the bpf@vger.

Thank you,

Quoted 42 lines

Thanks!

Quoted 39 lines
Quoted 33 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")
---
 kernel/fail_function.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/fail_function.c +3 -3
index 63b349168da7..b0b1ad93fa95 100644
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
      if (copy_from_user(buf, buffer, count)) {
              ret = -EFAULT;
-             goto out;
+             goto out_free;
      }
      buf[count] = '\0';
      sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
              ret = count;
      }
 out:
-     kfree(buf);
      mutex_unlock(&fei_lock);
+out_free:
+     kfree(buf);
      return ret;
 }
 
--
Quoted 2 lines

2.25.4

--
Masami Hiramatsu <[email protected]>

Signature · 1 line
Masami Hiramatsu <[email protected]>
#4 lore raw

PATCH 1/1 fail_function: remove a redundant mutex unlock

In reply to Luo Meng

From: Luo Meng <[email protected]>

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")

---

 0 files changed
kernel/fail_function.c +3 -2
index 63b349168da7..b0b1ad93fa95 100644
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
 	if (copy_from_user(buf, buffer, count)) {
 		ret = -EFAULT;
-		goto out;
+		goto out_free;
 	}
 	buf[count] = '\0';
 	sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 		ret = count;
 	}
 out:
-	kfree(buf);
 	mutex_unlock(&fei_lock);
+out_free:
+	kfree(buf);
 	return ret;
 }
 
#5 lore raw
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

Quoted 5 lines · On Wed, 18 Nov 2020 22:49:31 +0900 you wrote:

From: Luo Meng <[email protected]>

Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked.

Quoted 7 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")

[...]

Here is the summary with links:
- fail_function: remove a redundant mutex unlock

    https://git.kernel.org/bpf/bpf/c/891515d945a3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html