Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp266769ybg; Thu, 17 Oct 2019 22:44:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZkK4gCWtkN3MXqWJxNCH0ZAcCsCVtrNW90tDixRzi+x1PFJ3TeYUEc3xCjob1BaDY+nn4 X-Received: by 2002:aa7:ca59:: with SMTP id j25mr7771296edt.78.1571377442233; Thu, 17 Oct 2019 22:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571377442; cv=none; d=google.com; s=arc-20160816; b=lu3+ThxqptpM3XeOZqvmpohVdkEB0xm0rH8ekM0N2DifYiWgRWnOzOUySrt3M6uvv8 cQirDU64Lj8UnbnivbYU3XcFukQBgVk5nMLuFurQKsmhaVjaUZDnuXRlzZPaH3bEQDN1 g8SJJ/8Fl6s+Cl+YXcBh9cNkp+LraQi2tjldJlPN6nexc2FuNU6FOVnJRQvzea7SHvIM RqsK5CSViDtfAh5Q0CNlaS9f6k6untZo57ZAKQ02Z9dIU6mbnAZG8/JNpu9KrLjdEOzH 0SGYxCXbhHomru0N/MqhbaNpwu9GtCwAtI931tTSVMZqpJWWK4A4QuLdhEtQ9TQ9El5f pwSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AK1OtpwhD+5T5SYc4aqWUSJoX7IiVAlBKWUj0KHIhec=; b=ufq64QFkHd8VPW6QlxxQbse0ec5hBS+Hcot6Zjp3tzNNtg/ICPR0hgIB2f2G0RRlkf F7LqZ2KlcCAMDUWcpHfImgSQgQxMgNr41/fdYbaoAzn+tf/tak/L1F57TGVbnbULIMO1 tm7x+z/f4KhBCXDMyL45wvp1uZ/fXMU4KShdcmTPalwUwT9PdTSmsJyqQxKxksQiJsw4 E3xvPlS0MCR4C+T0bqesy7gBKDeVi0xanVRWPcJ6K2S6SyfiiDkjEUOtd1zQu7WpJttX OMea8iZlzRS4h5IEagb/2/qgpMQFKdvENBsSkZJ3cL2gaVodfu6aqUSlcpH2wKe87OcA DtQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uBh8gacb; 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 o14si2689935ejc.421.2019.10.17.22.43.38; Thu, 17 Oct 2019 22:44:02 -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=uBh8gacb; 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 S2395461AbfJQCRf (ORCPT + 99 others); Wed, 16 Oct 2019 22:17:35 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:46370 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393050AbfJQCRf (ORCPT ); Wed, 16 Oct 2019 22:17:35 -0400 Received: by mail-io1-f67.google.com with SMTP id c6so991616ioo.13; Wed, 16 Oct 2019 19:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AK1OtpwhD+5T5SYc4aqWUSJoX7IiVAlBKWUj0KHIhec=; b=uBh8gacbPpI0VJl5KhIjIShsglvHOpHqpSWiu+6AxZwpiR2br9ZYDKkGK4jzLu+SUZ 7pgTlEXcdIACDCfz+ZcAn1V3BDOLqi6DGWoP5O2RU3WMcLv1Lh90cXa+FJJrvFJQR2aT bAPtAcTfnfiJL+4duRq6FOhydOf/C+oXrqvtrxoGjsvx/VtGH1nkHRyAnI3TwxWEh6ex ReT4YQ6smyx7AQxDNe85Egx7Ln9loTOI253cZKhTn+qZA5IW7+3rjqztC8mgvP6Rcb+y WLxo78bSS6cWb63/APDyM9X9QxXPq5M3bemJVqbqCvakXx23eoJQZMAe3a4aculMMmgS AMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AK1OtpwhD+5T5SYc4aqWUSJoX7IiVAlBKWUj0KHIhec=; b=mLU7tYNnGyXA8rQhdEMKyJMX2JMrRhoEwE0uB64D8D3mAql93OnkdiA2f6BrM5ch/v FjVhHHW8zuCkFXuXW5Mypprm7Ylz/WklblU0dEaeYRQxJNVQHh4ezmFSyeGo1L3jnA1C e46IHak4JYUAsyRQ6GPeuFNshEDCXcyZOXDwpada7urcwn7SqshBDTQ0BhWa5x9A3bOK aPMaVWiF7PXFVozSq4sv0kmtZeynSsdpgWmUT7bcPQNKGPiMNdSaMgfrmpH/ETBeEN5V WvstdylAyu96ccD3D7BotpvWGyBupyjTl+oxAjKLe8+T0Pl5nX+Hz7jpHhOfctYaLqhV rIqQ== X-Gm-Message-State: APjAAAVXv2B4evh5rw2caL1OdEBiJaL0uvioVoGYQi9kTg+Ee9U/DRil Z9JyckTFOK0timimsWSQmWlW5AsaBokj2xkm+KY= X-Received: by 2002:a02:a11e:: with SMTP id f30mr1061524jag.95.1571278652391; Wed, 16 Oct 2019 19:17:32 -0700 (PDT) MIME-Version: 1.0 References: <20190729130912.7imtg3hfnvb4lt2y@MacBook-Pro-91.local> <20190729164226.22632-1-navid.emamdoost@gmail.com> <20190910113521.GA9895@unicorn.suse.cz> In-Reply-To: <20190910113521.GA9895@unicorn.suse.cz> From: Navid Emamdoost Date: Wed, 16 Oct 2019 21:17:21 -0500 Message-ID: Subject: Re: [PATCH v2] nbd_genl_status: null check for nla_nest_start To: Michal Kubecek Cc: Josef Bacik , Kangjie Lu , Stephen McCamant , secalert@redhat.com, Navid Emamdoost , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, please check v3 at https://lore.kernel.org/patchwork/patch/1126650/ Thanks, Navid. On Tue, Sep 10, 2019 at 6:35 AM Michal Kubecek wrote: > > (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 -- Navid.