SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-09-16 11:23:31 +00:00 committed by Git OBS Bridge
parent 720539c531
commit 3b1ac91cdb
16 changed files with 1153 additions and 0 deletions

View File

@ -0,0 +1,26 @@
From aa44499da15a8fa7026463555a7a27e55e4e24a8 Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert@gmail.com>
Date: Wed, 10 Sep 2014 22:14:41 +0300
Subject: [PATCH] activate: fix fd leak in do_accept()
Found with Coverity.
---
src/activate/activate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git src/activate/activate.c src/activate/activate.c
index 8942773..0a1df37 100644
--- src/activate/activate.c
+++ src/activate/activate.c
@@ -242,7 +242,7 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
static int do_accept(const char* name, char **argv, char **envp, int fd) {
_cleanup_free_ char *local = NULL, *peer = NULL;
- int fd2;
+ _cleanup_close_ int fd2 = -1;
fd2 = accept(fd, NULL, NULL);
if (fd2 < 0) {
--
1.7.9.2

View File

@ -0,0 +1,30 @@
From d725a138c5c311ba06567d6841933aa5b7b6a435 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Thu, 11 Sep 2014 23:41:44 +0200
Subject: [PATCH] analyze: avoid a null dereference
If we have an error in the early sd_bus_* calls then unit_times
will still be null.
Found with coverity. Fixes: CID#996464
---
src/analyze/analyze.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git src/analyze/analyze.c src/analyze/analyze.c
index d860a02..1281d6b 100644
--- src/analyze/analyze.c
+++ src/analyze/analyze.c
@@ -277,7 +277,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
return c;
fail:
- free_unit_times(unit_times, (unsigned) c);
+ if (unit_times)
+ free_unit_times(unit_times, (unsigned) c);
return r;
}
--
1.7.9.2

View File

@ -0,0 +1,27 @@
From 0ee9613d98cbe1f36ffc98c6bfa51dd2b798fc6d Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Sat, 13 Sep 2014 12:29:43 +0200
Subject: [PATCH] analyze: fix mem leak
Found with Coverity. Fixes: CID#1237756
---
src/analyze/analyze.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git src/analyze/analyze.c src/analyze/analyze.c
index 1281d6b..82f5cf3 100644
--- src/analyze/analyze.c
+++ src/analyze/analyze.c
@@ -848,7 +848,8 @@ static int list_dependencies(sd_bus *bus, const char *name) {
char ts[FORMAT_TIMESPAN_MAX];
struct unit_times *times;
int r;
- const char *path, *id;
+ const char *id;
+ _cleanup_free_ char *path = NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
struct boot_times *boot;
--
1.7.9.2

View File

@ -0,0 +1,33 @@
From b76388e123e8d73ded1fd53937d816b314948517 Mon Sep 17 00:00:00 2001
From: Michael Biebl <biebl@debian.org>
Date: Thu, 11 Sep 2014 00:49:36 +0200
Subject: [PATCH] backlight: Avoid error when state restore is disabled
When the state restore is disabled, we would print:
"Unknown verb: load" instead of simply skipping loading the
state.
---
src/backlight/backlight.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git src/backlight/backlight.c src/backlight/backlight.c
index 4d94ebf..0a2bac6 100644
--- src/backlight/backlight.c
+++ src/backlight/backlight.c
@@ -372,9 +372,12 @@ int main(int argc, char *argv[]) {
* device probing should be complete), so that the validity
* check at boot time doesn't have to be reliable. */
- if (streq(argv[1], "load") && shall_restore_state()) {
+ if (streq(argv[1], "load")) {
_cleanup_free_ char *value = NULL;
+ if (!shall_restore_state())
+ return EXIT_SUCCESS;
+
if (!validate_device(udev, device))
return EXIT_SUCCESS;
--
1.7.9.2

View File

@ -0,0 +1,35 @@
Based on fd989a0bc999d79719408ac28b126d9c9016bcb5 Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert@gmail.com>
Date: Wed, 10 Sep 2014 12:20:38 +0300
Subject: [PATCH] bus: avoid using m->kdbus after freeing it
m->kdbus could be freed before it is released. Changing the
order fixes the issue.
Found with Coverity. Fixes: CID#1237798
---
src/libsystemd/sd-bus/bus-message.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- src/libsystemd/sd-bus/bus-message.c
+++ src/libsystemd/sd-bus/bus-message.c 2014-09-16 10:31:37.538735664 +0000
@@ -126,9 +126,6 @@ static void message_free(sd_bus_message
message_reset_parts(m);
- if (m->free_kdbus)
- free(m->kdbus);
-
if (m->release_kdbus) {
uint64_t off;
@@ -136,6 +133,9 @@ static void message_free(sd_bus_message
ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);
}
+ if (m->free_kdbus)
+ free(m->kdbus);
+
if (m->bus)
sd_bus_unref(m->bus);

View File

@ -0,0 +1,32 @@
From 2b347169b9046ff2d735ef23e62a8c74f5151600 Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert@gmail.com>
Date: Wed, 10 Sep 2014 12:20:42 +0300
Subject: [PATCH] bus: unref buscreds on failure
Actually unref the buscreds when we are not going to return a
pointer to them. As when bus_creds_add_more fails we immediately
return the error code otherwise and leak the new buscreds.
Found with coverity. Fixes: CID#1237761
---
src/libsystemd/sd-bus/sd-bus.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c
index 78e91b9..83b3aa1 100644
--- src/libsystemd/sd-bus/sd-bus.c
+++ src/libsystemd/sd-bus/sd-bus.c
@@ -3339,8 +3339,10 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re
}
r = bus_creds_add_more(c, mask, pid, 0);
- if (r < 0)
+ if (r < 0) {
+ sd_bus_creds_unref(c);
return r;
+ }
*ret = c;
return 0;
--
1.7.9.2

View File

@ -0,0 +1,25 @@
Based on 4d5e13a125cf8d77d432225ab69826caa1d1cf59 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Sat, 13 Sep 2014 12:35:06 +0200
Subject: [PATCH] core: fix a potential mem leak
Found with Coverity. Fixes: CID#996438
---
src/core/load-fragment.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- src/core/load-fragment.c
+++ src/core/load-fragment.c 2014-09-16 10:35:13.354235607 +0000
@@ -1294,8 +1294,11 @@ int config_parse_timer(const char *unit,
}
v = new0(TimerValue, 1);
- if (!v)
+ if (!v) {
+ if (c)
+ free(c);
return log_oom();
+ }
v->base = b;
v->clock_id = id;

View File

@ -0,0 +1,31 @@
From b9289d4c6e13ec5fb67bfce69c826d93b004da6a Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert@gmail.com>
Date: Fri, 12 Sep 2014 16:49:48 +0300
Subject: [PATCH] core: smack-setup: Actually allow for succesfully loading
CIPSO policy
The line under the last switch statement *loaded_policy = true;
would never be executed. As all switch cases return 0. Thus the
policy would never be marked as loaded.
Found with Coverity. Fixes: CID#1237785
---
src/core/smack-setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git src/core/smack-setup.c src/core/smack-setup.c
index 5f6dabf..5d8a26c 100644
--- src/core/smack-setup.c
+++ src/core/smack-setup.c
@@ -158,7 +158,7 @@ int smack_setup(bool *loaded_policy) {
return 0;
case 0:
log_info("Successfully loaded Smack/CIPSO policies.");
- return 0;
+ break;
default:
log_warning("Failed to load Smack/CIPSO access rules: %s, ignoring.",
strerror(abs(r)));
--
1.7.9.2

View File

@ -0,0 +1,50 @@
From b67ddc7bbe31cde7f69f9814204d9bb1d4623c47 Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippedeswert@gmail.com>
Date: Wed, 10 Sep 2014 12:20:41 +0300
Subject: [PATCH] journal: do not leak mmaps on OOM
After a section of memory is succesfully allocated, some of the following
actions can still fail due to lack of memory. In this case -ENOMEM is
returned without actually freeing the already mapped memory.
Found with coverity. Fixes: CID#1237762
---
src/journal/mmap-cache.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git src/journal/mmap-cache.c src/journal/mmap-cache.c
index 7dbbb5e..908562d 100644
--- src/journal/mmap-cache.c
+++ src/journal/mmap-cache.c
@@ -496,15 +496,15 @@ static int add_mmap(
c = context_add(m, context);
if (!c)
- return -ENOMEM;
+ goto outofmem;
f = fd_add(m, fd);
if (!f)
- return -ENOMEM;
+ goto outofmem;
w = window_add(m);
if (!w)
- return -ENOMEM;
+ goto outofmem;
w->keep_always = keep_always;
w->ptr = d;
@@ -522,6 +522,10 @@ static int add_mmap(
if (ret)
*ret = (uint8_t*) w->ptr + (offset - w->offset);
return 1;
+
+outofmem:
+ munmap(d, wsize);
+ return -ENOMEM;
}
int mmap_cache_get(
--
1.7.9.2

View File

@ -0,0 +1,30 @@
From 807d0cca2b0daf4cd725298c1b5e062b1126f15b Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Thu, 11 Sep 2014 21:14:53 +0200
Subject: [PATCH] manager: use correct cleanup function
Close the dir instead of attempt to free it.
Introduced in 874310b7b68c4c0d36ff07397db30a959bb7dae5
Found with coverity. Fixes: CID#996368
---
src/core/manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git src/core/manager.c src/core/manager.c
index 9abdf47..095111e 100644
--- src/core/manager.c
+++ src/core/manager.c
@@ -896,7 +896,7 @@ static int manager_coldplug(Manager *m) {
static void manager_build_unit_path_cache(Manager *m) {
char **i;
- _cleanup_free_ DIR *d = NULL;
+ _cleanup_closedir_ DIR *d = NULL;
int r;
assert(m);
--
1.7.9.2

View File

@ -0,0 +1,349 @@
From be2ea723b1d023b3d385d3b791ee4607cbfb20ca Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Sat, 30 Aug 2014 11:34:20 +0200
Subject: [PATCH] udev: remove userspace firmware loading support
---
Makefile.am | 12 ---
README | 9 +--
TODO | 1 -
configure.ac | 20 -----
src/udev/udev-builtin-firmware.c | 154 ---------------------------------------
src/udev/udev-builtin.c | 3 -
src/udev/udev.h | 6 --
src/udev/udevd.c | 13 ----
Index: systemd-210/configure.ac
===================================================================
--- systemd-210.orig/configure.ac
+++ systemd-210/configure.ac
@@ -902,25 +902,6 @@ if test "x$have_myhostname" != "xno"; th
fi
# ------------------------------------------------------------------------------
-AC_ARG_WITH(firmware-path,
- AS_HELP_STRING([--with-firmware-path=DIR[[[:DIR[...]]]]],
- [Firmware search path (default="")]),
- [], [with_firmware_path=""])
-OLD_IFS=$IFS
-IFS=:
-for i in $with_firmware_path; do
- if test "x${FIRMWARE_PATH}" = "x"; then
- FIRMWARE_PATH="\\\"${i}/\\\""
- else
- FIRMWARE_PATH="${FIRMWARE_PATH}, \\\"${i}/\\\""
- fi
-done
-IFS=$OLD_IFS
-AC_SUBST(FIRMWARE_PATH)
-AS_IF([test "x${FIRMWARE_PATH}" != "x"], [ AC_DEFINE(HAVE_FIRMWARE, 1, [Define if FIRMWARE is available]) ])
-AM_CONDITIONAL(ENABLE_FIRMWARE, [test "x${FIRMWARE_PATH}" != "x"])
-
-# ------------------------------------------------------------------------------
AC_ARG_ENABLE([gudev],
AS_HELP_STRING([--disable-gudev], [disable Gobject libudev support @<:@default=enabled@:>@]),
[], [enable_gudev=yes])
@@ -1137,7 +1118,6 @@ AC_MSG_RESULT([
Build Python: ${PYTHON}
Installation Python: ${PYTHON_BINARY}
sphinx binary: ${SPHINX_BUILD}
- firmware path: ${FIRMWARE_PATH}
PAM modules dir: ${with_pamlibdir}
PAM configuration dir: ${with_pamconfdir}
D-Bus policy dir: ${with_dbuspolicydir}
Index: systemd-210/Makefile.am
===================================================================
--- systemd-210.orig/Makefile.am
+++ systemd-210/Makefile.am
@@ -2677,18 +2677,6 @@ libudev_core_la_LIBADD = \
$(BLKID_LIBS) \
$(KMOD_LIBS)
-libudev_core_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DFIRMWARE_PATH="$(FIRMWARE_PATH)"
-
-if ENABLE_FIRMWARE
-libudev_core_la_SOURCES += \
- src/udev/udev-builtin-firmware.c
-
-dist_udevrules_DATA += \
- rules/50-firmware.rules
-endif
-
if HAVE_KMOD
libudev_core_la_SOURCES += \
src/udev/udev-builtin-kmod.c
Index: systemd-210/README
===================================================================
--- systemd-210.orig/README
+++ systemd-210/README
@@ -51,14 +51,14 @@ REQUIREMENTS:
Linux kernel >= 3.8 for Smack support
- Udev will fail to work with the legacy layout:
+ Udev will fail to work with the legacy sysfs layout:
CONFIG_SYSFS_DEPRECATED=n
Legacy hotplug slows down the system and confuses udev:
CONFIG_UEVENT_HELPER_PATH=""
- Userspace firmware loading is deprecated, will go away, and
- sometimes causes problems:
+ Userspace firmware loading is not supported and should
+ be disabled in the kernel
CONFIG_FW_LOADER_USER_HELPER=n
Some udev rules and virtualization detection relies on it:
Index: systemd-210/src/udev/udev-builtin.c
===================================================================
--- systemd-210.orig/src/udev/udev-builtin.c
+++ systemd-210/src/udev/udev-builtin.c
@@ -34,9 +34,6 @@ static const struct udev_builtin *builti
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
#endif
[UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
-#ifdef HAVE_FIRMWARE
- [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
-#endif
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
[UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard,
Index: systemd-210/src/udev/udev-builtin-firmware.c
===================================================================
--- systemd-210.orig/src/udev/udev-builtin-firmware.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * firmware - Kernel firmware loader
- *
- * Copyright (C) 2009 Piter Punk <piterpunk@slackware.com>
- * Copyright (C) 2009-2011 Kay Sievers <kay@vrfy.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details:*
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <getopt.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <sys/utsname.h>
-#include <sys/stat.h>
-
-#include "udev.h"
-
-static bool set_loading(struct udev *udev, char *loadpath, const char *state)
-{
- FILE *ldfile;
-
- ldfile = fopen(loadpath, "we");
- if (ldfile == NULL) {
- log_error("error: can not open '%s'", loadpath);
- return false;
- };
- fprintf(ldfile, "%s\n", state);
- fclose(ldfile);
- return true;
-}
-
-static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size)
-{
- char *buf;
- FILE *fsource = NULL, *ftarget = NULL;
- bool ret = false;
-
- buf = malloc(size);
- if (buf == NULL) {
- log_error("No memory available to load firmware file");
- return false;
- }
-
- log_debug("writing '%s' (%zi) to '%s'", source, size, target);
-
- fsource = fopen(source, "re");
- if (fsource == NULL)
- goto exit;
- ftarget = fopen(target, "we");
- if (ftarget == NULL)
- goto exit;
- if (fread(buf, size, 1, fsource) != 1)
- goto exit;
- if (fwrite(buf, size, 1, ftarget) == 1)
- ret = true;
-exit:
- if (ftarget != NULL)
- fclose(ftarget);
- if (fsource != NULL)
- fclose(fsource);
- free(buf);
- return ret;
-}
-
-static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test)
-{
- struct udev *udev = udev_device_get_udev(dev);
- static const char *searchpath[] = { FIRMWARE_PATH };
- char loadpath[UTIL_PATH_SIZE];
- char datapath[UTIL_PATH_SIZE];
- char fwpath[UTIL_PATH_SIZE];
- const char *firmware;
- FILE *fwfile = NULL;
- struct utsname kernel;
- struct stat statbuf;
- unsigned int i;
- int rc = EXIT_SUCCESS;
-
- firmware = udev_device_get_property_value(dev, "FIRMWARE");
- if (firmware == NULL) {
- log_error("firmware parameter missing");
- rc = EXIT_FAILURE;
- goto exit;
- }
-
- /* lookup firmware file */
- uname(&kernel);
- for (i = 0; i < ELEMENTSOF(searchpath); i++) {
- strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL);
- fwfile = fopen(fwpath, "re");
- if (fwfile != NULL)
- break;
-
- strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL);
- fwfile = fopen(fwpath, "re");
- if (fwfile != NULL)
- break;
- }
-
- strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), "/loading", NULL);
-
- if (fwfile == NULL) {
- log_debug("did not find firmware file '%s'", firmware);
- rc = EXIT_FAILURE;
- /*
- * Do not cancel the request in the initrd, the real root might have
- * the firmware file and the 'coldplug' run in the real root will find
- * this pending request and fulfill or cancel it.
- * */
- if (!in_initrd())
- set_loading(udev, loadpath, "-1");
- goto exit;
- }
-
- if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) {
- if (!in_initrd())
- set_loading(udev, loadpath, "-1");
- rc = EXIT_FAILURE;
- goto exit;
- }
-
- if (!set_loading(udev, loadpath, "1"))
- goto exit;
-
- strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL);
- if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) {
- log_error("error sending firmware '%s' to device", firmware);
- set_loading(udev, loadpath, "-1");
- rc = EXIT_FAILURE;
- goto exit;
- };
-
- set_loading(udev, loadpath, "0");
-exit:
- if (fwfile)
- fclose(fwfile);
- return rc;
-}
-
-const struct udev_builtin udev_builtin_firmware = {
- .name = "firmware",
- .cmd = builtin_firmware,
- .help = "kernel firmware loader",
- .run_once = true,
-};
Index: systemd-210/src/udev/udevd.c
===================================================================
--- systemd-210.orig/src/udev/udevd.c
+++ systemd-210/src/udev/udevd.c
@@ -100,9 +100,6 @@ struct event {
dev_t devnum;
int ifindex;
bool is_block;
-#ifdef HAVE_FIRMWARE
- bool nodelay;
-#endif
};
static inline struct event *node_to_event(struct udev_list_node *node)
@@ -474,10 +471,6 @@ static int event_queue_insert(struct ude
event->devnum = udev_device_get_devnum(dev);
event->is_block = streq("block", udev_device_get_subsystem(dev));
event->ifindex = udev_device_get_ifindex(dev);
-#ifdef HAVE_FIRMWARE
- if (streq(udev_device_get_subsystem(dev), "firmware"))
- event->nodelay = true;
-#endif
udev_queue_export_device_queued(udev_queue_export, dev);
log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev),
@@ -557,12 +550,6 @@ static bool is_devpath_busy(struct event
return true;
}
-#ifdef HAVE_FIRMWARE
- /* allow to bypass the dependency tracking */
- if (event->nodelay)
- continue;
-#endif
-
/* parent device event found */
if (event->devpath[common] == '/') {
event->delaying_seqnum = loop_event->seqnum;
Index: systemd-210/src/udev/udev.h
===================================================================
--- systemd-210.orig/src/udev/udev.h
+++ systemd-210/src/udev/udev.h
@@ -141,9 +141,6 @@ enum udev_builtin_cmd {
UDEV_BUILTIN_BLKID,
#endif
UDEV_BUILTIN_BTRFS,
-#ifdef HAVE_FIRMWARE
- UDEV_BUILTIN_FIRMWARE,
-#endif
UDEV_BUILTIN_HWDB,
UDEV_BUILTIN_INPUT_ID,
UDEV_BUILTIN_KEYBOARD,
@@ -172,9 +169,6 @@ struct udev_builtin {
extern const struct udev_builtin udev_builtin_blkid;
#endif
extern const struct udev_builtin udev_builtin_btrfs;
-#ifdef HAVE_FIRMWARE
-extern const struct udev_builtin udev_builtin_firmware;
-#endif
extern const struct udev_builtin udev_builtin_hwdb;
extern const struct udev_builtin udev_builtin_input_id;
extern const struct udev_builtin udev_builtin_keyboard;
Index: systemd-210/TODO
===================================================================
--- systemd-210.orig/TODO
+++ systemd-210/TODO
@@ -541,7 +541,6 @@ Features:
* ExecOnFailure=/usr/bin/foo
* udev:
- - remove src/udev/udev-builtin-firmware.c (CONFIG_FW_LOADER_USER_HELPER=n)
- move to LGPL
- kill scsi_id
- add trigger --subsystem-match=usb/usb_device device

View File

@ -0,0 +1,349 @@
From be2ea723b1d023b3d385d3b791ee4607cbfb20ca Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Sat, 30 Aug 2014 11:34:20 +0200
Subject: [PATCH] udev: remove userspace firmware loading support
---
Makefile.am | 12 ---
README | 9 +--
TODO | 1 -
configure.ac | 20 -----
src/udev/udev-builtin-firmware.c | 154 ---------------------------------------
src/udev/udev-builtin.c | 3 -
src/udev/udev.h | 6 --
src/udev/udevd.c | 13 ----
Index: systemd-210/configure.ac
===================================================================
--- systemd-210.orig/configure.ac
+++ systemd-210/configure.ac
@@ -902,25 +902,6 @@ if test "x$have_myhostname" != "xno"; th
fi
# ------------------------------------------------------------------------------
-AC_ARG_WITH(firmware-path,
- AS_HELP_STRING([--with-firmware-path=DIR[[[:DIR[...]]]]],
- [Firmware search path (default="")]),
- [], [with_firmware_path=""])
-OLD_IFS=$IFS
-IFS=:
-for i in $with_firmware_path; do
- if test "x${FIRMWARE_PATH}" = "x"; then
- FIRMWARE_PATH="\\\"${i}/\\\""
- else
- FIRMWARE_PATH="${FIRMWARE_PATH}, \\\"${i}/\\\""
- fi
-done
-IFS=$OLD_IFS
-AC_SUBST(FIRMWARE_PATH)
-AS_IF([test "x${FIRMWARE_PATH}" != "x"], [ AC_DEFINE(HAVE_FIRMWARE, 1, [Define if FIRMWARE is available]) ])
-AM_CONDITIONAL(ENABLE_FIRMWARE, [test "x${FIRMWARE_PATH}" != "x"])
-
-# ------------------------------------------------------------------------------
AC_ARG_ENABLE([gudev],
AS_HELP_STRING([--disable-gudev], [disable Gobject libudev support @<:@default=enabled@:>@]),
[], [enable_gudev=yes])
@@ -1137,7 +1118,6 @@ AC_MSG_RESULT([
Build Python: ${PYTHON}
Installation Python: ${PYTHON_BINARY}
sphinx binary: ${SPHINX_BUILD}
- firmware path: ${FIRMWARE_PATH}
PAM modules dir: ${with_pamlibdir}
PAM configuration dir: ${with_pamconfdir}
D-Bus policy dir: ${with_dbuspolicydir}
Index: systemd-210/Makefile.am
===================================================================
--- systemd-210.orig/Makefile.am
+++ systemd-210/Makefile.am
@@ -2677,18 +2677,6 @@ libudev_core_la_LIBADD = \
$(BLKID_LIBS) \
$(KMOD_LIBS)
-libudev_core_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DFIRMWARE_PATH="$(FIRMWARE_PATH)"
-
-if ENABLE_FIRMWARE
-libudev_core_la_SOURCES += \
- src/udev/udev-builtin-firmware.c
-
-dist_udevrules_DATA += \
- rules/50-firmware.rules
-endif
-
if HAVE_KMOD
libudev_core_la_SOURCES += \
src/udev/udev-builtin-kmod.c
Index: systemd-210/README
===================================================================
--- systemd-210.orig/README
+++ systemd-210/README
@@ -51,14 +51,14 @@ REQUIREMENTS:
Linux kernel >= 3.8 for Smack support
- Udev will fail to work with the legacy layout:
+ Udev will fail to work with the legacy sysfs layout:
CONFIG_SYSFS_DEPRECATED=n
Legacy hotplug slows down the system and confuses udev:
CONFIG_UEVENT_HELPER_PATH=""
- Userspace firmware loading is deprecated, will go away, and
- sometimes causes problems:
+ Userspace firmware loading is not supported and should
+ be disabled in the kernel
CONFIG_FW_LOADER_USER_HELPER=n
Some udev rules and virtualization detection relies on it:
Index: systemd-210/src/udev/udev-builtin.c
===================================================================
--- systemd-210.orig/src/udev/udev-builtin.c
+++ systemd-210/src/udev/udev-builtin.c
@@ -34,9 +34,6 @@ static const struct udev_builtin *builti
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
#endif
[UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
-#ifdef HAVE_FIRMWARE
- [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
-#endif
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
[UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard,
Index: systemd-210/src/udev/udev-builtin-firmware.c
===================================================================
--- systemd-210.orig/src/udev/udev-builtin-firmware.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * firmware - Kernel firmware loader
- *
- * Copyright (C) 2009 Piter Punk <piterpunk@slackware.com>
- * Copyright (C) 2009-2011 Kay Sievers <kay@vrfy.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details:*
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <getopt.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <sys/utsname.h>
-#include <sys/stat.h>
-
-#include "udev.h"
-
-static bool set_loading(struct udev *udev, char *loadpath, const char *state)
-{
- FILE *ldfile;
-
- ldfile = fopen(loadpath, "we");
- if (ldfile == NULL) {
- log_error("error: can not open '%s'", loadpath);
- return false;
- };
- fprintf(ldfile, "%s\n", state);
- fclose(ldfile);
- return true;
-}
-
-static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size)
-{
- char *buf;
- FILE *fsource = NULL, *ftarget = NULL;
- bool ret = false;
-
- buf = malloc(size);
- if (buf == NULL) {
- log_error("No memory available to load firmware file");
- return false;
- }
-
- log_debug("writing '%s' (%zi) to '%s'", source, size, target);
-
- fsource = fopen(source, "re");
- if (fsource == NULL)
- goto exit;
- ftarget = fopen(target, "we");
- if (ftarget == NULL)
- goto exit;
- if (fread(buf, size, 1, fsource) != 1)
- goto exit;
- if (fwrite(buf, size, 1, ftarget) == 1)
- ret = true;
-exit:
- if (ftarget != NULL)
- fclose(ftarget);
- if (fsource != NULL)
- fclose(fsource);
- free(buf);
- return ret;
-}
-
-static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test)
-{
- struct udev *udev = udev_device_get_udev(dev);
- static const char *searchpath[] = { FIRMWARE_PATH };
- char loadpath[UTIL_PATH_SIZE];
- char datapath[UTIL_PATH_SIZE];
- char fwpath[UTIL_PATH_SIZE];
- const char *firmware;
- FILE *fwfile = NULL;
- struct utsname kernel;
- struct stat statbuf;
- unsigned int i;
- int rc = EXIT_SUCCESS;
-
- firmware = udev_device_get_property_value(dev, "FIRMWARE");
- if (firmware == NULL) {
- log_error("firmware parameter missing");
- rc = EXIT_FAILURE;
- goto exit;
- }
-
- /* lookup firmware file */
- uname(&kernel);
- for (i = 0; i < ELEMENTSOF(searchpath); i++) {
- strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL);
- fwfile = fopen(fwpath, "re");
- if (fwfile != NULL)
- break;
-
- strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL);
- fwfile = fopen(fwpath, "re");
- if (fwfile != NULL)
- break;
- }
-
- strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), "/loading", NULL);
-
- if (fwfile == NULL) {
- log_debug("did not find firmware file '%s'", firmware);
- rc = EXIT_FAILURE;
- /*
- * Do not cancel the request in the initrd, the real root might have
- * the firmware file and the 'coldplug' run in the real root will find
- * this pending request and fulfill or cancel it.
- * */
- if (!in_initrd())
- set_loading(udev, loadpath, "-1");
- goto exit;
- }
-
- if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) {
- if (!in_initrd())
- set_loading(udev, loadpath, "-1");
- rc = EXIT_FAILURE;
- goto exit;
- }
-
- if (!set_loading(udev, loadpath, "1"))
- goto exit;
-
- strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL);
- if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) {
- log_error("error sending firmware '%s' to device", firmware);
- set_loading(udev, loadpath, "-1");
- rc = EXIT_FAILURE;
- goto exit;
- };
-
- set_loading(udev, loadpath, "0");
-exit:
- if (fwfile)
- fclose(fwfile);
- return rc;
-}
-
-const struct udev_builtin udev_builtin_firmware = {
- .name = "firmware",
- .cmd = builtin_firmware,
- .help = "kernel firmware loader",
- .run_once = true,
-};
Index: systemd-210/src/udev/udevd.c
===================================================================
--- systemd-210.orig/src/udev/udevd.c
+++ systemd-210/src/udev/udevd.c
@@ -100,9 +100,6 @@ struct event {
dev_t devnum;
int ifindex;
bool is_block;
-#ifdef HAVE_FIRMWARE
- bool nodelay;
-#endif
};
static inline struct event *node_to_event(struct udev_list_node *node)
@@ -474,10 +471,6 @@ static int event_queue_insert(struct ude
event->devnum = udev_device_get_devnum(dev);
event->is_block = streq("block", udev_device_get_subsystem(dev));
event->ifindex = udev_device_get_ifindex(dev);
-#ifdef HAVE_FIRMWARE
- if (streq(udev_device_get_subsystem(dev), "firmware"))
- event->nodelay = true;
-#endif
log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev),
udev_device_get_action(dev), udev_device_get_subsystem(dev));
@@ -557,12 +550,6 @@ static bool is_devpath_busy(struct event
return true;
}
-#ifdef HAVE_FIRMWARE
- /* allow to bypass the dependency tracking */
- if (event->nodelay)
- continue;
-#endif
-
/* parent device event found */
if (event->devpath[common] == '/') {
event->delaying_seqnum = loop_event->seqnum;
Index: systemd-210/src/udev/udev.h
===================================================================
--- systemd-210.orig/src/udev/udev.h
+++ systemd-210/src/udev/udev.h
@@ -141,9 +141,6 @@ enum udev_builtin_cmd {
UDEV_BUILTIN_BLKID,
#endif
UDEV_BUILTIN_BTRFS,
-#ifdef HAVE_FIRMWARE
- UDEV_BUILTIN_FIRMWARE,
-#endif
UDEV_BUILTIN_HWDB,
UDEV_BUILTIN_INPUT_ID,
UDEV_BUILTIN_KEYBOARD,
@@ -172,9 +169,6 @@ struct udev_builtin {
extern const struct udev_builtin udev_builtin_blkid;
#endif
extern const struct udev_builtin udev_builtin_btrfs;
-#ifdef HAVE_FIRMWARE
-extern const struct udev_builtin udev_builtin_firmware;
-#endif
extern const struct udev_builtin udev_builtin_hwdb;
extern const struct udev_builtin udev_builtin_input_id;
extern const struct udev_builtin udev_builtin_keyboard;
Index: systemd-210/TODO
===================================================================
--- systemd-210.orig/TODO
+++ systemd-210/TODO
@@ -541,7 +541,6 @@ Features:
* ExecOnFailure=/usr/bin/foo
* udev:
- - remove src/udev/udev-builtin-firmware.c (CONFIG_FW_LOADER_USER_HELPER=n)
- move to LGPL
- kill scsi_id
- add trigger --subsystem-match=usb/usb_device device

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Tue Sep 16 10:45:33 UTC 2014 - werner@suse.de
- Add upstream patches as real fixes
0001-activate-fix-fd-leak-in-do_accept.patch
0002-analyze-avoid-a-null-dereference.patch
0003-analyze-fix-mem-leak.patch
0004-backlight-Avoid-error-when-state-restore-is-disabled.patch
0005-bus-avoid-using-m-kdbus-after-freeing-it.patch
0006-bus-unref-buscreds-on-failure.patch
0007-core-fix-a-potential-mem-leak.patch
0008-core-smack-setup-Actually-allow-for-succesfully-load.patch
0009-journal-do-not-leak-mmaps-on-OOM.patch
0010-manager-use-correct-cleanup-function.patch
- Intergrate the work of Robert and rename the patch
1068-udev-remove-userspace-firmware-loading-support.patch
to 1078-udev-remove-userspace-firmware-loading-support.patch
Also add patch
1079-udev-remove-userspace-firmware-loading-support.patch
to apply the same change for opensuse 13.2 and above
-------------------------------------------------------------------
Tue Sep 16 10:21:02 UTC 2014 - werner@suse.de
@ -20,6 +41,12 @@ Tue Sep 16 09:10:52 UTC 2014 - werner@suse.de
1076-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch (bnc#889297)
1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch (bnc#889297)
-------------------------------------------------------------------
Tue Sep 16 07:55:37 UTC 2014 - rmilasan@suse.com
- udev: remove userspace firmware loading support (bnc#889297).
Add 1068-udev-remove-userspace-firmware-loading-support.patch
-------------------------------------------------------------------
Sat Sep 13 13:35:33 UTC 2014 - rmilasan@suse.com

View File

@ -836,6 +836,26 @@ Patch402: 0008-hwdb-Update-database-of-Bluetooth-company-identifier.patch
Patch403: 0009-hwdb-update.patch
# PATCH-FIX-UPSTREAM bnc896664: Allow to override default target without --force
Patch404: 0001-systemctl-allow-to-change-the-default-target-without.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch405: 0001-activate-fix-fd-leak-in-do_accept.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch406: 0002-analyze-avoid-a-null-dereference.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch407: 0003-analyze-fix-mem-leak.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch408: 0004-backlight-Avoid-error-when-state-restore-is-disabled.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch409: 0005-bus-avoid-using-m-kdbus-after-freeing-it.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch410: 0006-bus-unref-buscreds-on-failure.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch411: 0007-core-fix-a-potential-mem-leak.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch412: 0008-core-smack-setup-Actually-allow-for-succesfully-load.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch413: 0009-journal-do-not-leak-mmaps-on-OOM.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch414: 0010-manager-use-correct-cleanup-function.patch
# UDEV PATCHES
# ============
@ -997,6 +1017,10 @@ Patch1075: 1075-udev-timeout-increase-timeout.patch
Patch1076: 1076-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
# PATCH-FIX-UPSTREAM 1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
Patch1077: 1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
# PATCH-FIX-UPSTREAM 1078-udev-remove-userspace-firmware-loading-support.patch
Patch1078: 1078-udev-remove-userspace-firmware-loading-support.patch
# PATCH-FIX-UPSTREAM 1079-udev-remove-userspace-firmware-loading-support.patch
Patch1079: 1079-udev-remove-userspace-firmware-loading-support.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -1562,6 +1586,16 @@ cp %{SOURCE7} m4/
%patch402 -p0
%patch403 -p0
%patch404 -p0
%patch405 -p0
%patch406 -p0
%patch407 -p0
%patch408 -p0
%patch409 -p0
%patch410 -p0
%patch411 -p0
%patch412 -p0
%patch413 -p0
%patch414 -p0
# udev patches
%patch1001 -p1
@ -1665,6 +1699,13 @@ cp %{SOURCE7} m4/
%else
%patch1077 -p0
%endif
%if 0%{?suse_version} > 1310
%if %{with udevsettle}
%patch1079 -p1
%else
%patch1078 -p1
%endif
%endif
# remove patch backups
find -name '*.orig' -exec rm -f '{}' \+

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Tue Sep 16 10:45:33 UTC 2014 - werner@suse.de
- Add upstream patches as real fixes
0001-activate-fix-fd-leak-in-do_accept.patch
0002-analyze-avoid-a-null-dereference.patch
0003-analyze-fix-mem-leak.patch
0004-backlight-Avoid-error-when-state-restore-is-disabled.patch
0005-bus-avoid-using-m-kdbus-after-freeing-it.patch
0006-bus-unref-buscreds-on-failure.patch
0007-core-fix-a-potential-mem-leak.patch
0008-core-smack-setup-Actually-allow-for-succesfully-load.patch
0009-journal-do-not-leak-mmaps-on-OOM.patch
0010-manager-use-correct-cleanup-function.patch
- Intergrate the work of Robert and rename the patch
1068-udev-remove-userspace-firmware-loading-support.patch
to 1078-udev-remove-userspace-firmware-loading-support.patch
Also add patch
1079-udev-remove-userspace-firmware-loading-support.patch
to apply the same change for opensuse 13.2 and above
-------------------------------------------------------------------
Tue Sep 16 10:21:02 UTC 2014 - werner@suse.de
@ -20,6 +41,12 @@ Tue Sep 16 09:10:52 UTC 2014 - werner@suse.de
1076-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch (bnc#889297)
1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch (bnc#889297)
-------------------------------------------------------------------
Tue Sep 16 07:55:37 UTC 2014 - rmilasan@suse.com
- udev: remove userspace firmware loading support (bnc#889297).
Add 1068-udev-remove-userspace-firmware-loading-support.patch
-------------------------------------------------------------------
Sat Sep 13 13:35:33 UTC 2014 - rmilasan@suse.com

View File

@ -831,6 +831,26 @@ Patch402: 0008-hwdb-Update-database-of-Bluetooth-company-identifier.patch
Patch403: 0009-hwdb-update.patch
# PATCH-FIX-UPSTREAM bnc896664: Allow to override default target without --force
Patch404: 0001-systemctl-allow-to-change-the-default-target-without.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch405: 0001-activate-fix-fd-leak-in-do_accept.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch406: 0002-analyze-avoid-a-null-dereference.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch407: 0003-analyze-fix-mem-leak.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch408: 0004-backlight-Avoid-error-when-state-restore-is-disabled.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch409: 0005-bus-avoid-using-m-kdbus-after-freeing-it.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch410: 0006-bus-unref-buscreds-on-failure.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch411: 0007-core-fix-a-potential-mem-leak.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch412: 0008-core-smack-setup-Actually-allow-for-succesfully-load.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch413: 0009-journal-do-not-leak-mmaps-on-OOM.patch
# PATCH-FIX-UPSTREAM added at 2014/09/16
Patch414: 0010-manager-use-correct-cleanup-function.patch
# UDEV PATCHES
# ============
@ -992,6 +1012,10 @@ Patch1075: 1075-udev-timeout-increase-timeout.patch
Patch1076: 1076-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
# PATCH-FIX-UPSTREAM 1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
Patch1077: 1077-udev-timeout-warn-after-a-third-of-the-timeout-befor.patch
# PATCH-FIX-UPSTREAM 1078-udev-remove-userspace-firmware-loading-support.patch
Patch1078: 1078-udev-remove-userspace-firmware-loading-support.patch
# PATCH-FIX-UPSTREAM 1079-udev-remove-userspace-firmware-loading-support.patch
Patch1079: 1079-udev-remove-userspace-firmware-loading-support.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -1557,6 +1581,16 @@ cp %{SOURCE7} m4/
%patch402 -p0
%patch403 -p0
%patch404 -p0
%patch405 -p0
%patch406 -p0
%patch407 -p0
%patch408 -p0
%patch409 -p0
%patch410 -p0
%patch411 -p0
%patch412 -p0
%patch413 -p0
%patch414 -p0
# udev patches
%patch1001 -p1
@ -1660,6 +1694,13 @@ cp %{SOURCE7} m4/
%else
%patch1077 -p0
%endif
%if 0%{?suse_version} > 1310
%if %{with udevsettle}
%patch1079 -p1
%else
%patch1078 -p1
%endif
%endif
# remove patch backups
find -name '*.orig' -exec rm -f '{}' \+