Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FFCBC3A589 for ; Sun, 18 Aug 2019 05:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ED8A21019 for ; Sun, 18 Aug 2019 05:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566105010; bh=XUbvz7tHOslGxtVncw5sWbbUdpLdoKiZ+61HV2wWJHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=vibMky92llc4PBv0dgl9LKEN36xSbCm/VTuXWmVlBsZ2llmhtIKZDAIW+CfKimDdT lpBWAoWZCsmQDUALTCca/YIC7cq2Z3nCqGMHe7Lf70hh1vKzxZ3BRJmTrx14qBKpEn OZ0lato4OuBZXiEn4Ry38xgZrkgyhF6DVrApu+Mg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbfHRFKJ (ORCPT ); Sun, 18 Aug 2019 01:10:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:39150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725209AbfHRFKJ (ORCPT ); Sun, 18 Aug 2019 01:10:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE2592086C; Sun, 18 Aug 2019 05:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566105008; bh=XUbvz7tHOslGxtVncw5sWbbUdpLdoKiZ+61HV2wWJHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tfeJxI14kulZlOhW1aUlX4QgyYewT3g4BnZrNGcz7T4pwnaq2gBtzzmnX+V3qSQkX 8O7LUxlEgYxIZAJMz9dFxLcygsUlg8TGvc02hCO3DMgJ3+vLdJl/2XaaJCJIxilq60 bq9hQlwJJspl1TYwEWWiJxz5duephOUrW+tQlDJ8= Date: Sun, 18 Aug 2019 07:10:05 +0200 From: Greg KH To: Ron Enfield Cc: viro@zeniv.linux.org.uk, stable@vger.kernel.org Subject: Re: [PATCH] fs: buffer: Check to avoid NULL pointer dereference of returned buffer_head for a private page Message-ID: <20190818051005.GB5519@kroah.com> References: <1565795351-10543-1-git-send-email-rhmcruiser@gmail.com> <20190814160259.GA11018@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Sun, Aug 18, 2019 at 02:27:29PM +1000, Ron Enfield wrote: > On Thu, Aug 15, 2019 at 2:03 AM Greg KH wrote: > > > > On Thu, Aug 15, 2019 at 01:09:11AM +1000, Monthero Ronald wrote: > > > The patch checks for this condition of NULL pointer for the buffer_head returned from page_buffers() > > > and also a check placed within the list traversal loop for next buffer_head structs. > > > > > > crash scenario: > > > The buffer_head returned from page_buffers() is not checked in block_invalidatepage_range function. > > > The struct buffer_head* pointer returned by page_buffers(page) was 0x0, although this page had its > > > private flag PG_private bit set and was expected to have buffer_head structs attached.The NULL pointer > > > buffer_head was dereferenced in block_invalidatepage_range function at bh->b_size, where bh returned by > > > page_buffers(page) was 0x0. > > > > > > The stack frames were truncate_inode_page() => do_invalidatepage_range() => xfs_vm_invalidatepage() => > > > [exception RIP: block_invalidatepage_range+132] > > > > > > The inode for truncate in this case was valid and had proper inode.i_state = 0x20 - FREEING and had > > > a valid mapped address space to xfs. And the struct page in context of block_invalidatepage_range() > > > had its page flag PG_private set but the page.private was 0x0. So page_buffers(page) returned 0x0 > > > and hence the crash. > > > This patch performs NULL pointer check for returned buffer_head. Applies to 3.16 and later kernels. > > > > > > Signed-off-by: Monthero Ronald > > > --- > > > fs/buffer.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > > > This is not the correct way to submit patches for inclusion in the > > stable kernel tree. Please read: > > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > > for how to do this properly. > > > > > > Hi Greg, > Thanks for feedback . Sorry I might have missed some steps. I am > checking through the patch list requirements. > I know there could be a couple of issue but if you or Viro to please clarify. > > Please clarify. > - I believe I should only email the maintainer of fs and not email the > list stable@vger.kernel.org at this stage of submission. Correct. > ( I ran the get-maintainer.pl script it showed Viro as maintainer > for fs/buffer.c , apology if not ) > - The patch is around 47 lines including the comments, I assume thats okay. > ( I have not included the crashed bt, page, buffer_head and inode > details just to keep it short ) > > - The crash occurred on 3.16 kernel but the buffer.c: > block_invalidatepage_range( ) code path in later kernels of 4.xx are > also same as this. > So it may apply to later kernels too. Please let me know if this > is not the right way to do it. You need to test the patch on the latest kernel release. 3.16 is many many years old. Also, use the mailing lists that get_maintainer.pl said to use. thanks, greg k-h