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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1311649258-24070-1-git-send-email-gaowanlong@cn.fujitsu.com>
Date:	Tue, 26 Jul 2011 11:00:58 +0800
From:	Wanlong Gao <gaowanlong@...fujitsu.com>
To:	linux-kernel@...r.kernel.org
Cc:	gaowanlong@...fujitsu.com, menage@...gle.com, vgoyal@...hat.com,
	axboe@...nel.dk, lizf@...fujitsu.com, wanlong.gao@...il.com
Subject: [PATCH v4] blk-cgroup:be able to remove the record of unplugged device

Thanks for the comments of Paul and Li Zefan.

The bug is we're not able to remove the device from blkio cgroup's
per-device control files if it gets unplugged.

To reproduce the bug:

  # mount -t cgroup -o blkio xxx /cgroup
  # cd /cgroup
  # echo "8:0 1000" > blkio.throttle.read_bps_device
  # unplug the device
  # cat blkio.throttle.read_bps_device
  8:0	1000
  # echo "8:0 0" > blkio.throttle.read_bps_device
  -bash: echo: write error: No such device

After patching, the device removal will succeed.

Signed-off-by: Wanlong Gao <gaowanlong@...fujitsu.com>
---
 block/blk-cgroup.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index bcaf16e..9825094 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -785,7 +785,7 @@ static int blkio_policy_parse_and_set(char *buf,
 {
 	char *s[4], *p, *major_s = NULL, *minor_s = NULL;
 	int ret;
-	unsigned long major, minor, temp;
+	unsigned long major, minor, weight;
 	int i = 0;
 	dev_t dev;
 	u64 bps, iops;
@@ -826,25 +826,25 @@ static int blkio_policy_parse_and_set(char *buf,
 
 	dev = MKDEV(major, minor);
 
-	ret = blkio_check_dev_num(dev);
+	ret = strict_strtoul(s[1], 10, &weight);
 	if (ret)
+		return -EINVAL;
+
+	ret = blkio_check_dev_num(dev);
+	if (ret && !weight)
 		return ret;
 
 	newpn->dev = dev;
 
-	if (s[1] == NULL)
-		return -EINVAL;
-
 	switch (plid) {
 	case BLKIO_POLICY_PROP:
-		ret = strict_strtoul(s[1], 10, &temp);
-		if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
-			temp > BLKIO_WEIGHT_MAX)
+		if ((weight < BLKIO_WEIGHT_MIN && weight > 0) ||
+			weight > BLKIO_WEIGHT_MAX)
 			return -EINVAL;
 
 		newpn->plid = plid;
 		newpn->fileid = fileid;
-		newpn->val.weight = temp;
+		newpn->val.weight = weight;
 		break;
 	case BLKIO_POLICY_THROTL:
 		switch(fileid) {
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