Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525263pxf; Mon, 15 Mar 2021 11:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAPmx5lmBcgpqAHHxuMq8YIV85VPfH/b8pKRY6ZlrAViiPv+JPTrtfK9u0QxWN0tZnr1tW X-Received: by 2002:aa7:ca04:: with SMTP id y4mr31241030eds.339.1615832988857; Mon, 15 Mar 2021 11:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832988; cv=none; d=google.com; s=arc-20160816; b=CUObEkH/tPtpOB9xqBiHZhq4I0wYza9gIo+GN2zfETxoKX1USv1xMdSxA3o7BDM2e6 WIIMY11FLBzDQiFcep3Wnt3sZE28faV4wYIT1WdvrMX4uv1sw0b/7J4JZdVnqIjUzHCj exoJfolN2ze8FXI6UgvDGwWqFJIO+0/2cDZVVIzFj6lsUJup1Plukirqt3Bou2FyCxio XcUXCQPSLnZ0gxINzM8Nnzc3THVA/H76IYOFNCLBvye17Vr/TMvXYnGc+FkQFFnVP99R DrM+fBSCcvrIMzEQENfjp1CmGDlAYlZ2p5HSbzDzGjESPP1ZAT16aaozLZrW8tvl59Tz y10Q== 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=s45BtKcAi633KCT2bDSiGUKZbUkMK01HbViZN7aInD4=; b=y3Ko2V0JHtuhhzsiVd7Twyduq4Yx3UQmqp4L37SfeEA42NSnnXQg/oArmPI6+lrVDu 0mVOm3Qu8LnEKzi6sMDAI1zGpcx3jTrZfk340KS2E4r7M52Usv7h9y/WemfR25XwWOGK Yy4DenoWEhIrTEvOCiVVHiTh5clgnCPNyMsfTE8cwJSgGqG2lttl3JX721u3B5FmJjtV gD+FcH2Gb309XvkSbNySC/WaKFkj/ogMDygkaeXKsOzdRwJmDwHUMAJagKUlBfdONJ83 1091NtbLWvxqf+FKAWmdtxhQ88yNMpmZp5AjpPPwuLrPdE/RxkDSDn1JQtfnmd6r7jRD sonw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dClgpOlX; 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 g20si12261467edq.32.2021.03.15.11.29.23; Mon, 15 Mar 2021 11:29:48 -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=dClgpOlX; 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 S239795AbhCOOdH (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbhCOOBU (ORCPT ); Mon, 15 Mar 2021 10:01:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4ED4D64F52; Mon, 15 Mar 2021 14:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816855; bh=heoRBBbg4wXrFA16wBhi5rGQpliksVgEIuFQeZHud0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dClgpOlXQ1Ss12Bzlq8Sl9Tx8n/NCV0ZZUlGdd/t2urT9JPsLZflayO8hPy+A0mKb mqPENmwil4a7U5YDfp0B3382zcJDi+RG14BeSkKz0/FB/RrIuF0NFmb3dDIY3L8ktl iqZDH21uF3D0Bi8VRVEIeCTsd5oa7QwMtLmlyToA= 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 4.19 112/120] prctl: fix PR_SET_MM_AUXV kernel stack leak Date: Mon, 15 Mar 2021 14:57:43 +0100 Message-Id: <20210315135723.655143908@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 baf60a3aa34b..81ed6023d01b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2069,7 +2069,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