Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp193909lqp; Thu, 4 Apr 2024 10:19:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWu8Zi9eNZOGj/GtQTHqO3IB0glp06yA4TgMYt4nU1aVrZ1D7LVTY4HcRr81tU1PssHS3z1TKiBmcuplQbxcy5dW+ntGSJrsWdZ2R0B+g== X-Google-Smtp-Source: AGHT+IFYboIIF8HJFBLiOgfC6zisJyDBjaFWJeTWepaEQEYv67ue2hEihzvY7ag2n91qskPhNmt6 X-Received: by 2002:a05:6a00:17aa:b0:6ea:bd59:7eed with SMTP id s42-20020a056a0017aa00b006eabd597eedmr4146264pfg.14.1712251156127; Thu, 04 Apr 2024 10:19:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712251156; cv=pass; d=google.com; s=arc-20160816; b=u0GlTjAYhkYOCdeL6v47ThrWtO7MLKios15Ca6iNeFfQEVCAWAaZuY2LMug3JxrcfX zf1xR4FTkE84DxRg5oXiCdCJeK9CJ0rYtLqRkJj26UqM9mtxX/hqf4jfjihmiKytZPJT VBZN2s50aKjMXEtbR4hXmTYTehFMv4i6Tdi9pFfk79t6TGMVTu928mcB4WXL/DxeqV/v REUL1ZCAZ6I/gK9Y9ayaHdkPYYBX5R1zM0nLCg63BSK0lcqabwx1cX62+UHfxpAvPfmO xoId+XNiq99ey6CTJAdAMhUfLHOV+0ExI6eLqBZHvmugAo69Gyn1r9Vq7HrpytZWbrDh ffgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=u+doro/JaQHck4vMp7NZSZdSbRh8luRKNIbrvkM3+ZI=; fh=p8RgLhJl+sIWK9Bp80JlLrxjRbdctuD7TBvdrndCNKk=; b=S5e92DK111txO4JE1mXhhirTImzJY726sRilduuPYmyZSI2ZNcRGAhOzR1jJSnMYOv /TtiWhFDjdrDhXGylimcUs2pP8VEa5e6TGVGcSsukmtBWmDcjFGVB0I7O9oHm1kKr+76 vO3z3oTvWMgPVGvRAfNYrFBoLTDRl/Cb09saEBASii3LPfeJkbgkDb5B5SpBTHef0BYS YcZh5fikBCyCCoi+o9h42xaBpM4LHmEYCLCb1AjS6bN1vUZXs/QL3f0uQPZhUKCzzvwu DYe8E9hisQ9pNfMP7JSMbKZbO8w7cV9ni2x0776JWiQ45ec6BWKj+A9gmkeYrwa8bEb7 uC/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ePLEgrRq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-131855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r13-20020aa7844d000000b006ecf39181e5si1047622pfn.352.2024.04.04.10.19.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 10:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ePLEgrRq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-131855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A7D36B250B6 for ; Thu, 4 Apr 2024 16:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75621762D0; Thu, 4 Apr 2024 16:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ePLEgrRq" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33F481CA84; Thu, 4 Apr 2024 16:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249515; cv=none; b=geZy/lTAnCk7AKmllpwX+uIpoZT4Gi2bPz0M9faB6JBYtYRhrEqB26aK1Vm6Chw4XDRw3rFI1QrUg35xdjipKizRCnE6kPi2wVh4cin6ImaFU5ZFvEoTKPRyjS1FHTTno+nsSCr8PfJ3K701fbLw9C7d+ewwWYdQiQNM9yTLgbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249515; c=relaxed/simple; bh=V2lamvqHqNnSBRfVpeT+opmreN/o/daYr1FfZVfNalI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VWpcSXXD+6P5/693RsiuArRUrQlkUeo82ljs0rqwDl2aR6ptMr1aMuE0XExsh9WuZxZ3FJ5jQgUFf+LyaTUoRiqEJRC8YMKqI97xulCLK/QCA9KslOy9mDN8yEXrrylYEoiu2TachNto4yZFv5KzmilF5wCpkfqeWZAWI1xlLUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ePLEgrRq; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e703e0e5deso1074052b3a.3; Thu, 04 Apr 2024 09:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712249513; x=1712854313; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=u+doro/JaQHck4vMp7NZSZdSbRh8luRKNIbrvkM3+ZI=; b=ePLEgrRq5qS2l4/W9QrhuGCXcuKF/PDZ+HG32kP/okLEZ1utsP5OABkrfgRq+sPQIn bem5E/E8izaYjVrlxxEpdPhdThzBomhv/TUylPyW1Q2MeMDDCF9mu0uFZ+RsNtU2j5FK NjjA+5T8+lT3+iC9ZjDcUTbFAZ8Mig/B1LHsUTmQDlSBLcRiCNdKYDKO3Ht4g1SHeOSV GNaovkpA/tzaN1QLy3I5yST+NsFzvLr9npixawAhAkFjYXDNr7h5oaqEARSYxOQv5g9w jouEICDSgpxov4fRjMmPwA8jOqaKtU9zDKsebJWCvF3OFo/BiIUrosXS/PaNULEalN7e rVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712249513; x=1712854313; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u+doro/JaQHck4vMp7NZSZdSbRh8luRKNIbrvkM3+ZI=; b=YludtTOWiBTCPT1SfmWaPDPUYXBUhf3wYDsa/CQS9yaNsioxNd0wGra6AKPyf2U2jn RbkiuscqqI/DdowH4smuq+9DZbhWagVJnYcfsUhqZFZxdrsduXLYXo2vdfGQdg7IbhYb a9axav37xc4+9KT8pU7B17LPXJwELvfrvS6yMC1RTkYsENNtvrfDpSjcTF+zScEbigXw LWWxM1EZV25D/ImHwWdQo5SfWolW65dSAmE2ERipk5UNuDB5Tb2Rtd99HoLfW2d0M4SA JqFQUlV750k8e3AZuWRYZjeptbpNDamcyPzgBX2SmBrzFg9yOBw04Tjwl6tyI4AJ66A8 dW4A== X-Forwarded-Encrypted: i=1; AJvYcCWCVskRZf+SOavQ+qHVU7fKw9y7wVoXE99wsUpVXs3O3vIRAUMyW1aNd37iFUSR+sXQ6jU00kHLE+wR8Zu+INcax6nrSs/Ffo8zWB+/diBFoX3L3+C//c4xL6cJnM9r035yXbK4 X-Gm-Message-State: AOJu0YzWFUbSm4XmQAksIOcz1w7wL/c1Nhcrs799hIuJTYHi9uOeNwsg 1+qMZ0wVo5Wrbprdq3xHabL/avfXPcze1dRJ+9Ja+AwPfoKAoDm3K8Pjp3VY X-Received: by 2002:a05:6a21:3403:b0:1a3:32e5:f38a with SMTP id yn3-20020a056a21340300b001a332e5f38amr2842687pzb.45.1712249513321; Thu, 04 Apr 2024 09:51:53 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:25ab]) by smtp.gmail.com with ESMTPSA id x7-20020aa784c7000000b006eae2f3c7d4sm12497975pfn.102.2024.04.04.09.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 09:51:52 -0700 (PDT) Sender: Tejun Heo Date: Thu, 4 Apr 2024 06:51:51 -1000 From: Tejun Heo To: Rik van Riel Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Jens Axboe , Josef Bacik , cgroups@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH] blk-iocost: avoid out of bounds shift Message-ID: References: <20240404123253.0f58010f@imladris.surriel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240404123253.0f58010f@imladris.surriel.com> On Thu, Apr 04, 2024 at 12:32:53PM -0400, Rik van Riel wrote: > UBSAN catches undefined behavior in blk-iocost, where sometimes > iocg->delay is shifted right by a number that is too large, > resulting in undefined behavior on some architectures. > > [ 186.556576] ------------[ cut here ]------------ > UBSAN: shift-out-of-bounds in block/blk-iocost.c:1366:23 > shift exponent 64 is too large for 64-bit type 'u64' (aka 'unsigned long long') > CPU: 16 PID: 0 Comm: swapper/16 Tainted: G S E N 6.9.0-0_fbk700_debug_rc2_kbuilder_0_gc85af715cac0 #1 > Hardware name: Quanta Twin Lakes MP/Twin Lakes Passive MP, BIOS F09_3A23 12/08/2020 > Call Trace: > > dump_stack_lvl+0x8f/0xe0 > __ubsan_handle_shift_out_of_bounds+0x22c/0x280 > iocg_kick_delay+0x30b/0x310 > ioc_timer_fn+0x2fb/0x1f80 > __run_timer_base+0x1b6/0x250 > ... > > Avoid that undefined behavior by simply taking the > "delay = 0" branch if the shift is too large. > > I am not sure what the symptoms of an undefined value > delay will be, but I suspect it could be more than a > little annoying to debug. > > Signed-off-by: Rik van Riel > Cc: Tejun Heo > Cc: Josef Bacik > Cc: Jens Axboe Acked-by: Tejun Heo Thanks. -- tejun