Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3900018ybi; Mon, 29 Jul 2019 14:58:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuZa9DYZYAet9t80MHSysqYp84KZGluHUmoyBu+Yfju+9ShJZj8I4ipl8ShC4ic5vuZ5aT X-Received: by 2002:a17:902:8490:: with SMTP id c16mr114488632plo.1.1564437502914; Mon, 29 Jul 2019 14:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564437502; cv=none; d=google.com; s=arc-20160816; b=gCSYNfXPGFNCL94MkKoVIO/k67bwTECNiYEP7SNoSO+ejK24PxMh5BCu/nRNLziLuH r0QQ6cdNBDZAwtiJnZpKuG8GHbk5TSFISgU1SAogNYLD1g+8gAXc4kdXae9d8SorHRov aPtVu0LmxfEXZsMLmIy3SoLYYCfKcPcV1ZrqcFKUibT5wvyrG5XUW4fLnjFpsLfwszWy Q89qWhXBa6YMCRnSURAaN58o2EhP0M0Ocjw0kZ9fCuFsv+GV7FIU4uWGxju23u0dwN8r BGgAUdoJa9RLsnuJFEDC8HK/VqzJUmHiD6ujntqI+2N/BO3ljFgOKdNuTiggsPExlCp/ U3bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bmQBBxHIt/eza4I+J3H3QVjWn12oGbnozJKzf9V+0Ig=; b=YK+BMSh2EdSFJpCVhfDYHVPc2f/mlJAdiUt8hgFCupK2fXnuFs6PPmRcI45lok3Xgd qKLyE8SHNmLmLNsrwQbVjAYcpVo/iBoizb76Rqkn5rpMrkayj4ezonzvsHobjTG8W/mc oYP6ByzSwprXsTmcLfym7t4kCrqJuw8o3MOvsNw9T6/+y0x4IdrflXB08NK0MqVbfbqw d8NddfbEvQhQIGKGSDZX68XSyWn7PSQkNJHV8ZWO/P145VojpzeHwFF2RhY67wN3EgvA 9xM+Ulb9X07kewBfz1ulSzMYR3CrtBhZD15SD7GyiMEsfC2nBzTz5qVN49oTsvCBkT4o 9d+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eg7LsPyD; 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 v13si29018413pfe.217.2019.07.29.14.58.07; Mon, 29 Jul 2019 14:58:22 -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=eg7LsPyD; 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 S1728473AbfG2Qmq (ORCPT + 99 others); Mon, 29 Jul 2019 12:42:46 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42422 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbfG2Qmp (ORCPT ); Mon, 29 Jul 2019 12:42:45 -0400 Received: by mail-io1-f67.google.com with SMTP id e20so91056830iob.9; Mon, 29 Jul 2019 09:42:45 -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:in-reply-to:references; bh=bmQBBxHIt/eza4I+J3H3QVjWn12oGbnozJKzf9V+0Ig=; b=eg7LsPyDXHvp4+juupUsF6DEW1xyfkm0S7KlgYBgIvTviXu5aaPxd2Ra64WBP1Hp19 LRvBFDEvdorvIFrVkf67rS7O0YL2ARodjMsu7RpaaV0i9mP+vvBMrLBvQv23AGwBFyy7 0LnuDifYQh8F/A3jUi6O5BiItpq3U8TZcdaovZA8U9UHoJXB1ZO0O6VpSwU/dfm5rVzH 7LNznnMqtliI6e+NCruUP/fiLNPqEipr39KpcpUV9L3yvf6fnvNbv5nmgbvnN4+2ofol 2xFPlOwsTjkytoJB3siD+JoT+bN9B66Wt94mOlbdxjAprgYUHvTeiG3HAFhXCCAs8/EJ vmzg== 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:in-reply-to :references; bh=bmQBBxHIt/eza4I+J3H3QVjWn12oGbnozJKzf9V+0Ig=; b=YtneJs6n1b9/OQHhPwj0YiI4w83acq9W5M5QSOmqj74RhxfA1Mdw/bs4t1rOKGEK7J yQuhnamENKMBcZwgIXmV/5H+kuzCDsmCae39tT2pQGVvia+j5JgM1F4mpRlpOKLeTmdd FGxI2mIW5MsC9TszpgPiAJs6oXa+3rtlTl7KH9b+mEseAKb5WGesmOHyXHmewqvps5rS UczKedinLOh8qj9qxAOKThFgulUngxYr/MsB82ZSBhNt4QxjdgTydyeRmkJ5PNBMqcbo dq++CYTr4lhLlCe7De8J594US60Mmb8BgZ7myZPuh7jm3DAL6I6Vf1LkE1iDgEE913UN ljCQ== X-Gm-Message-State: APjAAAU2VMR9Brvk3PMzBMTGP0JKCbQiK/xtEWR4/Hbu4xW62om4Iufa Y2Blnkdlx7BrMnSGujK6Nzo= X-Received: by 2002:a6b:f114:: with SMTP id e20mr102069896iog.169.1564418565034; Mon, 29 Jul 2019 09:42:45 -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 z17sm83662696iol.73.2019.07.29.09.42.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 09:42:44 -0700 (PDT) From: Navid Emamdoost To: josef@toxicpanda.com Cc: kjlu@umn.edu, smccaman@umn.edu, secalert@redhat.com, emamd001@umn.edu, Navid Emamdoost , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] nbd_genl_status: null check for nla_nest_start Date: Mon, 29 Jul 2019 11:42:26 -0500 Message-Id: <20190729164226.22632-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190729130912.7imtg3hfnvb4lt2y@MacBook-Pro-91.local> References: <20190729130912.7imtg3hfnvb4lt2y@MacBook-Pro-91.local> 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. Update: removed extra new line. Signed-off-by: Navid Emamdoost --- 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) { -- 2.17.1