From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 1034325760 for ; Mon, 13 Jan 2025 16:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736785356; cv=none; b=fO5+0YMtD8+uo96Y+Y1XfONd/Hllq7/uHgFaur9HrEaK6hHZeKTY5DtmepAdzcTiFeApP07IOQ9RAUt/K3smlObt2N0nytgPjt2RqJZlopdjio+l1WkB6iCP18O15+Uvg3CHvbfc7afFLI9u+BN0T2D9QwbnjMB+8KFU+vZzB1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736785356; c=relaxed/simple; bh=N6oGsVDXTz5YZotXLQU0Nv9iMnfaBqCIK2D9veUOWUc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y2rixvJ6ngjDRVMsDHP07SObaLn3ZvJEu/ob3pC67vKdDy7FCdvf/zPExJjKBZKHwGqA5122ylWIGe1OfRzUhcSCFYuafWkGM6LL84CcKg4gARg9pe8oKOkHvwvzvxBnSxUq19VhA1sdjY2+hEZP0r0McrpWHo6BEyIb/x3D5EY= 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=PeMUk/Ew; arc=none smtp.client-ip=209.85.222.182 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="PeMUk/Ew" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6f1be1daeso400207585a.0 for ; Mon, 13 Jan 2025 08:22:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1736785352; x=1737390152; 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=Q9Y1wAhknpKwAL+LxZwAdihxQFCeEbr4gwAfjxkCAMU=; b=PeMUk/EwWVtr2A/f6pyUAooSGO5gtx8QMa834Zr+tSrZgRPiZZLA+T9E8n32laj8wi NWPsykErnXYQ+BgyJlng1VmVmPtp1znA7Zv786kVWemAtHMN7qN/D+pwSBOYAfMNbYpG ANZqTQLQIzVtvoeCXb3J82ZW8nmHGSzwWKmsawPZ9oOSNPZUsemehj8fANhJEcnz4mos AdRBwRGkpIBWvHivYjV1Sngn4j4QKoNeB8GexoBjJxY5VpIWhWyh1hDSJcDEJfq6uaqA 18lFdAv/nN8o/EsuSnSAE+dWdTugmBkCtWCDMWL+1iDJoIKcPYIUs3Z02c5J1raD7zIy bjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736785352; x=1737390152; 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=Q9Y1wAhknpKwAL+LxZwAdihxQFCeEbr4gwAfjxkCAMU=; b=Dk5NSi/BgrKRJvwZPE6tuV2j9+r3UvLBG976Z1mjL4P/++B9cS0rIra7FmA+VSwhBk D8ywJBzHwrMXvm59YT8OJIV84EIBJ0WcmnW/0hxnp7pEHa6RypCSaBHFzIVcUSCzySKe YH5pyFsZxKrPwvcMc9XmWVeg4EV5wn6zpBsHWidAnZV0CoTkLeVGARc+OQ9jMypNrsbb veS13iJFsKvxO/UpHuQ6Q+J7+TmUgfRujuTxEz5GvZ21ujQhF4W0jicMpRsosoqjXdG4 8EdhebBz6fPfNpPXoxsdYOjrD0cQrt+8WE+GwQbjbAOn05UDS8knFwijHs/LBGAGMP3R Zg9Q== X-Forwarded-Encrypted: i=1; AJvYcCXcnIXeimyRulQ7A4wUceb0P1J1nSpw2/Nd8HlrrgdtjrtS1IiMkbbHZ2QKZeU5RxwtC2QsIRl2OpxtPQg=@vger.kernel.org X-Gm-Message-State: AOJu0YyO+T+69EXWjkERPV/bzrThORK4RxP7CAkEjXbbeuV5Cff8vq0i BR+xFEOgZKavm6PRGNAR7ZUvv+rws/wdWM0UYjs+cg4/L6JZgsNn8UPZWmVDt9A= X-Gm-Gg: ASbGncua0TkEtNELLJzrKVAl9MZ4Fk9PDJU40DDhS7kPMTh9CXfuEdV5PbPaTyxhmYH tinwsxfmo5GQRtDXT865YT7knWXFOZYCseslSamYn4EPXXJq8paHK7NUcPt/E1MDSRnJoCNY5Tp gxjmeIRwhZ/Oo4nYx52Leqb4DY5fO9VN7Wd5REwa0+eN11oaYJ0ltA86v545rj5RotaCyBMkm4t P3GqrtRqRpKwaJ9CL8l42zM2edDFyr5JCTOp0+U/i4p6D0/5XYMfIFbsuXvr+60SbDlTyqps5nC kRxRl3gp6u6VA5r0f8eD84uZ5S4xaw== X-Google-Smtp-Source: AGHT+IGuPCT1ln2n6Nf8zD9iikzUE0mYU2iIb13AOtbY5Dv0pUxewWhp2L+gz1DvUWP8tgnL3zljhQ== X-Received: by 2002:a05:620a:29c4:b0:7ac:dfed:65ee with SMTP id af79cd13be357-7bcd96e5ffamr3235887885a.3.1736785351877; Mon, 13 Jan 2025 08:22:31 -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 af79cd13be357-7bce3502aeesm507130485a.77.2025.01.13.08.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 08:22:31 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1tXNCw-00000002FfS-2OXQ; Mon, 13 Jan 2025 12:22:30 -0400 Date: Mon, 13 Jan 2025 12:22:30 -0400 From: Jason Gunthorpe To: Joao Martins Cc: Qasim Ijaz , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy Subject: Re: [PATCH] iommu: Fix shift-out-of-bounds in iova_bitmap_offset_to_index() Message-ID: <20250113162230.GH26854@ziepe.ca> References: <670871da-eae7-4052-abc0-92f90e869790@oracle.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: <670871da-eae7-4052-abc0-92f90e869790@oracle.com> On Mon, Jan 13, 2025 at 12:00:29PM +0000, Joao Martins wrote: > On 12/01/2025 12:39, Qasim Ijaz wrote: > > This patch resolves a UBSAN shift-out-of-bounds issue in > > Avoid the 'this patch' e.g. Resolve a UBSAN shift-out-of-bonds (...) > > The Subject component part could also be a bit more specific e.g. > > iommufd/iova_bitmap: Fix shift-out-of-bounds in iova_bitmap_offset_to_index() > > > 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 > > Signed-off-by: Qasim Ijaz > > With those two nits: > > Reviewed-by: Joao Martins It needs a fixes line too Jason