From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 E263F3B42D2 for ; Fri, 26 Jun 2026 22:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782513505; cv=none; b=IUY3CrMbpD/DbnTcT/MH3sJY0LfaBVCF1z3IcFmOIP+8BBTClrltrRkQie5PfhsfA055srGVCzcG/HoIDfdG3Ie0VHCNs3XUwZeqY/FxzrVjWTI5QPc7cuirveGuEceObiuRpNCHwIvcc/rcMw2Ni9TOFTC6RuV7/xoSsdoeikU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782513505; c=relaxed/simple; bh=ehfjVTHHrqbWFAlc6EFBTmDtfULwXvl63xM3YUjLyCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l5mmx6SZluvxBmhoGcPHUW4Xx2ZtTkGKS/qqM9WNAqiOY/NWwXoEwGDJZHP/EK98MrboA4T659mgxo4TJCSe5p2dd/evpKHk15BCAT3xphx2NsyXQO/wP3sPOFhsmGyHxF36g8mTgwY9lFsf7rGn/dt6j9khaB0GD3JlzWoZoYk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k5OBAVy+; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k5OBAVy+" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-80bd5b5b3afso12594877b3.3 for ; Fri, 26 Jun 2026 15:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782513503; x=1783118303; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UHjctOwAHvr5B+KSgeGZUSJFSThxaO6hOxTWkkNP1po=; b=k5OBAVy+dLQhkaUCdW/08fqcanAZwuH6IOV6Jj4cH7jHzuMEKLcqLV0/iDdcJ4aR3u xqzIKKfGfkJOx3myhDWuzu8f7/puttUEurVriLMvnlbKGKnJE//YIi+5cy9hhOOb+4+U s+f961DxsVLmk98R2PbMgxTWmgy/cz6WpjiOvYLVh0zNSekqPOdAgSLCA6b1Kw2RSqg/ d6B5LzOBjXJXdkCGQV8sVZvTwKucXFF39gZOMUTi6g8L2e3SFwZ33KngVKs3CgeuNO4p 6Cj/3CTj2RlnQWd4csj4DwrNKPjQT5P1dHalbQawdYO+BIiL3DBrokGGa2I3WxNVf8Ue pgDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782513503; x=1783118303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UHjctOwAHvr5B+KSgeGZUSJFSThxaO6hOxTWkkNP1po=; b=gXSh7WHbQXcL8bmSztcdv5q6DvBjyn2LqwGFnxYZMsP+QYWjkgjhc0OpVt44R9nrAN +gY4ouov4Sv7fAK0ZzK6GfJnnZbJ0dbUQNmCfj8pUFTgThy9VZQ68318F9AX4X3vAuIY qNsTlmTBGUERNwYd3LYYyclI1ZwZZr0S/+sBDSHxYSqJN9ZzSDHcCoyY2XQdEJLVDdcY 7MJyj/7EnXYGvK0DEuur12lWyG6eOZ3XkmV1oqH21+DyDip13AAHALw+718L9X092jg1 rFfSKaU4CpqLoSWoNUDxkc9j+IEgKzPyy7M3AcW+0Ht5mxg4epNlr26Y6KyMbnJ4QfTN q/nA== X-Forwarded-Encrypted: i=1; AHgh+RqR2LWnFM/mwdTdHtrY49wT0/FaLDsNpaQbeWPd3cuc7xPemV/cJ9m2jc7M6pwcWjiu4c0xTz9r/l5hvhg=@vger.kernel.org X-Gm-Message-State: AOJu0YzxXiEjPobgbddvSWbfwWE+6c+7XMqCVG3furf3vl7K3z4zQGxR GmOg1yCoRiBkjeh3501zlWw9oW4opGfLEBvncMJMHAe+BHEj8xlB0JWw X-Gm-Gg: AfdE7ckQHtzqJmehwbU1UyLELBILxi95oeA8RoIWbYjpIecjHrfVFFw+8arLmVFMXXu iM4F5JFaUEB8t0mSpuRyh/fYwX7DKBcEv4bprP6uAy3KGmatPQOFkp0pSizUUxJ+PB74QVAUy0J k+0f/qXvHjjEsAgX5PhmtyzMnutcMwkIIXNFMcFQgZnEQYhV+vMRA/QAyaoT8V70SKXRxbFoMQr JeGjFAnpwuLeNru0Q2zb5VxugjHhZkW9oZeC1zPoeNgtEjWLngSVPCF6ZXYNYZxJdRFgAEespG1 +owPjXcZ1iaT3PcRuoX0cnH5RZvRfEOKIzL3wmJJCYJZ7Ay2arNwvQ/i3XXPRdQH5mgoLxgnoX7 KzefEpWLF0rtlmdoTZ7mwpsVryvibr+rYUi36vKi4vx6ACkpZfTEOu7cxgnNjphlx+bkr2A8KmO /nHZKZDxpndCFT/DC8pRqN3e0JqA== X-Received: by 2002:a05:690c:7208:b0:80c:85e5:8743 with SMTP id 00721157ae682-80c85e58a99mr26080157b3.65.1782513502844; Fri, 26 Jun 2026 15:38:22 -0700 (PDT) Received: from Dev-Null-MSI ([2a0d:3344:52ac:a808:98a4:4381:be45:536f]) by smtp.gmail.com with ESMTPSA id 00721157ae682-80abc3d1734sm23177557b3.15.2026.06.26.15.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 15:38:22 -0700 (PDT) From: Yousef Alhouseen To: Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Yousef Alhouseen Subject: [PATCH v2 0/2] xen/gntalloc: validate grant count before allocation Date: Sat, 27 Jun 2026 00:38:03 +0200 Message-ID: <20260626223805.43781-1-alhouseenyousef@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260624124745.10073-1-alhouseenyousef@gmail.com> References: <20260624124745.10073-1-alhouseenyousef@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The allocation ioctl currently allocates a user-sized grant-id array before checking the global grant limit. It also adds the requested count when enforcing that limit, which makes the check harder to reason about in the presence of mixed signed and unsigned types. Make the grant counters unsigned first, then reject impossible requests before allocation and use subtraction for the locked limit check. Changes in v2: - Split the unsigned type changes into a prerequisite patch. - Remove the signed checks and unnecessary casts. Yousef Alhouseen (2): xen/gntalloc: make grant counters unsigned xen/gntalloc: validate grant count before allocation drivers/xen/gntalloc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) -- 2.54.0