Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527294pxf; Mon, 15 Mar 2021 11:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9etxjSyVNjbDwIAciFPrtOsszJgT6rlJZh0ggFGIgIvcpU9YWUPNVGRgcFMFpYtHS7JIG X-Received: by 2002:a17:906:c301:: with SMTP id s1mr24714661ejz.382.1615833149626; Mon, 15 Mar 2021 11:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833149; cv=none; d=google.com; s=arc-20160816; b=Z18di5ieE2M8gImStgG9+RCu3UuYd7awcQ8pmFuVzq0CY1ZFT/twSbY2v7ApRQIKu9 x6B5JZbQ90l45oIkeQNF3lAHPXn35RQBr3pUM9Ewzsc56D6JGq+RRGNqJ+Zo0IXy3yz+ X7neg2FA2bMBSXCUOZNj88kQF/xzGxNv8iewO+3cvwAQgMPmFhnB9t7+2KUWev7t19P8 CqzWE9f0r0WpqwXXPDf1afzPIf4o2IU5aAtdps+C/cUUtBEJue7D3qbQpSZEOz/mfn+9 Yk1XlrgXXcel6rzHxjWZnDMhaGLXmAf4RZd1MUJz8Y7e8tg+1GnKaTAKkmg0Hd/MCiRN Gtdw== 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=87N8eAzicWi6mAnMR51zGe3mJOM0JqXAP81yGGWcpD0=; b=YA9hOt9Axs1z4aNHisIu0JdGZ+7+BYybuHKBMjrIdHpVQDt2sK1D4kWeJE71tqUn+U Y0hjbgOg+iG2+qyRWCEzpNRlDBdhkSUuAg8UDaMJA9D7F3LLeOErcj6G66cpQ+Lfo4i1 ZLP/dJPFdosjnCboI1fJQkTfDEpxcUTiIoHCfdipJvYlo3KP+pKG30v7/HH8NKqiCeMY hwyXYIyeZ3HclaqMe4fhPiJCQziBxh0hBto3ZNcrQKoMzcduTvmZa/E+YCly8AIFhty5 mNRtSviayUW2cEzt/5huPK0ZmzXea+uUmI6tN0s9VUXrHifSPb5YtXAj2Ll8OEqY7o32 qKeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f+P9FMmp; 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 u13si11224873ejc.243.2021.03.15.11.32.07; Mon, 15 Mar 2021 11:32:29 -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=f+P9FMmp; 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 S240426AbhCOOhy (ORCPT + 99 others); Mon, 15 Mar 2021 10:37:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233350AbhCOOBd (ORCPT ); Mon, 15 Mar 2021 10:01:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3A3864F67; Mon, 15 Mar 2021 14:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816857; bh=e+PstZxFdW5nYgvCJHxlsyd8l+rVQZb8n4xo+V9tIK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+P9FMmpforqSYIgD0+Yz8Mo6aAj7vz4i5MWhN3OlOKpO4020tkXk1OBLVZP5Dfp1 pbhZEjoeP4kQRx0ewdJ18Qkui+6dKQMoTqySmkwQZzGVa7mMjrW7+qkQrbvEYIlubB iZZ0ZHvaIzVQrwjHIcSNpAaWJU9N9+vY0XO/74y8= 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.4 155/168] prctl: fix PR_SET_MM_AUXV kernel stack leak Date: Mon, 15 Mar 2021 14:56:27 +0100 Message-Id: <20210315135555.442241250@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 3459a5ce0da0..867ec3e003fd 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2062,7 +2062,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