lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <422c2ef1aef220d56db0fce5feb8911c4fe541ea.1504206475.git.mirq-linux@rere.qmqm.pl>
Date:   Thu, 31 Aug 2017 21:12:51 +0200
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Ingo Molnar <mingo@...nel.org>, Michal Hocko <mhocko@...e.com>,
        John Stultz <john.stultz@...aro.org>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Al Viro <viro@...iv.linux.org.uk>
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] procfs: signal /proc/pid/comm write truncation

Keeps truncation working, but also signals to writing process
when that happens.

Fixes: 830e0fc967a7 ("fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes")
Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
 fs/proc/base.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index f1e1927ccd48..7238a64751e4 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1492,8 +1492,14 @@ static ssize_t comm_write(struct file *file, const char __user *buf,
 	char buffer[TASK_COMM_LEN];
 	const size_t maxlen = sizeof(buffer) - 1;
 
+	if (*offset)
+		return -ENOSPC;
+
+	if (count > maxlen)
+		count = maxlen;
+
 	memset(buffer, 0, sizeof(buffer));
-	if (copy_from_user(buffer, buf, count > maxlen ? maxlen : count))
+	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
 
 	p = get_proc_task(inode);
@@ -1507,6 +1513,9 @@ static ssize_t comm_write(struct file *file, const char __user *buf,
 
 	put_task_struct(p);
 
+	if (count > 0)
+		*offset = count;
+
 	return count;
 }
 
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