From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Ungerer Subject: Re: [PATCH] binfmt_flat: make load_flat_shared_library() work Date: Tue, 28 May 2019 20:56:37 +1000 Message-ID: <6956cfe5-90d4-aad4-48e3-66b0ece91fed@linux-m68k.org> References: <20190524201817.16509-1-jannh@google.com> <20190525144304.e2b9475a18a1f78a964c5640@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Jann Horn , Andrew Morton Cc: Nicolas Pitre , linux-m68k@vger.kernel.org, Kees Cook , Arnd Bergmann , kernel list , Russell King , Geert Uytterhoeven , Alexander Viro , linux-fsdevel , linux-arm-kernel@lists.infradead.org List-Id: linux-m68k@vger.kernel.org On 27/5/19 11:38 pm, Jann Horn wrote: > On Sat, May 25, 2019 at 11:43 PM Andrew Morton > wrote: >> On Fri, 24 May 2019 22:18:17 +0200 Jann Horn wrote: >>> load_flat_shared_library() is broken: It only calls load_flat_file() if >>> prepare_binprm() returns zero, but prepare_binprm() returns the number of >>> bytes read - so this only happens if the file is empty. >> >> ouch. >> >>> Instead, call into load_flat_file() if the number of bytes read is >>> non-negative. (Even if the number of bytes is zero - in that case, >>> load_flat_file() will see nullbytes and return a nice -ENOEXEC.) >>> >>> In addition, remove the code related to bprm creds and stop using >>> prepare_binprm() - this code is loading a library, not a main executable, >>> and it only actually uses the members "buf", "file" and "filename" of the >>> linux_binprm struct. Instead, call kernel_read() directly. >>> >>> Cc: stable@vger.kernel.org >>> Fixes: 287980e49ffc ("remove lots of IS_ERR_VALUE abuses") >>> Signed-off-by: Jann Horn >>> --- >>> I only found the bug by looking at the code, I have not verified its >>> existence at runtime. >>> Also, this patch is compile-tested only. >>> It would be nice if someone who works with nommu Linux could have a >>> look at this patch. >> >> 287980e49ffc was three years ago! Has it really been broken for all >> that time? If so, it seems a good source of freed disk space... > > Maybe... but I didn't want to rip it out without having one of the > maintainers confirm that this really isn't likely to be used anymore. I have not used shared libraries on m68k non-mmu setups for a very long time. At least 10 years I would think. Regards Greg