Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2975894imu; Mon, 19 Nov 2018 08:52:15 -0800 (PST) X-Google-Smtp-Source: AJdET5cZOZ9LfTZ3lo2Br8cmfHj1vfiNMbTNkP0IBE4HLGUBly6EslK+r53XNuU5B0RiZUxqLEFl X-Received: by 2002:a62:4105:: with SMTP id o5-v6mr23223538pfa.85.1542646335927; Mon, 19 Nov 2018 08:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646335; cv=none; d=google.com; s=arc-20160816; b=fIaN6fmRzS5Zw4Gdixz6AAMOPXUxMuM1hZ5XKxk+rz0KHeAR5yikq+7c7WG7F6AFNb PbCzyz3X++CZzibfJsAmLgqVoRo/+SZ4MtQeNLjQVi7J9TyOcjhROiiotVHfBIo0aE8z 0hJZsQlJRRHoYchVsLhEYDEos0mhgk8n6jl0Fv3pDHiPz/Yy2jv5ThtdEuFU9xg58jGG Q2WMM8oHt8w2bn9ThQrCY/Wr3rpXhS7QRQZE8IjWQN8yR0gnXS8rGH0mftT0xVUjBBDG FWZnTctoxo3pToYgZAWYnFNodGJc8RmMdFfe4QS63IXK87pjmxUaCIwOSJY1gH6jc+zx 41fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g78vgZHfGynHgoSdQm/GDOewSe7ehOi7unztO5cjHaA=; b=cZ63DG3HZIOfiMitd7dKVLn8DLXciBZwZO4iTis4dAVv7auewEkWfcAIGSaBrDLVEp 8Sf/gKKVd5yjR8YimYJcrNrMZRTDk0fn9jeXc0o7hsELbGAzNaJMxvkt78CDUg3AHMqz xzPE2UwmQrIunqnC6NUp6VL42HIqtEvik/WJHUED6MICHo/OMzt6VFKWBUoRXGJydkrb +IRNHdfHVXc6TB+SiO1aofpXG1J07llGLmp2PRVm6u4/v6Bx5FSvc9zSNnb+WhebRKy7 /8FpsPWR+53pe6gBQr6FW+98k8huXg0AGhzNp0/0zkymJHcXl4IsRdqmVL0e+rY1Gb4R dHIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MpRzgR97; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si37120585pgq.215.2018.11.19.08.52.01; Mon, 19 Nov 2018 08:52:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MpRzgR97; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390230AbeKTDPZ (ORCPT + 99 others); Mon, 19 Nov 2018 22:15:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:52998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388976AbeKTDPZ (ORCPT ); Mon, 19 Nov 2018 22:15:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8717B21104; Mon, 19 Nov 2018 16:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646272; bh=EldxGgaxHkTiH8zUq66S1LX4wGZSXlEH3uOHODuaOyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpRzgR979SH6syeeXECrB8OvM38QX9R2U+ddssUGq10OeRrHlcBB/bgGKgA+DQF5P BQa7bECBtS4Qj3EMc+nXm6/26DjcoX25chTFW3JaZGVORJOnO9MEd9N9YYzAwN730p ym9vzsUBu6OitWYLo1RGwRUDelIv4J7ssPIoYBow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 4.14 102/124] crypto: user - fix leaking uninitialized memory to userspace Date: Mon, 19 Nov 2018 17:29:16 +0100 Message-Id: <20181119162631.563208168@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.951907286@linuxfoundation.org> References: <20181119162612.951907286@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit f43f39958beb206b53292801e216d9b8a660f087 upstream. All bytes of the NETLINK_CRYPTO report structures must be initialized, since they are copied to userspace. The change from strncpy() to strlcpy() broke this. As a minimal fix, change it back. Fixes: 4473710df1f8 ("crypto: user - Prepare for CRYPTO_MAX_ALG_NAME expansion") Cc: # v4.12+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/crypto_user.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c @@ -83,7 +83,7 @@ static int crypto_report_cipher(struct s { struct crypto_report_cipher rcipher; - strlcpy(rcipher.type, "cipher", sizeof(rcipher.type)); + strncpy(rcipher.type, "cipher", sizeof(rcipher.type)); rcipher.blocksize = alg->cra_blocksize; rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; @@ -102,7 +102,7 @@ static int crypto_report_comp(struct sk_ { struct crypto_report_comp rcomp; - strlcpy(rcomp.type, "compression", sizeof(rcomp.type)); + strncpy(rcomp.type, "compression", sizeof(rcomp.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, sizeof(struct crypto_report_comp), &rcomp)) goto nla_put_failure; @@ -116,7 +116,7 @@ static int crypto_report_acomp(struct sk { struct crypto_report_acomp racomp; - strlcpy(racomp.type, "acomp", sizeof(racomp.type)); + strncpy(racomp.type, "acomp", sizeof(racomp.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP, sizeof(struct crypto_report_acomp), &racomp)) @@ -131,7 +131,7 @@ static int crypto_report_akcipher(struct { struct crypto_report_akcipher rakcipher; - strlcpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); + strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER, sizeof(struct crypto_report_akcipher), &rakcipher)) @@ -146,7 +146,7 @@ static int crypto_report_kpp(struct sk_b { struct crypto_report_kpp rkpp; - strlcpy(rkpp.type, "kpp", sizeof(rkpp.type)); + strncpy(rkpp.type, "kpp", sizeof(rkpp.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_KPP, sizeof(struct crypto_report_kpp), &rkpp)) @@ -160,10 +160,10 @@ nla_put_failure: static int crypto_report_one(struct crypto_alg *alg, struct crypto_user_alg *ualg, struct sk_buff *skb) { - strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); - strlcpy(ualg->cru_driver_name, alg->cra_driver_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)); - strlcpy(ualg->cru_module_name, module_name(alg->cra_module), + strncpy(ualg->cru_module_name, module_name(alg->cra_module), sizeof(ualg->cru_module_name)); ualg->cru_type = 0; @@ -176,7 +176,7 @@ static int crypto_report_one(struct cryp if (alg->cra_flags & CRYPTO_ALG_LARVAL) { struct crypto_report_larval rl; - strlcpy(rl.type, "larval", sizeof(rl.type)); + strncpy(rl.type, "larval", sizeof(rl.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, sizeof(struct crypto_report_larval), &rl)) goto nla_put_failure;