Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp851993pxk; Thu, 17 Sep 2020 19:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZiTQfN0p//cl3Nc3WbFu5gWtxJcp9xr6GRM3/Npqi+jwcpxId+7Nvb6wcH1O737QvmkUc X-Received: by 2002:a05:6402:184d:: with SMTP id v13mr36999209edy.240.1600394711587; Thu, 17 Sep 2020 19:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394711; cv=none; d=google.com; s=arc-20160816; b=k6vzFrVYQpijwu6/UC6c0nerA5BTXglzyXQXLWaLBFCRxDKtfAnHO3MxhHavMNe0a7 TuCpheJAAySjZgIgrIaOgM8sjluBNKSuSXGxAN8rNMM5bYz8oI0kv8ai6YkHbdiZXBLC Nf1pEDFgEO/DxcyXa/R4aJd3ingVTJNCoGBFA8m/E8sox05p5djbzUZm9Xb5E2pYZ+i0 cDiYxTs3yst7x8C/3OQPkYysAzmaESK6/Had1aL6npUYmsKlxTNFj3/2/aO9R1EMaDQY bLEVW2NC2b+prYAAetCK7h+vmeLZ7Jz+nTyRoWvxCkZfxzvLrL40F5TXuNeExXP7WTZ1 +HAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dtphBNQoCU8szYKmBoPvhFheXdo6LBmbRbukVfSFpds=; b=NxnvIuTJ8lDKP+8ULfP9+I22a/Xg/dUlbXrB9sDnoh7SFbAAqE76pmr+umkKdqglOH +0fW5zDnAH7FmGQkdTU5RjGdNpf3ripqeky6SehtCgHTPD4Iib7IgdXpxte60RttPYL1 vXhKNlNq6NDxEKNasdSVIb4JheZhLr57nLjBh/FVhO3zgQxNPr+XwAAxKI7wDiokWaDA wTExpq22Z55IaijgRq4bZwRKUiQAHIQXTemrI4373mm1afc26CBfFs/Ixi/dliVk8ZKH 7PAEnR50IQNVBDX0cHp7Uj2HvCKZf4Z6nIpSfwUZJgvZxKzd+wuz5nLuDcxYGKeKYze0 Lxvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Z+cl/lXb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy13si1180298ejb.481.2020.09.17.19.04.48; Thu, 17 Sep 2020 19:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Z+cl/lXb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbgIRCDB (ORCPT + 99 others); Thu, 17 Sep 2020 22:03:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgIRCCk (ORCPT ); Thu, 17 Sep 2020 22:02:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 016E1235F8; Fri, 18 Sep 2020 02:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394560; bh=7OB6RWjA1q5chzgCBY94D09Hb0OdN7JRaoGvy11b7iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+cl/lXbtEunZ9dms3wasZGhal6nkw6vDzQL/E1EJm5DWF1o4TrYywqPgXzBDaij+ mmFYcLqp0b+HULxPTlggJAHm87uSQYcqc+MIunRxTvI5wg9o+s+gw4Iu56Qk8Q9Irg gM3BRs5G0Wtqyaa7n1GELWGO+/TE3JQqVco69aIY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Joe Perches , Dan Carpenter , Julia Lawall , Thomas Gleixner , Kees Cook , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 5.4 073/330] kernel/sys.c: avoid copying possible padding bytes in copy_to_user Date: Thu, 17 Sep 2020 21:56:53 -0400 Message-Id: <20200918020110.2063155-73-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joe Perches [ Upstream commit 5e1aada08cd19ea652b2d32a250501d09b02ff2e ] Initialization is not guaranteed to zero padding bytes so use an explicit memset instead to avoid leaking any kernel content in any possible padding bytes. Link: http://lkml.kernel.org/r/dfa331c00881d61c8ee51577a082d8bebd61805c.camel@perches.com Signed-off-by: Joe Perches Cc: Dan Carpenter Cc: Julia Lawall Cc: Thomas Gleixner Cc: Kees Cook Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/sys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sys.c b/kernel/sys.c index a611d1d58c7d0..3459a5ce0da01 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1279,11 +1279,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) { - struct oldold_utsname tmp = {}; + struct oldold_utsname tmp; if (!name) return -EFAULT; + memset(&tmp, 0, sizeof(tmp)); + down_read(&uts_sem); memcpy(&tmp.sysname, &utsname()->sysname, __OLD_UTS_LEN); memcpy(&tmp.nodename, &utsname()->nodename, __OLD_UTS_LEN); -- 2.25.1