Received: by 10.223.176.5 with SMTP id f5csp683648wra; Fri, 9 Feb 2018 05:39:11 -0800 (PST) X-Google-Smtp-Source: AH8x227daFxEuyaeub9jbupvWpNCsUpOHD9z1LQC/531kcEK26Y3tXNkACgimN/x8t209YSjZqNT X-Received: by 10.101.64.204 with SMTP id u12mr2445374pgp.280.1518183551675; Fri, 09 Feb 2018 05:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518183551; cv=none; d=google.com; s=arc-20160816; b=G3bh9r6TTl9MPXiJZJhew9IVrpDwvifUCxdOd6rlE0yn6dpqKox5D2BhAi+8xNCrpu ZG7JGbLl2ebzPYG1MfXsiBrjsDf2qBU9C18HV8L9NYdvZYSDSqomYE4TEtqreWhFIHcD o+Elum2DrGCY7G5Y01tQnRrrjhWp5f8O2iHvsXVNmlPZ8lpn/bG4F4peXau2144TPVWz 0Er6jjoigNDcRDcBqK3nIgJS0t8mqoKV+0xB/ua7YKyrKQ4ZVcy0F9fgbLz7de5m26Oc hgmMdfNJAqCdjj1GYRp9E7yAX3x+bF+9uL3ytnIPlt9CJIuH2HnpqcbCQ6djeUebv/BG Diyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :user-agent:in-reply-to:references:subject:cc:to:from:message-id :date:arc-authentication-results; bh=gO0tbz129CdbdXTv5ulTTCUE2oZ48hUKFB7z1qPQFPU=; b=VYqTVaj+XB5NICJevbRKiQ3gsN3wDqPgsZ4Hm627LSpPkz6oNcD3UsUs2vVZs5g1l7 bEH/FZvpvEFHgK+b8a6WQVi63aoWvWfy0Aouu8ITuh9NTDXilBUoEy3lZfiE0SGEEJmA MHeknmQyi4mIsVtAXtcrgdpStE4WVFZG20bjF1vntO9R3qMnb9R0YKpWTU7ul8pXvdet 10V/fJdx2x/70Ty9qtOqsj0Oz+11ts2QNsEDbjVd2jz+AbH8e8VgQ+qlsiyct8nYL/2J qNzNgKu6DCLcGXStRJ9Ym0dSQE5F+JPOJE2jWY04+7+wI+QyicaKChwL02GQN9b8oxFK 0Q2Q== 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 o61-v6si1567845pld.259.2018.02.09.05.38.57; Fri, 09 Feb 2018 05:39:11 -0800 (PST) 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 S1751107AbeBINgv (ORCPT + 99 others); Fri, 9 Feb 2018 08:36:51 -0500 Received: from gateway24.websitewelcome.com ([192.185.50.66]:23644 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751004AbeBINgu (ORCPT ); Fri, 9 Feb 2018 08:36:50 -0500 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway24.websitewelcome.com (Postfix) with ESMTP id D513CC2C6 for ; Fri, 9 Feb 2018 07:36:49 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id k8rBeiLrFcGlpk8rBei24f; Fri, 09 Feb 2018 07:36:49 -0600 Received: from gator4166.hostgator.com ([108.167.133.22]:28610) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ek8rB-000SNI-Fm; Fri, 09 Feb 2018 07:36:49 -0600 Received: from 189.175.4.238 ([189.175.4.238]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Fri, 09 Feb 2018 07:36:49 -0600 Date: Fri, 09 Feb 2018 07:36:49 -0600 Message-ID: <20180209073649.Horde.OueGLKMtzpLyz4w36quXUca@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Leon Romanovsky Cc: "Gustavo A. R. Silva" , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] RDMA/nldev: Fix multiple potential NULL pointer dereferences References: <20180209063702.GA28685@embeddedgus> <20180209122549.GK2197@mtr-leonro.local> In-Reply-To: <20180209122549.GK2197@mtr-leonro.local> User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1ek8rB-000SNI-Fm X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:28610 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leon, Quoting Leon Romanovsky : > On Fri, Feb 09, 2018 at 12:37:02AM -0600, Gustavo A. R. Silva wrote: >> In case the message header and payload cannot be stored, function >> nlmsg_put returns null. >> >> Fix this by adding multiple sanity checks and avoid a potential >> null dereference on _nlh_ when calling nlmsg_end. >> >> Addresses-Coverity-ID: 1454215 ("Dereference null return value") >> Addresses-Coverity-ID: 1454223 ("Dereference null return value") >> Addresses-Coverity-ID: 1454224 ("Dereference null return value") >> Addresses-Coverity-ID: 1464669 ("Dereference null return value") >> Addresses-Coverity-ID: 1464670 ("Dereference null return value") >> Addresses-Coverity-ID: 1464672 ("Dereference null return value") >> Fixes: e5c9469efcb1 ("RDMA/netlink: Add nldev device doit implementation") >> Fixes: c3f66f7b0052 ("RDMA/netlink: Implement nldev port doit callback") >> Fixes: 7d02f605f0dc ("RDMA/netlink: Add nldev port dumpit implementation") >> Fixes: b5fa635aab8f ("RDMA/nldev: Provide detailed QP information") >> Fixes: bf3c5a93c523 ("RDMA/nldev: Provide global resource utilization") >> Signed-off-by: Gustavo A. R. Silva >> --- >> drivers/infiniband/core/nldev.c | 26 +++++++++++++++++++++++++- >> 1 file changed, 25 insertions(+), 1 deletion(-) >> > > It will be much better to fix the tool instead of fixing ghost case. > This scenario is impossible for all those flows. > We can receive the skv/msg in two ways: > * First by allocating new message with NLMSG_DEFAULT_SIZE, which > has more room > than nlmsg_total_size(payload), payload is 0. > * Second by getting from netlink.c and it will be at least "struct > nlmsghdr" too. > > Can you please add this info to the commit message? > Actually, I was planing to send a new version of this patch. This time using the unlikely macro for all the null checks on nlh. What do you think? Thanks -- Gustavo