Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529152pxf; Mon, 15 Mar 2021 11:35:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZygRJCkl/68+8nPIq3OixvB1d+jJLamqMuFOD9GfidXfnVSErudvzxcdnx7Ysrq3lq3B6 X-Received: by 2002:a05:6402:254f:: with SMTP id l15mr31612887edb.189.1615833304090; Mon, 15 Mar 2021 11:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833304; cv=none; d=google.com; s=arc-20160816; b=s4xGW+FjqEIHlt9IPbzJW5BPOAsJQOnY+a5iJd7KcuTvC+t7xTI3DCSdw6szN2HWQT oSRSwrSdbiDBgmmyxbNsBq/28oaRORvlQkTN6Dk1hHRN1AXJhG8oizBYx++JfV1hGlJL PU08bTzeVLzMkXabO7Ir07bSv4uC4kYMEEcYMM7yMT3PqYwdbMnR50iS+eVedLoJY+Yf B0xchhjARFp2E+nnvwOdYcTP650qEBqxmOuHOGTd1/bFxE0M6wBCNZEYKRpGbKPY8FvB 6u2J8H4HTCmhZ+4can2Qu7m/FKZ19kDi56B2ALE+9WAOrp/FBeurIorY139H2HiWjW5S xtmg== 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=Zw3U25maesoG6xRnlR49r3zmycdSBC2HQjvwh2TL71Q=; b=JwN8ithdz/QDCTYwi1A5dO4JIWrEudqUmhd/mwGXYVTFxM0puf6GBhBTQZjBpXQE8C pSZh+4xg7DMy07oH+qFtPnGIlH5sXchKJQyw2y9iS1nsWDTsRsbhmJ3aXsg7p7/+dR6b QZbOIM4+yrgVQD7yyu8NhiniIim1bp3idRlSkK0ASUK8Qo+2o1XbO/L1AYogGKEe6Oqq 6riWzBqpB0C9Pe/bq4N7dsIsQIUF9wgt/wRFM2LI8IyO8q+9XO719l87Ab9iRdgaqhQw fiafKCbjZ5pU+Vdh+W6mhev55dZXpKx2inOcDfvt9OEkz90rauxnXi9tI8IaiG9Knz09 oojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tHRAwjtU; 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 c17si5836889ede.535.2021.03.15.11.34.42; Mon, 15 Mar 2021 11:35:04 -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=tHRAwjtU; 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 S238436AbhCOOon (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:50658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbhCOODx (ORCPT ); Mon, 15 Mar 2021 10:03:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D9529600EF; Mon, 15 Mar 2021 14:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817033; bh=kS+ZPXV7JrwZH1yID6qLLiZfV2jBJJqvvHJx4T01hpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHRAwjtUaUmeh9p+jMqLy6V/pXJE7RpRMlQou0TWNK+krt+dDwZrXTUO1hLKGHZu/ Nff2iUuMV4n+WXMorvTTpVN/qTHLOcFW9N6bbHheYrsJQKGdhBTao9+RQeWIypAB91 jrJ4IlZO/MMynGXEmHykOygFp6l2t5OWZ+Iju9uc= 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.11 268/306] prctl: fix PR_SET_MM_AUXV kernel stack leak Date: Mon, 15 Mar 2021 14:55:31 +0100 Message-Id: <20210315135516.707577306@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 51f00fe20e4d..7cf21c947649 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2080,7 +2080,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