From patchwork Thu Mar 28 12:58:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Markus_K=C3=B6nigshaus?= X-Patchwork-Id: 232001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id DC8762C00BB for ; Fri, 29 Mar 2013 00:04:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9BC7325D6C; Thu, 28 Mar 2013 13:04:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L2u1lLErlL4u; Thu, 28 Mar 2013 13:04:36 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 883AB31826; Thu, 28 Mar 2013 13:04:35 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 98B8A8F753 for ; Thu, 28 Mar 2013 13:04:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0CA498CEBA for ; Thu, 28 Mar 2013 13:04:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v8H8zm767UzY for ; Thu, 28 Mar 2013 13:04:31 +0000 (UTC) X-Greylist: delayed 00:05:39 by SQLgrey-1.7.6 Received: from mail.wut.de (mail.wut.de [194.77.229.25]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5AEB28C934 for ; Thu, 28 Mar 2013 13:04:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.wut.de (Postfix) with ESMTP id A44751A601C for ; Thu, 28 Mar 2013 13:58:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wut.de; h= content-type:subject:mime-version:user-agent:from:date :message-id:received:received:x-virus-scanned; s=20110119wut; t= 1364475526; x=1366289926; bh=JQThoZuSb6LYqprJRzlh663xXqy+cZcbaKE tX8SqpSU=; b=EoYeW9fbGhf3LWck9fppt7elXTf8yMJB5SSPX032+CdFnSn2sn1 Kj2Fl9/j3TdMOFzxiZWV5ZjdCEoHhBF9fs7/YRfpN4BMTgD+elNkH8BW4xzIh+29 D2KqEqTb5KLwuCR1e3OFreKmu5yTvlB5NH3w3mqrfkm4FI7OrkwOVtW0= X-Amavis-Modified: Mail body modified (using disclaimer) - ms3.wtintern.de X-Virus-Scanned: amavisd-new at wut.de Received: from mail.wut.de ([127.0.0.1]) by localhost (ms3.wtintern.de [127.0.0.1]) (amavisd-new, port 10026) with LMTP id DsF0cAXPOKaB; Thu, 28 Mar 2013 13:58:46 +0100 (CET) Received: from [10.40.33.3] (WSKK3.wtintern.de [10.40.33.3]) by mail.wut.de (Postfix) with ESMTPA id 264911A6005 for ; Thu, 28 Mar 2013 13:58:46 +0100 (CET) Message-ID: <51543E86.9000706@wut.de> Date: Thu, 28 Mar 2013 13:58:46 +0100 From: =?ISO-8859-15?Q?Markus_K=F6nigshaus?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: buildroot@busybox.net Subject: [Buildroot] Bug in uClibc-0.9.33.2 resolv.c X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Hello, I have found a bug in resolv.c in conjunction with the function res_init: res_init sets __ res_sync to res_sync_func and then calls __res_vinit. -> __res_vinit calls __ open_nameservers. In __open_nameservers __nameserver and __nameservers are set by the contents of resolv.conf. So far so good. -> __open_nameserver calls res_sync_func In res_sync_func__nameservers is set to rp->nscount, what is 0. Backin _res_vinit rp->nscount is set to __nameservers then, what is 0. So the cat bites its own tail. Attached is a simple patch, that fixes the problemby setting __res_sync after calling __res_vinit. Before this patch with busybox "nslookup www.google.de" -> nslookup: can not resolve '(null)': Name or service not known Name: www.google.de Address 1: 2a00: 1450:4016:800 :: 101f muc03s01-in-x1f.1e100.net Address 2: 173.194.35.151 muc03s01-in-f23.1e100.net Address 3: 173.194.35.159 muc03s01-in-f31.1e100.net Address 4: 173.194.35.152 muc03s01-in-f24.1e100.net After the patch "nslookup www.google.de" -> nslookup www.google.de Server: 8.8.8.8 Address 1: 8.8.8.8 google-public-dns-a.google.com Name: www.google.de Address 1: 2a00: 1450:4016:803 :: 1018 muc03s08-in-x18.1e100.net Address 2: 173.194.44.56 muc03s08-in-f24.1e100.net Address 3: 173.194.44.55 muc03s08-in-f23.1e100.net Address 4: 173.194.44.63 muc03s08-in-f31.1e100.net This patch ist tested with buildroot-02.13. Regards, Markus -- Unsere Aussagen koennen Irrtuemer und Missverstaendnisse enthalten. Bitte pruefen Sie die Aussagen fuer Ihren Fall, bevor Sie Entscheidungen auf Grundlage dieser Aussagen treffen. Wiesemann & Theis GmbH, Porschestr. 12, D-42279 Wuppertal Geschaeftsfuehrer: Dipl.-Ing. Ruediger Theis Registergericht: Amtsgericht Wuppertal, HRB 6377 Tel. +49-202/2680-0, Fax +49-202/2680-265, http://www.wut.de Autor: Markus Königshaus --- uClibc-0.9.33.2.org/libc/inet/resolv.c 2012-05-15 09:20:09.000000000 +0200 +++ uClibc-0.9.33.2/libc/inet/resolv.c 2013-03-28 11:52:55.000000000 +0100 @@ -3653,12 +3653,18 @@ */ if (!_res.id) _res.id = res_randomid(); - __res_sync = res_sync_func; + __res_sync = NULL; __UCLIBC_MUTEX_UNLOCK(__resolv_lock); __res_vinit(&_res, 1); + __UCLIBC_MUTEX_LOCK(__resolv_lock); + + __res_sync = res_sync_func; + + __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + return 0; } libc_hidden_def(res_init)