]> git.pld-linux.org Git - packages/parted.git/blob - 0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch
- release 6 (by relup.sh)
[packages/parted.git] / 0078-libparted-Fix-udev-cookie-leak-in-_dm_resize_partiti.patch
1 From e7870afe3c13dcc77845d48409daa35e3e42b5fb Mon Sep 17 00:00:00 2001
2 From: "Brian C. Lane" <bcl@redhat.com>
3 Date: Thu, 25 May 2017 09:42:23 -0700
4 Subject: [PATCH] libparted: Fix udev cookie leak in _dm_resize_partition
5
6 The function is setting udev cookies, but not using them when waiting
7 for the task. This results in leaked cookies, which can eventually
8 exhaust the available number of semaphores.
9
10 'dmsetup udevcookies' will show a cookie remaining afterwards, and 'ipcs -s'
11 will show the semaphores in use.
12
13 Also simplified the exit so that the task is always destroyed and memory
14 is all freed in the same path.
15
16 Resolves: rhbz#1455564
17 ---
18  libparted/arch/linux.c | 14 +++++++-------
19  1 file changed, 7 insertions(+), 7 deletions(-)
20
21 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
22 index 9886d6e..1a35964 100644
23 --- a/libparted/arch/linux.c
24 +++ b/libparted/arch/linux.c
25 @@ -2943,6 +2943,7 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part)
26          char*           vol_name = NULL;
27          const char*     dev_name = NULL;
28          uint32_t        cookie = 0;
29 +        int             rc = 0;
30  
31          /* Get map name from devicemapper */
32          struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
33 @@ -2983,8 +2984,9 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part)
34          /* device-mapper uses 512b units, not the device's sector size */
35          dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT),
36                  "linear", params);
37 -        if (!dm_task_set_cookie (task, &cookie, 0))
38 -                goto err;
39 +        /* NOTE: DM_DEVICE_RELOAD doesn't generate udev events, so no cookie is needed (it will freeze).
40 +         *       DM_DEVICE_RESUME does, so get a cookie and synchronize with udev.
41 +         */
42          if (dm_task_run (task)) {
43                  dm_task_destroy (task);
44                  task = dm_task_create (DM_DEVICE_RESUME);
45 @@ -2993,10 +2995,8 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part)
46                  dm_task_set_name (task, vol_name);
47                  if (!dm_task_set_cookie (task, &cookie, 0))
48                          goto err;
49 -                if (dm_task_run (task)) {
50 -                        free (params);
51 -                        free (vol_name);
52 -                        return 1;
53 +                if (_dm_task_run_wait (task, cookie)) {
54 +                        rc = 1;
55                  }
56          }
57  err:
58 @@ -3005,7 +3005,7 @@ err:
59                  dm_task_destroy (task);
60          free (params);
61          free (vol_name);
62 -        return 0;
63 +        return rc;
64  }
65  
66  #endif
67 -- 
68 2.9.4
69
This page took 0.059229 seconds and 3 git commands to generate.