Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp769174ybc; Sat, 16 Nov 2019 08:21:58 -0800 (PST) X-Google-Smtp-Source: APXvYqy0FmcGNwGWqwFNm49jqWkuZNjIwsjQRV/4zyPGXuDH5WTg4k3UYvQKC9Ca30F7KbSykYkd X-Received: by 2002:a17:906:b6cb:: with SMTP id ec11mr10912129ejb.145.1573921318186; Sat, 16 Nov 2019 08:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921318; cv=none; d=google.com; s=arc-20160816; b=bIRzMNBZA4QoiJvcSzNltU/ZY4Wre27HcrI656pTH0uu38SMutlGAckJNctA5OAb/9 LutpvEJEGicxtZ8jCuHp2kwIbz/AsZYCtAsaLK26hnUgX4/QO1yNNupux33qxUKMnxqi ywkelj2wm1+aKW2As/Faia2KMvfP/Q6umm0/SRzpJgz8GqpmBev941xlcHB9EBkLgkYY zakj4yoEgr/RfttSzr+Tu4s1fpfkcMuygi/NOZdRUKPVFhZMIYNl7eqh0XQO65A0mPW+ Ugo0rOWYG3bvpVVKS1yrcucqBmzXkPaWnfO+ZhEx8vgy/e5wEuh19mTp71yQ46DTRJmt 7iMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZX7DH2eyz6XMl/bHmBU/CVqQgFvf8MuExHYvMZBdntk=; b=IClniVkEv5eW3tuDWRIn/g3wII4cJWGfez5bmE7ATGS75Z7JGJ5N/+cKvuJa5bJKRB HOVmql1+nBK9gHNFQR0x+h/NadM/6ZqmQwznboINn+BAHB7CVIGPWkuywwPu46WnLHeF azucUenrU5J2BMus1zyvgkiaJK15T78wqcupuCuh5KaiREBPvT0blEONeOYjaCgS89y8 JZBWSOz/tzbHsik45rzZRZMF82cqx7ds8VaRjtDWiQxZIDCjKdZHbP3pbt3FYaPIuywQ h1Mlk9I6ePQqVthf4WO0j0bYF9LJw2TAmZlo30x2mr+uG4gkqhq3yA33AwYrTLK1VLA2 +5/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T/vSchYI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id t24si6064192edy.179.2019.11.16.08.21.33; Sat, 16 Nov 2019 08:21:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T/vSchYI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731983AbfKPQRJ (ORCPT + 99 others); Sat, 16 Nov 2019 11:17:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:53476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbfKPPqv (ORCPT ); Sat, 16 Nov 2019 10:46:51 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 23D8E2089D; Sat, 16 Nov 2019 15:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919211; bh=ec5cu6iX0BJxkuAKCLot3vx4SnlxHWGsD52ZwXxIf8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/vSchYIi3GaaNAi4zA18NctxMfDkkizyAd1mIl40jvd3acPbPwAR/179GmGtiQ2e bFYqXOHKpV4EA6s76D7h2N8xExluRTDnY2RKvu8PdEEnejLdzE1FZL/Z+cCPXmdK/R 6oLXayuVqna8Vk+Aw6rbXcicWs9c6wUl53fFIxeY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tycho Andersen , David Teigland , Sasha Levin , cluster-devel@redhat.com Subject: [PATCH AUTOSEL 4.19 217/237] dlm: don't leak kernel pointer to userspace Date: Sat, 16 Nov 2019 10:40:52 -0500 Message-Id: <20191116154113.7417-217-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tycho Andersen [ Upstream commit 9de30f3f7f4d31037cfbb7c787e1089c1944b3a7 ] In copy_result_to_user(), we first create a struct dlm_lock_result, which contains a struct dlm_lksb, the last member of which is a pointer to the lvb. Unfortunately, we copy the entire struct dlm_lksb to the result struct, which is then copied to userspace at the end of the function, leaking the contents of sb_lvbptr, which is a valid kernel pointer in some cases (indeed, later in the same function the data it points to is copied to userspace). It is an error to leak kernel pointers to userspace, as it undermines KASLR protections (see e.g. 65eea8edc31 ("floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl") for another example of this). Signed-off-by: Tycho Andersen Signed-off-by: David Teigland Signed-off-by: Sasha Levin --- fs/dlm/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 2a669390cd7f6..13f29409600bb 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c @@ -702,7 +702,7 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat, result.version[0] = DLM_DEVICE_VERSION_MAJOR; result.version[1] = DLM_DEVICE_VERSION_MINOR; result.version[2] = DLM_DEVICE_VERSION_PATCH; - memcpy(&result.lksb, &ua->lksb, sizeof(struct dlm_lksb)); + memcpy(&result.lksb, &ua->lksb, offsetof(struct dlm_lksb, sb_lvbptr)); result.user_lksb = ua->user_lksb; /* FIXME: dlm1 provides for the user's bastparam/addr to not be updated -- 2.20.1