All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-23  2:31 Junwen Wu
  2022-04-24 15:23   ` Junwen Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Junwen Wu @ 2022-04-23  2:31 UTC (permalink / raw)
  To: akpm, keescook, adobriyan, fweimer, ddiss
  Cc: linux-kernel, linux-fsdevel, Junwen Wu

Whatever value is written to /proc/$pid/sched, a task's schedstate data
will reset.In some cases, schedstate will drop by accident. We restrict
writing a certain value to this node before the data is reset.

Signed-off-by: Junwen Wu <wudaemon@163.com>
---
 fs/proc/base.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index d654ce7150fd..6bb2677659ce 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1459,13 +1459,21 @@ sched_write(struct file *file, const char __user *buf,
 {
 	struct inode *inode = file_inode(file);
 	struct task_struct *p;
+	char ubuf[5];
 
-	p = get_proc_task(inode);
-	if (!p)
-		return -ESRCH;
-	proc_sched_set_task(p);
+	memset(ubuf, 0, sizeof(ubuf));
+	if (count > 5)
+		count = 0;
+	if (copy_from_user(ubuf, buf, count))
+		return -EFAULT;
+	if (strcmp(ubuf, "reset") == 0) {
+		p = get_proc_task(inode);
+		if (!p)
+			return -ESRCH;
+		proc_sched_set_task(p);
 
-	put_task_struct(p);
+		put_task_struct(p);
+	}
 
 	return count;
 }
-- 
2.25.1


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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-24 15:23   ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Matthew Wilcox @ 2022-04-23  3:05 UTC (permalink / raw)
  To: Junwen Wu
  Cc: akpm, keescook, adobriyan, fweimer, ddiss, linux-kernel, linux-fsdevel

On Sat, Apr 23, 2022 at 02:31:04AM +0000, Junwen Wu wrote:
> Whatever value is written to /proc/$pid/sched, a task's schedstate data
> will reset.In some cases, schedstate will drop by accident. We restrict
> writing a certain value to this node before the data is reset.

... and break the existing scripts which expect the current behaviour.

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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-24 15:27   ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2022-04-23  4:26 UTC (permalink / raw)
  To: Junwen Wu, akpm, keescook, adobriyan, fweimer, ddiss
  Cc: kbuild-all, linux-kernel, linux-fsdevel, Junwen Wu

Hi Junwen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hnaz-mm/master]
[also build test WARNING on kees/for-next/pstore linus/master linux/master v5.18-rc3 next-20220422]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Junwen-Wu/proc-limit-schedstate-node-write-operation/20220423-103457
base:   https://github.com/hnaz/linux-mm master
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220423/202204231250.LYIILAXn-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/e7bc039b7c0aa4e9a5bb3ae2340769a451f795db
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Junwen-Wu/proc-limit-schedstate-node-write-operation/20220423-103457
        git checkout e7bc039b7c0aa4e9a5bb3ae2340769a451f795db
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash fs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   fs/proc/base.c: In function 'sched_write':
>> fs/proc/base.c:1468:13: warning: 'strcmp' of a string of length 5 and an array of size 5 evaluates to nonzero [-Wstring-compare]
    1468 |         if (strcmp(ubuf, "reset") == 0) {
         |             ^~~~~~~~~~~~~~~~~~~~~


vim +/strcmp +1468 fs/proc/base.c

  1454	
  1455	static ssize_t
  1456	sched_write(struct file *file, const char __user *buf,
  1457		    size_t count, loff_t *offset)
  1458	{
  1459		struct inode *inode = file_inode(file);
  1460		struct task_struct *p;
  1461		char ubuf[5];
  1462	
  1463		memset(ubuf, 0, sizeof(ubuf));
  1464		if (count > 5)
  1465			count = 0;
  1466		if (copy_from_user(ubuf, buf, count))
  1467			return -EFAULT;
> 1468		if (strcmp(ubuf, "reset") == 0) {
  1469			p = get_proc_task(inode);
  1470			if (!p)
  1471				return -ESRCH;
  1472			proc_sched_set_task(p);
  1473	
  1474			put_task_struct(p);
  1475		}
  1476	
  1477		return count;
  1478	}
  1479	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-24 15:23   ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2022-04-24 15:23 UTC (permalink / raw)
  To: willy, Junwen Wu
  Cc: adobriyan, akpm, ddiss, fweimer, keescook, linux-fsdevel, linux-kernel

From: Matthew Wilcox <willy@infradead.org>

On Sat, Apr 23, 2022 at 02:31:04AM +0000, Junwen Wu wrote:
> Whatever value is written to /proc/$pid/sched, a task's schedstate data
> will reset.In some cases, schedstate will drop by accident. We restrict
> writing a certain value to this node before the data is reset.

... and break the existing scripts which expect the current behaviour.


Hi, Matthew,can you describe it in more detail.

Thanks


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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-24 15:27   ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2022-04-24 15:27 UTC (permalink / raw)
  To: lkp, Junwen Wu, akpm, keescook, adobriyan, fweimer, ddiss
  Cc: kbuild-all, linux-fsdevel, linux-kernel

From: kernel test robot <lkp@intel.com>

>Hi Junwen,

>Thank you for the patch! Perhaps something to improve:

ooh ,I will fix the warning


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

* Re: [PATCH v1] proc: limit schedstate node write operation
  2022-04-23  2:31 [PATCH v1] proc: limit schedstate node write operation Junwen Wu
  2022-04-24 15:23   ` Junwen Wu
  2022-04-24 15:27   ` Junwen Wu
@ 2022-04-24 15:27 ` Junwen Wu
  2 siblings, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2022-04-24 15:27 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 146 bytes --]

