From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Yevgeny Pats <yevgeny@perception-point.io>,
David Howells <dhowells@redhat.com>,
Don Zickus <dzickus@redhat.com>,
Prarit Bhargava <prarit@redhat.com>,
Jarod Wilson <jarod@redhat.com>,
James Morris <james.l.morris@oracle.com>
Subject: [PATCH 4.1 43/43] KEYS: Fix keyring ref leak in join_session_keyring()
Date: Wed, 20 Jan 2016 15:10:50 -0800 [thread overview]
Message-ID: <20160120215933.287438207@linuxfoundation.org> (raw)
In-Reply-To: <20160120215926.787430744@linuxfoundation.org>
4.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yevgeny Pats <yevgeny@perception-point.io>
commit 23567fd052a9abb6d67fe8e7a9ccdd9800a540f2 upstream.
This fixes CVE-2016-0728.
If a thread is asked to join as a session keyring the keyring that's already
set as its session, we leak a keyring reference.
This can be tested with the following program:
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <keyutils.h>
int main(int argc, const char *argv[])
{
int i = 0;
key_serial_t serial;
serial = keyctl(KEYCTL_JOIN_SESSION_KEYRING,
"leaked-keyring");
if (serial < 0) {
perror("keyctl");
return -1;
}
if (keyctl(KEYCTL_SETPERM, serial,
KEY_POS_ALL | KEY_USR_ALL) < 0) {
perror("keyctl");
return -1;
}
for (i = 0; i < 100; i++) {
serial = keyctl(KEYCTL_JOIN_SESSION_KEYRING,
"leaked-keyring");
if (serial < 0) {
perror("keyctl");
return -1;
}
}
return 0;
}
If, after the program has run, there something like the following line in
/proc/keys:
3f3d898f I--Q--- 100 perm 3f3f0000 0 0 keyring leaked-keyring: empty
with a usage count of 100 * the number of times the program has been run,
then the kernel is malfunctioning. If leaked-keyring has zero usages or
has been garbage collected, then the problem is fixed.
Reported-by: Yevgeny Pats <yevgeny@perception-point.io>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Acked-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/process_keys.c | 1 +
1 file changed, 1 insertion(+)
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -794,6 +794,7 @@ long join_session_keyring(const char *na
ret = PTR_ERR(keyring);
goto error2;
} else if (keyring == new->session_keyring) {
+ key_put(keyring);
ret = 0;
goto error2;
}
next prev parent reply other threads:[~2016-01-20 23:10 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-20 23:10 [PATCH 4.1 00/43] 4.1.16-stable review Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 01/43] tpm, tpm_tis: fix tpm_tis ACPI detection issue with TPM 2.0 Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 02/43] toshiba_acpi: Initialize hotkey_event_type variable Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 03/43] USB: cdc_acm: Ignore Infineon Flash Loader utility Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 04/43] USB: serial: Another Infineon flash loader USB ID Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 05/43] usb-storage: Fix scsi-sd failure "Invalid field in cdb" for USB adapter JMicron Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 06/43] USB: cp210x: Remove CP2110 ID from compatibility list Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 07/43] USB: add quirk for devices with broken LPM Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 08/43] USB: whci-hcd: add check for dma mapping error Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 09/43] usb: gadget: pxa27x: fix suspend callback Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 10/43] usb: musb: USB_TI_CPPI41_DMA requires dmaengine support Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 11/43] usb: core : hub: Fix BOS NULL pointer kernel panic Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 12/43] usb: Use the USB_SS_MULT() macro to decode burst multiplier for log message Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 13/43] pppoe: fix memory corruption in padt work structure Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 14/43] gre6: allow to update all parameters via rtnl Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 15/43] atl1c: Improve driver not to do order 4 GFP_ATOMIC allocation Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 17/43] vxlan: fix incorrect RCO bit in VXLAN header Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 18/43] sctp: use the same clock as if sock source timestamps were on Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 19/43] sctp: update the netstamp_needed counter when copying sockets Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 20/43] sctp: also copy sk_tsflags when copying the socket Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 21/43] net: qca_spi: fix transmit queue timeout handling Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 22/43] r8152: fix lockup when runtime PM is enabled Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 23/43] ipv6: sctp: clone options to avoid use after free Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 25/43] sh_eth: fix kernel oops in skb_put() Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 26/43] net: fix IP early demux races Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 27/43] pptp: verify sockaddr_len in pptp_bind() and pptp_connect() Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 28/43] vlan: Fix untag operations of stacked vlans with REORDER_HEADER off Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 29/43] skbuff: Fix offset error in skb_reorder_vlan_header Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 30/43] net: check both type and procotol for tcp sockets Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 31/43] net_sched: make qdisc_tree_decrease_qlen() work for non mq Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 32/43] bluetooth: Validate socket address length in sco_sock_bind() Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 33/43] net: fix uninitialized variable issue Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 35/43] rhashtable: Enforce minimum size on initial hash table Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 36/43] fou: clean up socket with kfree_rcu Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 37/43] af_unix: Revert lock_interruptible in stream receive code Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 38/43] tcp: restore fastopen with no data in SYN packet Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 39/43] rhashtable: Fix walker list corruption Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 40/43] KEYS: Fix race between key destruction and finding a keyring by name Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 41/43] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Greg Kroah-Hartman
2016-01-20 23:10 ` [PATCH 4.1 42/43] KEYS: Fix race between read and revoke Greg Kroah-Hartman
2016-01-20 23:10 ` Greg Kroah-Hartman [this message]
2016-01-20 23:51 ` [PATCH 4.1 00/43] 4.1.16-stable review Shuah Khan
2016-01-21 12:23 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160120215933.287438207@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=dhowells@redhat.com \
--cc=dzickus@redhat.com \
--cc=james.l.morris@oracle.com \
--cc=jarod@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prarit@redhat.com \
--cc=stable@vger.kernel.org \
--cc=yevgeny@perception-point.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).