Fix: syscall listing: handle "enable all syscall"
[lttng-modules.git] / lttng-syscalls.c
index 1489934f3319bbad05de08d3c404f155bd2feac7..846946ad374ca00d7af1b4f3c36fa0d60155938d 100644 (file)
@@ -1036,6 +1036,8 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan,
        WARN_ON_ONCE(!chan->sc_table);
 
        if (!chan->sc_filter) {
+               if (!chan->syscall_all)
+                       return -EEXIST;
                filter = kzalloc(sizeof(struct lttng_syscall_filter),
                                GFP_KERNEL);
                if (!filter)
@@ -1048,6 +1050,14 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan,
        }
 
        if (!name) {
+               /* Fail if all syscalls are already disabled. */
+               if (bitmap_empty(filter->sc, NR_syscalls)
+                       && bitmap_empty(filter->sc_compat,
+                               NR_compat_syscalls)) {
+                       ret = -EEXIST;
+                       goto error;
+               }
+
                /* Disable all system calls */
                bitmap_clear(filter->sc, 0, NR_syscalls);
                bitmap_clear(filter->sc_compat, 0, NR_compat_syscalls);
@@ -1220,12 +1230,12 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel,
 
        for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
                bt_bitfield_write_be(tmp_mask, char, bit, 1,
-                       test_bit(bit, filter->sc));
+                       filter ? test_bit(bit, filter->sc) : 1);
        }
        for (; bit < sc_tables_len; bit++) {
                bt_bitfield_write_be(tmp_mask, char, bit, 1,
-                       test_bit(bit - ARRAY_SIZE(sc_table),
-                               filter->sc_compat));
+                       filter ? test_bit(bit - ARRAY_SIZE(sc_table),
+                               filter->sc_compat) : 1);
        }
        if (copy_to_user(usyscall_mask->mask, tmp_mask, bitmask_len))
                ret = -EFAULT;
This page took 0.024209 seconds and 4 git commands to generate.