From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org,
Mathias Krause <minipli@googlemail.com>,
Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.hengli.com.au>
Subject: [ 68/82] crypto: user - fix info leaks in report API
Date: Mon, 18 Mar 2013 04:22:52 +0000 [thread overview]
Message-ID: <20130318042150.842287128@decadent.org.uk> (raw)
In-Reply-To: <20130318042144.234468645@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <minipli@googlemail.com>
commit 9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6 upstream.
Three errors resulting in kernel memory disclosure:
1/ The structures used for the netlink based crypto algorithm report API
are located on the stack. As snprintf() does not fill the remainder of
the buffer with null bytes, those stack bytes will be disclosed to users
of the API. Switch to strncpy() to fix this.
2/ crypto_report_one() does not initialize all field of struct
crypto_user_alg. Fix this to fix the heap info leak.
3/ For the module name we should copy only as many bytes as
module_name() returns -- not as much as the destination buffer could
hold. But the current code does not and therefore copies random data
from behind the end of the module name, as the module name is always
shorter than CRYPTO_MAX_ALG_NAME.
Also switch to use strncpy() to copy the algorithm's name and
driver_name. They are strings, after all.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
crypto/ablkcipher.c | 12 ++++++------
crypto/aead.c | 9 ++++-----
crypto/ahash.c | 2 +-
crypto/blkcipher.c | 6 +++---
crypto/crypto_user.c | 22 +++++++++++-----------
crypto/pcompress.c | 3 +--
crypto/rng.c | 2 +-
crypto/shash.c | 3 ++-
8 files changed, 29 insertions(+), 30 deletions(-)
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -388,9 +388,9 @@ static int crypto_ablkcipher_report(stru
{
struct crypto_report_blkcipher rblkcipher;
- snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "ablkcipher");
- snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s",
- alg->cra_ablkcipher.geniv ?: "<default>");
+ strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
+ strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
+ sizeof(rblkcipher.geniv));
rblkcipher.blocksize = alg->cra_blocksize;
rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
@@ -469,9 +469,9 @@ static int crypto_givcipher_report(struc
{
struct crypto_report_blkcipher rblkcipher;
- snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "givcipher");
- snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s",
- alg->cra_ablkcipher.geniv ?: "<built-in>");
+ strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
+ strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
+ sizeof(rblkcipher.geniv));
rblkcipher.blocksize = alg->cra_blocksize;
rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -117,9 +117,8 @@ static int crypto_aead_report(struct sk_
struct crypto_report_aead raead;
struct aead_alg *aead = &alg->cra_aead;
- snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "aead");
- snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s",
- aead->geniv ?: "<built-in>");
+ strncpy(raead.type, "aead", sizeof(raead.type));
+ strncpy(raead.geniv, aead->geniv ?: "<built-in>", sizeof(raead.geniv));
raead.blocksize = alg->cra_blocksize;
raead.maxauthsize = aead->maxauthsize;
@@ -203,8 +202,8 @@ static int crypto_nivaead_report(struct
struct crypto_report_aead raead;
struct aead_alg *aead = &alg->cra_aead;
- snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "nivaead");
- snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", aead->geniv);
+ strncpy(raead.type, "nivaead", sizeof(raead.type));
+ strncpy(raead.geniv, aead->geniv, sizeof(raead.geniv));
raead.blocksize = alg->cra_blocksize;
raead.maxauthsize = aead->maxauthsize;
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -404,7 +404,7 @@ static int crypto_ahash_report(struct sk
{
struct crypto_report_hash rhash;
- snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "ahash");
+ strncpy(rhash.type, "ahash", sizeof(rhash.type));
rhash.blocksize = alg->cra_blocksize;
rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize;
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -499,9 +499,9 @@ static int crypto_blkcipher_report(struc
{
struct crypto_report_blkcipher rblkcipher;
- snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "blkcipher");
- snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s",
- alg->cra_blkcipher.geniv ?: "<default>");
+ strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type));
+ strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>",
+ sizeof(rblkcipher.geniv));
rblkcipher.blocksize = alg->cra_blocksize;
rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize;
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -71,7 +71,7 @@ static int crypto_report_cipher(struct s
{
struct crypto_report_cipher rcipher;
- snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher");
+ strncpy(rcipher.type, "cipher", sizeof(rcipher.type));
rcipher.blocksize = alg->cra_blocksize;
rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
@@ -90,8 +90,7 @@ static int crypto_report_comp(struct sk_
{
struct crypto_report_comp rcomp;
- snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression");
-
+ strncpy(rcomp.type, "compression", sizeof(rcomp.type));
NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
sizeof(struct crypto_report_comp), &rcomp);
@@ -104,12 +103,14 @@ nla_put_failure:
static int crypto_report_one(struct crypto_alg *alg,
struct crypto_user_alg *ualg, struct sk_buff *skb)
{
- memcpy(&ualg->cru_name, &alg->cra_name, sizeof(ualg->cru_name));
- memcpy(&ualg->cru_driver_name, &alg->cra_driver_name,
- sizeof(ualg->cru_driver_name));
- memcpy(&ualg->cru_module_name, module_name(alg->cra_module),
- CRYPTO_MAX_ALG_NAME);
+ strncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
+ strncpy(ualg->cru_driver_name, alg->cra_driver_name,
+ sizeof(ualg->cru_driver_name));
+ strncpy(ualg->cru_module_name, module_name(alg->cra_module),
+ sizeof(ualg->cru_module_name));
+ ualg->cru_type = 0;
+ ualg->cru_mask = 0;
ualg->cru_flags = alg->cra_flags;
ualg->cru_refcnt = atomic_read(&alg->cra_refcnt);
@@ -118,8 +119,7 @@ static int crypto_report_one(struct cryp
if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
struct crypto_report_larval rl;
- snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval");
-
+ strncpy(rl.type, "larval", sizeof(rl.type));
NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL,
sizeof(struct crypto_report_larval), &rl);
--- a/crypto/pcompress.c
+++ b/crypto/pcompress.c
@@ -53,8 +53,7 @@ static int crypto_pcomp_report(struct sk
{
struct crypto_report_comp rpcomp;
- snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp");
-
+ strncpy(rpcomp.type, "pcomp", sizeof(rpcomp.type));
NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
sizeof(struct crypto_report_comp), &rpcomp);
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -65,7 +65,7 @@ static int crypto_rng_report(struct sk_b
{
struct crypto_report_rng rrng;
- snprintf(rrng.type, CRYPTO_MAX_ALG_NAME, "%s", "rng");
+ strncpy(rrng.type, "rng", sizeof(rrng.type));
rrng.seedsize = alg->cra_rng.seedsize;
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -530,7 +530,8 @@ static int crypto_shash_report(struct sk
struct crypto_report_hash rhash;
struct shash_alg *salg = __crypto_shash_alg(alg);
- snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "shash");
+ strncpy(rhash.type, "shash", sizeof(rhash.type));
+
rhash.blocksize = alg->cra_blocksize;
rhash.digestsize = salg->digestsize;
next prev parent reply other threads:[~2013-03-18 4:46 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-18 4:21 [ 00/82] 3.2.41-stable review Ben Hutchings
2013-03-18 4:21 ` [ 01/82] Revert "powerpc/eeh: Fix crash when adding a device in a slot with DDW" Ben Hutchings
2013-03-18 4:21 ` [ 02/82] btrfs: Init io_lock after cloning btrfs device struct Ben Hutchings
2013-03-18 4:21 ` [ 03/82] md: protect against crash upon fsync on ro array Ben Hutchings
2013-03-18 4:21 ` [ 04/82] NFS: Dont allow NFS silly-renamed files to be deleted, no signal Ben Hutchings
2013-03-18 4:21 ` [ 05/82] SUNRPC: Dont start the retransmission timer when out of socket space Ben Hutchings
2013-03-18 4:21 ` [ 06/82] [SCSI] storvsc: Initialize the sglist Ben Hutchings
2013-03-18 4:21 ` [ 07/82] [SCSI] dc395x: uninitialized variable in device_alloc() Ben Hutchings
2013-03-18 4:21 ` [ 08/82] ARM: VFP: fix emulation of second VFP instruction Ben Hutchings
2013-03-18 4:21 ` [ 09/82] ARM: fix scheduling while atomic warning in alignment handling code Ben Hutchings
2013-03-18 4:21 ` [ 10/82] md: fix two bugs when attempting to resize RAID0 array Ben Hutchings
2013-03-18 4:21 ` [ 11/82] md: raid0: fix error return from create_stripe_zones Ben Hutchings
2013-03-18 4:21 ` [ 12/82] proc connector: reject unprivileged listener bumps Ben Hutchings
2013-03-18 4:21 ` [ 13/82] ath9k: fix RSSI dummy marker value Ben Hutchings
2013-03-18 4:21 ` [ 14/82] ath9k_htc: fix signal strength handling issues Ben Hutchings
2013-03-18 4:21 ` [ 15/82] mwifiex: correct sleep delay counter Ben Hutchings
2013-03-18 4:22 ` [ 16/82] cifs: ensure that cifs_get_root() only traverses directories Ben Hutchings
2013-03-18 4:22 ` [ 17/82] xen/pci: We dont do multiple MSIs Ben Hutchings
2013-03-18 4:22 ` [ 18/82] dm: fix truncated status strings Ben Hutchings
2013-03-18 4:22 ` [ 19/82] dm snapshot: add missing module aliases Ben Hutchings
2013-03-18 4:22 ` [ 20/82] drm/i915: Dont clobber crtc->fb when queue_flip fails Ben Hutchings
2013-03-18 4:22 ` [ 21/82] ARM: 7663/1: perf: fix ARMv7 EVTYPE_MASK to include NSH bit Ben Hutchings
2013-03-18 4:22 ` [ 22/82] hwmon: (pmbus/ltc2978) Fix peak attribute handling Ben Hutchings
2013-03-18 4:22 ` [ 23/82] hwmon: (pmbus/ltc2978) Use detected chip ID to select supported functionality Ben Hutchings
2013-03-18 4:22 ` [ 24/82] hwmon: (sht15) Check return value of regulator_enable() Ben Hutchings
2013-03-18 4:22 ` [ 25/82] hw_random: make buffer usable in scatterlist Ben Hutchings
2013-03-18 4:22 ` [ 26/82] ALSA: vmaster: Fix slave change notification Ben Hutchings
2013-03-18 4:22 ` [ 27/82] drm/radeon: add primary dac adj quirk for R200 board Ben Hutchings
2013-03-18 4:22 ` [ 28/82] dmi_scan: fix missing check for _DMI_ signature in smbios_present() Ben Hutchings
2013-03-18 4:22 ` [ 29/82] iwlwifi: always copy first 16 bytes of commands Ben Hutchings
2013-03-18 4:22 ` [ 30/82] HID: add support for Sony RF receiver with USB product id 0x0374 Ben Hutchings
2013-03-18 4:22 ` [ 31/82] HID: clean up quirk for Sony RF receivers Ben Hutchings
2013-03-18 4:22 ` [ 32/82] ahci: AHCI-mode SATA patch for Intel Lynx Point DeviceIDs Ben Hutchings
2013-03-18 4:22 ` [ 33/82] ahci: Add Device IDs for Intel Lynx Point-LP PCH Ben Hutchings
2013-03-18 4:22 ` [ 34/82] ahci: AHCI-mode SATA patch for Intel Avoton DeviceIDs Ben Hutchings
2013-03-18 4:22 ` [ 35/82] ahci: Add Device IDs for Intel Wellsburg PCH Ben Hutchings
2013-03-18 4:22 ` [ 36/82] iommu/amd: Initialize device table after dma_ops Ben Hutchings
2013-03-18 4:22 ` [ 37/82] tty: Correct tty buffer flush Ben Hutchings
2013-03-18 4:22 ` [ 38/82] efi_pstore: Check remaining space with QueryVariableInfo() before writing data Ben Hutchings
2013-03-18 4:22 ` [ 39/82] efivars: Disable external interrupt while holding efivars->lock Ben Hutchings
2013-03-18 4:22 ` [ 40/82] efi: be more paranoid about available space when creating variables Ben Hutchings
2013-03-18 4:22 ` [ 41/82] ftrace: Update the kconfig for DYNAMIC_FTRACE Ben Hutchings
2013-03-18 4:22 ` [ 42/82] decnet: Fix disappearing sysctl entries Ben Hutchings
2013-03-18 4:22 ` [ 43/82] Fix memory leak in cpufreq stats Ben Hutchings
2013-03-18 4:22 ` [ 44/82] vfs: fix pipe counter breakage Ben Hutchings
2013-03-18 4:22 ` [ 45/82] USB: EHCI: dont check DMA values in QH overlays Ben Hutchings
2013-03-19 3:09 ` Ben Hutchings
2013-03-19 15:27 ` Alan Stern
2013-03-19 20:31 ` Ben Hutchings
2013-03-18 4:22 ` [ 46/82] xen/pciback: Dont disable a PCI device that is already disabled Ben Hutchings
2013-03-18 4:22 ` [ 47/82] USB: option: add Huawei E5331 Ben Hutchings
2013-03-18 4:22 ` [ 48/82] USB: storage: fix Huawei mode switching regression Ben Hutchings
2013-03-18 4:22 ` [ 49/82] USB: added support for Cinterions products AH6 and PLS8 Ben Hutchings
2013-03-18 4:22 ` [ 50/82] e1000e: fix pci-device enable-counter balance Ben Hutchings
2013-03-18 4:22 ` [ 51/82] virtio: rng: disallow multiple device registrations, fixes crashes Ben Hutchings
2013-03-18 4:22 ` [ 52/82] ALSA: seq: Fix missing error handling in snd_seq_timer_open() Ben Hutchings
2013-03-18 4:22 ` [ 53/82] usb: cp210x new Vendor/Device IDs Ben Hutchings
2013-03-18 4:22 ` [ 54/82] staging: vt6656: Fix oops on resume from suspend Ben Hutchings
2013-03-18 4:22 ` [ 55/82] qcaux: add Franklin U600 Ben Hutchings
2013-03-18 4:22 ` [ 56/82] ext3: Fix format string issues Ben Hutchings
2013-03-18 4:22 ` [ 57/82] keys: fix race with concurrent install_user_keyrings() Ben Hutchings
2013-03-18 4:22 ` [ 58/82] tty/serial: Add support for Altera serial port Ben Hutchings
2013-03-18 4:22 ` [ 59/82] Fix 4 port and add support for 8 port Unknown PCI serial port cards Ben Hutchings
2013-03-18 4:22 ` [ 60/82] serial: 8250_pci: add support for another kind of NetMos Technology PCI 9835 Multi-I/O Controller Ben Hutchings
2013-03-18 4:22 ` [ 61/82] tty: serial: fix typo "ARCH_S5P6450" Ben Hutchings
2013-03-18 4:22 ` [ 62/82] usb: serial: Add Rigblaster Advantage to device table Ben Hutchings
2013-03-18 4:22 ` [ 63/82] w1: fix oops when w1_search is called from netlink connector Ben Hutchings
2013-03-18 4:22 ` [ 64/82] USB: cdc-wdm: fix buffer overflow Ben Hutchings
2013-03-18 4:22 ` [ 65/82] signal: always clear sa_restorer on execve Ben Hutchings
2013-03-18 4:22 ` [ 66/82] hwmon: (lineage-pem) Add missing terminating entry for pem_[input|fan]_attributes Ben Hutchings
2013-03-18 4:22 ` [ 67/82] hwmon: (pmbus/ltc2978) Fix temperature reporting Ben Hutchings
2013-03-18 4:22 ` Ben Hutchings [this message]
2013-03-18 4:22 ` [ 69/82] Fix: compat_rw_copy_check_uvector() misuse in aio, readv, writev, and security keys Ben Hutchings
2013-03-18 4:22 ` [ 70/82] USB: Dont use EHCI port sempahore for USB 3.0 hubs Ben Hutchings
2013-03-18 4:22 ` [ 71/82] USB: Prepare for refactoring by adding extra udev checks Ben Hutchings
2013-03-18 4:22 ` [ 72/82] USB: Rip out recursive call on warm port reset Ben Hutchings
2013-03-18 4:22 ` [ 73/82] USB: Fix connected device switch to Inactive state Ben Hutchings
2013-03-18 4:22 ` [ 74/82] batman-adv: bat_socket_read missing checks Ben Hutchings
2013-03-18 4:22 ` [ 75/82] batman-adv: Only write requested number of byte to user buffer Ben Hutchings
2013-03-18 4:23 ` [ 76/82] mm/hotplug: correctly add new zone to all other nodes zone lists Ben Hutchings
2013-03-18 4:23 ` [ 77/82] xen-netfront: delay gARP until backend switches to Connected Ben Hutchings
2013-03-18 4:23 ` [ 78/82] block: use i_size_write() in bd_set_size() Ben Hutchings
2013-03-18 4:23 ` [ 79/82] loopdev: fix a deadlock Ben Hutchings
2013-03-18 4:23 ` [ 80/82] loopdev: remove an user triggerable oops Ben Hutchings
2013-03-18 4:23 ` [ 81/82] btrfs: use rcu_barrier() to wait for bdev puts at unmount Ben Hutchings
2013-03-18 4:23 ` [ 82/82] NLS: improve UTF8 -> UTF16 string conversion routine Ben Hutchings
2013-03-18 5:00 ` [ 00/82] 3.2.41-stable review Ben Hutchings
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=20130318042150.842287128@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=herbert@gondor.hengli.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=minipli@googlemail.com \
--cc=stable@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/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