Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3688264ybb; Mon, 23 Mar 2020 05:59:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt4mU3ZOg9RYjrguWewZrs4XwUkD/NrrJhks06iSwvXx76X5fBKK0Peg/X83Qzxld+kgzw/ X-Received: by 2002:a9d:6186:: with SMTP id g6mr17418554otk.236.1584968352304; Mon, 23 Mar 2020 05:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584968352; cv=none; d=google.com; s=arc-20160816; b=xnMGKC/wPR4IOlpaqyKY2wkjdmVnJhM4lEfNaPccgYNq62KCXkPlwpkgGSSSdJgxdI P15luiQ9L6SgUPCRG/WWcg50GPq5SOSFNH1YLg3GEVnxNTHOnUwZ79BojfPUlRD6BfIB JM4nmba7piFHuOR8aECNRJxpwhQTNOYHvbvY2oBF4fftgnoo1kkLciPrrPruB5sr47NL IAMqN1j1PQx56txSpR19O1tRmT1ywvwtBpW1tJXUIyx98dpCuLqm9GviP9S6t/yo7LPo 7slISUibB53DFzbbA6MVVutFV2k/fnYnmkvSIjeRC4/9P05LOr4MwjORdGMBxmgjIyYC xiIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=aK3DeOPBkAJf49C7Fw8X52i7Vx073H/AsUP+vobEGEY=; b=0KEZWS8UwMhOSzXT/89jYoKj3zZI8U+fzeIo+ZB7hqE6SJ/fJwcloFlGDWGa+fMqgX oHATqsjWRWAmZJu1P3s5PX0dbBuvGTzfnTQ8TayfSIItTWKGqqTVjEvF04GYZioLxEhZ UlsEK1iDSn5BrCHoCaUJ2Jpurj/hKPkNRwKUdPrQKPhKDXiwhLhIWZkteRQ7ZIJWJyFo j+Oz9te8LyIciRSwiNhffssrRvfOftSn3gau7xbRVj/vuSdedlO1wmu766kK+9M1CPp5 WIm3RnnRnj906YU1fLDerSX0eFU+FfmDHY5hAZC0du9Tl4mrLf/+7R828UE8z+qNdA7W lH3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ly3490A7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si7527284otm.111.2020.03.23.05.58.57; Mon, 23 Mar 2020 05:59:12 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ly3490A7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728258AbgCWM5I (ORCPT + 99 others); Mon, 23 Mar 2020 08:57:08 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36389 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbgCWM5I (ORCPT ); Mon, 23 Mar 2020 08:57:08 -0400 Received: by mail-pf1-f194.google.com with SMTP id i13so7465296pfe.3 for ; Mon, 23 Mar 2020 05:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aK3DeOPBkAJf49C7Fw8X52i7Vx073H/AsUP+vobEGEY=; b=ly3490A72/2ieLkbBI5Mnz+tBc4A71HmZmowVGlOolfoe/jZD2H/R6mbyQWsQiUgTu kpZ4ZcWsciDi9I3YlrR0LKSqWW8Gv/mkNMUbu7PZW7D74qyZ8RVIstQhlfH+HptO6NL2 58F85Id8z1kFzPI9eLxKvVzNenX0rjcD4cPfzcNEmAl5dnrwc7oliFKxWPVmJQ+rw6aJ QdDETWJk+hHmmYkTfpb7yUgjIg+6p/2afiWL6Td8D2YI0TuVpHn0FNtsgcI/xXyqtR99 scEkPd+CM0ZeeeNon4UQFyZcGWDBGXAhkpVoPREqvbJhm0I6YqTCmNT8Rzep93Ry1eR6 K7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aK3DeOPBkAJf49C7Fw8X52i7Vx073H/AsUP+vobEGEY=; b=EDmEBK9OwDi/4dLugfhnUrT5Ku5y1rnGfcEmhC7BpKwCZ2asUb7/9UqNxYun9DRnUz cg2hkYazqIYvLzTErai95syQFKPRkD25Yjl+QBI6flaiBgKr0XD6S/91FshgxoG869tj 5Re6khK0Ya4AUHbX98MYdxMc6VkH+i8bHXzv7oDh5YTA6bR7iDaDmealLh9dMSljQaxN yxdODKqglo5tuDX4/lzfU87TjM+WkZIUSM31lLM7K0LKeh9goHCO+3LmpZZRE5mqFoIF 5PBjwyB4O+2R2WGvH6jInQXgxaqtxavfxVn3ySuF2/NQSnoIUyz4IIG0K4vx/7TNbbq+ 8IzA== X-Gm-Message-State: ANhLgQ15G4v8LECXc7TDT8xT4eqCXYv+ApZd5JSX/CPc+if5Kv6ij81E +MwQfokoArAjHCvfds+On+ZIxWZdLGGArw== X-Received: by 2002:a63:2cce:: with SMTP id s197mr22598743pgs.184.1584968226972; Mon, 23 Mar 2020 05:57:06 -0700 (PDT) Received: from localhost ([161.117.239.120]) by smtp.gmail.com with ESMTPSA id p7sm12922826pjp.1.2020.03.23.05.57.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 05:57:06 -0700 (PDT) From: Qiujun Huang To: tglx@linutronix.de, dan.carpenter@oracle.com, gregkh@linuxfoundation.org Cc: viro@zeniv.linux.org.uk, deepa.kernel@gmail.com, darrick.wong@oracle.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, anenbupt@gmail.com, Qiujun Huang Subject: [PATCH] minix: Fix NULL dereference in alloc_branch() Date: Mon, 23 Mar 2020 20:57:00 +0800 Message-Id: <20200323125700.7512-1-hqjagain@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Need to check the return value of sb_getblk. Reported-by: syzbot+4a88b2b9dc280f47baf4@syzkaller.appspotmail.com Signed-off-by: Qiujun Huang --- fs/minix/itree_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c index 043c3fdbc8e7..6edb0f11e8a0 100644 --- a/fs/minix/itree_common.c +++ b/fs/minix/itree_common.c @@ -85,6 +85,10 @@ static int alloc_branch(struct inode *inode, break; branch[n].key = cpu_to_block(nr); bh = sb_getblk(inode->i_sb, parent); + if (!bh) { + minix_free_block(inode, block_to_cpu(branch[n].key)); + break; + } lock_buffer(bh); memset(bh->b_data, 0, bh->b_size); branch[n].bh = bh; -- 2.17.1