Backports Archive on lore.kernel.org
 help / color / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: backports@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 6/6] backports: genetlink: avoid NULL dereference
Date: Fri, 15 Mar 2019 16:33:18 +0200
Message-ID: <20190315143318.4714-7-luca@coelho.fi> (raw)
In-Reply-To: <20190315143318.4714-1-luca@coelho.fi>

From: Johannes Berg <johannes.berg@intel.com>

If we fail to allocate extack, we fall back to the code path
that tries to send an error *with* extack, but that will
access our extack pointer. It also doesn't make sense, so just
return an error back to netlink immediately and let it handle
sending the error message to userspace.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 backport/compat/backport-genetlink.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
index 71bf45adf88d..885f17568333 100644
--- a/backport/compat/backport-genetlink.c
+++ b/backport/compat/backport-genetlink.c
@@ -157,12 +157,10 @@ static int backport_pre_doit(__genl_const struct genl_ops *ops,
 #if LINUX_VERSION_IS_LESS(4,12,0)
 	struct netlink_ext_ack *extack = kzalloc(sizeof(*extack), GFP_KERNEL);
 
-	__bp_genl_info_userhdr_set(info, extack);
+	if (!extack)
+		return -ENOMEM;
 
-	if (!extack) {
-		err = -ENOMEM;
-		goto err;
-	}
+	__bp_genl_info_userhdr_set(info, extack);
 
 	extack->__bp_doit = ops->doit;
 #else
@@ -175,7 +173,6 @@ static int backport_pre_doit(__genl_const struct genl_ops *ops,
 		err = family->pre_doit(ops, skb, info);
 
 #if LINUX_VERSION_IS_LESS(4,12,0)
-err:
 	if (err) {
 		/* signal to do nothing */
 		extack->__bp_doit = NULL;
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 14:33 [PATCH 0/6] backport: some patches from our internal tree 2019-03-15 Luca Coelho
2019-03-15 14:33 ` [PATCH 1/6] backport: add v5.* to the Makefile Luca Coelho
2019-03-15 14:33 ` [PATCH 2/6] backports: update iwlwifi pci device removal patch for v5.0 Luca Coelho
2019-03-15 14:33 ` [PATCH 3/6] backport: add atomic_fetch_add_unless() Luca Coelho
2019-03-15 14:33 ` [PATCH 4/6] backport: add include ftrace_event.h back to backport-4.0.c Luca Coelho
2019-03-15 14:33 ` [PATCH 5/6] backport: fix handling of nospec.h for 4.15.0 and 4.15.1 Luca Coelho
2019-03-15 14:33 ` Luca Coelho [this message]
2019-03-19 21:55 ` [PATCH 0/6] backport: some patches from our internal tree 2019-03-15 Hauke Mehrtens
2019-03-28 15:03 ` Hauke Mehrtens

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190315143318.4714-7-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=backports@vger.kernel.org \
    --cc=johannes.berg@intel.com \
    --cc=luciano.coelho@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Backports Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/backports/0 backports/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 backports backports/ https://lore.kernel.org/backports \
		backports@vger.kernel.org backports@archiver.kernel.org
	public-inbox-index backports


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.backports


AGPL code for this site: git clone https://public-inbox.org/ public-inbox