|
|
5a6fb1c |
From 34c4eae2eb493d4de97f5f9e784d4efc73b9f886 Mon Sep 17 00:00:00 2001
|
|
|
5a6fb1c |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
5a6fb1c |
Date: Fri, 7 Jan 2011 13:53:13 +0100
|
|
|
5a6fb1c |
Subject: [PATCH] Check set limits fit into the range supported by RPC transport
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
E.g. setquota -r root $((2**32)) 1000 10 10 /mnt/nfs/12tb
|
|
|
5a6fb1c |
clamped the values into 32 bits and RPC server got 0 soft block limit.
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
This fixes simalar bug spotted in 8a4dc3612c6c170c05e5eef68dd3555baeb341c1
|
|
|
5a6fb1c |
(Check whether set limits fit into the range supported by quota format.)
|
|
|
5a6fb1c |
---
|
|
|
5a6fb1c |
quotaio.c | 2 ++
|
|
|
5a6fb1c |
quotaio_rpc.c | 18 ++++++++++++++++++
|
|
|
5a6fb1c |
rquota_client.c | 5 +++++
|
|
|
5a6fb1c |
3 files changed, 25 insertions(+), 0 deletions(-)
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
diff --git a/quotaio.c b/quotaio.c
|
|
|
5a6fb1c |
index 21881fc..3b74680 100644
|
|
|
5a6fb1c |
--- a/quotaio.c
|
|
|
5a6fb1c |
+++ b/quotaio.c
|
|
|
5a6fb1c |
@@ -69,6 +69,8 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
|
|
|
5a6fb1c |
h->qh_fd = -1;
|
|
|
5a6fb1c |
h->qh_fmt = QF_RPC;
|
|
|
5a6fb1c |
h->qh_ops = "afile_ops_rpc;
|
|
|
5a6fb1c |
+ memset(&h->qh_info, 0, sizeof(h->qh_info));
|
|
|
5a6fb1c |
+ h->qh_ops->init_io(h);
|
|
|
5a6fb1c |
return h;
|
|
|
5a6fb1c |
#else
|
|
|
5a6fb1c |
errstr(_("RPC quota format not compiled.\n"));
|
|
|
5a6fb1c |
diff --git a/quotaio_rpc.c b/quotaio_rpc.c
|
|
|
5a6fb1c |
index 14fe410..2e0b493 100644
|
|
|
5a6fb1c |
--- a/quotaio_rpc.c
|
|
|
5a6fb1c |
+++ b/quotaio_rpc.c
|
|
|
5a6fb1c |
@@ -15,14 +15,32 @@
|
|
|
5a6fb1c |
#include "rquota_client.h"
|
|
|
5a6fb1c |
#include "pot.h"
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
+static int rpc_init_io(struct quota_handle *h);
|
|
|
5a6fb1c |
static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id);
|
|
|
5a6fb1c |
static int rpc_commit_dquot(struct dquot *dquot, int flags);
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
struct quotafile_ops quotafile_ops_rpc = {
|
|
|
5a6fb1c |
+init_io: rpc_init_io,
|
|
|
5a6fb1c |
read_dquot: rpc_read_dquot,
|
|
|
5a6fb1c |
commit_dquot: rpc_commit_dquot
|
|
|
5a6fb1c |
};
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
+/*
|
|
|
5a6fb1c |
+ * Define maximal values RPC client can transmit to server.
|
|
|
5a6fb1c |
+ */
|
|
|
5a6fb1c |
+static int rpc_init_io(struct quota_handle *h)
|
|
|
5a6fb1c |
+{
|
|
|
5a6fb1c |
+#ifdef RPC
|
|
|
5a6fb1c |
+ h->qh_info.dqi_max_b_limit = ~(uint32_t)0;
|
|
|
5a6fb1c |
+ h->qh_info.dqi_max_i_limit = ~(uint32_t)0;
|
|
|
5a6fb1c |
+ h->qh_info.dqi_max_b_usage = (~(uint32_t)0) << QUOTABLOCK_BITS;
|
|
|
5a6fb1c |
+ h->qh_info.dqi_max_i_usage = ~(uint32_t)0;
|
|
|
5a6fb1c |
+ return 0;
|
|
|
5a6fb1c |
+#else
|
|
|
5a6fb1c |
+ return -1;
|
|
|
5a6fb1c |
+#endif
|
|
|
5a6fb1c |
+}
|
|
|
5a6fb1c |
+
|
|
|
5a6fb1c |
/*
|
|
|
5a6fb1c |
* Read a dqblk struct from RPC server - just wrapper function.
|
|
|
5a6fb1c |
*/
|
|
|
5a6fb1c |
diff --git a/rquota_client.c b/rquota_client.c
|
|
|
5a6fb1c |
index cc1d623..4aad4b9 100644
|
|
|
5a6fb1c |
--- a/rquota_client.c
|
|
|
5a6fb1c |
+++ b/rquota_client.c
|
|
|
5a6fb1c |
@@ -242,6 +242,11 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
|
|
|
5a6fb1c |
char *fsname_tmp, *host, *pathname;
|
|
|
5a6fb1c |
struct timeval timeout = { 2, 0 };
|
|
|
5a6fb1c |
|
|
|
5a6fb1c |
+ /* RPC limits values to 32b variables. Prevent value wrapping. */
|
|
|
5a6fb1c |
+ if (check_dquot_range(dquot) < 0) {
|
|
|
5a6fb1c |
+ return -ERANGE;
|
|
|
5a6fb1c |
+ }
|
|
|
5a6fb1c |
+
|
|
|
5a6fb1c |
/*
|
|
|
5a6fb1c |
* Convert host:pathname to seperate host and pathname.
|
|
|
5a6fb1c |
*/
|
|
|
5a6fb1c |
--
|
|
|
5a6fb1c |
1.7.3.4
|
|
|
5a6fb1c |
|