Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp172054ima; Thu, 14 Mar 2019 23:32:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPvrSWILzRB/bpTMPAm7B/idV4kVe+sS4odVY97Cn14XXC38QNMONV99oj02BeL3AV/UC7 X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr2430912plq.293.1552631564984; Thu, 14 Mar 2019 23:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552631564; cv=none; d=google.com; s=arc-20160816; b=I/dA4dDa0FIrJHBRVb+3AfDHpgxCk4Pcw9A4xaFiv69/Rmki3bO2peFtEUpHPtmoNg vYWy/laeKcciFZ+ivp64fxg0hWlZSAjQ76fWngqfD6cjdt8S+zOKmIM5y4mKAqPcpCf/ sarMqhdek/Qxdk7ZfJXr/8Di3ooSHpRVwNuS724Z+oUSO0ko6V0aFaydvw34whr67yeg XpbVPBhX1zsBMs5wmpn7+x6RyZnztK29O5wVD4vvgB8VvY/Xq7hJC4xRNlUbFo51zB1Q Pj5R7KXxBZ1n/cK87TvawWeEGhYdc7HuIjSWk3ydsQGAdc0i1NKFbAX31eqgjlwrBe7c FjJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=RScIh5HilcI0s6YdRvi01yt2VTjLLnx7lLlGiP4k7Uk=; b=DLsvaoK06WB4Bttu8BT1lVjJoWBabwEbD/wmokZMTKFThf2+4F448tJN7pK0b5mVV6 i5gHrtQ013b6Lkl1iX41uMcsXJzLqrbmm2fAQiauW0/fHBft86fK0pWJxyC2xHBZGhiz /41Cnsk4K5L3NnJzaljlZxBvLn2Loxg5IHiubXjvpBn4mwgyCkcA3PrDJXPNyPjv8wcK QbBqjYcJHtinqCJcxjaHnZyImdRoh8ey6KtjZXZ1qZZKD+GjXRl7qn0T0VthYiYORPQV eXkMF8PNl7TCKVSoB1kscu27xXFfTxYC44rVpAEI0zScT2/i+Tfg6nbeNPJlqInC9HiH MjHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=l3fPATFA; 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=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si1060923pgk.524.2019.03.14.23.32.29; Thu, 14 Mar 2019 23:32:44 -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=@umn.edu header.s=google header.b=l3fPATFA; 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=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbfCOGbr (ORCPT + 99 others); Fri, 15 Mar 2019 02:31:47 -0400 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:49654 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbfCOGbq (ORCPT ); Fri, 15 Mar 2019 02:31:46 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 5FF0DCA6 for ; Fri, 15 Mar 2019 06:31:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M_5-XTDxW7Nl for ; Fri, 15 Mar 2019 01:31:45 -0500 (CDT) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id 2C328A7E for ; Fri, 15 Mar 2019 01:31:45 -0500 (CDT) Received: by mail-it1-f199.google.com with SMTP id j127so6895778itj.7 for ; Thu, 14 Mar 2019 23:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=RScIh5HilcI0s6YdRvi01yt2VTjLLnx7lLlGiP4k7Uk=; b=l3fPATFAaPxQTxi8y7dBUtMT5IgF4dSZ1HhaH6DbrCbcsZcOWhxAjauFci8BRZfPy8 tW7A5nqREeqp2Bkez8sG4zBXG2LtbWwAh5lqLvtp91uQRRAreiNMUpyJlaAHu3sXrSdJ OQZE4whciBByNO792wHceoLitp5nS1pPPBjVqWwGqIKgRAkvcMlhUQRb9tfT3fPsQu85 DATdWzSEdjKfxNtUtFjfoASvAZll0uBdNqaapi/lL7FCZaTHP0rWr5u7A0mFa1IXpZej odC3+1bGbUCd/P06XsvAnKCdiN9JFI3e6gVcu8yI1l1d2WCpBMnot21Hdr270CH3o9bg vi0A== 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=RScIh5HilcI0s6YdRvi01yt2VTjLLnx7lLlGiP4k7Uk=; b=GVWfX9fGssK+soX65pSVebk+8tvlChf7fQ74upJ9j41l0+UQ1Xmc9gW+H1H2rYxyC6 e1I9mvX3YEKFyM1J9KdQJUg7UqHy6znYqZF9zrkagi+H29Q0IfZk2s1ndwl42/sLf7pf OwYfjf2t+fNUkwBgQ8EGEG1Jizv8HXnd68LeLP6NMmNzB1wAfAm8qJZ/4uDDCLG+vx1A fsmChhIuRfJJy683Z5+14/lZQxwIkhvHiMcnp/nQza1ns6U6m7MxPeA6ibWClX37+C3T uUFFCY11YlT6CLt3L23RCvWS7FoEXcQBM/ehj/+U9ZjoCD2oWC+1GH5iEtcpMig29NpB giOw== X-Gm-Message-State: APjAAAVZ2vr5KK+FOjrfMih3hxPjs9PjMxmDJzNE9Sjy+gC09Lqh0enl OW9Z8+IAFbSrjbIbLnkKiAjxzAYSfLhtujUe2CXbb62DruRIZiDUvTxwsvdYcUqVPtDxO9rH7NJ xEvRbhAiatcF+53wQDlcJd3GLKLcJ X-Received: by 2002:a24:f709:: with SMTP id x9mr950050ith.149.1552631504798; Thu, 14 Mar 2019 23:31:44 -0700 (PDT) X-Received: by 2002:a24:f709:: with SMTP id x9mr950041ith.149.1552631504558; Thu, 14 Mar 2019 23:31:44 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id 197sm661341itz.24.2019.03.14.23.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 23:31:43 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Josef Bacik , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: [PATCH] block: nbd: fix a missing check for nla_nest_start Date: Fri, 15 Mar 2019 01:31:38 -0500 Message-Id: <20190315063138.17666-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 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 thus deserves a check. The fix inserts such a check and exits gracefully in case it fails. Signed-off-by: Kangjie Lu --- drivers/block/nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 7c9a949e876b..810c8c20b142 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -2099,6 +2099,10 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info) } dev_list = nla_nest_start(reply, NBD_ATTR_DEVICE_LIST); + if (!dev_list) { + nlmsg_free(reply); + goto out; + } if (index == -1) { ret = idr_for_each(&nbd_index_idr, &status_cb, reply); if (ret) { -- 2.17.1