LWN.net Logo

Security

Loading modules from file descriptors

By Michael Kerrisk
October 10, 2012

Loadable kernel modules provide a mechanism to dynamically modify the functionality of a running system, by allowing code to be loaded and unloaded from the kernel. Loading code into the kernel via a module has a number of advantages over building a completely new monolithic kernel from modified source code. The first of these is that loading a kernel module does not require a system reboot. This means that new kernel functionally can be added without disturbing users and applications.

From a developer perspective, implementing new kernel functionality via modules is faster: a slow "compile kernel, reboot, test" sequence in each development iteration is instead replaced by a much faster "compile module, load module, test" sequence. Employing modules can also save memory, since code in a module can be loaded into memory only when it is actually needed. Device drivers are often implemented as loadable modules for this reason.

From a security perspective, loadable modules also have a potential downside: since a module has full access to kernel memory, it can compromise the integrity of a system. Although modules can be loaded only by privileged users, there are still potential security risks, since a system administrator may be unable to directly verify the authenticity and origin of a particular kernel module. Providing module-related infrastructure to support administrators in that task is the subject of ongoing effort, with one of the most notable pieces being the work to support module signing.

Kees Cook has recently posted a series of patches that tackle another facet of the module-verification problem. These patches add a new system call for loading kernel modules. To understand why the new system call is useful, we need to start by looking at the existing interface for loading kernel modules.

The Linux interface for loading kernel modules has had (since kernel 2.6.0) the following form:

    int init_module(void *module_image, unsigned long len,
                    const char *param_values);

