summaryrefslogtreecommitdiff
path: root/debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch')
-rw-r--r--debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch b/debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch
new file mode 100644
index 00000000..92289b1e
--- /dev/null
+++ b/debian/patches/0002-libdiskfs-fix-reference-counting-of-peropen-objects.patch
@@ -0,0 +1,88 @@
+From d6bfa7bf45e77670f5e8150137ff95fd591c0e8c Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 20 Jun 2014 13:54:28 +0200
+Subject: [PATCH 02/10] libdiskfs: fix reference counting of peropen objects
+
+Previously, peropen objects were created with a reference count of
+zero. Therefore, if diskfs_create_protid fails, passing such an
+object to diskfs_release_peropen would lead to a reference count
+underflow.
+
+* libdiskfs/peropen-make.c (diskfs_peropen_make): Initialize reference
+count to one.
+* libdiskfs/protid-make.c (diskfs_start_protid): And consume this
+reference on success. Update comment.
+(diskfs_finish_protid): Update comment.
+* libdiskfs/diskfs.h: Update comments.
+---
+ libdiskfs/diskfs.h | 4 ++--
+ libdiskfs/peropen-make.c | 2 +-
+ libdiskfs/protid-make.c | 6 +++---
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
+index e328527..e59ba99 100644
+--- a/libdiskfs/diskfs.h
++++ b/libdiskfs/diskfs.h
+@@ -820,12 +820,12 @@ diskfs_create_node (struct node *dir, const char *name, mode_t mode,
+ struct dirstat *ds);
+
+ /* Create and return a protid for an existing peropen PO in CRED,
+- referring to user USER. */
++ referring to user USER. On success, consume a reference to PO. */
+ error_t diskfs_create_protid (struct peropen *po, struct iouser *user,
+ struct protid **cred);
+
+ /* Build and return in CRED a protid which has no user identification, for
+- peropen PO. */
++ peropen PO. On success, consume a reference to PO. */
+ error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
+
+ /* Finish building protid CRED started with diskfs_start_protid;
+diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
+index 6d5ca01..788b9a7 100644
+--- a/libdiskfs/peropen-make.c
++++ b/libdiskfs/peropen-make.c
+@@ -31,7 +31,7 @@ diskfs_make_peropen (struct node *np, int flags, struct peropen *context,
+
+ po->filepointer = 0;
+ po->lock_status = LOCK_UN;
+- refcount_init (&po->refcnt, 0);
++ refcount_init (&po->refcnt, 1);
+ po->openstat = flags;
+ po->np = np;
+ po->path = NULL;
+diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c
+index 22aaa2e..bd13bde 100644
+--- a/libdiskfs/protid-make.c
++++ b/libdiskfs/protid-make.c
+@@ -20,7 +20,7 @@
+ #include <assert.h>
+
+ /* Build and return in CRED a protid which has no user identification, for
+- peropen PO. */
++ peropen PO. On success, consume a reference to PO. */
+ error_t
+ diskfs_start_protid (struct peropen *po, struct protid **cred)
+ {
+@@ -29,7 +29,7 @@ diskfs_start_protid (struct peropen *po, struct protid **cred)
+ sizeof (struct protid), cred);
+ if (! err)
+ {
+- refcount_ref (&po->refcnt);
++ /* Consume a reference. */
+ (*cred)->po = po;
+ (*cred)->shared_object = MACH_PORT_NULL;
+ (*cred)->mapped = 0;
+@@ -56,7 +56,7 @@ diskfs_finish_protid (struct protid *cred, struct iouser *user)
+ }
+
+ /* Create and return a protid for an existing peropen PO in CRED for
+- USER. */
++ USER. On success, consume a reference to PO. */
+ error_t
+ diskfs_create_protid (struct peropen *po, struct iouser *user,
+ struct protid **cred)
+--
+2.0.0
+