Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796041744; b=B/julRMMXmo0DY/b65SCIxGepNmz4MtecVrmy1wLD7+bKmEvQS5XMDlA8z1oMNBCSxe4 dBA8LPz0yq91zL7x140MXkNNc9957oCij23iYiOybjM/T0dc0G7ocQ7l16WeM87kotXYF nyHfnN4T6ULZDjdyiDbuH9Q1uGhiYyfaBmediTn53lQzKnrJJtbyOihGwWL6sd5LNtEI7 oIfJ+BJUa3UTf3kmYAIHgLJXHC5xYr9DBmGlaN/1fl6C7LSaTuMjSsgjxuVjBB/GjZJV1 8M+JrBt+zq3KgLLnXUqRZhjLACikdjdJ0fCMBt2QeKbH/xk+VtzSTvLuyQZrVWR9Zhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041744; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=K3ysY1hWrp2Lx4m/BGfMcF1q3CnLrFcvARjuiwWo+fg=; b=pJFPDTCLBhyDgZhvwNJ4ONY5rYMMqptC7IXFeqoLaTpWRn+X9eIfO6DG1yUIjk+M9+ap CStfZXHgM5+5KkVxjOCFTlKkbeRq0wK7Lc1MVRgAG8GSfXlxVVbuvwR5ukNqEUXXn2Hhf ZgyUrx+CdBDm0hR6ht3/JNwCQMm+OydZ3ybG3Ecoc3ZWkU4X/cZ7V4du3dJTTajwVUvoD GLVW1oytCCfH4Hv8r/HkKbjNkZFCfu6iMKGvZPht/ZURi0STq/XIUsgoaUgaZ5v/FKxsT jl78i4/WHcembNH4IuiYXh8k8bdNBcEs5vswVbMdkQxMv8kydQ/os42EU4+0HDWirYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kFukrWPq; arc=none smtp.remote-ip=74.125.82.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AE86606A327 for ; Mon, 30 Nov 2026 12:29:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7AE86606A327 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.a=rsa-sha256 header.s=20260707 header.b=kFukrWPq Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-386ab9ab619so15383343eec.1 for ; Mon, 30 Nov 2026 04:29:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796041743; x=1796646543; 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:content-type; bh=K3ysY1hWrp2Lx4m/BGfMcF1q3CnLrFcvARjuiwWo+fg=; b=kFukrWPqsMnLXl6aPzTEzJaHMFGDepTDG25nx5fRi9OX2WFwhqBcnkjnBrjBcoxSDJ MECeUOSAx+ZBta4w1Yjr5qGFf2NBbMg+5iDKk1J5d10W9XMDtkgfCNbYebIsr3jhzxv2 dDHPCiOC3badABuuKprELnhlx88Dw/EXc6/pTfRseNtJIzNXap322S8V4SuUa2KZolCc xY5vZe4k7xC3UVVTdyGQG3NLCRmOqVwSZLAh8SAZSy8HB9sM3Z//4yrkkQ7CahP3OZuV h5qjvQuhgvxTVI/bUivgqbXfbPQtfAImB5VVf+vBrhAr6aQzOuslrrDxEiIHKCKdDYkU UpYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796041743; x=1796646543; 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:content-type; bh=K3ysY1hWrp2Lx4m/BGfMcF1q3CnLrFcvARjuiwWo+fg=; b=rXmWUScH6YRT+71A/mlypNj4KL6rcK6o9CkGUV2elKofOFMBKTMqAN8UVXvoSDGSLA QEC+ss3TakPQsC4oS1CI8ndZb/wZrMeT6N+g02Ju4luU7nk0U5F7FV8iG9TRgl8zWGfS MTEZ5wEEuL/mLAob2bu9PhGchiWHO8iCM2z8YG9QJ0mdJ8pU4sEU14gNLQj1P8ZsqUDr NtwiBUkXrtHVAVWJaXeZNWM4mxyEfO2q/c7M8dwk5+UbVj6UJ250BfNnxfhZ16m4tg+R nLdfBEMc3liMjvIRNgAzr1tKnaojTEvTFf3yiFpbysfxK5i8dIUu9drmET0Qml2/Njod 2lWg== X-Forwarded-Encrypted: i=1; AL+hErFIRETVyww4JMIn4eWjWL2D3cTpfn+UpYs/LGn8nPq5fPlkB5fzkWfl4to0qKAREz9Do73MNwcQKkg=@vger.kernel.org X-Gm-Message-State: APuU4Z8ycx282i+BoRCsugA2Mhvr8K+s/V9QwO4+AOxTHcL8OlEzyfCC hUW79xmO2WWdB2LBPwnY1PtDbEZXQv7Hwb9yYkR7KznqtmDMqJ8toDde X-Gm-Gg: AZFdTZd0t7dQgQS74ep/uieq+UtP43v8QXHmdmMvgSPzAa2gXK/GeoEFxVx2oKrDUVy pxvW1U7Lz1dIlnMka/PZdAhe9KubtpK0PV238C/RtsNXbBftbVRB0pWW7bQrwLVuy7+t6JU6cH1 bseYIvZpSYS6IQu/PmkR/MAbS8TzZsTCfahNFr84awQpDl3643vqbk94S6gcYx6ierncDEmcXQw HahjxoU7iMb4n5UYA154YsiqvG0LcEmffGbPTuvEmpF8fxsmNEvHIRYQsdvFAxehC/0gGD2jzgg 7VDl0SpFXA8XCyVaa6AKn91gNVmpa1fRZAKeevHwI5cGwQCL7ZorxvH1NfFUveH/zpML4LX7R3h nbBk23y7scw0poLp+oMZeZlzMZL0HZGeSMgVKvON7wYXQBBrgZclI37UvCi8kUxofBim+EAkrPC JpH5Bftf+iiJ/uLbPwo2DrzwC/5jL7S8lcqS7yayyaX1s/7Trngnd8r5BXI6bEBShZ+59Pc6ULY N1QYZGIypMDP14VC1ckYmPs9H977yoC1aLllxpjh8YiqoqGficUMlO6Muf69kZSOqqhtBKFmNk/ HaOI+jtuuHKO9JicIt6OIggoI/EPWyZxMpP5+jbni4QZx59J5eNKjQ== X-Received: by 2002:a05:7301:4301:b0:386:548e:e533 with SMTP id 5a478bee46e88-386548ee6c3mr31791692eec.18.1796041742529; Mon, 30 Nov 2026 04:29:02 -0800 (PST) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f676c3ccsm24259053eec.12.2026.11.30.04.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 04:29:02 -0800 (PST) From: Maoyi Xie To: Jonathan Cameron Cc: David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, Ramona Gradinariu , Antoniu Miclaus , Michael Hennerich , linux@analog.com, Sean Nyekjaer Subject: [PATCH 1/4] iio: accel: adxl380: check the HPF corner code in adxl380_get_hpf() Date: Mon, 30 Nov 2026 20:28:50 +0800 Message-Id: <20261130122853.2473023-2-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130122853.2473023-1-maoyixie.tju@gmail.com> References: <20261130122853.2473023-1-maoyixie.tju@gmail.com> X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit adxl380_get_hpf() reads the FILTER register and uses its 3-bit HPF corner code as an index into st->hpf_tbl[] without a check. The table has seven rows, so code 7 reads the eight bytes that follow it in struct adxl380_state. The driver only writes codes 0 to 6 in adxl380_set_hpf(), so this needs a chip or bus that returns a value it should not. Check the code against the table size and return -ERANGE. Signed-off-by: Maoyi Xie --- Found with a CodeQL-based static analysis tool that we are developing. Reproduced in a userspace harness under UBSan. Not tested on hardware. I used an LLM to help write the harness and this patch. drivers/iio/accel/adxl380.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c index 03b140303520..42696e31376c 100644 --- a/drivers/iio/accel/adxl380.c +++ b/drivers/iio/accel/adxl380.c @@ -615,6 +615,8 @@ static int adxl380_get_hpf(struct adxl380_state *st, int *hpf_int, int *hpf_frac return ret; hpf_idx = FIELD_GET(ADXL380_FILTER_HPF_CORNER_MSK, trig_cfg); + if (hpf_idx >= ARRAY_SIZE(st->hpf_tbl)) + return -ERANGE; *hpf_int = st->hpf_tbl[hpf_idx][0]; *hpf_frac = st->hpf_tbl[hpf_idx][1]; -- 2.34.1