From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 5FF2438F64C for ; Sat, 9 May 2026 09:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778318851; cv=none; b=arHp77fpxB8+KcDxoRf/tDNAG9d1GvueeuPiPj+7A8ZQcJeqwRuzNBZ6gRrXQkMYU4KnjskYmOH2krUu/u062kgRdlNtHtI2fvt9xVKTmaL1ikWX9b1a0tCqGg3M6q3F2YeHTCwSlAtfJSRR6gw0P1/0U/v5MBRDzb0RJbM6Ztc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778318851; c=relaxed/simple; bh=lHIfUfoYldIKXo/UX6z7lcvZXFL6uzec1GWs/aBId0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=niLj2CzM6CHGg8348SC8q2OrIPeNhIOErZhfk+RCpD6Ea2DMEJEBu2UN/1PD3PCySqtWkSl5vXLl7WiD4//xmtG6zh6KuFMpvHWOnNnzuf9EWlq4Sp4RLyLqEEBj12/pm8rBD+FapqjHNpmSqzHdGj8UOlDZh+V1AfxkKw0O1+Y= 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=MlPK6OuL; arc=none smtp.client-ip=209.85.214.173 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="MlPK6OuL" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2b788a98557so20889005ad.2 for ; Sat, 09 May 2026 02:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778318850; x=1778923650; 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=/fNKru4wcaLCJfeGMBIRpabwgz5gQjSTUlQZOu9/T4s=; b=MlPK6OuL7pkqOOYwku48kD5qw5TX9ME0NSqUvqt3LmVWwU1UQVbJVUAjUaOlct8QgU 828c9m7cWzJr1E6ylMJKtxIfh36r6Q1kU+qDhTRMVzZWW97qJWQB9bTDPnHxOd/7u/Fu 6YpuIWZG01097jPL8ZV3v5snpU7wGsWpayEAy33YY2H2CBMPFTKmmtGqWaNU2nZQ0dal QzAy++G+wW+C0HrHKu7ZkYTW24uV2qLx5R/8CTBxcXlnOALNHWIcqs99g/ofXXWySz+/ jifFi26/fiok6DbUTACO4TUPOpE3rE3Dlb/szPU8yby3Dwzuvb0EChMe6+AZ0LVntH6V ZdpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778318850; x=1778923650; 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=/fNKru4wcaLCJfeGMBIRpabwgz5gQjSTUlQZOu9/T4s=; b=sNEG0dtHhr1m5fj809uh+7Q2UHv+Nrle+IIb/maRYHH0LyquUmy8ZdlEzk4OCN9+Xa R4jnIaLNPifJU8B7Qws+5TRtsx6DCc2odLN3AITGXrqT8ZR5VxnRiP4QRBrGEvXAXNZe 5VeX2jQe3YJnWcgvGpvd0ba2qAoGvcrSGJ7vuEFiaVrYilwv6bzCYHPYfeZrQLpdxnBu +HUbLITclByhdTruspmmLPS52zDw1NRbOuU9MUv/M/OlhI/TfGXt93UTAIJgMmXoX2HT x4O9ifeImt5GPl7stGgw0j2D4D7orj+wdVjqT7j6r/0JhSMCc9xQLnFUCLKGOpxIa/9K XXjw== X-Forwarded-Encrypted: i=1; AFNElJ9Y0EBL0woB4xJwFj/BCsaktDvJyR3HUTc/oMTprRTcd56OFpaDBRHtAIngnhdjr+wfDL9+3bPHPCxlLjw=@vger.kernel.org X-Gm-Message-State: AOJu0YwkKGthiW79yloxa0UWsASnQva+tvhsadKwnWFOxapLWBjyUG/D +p88PCuu4zKObSeVPjzBCTpotsRLp0/FwXSgmqJlgwhF/Rzaz/r7nAms X-Gm-Gg: Acq92OG+tpCd9vqgvtz8KiyZf44pg++BQeB32t1aSyUH7cpu/BM5WNmN3M4xbgXFE4t oz0b9EooJqwkeoKCak1AmzjzgoyV6zdAyVC+9/RzpPgObn1tHL8DILtCx8T1Oi4vZOUQl4ROshB rZOG1wEVgQA/TW7g1HeWeoZfa5ua3Nw5xOoHVxelN7DoIRtWRovHZSRU1f6CFtDcbaALmTrZON0 wUytTI3yyBJqIen69/AiaEtENm9yiUd9Qe6j3p6pp3opPwh8LEC4cSJpaxaJQPUS0J3iW52lipr sxAtLPv1GWAwB1nzZ4y+dZC9RXLiriqNDj/h5JZ3xF3gBo6iwhEsJQRg315gEjFx0+Ogpuud92y 1FA4wTp8T7bCOM22iSXNhNlUoanrNIulf34UM1p0coa77PJtYd0PgzKIR7oW280/1kDSaqCn1Yo Fp8nCmUNygp5SjhRl9zx7PjuuLH3xEndjErp7TVYEnQ4p5Y9PSF3VdxmnIBLP/+Q== X-Received: by 2002:a17:903:284:b0:2ba:6ca2:be0 with SMTP id d9443c01a7336-2baf0cf3149mr70808065ad.4.1778318849521; Sat, 09 May 2026 02:27:29 -0700 (PDT) Received: from PC.localdomain (softbank060090219114.bbtec.net. [60.90.219.114]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e36596sm47463105ad.48.2026.05.09.02.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2026 02:27:29 -0700 (PDT) From: Rion Kiguchi To: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, security@kernel.org, Rion Kiguchi , stable@vger.kernel.org Subject: [PATCH v3] staging: vme_user: validate slave window size against buffer size Date: Sat, 9 May 2026 18:26:27 +0900 Message-ID: <20260509092627.1136357-1-kiguchi.r.sec@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <2026050935-designing-glancing-2e16@gregkh> References: <2026050935-designing-glancing-2e16@gregkh> 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 VME_SET_SLAVE ioctl in drivers/staging/vme_user/vme_user.c accepts a user-controlled slave.size and forwards it to vme_slave_set() without comparing it against image[minor].size_buf. The slave-image kernel buffer is allocated at probe time with a fixed size of PCI_BUF_SIZE (0x20000 / 128 KiB), but the configured VME window size can be made much larger via the ioctl. The subsequent read() / write() handlers (vme_user_read / vme_user_write) clamp the I/O range against vme_get_size(), which returns the size the bridge driver has programmed for the window (i.e. the attacker-supplied slave.size). vme_get_size() does not consult size_buf, so an oversized window passes the existing bounds checks, and buffer_to_user() / buffer_from_user() then index image[minor].kern_buf with offsets beyond the actual allocation. Result: a local user with read/write access to /dev/bus/vme/s* can trigger out-of-bounds read and write of the kernel slab adjacent to the slave-image buffer. Fix: reject slave.size > size_buf in the VME_SET_SLAVE handler. With this check in place, the existing bounds checks in vme_user_read() / vme_user_write() against vme_get_size() are sufficient to prevent OOB access; no additional checks in buffer_to_user() / buffer_from_user() are needed. Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Rion Kiguchi --- Changes in v3: - Drop redundant checks in buffer_to_user() / buffer_from_user(); the existing vme_get_size()-based bounds checks in vme_user_read() / vme_user_write() are sufficient once VME_SET_SLAVE rejects oversized windows (Greg's review feedback) - Reword commit message to explain why vme_get_size() does not already catch this Changes in v2: - Use git send-email instead of Gmail web compose (v1 corrupted the diff) - Drop redundant Reported-by tag (author == reporter) - Add Assisted-by tag per Documentation/process/coding-assistants.rst drivers/staging/vme_user/vme_user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vme_user/vme_user.c b/drivers/staging/vme_user/vme_user.c index 11e25c2f6..64e95b026 100644 --- a/drivers/staging/vme_user/vme_user.c +++ b/drivers/staging/vme_user/vme_user.c @@ -394,6 +394,14 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, return -EFAULT; } + /* + * Reject window sizes larger than the kernel buffer + * allocated at probe time, otherwise subsequent + * read/write would access memory beyond kern_buf. + */ + if (slave.size > image[minor].size_buf) + return -EINVAL; + /* XXX We do not want to push aspace, cycle and width * to userspace as they are */ @@ -401,7 +409,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, slave.enable, slave.vme_addr, slave.size, image[minor].pci_buf, slave.aspace, slave.cycle); - + break; } break; -- 2.43.0