[quota] Check set limits fit into the range supported by RPC transport
Petr Pisar
ppisar at fedoraproject.org
Tue Jan 11 10:05:18 UTC 2011
commit 5a6fb1cc1e41ad173d061a52bb8784c13c1bb857
Author: Petr Písař <ppisar at redhat.com>
Date: Tue Jan 11 10:56:31 2011 +0100
Check set limits fit into the range supported by RPC transport
...imits-fit-into-the-range-supported-by-RPC.patch | 85 ++++++++++++++++++++
quota.spec | 4 +
2 files changed, 89 insertions(+), 0 deletions(-)
---
diff --git a/quota-4.00_pre1-Check-set-limits-fit-into-the-range-supported-by-RPC.patch b/quota-4.00_pre1-Check-set-limits-fit-into-the-range-supported-by-RPC.patch
new file mode 100644
index 0000000..7ff5403
--- /dev/null
+++ b/quota-4.00_pre1-Check-set-limits-fit-into-the-range-supported-by-RPC.patch
@@ -0,0 +1,85 @@
+From 34c4eae2eb493d4de97f5f9e784d4efc73b9f886 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Fri, 7 Jan 2011 13:53:13 +0100
+Subject: [PATCH] Check set limits fit into the range supported by RPC transport
+
+E.g. setquota -r root $((2**32)) 1000 10 10 /mnt/nfs/12tb
+clamped the values into 32 bits and RPC server got 0 soft block limit.
+
+This fixes simalar bug spotted in 8a4dc3612c6c170c05e5eef68dd3555baeb341c1
+(Check whether set limits fit into the range supported by quota format.)
+---
+ quotaio.c | 2 ++
+ quotaio_rpc.c | 18 ++++++++++++++++++
+ rquota_client.c | 5 +++++
+ 3 files changed, 25 insertions(+), 0 deletions(-)
+
+diff --git a/quotaio.c b/quotaio.c
+index 21881fc..3b74680 100644
+--- a/quotaio.c
++++ b/quotaio.c
+@@ -69,6 +69,8 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
+ h->qh_fd = -1;
+ h->qh_fmt = QF_RPC;
+ h->qh_ops = "afile_ops_rpc;
++ memset(&h->qh_info, 0, sizeof(h->qh_info));
++ h->qh_ops->init_io(h);
+ return h;
+ #else
+ errstr(_("RPC quota format not compiled.\n"));
+diff --git a/quotaio_rpc.c b/quotaio_rpc.c
+index 14fe410..2e0b493 100644
+--- a/quotaio_rpc.c
++++ b/quotaio_rpc.c
+@@ -15,14 +15,32 @@
+ #include "rquota_client.h"
+ #include "pot.h"
+
++static int rpc_init_io(struct quota_handle *h);
+ static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id);
+ static int rpc_commit_dquot(struct dquot *dquot, int flags);
+
+ struct quotafile_ops quotafile_ops_rpc = {
++init_io: rpc_init_io,
+ read_dquot: rpc_read_dquot,
+ commit_dquot: rpc_commit_dquot
+ };
+
++/*
++ * Define maximal values RPC client can transmit to server.
++ */
++static int rpc_init_io(struct quota_handle *h)
++{
++#ifdef RPC
++ h->qh_info.dqi_max_b_limit = ~(uint32_t)0;
++ h->qh_info.dqi_max_i_limit = ~(uint32_t)0;
++ h->qh_info.dqi_max_b_usage = (~(uint32_t)0) << QUOTABLOCK_BITS;
++ h->qh_info.dqi_max_i_usage = ~(uint32_t)0;
++ return 0;
++#else
++ return -1;
++#endif
++}
++
+ /*
+ * Read a dqblk struct from RPC server - just wrapper function.
+ */
+diff --git a/rquota_client.c b/rquota_client.c
+index cc1d623..4aad4b9 100644
+--- a/rquota_client.c
++++ b/rquota_client.c
+@@ -242,6 +242,11 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
+ char *fsname_tmp, *host, *pathname;
+ struct timeval timeout = { 2, 0 };
+
++ /* RPC limits values to 32b variables. Prevent value wrapping. */
++ if (check_dquot_range(dquot) < 0) {
++ return -ERANGE;
++ }
++
+ /*
+ * Convert host:pathname to seperate host and pathname.
+ */
+--
+1.7.3.4
+
diff --git a/quota.spec b/quota.spec
index 4458d0c..c53a3f0 100644
--- a/quota.spec
+++ b/quota.spec
@@ -37,6 +37,8 @@ Patch12: quota-4.00_pre1-Document-always-resolve-at-edquota-and-setquota.patch
Patch13: quota-4.00_pre1-Make-RPC-block-factor-dynamic.patch
# Bug #668688, included in upstream 4.00_pre2
Patch14: quota-4.00_pre1-Check-whether-set-limits-fit-into-the-range-supporte.patch
+# Bug #668691
+Patch15: quota-4.00_pre1-Check-set-limits-fit-into-the-range-supported-by-RPC.patch
%description
The quota package contains system administration tools for monitoring
@@ -121,6 +123,7 @@ Linux/UNIX environment.
%patch12 -p1 -b .document_always_resolve_setquota
%patch13 -p1 -b .rpc_block_factor_dynamic
%patch14 -p1 -b .check_set_limits
+%patch15 -p1 -b .check_set_limits_rpc
# quotactl(2) moved into `man-pages' package (bug #640590)
rm -f quotactl.2
# remove VCS files
@@ -246,6 +249,7 @@ rm -rf %{buildroot}
- Make RPC block factor dynamic (bug #667757)
- Check whether set limits fit into the range supported by quota format
(bug #668688)
+- Check set limits fit into the range supported by RPC transport (bug #668691)
* Mon Jan 10 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-0.3.pre1
- Document --always-resolve option
More information about the scm-commits
mailing list