From patchwork Tue Dec 29 21:26:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Randy Dunlap X-Patchwork-Id: 11992663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84C0EC433DB for ; Tue, 29 Dec 2020 21:26:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 020E121D94 for ; Tue, 29 Dec 2020 21:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 020E121D94 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4F0848D0041; Tue, 29 Dec 2020 16:26:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A0A08D002C; Tue, 29 Dec 2020 16:26:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B6088D0041; Tue, 29 Dec 2020 16:26:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 25F748D002C for ; Tue, 29 Dec 2020 16:26:51 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E0638362A for ; Tue, 29 Dec 2020 21:26:50 +0000 (UTC) X-FDA: 77647604580.23.song46_48072682749f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id BF83D37606 for ; Tue, 29 Dec 2020 21:26:50 +0000 (UTC) X-HE-Tag: song46_48072682749f X-Filterd-Recvd-Size: 3116 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Dec 2020 21:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=hoh1jwuAHk2NhOLKPgomsC/sBn0dqjmZHnGGGkw8rew=; b=NViHlHQ6d5fbryvIeLA8Q/Pdue D7bxqSN0B9/eGKjXupDSSWvEfW3xHzkpQ3b+KJaVjk2H8SqzE2Lhe5/Q52JMfPlm5oXIeMtRfNVL4 f9SobVXHtIbe7Z5jRPtbYZ3PDnJGxrsX4Uj4YHrOfZ67Qyy1AUzzzRUvR18vireLEl6VEasYh5h/n HM7PdBx0Bh+VykINOkknGsc9xpLpZaTp76vR51wIkkkohMmgjPHUhgvF+MmiPOiytmNcC8TPzevZ/ FpNCIkf8MFGX39FLvmZvhBLReBbsxfslFv3qV3BIM3ACciO7s/hLt+LVVOgkn5w5HRIohxcVbNa38 ZDSHuUew==; Received: from [2601:1c0:6280:3f0::2c43] (helo=smtpauth.infradead.org) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuMVr-0004Dx-UL; Tue, 29 Dec 2020 21:26:40 +0000 From: Randy Dunlap To: linux-kernel@vger.kernel.org Cc: Randy Dunlap , =?utf-8?q?Toralf_F=C3=B6rster?= , Andrew Morton , Jens Axboe , Matthew Wilcox , linux-mm@kvack.org Subject: [PATCH -mm] mm: readahead: apply a default readahead size Date: Tue, 29 Dec 2020 13:26:34 -0800 Message-Id: <20201229212634.31307-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: UBSAN reports an invalid shift size: mr-fox kernel: UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13 mr-fox kernel: shift exponent 64 is too large for 64-bit type 'long unsigned int' Original report: https://lore.kernel.org/lkml/c6e5eb81-680f-dd5c-8a81-62041a5ce50c@gmx.de/ Follow-up report: https://lore.kernel.org/lkml/0c283ea9-b446-0e40-6dc8-e9585ae171b4@gmx.de/T/#m9b604660925f9e8a544f7453130c31d083c1e5bb Willy suggested that get_init_ra_size() was being called with a size of 0, which would cause this (instead of some Huge value), so add a check in that function for size == 0, and if 0, default it to 32 (pages). Reported-by: Toralf Förster Signed-off-by: Randy Dunlap Cc: Andrew Morton Cc: Jens Axboe Cc: Matthew Wilcox Cc: linux-mm@kvack.org --- mm/readahead.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- linux-5.10.1.orig/mm/readahead.c +++ linux-5.10.1/mm/readahead.c @@ -310,7 +310,11 @@ void force_page_cache_ra(struct readahea */ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) { - unsigned long newsize = roundup_pow_of_two(size); + unsigned long newsize; + + if (!size) + size = 32; + newsize = roundup_pow_of_two(size); if (newsize <= max / 32) newsize = newsize * 4;