Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp538175rdh; Sun, 24 Sep 2023 00:36:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUKnZ58A6f1lKgC4LkiqWBjHY/4qHxWUc1edGn2urL/UToRw4fDvM6et/vMEXyMSmzQMbj X-Received: by 2002:a05:6a20:a110:b0:15e:d84:1c5e with SMTP id q16-20020a056a20a11000b0015e0d841c5emr5150779pzk.38.1695540985807; Sun, 24 Sep 2023 00:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695540985; cv=none; d=google.com; s=arc-20160816; b=IcC/F2OQs1zP6/4UiMVjVyE4nAtVTXdoyDC7inB2I0NsuQyeOdt7lxg6azffU96X/X /qov+jBUGKswZ9tzL3O2hD9m+y2Y3nI778AzSgZjxZDUpDR4hXhYj99hsBJCDZVlyhzi RamcVWwcdwsm3MuckVZ5aX9uDSMWN3PXyjFGq4hT41Nlc6m+4jS//nvZD6wDUEqlYyZI Q6XdInTMv5+ImViZ7NxF1iP/t05UACpPk6j4+2rnfSJ6xYV2L6iXGfCQrgk1Q9tH1dW+ AXUSlXCKPZ3Afpn0syEat0eArm//Zx2YOB0P4uT7q74GYqzP0wpCHZVaSA5TmTZ2zXhQ Lizg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dqouo1KR3QIB4VuW2gBPYmlnqE6R3OEfgs5LOzPDfWs=; fh=TzfSr8auzVab3L/b5POYYxLyYM7wwKHHkyJi2IqY5EM=; b=VNkBjTW2WeXpjpDOi/XBdIfcOodGlT9EPSKWs647NQFZtfanW+u62DmnmU1TwT1Qd3 AP9gQXCDzarRnmyNCNxm/GKpYzQZuf0GsktMTZ1271uv/LRuAPyHqDLHpxYG5Elg/Sin 8bb53aokrITGDm1enb1MJPB2fZ1dTbQ7SB62fP6Jmno2pdu6v6/wlzNyUJT+x2fkdKt3 lyJwHHwGhhKr7SoA6zXo5XExFDmpAow7gr2zN78GQP2xnE0bZ7pdBO+KW/Rwt/ATRJqJ avRXoC2a4gB4zMZ6+9T7ij5+lzzDiBj8wc9EAAYbItcnisBPkmD9OqTq8TICtBJOi45e UpdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7qd4eju; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e191-20020a6369c8000000b00578b9314261si7215459pgc.437.2023.09.24.00.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 00:36:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7qd4eju; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9E99580D9B0B; Sat, 23 Sep 2023 17:24:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjIXAPs (ORCPT + 99 others); Sat, 23 Sep 2023 20:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjIXAPr (ORCPT ); Sat, 23 Sep 2023 20:15:47 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C81F139 for ; Sat, 23 Sep 2023 17:15:41 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-59f4bc88f9fso22481827b3.2 for ; Sat, 23 Sep 2023 17:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695514540; x=1696119340; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dqouo1KR3QIB4VuW2gBPYmlnqE6R3OEfgs5LOzPDfWs=; b=L7qd4ejuReJaZZEdzE3d7Dv4HtkkRsgRx7kPOIlZqQ4zCRQR7imIbkwV7jQ9imTzbW TuoMVGurcDmL3M6kYdJIZUWpTwnMoY/CzSWhsWJMzlD7nbaS7g8l2To6sO7XnSPbLIFN zFJVn5apKpen8Ei3aP6avqbebNJBK+cG7VmE6hgLooCc2mzEjBMHojqc7YXNtmfM2JF5 66EeSKPvuS6iHtKt3l+cnLSuajFzljNhuaz2ne2VC7DRAYjQ6qhB1t0yvdMdBIdK0syc KjGwNERBCEZLR8v3Yc4gz/VoFp5frPcNFjE5YToa74jLX4dNvtJz5xpIhBjeSRXZlD/B CBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695514540; x=1696119340; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dqouo1KR3QIB4VuW2gBPYmlnqE6R3OEfgs5LOzPDfWs=; b=dgNBuJeFS59u9c4xC0W6K3OKX/RtnmUsGOMZXNua359eXOzwY/zPup4JCsA6e3E3IA jUstLuEEfzYnURyKRF/sY6O/bAJyEC4LeVd5spb+sJYDrUgxLtzvxV3GX57oItkhBCLk mKJo38gJQZ16e37qefce1EsFofH88bTAZf3jrGSDRbwbJhgSgxVJbL67etMiYzWBtWVg +HYhCA+S8LTIxAMSfbDWJ08z8bJL1Dr92Cl7gK0eTniUcG5aajHlc6mDYhwHb+iqTGTS zgXQPti730tbduyAOsktMAC0Gv2Nxr6i4SEUIrytUYaGmTyNv82cDjw6MRig+dhurfGm zzMg== X-Gm-Message-State: AOJu0Yz5jBuNVSBx+gj4e6+TX95WOvkN3fcZDezwLLh6wo2KBlqoJx7i PHE4YdxPRcmprbTgxaY7E88n2VzlpPUq8RX756Jg5Q== X-Received: by 2002:a81:5b05:0:b0:599:b570:2db7 with SMTP id p5-20020a815b05000000b00599b5702db7mr2470522ywb.30.1695514540275; Sat, 23 Sep 2023 17:15:40 -0700 (PDT) MIME-Version: 1.0 References: <20230922175203.work.760-kees@kernel.org> In-Reply-To: <20230922175203.work.760-kees@kernel.org> From: Linus Walleij Date: Sun, 24 Sep 2023 02:15:29 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: cdev: Annotate struct linereq with __counted_by To: Kees Cook Cc: Bartosz Golaszewski , Andy Shevchenko , linux-gpio@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 23 Sep 2023 17:24:02 -0700 (PDT) On Fri, Sep 22, 2023 at 7:52=E2=80=AFPM Kees Cook w= rote: > Prepare for the coming implementation by GCC and Clang of the __counted_b= y > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUND= S > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct linereq. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/c= ounted_by.cocci > > Cc: Linus Walleij > Cc: Bartosz Golaszewski > Cc: Andy Shevchenko > Cc: linux-gpio@vger.kernel.org > Signed-off-by: Kees Cook That's neat! Reviewed-by: Linus Walleij Yours, Linus Walleij