The caller supplies the ELF image of the to-be-loaded module via the memory buffer pointed to by module_image; len specifies the size of that buffer. (The param_values argument is a string that can be used to specify initial values for the module's parameters.)

The main users of init_module() are the insmod and modprobe commands. However any privileged user-space application (i.e., one with the CAP_SYS_MODULE capability) can load a module in the same way that these commands do, via a three-step process: opening a file that contains a suitably built ELF image, reading or mmap()ing the file's contents into memory, and then calling init_module().

However, this call sequence is the source of an itch for Kees. Because the step of obtaining a file descriptor for the image file is separated from the module-loading step, the operating system loses the ability to make deductions about the trustworthiness of the module based on its origin in the filesystem. As Kees said:

being able to reason about the origin of a kernel module would be valuable in situations where an OS already trusts a specific file system, file, etc, due to things like security labels or an existing root of trust to a partition through things like dm-verity.

His solution is fairly straightforward: remove the middle of the three steps posted above. Instead, the application will open the file and pass the returned file descriptor directly to the kernel as part of a new module-loading system call; the kernel then performs the task of reading the module image from the file as a precursor to loading the module.

Although the concept of the solution is simple, it has been through a few iterations, with the most notable changes being to details of the user-space interface. Kees's initial proposal was to hack the existing init_module() interface, so that if NULL is passed in the module_image argument, the kernel would interpret the len argument as a file descriptor. Rusty Russell, the kernel modules subsystem maintainer, somewhat bluntly suggested that a new system call would be a better approach, and on the next revision of the patch, H. Peter Anvin pointed out that the system call would be better named according to existing conventions, where the file descriptor analog of an existing system call simply uses the same name as that system call, but with an "f" prefix. Thus, Kees has arrived at the currently proposed interface:

    int finit_module(int fd, const char *param_values);

In the most recent patch, Kees, who works for Google on Chrome OS, has also further elaborated on the motivations for adding this system call. Specifically, in order to ensure the integrity of a user's system, the Chrome OS developers would like to be able to enforce the restriction that kernel modules are loaded only from the system's read-only, cryptographically verified root filesystem. Since the developers already trust the contents of the root filesystem, employing module signatures to verify the contents of a kernel module would require the addition of an unnecessary set of keys to the kernel and would also slow down module loading. All that Chrome OS requires is a light-weight mechanism for verifying that the module image originates from that filesystem, and the new system call provides just that facility.

Kees pointed out that the new system call also has potential for wider use. For example, Linux Security Modules (LSMs) could use it to examine digital signatures contained in the module file's extended attributes (the file descriptor provides the kernel with the route to access the extended attributes). During discussion of the patches, interest in the new system call was confirmed by the maintainers of the IMA and AppArmor kernel subsystems.

At this stage, there appear to be few roadblocks to getting this system call into the kernel. The only question is when it will arrive. Kees would very much like to see the patches go into the currently open 3.7 merge window, but for various reasons, it appears probable that they will only be merged in Linux 3.8.

Update, January 2013: finit_module() was indeed merged in Linux 3.8, but with a changed API that added a flags argument that can be used to modify the behavior of the system call. Details can be found in the manual page.

Comments (4 posted)

Brief items

Security quotes of the week

The point is that we in the community need to start the migration away from SHA-1 and to SHA-2/SHA-3 now.
-- Bruce Schneier

That's because a design flaw in the service [McAfee Secure], and in competing services offered by Trust Guard and others, makes it easy to discover in almost real time when a customer has had the seal revoked. A revocation is a either a sign the site has failed to pay its bill, has been inaccessible for a sustained period of time, or most crucially, is no longer able to pass the daily security test.
-- Dan Goodin in ars technica

This apparent screw up in the automated filter mistakenly attempts to censor AMC Theatres, BBC, Buzzfeed, CNN, HuffPo, TechCrunch, RealClearPolitics, Rotten Tomatoes, ScienceDirect, Washington Post, Wikipedia and even the U.S. Government.

Judging from the page titles and content the websites in question were targeted because they reference the number "45".

-- TorrentFreak looks at a Microsoft DMCA notice

Comments (2 posted)

The Linux Foundation's UEFI secure boot system

The Linux Foundation has announced a new boot system meant to make life easier on UEFI secure boot systems. "In a nutshell, the Linux Foundation will obtain a Microsoft Key and sign a small pre-bootloader which will, in turn, chain load (without any form of signature check) a predesignated boot loader which will, in turn, boot Linux (or any other operating system). The pre-bootloader will employ a 'present user' test to ensure that it cannot be used as a vector for any type of UEFI malware to target secure systems. This pre-bootloader can be used either to boot a CD/DVD installer or LiveCD distribution or even boot an installed operating system in secure mode for any distribution that chooses to use it."

Comments (39 posted)

The CryptoParty Handbook

The first draft of the CryptoParty Handbook, a 390-page guide to maintaining privacy in the networked world, is available. "This book was written in the first 3 days of October 2012 at Studio Weise7, Berlin, surrounded by fine food and a lake of coffee amidst a veritable snake pit of cables. Approximately 20 people were involved in its creation, some more than others, some local and some far (Melbourne in particular)." It is available under the (still evolving) CC-BY-SA 4.0 license. The guide, too, is still evolving; it should probably be regarded the way one would look at early-stage cryptographic code. Naturally, the authors are looking for contributors to help make the next release better.

Comments (none posted)

New vulnerabilities

bacula: information disclosure

Package(s):bacula CVE #(s):CVE-2012-4430
Created:October 8, 2012 Updated:January 25, 2013
Description: From the Debian advisory:

It was discovered that bacula, a network backup service, does not properly enforce console ACLs. This could allow information about resources to be dumped by an otherwise-restricted client.

Alerts:
Debian DSA-2558-1 2012-10-08
Mandriva MDVSA-2012:166 2012-10-12
Mageia MGASA-2012-0321 2012-11-06
Fedora FEDORA-2012-14452 2013-01-24

Comments (none posted)

bind: denial of service

Package(s):bind CVE #(s):CVE-2012-5166
Created:October 10, 2012 Updated:November 6, 2012
Description: From the Mandriva advisory:

A certain combination of records in the RBT could cause named to hang while populating the additional section of a response.

Alerts:
Mandriva MDVSA-2012:162 2012-10-10
Ubuntu USN-1601-1 2012-10-10
Mageia MGASA-2012-0287 2012-10-11
Slackware SSA:2012-284-01 2012-10-10
Red Hat RHSA-2012:1364-01 2012-10-12
Red Hat RHSA-2012:1363-01 2012-10-12
Red Hat RHSA-2012:1365-01 2012-10-12
CentOS CESA-2012:1363 2012-10-12
CentOS CESA-2012:1363 2012-10-13
CentOS CESA-2012:1364 2012-10-12
Oracle ELSA-2012-1363 2012-10-12
Oracle ELSA-2012-1363 2012-10-13
Oracle ELSA-2012-1364 2012-10-13
Scientific Linux SL-bind-20121015 2012-10-15
Scientific Linux SL-bind-20121015 2012-10-15
openSUSE openSUSE-SU-2012:1372-1 2012-10-19
Fedora FEDORA-2012-15965 2012-10-19
Fedora FEDORA-2012-15965 2012-10-19
Fedora FEDORA-2012-15965 2012-10-19
Fedora FEDORA-2012-15965 2012-10-19
Debian DSA-2560-1 2012-10-20
Fedora FEDORA-2012-15981 2012-10-23
Fedora FEDORA-2012-15981 2012-10-23
Fedora FEDORA-2012-15981 2012-10-23
Fedora FEDORA-2012-15981 2012-10-23
SUSE SUSE-SU-2012:1390-1 2012-10-23
SUSE SUSE-SU-2012:1390-2 2012-10-24
SUSE SUSE-SU-2012:1390-3 2012-11-05
Oracle ELSA-2012-1365 2012-11-29
Slackware SSA:2012-341-01 2012-12-06
openSUSE openSUSE-SU-2013:0605-1 2013-04-03

Comments (none posted)

hostapd: denial of service

Package(s):hostapd CVE #(s):CVE-2012-4445
Created:October 8, 2012 Updated:October 19, 2012
Description: From the Debian advisory:

Timo Warns discovered that the internal authentication server of hostapd, a user space IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator, is vulnerable to a buffer overflow when processing fragmented EAP-TLS messages. As a result, an internal overflow checking routine terminates the process. An attacker can abuse this flaw to conduct denial of service attacks via crafted EAP-TLS messages prior to any authentication.

Alerts:
Debian DSA-2557-1 2012-10-08
Mageia MGASA-2012-0291 2012-10-11
Fedora FEDORA-2012-15748 2012-10-18
Fedora FEDORA-2012-15759 2012-10-18
openSUSE openSUSE-SU-2012:1371-1 2012-10-19
Mandriva MDVSA-2012:168 2012-10-22

Comments (none posted)

libxslt: code execution

Package(s):libxslt CVE #(s):CVE-2012-2893
Created:October 4, 2012 Updated:October 22, 2012
Description:

From the Ubuntu advisory:

Cris Neckar discovered that libxslt incorrectly managed memory. If a user or automated system were tricked into processing a specially crafted XSLT document, a remote attacker could cause libxslt to crash, causing a denial of service, or possibly execute arbitrary code. (CVE-2012-2893)

Alerts:
Ubuntu USN-1595-1 2012-10-04
Debian DSA-2555-1 2012-10-05
Mageia MGASA-2012-0283 2012-10-06
Mandriva MDVSA-2012:164 2012-10-11
openSUSE openSUSE-SU-2012:1376-1 2012-10-22
Mandriva MDVSA-2013:047 2013-04-05

Comments (none posted)

mozilla: multiple vulnerabilities

Package(s):firefox, thunderbird, seamonkey CVE #(s):CVE-2012-3983 CVE-2012-3989 CVE-2012-3984 CVE-2012-3985
Created:October 10, 2012 Updated:October 17, 2012
Description: From the Ubuntu advisory:

Henrik Skupin, Jesse Ruderman, Christian Holler, Soroush Dalili and others discovered several memory corruption flaws in Firefox. If a user were tricked into opening a specially crafted web page, a remote attacker could cause Firefox to crash or potentially execute arbitrary code as the user invoking the program. (CVE-2012-3982, CVE-2012-3983, CVE-2012-3988, CVE-2012-3989)

David Bloom and Jordi Chancel discovered that Firefox did not always properly handle the <select> element. A remote attacker could exploit this to conduct URL spoofing and clickjacking attacks. (CVE-2012-3984)

Collin Jackson discovered that Firefox did not properly follow the HTML5 specification for document.domain behavior. A remote attacker could exploit this to conduct cross-site scripting (XSS) attacks via javascript execution. (CVE-2012-3985)

Johnny Stenback discovered that Firefox did not properly perform security checks on tests methods for DOMWindowUtils. (CVE-2012-3986)

Alice White discovered that the security checks for GetProperty could be bypassed when using JSAPI. If a user were tricked into opening a specially crafted web page, a remote attacker could exploit this to execute arbitrary code as the user invoking the program. (CVE-2012-3991)

Mariusz Mlynski discovered a history state error in Firefox. A remote attacker could exploit this to spoof the location property to inject script or intercept posted data. (CVE-2012-3992)

Mariusz Mlynski and others discovered several flays in Firefox that allowed a remote attacker to conduct cross-site scripting (XSS) attacks. (CVE-2012-3993, CVE-2012-3994, CVE-2012-4184)

Abhishek Arya, Atte Kettunen and others discovered several memory flaws in Firefox when using the Address Sanitizer tool. If a user were tricked into opening a specially crafted web page, a remote attacker could cause Firefox to crash or potentially execute arbitrary code as the user invoking the program. (CVE-2012-3990, CVE-2012-3995, CVE-2012-4179, CVE-2012-4180, CVE-2012-4181, CVE-2012-4182, CVE-2012-4183, CVE-2012-4185, CVE-2012-4186, CVE-2012-4187, CVE-2012-4188)

Alerts:
Ubuntu USN-1600-1 2012-10-09
Ubuntu USN-1611-1 2012-10-12
openSUSE openSUSE-SU-2012:1345-1 2012-10-15
SUSE SUSE-SU-2012:1351-1 2012-10-16
Mageia MGASA-2012-0353 2012-12-07
Gentoo 201301-01 2013-01-07

Comments (none posted)

mozilla: multiple vulnerabilities

Package(s):firefox, thunderbird, seamonkey CVE #(s):CVE-2012-3982 CVE-2012-3986 CVE-2012-3988 CVE-2012-3990 CVE-2012-3991 CVE-2012-3992 CVE-2012-3993 CVE-2012-3994 CVE-2012-3995 CVE-2012-4179 CVE-2012-4180 CVE-2012-4181 CVE-2012-4182 CVE-2012-4183 CVE-2012-4184 CVE-2012-4185 CVE-2012-4186 CVE-2012-4187 CVE-2012-4188
Created:October 10, 2012 Updated:January 10, 2013
Description: From the Red Hat advisory:

Several flaws were found in the processing of malformed web content. A web page containing malicious content could cause Firefox to crash or, potentially, execute arbitrary code with the privileges of the user running Firefox. (CVE-2012-3982, CVE-2012-3988, CVE-2012-3990, CVE-2012-3995, CVE-2012-4179, CVE-2012-4180, CVE-2012-4181, CVE-2012-4182, CVE-2012-4183, CVE-2012-4185, CVE-2012-4186, CVE-2012-4187, CVE-2012-4188)

Two flaws in Firefox could allow a malicious website to bypass intended restrictions, possibly leading to information disclosure, or Firefox executing arbitrary code. Note that the information disclosure issue could possibly be combined with other flaws to achieve arbitrary code execution. (CVE-2012-3986, CVE-2012-3991)

Multiple flaws were found in the location object implementation in Firefox. Malicious content could be used to perform cross-site scripting attacks, script injection, or spoofing attacks. (CVE-2012-1956, CVE-2012-3992, CVE-2012-3994)

Two flaws were found in the way Chrome Object Wrappers were implemented. Malicious content could be used to perform cross-site scripting attacks or cause Firefox to execute arbitrary code. (CVE-2012-3993, CVE-2012-4184)

Alerts:
Red Hat RHSA-2012:1350-01 2012-10-09
Red Hat RHSA-2012:1351-01 2012-10-09
CentOS CESA-2012:1350 2012-10-10
CentOS CESA-2012:1351 2012-10-10
Scientific Linux SL-fire-20121010 2012-10-10
Scientific Linux SL-thun-20121010 2012-10-10
Slackware SSA:2012-283-01 2012-10-09
Ubuntu USN-1600-1 2012-10-09
CentOS CESA-2012:1350 2012-10-10
CentOS CESA-2012:1351 2012-10-10
Fedora FEDORA-2012-15863 2012-10-11
Fedora FEDORA-2012-15863 2012-10-11
Fedora FEDORA-2012-15863 2012-10-11
Mageia MGASA-2012-0288 2012-10-11
Mageia MGASA-2012-0289 2012-10-11
Mandriva MDVSA-2012:163 2012-10-11
Oracle ELSA-2012-1351 2012-10-10
Oracle ELSA-2012-1350 2012-10-11
Oracle ELSA-2012-1350 2012-10-10
Ubuntu USN-1611-1 2012-10-12
openSUSE openSUSE-SU-2012:1345-1 2012-10-15
Slackware SSA:2012-288-01 2012-10-15
SUSE SUSE-SU-2012:1351-1 2012-10-16
Debian DSA-2565-1 2012-10-23
Fedora FEDORA-2012-15877 2012-10-24
Fedora FEDORA-2012-15842 2012-10-24
Debian DSA-2569-1 2012-10-29
Debian DSA-2572-1 2012-11-04
Mageia MGASA-2012-0353 2012-12-07
Gentoo 201301-01 2013-01-07
Slackware SSA:2013-009-03 2013-01-10

Comments (none posted)

openstack-keystone: two authentication bypass flaws

Package(s):openstack-keystone CVE #(s):CVE-2012-4456 CVE-2012-4457
Created:October 4, 2012 Updated:October 10, 2012
Description:

From the Red Hat Bugzilla entries [1, 2]:

CVE-2012-4456: Jason Xu discovered several vulnerabilities in OpenStack Keystone token verification:

The first occurs in the API /v2.0/OS-KSADM/services and /v2.0/OS-KSADM/services/{service_id}, the second occurs in /v2.0/tenants/{tenant_id}/users/{user_id}/roles

In both cases the OpenStack Keystone code fails to check if the tokens are valid. These issues have been addressed by adding checks in the form of test_service_crud_requires_auth() and test_user_role_list_requires_auth().

CVE-2012-4457: Token authentication for a user belonging to a disable tenant should not be allowed.

Alerts:
Fedora FEDORA-2012-13075 2012-10-03
Red Hat RHSA-2012:1378-01 2012-10-16

Comments (none posted)

openstack-swift: insecure use of python pickle

Package(s):openstack-swift CVE #(s):CVE-2012-4406
Created:October 8, 2012 Updated:October 18, 2012
Description: From the Red Hat bugzilla:

Sebastian Krahmer (krahmer@suse.de) reports:

swift uses pickle to store and load meta data. pickle is insecure and allows to execute arbitrary code in loads().

Alerts:
Fedora FEDORA-2012-15098 2012-10-08
Red Hat RHSA-2012:1379-01 2012-10-16
Fedora FEDORA-2012-15642 2012-10-18

Comments (none posted)

php: multiple vulnerabilities

Package(s):php CVE #(s):
Created:October 8, 2012 Updated:October 10, 2012
Description: PHP 5.4.7 fixes multiple vulnerabilities. See the PHP changelog for details.
Alerts:
Mageia MGASA-2012-0281 2012-10-06

Comments (none posted)

phpldapadmin: cross-site scripting

Package(s):phpldapadmin CVE #(s):CVE-2012-1114 CVE-2012-1115
Created:October 8, 2012 Updated:October 10, 2012
Description: From the Red Hat bugzilla:

Originally (2012-03-01), the following cross-site (XSS) flaws were reported against LDAP Account Manager Pro (from Secunia advisory):

* 1) Input passed to e.g. the "filteruid" POST parameter when filtering result sets in lam/templates/lists/list.php (when "type" is set to a valid value) is not properly sanitised before being returned to the user. This can be exploited to execute arbitrary HTML and script code in a user's browser session in context of an affected site.

