From patchwork Fri Nov 24 20:07:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 841157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yk6h20F5Jz9s5L for ; Sat, 25 Nov 2017 07:08:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kGcksJyx"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yk6h14C91zDrns for ; Sat, 25 Nov 2017 07:08:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kGcksJyx"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::241; helo=mail-pg0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kGcksJyx"; dkim-atps=neutral Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yk6gw5VcpzDrpF for ; Sat, 25 Nov 2017 07:08:11 +1100 (AEDT) Received: by mail-pg0-x241.google.com with SMTP id 70so15959077pgf.6 for ; Fri, 24 Nov 2017 12:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZvqjGkc3w/n9l4Zv4O3rej5R837qfZtqHjqlarwBEng=; b=kGcksJyxZnKWHCsy3U5ced2j99wYe8K2WSt0TillkJ4TN4iaYafLikFipUJjPm77aX fQ90vIKWXlASnJHkBZdp5rhKuaZCAjzCo41zWDuzrLtirY+Bh4TGc12smRg9gmppHrNE XIos0/pVU1EtOzQaW1zRPwqsdnsajkLqbOl1DPClSuyqkuw6WBogUskG7CvJkX8Cm8wH 5SsiRsmp+hLpt+uqH+wgp4GjkSvdMNyWu58KtXlW6Ow1WF9KepQMj0fbCt7yJQr9Bix+ wl3594DPhPmJdKWkLo2fDiCubGDUIhGbx8VUFip/w/e7+82tgB8+6htkd4u8YtmI1hKK DfRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZvqjGkc3w/n9l4Zv4O3rej5R837qfZtqHjqlarwBEng=; b=O057UvnxdJU9Dc8/hL+iXZLKmrUGlHXBcBlppThO7UAMNPiraMNhX4gZEt2L1x6v9X 1lYObqB69RrUlJjspneQQQ8EOTz940ybW2gs3VS7LwEIWJJQUlgSAHo2jZhN3GQyoxlO PBgKG8HBeUoIsLwJ76kHg7LIAQ/PdCtAmQdFLp+E6fN6Zc30lXFOfSke0fmOhEFq6/uT fPMeXimJdDKhMFhKQXd4kXueJZNj61CXU7eZyswuouLhHwdasjhI8rPZ5MwwUKo44lEt KbUEuRLWQy5TGDbm3jlBKSD+GvfgFvVfzynkq0Ihx3R7soGQfzRYtKZiePEuCwDBWz6H ovVg== X-Gm-Message-State: AJaThX413iHP0ThlG81fqiJBjZk6+RLJJRCB6QdApafdctOGz4/cp9qf 0QtwBY0umBlx2Bz56HTSBb0m0Q== X-Google-Smtp-Source: AGs4zMY3PYA46iUVzLBx4wfJPI9XZkl8cNsY6OMirYHkBVZo0J2kD71Bg60KsyyaxtlE4IjqinC04Q== X-Received: by 10.99.156.26 with SMTP id f26mr3126841pge.347.1511554089842; Fri, 24 Nov 2017 12:08:09 -0800 (PST) Received: from roar.au.ibm.com (27-33-241-2.tpgi.com.au. [27.33.241.2]) by smtp.gmail.com with ESMTPSA id w9sm39006866pfk.16.2017.11.24.12.08.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 12:08:08 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sat, 25 Nov 2017 06:07:59 +1000 Message-Id: <20171124200759.24733-1-npiggin@gmail.com> X-Mailer: git-send-email 2.15.0 Subject: [Skiboot] [PATCH] core/bitmap: fix bitmap iteration limit corruption X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The bitmap iterators did not reduce the number of bits to scan when searching for the next bit, which would result in them overruning their bitmap. These are only used in one place, in xive reset, and the effect is that the xive reset code will keep zeroing memory until it reaches a block of memory of MAX_EQ_COUNT >> 3 bits in length, all zeroes. Signed-off-by: Nicholas Piggin --- include/bitmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bitmap.h b/include/bitmap.h index 12913ea00..f3510f725 100644 --- a/include/bitmap.h +++ b/include/bitmap.h @@ -59,11 +59,11 @@ extern int bitmap_find_one_bit(bitmap_t map, unsigned int start, #define bitmap_for_each_zero(map, size, bit) \ for (bit = bitmap_find_zero_bit(map, 0, size); \ bit >= 0; \ - bit = bitmap_find_zero_bit(map, bit + 1, size)) + bit = bitmap_find_zero_bit(map, (bit) + 1, (size) - (bit) - 1)) #define bitmap_for_each_one(map, size, bit) \ for (bit = bitmap_find_one_bit(map, 0, size); \ bit >= 0; \ - bit = bitmap_find_one_bit(map, bit + 1, size)) + bit = bitmap_find_one_bit(map, (bit) + 1, (size) - (bit) - 1)) #endif /* __BITMAP_H */