From: kernel test robot <lkp@intel.com>

>Hi Junwen,

>Thank you for the patch! Perhaps something to improve:

ooh ,I will fix the warning

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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-30 13:48     ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Matthew Wilcox @ 2022-04-24 19:23 UTC (permalink / raw)
  To: Junwen Wu
  Cc: adobriyan, akpm, ddiss, fweimer, keescook, linux-fsdevel, linux-kernel

On Sun, Apr 24, 2022 at 03:23:54PM +0000, Junwen Wu wrote:
> From: Matthew Wilcox <willy@infradead.org>
> 
> On Sat, Apr 23, 2022 at 02:31:04AM +0000, Junwen Wu wrote:
> > Whatever value is written to /proc/$pid/sched, a task's schedstate data
> > will reset.In some cases, schedstate will drop by accident. We restrict
> > writing a certain value to this node before the data is reset.
> 
> ... and break the existing scripts which expect the current behaviour.
> 
> 
> Hi, Matthew,can you describe it in more detail.

What detail do you need?  Existing scripts depend on the existing
behaviour.  Your change to the behaviour will break them.  That's not
allowed, so your patch is rejected.

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

* Re: [PATCH v1] proc: limit schedstate node write operation
@ 2022-04-30 13:48     ` Junwen Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Junwen Wu @ 2022-04-30 13:48 UTC (permalink / raw)
  To: willy, Junwen Wu
  Cc: adobriyan, akpm, ddiss, fweimer, keescook, linux-fsdevel, linux-kernel

From: Matthew Wilcox <willy@infradead.org>

On Sun, Apr 24, 2022 at 03:23:54PM +0000, Junwen Wu wrote:
> From: Matthew Wilcox <willy@infradead.org>
> 
> On Sat, Apr 23, 2022 at 02:31:04AM +0000, Junwen Wu wrote:
> > Whatever value is written to /proc/$pid/sched, a task's schedstate data
> > will reset.In some cases, schedstate will drop by accident. We restrict
> > writing a certain value to this node before the data is reset.
> 
> ... and break the existing scripts which expect the current behaviour.
> 
> 
> Hi, Matthew,can you describe it in more detail.

> What detail do you need?  Existing scripts depend on the existing
> behaviour.  Your change to the behaviour will break them.  That's not
> allowed, so your patch is rejected.

ooh ,just how to operate the node make the script break. I write data to
this node can work well.

Thanks


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

end of thread, other threads:[~2022-04-30 13:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23  2:31 [PATCH v1] proc: limit schedstate node write operation Junwen Wu
2022-04-23  3:05 ` Matthew Wilcox
2022-04-24 15:23   ` Junwen Wu
2022-04-24 19:23   ` Matthew Wilcox
2022-04-30 13:48     ` Junwen Wu
2022-04-23  4:26 ` kernel test robot
2022-04-24 15:27   ` Junwen Wu
2022-04-24 15:27 ` Junwen Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.