Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9588455ybi; Wed, 24 Jul 2019 06:42:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyESb3H76mPVXnimkXIAh7ll6oeWQeMbkVs1KCAR7Jjawp6Z275k+gYt8RDgRRuVmyK/+gL X-Received: by 2002:a63:29c4:: with SMTP id p187mr29580502pgp.330.1563975751038; Wed, 24 Jul 2019 06:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563975751; cv=none; d=google.com; s=arc-20160816; b=w+1BMDWXpJUyEUuR3RFow9LuI4WZhQc+jlWaQaoTBV+O26uTj+MTGG1Q7FGXLG71U8 PobzqLsKOvGhnzgbHecN/GgoUqw4bayC5gAH9lJaCruoXvl/gCfPZvY+YiIwY+bca17O 77CJjL2Wee00RfzA5wGWgFq8NP6Hv50RpM8vRcLH+xS+fh5ynlOZlnlvp2fsyIx6ecQt hev2sspqpr9nkSynKpLR/x4GT5q2Ey/JS7Fidfk8u47yYtdZeUb4/hPlFjxY8b5ounEo F1uTiYOaiUHG6tdQTQov2Szd6OUEvrMCP9yNScctD3IXNfwtg8B4PgGuTUFt+enIUOq5 rGcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tRI1IniVegTQRYO4TGJQovKVRqtm90GRij/Ychi2bjs=; b=rDW8eVyBTC0Oqig3/9RJvwpowadcyXViGlGjdsKe6PN9CPt34PF56K3/RCiG/s5kLm j+j75Ywd2bmbt54a1a1lq7AZKX1Ok0lDxS9aJ/h+Ta66Lr45i/Otm2XDshBtswnWE08t AAjkg4Bw0uaeXdMfN5cj1pDOle47yCqIYJdfXqdHdwdnoN5nOu4jU43LTJxjvEZmdq37 qoe5C7J3y/X0SMcdrnWElA9HVOpmmrpGdPNZAclZwYXS7rGBPIpNijR8N+iVzivtO7QX ER5m48TKXzKXp+WxrlcuP3XPsFh0fohDbnc3jKlNXk7LjoEfN5FqoIDb+/pZFk9OWpYa 5TLA== 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 d2si14115925pgo.463.2019.07.24.06.42.16; Wed, 24 Jul 2019 06:42:31 -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 S2387418AbfGXM4C (ORCPT + 99 others); Wed, 24 Jul 2019 08:56:02 -0400 Received: from nautica.notk.org ([91.121.71.147]:51183 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbfGXM4C (ORCPT ); Wed, 24 Jul 2019 08:56:02 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 29525C009; Wed, 24 Jul 2019 14:56:00 +0200 (CEST) Date: Wed, 24 Jul 2019 14:55:45 +0200 From: Dominique Martinet To: Jia-Ju Bai Cc: ericvh@gmail.com, lucho@ionkov.net, davem@davemloft.net, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: 9p: Fix possible null-pointer dereferences in p9_cm_event_handler() Message-ID: <20190724125545.GA12982@nautica> References: <20190724103948.5834-1-baijiaju1990@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190724103948.5834-1-baijiaju1990@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jia-Ju Bai wrote on Wed, Jul 24, 2019: > In p9_cm_event_handler(), there is an if statement on 260 to check > whether rdma is NULL, which indicates that rdma can be NULL. > If so, using rdma->xxx may cause a possible null-pointer dereference. The final dereference (complete(&rdma->cm_done) line 285) has been here from the start, so we would have seen crashes by now if rdma could be null at this point. Let's do it the other way around and remove the useless "if (rdma)" that has been here from day 1 instead ; I basically did the same with c->status a few months ago (from a coverity report)... That said, please note that 'rdma checked for null in this event->event == RDMA_CM_EVENT_DISCONNECTED branch' does not mean rdma can be null in other branches. static analysis does not say anything more than the final complete() should also have a check if the previous one has, but nothing about the other cases in the switch. Thanks, -- Dominique