From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E44F7EF00; Thu, 28 Mar 2024 19:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=72.21.196.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711655405; cv=none; b=eQM1p0j4x+oQMRuiZi1Ha00ZO381by0/mANCvqeUxQqs25KAroC1UsIx6ODhAWJQuHcjtOm8FRHkQ5T3X1Tb2fcVTJnP/WyiAtpOyIOfEgJHRdDXsykiENlbErjxCGvW/1iw14MCdy+ewLkTgo6Wzs4e5zBLkngm0LpFzhkx6bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711655405; c=relaxed/simple; bh=jy7iDHuc6Ej+2jTP9CC2GUNMdvWMnjZbOjyyWldjqgM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n5las7b+3LRdoDG7V1xmzIjHPV5y4dvZHrNlQCKNFdsLpeJpLWA2XrJ2zDeIIdHiOqgCo8XyqoyK9FUqQYGUsmTlG/d5ZYm3pkD+OziapsOQf/djJcX1w1FTnFuWD09DG/td01dP3JhLFwOj1xUugNbrzF/oRQQMW1ELv7TFlzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=kSsq3Ssw; arc=none smtp.client-ip=72.21.196.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="kSsq3Ssw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1711655404; x=1743191404; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nJnwU1+gGS+NGNA2zseGcZeJ5QG2IPGlkTTsQ5KCHlw=; b=kSsq3SswdfM+s5M8UqDDX85q+IN/9e+Z567+yJm/QP1kNGJtNRgrVEbl odpo0TI25iXqMG4FHEkylvhcNAI6R2yWFlh9tcBfJJxN+t0/yvVjL+97g tZFDglExU6sH72SoJanz1znpLauXX5knwVJVaV+VuU3Cxnnl9Os8Q5cbG c=; X-IronPort-AV: E=Sophos;i="6.07,162,1708387200"; d="scan'208";a="391312047" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 19:49:56 +0000 Received: from EX19MTAUWB001.ant.amazon.com [10.0.21.151:20037] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.47.83:2525] with esmtp (Farcaster) id 73cfa33f-945b-445c-ba15-2d07ca3a8590; Thu, 28 Mar 2024 19:49:56 +0000 (UTC) X-Farcaster-Flow-ID: 73cfa33f-945b-445c-ba15-2d07ca3a8590 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 28 Mar 2024 19:49:56 +0000 Received: from 88665a182662.ant.amazon.com.com (10.106.101.27) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.28; Thu, 28 Mar 2024 19:49:44 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 4/4] ax.25: Remove the now superfluous sentinel elements from ctl_table array Date: Thu, 28 Mar 2024 12:49:34 -0700 Message-ID: <20240328194934.42278-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240328-jag-sysctl_remset_net-v2-4-52c9fad9a1af@samsung.com> References: <20240328-jag-sysctl_remset_net-v2-4-52c9fad9a1af@samsung.com> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D037UWC001.ant.amazon.com (10.13.139.197) To EX19D004ANA001.ant.amazon.com (10.37.240.138) From: Joel Granados via B4 Relay Date: Thu, 28 Mar 2024 16:40:05 +0100 > This commit comes at the tail end of a greater effort to remove the > empty elements at the end of the ctl_table arrays (sentinels) which will > reduce the overall build time size of the kernel and run time memory > bloat by ~64 bytes per sentinel (further information Link : > https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/) > > When we remove the sentinel from ax25_param_table a buffer overflow > shows its ugly head. The sentinel's data element used to be changed when > CONFIG_AX25_DAMA_SLAVE was not defined. I think it's better to define the relation explicitly between the enum and sysctl table by BUILD_BUG_ON() in ax25_register_dev_sysctl() BUILD_BUG_ON(AX25_MAX_VALUES != ARRAY_SIZE(ax25_param_table)); and guard AX25_VALUES_DS_TIMEOUT with #ifdef CONFIG_AX25_DAMA_SLAVE as done for other enum. > This did not have any adverse > effects as we still stopped on the sentinel because of its null > procname. But now that we do not have the sentinel element, we are > careful to check ax25_param_table's size. > > Signed-off-by: Joel Granados > --- > net/ax25/sysctl_net_ax25.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c > index db66e11e7fe8..e55be8817a1e 100644 > --- a/net/ax25/sysctl_net_ax25.c > +++ b/net/ax25/sysctl_net_ax25.c > @@ -141,8 +141,6 @@ static const struct ctl_table ax25_param_table[] = { > .extra2 = &max_ds_timeout > }, > #endif > - > - { } /* that's all, folks! */ > }; > > int ax25_register_dev_sysctl(ax25_dev *ax25_dev) > @@ -155,7 +153,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev) > if (!table) > return -ENOMEM; > > - for (k = 0; k < AX25_MAX_VALUES; k++) > + for (k = 0; k < AX25_MAX_VALUES && k < ARRAY_SIZE(ax25_param_table); k++) > table[k].data = &ax25_dev->values[k]; > > snprintf(path, sizeof(path), "net/ax25/%s", ax25_dev->dev->name); > > -- > 2.43.0