From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CA1EC61DA4 for ; Sat, 28 Jan 2023 07:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233186AbjA1HWl (ORCPT ); Sat, 28 Jan 2023 02:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbjA1HWj (ORCPT ); Sat, 28 Jan 2023 02:22:39 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5155A611FE for ; Fri, 27 Jan 2023 23:22:38 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso9844046pju.0 for ; Fri, 27 Jan 2023 23:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dowhile0-org.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=czFnnNgiMNwVHtOu8IgfTLKpLnKZzktc8ilaRgu2SLg=; b=rovDaWkwW8WlO27xY4VUiD/aZvHiRLwNMSkQgtqLrdciFxOgTcudSDnJsAHv8KkLxM IAnDuY/G7Zk2eBOcEwZ4dSSR4S7SqRNPhOXVIeuR2KuGxz3GPH11K80oa3m3sB9julDh 0kVpWxN77OH8NZ+232r6NuT0rax30rlki9uthNbNhsPIXeXaPZwqdtm4M8Nzxf0NBo6q JvM4BmrYy2mCnE1IDOTRRGJdt32xNJm8EJAv71R9ziUdwMVViRonZ/CwNnwgSNh56sSe /b+abh0GK/ep1OZuWPvg+XpA3mn9UTYYA0Uy6+F2cwgMyZK5SaPHggOyfQQuAg40k0Sd ZzoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=czFnnNgiMNwVHtOu8IgfTLKpLnKZzktc8ilaRgu2SLg=; b=pRByZQ1i57g9x3K3ARHOptPVXR1YmHDbLV3Xu+73BOquR84txRlOsrmN3uVj8JFEgP Ng0WHJKJs0Y27iIooISAsdwe9UmtGKVqzoV793tmk0Z5hcYXyCF5QCR0fRVG6DreTcCC Q+4HsAwvKKji/KZ3gzys8+sAUg54o4uxIguhCNohiYVx+XSZgGVOmDVkgiY+LRAUGlIQ ptFjShifHlwAutgXVk54D/8VmKn0nt9CECgcKXlY6jjln09AYw1KzJHmYfOnXsq1TbHN 4nmaqYGIc5zk/Foea95Kef1jA9vN/VjNN0cPhcpxrRV7ZvAtC4hw3ju69ZQLSApAky2q aDkw== X-Gm-Message-State: AO0yUKVdMm71dWwxyMRpmZM14aZKNRcJ9HwHaepYDRS0x+KcbyE/rtyT 8rocl1QMYYwWdqiXvCRYQEqLJW2D/CZW4BMTCmK+Aw== X-Google-Smtp-Source: AK7set+A9FRO1xMuryCPrO/4me6tixWO+0SFK14DctJNZ8/DouO/cwHk9Esb4rQBlA2SMC3R4VlaS3LaxZbOr1Eo4NM= X-Received: by 2002:a17:90a:414a:b0:22c:1be3:1985 with SMTP id m10-20020a17090a414a00b0022c1be31985mr1312197pjg.192.1674890557793; Fri, 27 Jan 2023 23:22:37 -0800 (PST) MIME-Version: 1.0 References: <20230127225203.never.864-kees@kernel.org> In-Reply-To: <20230127225203.never.864-kees@kernel.org> From: Javier Martinez Canillas Date: Sat, 28 Jan 2023 08:22:26 +0100 Message-ID: Subject: Re: [PATCH] regulator: max77802: Bounds check regulator id against opmode To: Kees Cook Cc: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Kees, On Fri, Jan 27, 2023 at 11:52 PM Kees Cook wrote: > > Explicitly bounds-check the id before accessing the opmode array. Seen > with GCC 13: > > ../drivers/regulator/max77802-regulator.c: In function 'max77802_enable': > ../drivers/regulator/max77802-regulator.c:217:29: warning: array subscript [0, 41] is outside array bounds of 'unsigned int[42]' [-Warray-bounds=] > 217 | if (max77802->opmode[id] == MAX77802_OFF_PWRREQ) > | ~~~~~~~~~~~~~~~~^~~~ > ../drivers/regulator/max77802-regulator.c:62:22: note: while referencing 'opmode' > 62 | unsigned int opmode[MAX77802_REG_MAX]; > | ^~~~~~ > > Cc: Javier Martinez Canillas > Cc: Liam Girdwood > Cc: Mark Brown > Signed-off-by: Kees Cook > --- > drivers/regulator/max77802-regulator.c | 34 ++++++++++++++++++-------- The patch looks good to me. Acked-by: Javier Martinez Canillas Best regards, Javier