From patchwork Sat Jul 25 13:14:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Magdum X-Patchwork-Id: 27507 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 03855BE080 for ; Sat, 25 Jul 2026 13:19:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20F6167F4B; Sat, 25 Jul 2026 15:19:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eGCRCX6y"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B95B767E5C for ; Sat, 25 Jul 2026 15:19:38 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-495590ba856so11711025e9.2 for ; Sat, 25 Jul 2026 06:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784985578; x=1785590378; darn=lists.libcamera.org; h=content-transfer-encoding:content-type: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=+ZUxNNJ5Yj7xbJ5jiL5/jDB7p7bOZRI06MAE8OfhJM4=; b=eGCRCX6yKpk9OrtH/3P1BchRHThIBeBbZpjeMQNKmLSW/0lAKSG1YX7qukL36vX8F8 vFYYcjTfUJlYRJH769qmjFfPFomQ0J6HSrwvMUfcXQmHYz7LD/be4yI4LwEs7wnKyjch 6Quny3a4RWEQiRBh8OMosQCzoIY9/C2+2TddPB0Wzd/Buzxv5ksjltwtXkhfgHVDNNc0 WpgbdCczKG0CAPdamLk28+D/p6OH5ELJnneu3MZHzq6/A2l9M5jCAxKGs0LPXwYRFwo+ gdd/tVYgi+zJsrKhSYdQ7J6tLN92k8fLbStoOtk2wiDeqHBaIHzpqTBaop1Ga9so0U/S Fi3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784985578; x=1785590378; h=content-transfer-encoding:content-type: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=+ZUxNNJ5Yj7xbJ5jiL5/jDB7p7bOZRI06MAE8OfhJM4=; b=sVnTPl16Lx0RtIEefPDCM5+zkXAhxzy6d2q3Y72NwMNNOLtod0G+/GZUPN6pb3I5KJ aInE0T5tO0ZQ9R40U2GdlMXX8LW1H3i/lFQdG6/IGsbxwFvdLp+eYI2+vzlwo5a8PTcp 3Sr0IrZkQMhrakA7WgAuSCRPB5cOnOS9J4/KJK1Vjw6s39afZ18vHDeJj3qFoUiZB7Ga bmK1bSX4eR9Q/16V0MCs4PSLx0wKsNK3F8hTTRFkCujwDrpW5G05lCSaHVgSojGDAX18 EhYBFDX1Byjg+qZ40bLQCpAYi2sSXHMynos+CQg/8HHI47A+aE0keRkODdqZqM9RuU3S drHg== X-Gm-Message-State: AOJu0YwA+gQ1N/mA9gcOJbCRPvg2HPKMuuQapuN+tDarRKlJ+ZUDvmBZ 2P9xYn3OkDOSOxQ5kfwExOs6fP/b2FzoP6uqOPwCtO2MWp+1gr9sV+yppphlHYcHX5Y= X-Gm-Gg: AR+sD13O1KLc4mZW7MiDAZS0OvmvCYLQWp0VDiErECRvW5YmoA4pcagIVNBxU6IpiCm TSLyf4MdTiTjh26y72ZSF5PSftecTV8rjsg37CVVpFLmda0+D72zRcXi0leGiQn93ElCBeVQhFB 5L5nyfk6MHicYGidh1MiCVV4TgUx/tbCslG3LWw5Cu92GsMkgUaCMJ/npyAjem3ni4rH6BYdjCI Y/CDKR6wSP5MXljRZdxjx1uhS+1etQq14K3mqSVJ414/1RbtiUItK732GO5B194qCEgF5Nn1Yuq iOsTYNyFy4pebZ3y5ukO+sckEtTaVFphQwNoct2SUsDyhPOY1dYuuKOkaMoPwj+29efGBi1bzQ3 wuSWu+AYD9df1N5FmksLrZx6G7CY44/3AP3VnmkVdMEfVatH5B7rmmentfTS5OnSd0S+XWQu0BM Cfwt8/s6Ox+QrDNkZ/xl+GiMjUc8BCMIoUknHrVlRH5+YM4MapfKeiOKdvg+jzrME= X-Received: by 2002:a05:600c:3509:b0:495:64c6:84e9 with SMTP id 5b1f17b1804b1-496b5648f38mr26903575e9.0.1784985577662; Sat, 25 Jul 2026 06:19:37 -0700 (PDT) Received: from magdum-System-Product-Name.vodafone.ultrahub ([2a02:810d:4b14:4600:4c66:91af:4d7a:df5e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496b49a6e17sm67431455e9.13.2026.07.25.06.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2026 06:19:37 -0700 (PDT) From: Magdum To: libcamera-devel@lists.libcamera.org Cc: Magdum Subject: [PATCH v2 2/2] libcamera: Harden control serializer size and input validation Date: Sat, 25 Jul 2026 15:14:07 +0200 Message-ID: <20260725131932.13509-1-magdum.foss@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723174644.6580-3-magdum.foss@gmail.com> References: <20260723174644.6580-3-magdum.foss@gmail.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add overflow-safe size computations before writing 32-bit wire fields, centralize control-name size accounting, and validate deserialized local control direction values. Strengthen tests with alignment-safe packet mutation, deterministic malformed name-offset corruption, and max-length control-name boundary coverage. Signed-off-by: Magdum --- < std::numeric_limits::max() / rhs) << return false; << and drop the previous `if`. Good simplification — the rhs && guard makes the explicit zero-case branch unnecessary since lhs * 0 = 0 falls through correctly anyway. <= lhs;` and drop the `if`. Done << But in any case I am a bit wary of these ad-hoc implementations here. Given that <