Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3877895ybg; Sun, 20 Oct 2019 23:43:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwY+uu5JCFIICMtAW8GWF45cbRicUAYlbUc7PiHlw/VymsWrJDosE0PMd8nO8iUkkh8FAR8 X-Received: by 2002:a17:906:154a:: with SMTP id c10mr19914445ejd.238.1571640186433; Sun, 20 Oct 2019 23:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571640186; cv=none; d=google.com; s=arc-20160816; b=WpdQpcX02XebszXdA08/qPxqHepgVEeID2FhFuMSgeN5Ehth2RCSIPrSkRy+3zFmjK eyPRFl+GYuJQ1M8MnIVJflhK7KcebvPPPIU8rfQBULxvqe7DxWim8hcuBa48I1umWUjl 5Q+7Fz+OFkTJO/5GXtgQk8vqHU6c5suWYxo5EBIdixzvJGW1kEOe6WnJgWIzHFY48she tEd3Cc38CjJnU9h819RfxCuPvYIwnwuvKOkv8YjnwUMEpW3vbYMUTmzM2GHlvTsN2iIX VvP5pD4Ogf2ciF4pQMa8Lhix/6FaC4bch7nb+aBmTABgKvU6UyxO9oWmxzAaylas4K3N ZiXQ== 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=bS1qvVFovM8zu+yBkS/L9vtUkQtvHnCv11JyRtTN8hE=; b=wvzwlVWBm8xHsoyWq2HgnPGEs6AM5r99Qj6ZgVZFjZ+vy/E9wQ3csaqHiJiiid39ID VPvEnW2UkbQY+DfsMCmzwzlGCNrRbDjQe1+tzPGnukVALFZzY/bEsOZBeryTdvAmuLC6 3iEJm7+AxbjHKIAKA82t6VW+cj/uFgC9IKicXW9Pnwbg35IXIonmbTbwBH3tH+DXZOdp 6MNk5bWBKTyOgDJZaKwz0dQrLeKbVweM6dBpScIOe3tQXzTCufYPw6vC9ysfovXa04xy E2LK8EnV+sofbkYjkVl1K3236D4hJbH+erKtUXFbpYRlL6OyCG1AQIs6NhjYGsSoWj43 KcqQ== 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 os27si490202ejb.71.2019.10.20.23.42.43; Sun, 20 Oct 2019 23:43: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 S1726645AbfJUGmN (ORCPT + 99 others); Mon, 21 Oct 2019 02:42:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:58958 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726039AbfJUGmN (ORCPT ); Mon, 21 Oct 2019 02:42:13 -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 A52F8B373; Mon, 21 Oct 2019 06:42:11 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id D50D7E3C6D; Mon, 21 Oct 2019 08:42:10 +0200 (CEST) Date: Mon, 21 Oct 2019 08:42:10 +0200 From: Michal Kubecek To: linux-kernel@vger.kernel.org Cc: Navid Emamdoost , emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu, Josef Bacik , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org Subject: Re: [PATCH v3] nbd_genl_status: null check for nla_nest_start Message-ID: <20191021064210.GD27784@unicorn.suse.cz> References: <20190910113521.GA9895@unicorn.suse.cz> <20190911164013.27364-1-navid.emamdoost@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190911164013.27364-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 On Wed, Sep 11, 2019 at 11:40:12AM -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. > v3 Update: added release reply, thanks to Michal Kubecek for pointing > out. > > Signed-off-by: Navid Emamdoost > --- > drivers/block/nbd.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index e21d2ded732b..8a9712181c2a 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -2149,6 +2149,12 @@ 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) { > + nlmsg_free(reply); > + ret = -EMSGSIZE; > + goto out; > + } > + > if (index == -1) { > ret = idr_for_each(&nbd_index_idr, &status_cb, reply); > if (ret) { Reviewed-by: Michal Kubecek