Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1204041imm; Fri, 29 Jun 2018 13:21:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpebfDUHe6MiOrLEmfWwWBsIBJ7Ryc9ZS8X1or/Sv25Pizld1IMfw800jK1um5nM6RGlkynQ X-Received: by 2002:aa7:808f:: with SMTP id v15-v6mr16003937pff.38.1530303719243; Fri, 29 Jun 2018 13:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530303719; cv=none; d=google.com; s=arc-20160816; b=yrggheLZAePhJ/IghWYiTl4IkBbr1dLgNYuy1Vdye5SlI8wa7ASu6mGjw2HsMhcG/w vR+O+d1YrCFF6Ak7szjoDl+T8g8sbRXunjbquWh4jcWgzn51Lv2Mn3cxx4RdOms1kYm9 pGLeLSIWL7GXkhB6j2+MunSULxR397B5RUYoiPAoJ3P7li2tbZ2gpSVRJOFpRL+iA8aM SIjYDDlqEGJSLtc99GRY+41ymv6NFzrD5o4el+ShVvQlnnoDhsCyH+dlI+9YfTGJDcce 9beItCgbHG1MRkOCWnDqGydQ6h1PG2e2+0BBCQfbuppK5TeROLcvIGOvmzexbPEUpIJZ uJ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wjQ1pKmQSQ88guZSAVBVF2bq2IJ54XmaJP7r7Bld1dU=; b=YW9YoXLdHr+M5w5qWIqoCrD9XimVtupkMV0LMqBpzP4EnkJXOCovNH9H2y+DQhbQ0O yc9iQeCCm5E24AJT+TOicrXLMj/En6UABFqy9Wt5PoFtrvQodQHti+rayBWUHFCvmCgS spflq+FxqCp8SP+D1BpMMwwonWgcL/VHqH666u3BPLLVH7x928BnVk7TZ8UAR8Kbfx3P hBOOm3wD7eBh6O+MrWlE2HhqT0gv/2nSjBsS0aswYU9RhX6aneUmtwfQD2tFl8EGvhyZ 72Se9o+Bbz03kAKFhWt/xvTITehhtgw+WwMJuUIRk155F0iLo4TprLVlOZmBrr97+biP l/HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=XZMm9uV9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si8299137pgv.652.2018.06.29.13.21.45; Fri, 29 Jun 2018 13:21:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=XZMm9uV9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936191AbeF2Snu (ORCPT + 99 others); Fri, 29 Jun 2018 14:43:50 -0400 Received: from mail-eopbgr00092.outbound.protection.outlook.com ([40.107.0.92]:39424 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935928AbeF2Snr (ORCPT ); Fri, 29 Jun 2018 14:43:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wjQ1pKmQSQ88guZSAVBVF2bq2IJ54XmaJP7r7Bld1dU=; b=XZMm9uV9KOd29vGIEBILkU23Ssr1jt+48FvdgAxniMYOiybbZHR4ZQKlkZp7p3CwBHmgGwbQSJFvT7/vvjwd43kL0e19gvQNIQ1lhvEo/KR0gI4NVV/osPPgYILUttxY8oMsAYz+qOR07SEIU/0xvTueS/ls0RCo0DdUPggMzsU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from i7.sw.ru (185.231.240.5) by AM6PR08MB3256.eurprd08.prod.outlook.com (2603:10a6:209:47::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Fri, 29 Jun 2018 18:43:43 +0000 From: Andrey Ryabinin To: Andrew Morton Cc: icytxw@gmail.com, Alexander Potapenko , Dmitry Vyukov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Ryabinin Subject: [PATCH] mm/fadvise: Fix signed overflow UBSAN complaint Date: Fri, 29 Jun 2018 21:44:53 +0300 Message-Id: <20180629184453.7614-1-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180627204808.99988d94180dd144b14aa38b@linux-foundation.org> References: <20180627204808.99988d94180dd144b14aa38b@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: DB6P18901CA0003.EURP189.PROD.OUTLOOK.COM (2603:10a6:4:16::13) To AM6PR08MB3256.eurprd08.prod.outlook.com (2603:10a6:209:47::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bec025f2-a2b2-4b97-4416-08d5ddf03dee X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(2017052603328)(7153060)(7193020);SRVR:AM6PR08MB3256; X-Microsoft-Exchange-Diagnostics: 1;AM6PR08MB3256;3:dN7bOMnVDFJryR5Lb+N9L5qB8f7/HOI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ZySLGilEWOMAtjTsTYmxNMQjkNmLqNbEXSplZ6OryX1dVFqcQReVzSaZgiqxTGhGUoK8TCzqoxAkr6ke5KvdTvMiWOsfoxkcmazwgPEeo19+M3WLs1XzzII1N1FcOr22EECCghwPRj0JWWB7pB6H3heJuiySOjQE7G7LTOMLwwmbPiQXHUce98xEJaoKcmwMXdrbJpI3qSIj270ZzDp6bnNoIw7YHOXJITpevgQNywgT23UjbNTqRI0XWWv38ZpIFUu/e+a6JpyM7p8jwlfT+ax1X0XOjZTXrP4Vb/PZa8OUSUIUfAD2pi;4:ChBBOazfoAUuCD7SJV5P//JWK7J702Rh1M7tjqZbEL0npW5NnSf6puTg1yWlHpLkLVZPHCJ5i6fXLVJ8Weje2XYMt6ijJrHPWCJjeBgqZ1t32UAA9VklydW5IOXUvs1ydxgXOzBwrpgeHdCSsWgzA3+A+I8rFkP5TEeSKbF3Rdr0M8XsvuRM/ga124n69Lyk32B69c3FL+7IarsfEPOp4cTUAJasr5rdaJKYpCpFUVSnj4HQKhv7g9atZBIlm6mWjtHrAbrhm28CJ0wtIsKjtgrhKnu7d8Q0SbbbpN8xcOT2eX8RgxvLi+O8dkYq0QhB X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:AM6PR08MB3256;BCL:0;PCL:0;RULEID:;SRVR:AM6PR08MB3256; X-Forefront-PRVS: 0718908305 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(396003)(376002)(136003)(346002)(39850400004)(199004)(189003)(105586002)(186003)(1857600001)(6506007)(386003)(48376002)(76176011)(50466002)(6116002)(6486002)(97736004)(3846002)(1076002)(68736007)(53936002)(51416003)(5660300001)(107886003)(39060400002)(52116002)(478600001)(26005)(16526019)(2906002)(36756003)(6512007)(81166006)(81156014)(8936002)(66066001)(8676002)(7736002)(305945005)(4326008)(86362001)(6666003)(47776003)(6916009)(106356001)(14444005)(316002)(16586007)(486006)(50226002)(11346002)(53416004)(54906003)(2616005)(25786009)(476003)(446003)(956004);DIR:OUT;SFP:1102;SCL:1;SRVR:AM6PR08MB3256;H:i7.sw.ru;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM6PR08MB3256;23:Z0XFHrEk/ronurh39uxEnG8OKa5Ny54VR9kgJnx96?= =?us-ascii?Q?2rJXj7hK9fjp+QeHcFyQ4PqNvcn/tJRHvsNHpvNWRQ5RbpZ01Z5pTDaT6+mf?= =?us-ascii?Q?p9z+o9E+qpIe0gdL6j++gXIFOQl9g/p5OdADN/8JCVGXZRk7nuq1zJhFRGfB?= =?us-ascii?Q?Fz/5wTyve01rVZ0vY4X65URJEb2bcnAZsKEvpHk0YoljpD7X/QnYmFPLRoSQ?= =?us-ascii?Q?QlMM1iRFujmKoIGliu7sED48/pWSU8oG7RafPlTlM8peH3ZPNzM/06MhpI+p?= =?us-ascii?Q?HEmbyFe7agyR6HH6IFcVCZBTiOEyRtafEoUoLDx8ac2u+b1nCsIijtKkik5T?= =?us-ascii?Q?R3hYL+V/tqdtugGrJ8jJ5vn5RQiJjWkdZOMob2Mk8qDkXpu1Q0Ou4Wzj276I?= =?us-ascii?Q?2OiFcEsw7aoJFGrOeIpoo59t19wSd3HQjSS8a5VnWvkCdshVCeWZj1HuVzVz?= =?us-ascii?Q?/9OwnTYp7oKRikoPQMD792P4LB9+E87HmegajhCPNmEGltk4KFLV91aweFoK?= =?us-ascii?Q?pbKe5rS6uE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: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM6PR08MB3256;7:AK2/w7w7qz+455zBotX2kreMUpvLD2iQBUwEbAxM5COALHcJ/m0OFuF3LX/WY8K7WdU6kJv2Lovp2Q7DhSMSu+e7ts+ZpCAKOZA4snnjQsM1nNtj5OlJRTYgevH+tVifp3kHc7px49QvXKsvXaih/4D4KI+AhM26wZaqkl4LU4yC3IETSS0XWOJo5JDKEz7gKKM5z+ZYG/38GAnINWLJFxgWP+u8VrD4ojbZvSRTIRBwmBJBsyoKC0qEKH2fzVQx;20:Hf2lVE0/khMOjNVnpX3LxDe5823nE/5TVCamR4/fblBP8/uX7YYtImEeQLso4r5Cy5igUz2OEVLTMAGoYL0D/xTgwzs26QqGGmgCexX70rhVmSjHeJ3KaK39Ted4S53Qrak+kV2KfvSBzlafuojN0c6589rAKouDcDGd/Qjoqy8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2018 18:43:43.6912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bec025f2-a2b2-4b97-4416-08d5ddf03dee X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3256 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed integer overflow is undefined according to the C standard. The overflow in ksys_fadvise64_64() is deliberate, but since it is signed overflow, UBSAN complains: UBSAN: Undefined behaviour in mm/fadvise.c:76:10 signed integer overflow: 4 + 9223372036854775805 cannot be represented in type 'long long int' Use unsigned types to do math. Unsigned overflow is defined so UBSAN will not complain about it. This patch doesn't change generated code. Reported-by: Signed-off-by: Andrey Ryabinin --- mm/fadvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/fadvise.c b/mm/fadvise.c index afa41491d324..1eaf2002d79a 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -73,7 +73,7 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) } /* Careful about overflows. Len == 0 means "as much as possible" */ - endbyte = offset + len; + endbyte = (u64)offset + (u64)len; if (!len || endbyte < len) endbyte = -1; else -- 2.16.4