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 EDA0033372A; Thu, 28 May 2026 20:53:07 +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=1780001588; cv=none; b=e21LFaHzE4VHr/AsmGQ2iQcQn8yRlGGzUrfx93NwHz7p/Kxs/OLTY2Us2HKIZ/tfBadH3bhbxerWvAxyCGcuY83/0uUn9mvxDpHbFefJcaNN9FzdO+F1q7ijPGVY8+Hm68/o78MnjFiRy2OINVuPfPo6Nop7CUuCPLI+UT15mnQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001588; c=relaxed/simple; bh=K8aIVGMMtYgIiWiEZp1HpO6+UQwdf+ba956BCX1XEBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=exooupnAwEKQv7ZuSZEo84agNPokKCzVsejF8G6GbvhlzlUywo0m16riGvVMPqAdLEU5UZSrEpahuOUdm4gC2eW1wA99M38krWpoLTUovf1L+fGeAA4lEFiZaPGAbbvZXYyb8EcO2A/PEriKQE9k4sflloY5AcV9fCVXGO9V4tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1WI9cpAB; 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="1WI9cpAB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56EB71F000E9; Thu, 28 May 2026 20:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780001587; bh=JJJPKjDYZYE7//R1zxV4HLEP94ilpVrqQEN9g72WcI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1WI9cpABG67nmGjAiQs9y+BDYI6+5/Ym5AEG1i7PNl1gCgzVJBR6Peeuj3ARWO1t5 fJxpK/exi820oZy/Gmh0OF84g7hBeWe3nVNukFBS4Ia4ARveoQHQwDesAGfK404vQL eLsiZouzyVZqYXvzbjqmirMrzb+6giY2Kf3SdXBM= 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.6 180/186] gpio: cdev: check if uAPI v2 config attributes are correctly zeroed Date: Thu, 28 May 2026 21:51:00 +0200 Message-ID: <20260528194933.849432639@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194928.941004471@linuxfoundation.org> References: <20260528194928.941004471@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.6-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 f9a88b239301e..c6689f66a2d29 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -1374,6 +1374,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; @@ -1381,9 +1382,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