Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6259546imu; Mon, 21 Jan 2019 06:01:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN6wXCiDgZOjSzZwGSBZUe70lJcRCe0PZ8LxoifGeuhNev6qlP9l3fwciH7ycWlg33Df0X+/ X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr30666687plb.55.1548079273317; Mon, 21 Jan 2019 06:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079273; cv=none; d=google.com; s=arc-20160816; b=zSFgMk2zL5v59OaFjbpVDhjTGlYNhHGdgBCdYwlh7xQ1Ps5f2yJwz8XH5YWMTXm0D7 W5kQv40iAuPyjq5KQADGphEhIvFF74mV0AYAn8k5e3kO6vZ4Emt2E5rMRO87HQkImLht YQm4S9wDkxCKAjcmlb6GXwLEbGyGOMRONh8e0Xe6eAzfCAWgtR3JYxbpHR+nJviHUJL8 ZXYsAUNDsNhbIWN0sMbaHO5DoZjsrZ8pXI6w1mNLwRoZqP/i27BOXl06K/uOd/cK46Kw O4AI4dQiCTJeDhliVGjjdJRLZBmJKBXUstaxCJXEcRctac4RZA4PM3AWt4WiIO/xopvy ecTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bp7Vh19qHBVBXiDqQCvYqAFuOqrREP9SO+n9UKoV9cE=; b=jByy8lHk/Aut0VVZcAAz5bc+29tY97xRj9FumxZOHl94aElVA8TcKkQupfMdZuSfYB sJ89DuUe9MhRZ0cCMHXKRcEbXhxeRTQnN5d+72O5Q8KXmxNYFr/s1aSZxuM7omLv8Bed 9FiPkgqLsTOrI6VUPk8abXF2NEleF1DYrp9NvPVsOquJZY5GCkxuzcVfnxGZSOCuMAW3 e5GkWKjS/MY1UTJzjKIX+WWC/wTkbaZ9370rxScRAmHF1xvoHo4cCZFBh+v2xqwAYWzE z/Me8rO/LcH/z12VmjGvEyL3WNy8NLFFyv8go6iA4oDuQ0spOPOpwqS1BRzPGrjzBTVM T90A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z2PTA1v6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 133si12140751pfw.64.2019.01.21.06.00.57; Mon, 21 Jan 2019 06:01:13 -0800 (PST) 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=@kernel.org header.s=default header.b=Z2PTA1v6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732127AbfAUN7E (ORCPT + 99 others); Mon, 21 Jan 2019 08:59:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:44876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732121AbfAUN7B (ORCPT ); Mon, 21 Jan 2019 08:59:01 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD14020879; Mon, 21 Jan 2019 13:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079141; bh=UiA7FTSTYOBbclCEqL/whm0QzziHz8lW0tXMI+x4SBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2PTA1v6oVDuuwyvETmMJj7kfRTmwLpxvdgyXyYrNgOnLqp+E91KymK8R3dcktfSC /MhEydv2A83nCMnTxoYbzXzEJHfR7PjWzZNzDnczp+OUqWqomx3G+VyNpavKc6W8++ 6xa5D5hNPawZpjNhmORmB2m2ZFcIj0VTGNGh0imc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Willem de Bruijn , "David S. Miller" Subject: [PATCH 4.19 22/99] packet: Do not leak dev refcounts on error exit Date: Mon, 21 Jan 2019 14:48:14 +0100 Message-Id: <20190121134914.751181668@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Gunthorpe [ Upstream commit d972f3dce8d161e2142da0ab1ef25df00e2f21a9 ] 'dev' is non NULL when the addr_len check triggers so it must goto a label that does the dev_put otherwise dev will have a leaked refcount. This bug causes the ib_ipoib module to become unloadable when using systemd-network as it triggers this check on InfiniBand links. Fixes: 99137b7888f4 ("packet: validate address length") Reported-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Acked-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/packet/af_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2628,7 +2628,7 @@ static int tpacket_snd(struct packet_soc addr = saddr->sll_halen ? saddr->sll_addr : NULL; dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex); if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_put; } err = -ENXIO; @@ -2828,7 +2828,7 @@ static int packet_snd(struct socket *soc addr = saddr->sll_halen ? saddr->sll_addr : NULL; dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_unlock; } err = -ENXIO;