From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ie0-f179.google.com (mail-ie0-f179.google.com [209.85.223.179]) by kanga.kvack.org (Postfix) with ESMTP id 048346B0032 for ; Tue, 13 Jan 2015 19:11:48 -0500 (EST) Received: by mail-ie0-f179.google.com with SMTP id rp18so5994893iec.10 for ; Tue, 13 Jan 2015 16:11:47 -0800 (PST) Received: from vapor.isi.edu (vapor.isi.edu. [128.9.64.64]) by mx.google.com with ESMTPS id d17si612792ics.13.2015.01.13.16.11.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 16:11:46 -0800 (PST) Date: Tue, 13 Jan 2015 16:10:57 -0800 From: Craig Milo Rogers Subject: Re: [PATCH 0/5] kstrdup optimization Message-ID: <20150114001057.GA30408@isi.edu> References: <1421054323-14430-1-git-send-email-a.hajda@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andrzej Hajda Cc: Geert Uytterhoeven , Linux MM , Marek Szyprowski , Kyungmin Park , "linux-kernel@vger.kernel.org" , Andi Kleen , Andreas Mohr , Mike Turquette , Alexander Viro , Andrew Morton > As kfree_const() has the exact same signature as kfree(), the risk of > accidentally passing pointers returned from kstrdup_const() to kfree() seems > high, which may lead to memory corruption if the pointer doesn't point to > allocated memory. ... >> To verify if the source is in .rodata function checks if the address is between >> sentinels __start_rodata, __end_rodata. I guess it should work with all >> architectures. kfree() could also check if the region being freed is in .rodata, and ignore the call; kfree_const() would not be needed. If making this check all the time leads to a significant decrease in performance (numbers needed here), another option is to keep kfree_const() but add a check to kfree(), when compiled for debugging, that issues a suitable complaint if the region being freed is in .rodata. Craig Milo Rogers -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org