Received: by 10.213.65.68 with SMTP id h4csp686774imn; Fri, 6 Apr 2018 07:18:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/4m2quuh593+2bT9WIx/nhNj+/uay5A5IQA8oidBhY1odin+8dhacxeY21sSjuX1xVbLLx X-Received: by 10.98.107.138 with SMTP id g132mr20351865pfc.163.1523024325216; Fri, 06 Apr 2018 07:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024325; cv=none; d=google.com; s=arc-20160816; b=Gdja2Oh4aZjys3BC6f5zVT6cK/Khh0FGGV9ap9b54qq1AZOsV1aQV3sOgW/E6WIdux EcAd1IMV/DtIwgJHOE7iJDK1bZuTtMc8bk+4r82pebp11DGniyfDenvWheSqRQ9M7VqG PBsLXkhf1QrICok8kdAtPzn4U0fZbUAmCyFnGunT8b+IrcZXTF4medzlWzAKUSrvQC7Z flZ+xgQZHJtHW17jPOws6RPIzXzcjrfOvPZqZonRSpwkKgy4nF/cKrtMpqHcbcKYI8KN JcrfwjXPbEoYfO9dsmBaozFrUwYapartOCPcwoVPQnWuh6dthgt1d4xN58pRMJnUdoBt NwxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Bcu74ZH/oLIye/HRxcXyo+yvnTbUHb2l7UQYe5fUjDo=; b=vcWLBJWoEU9DLaHKU+YnCXoInwC2pVHr/ME1KCTm1kh347bfapRXHBSncyMGe6yi1D B1Q3QgvIkyjiKsDqjg6PwAAGuB7ZIjrkZXTeT8k3xO0cIRRCO0YKd3mu7Ym+cwyKu+bf Q6KusyetpvXrUlXyKOQjVLM7U7N/zEn3RPuTikSPZ17qsbe/gxqGx0IQAnQPhVn9yTgu LdDLPjD7gzmKwL60YUtxmwLCyoxs/2aHoRXxhy08jbIy8qA4tozDfiG26YRe+IAX0mGi 3YN/Rfn5OXPexGoSBnkV/8BklFHEGT46D0mW4FFbVfqgc+Of+YXkbGdQGVZS9Q7ot80/ DNXA== ARC-Authentication-Results: i=1; mx.google.com; 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 x8-v6si7876644plv.420.2018.04.06.07.18.31; Fri, 06 Apr 2018 07:18:45 -0700 (PDT) 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; 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 S1756577AbeDFOR3 (ORCPT + 99 others); Fri, 6 Apr 2018 10:17:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34206 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932541AbeDFNjI (ORCPT ); Fri, 6 Apr 2018 09:39:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6461FD17; Fri, 6 Apr 2018 13:39:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brad Spengler , Kees Cook Subject: [PATCH 4.14 43/67] /dev/mem: Avoid overwriting "err" in read_mem() Date: Fri, 6 Apr 2018 15:24:13 +0200 Message-Id: <20180406084347.133202378@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit b5b38200ebe54879a7264cb6f33821f61c586a7e upstream. Successes in probe_kernel_read() would mask failures in copy_to_user() during read_mem(). Reported-by: Brad Spengler Fixes: 22ec1a2aea73 ("/dev/mem: Add bounce buffer for copy-out") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- drivers/char/mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -137,7 +137,7 @@ static ssize_t read_mem(struct file *fil while (count > 0) { unsigned long remaining; - int allowed; + int allowed, probe; sz = size_inside_page(p, count); @@ -160,9 +160,9 @@ static ssize_t read_mem(struct file *fil if (!ptr) goto failed; - err = probe_kernel_read(bounce, ptr, sz); + probe = probe_kernel_read(bounce, ptr, sz); unxlate_dev_mem_ptr(p, ptr); - if (err) + if (probe) goto failed; remaining = copy_to_user(buf, bounce, sz);