Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp350644ybz; Thu, 30 Apr 2020 23:31:40 -0700 (PDT) X-Google-Smtp-Source: APiQypI9dp3+hoyLavlptoMGzksv90wYXeU6n/xq0d8YEY0JrvzNHnLun5EkhebRdRx3Zxk8upIE X-Received: by 2002:aa7:d4c3:: with SMTP id t3mr2177649edr.191.1588314700496; Thu, 30 Apr 2020 23:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588314700; cv=none; d=google.com; s=arc-20160816; b=XGG8MJXncuL4SfjKWo1Z074gVqf3sx0DYP9xmozB0aWSapVKfDFZAnZcoVfvtS77qM uQNEh0UjJ6RNrdcrnSI7DW8vol+YUTjCoDKPGVAUASS+/aMyKrgiqsQb5cnBNqUzD56B JSdOV84wmlqla4mWYmh32PB361uuiLfvMrPH9msXkX7uuVLfFBnM6bXMjnhO+vphfVjd ki+Izilk/0FydRg9q406i7f19m+ECU/IBsAiaF5jLVCogd6SKmbZetI/agjvtShqklqs UvrX5bocq0VyyixYWoRiMRD+rJlg6+Zz2+agj9OElFCzrOuOUkMv0BxNrPmeP24vmLmm jfyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vG67a65I9+8dEUFdHhq4mJ1W9RxXwMfLX9q0cRFUNRc=; b=hQmydNjK7h6fJV81Dbyul+HhmhbdRCqg6EbSNNPQeAEPxhxl7vr8OfBkZoBv4sU+n2 hDUg4g2k882SUyCpuYYaPh7GHv5kXg2Ej7lb4JonZWRh7Bp7KijNHlwkVZjf7knhvvM2 v60Ttb2dST0d0jt1PpqkXfT5TXl/uqT/aBfUbGzU6hR/d/dUD19yZXeuaX8H1z1cLA7N 7wjGRlQwiKuYLffMiRyi1/q6XoyyCj7bLTzlYo77EszGyh1kiuNUobT9OOdmGd5fkrbx MVPaeDmldsW6egt1PBQqXnqJ51BbtzvJB1oL3/zKgtYKMw4QzvAcL0MYfgHQxFbMg7H4 nCPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si1080795edx.291.2020.04.30.23.31.17; Thu, 30 Apr 2020 23:31:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728323AbgEAGan (ORCPT + 99 others); Fri, 1 May 2020 02:30:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54904 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728126AbgEAGan (ORCPT ); Fri, 1 May 2020 02:30:43 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04161BFF129427; Fri, 1 May 2020 02:30:37 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 30r825gvep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 May 2020 02:30:37 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0416Ax6r030098; Fri, 1 May 2020 06:30:36 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 30mcu5v507-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 May 2020 06:30:35 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0416UXxh52756920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 May 2020 06:30:33 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E3E0A405F; Fri, 1 May 2020 06:30:33 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6462CA4060; Fri, 1 May 2020 06:30:31 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.81.13]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 May 2020 06:30:31 +0000 (GMT) From: Ritesh Harjani To: linux-ext4@vger.kernel.org Cc: "Paul E . McKenney" , linux-fsdevel@vger.kernel.org, Jan Kara , tytso@mit.edu, "Aneesh Kumar K . V" , Ritesh Harjani Subject: [RFC 12/20] ext4: mballoc: Fix possible NULL ptr dereference from mb_cmp_bitmaps() Date: Fri, 1 May 2020 11:59:54 +0530 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-05-01_01:2020-04-30,2020-05-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=890 spamscore=0 impostorscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=1 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005010040 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Make sure to check for e4b->bd_info->bb_bitmap == NULL, in mb_cmp_bitmaps() and return if NULL, to avoid possible NULL ptr dereference. Similar to how we do this in other ifdef DOUBLE_CHECK functions. Signed-off-by: Ritesh Harjani --- fs/ext4/mballoc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 5e59c18c89c0..e32f3675f962 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -522,6 +522,8 @@ static void mb_mark_used_double(struct ext4_buddy *e4b, int first, int count) static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap) { + if (unlikely(e4b->bd_info->bb_bitmap == NULL)) + return; if (memcmp(e4b->bd_info->bb_bitmap, bitmap, e4b->bd_sb->s_blocksize)) { unsigned char *b1, *b2; int i; -- 2.21.0