* 2) Input passed to the "filter" POST parameter in lam/templates/3rdParty/pla/htdocs/cmd.php (when "cmd" is set to "export" and "exporter_id" is set to "LDIF") is not properly sanitised before being returned to the user. This can be exploited to execute arbitrary HTML and script code in a user's browser session in context of an affected site.

* 3) Input passed to the "attr" parameter in lam/templates/3rdParty/pla/htdocs/cmd.php (when "cmd" is set to "add_value_form" and "dn" is set to a valid value) is not properly sanitised before being returned to the user. This can be exploited to execute arbitrary HTML and script code in a user's browser session in context of an affected site.

Alerts:
Fedora FEDORA-2012-14344 2012-10-06
Fedora FEDORA-2012-14363 2012-10-06

Comments (none posted)

php-zendframework: multiple vulnerabilities

Package(s):php-zendframework CVE #(s):
Created:October 8, 2012 Updated:October 10, 2012
Description: From the ZendFramework advisories [1], [2]:

[1] The default error handling view script generated using Zend_Tool failed to escape request parameters when run in the "development" configuration environment, providing a potential XSS attack vector.

[2] Developers using non-ASCII-compatible encodings in conjunction with the MySQL PDO driver of PHP may be vulnerable to SQL injection attacks. Developers using ASCII-compatible encodings like UTF8 or latin1 are not affected by this PHP issue.

Alerts:
Mageia MGASA-2012-0285 2012-10-06

Comments (none posted)

wireshark: denial of service

Package(s):wireshark CVE #(s):CVE-2012-5239 CVE-2012-3548
Created:October 8, 2012 Updated:March 8, 2013
Description: From the CVE entries:

The Mageia advisory references CVE-2012-5239, which is a duplicate of CVE-2012-3548.

The dissect_drda function in epan/dissectors/packet-drda.c in Wireshark 1.6.x through 1.6.10 and 1.8.x through 1.8.2 allows remote attackers to cause a denial of service (infinite loop and CPU consumption) via a small value for a certain length field in a capture file. (CVE-2012-3548)

Alerts:
Mageia MGASA-2012-0284 2012-10-06
Mandriva MDVSA-2013:020 2013-03-08
Mandriva MDVSA-2013:055 2013-04-05

Comments (none posted)

Page editor: Jake Edge
Next page: Kernel development>>

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds