Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6224549ybi; Wed, 29 May 2019 04:54:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqww/CRSYaMf+fU5BD8Azwt96qtsg31A316vYX/jRTN9rwKHBM8rohljXI6CbiV1W3rmeBrm X-Received: by 2002:a63:1344:: with SMTP id 4mr135985727pgt.448.1559130848310; Wed, 29 May 2019 04:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559130848; cv=none; d=google.com; s=arc-20160816; b=vQL8+4YV/pfnoSNVGLeHmXFFgv7Xwj+lj2TOt19t5zJvTut0xRElVJXTe/OfS7qarj T/n/pLw3WmWYVnHBW+to2wj114Cj5O1JUTbt6KsN9hrwQvCSpkrKLMZe6LnrL/P71/Kc plJvM7uviXvGzOd09KZqqiibVr1KZ/nx08/RFeQRsBpmDK7l+CYp9dy7vNey5VQxuTTM dmwnYDofPRcfsp4fxlKRR4uoig9xIV20aRaU0ZUKSJGQMVGvvPgJ8Y4CGL3Nx9VPJz9h k84WGPO+OeLa1dKMsDo44TmuMlLFoiZopFJejlei/yt3rtcnNj+NEDzl0RBWuxyRfEna oUpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=TdAznkRxrKE17L8clQuRvpoCe6A9H8ATfOCcLEenWWI=; b=UVub+bR0QMwzOFP059ijEyTvcd+aRtxzvs/SP65SEyqs5psOlt+GQs8HlymtKIVEFO c+nqnfnwOX58LCcDbDXzV2Fa8v1Tu6G/lp6pxZMGoN+OY5MYHv1GSa3xqgSx77TJ+0sO XqHHdpNjmL6wV4+JwnKoZM47fIGgnJyqvHt2wRuPk9ak4y1wiMN744XZaP8GRb05ZAJm wD8qyV7LFvdW3QUgysUR9Fh3wi7CbOrEh9b3En+hu+bI/McQOtJTTCEDzw9+S1ZYQ5uP cGITU8R5sxftJDB4G3YcNP8YLc/M+V2KP1j3a8gZr1Pz5E/30Cx2GU/50AV/hU120LaJ qHBQ== 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 h96si6756422pjb.43.2019.05.29.04.53.51; Wed, 29 May 2019 04:54:08 -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 S1726986AbfE2LwU (ORCPT + 99 others); Wed, 29 May 2019 07:52:20 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:35274 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbfE2LwU (ORCPT ); Wed, 29 May 2019 07:52:20 -0400 Received: by mail-qk1-f196.google.com with SMTP id l128so1235315qke.2; Wed, 29 May 2019 04:52:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TdAznkRxrKE17L8clQuRvpoCe6A9H8ATfOCcLEenWWI=; b=s0778B/4PRJRV9CHP8Na6IFf77DRRrjYvnHi2Ijrigok937pUAnGjgZrBN0AJlbyQw ALs5JTxaeiWGsHVmFccnlIJca5vkxz9tVKMiv8aMDWkkjsmf1mFaYZDMe2OhGWE/H9NF 4A+PdgvfmUPMxgumo6xz3+rGQsM4OOhsYg5ox9Ua1r9ftcR3Si2Jn+rceTEZILu1KBRG 2pmR4YRHcGCdzmOGya6b0suS0e+hGVHP3PFngeaYW/HcwT+eXVKXZk9p/qHknpEI9R4u YNu/I+7Pme4clYwYpCiiujSoogHlaAwvbCMjivm+nc/285DrMguCE3ZVkIX2ykrIvVNN fNUA== X-Gm-Message-State: APjAAAWaXxHw2poBQLbjUXCnIHjGt565pHQ+68cmOKh1ypgY3oFItZvz r9Mo+XsQ5YuVp7tEG70xNclGdRUmS8gaIal1YwE= X-Received: by 2002:a37:bb85:: with SMTP id l127mr27927380qkf.285.1559130738893; Wed, 29 May 2019 04:52:18 -0700 (PDT) MIME-Version: 1.0 References: <20190524201817.16509-1-jannh@google.com> <20190525144304.e2b9475a18a1f78a964c5640@linux-foundation.org> In-Reply-To: From: Arnd Bergmann Date: Wed, 29 May 2019 13:52:02 +0200 Message-ID: Subject: Re: [PATCH] binfmt_flat: make load_flat_shared_library() work To: Greg Ungerer Cc: Jann Horn , Andrew Morton , Alexander Viro , linux-fsdevel , kernel list , Kees Cook , Nicolas Pitre , Geert Uytterhoeven , "Linux/m68k" , Russell King , Linux ARM 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 On Tue, May 28, 2019 at 12:56 PM Greg Ungerer wrote: > 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. > >> > >>> 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 > > >