Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6025747ybc; Wed, 27 Nov 2019 13:37:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxauNjWhw+538aJa0vutp8W6aKeTd8uCdyQjvv2qM+jfj3uRpaIqJsD6DnVqbM8POEdboPY X-Received: by 2002:a17:906:2505:: with SMTP id i5mr51905568ejb.18.1574890659650; Wed, 27 Nov 2019 13:37:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890659; cv=none; d=google.com; s=arc-20160816; b=EluoVNYCAg8c2AH2a3RAmqyD9xXcRvTb0QRqgivQ2LHYW1ceUZtxw6GmevNfpGxDDA QfkVnezivfs/7U+3hRA0w416/cASz1zxzBxS4WnEU7cOxfkVlV6yCVVHzL9ljFSZDVM1 VNoeBpE6YtnWp3puQllirkhyutzt89h+LtKbVfJY6MRIKhCdJaVZ8fasbnfh5mUd5MpP vbyrWMSJgEFfhAqAFgyYmEdaNnz/cOi5qyRbjZVKQQIeswkZ3K9GEdHHltCFyWpMotk3 q+TfJE7cpRZVDeF8RZLqfnQ2HOcyqTxaLIlUCPmvZRx2g7uwVlcA5yNVvcC4roZYpwy7 LWWA== 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=k3mDT/WhDi8eRKDGoKV8RnVHJiefRpM/YcO55yn6//M=; b=lcGkC2PMx9BADuQU73zl/8mlqwhni2s+nacJKUS4aljG38+8QJMBCOCkrVnR/HTAXc JWaxBiUtkmMFa/oXyhJdsm0875U0zKVfFn3V/OlaPVclUincGrJeZbAMwtfjKi00brQX RgHmeeBIl2naNLk3wa0oym+Ts5GEQmb4rLxEzTwfTUng0H2h0BSwpcqoix9iUJmD7qnO /NuC4X3xnIu7Uj3c37fW52/wK2o8w+haZ72x8mODa0Uihah+guCt0ryt7Ot7CmMXkjX4 tT7C8DGmAKWmgxFSxN1mIWignnXLx1OShRd7B5sk/1HjGbxRoHybbVcGlmGd6HcIY6dy 1+UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vdDcwJu/"; 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 x95si11506689ede.192.2019.11.27.13.37.16; Wed, 27 Nov 2019 13:37:39 -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="vdDcwJu/"; 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 S1730566AbfK0UwG (ORCPT + 99 others); Wed, 27 Nov 2019 15:52:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:39308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbfK0UwF (ORCPT ); Wed, 27 Nov 2019 15:52:05 -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 76B0F218AE; Wed, 27 Nov 2019 20:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887923; bh=XRbu216x41VlCbMrwQejgg8e7awRwMdwlAm6BBlFN/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vdDcwJu/4pp2p9N4o1QK7rEvnWtcGuXEcOUZkbtoPOup4QR32GHxDN9u1fSIThp6v Vl8DBQbzusB6Q2LmsRAyZ7HylI44fRkR7P2a7Lcx9eKY2nDqAeAMPHI5uoJwWdW/ml fI8HYWcl96BTOJUGVOCICQtre8wqZeLeFWi2mcy4= 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.14 148/211] dlm: dont leak kernel pointer to userspace Date: Wed, 27 Nov 2019 21:31:21 +0100 Message-Id: <20191127203108.000787142@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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 d18e7a539f116..1f0c071d4a861 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