Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753289AbaA3N1T (ORCPT ); Thu, 30 Jan 2014 08:27:19 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39582 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbaA3N1R (ORCPT ); Thu, 30 Jan 2014 08:27:17 -0500 Date: Thu, 30 Jan 2014 05:28:27 -0800 From: Greg Kroah-Hartman To: Petr Tesarik Cc: Arnd Bergmann , linux-kernel@vger.kernel.org Subject: Re: [PATCH] /dev/mem: handle out-of-bounds read/write Message-ID: <20140130132827.GA22557@kroah.com> References: <20140130094802.4ee29435@hananiah.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140130094802.4ee29435@hananiah.suse.cz> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 30, 2014 at 09:48:02AM +0100, Petr Tesarik wrote: > The loff_t type may be wider than phys_addr_t (e.g. on 32-bit systems). > Consequently, the file offset may be truncated in the assignment. > Currently, /dev/mem wraps around, which may cause applications to read > or write incorrect regions of memory by accident. Does that really happen? If so, that's a userspace bug, right? > Let's follow POSIX file semantics here and return 0 when reading from > and -EFBIG when writing to an offset that cannot be represented by a > phys_addr_t. > > Note that the conditional is optimized out by the compiler if loff_t > has the same size as phys_addr_t. > > Signed-off-by: Petr Tesarik > --- > drivers/char/mem.c | 6 ++++++ > 1 file changed, 6 insertions(+) What is going to break if we apply this patch? :) thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/