summaryrefslogtreecommitdiff
path: root/libkmod/libkmod-config.c
AgeCommit message (Collapse)AuthorFilesLines
2021-04-12libkmod-config: fix a memory leak when kmod_list_append() failssubmit/tizen/20210412.054957accepted/tizen/unified/20210413.021236Seung-Woo Kim1-1/+3
From kmod_config_new(), when kmod_list_append() fails, fix not list-appended kmod_config_path leak. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> [sw0312.kim: cherry-pick mainline commit 39dd17162374] Change-Id: Ic1d1e77ecc9b81fdd4f0eb771cce1d7b42d0024e
2020-03-13libkmod: ignore kcmdline option if we fail to parse modnameLucas De Marchi1-1/+2
The error message is saying we are ignoring the option on the kernel command line, so just do it.
2020-01-20libkmod: reset was_space on second passLucas De Marchi1-0/+1
The softdep config parser uses a 2-pass approach to use a single allocation for all the softdep struct. However "was_space" variable isn't reset between them. This can lead to a buffer overflow. Reported-by: Jorge Lucangeli Obes <jorgelo@google.com> Link: https://lore.kernel.org/linux-modules/CAKYuF5QhGCPCazHQjN-=kFc5kHs7Ok8WqmmGLo31CiOEN8TYdA@mail.gmail.com
2017-02-16libkmod-config: fix parsing quoted kernel cmdline on paramsLucas De Marchi1-0/+14
We can only accept quoted values, not module names or parameter names.
2017-02-16libkmod-config: replace 0/1 with boolLucas De Marchi1-4/+4
2017-01-23libkmod: Fix handling of quotes in kernel command lineJames Minor1-0/+7
If a module parameter on the command line contains quotes, any spaces inside those quotes should be included as part of the parameter. Signed-off-by: James Minor <james.minor@ni.com>
2016-08-08libkmod: fix use of strcpyLucas De Marchi1-6/+11
We were not checking if there was sufficient space in the buffer.
2014-12-25Remove FSF mailing addressLucas De Marchi1-2/+1
It has changed in the past, and these days, anyone can get a copy of the LGPL via the web rather than by post. Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet, but let the FSF website in which the license can be found.
2014-10-09Log error on failed underscores(), moving it to shared/Lucas De Marchi1-56/+17
Move underscores() to shared/. It's the same as alias_normalize(), but it rather operates in place, with the same string being passed. The difference now that it's in shared/ is that it's a non-logging function. This makes us a little bit more verbose: we don't accept partially correct module and aliases names in kcmdline and in configuration files. We log an error instead.
2014-10-03Rename getline_wrapped() to freadline_wrapped()Lucas De Marchi1-1/+1
2014-10-03Reorder and reorganize header filesLucas De Marchi1-6/+6
Let the includes in the following order: < system headers > < libkmod > < tool > < local headers >
2014-10-03Move generic util functions to shared directoryLucas De Marchi1-0/+2
2014-04-01config: also parse softdeps from modulesTom Gundersen1-0/+2
This information can be found in /lib/modules/`uname -r`/modules.softdep, and has only recently been exported by the kernel. Also remove the advice about copying modules.softdep to /lib/modules as it is not clear how to do this correctly with several kernels installed with potentially conflicting soft dependencies.
2014-03-05libkmod-config: Only match dot before '=' in /proc/cmdlineMichal Marek1-3/+8
Otherwise, we also parse strings like BOOT_IMAGE=/boot/vmlinuz-3.12.12-57.g5f654cf-default In practice, this is not a problem, because there is no module named BOOT_IMAGE=/boot/vmlinuz-3. It just disturbs in modprobe -c output.
2014-03-05libkmod-config,depmod: Accept special files as configuration files, tooMichal Marek1-5/+1
If we can open it and read it, it's good enough for us. Otherwise, we cannot use -C /dev/null to skip the system configuration for instance: $ ./tools/modprobe -C /dev/null -c libkmod: ERROR libkmod/libkmod-config.c:821 conf_files_list: unsupported file mode /dev/null: 0x21b6 ...
2013-11-18config: Use _cleanup_free_Lucas De Marchi1-40/+22
2013-08-29Fix usage of readdir_r()Lucas De Marchi1-18/+4
With readdir_r() we should be providing enough space to store the dir name. This could be accomplished by define an union like systemd does: union dirent_storage { struct dirent de; uint8_t storage[offsetof(struct dirent, d_name) + ((NAME_MAX + 1 + sizeof(long)) & ~(sizeof(long) - 1))]; }; However in all places that we use readdir_r() we have no concerns about reentrance nor we have problems with threads. Thus use the simpler readdir() instead. We also remove the error logging here (that could be added back by checking errno), but it was not adding much value so it's gone.
2013-08-13libkmod: Fix getting param with no value from kcmdlineLucas De Marchi1-1/+1
2013-08-09depmod: add missing "else" clauseJan Engelhardt1-1/+1
It occurred to an openSUSE user that our mkinitrd would throw a warning when used with kmod: libkmod: conf_files_list: unsupported file mode /dev/null: 0x21b6 Grepping for the error message revealed that there might be a missing "else" keyword here, since it is unusual to put an "if" directly after closing brace.
2013-07-04Use "-internal" suffix instead of "-private"Lucas De Marchi1-1/+1
2013-01-16Update copyright noticesLucas De Marchi1-1/+1
2012-10-09libkmod: Add support for '.' in module parameter on kcmdlineLucas De Marchi1-2/+4
Otherwise we fail to parse arguments in kernel command line like testmodule.testparam=1.5G Suggested-by: Selim T. Erdogan <selim@alumni.cs.utexas.edu>
2012-06-12libkmod-config: refactor functions to get configLucas De Marchi1-6/+7
It makes more sense to have libkmod-config.c deal with the configuration directly and the others get the config from ctx. As a bonus point we get a smaller binary. Following numbers are for x86-64, libkmod + kmod: Before: text data bss dec hex filename 128840 1496 104 130440 1fd88 tools/modprobe After: text data bss dec hex filename 128392 1496 104 129992 1fbc8 tools/modprobe
2012-05-15libkmod: move function to the only file using itMike Frysinger1-0/+31
If we don't have --gc-sections support, linking kmod fails: libkmod/.libs/libkmod-util.a(libkmod-util.o): In function 'underscores': libkmod/libkmod-util.c:117: undefined reference to 'kmod_log' This is because libkmod-util.la uses kmod_log(), that is in libkmod.la. Move the function so we don't have a dependency loop while building the libraries and it works with compilers with no support for --gc-sections.
2012-04-19doc: remove links to NULL going nowhereLucas De Marchi1-6/+6
2012-02-18Add missing newlinesLucas De Marchi1-1/+1
Checked with following semantic patch for the library: // smpl @a@ identifier virtual.func; expression E1; expression fmt; position p1; @@ func(E1, fmt@p1, ...) @script:python b@ fmt << a.fmt; p1 << a.p1; @@ s = str(fmt) if s.find("\\n") < 0: print p1[0].file + ":" + p1[0].line // smpl For tools, just remove E1
2012-01-31improve logging to mention context.Gustavo Sverzut Barbieri1-1/+1
Just printing the errno string such as "%m\n" is not enough to help debug or users understand the problem. Change to provide more context on the failing operation.
2012-01-17Check if struct stat has mtim memberLucas De Marchi1-1/+1
Not all libc's have a mtim member in struct stat (dietlibc doesn't). Change ts_usec() to receive a struct stat as parameter and implement it accordingly for both cases.
2012-01-14Update documentation with recent changesLucas De Marchi1-0/+115
2012-01-13config: let softdeps dump their dataLucas De Marchi1-1/+91
2012-01-13config: add exported iterator functionsLucas De Marchi1-0/+152
Config iterators are useful to get each configuration list, remember its type and how to get their key/value pair. softdeps don't have the value yet, because they are stored as string vectors.
2012-01-11config: deprecate 'include' and 'config' commandsLucas De Marchi1-1/+1
2012-01-10config: be reliable againt syntax errors in configsLucas De Marchi1-8/+12
2012-01-09Update copyrightLucas De Marchi1-1/+1
2012-01-06config: check if opening /proc/cmdline succeededLucas De Marchi1-0/+6
2012-01-04config: take a weakref to ctxLucas De Marchi1-0/+1
Commit "b6a4dfb config: save list of config paths with their timestamps" removed the weakref to ctx. Add it back.
2012-01-01config: save list of config paths with their timestampsLucas De Marchi1-8/+43
Save a list of config paths with their timestamps so they can be checked later.
2011-12-31libkmod-config: remove warning for skipped config filesDave Reisner1-5/+1
conf_files_filter_out() already skips these files, but writes to the log to warn that they'll be ignored in the future.
2011-12-28Do not forget parenthesis around if (streq(A, B)).Leandro Pereira1-3/+3
2011-12-27Add functions to get ctx blacklistsLucas De Marchi1-0/+5
2011-12-22Initialize line number with 0Lucas De Marchi1-1/+1
2011-12-20Use sorted configuration files in precedence orderLucas De Marchi1-64/+100
We need to keep config files sorted and use them taking the precedence order into account. The following message was taken from module-init-tools commit doing a similar thing: Configuration files are parsed in alphabetic order, regardles of what directory they reside in. Furthermore, if several files by the same name exist in different directories only the one in the directory with highest precedence is loaded. The order of precedence is /run, /etc, /usr/lib, /lib. The sad thing is that we are not using openat() anymore since each file is in different directories. In future we might change the implementation to open all DIRs and keep a reference to them instead of the path. However we'd have to keep a separate list with all the opened dirs so we can close them later (when all configs are parsed).
2011-12-20kmod_config: fix kcmd line parser with dots after =Lucas De Marchi1-1/+2
Check if '=' appeared before the dot. In this case, it's not a valid module option in kernel command line. The command line that was failing is: "root=/dev/sda3 ro pcie_aspm=force init=/sbin/bootchartd initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux"
2011-12-19Fix debug message formattingLucas De Marchi1-1/+1
2011-12-17implement softdeps.Gustavo Sverzut Barbieri1-1/+180
2011-12-17Open more file descriptors with O_CLOEXECCristian Rodríguez1-2/+2
2011-12-16Library must use O_CLOEXEC whenever it opens file descriptorsCristian Rodríguez1-1/+1
2011-12-14Fix format of log messageLucas De Marchi1-1/+1
2011-12-14kmod_config: parse kernel command line for options and blacklistLucas De Marchi1-0/+63
2011-12-12Fix "Dead assignments" as reported by llvmLucas De Marchi1-3/+2