Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8990093ybi; Tue, 23 Jul 2019 19:34:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqynsKgEoZX+5cU4hBCLXcDDRxqxCZic2EF4mNzo5wLkHPu6WDkCQ+dki2DfgaoUlGG/e2aA X-Received: by 2002:a17:902:4c:: with SMTP id 70mr83228373pla.308.1563935691680; Tue, 23 Jul 2019 19:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563935691; cv=none; d=google.com; s=arc-20160816; b=HDUxCsXqIdbLlfFPZ+QRwUxYDn4MngG7B18oQ/F87u73UpLxYXTZeDwnz1WMacAKH2 moQKznykv8SddrLmyH6KyuuQv+T/fit445BQyiCi8rZQIhE69sMXuEVdyzHNhLWHurdo K73PhRfW5N8EV6MaRkunc7V23IAQgrTmT+2AzYUT97AOskKHfzmImey0DHmS8BYXjwpS YvGK+rWuk+Yjs7a535IluW5gDJTugOPoGbYLIUR2GdQKrkSlDSeSgubwabYEQ6Vsly87 GZ6FfbhGQJ5L4MczBt2wwWXEZIiK8FvaXGhiwZfOwio9pN+rGnZcCD3TQQPJvEYRJYWC m+Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=WLivNX+IOU3BF5pVPZ4dT2PGyWr1z46q52x8JkbNVPY=; b=tezG6KMZe7A0ZGd5m1kBQSl5gQ4gI6VIh7YniNUvs99OBuiKLHJfmM4XQwtSqf7qam rKtXn1eT+R08XN63pzDI9cNdYexVB2RvoOcpVDLhhlG6Fu2G6XcqwR9y6TlWs+5F+t5C +lLdNtIktPaPdtpuUfTHuQ2pOuB9+eqDw2jPSQ3Dzd6aw8xYWHDp3XdGUwusF7qriGiP lPU5sYT2vWo8j6nLzmdXbXpi3v/OjrTSNziJIejklK4XCE8Rj65UkNhfAEYEOZGsYxtr Fdj5NDNwBI06rMBQ1ojFd2pB0fxaswhPWTKMMJHMiS1WmxUhJgECnohpKZJNeHfjvYzJ lYnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z8CkXQHt; 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=fail (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 x66si4837502pfd.156.2019.07.23.19.34.35; Tue, 23 Jul 2019 19:34:51 -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=fail header.i=@gmail.com header.s=20161025 header.b=Z8CkXQHt; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392586AbfGWXCM (ORCPT + 99 others); Tue, 23 Jul 2019 19:02:12 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:38138 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392608AbfGWXCG (ORCPT ); Tue, 23 Jul 2019 19:02:06 -0400 Received: by mail-io1-f67.google.com with SMTP id j6so10304752ioa.5; Tue, 23 Jul 2019 16:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WLivNX+IOU3BF5pVPZ4dT2PGyWr1z46q52x8JkbNVPY=; b=Z8CkXQHtW2MsPGieVx6RX8eY6KKzotV/eE19hybmIqhS5dToSWjnczzuz+1Uhz6rrh zxz4ZMS9cEwRPfXnSTKOW5vFjehBiljmlg3X5Oymz/MvTObEZ5yIV0dYXCM0cOuYiM47 0+DQlGJ16dCKLm+K09Sdb6aVtLmafnOddQhhRip9PBFKIb7qv7GjaliBMwqhpP4po6ho 2bd5iFeZBYllACr5dGiIlaK2i6/PSoPpL6wa1FI+xK2R7S7a/siCQNUhBTukQufvqygC aeugjPFBUR4ng4oCJi5khHw2z0OogUaddtLA//mvVhVcIGG4HRoj5TT20nHyXs3rDOX2 bsdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WLivNX+IOU3BF5pVPZ4dT2PGyWr1z46q52x8JkbNVPY=; b=WkFxVBxusoF8J4Rg2YejSuqnlOJCCChR/cjTmBJ/gSDlvad64JjnBgjrfwwt4vqDo+ 66XxGvbr67AERM/eox8lN+7xKiSGYu1OPIGr9jHbmVR2JwyAsrnWd8RBEQ1/P2sedxRS 7BDKu2GuZRUPB0NjRsxa2dHU2M13NHM2PBPGR4y+P5wUxVOGoR78mgUZNMXycACRjL3Y jU5QZjArFc6+xHE2DK5Wg58MPBUyaSbEtaIoz4BukKt+Vf3maPpa4bv5XRhlPVSnEecd IhZMQqPSUlYxsHWLnALWLUvy+cLQsWK7tcK5vnOkCWnJnKZf/ZLisKyivn0gCUHaXuOn w53g== X-Gm-Message-State: APjAAAUgH9tKjb7EMCT2Jck0fvnMoyUEK+SrL4nxqbH4KnwkjgwleKu3 1+ZUOUnI5nmgdlhCqVTCcM0= X-Received: by 2002:a02:37d6:: with SMTP id r205mr80277850jar.57.1563922925974; Tue, 23 Jul 2019 16:02:05 -0700 (PDT) Received: from cs-dulles.cs.umn.edu (cs-dulles.cs.umn.edu. [128.101.35.54]) by smtp.googlemail.com with ESMTPSA id m10sm84918390ioj.75.2019.07.23.16.02.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 16:02:05 -0700 (PDT) From: Navid Emamdoost Cc: emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu, secalert@redhat.com, Navid Emamdoost , Josef Bacik , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: [PATCH] nbd_genl_status: null check for nla_nest_start Date: Tue, 23 Jul 2019 18:01:57 -0500 Message-Id: <20190723230157.14484-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 9bcde2325893..dba362de4d91 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) { + ret = -EMSGSIZE; + goto out; + } + if (index == -1) { ret = idr_for_each(&nbd_index_idr, &status_cb, reply); if (ret) { -- 2.17.1