Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11629088ybi; Thu, 25 Jul 2019 20:39:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0W8oJLJ2dlgNzGfBlXXb4u002mYi6qOd1cGRfK+/+iZYJfQ7xhwGgDaaucYR/rEmcgPYT X-Received: by 2002:a17:902:a413:: with SMTP id p19mr94809420plq.134.1564112347437; Thu, 25 Jul 2019 20:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564112347; cv=none; d=google.com; s=arc-20160816; b=tet5+spqD8WMUd0HfRkbmQUU9oej+CL8S99njpHQXw2QIanHRYHId3n8TtjRRNYNih 4H8XwAOq638D0yyt4a46A3QtFt5fpGtJ9jc0xhqjfakegb5LGc6zRUeM5mQcD7jadoBo aZL81tbxNnz0pDcBjhmoxIiuL92lyd8vr5Bx3orfw3MFmTxXujp/LXB2Hay7xDIpzwZP RePRzukgYWM1Lbvfhn1Oop+FCzbs2ja2bSSF8ug+uQHUQ0y7ZyhsYsGsySnasbyL/JXT fUxq7qJEQ1le7G5xb83AKbHXkdE2uL3L6sZU+oiREa3whVLn3mcPs7DPCI9b+yZhtSs6 SDAA== 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=MVFsNfeXzerLqMZOF/NXhnILFTns7YePBX6j9xJptms=; b=pYJOm8JTVu8L78L5ouhu/tU8cUywvH6RjRKQxv4VhgOWfbP2b/NfIGeVMG4QrZFBRQ dgKlrMcMXKz7KZBztpqb79uABdF0ef4M8RNEYLpEFbFiTqjqe95P4y4gOWMW4kdO9XOg vYvEkOp2VK3lpzTnRjLZ4vEeEJS+EZLYL76g3BZEpGki1bfPzXYdlwz7whmwwZ/yx6Ep NoocGjtGEoI7Kx1Ne0eLSuQGIlMheBtt/etYnqIEj/bhOixY+qm5+UAgXthXAJbPjLeY bNFr87yR8mWWXzjU8dxso5XAx71WXPY8ID0FUAcENeNi16iMDXcvhnOkq0FGRDzR9iVe mvYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="f/8noa7C"; 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 l1si17758210pgm.391.2019.07.25.20.38.51; Thu, 25 Jul 2019 20:39:07 -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="f/8noa7C"; 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 S1726216AbfGZDhY (ORCPT + 99 others); Thu, 25 Jul 2019 23:37:24 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38829 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfGZDhY (ORCPT ); Thu, 25 Jul 2019 23:37:24 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so23785512pfn.5 for ; Thu, 25 Jul 2019 20:37:23 -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=MVFsNfeXzerLqMZOF/NXhnILFTns7YePBX6j9xJptms=; b=f/8noa7Cj2VQKBganab1JYvwrmyua4Cf/vzhDrYyIXd5XHyCwhZlCwqhtqih+QvxUU zgn+x9WKhWck1N72TP0W/qSYFawiiOcMkckjARINwR8GfMYg9ZxXOpy99LtcYWs9o+/U pkdUyvGvhxh+VpuEofdrLfS2YC8kQfF/ubUROkOV7Kypc+xSvCiFKbqCFqt2hMs7LiGi qhkxYMIol/sZg3s8tC8Bbpc4lbowo1tNE8fsCVB0GXcWtj7BRot5d4lHLzj1Y+UMFJOd L97vxAfIKce9S5vj+IbECZMhSPiln0J2zfffrnYfSec/ERRI8Z9XmfDBr0yyoRYITif9 9Idw== 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=MVFsNfeXzerLqMZOF/NXhnILFTns7YePBX6j9xJptms=; b=E4DXotCCltDMBygAJoskZ8sA0aSEHpgqwfPOQ7ULcDK60hETiNWBvRhow4cN/0OIQR 0/WmM2v2ingK0glo+VoOuaWY9JyNeLwCyd4x+YLzfslVNVTGnmjVLn48/xBSIVACx+04 Q06GKSPR4/0Zp0EWKkQNBXUdSehP0+ah+2z2aVGqSi2aJxnK00n/GVS/ub1frnfBVDcK 5v+cOXmFqkUNfziCK7zMlzXXa31BkYHppHgmhRotiMYbTYJdy7+c3oavElM1NeirlZJd RYdZXUO6jwqDjDpET5WjwmA5Y3F7sb6JGF2nUQAJmlylrkLLjO9n4FeqB7Bi+nfiLjbY wpdA== X-Gm-Message-State: APjAAAXxGC9D6u3SpK4jO/cy3fcoVd2bw59gQ/yL7xjFcPSCnPJUDMge 0vFRSc5qMNhMmK2kWRHvA8M= X-Received: by 2002:aa7:8651:: with SMTP id a17mr19749665pfo.138.1564112243397; Thu, 25 Jul 2019 20:37:23 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id v63sm53036295pfv.174.2019.07.25.20.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 20:37:22 -0700 (PDT) From: Jia-Ju Bai To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 3/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() Date: Fri, 26 Jul 2019 11:37:17 +0800 Message-Id: <20190726033717.32359-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ocfs2_info_scan_inode_alloc(), there is an if statement on line 283 to check whether inode_alloc is NULL: if (inode_alloc) When inode_alloc is NULL, it is used on line 287: ocfs2_inode_lock(inode_alloc, &bh, 0); ocfs2_inode_lock_full_nested(inode, ...) struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); Thus, a possible null-pointer dereference may occur. To fix this bug, inode_alloc is checked on line 286. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- fs/ocfs2/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index d6f7b299eb23..efeea208fdeb 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -283,7 +283,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb, if (inode_alloc) inode_lock(inode_alloc); - if (o2info_coherent(&fi->ifi_req)) { + if (inode_alloc && o2info_coherent(&fi->ifi_req)) { status = ocfs2_inode_lock(inode_alloc, &bh, 0); if (status < 0) { mlog_errno(status); -- 2.17.0