Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bS6LI-0002eo-2P for mharc-grub-devel@gnu.org; Tue, 26 Jul 2016 13:40:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS6LF-0002eC-3C for grub-devel@gnu.org; Tue, 26 Jul 2016 13:40:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS6L9-0004jW-59 for grub-devel@gnu.org; Tue, 26 Jul 2016 13:40:28 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:36700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS6L8-0004iu-Sw for grub-devel@gnu.org; Tue, 26 Jul 2016 13:40:23 -0400 Received: by mail-lf0-x232.google.com with SMTP id g62so10240328lfe.3 for ; Tue, 26 Jul 2016 10:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=sVUDw75ax+zOkk4T683ge9a8155Mc0NkCrIYfvp/q5I=; b=kaE5BYJ3QSRk2oPcvzbrCo8zVJXbsk2qNPw7LpoqeiPvisnqAtPx8PnYMX1mFs88Ca Kg89Sd+WLuOIwAoxRlgWYw0iUkkHQksuGfsRVSav00wTroDbfdZeL/b9wPFUGR9WSBpP OuVCFuEpeVEPCL40cFN2HWtpqkYSd+7ej27FzIUmkzHL40pKZgPhNb+ZDYHS9p9e/gSX QXOdBEan3M1pY1gscfdgriYVkxRT7yOld7Ta1cErskbUYsKPF04Cb4jV+J97V0MVmwZ2 w/FB/Ci16MpKeC9gHcyPCmL3Ms+mecwm1ouS1NUocqQyyeNJKCKr5qd8WYAngFgYcZvN knFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=sVUDw75ax+zOkk4T683ge9a8155Mc0NkCrIYfvp/q5I=; b=Nyzdy6D7kFFMMfCbohK3EPswJOtkKMiT9r7ikazD6JPqDKPqO69j9v0imf9fxgCnBL y+2Ugdw9IuUJEvxXi/8ABOJZrz7qMxFLbD90RmN3IOLphcagYjNmqafp8GLbHi+kblz1 xEC+1jeACHy1SpnrJ7DnpsNd3hbqy7FOAHMTlk5oagUmpRHfC6X5wGv6dYY4iQ9uLczA rpzfkFWBHbqqgWxuC/rzaTU12eko8zT3g2rQooBK+A/FetHou9ZdZYq9+SFpD0yIynf2 7ySJH4YsO4ZBVUEhhEJzkm5IOiFqZT1GwVyHSDCKfrTq/DdiBU8bF95Y0y5OW3MWpJ0f hc2w== X-Gm-Message-State: AEkoousKoI4ZRExZ9EB1zLA09L6743peuIYVii0lJHTaibKIxse8WqRdFE3MGbzZd4fFwg== X-Received: by 10.46.9.216 with SMTP id 207mr9175325ljj.62.1469554821687; Tue, 26 Jul 2016 10:40:21 -0700 (PDT) Received: from [192.168.1.44] (ppp109-252-91-231.pppoe.spdop.ru. [109.252.91.231]) by smtp.gmail.com with ESMTPSA id 65sm285075ljb.48.2016.07.26.10.40.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jul 2016 10:40:20 -0700 (PDT) Subject: Re: [PATCH] dns: fix heap corruption To: grub-devel@gnu.org References: <20160707091817.GA16571@linux-9gqx.suse.de> <578004FD.5020601@gmail.com> <20160711060259.GA26485@linux-9gqx.suse.de> From: Andrei Borzenkov Message-ID: Date: Tue, 26 Jul 2016 20:40:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160711060259.GA26485@linux-9gqx.suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2016 17:40:30 -0000 11.07.2016 09:02, Michael Chang пишет: > On Fri, Jul 08, 2016 at 10:54:37PM +0300, Andrei Borzenkov wrote: >> 07.07.2016 12:18, Michael Chang пишет: >>> Since commit f9d1b4422efb2c06e5472fb2c304712e2029796b I occasionally bumped >>> into heap corruption problem during dns lookup. >>> >>> After tracing the issue, it looks the *data->addresses array is not correctly >>> allocated. It need to hold accumulated dns look up result but not only the new >>> result in new message. The heap corruption occured when appending new result to >>> it. >>> >>> This patch fixed the issue for me by reallocating the array if it found too >>> small to hold all the result. >>> >> >> I'm not sure. I think we discussed this with Josef back then. The code >> apparently was assuming single response; and if we are going to collect >> multiple answers, we need to filter out duplicates at least and also not >> depend on packet order to select between A and AAAA. > > OK. > >> >> Does attached patch fix corruption for you? I think that is the least >> intrusive as bug fix, and we need to revisit code to properly handle >> multiple responses later. > > Yes, it does. I have tested several times to make sure it doesn't happen. > > Thanks for review. > Applied. Thanks!