From patchwork Sun Aug 26 23:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 962304 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="r0qPxB4c"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41z9xV4vnKz9rvt for ; Mon, 27 Aug 2018 09:21:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 64B96C21E15; Sun, 26 Aug 2018 23:18:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 014E9C21E0B; Sun, 26 Aug 2018 23:17:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 44A7EC21E1B; Sun, 26 Aug 2018 23:16:28 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id 5BE59C21E1A for ; Sun, 26 Aug 2018 23:16:25 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id 20-v6so11879297wrb.12 for ; Sun, 26 Aug 2018 16:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=15JQKuFj84nVIae0VWiIsyUAwT727Hn0h8EIBc7lKbw=; b=r0qPxB4c7CXNp3WKjFJFCZxjSrS+IwU05JpIYPcbFG2xad7UxO55d2HbH8wa8zNyoY XzPkMalBP9jWiuxOfBfWelqfOOiGcceRsJHqxkVXjcU091PanN/e+TeNjQgB86bx4mqb jhquIbPsZnp8agU42LrTfFmJyyAHJcC107SyjjP2ROMC7BlD+1elfPUF/f216tWl/OLl DPEQVFQnONsZxzkIKWnDQ2YCducnru4zebXdWltyiUzm3B3tlb+fwVfr4RPEKfHMIQwL t5IeGIoBq+9wOESvoZ3F/eA3YiFZvd+ec5RHLUZ/9l9oP4KysYDHd6fTAGHg6nTP4gx/ CEtg== 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:in-reply-to :references; bh=15JQKuFj84nVIae0VWiIsyUAwT727Hn0h8EIBc7lKbw=; b=GsQXLs77urRB6ExMgwDMspE+R8y//eLyKXt7zyhXmc6Hx6XjOAugFPNZJmO0vIlnHj JiM/lSnK2QOpzC0vtnEV754MKvuLXCfhgnYFoe5X81XV/tcQoPSEDYmfermp+Tw/7HES NkpdM1EnUjvMlP+eGZp+m4UoiPZdCwGPtUf5UrYeGbKHpRW4tcou0VIHHOrItpAwRzBR 34V/Ie+yjp3DDSjzhNJj5k04pE15YdKcIPNkBvXCSM4KMu6ERFrKvKVJBJHRqRphVWVa Z7CUC5Z+dD5fRyFC95ruxVeoH1AgoYRSTb7tY9Q7M3IrX2Yvs4TiSZlo8Q0zpgv52WOV oTow== X-Gm-Message-State: APzg51DFzSN8y101noHAEzuAeCl13NSoKUWC9iAb2vtp6ThF0aK2pkjH i8v6mxej3rlKdXL3RHTwX8Y= X-Google-Smtp-Source: ANB0VdZO+xFs+ONtQv0z99/0NKLNvog8fEEEU40lqH8KR1OdNhkZvF8UFVz5a1HROTCtY+Kz8U5dUQ== X-Received: by 2002:adf:ff82:: with SMTP id j2-v6mr6516678wrr.165.1535325385046; Sun, 26 Aug 2018 16:16:25 -0700 (PDT) Received: from localhost.localdomain (ipb218f467.dynamic.kabel-deutschland.de. [178.24.244.103]) by smtp.gmail.com with ESMTPSA id e141-v6sm10828362wmd.32.2018.08.26.16.16.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Aug 2018 16:16:24 -0700 (PDT) From: Eugeniu Rosca X-Google-Original-From: Eugeniu Rosca To: Tom Rini , u-boot@lists.denx.de Date: Mon, 27 Aug 2018 01:13:26 +0200 Message-Id: <20180826231332.2491-9-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180826231332.2491-1-erosca@de.adit-jv.com> References: <20180826231332.2491-1-erosca@de.adit-jv.com> Cc: Eugeniu Rosca , Andre Przywara , Alexey Brodkin , Alexander Graf , Peter Jones , Fabio Estevam , Eugeniu Rosca Subject: [U-Boot] [PATCH v2 08/13] disk: part_dos: Fix signed shift overflow X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Fix the following UBSAN report: ==================================================================== UBSAN: Undefined behaviour in disk/part_dos.c:30:22 left shift of 209 by 24 places cannot be represented in type 'int' ==================================================================== Steps to reproduce the above: * echo CONFIG_UBSAN=y >> configs/qemu-x86_defconfig * make ARCH=x86 qemu-x86_defconfig all * qemu-system-i386 --version QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.31) * qemu-system-i386 --nographic -bios u-boot.rom * bootefi selftest Fixes: fe8c2806cdba ("Initial revision") Signed-off-by: Eugeniu Rosca --- Changes in v2: - None. Newly pushed. --- disk/part_dos.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index 936cee0d36ce..e19695846a95 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -27,11 +27,10 @@ */ static inline unsigned int le32_to_int(unsigned char *le32) { - return ((le32[3] << 24) + - (le32[2] << 16) + - (le32[1] << 8) + - le32[0] - ); + return (((unsigned int)le32[3] << 24) + + ((unsigned int)le32[2] << 16) + + ((unsigned int)le32[1] << 8) + + (unsigned int)le32[0]); } static inline int is_extended(int part_type)