Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5999119ybe; Tue, 10 Sep 2019 11:58:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU8eTO0iUFYFCKRzchyskSlQrFP/H8+rfIrB39twR2lsTptH7BcgR7DOJ2H4kZgg0Zqhv4 X-Received: by 2002:a50:e886:: with SMTP id f6mr31130452edn.199.1568141886715; Tue, 10 Sep 2019 11:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141886; cv=none; d=google.com; s=arc-20160816; b=AAVcLrNsQFutBItxXg/z4uqmfwJBDwqnAQquRolEyFCUyGs9T9i32oumPASZEezDJI kJh3UXyOQUKe0nOfRT44vzm8+44Ik8I7bD1xz07U2LkLFxMoTRvuS5fMVF6vAs+146OJ tU64Ood4iD+Unc1ykjz1loO2rPAQF3ltKMbNSuC/hG+NsuY8KOrU2NO2g1/wWB4tCeAi ifn5Ksfu+odeiZqGhhlmrhkXeiCrqIj0DlWrITNbwT0djZ2Wx3EPsey1bjz2x45SqWa0 RTiTDeHMKD8A5scd9l17D298CBEPc14gi2Ylgd2HH+ftZeFKSwpUlQuATkbIuZWEX+XK wymg== 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=QpMAY9ONaGKm8ZqGW7XPKDAQ0Xa2PZRgz0esUf5h7Ow=; b=jipq0VDwgmDf8UYWjSA8A4Brqdk26wxskk1d3tArW/mVUaOTgOhUJxsOaEcgzJiJ3R 84UtohYM8N5rYekKbt4U8NiGg6j/qJ/lJJo5QA1JbukVFyWC7aWaTXowhChjHQ2mmAUP uLyibPtZGPNx5PDKVhlCP9DrlxmSfZn+n9keX6JG/m67AeyG4K8IqTV2hfXe1+ed4ucH pLtN9a7X1+ykRoRSYdtk+AKVKebMQmE0iNjiUGnj2Z4IY9rY2pIJIzM0HtHu/N/msUv2 OTpKXHcccGVEMp/c4dhQoHBIEk89ZwDtJXLkCsr2+jbyC9cXgBIVRQKHmKLSHVh0bQlP aYVg== 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 p32si12548233edc.259.2019.09.10.11.57.42; Tue, 10 Sep 2019 11:58:06 -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 S1730924AbfIJLfX (ORCPT + 99 others); Tue, 10 Sep 2019 07:35:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:52258 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726716AbfIJLfX (ORCPT ); Tue, 10 Sep 2019 07:35:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D3D19B6C1; Tue, 10 Sep 2019 11:35:21 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 133D9E03B1; Tue, 10 Sep 2019 13:35:21 +0200 (CEST) Date: Tue, 10 Sep 2019 13:35:21 +0200 From: Michal Kubecek To: Navid Emamdoost Cc: josef@toxicpanda.com, kjlu@umn.edu, smccaman@umn.edu, secalert@redhat.com, emamd001@umn.edu, Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] nbd_genl_status: null check for nla_nest_start Message-ID: <20190910113521.GA9895@unicorn.suse.cz> References: <20190729130912.7imtg3hfnvb4lt2y@MacBook-Pro-91.local> <20190729164226.22632-1-navid.emamdoost@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190729164226.22632-1-navid.emamdoost@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Just stumbled upon this patch when link to it came with a CVE bug report.) On Mon, Jul 29, 2019 at 11:42:26AM -0500, Navid Emamdoost wrote: > nla_nest_start may fail and return NULL. The check is inserted, and > errno is selected based on other call sites within the same source code. > Update: removed extra new line. > > Signed-off-by: Navid Emamdoost > Reviewed-by: Bob Liu > --- > drivers/block/nbd.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 9bcde2325893..2410812d1e82 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -2149,6 +2149,11 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info) > } > > dev_list = nla_nest_start_noflag(reply, NBD_ATTR_DEVICE_LIST); > + if (!dev_list) { > + ret = -EMSGSIZE; > + goto out; > + } > + > if (index == -1) { > ret = idr_for_each(&nbd_index_idr, &status_cb, reply); > if (ret) { You should also call nlmsg_free(reply) when you bail out so that you don't introduce a memory leak. Michal Kubecek