quotaio_xfs: Fix error handling in xfs_read_dquot()
(cherry picked from commit 648f3151b5aa6a0b532d1e9ef59c2a7db40d20ed)
This commit is contained in:
parent
841525874e
commit
a11cd899d8
36
0008-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch
Normal file
36
0008-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From dba8c5ca95516b9550fc44b2a476ceca60ee4b38 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Kara <jack@suse.cz>
|
||||||
|
Date: Tue, 7 May 2024 12:55:30 +0200
|
||||||
|
Subject: [PATCH] quotaio_xfs: Fix error handling in xfs_read_dquot()
|
||||||
|
|
||||||
|
When quotactl(2) fails, xfs_read_dquot() will happily return zero-filled
|
||||||
|
structure. This is fine when the user structure does not exist but it is
|
||||||
|
wrong when there's other error (like EACCESS). Fix the error handling.
|
||||||
|
|
||||||
|
Signed-off-by: Jan Kara <jack@suse.cz>
|
||||||
|
---
|
||||||
|
quotaio_xfs.c | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
|
||||||
|
index 5abb2c2..a91567d 100644
|
||||||
|
--- a/quotaio_xfs.c
|
||||||
|
+++ b/quotaio_xfs.c
|
||||||
|
@@ -175,7 +175,13 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id)
|
||||||
|
|
||||||
|
qcmd = QCMD(Q_XFS_GETQUOTA, h->qh_type);
|
||||||
|
if (quotactl(qcmd, h->qh_quotadev, id, (void *)&xdqblk) < 0) {
|
||||||
|
- ;
|
||||||
|
+ /*
|
||||||
|
+ * ENOENT means the structure just does not exist - return all
|
||||||
|
+ * zeros. Otherwise return failure.
|
||||||
|
+ */
|
||||||
|
+ if (errno != ENOENT) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk);
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
30
0009-quotaio_xfs-Fix-memory-leak.patch
Normal file
30
0009-quotaio_xfs-Fix-memory-leak.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From c59b85805ee64c7ee2937b91533eb96f56d87738 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pavel Reichl <preichl@redhat.com>
|
||||||
|
Date: Tue, 30 Jul 2024 00:18:13 +0200
|
||||||
|
Subject: [PATCH] quotaio_xfs: Fix memory leak
|
||||||
|
|
||||||
|
Error: RESOURCE_LEAK (CWE-772):
|
||||||
|
quota-4.09/quotaio_xfs.c:162:2: alloc_fn: Storage is returned from allocation function "get_empty_dquot".
|
||||||
|
quota-4.09/quotaio_xfs.c:162:2: var_assign: Assigning: "dquot" = storage returned from "get_empty_dquot()".
|
||||||
|
quota-4.09/quotaio_xfs.c:180:4: leaked_storage: Variable "dquot" going out of scope leaks the storage it points to.
|
||||||
|
|
||||||
|
Signed-off-by: Pavel Reichl <preichl@redhat.com>
|
||||||
|
---
|
||||||
|
quotaio_xfs.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
|
||||||
|
index 2df27b5..5446bc5 100644
|
||||||
|
--- a/quotaio_xfs.c
|
||||||
|
+++ b/quotaio_xfs.c
|
||||||
|
@@ -174,6 +174,7 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id)
|
||||||
|
* zeros. Otherwise return failure.
|
||||||
|
*/
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
+ free(dquot);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Name: quota
|
Name: quota
|
||||||
Version: 4.06
|
Version: 4.06
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Release: 9
|
Release: 10
|
||||||
Summary: Linux Diskquota system as part of the Linux kernel
|
Summary: Linux Diskquota system as part of the Linux kernel
|
||||||
License: BSD and GPLv2 and GPLv2+ and LGPLv2+
|
License: BSD and GPLv2 and GPLv2+ and LGPLv2+
|
||||||
URL: http://sourceforge.net/projects/linuxquota/
|
URL: http://sourceforge.net/projects/linuxquota/
|
||||||
@ -20,6 +20,8 @@ Patch4: 0004-quota_nld-Initialize-sa_mask-when-registering-PID-fi.patch
|
|||||||
Patch5: 0005-quota-nld-fix-open-PID-file-failed-when-systemd-read.patch
|
Patch5: 0005-quota-nld-fix-open-PID-file-failed-when-systemd-read.patch
|
||||||
Patch6: 0006-common.c-fix-strncat-usage.patch
|
Patch6: 0006-common.c-fix-strncat-usage.patch
|
||||||
Patch7: 0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch
|
Patch7: 0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch
|
||||||
|
Patch8: 0008-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch
|
||||||
|
Patch9: 0009-quotaio_xfs-Fix-memory-leak.patch
|
||||||
|
|
||||||
BuildRequires: autoconf, automake, coreutils, rpcgen, systemd, gcc
|
BuildRequires: autoconf, automake, coreutils, rpcgen, systemd, gcc
|
||||||
BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel
|
BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel
|
||||||
@ -128,6 +130,9 @@ make check
|
|||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed May 7 2025 lvyy <lyunmail@163.com> - 1:4.06-10
|
||||||
|
- DESC:Fix error handling in xfs_read_dquot()
|
||||||
|
|
||||||
* Mon Oct 14 2024 lvyy <lyunmail@163.com> - 1:4.06-9
|
* Mon Oct 14 2024 lvyy <lyunmail@163.com> - 1:4.06-9
|
||||||
- DESC:Use realloc(3) instead of reallocarray(3)
|
- DESC:Use realloc(3) instead of reallocarray(3)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user