From patchwork Mon Apr 28 07:51:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 4075651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C010DBFF02 for ; Mon, 28 Apr 2014 07:54:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E39842028D for ; Mon, 28 Apr 2014 07:54:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC9A42026D for ; Mon, 28 Apr 2014 07:54:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WegMO-0005hB-Br; Mon, 28 Apr 2014 07:52:20 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WegMM-0005g8-F6 for linux-arm-kernel@lists.infradead.org; Mon, 28 Apr 2014 07:52:19 +0000 Received: from ptx.hi.pengutronix.de ([2001:6f8:1178:2:5054:ff:fec0:8e10] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1WegLt-0005uz-Dh; Mon, 28 Apr 2014 09:51:49 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1WegLt-0005ho-Q9; Mon, 28 Apr 2014 09:51:49 +0200 Date: Mon, 28 Apr 2014 09:51:49 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Rabin Vincent Subject: Re: [PATCH] ARM: fix string functions on !MMU Message-ID: <20140428075149.GB28564@pengutronix.de> References: <1398103808-24380-1-git-send-email-rabin@rab.in> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1398103808-24380-1-git-send-email-rabin@rab.in> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:6f8:1178:2:5054:ff:fec0:8e10 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140428_005218_917392_BC4BCA6D X-CRM114-Status: GOOD ( 16.95 ) X-Spam-Score: -0.7 (/) Cc: Will Deacon , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Rabin, On Mon, Apr 21, 2014 at 08:10:08PM +0200, Rabin Vincent wrote: > 8c56cc8be5b38e ("ARM: 7449/1: use generic strnlen_user and > strncpy_from_user functions") apparently broken those string operations > for !MMU. USER_DS == KERNEL_DS on !MMU, so user_addr_max() always > restricts the addresses to TASK_SIZE. > > TASK_SIZE has anyway no meaning on !MMU, so make user_addr_max() not > restrict anything. > > Signed-off-by: Rabin Vincent I tested this on my efm32 machine and it booted just fine. Before I used a patch that did: Regarding "TASK_SIZE has anyway no meaning on !MMU", there are a few more usages of TASK_SIZE for no-MMU (tested by removing its definition and compiling with my efm32 config, so I might have missed some usages): - mm/nommu.c uses TASK_SIZE in validate_mmap_request: /* Careful about overflows.. */ rlen = PAGE_ALIGN(len); if (!rlen || rlen > TASK_SIZE) return -ENOMEM; Maybe this should better be explicitly: if (!rlen || rlen > CONFIG_DRAM_SIZE) return -ENOMEM; ? - kernel/sys.c uses TASK_SIZE in prctl_set_mm used for prctl syscall with option=PR_SET_MM. Maybe here it would be nice to have TASK_SIZE == ~0UL? - fs/exec.c uses TASK_SIZE in setup_new_exec to assign current->mm->task_size. I didn't check if/how this is used. Best regards Uwe diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 02fa2558f662..f25c7f4c5a44 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -92,9 +92,12 @@ * It is difficult to define and perhaps will never meet the original meaning * of this define that was meant to. * Fortunately, there is no reference for this in noMMU mode, for now. + * + * HACK: copy_from_user must even handle copying from flash. So don't impose a + * limit at all. Not sure this is correct ... */ #ifndef TASK_SIZE -#define TASK_SIZE (CONFIG_DRAM_SIZE) +#define TASK_SIZE (~0UL) #endif #ifndef TASK_UNMAPPED_BASE