Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753046AbbK2OCP (ORCPT ); Sun, 29 Nov 2015 09:02:15 -0500 Received: from mail-vk0-f43.google.com ([209.85.213.43]:33276 "EHLO mail-vk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752787AbbK2OCM (ORCPT ); Sun, 29 Nov 2015 09:02:12 -0500 MIME-Version: 1.0 Date: Sun, 29 Nov 2015 11:02:11 -0300 Message-ID: Subject: [RFC] arch/ia64/kernel/palinfo.c: bitvector_process reading out of bounds From: =?UTF-8?Q?Geyslan_Greg=C3=B3rio_Bem?= To: Tony Luck , Fenghua Yu , linux-ia64@vger.kernel.org, LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1414 Lines: 48 Hello, I'm doing some static analysis and stumbled in this function static void bitvector_process(struct seq_file *m, u64 vector) { int i,j; static const char *units[]={ "", "K", "M", "G", "T" }; for (i=0, j=0; i < 64; i++ , j=i/10) { if (vector & 0x1) seq_printf(m, "%d%s ", 1 << (i-j*10), units[j]); vector >>= 1; } } It appears that units[] (5 elements) can be accessed out of bounds in seq_printf call seq_printf(m, "%d%s ", 1 << (i-j*10), units[j]); once j is being set to i/10. i goes from 0 to 63 (u64 bits length), and when vector & 1 (odd), units[j] will calculate outside the boundaries when vector get close to Petabyte magnitude. Well, as bitvector_process doesn't control the max size of vector and the future is knocking on door, I would suggest this change -static const char *units[]={ "", "K", "M", "G", "T" }; +static const char *units[]={ "", "K", "M", "G", "T", "P", "E" }; then if the u64 max value (18446744073709551615) is used the array will provide the correct (E) suffix. If that change is not pertinent I would like to know why. -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/