Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529394pxf; Mon, 15 Mar 2021 11:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2HybwHcnPyTV0W9yV/ESWNFJEi5ZjZGZ8mLpR/iQduMwTdKsXNbOYmhuu6me7ylDUNUNm X-Received: by 2002:a17:906:565a:: with SMTP id v26mr25688458ejr.516.1615833322323; Mon, 15 Mar 2021 11:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833322; cv=none; d=google.com; s=arc-20160816; b=rdBSZO6beBJhZHDjfh8q085+7Oty/+zOek6mkVLKTL5qavYwAGOlxAxOQGXDV8uzDc 0McXP+XGaq7UseH0sjFIFTEpAdhx38VTyPZwShkScrZtlPgacFmGr5VFaFstXmHz4alL 6UTtbNCJGZQ2JCkqt+pa/6syBaYr4MNzO6eTA2lXGIyhdTgPuPp765QaLodxcEDvxHgS yEOdQPT2m5OdZ7XHfBgCVvnNOGJI5QuNmKxlYsTINgw7j5CpI1Wgucjne2NcRvPLBgHy jrXKjjQdRnX8ScIwZh0WGY7aM3I17VihdqnWo2kkQpnxKJh5m2j2psytoUnn/zzsHa6o S+Jg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FsCYUkGmfIqS4xdcvt/dKg/I9mKFpItLl7sOVTzgGJ8=; b=NQ0hNR1KQp6iAn47TTDRRfViuF31kpUlcLKHJmMkyc4Wurs2/KtQLmcDspZ2d61g/Q OgeO7X/0Nefcs1CvSkkXnyWudGZ5zgWfNkhsQdZA9wl+PW7gG8pEWRPu5WzPdrPwwFqQ fjWOgtUdKj1FT0bfUkXtA2rbKKeZs8vkPpE7HXbXkRU4/ikd+1uVe9JASlCAiqv3Zbip h/3X/PPzbqssHDUic7ecZ/MQKdk5xSo/bv0B9Ynq6CUEC5kmWKitHfr4G4VyHJkz2/4u Lj7S8lG4D7HAGBNhwFR2/+QE80dtw8Y9RDRsVl/osBY6U4qqnqHXHgZcmpQijbcZmP9a RQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XlWK1ijw; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si11220034edt.469.2021.03.15.11.35.00; Mon, 15 Mar 2021 11:35:22 -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=@linuxfoundation.org header.s=korg header.b=XlWK1ijw; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238707AbhCOOoz (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:51172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233590AbhCOOED (ORCPT ); Mon, 15 Mar 2021 10:04:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 113DF64E83; Mon, 15 Mar 2021 14:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817042; bh=iXbS/5ssr4QwnlzugOT1vgBTnbWnzpyoMa5HSr/L7Is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlWK1ijwzAT0SIPZBhcdk8iXD1a907Zgf4LS3Zx0YB4Zb3z/SES74RPvuRqWd+ztC VzloeapCUcWHPg9r8fee57L2dH3ttawY8eqAWebmm3Cr/zyZ35YCThWnbZaDNvXcQx JnULdj4p18iQJ3xbod3mcAawTuVbx/3n075PT4As= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Dobriyan , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 260/290] prctl: fix PR_SET_MM_AUXV kernel stack leak Date: Mon, 15 Mar 2021 14:55:53 +0100 Message-Id: <20210315135550.804630990@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Alexey Dobriyan [ Upstream commit c995f12ad8842dbf5cfed113fb52cdd083f5afd1 ] Doing a prctl(PR_SET_MM, PR_SET_MM_AUXV, addr, 1); will copy 1 byte from userspace to (quite big) on-stack array and then stash everything to mm->saved_auxv. AT_NULL terminator will be inserted at the very end. /proc/*/auxv handler will find that AT_NULL terminator and copy original stack contents to userspace. This devious scheme requires CAP_SYS_RESOURCE. Signed-off-by: Alexey Dobriyan Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sys.c b/kernel/sys.c index a730c03ee607..2603280b97be 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2079,7 +2079,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr, * up to the caller to provide sane values here, otherwise userspace * tools which use this vector might be unhappy. */ - unsigned long user_auxv[AT_VECTOR_SIZE]; + unsigned long user_auxv[AT_VECTOR_SIZE] = {}; if (len > sizeof(user_auxv)) return -EINVAL; -- 2.30.1