From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 D5C0F1E3DCC for ; Tue, 14 Jan 2025 17:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736877247; cv=none; b=tNGKLlmUGBTw7fwLE5dxfIQQheD5A7vN8VFrbQiHjCN3CqJAbTcop5mzconkO5rP6P5wd89ZbbZ+37t90gXQbe/hK6T4cXwEruNE9C76HJ20eQoAet6DyUGSMloOHNExV/nNFWUSYN+dBjarnFgiEqcBBdXvi3aEHcIJM39N3ZU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736877247; c=relaxed/simple; bh=kSuJ3mN9wNcjimoqX2+ynSqvhqVDCdhDEuVwg4Xhe+U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fckppDhBATBasXffVv8fdO298Q+uATCDqTyD64GkB2waMaV71Pr1ZZ+bMa/9cfbmnB7Jj9W8BYh1dxmvx6Ghiatu6lUj41uHlocI6IldiK5YASPhSAWuCiUdrncadrSFhD1pTU3igDTjamtbjLxckdUVhNT9ewi9DCoYfbwg0OQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=c26J3MR5; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="c26J3MR5" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6d8fd060e27so46681226d6.1 for ; Tue, 14 Jan 2025 09:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1736877245; x=1737482045; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mINefyrdNhvGcAGjffpVPeJdsAxn2rONefBHfd+bibg=; b=c26J3MR5Pv1LvHbgw54ZWXQgMM9+q42mPoKGXIC0cRWaDSSSFuaoP6mWVY++TnDjRe CQtraN4aYLcvcxER8oF4Y1bzEwpYN2DwFwgeeIDDGUz8ZS7COucN+jntSiqG1jbsooCP 0C7sqNym044h9V4KBsdmq/PvOOkQUYNmkCbZnVDspjzI0LspCatdk1VP6ijRw6phP9yD s8ftB2139O+H7AXZ3xADRNxkmz2kuiMi9XmVaEUY6Lo3Nm+3MsrLRJGrFAuKOFLkresn +ypTcBllPoSdAewo27WbuZ6tvIoNENEBe4W1wgb0RB0ZzDCOy40IfLBB7mv9eFN29l0U kRmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736877245; x=1737482045; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mINefyrdNhvGcAGjffpVPeJdsAxn2rONefBHfd+bibg=; b=v53GtpW2bL0SK7kZBOzYgnajKP11NxFRvQNWtS8pmNqgfpHwhraAZUNucoQW5x6UIA ayCFNFHWfHPY6ykrO6Zmu5LAMrU/j5PkteDSqnqEjhtg6WonmIEW0IgPtFpHfnvSJ3FW kJiNxCOtf4SlU+mxXf3yGMTS187FxDLdqFA9iV6o/B18TEJRAR5ei1RT3s1/GH3niav8 is2G1K5ersx1Czw41LFux+BmP5+DsRdZn9BqCshu15V3dqlTkEUUBwFinhlHgc8IqZDt 3flj0a2+7/vgl+XCq3Q6cPOJXGDMD8SmxR1zFr0Zh2w5l39INXR4ht9iHsDnAN5E4aaF q8AA== X-Forwarded-Encrypted: i=1; AJvYcCVtQNltOYIv9ZtmWgOSxNmrhqnRO1fFHOWkWawcjtnjR04/eoV3C5xksmj7MGeUas1za4CU91RosotEMkQ=@vger.kernel.org X-Gm-Message-State: AOJu0YynjrJwFblXKIjxjcQqMySyn5+ovh4Xu/35r8mo950beNZRLR+M dowNiQBJdeWsSx339BfvNGola7qXwBbs4Rwp+Hl6wt979GZq6ls5gJJxXtLMHSgF22d8adxfu7D Z X-Gm-Gg: ASbGncvD4aKlOflFzVaNTtv5+WW8yeXxznRvG9D+FtJ2wylKme5/qh4m1ITtab8H2dk UQ14ldKWM3Ze14nMtzCSNZ/NO8gOCYZMzt/qDYeys1SEjbkzazHvVrwwg0dsm4zitWYliKCRnVX 5AOIq/dEElqJJ9apmgtiidzAi8+4T4rE76Qhl0vzI55lrdXMzerd6GGjLidF+kuQSonkbgZzvlp wUWBPvJ2w58bOQctkEo/1dvX3Okc5zoGsldUoUkh+z2exYF/c4LcjIRoWVb61iXaBepTJm84jL8 aoSZ8s1LhSweqjyWEz3qcgQCipzeVQ== X-Google-Smtp-Source: AGHT+IF0bqJY679rWk3hHZZyqaZ3/i8agMtreEpHxxrVchKDBg/QKPQaM5QFHOuP3wTvHa0TYcOpvg== X-Received: by 2002:a05:6214:495:b0:6d8:a76d:b66c with SMTP id 6a1803df08f44-6df9b2b33b0mr347773016d6.30.1736877244760; Tue, 14 Jan 2025 09:54:04 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-68-128-5.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.128.5]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dfade89277sm54792846d6.108.2025.01.14.09.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 09:54:04 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1tXl75-00000002P9t-29DO; Tue, 14 Jan 2025 13:54:03 -0400 Date: Tue, 14 Jan 2025 13:54:03 -0400 From: Jason Gunthorpe To: Qasim Ijaz Cc: kevin.tian@intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, syzbot Subject: Re: [PATCH v2] iommufd/iova_bitmap: Fix shift-out-of-bounds in iova_bitmap_offset_to_index() Message-ID: <20250114175403.GO26854@ziepe.ca> References: <20250113223820.10713-1-qasdev00@gmail.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: <20250113223820.10713-1-qasdev00@gmail.com> On Mon, Jan 13, 2025 at 10:38:20PM +0000, Qasim Ijaz wrote: > Resolve a UBSAN shift-out-of-bounds issue in iova_bitmap_offset_to_index() where > shifting the constant "1" (of type int) by bitmap->mapped.pgshift > (an unsigned long value) could result in undefined behavior. > > The constant "1" defaults to a 32-bit "int", and when "pgshift" exceeds 31 (e.g., pgshift = 63) > the shift operation overflows, as the result cannot be represented in a 32-bit type. > > To resolve this, the constant is updated to "1UL", promoting it to an unsigned long type > to match the operand's type. > > Reported-by: syzbot > Closes: https://syzkaller.appspot.com/bug?extid=85992ace37d5b7b51635 > Fixes: 58ccf0190d19 ("vfio: Add an IOVA bitmap support") > Signed-off-by: Qasim Ijaz > --- > drivers/iommu/iommufd/iova_bitmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied to iommufd for-next Thanks, Jason