From patchwork Tue Aug 16 14:45:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 659755 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sDFYZ6Hkwz9t1K for ; Wed, 17 Aug 2016 00:46:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=JiLA4xUs; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753810AbcHPOq3 (ORCPT ); Tue, 16 Aug 2016 10:46:29 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36207 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbcHPOpm (ORCPT ); Tue, 16 Aug 2016 10:45:42 -0400 Received: by mail-wm0-f67.google.com with SMTP id i138so16795872wmf.3; Tue, 16 Aug 2016 07:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=uJBreoBxDorDSWkhHJIdOlnJlDpLcrYBTGa7F3k+r9o=; b=JiLA4xUs7QJZyedJ1nMM68to01OfvOi84v9rIdd9y3tAaCvWc+E0465yY+QkHX+AfY t3hYR7+D7g7r5+5jjSp6fq9+9sIv84l7/+3VAQRakixzOO4uK2/S/yG7/EPaEzrJB5GY LFDDD5z8jxHn+VN/yncz6hu+eDBaAhB6gik8GyFYhBo/VyAefr9K9/NtOQ3py/F+nan9 ZHsipjjgOCXd95OEiF/GuaxdATHzcK0b56tcUXMSvNZ8gnVetYYzByN79jp2GGiKFuuz YxQMlH/7N9Z4jbjp44l7HNn1qEeDerNIJBKQ2v1UB4KSOe/7pQn5BJ+9X9VvqBYtyj4l Dcpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uJBreoBxDorDSWkhHJIdOlnJlDpLcrYBTGa7F3k+r9o=; b=JH7BDcdI7CHbx5swsBR48O61CeLAgfhjvYRxKPnfxfivWdtGdHvQFZnnYB3ZM0En86 gAPXVW4puMZSx/9P3N4qQLTW8xPueqrKhwRqtGhGzSceV3Uj64tCcaxdLbWbNT7yPToI nAU68dBiQ1nkcN/eaSkIcNkfmwQ8cZ9tVC1gPXvY2N4h9Gq8L43c985OW54B892qpiyU g4mcurBjm06CjiQgero8ZAm5DvAhBwyQVvn4QafkUyIpcSDTL2sRmjiT6I/KVY4Ive5e TQf+Dc9IAfa9PJP0AUCy/vhhuYCE3tbiJAMbrtkzKIyyyYkLmI3XtJyvzRPE2mB8OnLq NBiw== X-Gm-Message-State: AEkoousZcis7Ve5Bx9osfhbUbc8g0MT/5R+4LOzKtbSHfLsC7olQxxDsZ3BZ+lbU8yc30w== X-Received: by 10.194.148.19 with SMTP id to19mr43606910wjb.81.1471358740544; Tue, 16 Aug 2016 07:45:40 -0700 (PDT) Received: from localhost (port-18398.pppoe.wtnet.de. [46.59.133.124]) by smtp.gmail.com with ESMTPSA id o4sm27039379wjd.15.2016.08.16.07.45.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Aug 2016 07:45:39 -0700 (PDT) From: Thierry Reding To: "David S . Miller" Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Geert Uytterhoeven , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: ipconfig: Fix more use after free Date: Tue, 16 Aug 2016 16:45:38 +0200 Message-Id: <20160816144538.3181-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.9.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Thierry Reding While commit 9c706a49d660 ("net: ipconfig: fix use after free") avoids the use after free, the resulting code still ends up calling both the ic_setup_if() and ic_setup_routes() after calling ic_close_devs(), and access to the device is still required. Move the call to ic_close_devs() to the very end of the function. Signed-off-by: Thierry Reding --- This applies on top of next-20160816. net/ipv4/ipconfig.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 66c2fe602810..ba9cbeafbb2e 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1530,12 +1530,14 @@ static int __init ip_auto_config(void) * Close all network devices except the device we've * autoconfigured and set up routes. */ - ic_close_devs(); if (ic_setup_if() < 0 || ic_setup_routes() < 0) - return -1; + err = -1; + else + err = 0; + ic_close_devs(); - return 0; + return err; } late_initcall(ip_auto_config);