From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 5D45A38E124 for ; Sat, 9 May 2026 09:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778318851; cv=none; b=jBVQ952BVgkOyrno7Ehzh7+97cqFeD9KY8g/gVquGuYCAsp447xLvNtx+/+fl9KWMom/1ekkMukQLEOp/X1+1qPGTu/iAnLrYOeh70WnJqejaiqShgG7NUHGtWBlaw4IV6Rb8Yqyw2GEWDiivOdfPhPYVBGbpLTWGDx43E1/oI8= 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.172 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-f172.google.com with SMTP id d9443c01a7336-2b788a98557so20888995ad.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=Lm05N4jAwvvDxSWYhqldaJeQM6rJFEPcE3igsFyF586TEL5/lg4TnkdeVzWcAtA0dC UHnuAV+2AmzK/DGzEsZ+0TxnzcI5TdEttMSI3z6hUGvDUbAqRP8b7oBVJsSZEqVAbkHk MoquD+kRAx9DmYUvhQgd26azhQ04VBozz1ieuS4ocpJlhfX7olnvsJ/qGS1BNnN7OV0H UMzulMeBD91O0X2Shp4HUGorgvfPrIR/D7xSexikxNiES7OHtio67KZRZVJ82Q6S79jo 3xN5uXDmPn73/NYsYQ5WlIxwB9DfllXF3YXNBuGqyl5qz/2d0gnXQYyuc9LaKmh7x6ao 5V1w== X-Forwarded-Encrypted: i=1; AFNElJ/vnnkPwYwLHCkWI+6q5r6990REkjWQhSCbdL3V3Md1kJ1IO6JSQBljZxSzoKSp0s81uzW+pcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzjNc6BYYKqp8doP1z6RMLVJysq/qHYWrp3Atl3UuJv9ZAdj7fC vnEdOeSmzlytLJKtg18JXIR9exY9AqrOrRamUMnEZrgSOXhpli28mLlH X-Gm-Gg: Acq92OH8SGfX9xGALU1yjbwW454rw96FGbSCkZCReQc/GS9mlTALatbFrPp+En2UKeF gP11ggJcp58XbQ8VMtvjV96/2khcijluNnlpxLGgkPtuESXvAZNvTrxGk5c2WkB5eLS7AUbmVYp 1gf+Q3kXzBviDKkrV7m+w9SE7qOpxJvY1M9K7+badKySRV58JFkDgrr2h/Nk33iOBmp/y/XX/26 xtjgSyBeReagHz3TXylaHnLwQVgq7rtsDwqS4KmT8vbOkSL/BPbHi/1bNwBvb0t0JC1pF+8I9ot /xWOrCrap7ql9Zv86KU4u2KzGoWlLfkhSTgsbifDQ3FqQFzWYluSf8NDGx7K+rWph1QOxxuTfpq ve49ecYGu+T5gBpaWVcJFVwSlUCu2GXn7N0MCFQN0yfnpURJ9HHVG1h3NF4+UO+jbyT77oRIdzW krJvhzr+lTPDsJR+pkoJdRdun0uPqzCNRaW1tBn35A5+sRDnDG6rFhC/3Z9yQlGQ== 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: stable@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