Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5996256ybc; Wed, 27 Nov 2019 13:06:46 -0800 (PST) X-Google-Smtp-Source: APXvYqw98im3bsADHuKIkBcRXHoRIlarZ3ocxsoFuFXGuf2L0OKD4Eu6AYXwZ2qMnk8s+LuIOqIy X-Received: by 2002:a17:906:6c95:: with SMTP id s21mr52405212ejr.205.1574888806624; Wed, 27 Nov 2019 13:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888806; cv=none; d=google.com; s=arc-20160816; b=ATZZWEIflrdINd2XAY1vCGq8tY8BSbBB0F6d/CrxyPucxWy/R0wqVikIMYrBlPfNlw +FX6YLgbRkhHWXCrdKFmy34VG+0WjgPFwrKA2JBMeh/dQ1eNz/s3c8d9hyh4isuzD8TU pBvhfq3uXxza6+isPEUDhIr10ayU7MH/jlYEuKcDUoSMP8ZcIo3gVSSQvZfVbkpNyxdt x7So+JW9/ZxjbnGvM+KGaFgG0UZfrL8mm7/4xULV4O6e3eVVVOuD4Ngwj0uYUMS5TFvR 1RqaMkD+IQQtBioEUD/qpQMhVcoV6hWbrC4AphWbpn6hjVcnbHATs+dEFRmWqY6LuHfT YIkg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZX7DH2eyz6XMl/bHmBU/CVqQgFvf8MuExHYvMZBdntk=; b=Ra6QSNtQRtGoOlvPDIXI4PJ83g34s1LCqQhv3Fhl8NYLYC0wVTvH0WJwtQe4ucUKpS /WYmmrhQ+zpV0OqsWhHknO6nDvVuEgdX0/2dJPem2qHkYcrSQ0oeJiFrcT4IJAk+tWRv njFycdI2XVVWbOZozleKQ2pDqUBNv523aK1LuB05H1oQQXfLLyS3KoNuADiKBeOWGQJw aaiGynDYBb99J62JWnIZAO0IeOq95yFdP9HMK6PXWbTPPtJlVqDqUn0PGJHSCNMr8OIu C1qZZUTJaGExcHT5JOND6dIZwWyKQsAkRG1hpKJMZ+f42fJpfRLiqL2ARB3nxuRTeuNE jiTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UGgh9PcR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb26si12658476edb.106.2019.11.27.13.06.22; Wed, 27 Nov 2019 13:06:46 -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=UGgh9PcR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732266AbfK0VFQ (ORCPT + 99 others); Wed, 27 Nov 2019 16:05:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:58926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732257AbfK0VFO (ORCPT ); Wed, 27 Nov 2019 16:05:14 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EAC9E2080F; Wed, 27 Nov 2019 21:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888714; bh=ec5cu6iX0BJxkuAKCLot3vx4SnlxHWGsD52ZwXxIf8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UGgh9PcRGGRJDm0pxOW7+PL+L9oQ/lVGfLzSf8CGxBvMiyvjk3u+c4dUjDwB2IoXu +l0iEU+aeJ6DVXTbZfTF2KbCp/htDaa6t6dWHExwLiSMDKhFWJUR+2731uAgF4Q5iy c+xpCAf8PkI6uAnaAGibWvaUn5aunJmkeqsmmKQ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tycho Andersen , David Teigland , Sasha Levin Subject: [PATCH 4.19 234/306] dlm: dont leak kernel pointer to userspace Date: Wed, 27 Nov 2019 21:31:24 +0100 Message-Id: <20191127203132.097435325@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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