Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1073568rwb; Wed, 26 Jul 2023 07:14:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdwmIKWZMdC5aS/Qa+JbwCSYSwKBG4EwSgOFaod4REbv2NrhN5i+M8lwsTZiGtKdIGQuF0 X-Received: by 2002:a05:6a20:440c:b0:137:2d73:707f with SMTP id ce12-20020a056a20440c00b001372d73707fmr2202404pzb.5.1690380872312; Wed, 26 Jul 2023 07:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690380872; cv=none; d=google.com; s=arc-20160816; b=wSYV9dhevvrMO7Y1XhOAugbElCX7kwFik8fQ06TRv7CU5/HZADMz+r8Myb46hpZyM9 k6olNIxEMjSJt0CnZrJKKKE4Eh3XBZd6445odDWukrN2cGFHU1T00EAWRfCGaS2+rFm2 kWfdpbH0zG8t4ZHWBeIq4kYjVIbbtZpi99SdOW5mrOgJV65LslwrOlEO9k5fMEDGEj5W A4tMbLVkzB4m6V59i2W6nunYT+cTsYR2EGFCoRsU2tQnsR3Y5RlM45hg99GlPs5dzJh1 K7Odc+g2IMuvdFsziVMCzSmaxldg7e3ZWpqnEEHXhuER/96kO1d+5TBsnOsZrSM5oSbA CIaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=y+3JcMDmwcBxmDJnO96kGfYESZ6WRSROP/M0qnZiaW4=; fh=jc9Oc4z2chBkB++ulkkGj5ASBtrAOk+67EQBS5BnDw0=; b=s2X4vgwbjWQplmcLokhH439IgUbmA0eCSY8c9bNT62qN+Kn0NiJbMVFVCGdqHTtoCy nsyprZHjhlyBz6+tjAoPF9+AMI/B0xtQYKqnQWX4UIM7YdzUFOTmorh5aRUN+jBcRBXM 7ObECREFSEvvj62MPY/uHkm8FxULyDpzp1geq6/qRosxFvMclJeN5F5/bqcCboJl/NBf SPO7/MTTVDpRjN+DAQPXNbeoH+al0si6gCpO7u+clepWAhU7c3P/LQnj8kYQF7cdYpY0 UylV3nNym3QH1w+BJ9BTfzoOg5YQOXsI4PHiSvTWArvF3NwyGKKFNjcO/Q/OHcIkBBO+ aL+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bn8TlKha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h23-20020a656397000000b0055c1fb5a4a9si12801793pgv.661.2023.07.26.07.14.19; Wed, 26 Jul 2023 07:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bn8TlKha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234235AbjGZOI4 (ORCPT + 99 others); Wed, 26 Jul 2023 10:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbjGZOH4 (ORCPT ); Wed, 26 Jul 2023 10:07:56 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9402724 for ; Wed, 26 Jul 2023 07:07:16 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140714euoutp0228f6a41888f83d95a60945ad88b109df~1cAyyzi-Z1609016090euoutp02N for ; Wed, 26 Jul 2023 14:07:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140714euoutp0228f6a41888f83d95a60945ad88b109df~1cAyyzi-Z1609016090euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380435; bh=y+3JcMDmwcBxmDJnO96kGfYESZ6WRSROP/M0qnZiaW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bn8TlKhaPm+ZoNVd1/sk8+To5fFDMyF8NWplF1EFtK0Ja4bYvIxtB9ek8mo548IZg qVrJ7TTRD0zEHi3nbJSRzRD6Z/UHSz/l6jmklfsW8lch+iL5j9gSe6xuqoPkxOaaOF n/QKCdN/Wc2bHqQAFpAaP7SRnOSQoz37IyoyIiZE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140714eucas1p17067e35c5306c93c315855e164a426f4~1cAyiQPQ62256722567eucas1p1_; Wed, 26 Jul 2023 14:07:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 3D.76.42423.29821C46; Wed, 26 Jul 2023 15:07:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230726140714eucas1p186bad44daf14c4c8c93f9aaf52deade5~1cAyRGU8u2041620416eucas1p1-; Wed, 26 Jul 2023 14:07:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230726140714eusmtrp17d12f7d118f120e8c898b69e46e1046a~1cAyQjihf2411224112eusmtrp1b; Wed, 26 Jul 2023 14:07:14 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-b0-64c12892eb80 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B3.67.14344.29821C46; Wed, 26 Jul 2023 15:07:14 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230726140714eusmtip1e2ad697c5d7344b8bd32e0d7e06a4b6a~1cAyDjtKe0954609546eusmtip1X; Wed, 26 Jul 2023 14:07:14 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Kees Cook , Iurii Zaikin Cc: willy@infradead.org, josh@joshtriplett.org, Joel Granados , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 14/14] sysctl: Use size as stopping criteria for list macro Date: Wed, 26 Jul 2023 16:06:34 +0200 Message-Id: <20230726140635.2059334-15-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SeUxScRzvx3vAk0Jf5OI7ZGkGyy6PYg3zbNZGp3bNDlsxeKkT0fGkzNWy u6y8Ukm0zRVZis6NLirNIsvMssyWrexaWh65NDNsNk18tPrvc32v7UtgAiNbRMRrUyidVqnx 5vDwaw9+Nc3L9bmr9s+wSuUXaj8i+WhJkvzxiUR5dU0DLm+5WcyRv8ruQPLhoTFUemN1OKEo Sm/GFSUWveLypdmK1z0hCkv5cY4i80o5UgxYpkVxN/OC1ZQmfiel8wvdzosr/tXATTbwUofe ytLRPSIDuRBAyiCnfwTPQDxCQF5CMGCzOMkPBE967iCGDCB4N2LG/pZU3bJjjHERwYu6g07S haDzUyfXkeKQc+Hp17YxgyDcya1wPk/tkDHSgMBULHbgKeQKyDE1IgfGSSmMfrSxHZhPh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P gSWEBbwlJi45zQhiswioSvx/eIgVxOYVsJM49H0aK8QCeYm269PBajiB4ivXfmeFWGYr0TP1 KTtEvaDEyZlPWEBsZqD65q2zmScwCsxCkpqFJLWAkWkVo0hqaXFuem6xkV5xYm5xaV66XnJ+ 7iZGYIxsO/Zzyw7Gla8+6h1iZOJgPMQowcGsJMJrGLMvRYg3JbGyKrUoP76oNCe1+BCjKdDd E5mlRJPzgVGaVxJvaGZgamhiZmlgamlmrCTO61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXApPLf 3Y2/eP/HU/cXP9S1Nvfi0IpX8unedeKzNXfFgmMXA7TDpWfPS+WRuMbgdd3swrrTKTKxRzVv bZp6dX5X5tnnvVP8TIwu3VCZ84JtxSmJlYs5z0T/eJxkeZW75/2DsJjGp+//3TgRsdztdFvb 7u8s+9x1ghm/F6w8/1fntRvvghqWe0VLmM1mx8dkrG7OtHM36AnvS51tbLXx6DEDr/s71E5l /Sl0C65csTuzcPFN7SMrPux6d2TBiwMKTHeuWj9dXajq/qx9iY74wh3bputULJO66MCX5ni5 6C+HrcU2jpO77hd8c8pS7Pf36Wdr3Lxpcah/hpaUjd6J0vmrlN+4GTn7inl+7r3gslx3qhJL cUaioRZzUXEiAEYQkfAaAwAA X-CMS-MailID: 20230726140714eucas1p186bad44daf14c4c8c93f9aaf52deade5 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20230726140714eucas1p186bad44daf14c4c8c93f9aaf52deade5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140714eucas1p186bad44daf14c4c8c93f9aaf52deade5 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add header->ctl_table_size as an additional stopping criteria for the list_for_each_table_entry macro. In this way it will execute until it finds an "empty" ->procname or until the size runs out. Therefore if a ctl_table array with a sentinel is passed its size will be too big (by one element) but it will stop on the sentinel. On the other hand, if the ctl_table array without a sentinel is passed its size will be just write and there will be no need for a sentinel. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 6c0721cd35f3..3eea34d98d54 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -19,8 +19,9 @@ #include #include "internal.h" -#define list_for_each_table_entry(entry, header) \ - for ((entry) = (header->ctl_table); (entry)->procname; (entry)++) +#define list_for_each_table_entry(entry, header) \ + entry = header->ctl_table; \ + for (size_t i = 0 ; i < header->ctl_table_size && entry->procname; ++i, entry++) static const struct dentry_operations proc_sys_dentry_operations; static const struct file_operations proc_sys_file_operations; -- 2.30.2