From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F316533372A; Thu, 28 May 2026 20:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780000264; cv=none; b=I1QWsOEyJ1ShPtEE7cyT5UabhrVXSxi7xIsLgxg9qrytYm+F3mMSM/D2xYuGGRRk2P3b93S/7vOA7h+N1pJWyin0PEIqkcbDEX6K46NP+9YkP/uAVppaxATaq0BMNcg9Fcp4JVxEGltHtv3B0pVMHhm4OFGOGjCaGOAB1504CfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780000264; c=relaxed/simple; bh=80gHyN7Ci2b6h7Qn196QuqFv5P9Km2Haujn4hF6hWmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I3Z0xYhdSDNGgtA/7hbPvhtjfab/3pBu5WxQirUBwv78xZ4yByv/eUo3YWaqXVU41pDcUjsKrPTxSxVt4Lj2DT6BfcBQ6yunG46WzL5q+doVLOh2NzenTqWQBkmsDMbnaDfb2Tz402e9u2PlxDwOLBdC7X78r7Zg4DpueB0QniY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eL9qnWAG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eL9qnWAG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5741E1F000E9; Thu, 28 May 2026 20:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780000262; bh=ug28VS/aXDKuqB0PFAbAjMo17w5GDWfE5D2JVNrXA2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eL9qnWAGE35+wAFoVZakB1Tqih+p7x8wJP+yFcx10lW46wC4r8ZsiwVSWKjhgrwY9 NTxpLEarYnFsJhdGX4mvbVWuvqMb62KXfVAHGxPzLSWRISzLxbPB2G2+CupB8NTZp+ L5vMpUAEFfXKXBHnCNb18cdariZhgX86IiLFimE4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kent Gibson , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.18 361/377] gpio: cdev: check if uAPI v2 config attributes are correctly zeroed Date: Thu, 28 May 2026 21:49:59 +0200 Message-ID: <20260528194648.882592445@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194638.371537336@linuxfoundation.org> References: <20260528194638.371537336@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski [ Upstream commit 3e6ccd790ed69bedd3d9626d01dd35cf9821c121 ] We check the padding of other uAPI v2 structures but not that of line config attributes. For used attributes: check if their padding is zeroed, for unused: check if the entire structure is zeroed. Fixes: 3c0d9c635ae2 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL") Reviewed-by: Kent Gibson Link: https://patch.msgid.link/20260521-gpio-cdev-attr-padding-check-v3-1-ec3bcbe2e358@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib-cdev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 986312c71678f..89abf7a238d87 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -1208,6 +1208,7 @@ static int gpio_v2_line_flags_validate(u64 flags) static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc, unsigned int num_lines) { + size_t unused_attrs; unsigned int i; u64 flags; int ret; @@ -1215,9 +1216,21 @@ static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc, if (lc->num_attrs > GPIO_V2_LINE_NUM_ATTRS_MAX) return -EINVAL; + unused_attrs = GPIO_V2_LINE_NUM_ATTRS_MAX - lc->num_attrs; + if (!mem_is_zero(lc->padding, sizeof(lc->padding))) return -EINVAL; + for (i = 0; i < lc->num_attrs; i++) { + if (lc->attrs[i].attr.padding != 0) + return -EINVAL; + } + + if (unused_attrs) { + if (!mem_is_zero(&lc->attrs[lc->num_attrs], unused_attrs * sizeof(*lc->attrs))) + return -EINVAL; + } + for (i = 0; i < num_lines; i++) { flags = gpio_v2_line_config_flags(lc, i); ret = gpio_v2_line_flags_validate(flags); -- 2.53.0