Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8502568rwp; Wed, 19 Jul 2023 10:41:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlHrU8uKp5GgpiREZlhxD1vlTg3ou2IiUguctqz6c5y90/G31bYcwsgpUvziTJWMvf8jIMCI X-Received: by 2002:a17:906:1d7:b0:993:d536:3cb8 with SMTP id 23-20020a17090601d700b00993d5363cb8mr2971011ejj.2.1689788472954; Wed, 19 Jul 2023 10:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689788472; cv=none; d=google.com; s=arc-20160816; b=hEAJhGxSQT0YcfubD/hnY10bIxCvddrPQgkYZxelF/+xNoAdIglSxrrPfqlMDttoXl HO+PEPHANEWaR+e+jDOWa7Oo2W6h79fBob2fvfTGIy6kEa7kaBkzWRjhSwvAQWYlck1Z 8JOqcJetvc8zMAF2nbfNe6TMx9wV2Wo70YEY6fgis+9zmyDcRQYH6DivzgZUTWgVeOgx XykvTNiqHZ2hJljzj+tl6KWsfVvHYcbczj097BUNOUdMqqLK8njZ+JCdxHQUhRzf/5sb 0Y6HBrp7dFFMIuUNi0AL1JPxK1JHzNrpNrSAfhI2aEY+11knoxT/DA5M+sykLatx60Ys Sh7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TQcUan7l1y5Yv0vldMssZE2G80VjsCzDArJ5W4+oGwY=; fh=ZtFECbHo7s4BonE6ONdBXyHdo6kuM6Z6Gbs6g/zBjho=; b=y8ZgJ4VBpNTWJqO0L2DCudUzqRYdp6hS43BVG63dC7Upgd7IWB+PBXC+mX+nnSKZwZ GMNNph2z1eJFMg/Oa9pxxHcGJtYuUNu2YwWcJgr46NksL/feRjEzqJZ757WFiSvkfQRC Nb8oGAJmbVyWB3Qzn4K18UDeX780jEO1eDR/aFrae9Ki/nrKwfoaHyA4LHt71WsN223O 7T/96emjKkePkU7Hoc/OcYlEe47yyZWVZbEssrcHXODnHzVylGLgnL3mmu/tf7WWC61V oDs1Js3y9Ul8c7z2nFwLDWcDIBHuGgabp0aOvP7cB74NN5yHvAW916kdYHEsZL1CNG7D mzhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="cQbmiFa/"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a1709062c4100b00988a4a7abc8si3091753ejh.75.2023.07.19.10.40.49; Wed, 19 Jul 2023 10:41:12 -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=@amazon.com header.s=amazon201209 header.b="cQbmiFa/"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjGSRah (ORCPT + 99 others); Wed, 19 Jul 2023 13:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjGSRaf (ORCPT ); Wed, 19 Jul 2023 13:30:35 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE59CE69; Wed, 19 Jul 2023 10:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1689787835; x=1721323835; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TQcUan7l1y5Yv0vldMssZE2G80VjsCzDArJ5W4+oGwY=; b=cQbmiFa/rdWZsFmxpWCHNp9LK+JoCbJa6H7jRoBc2eupM8mRmxh8BM1M FeaH8s3/KytBWpr+g9F1us9786NICnExLVJ7I9+bVT1OuSgA9vU1jJrMw NVsGuWVP41kOhkq8aWM1EABv3RQ+ZPVd7hfmXaiM8SF0SYWCZyDltBbTt A=; X-IronPort-AV: E=Sophos;i="6.01,216,1684800000"; d="scan'208";a="345522651" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-a893d89c.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2023 17:30:31 +0000 Received: from EX19MTAUWC001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2b-m6i4x-a893d89c.us-west-2.amazon.com (Postfix) with ESMTPS id F2D4740D58; Wed, 19 Jul 2023 17:30:29 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 19 Jul 2023 17:30:29 +0000 Received: from 88665a182662.ant.amazon.com (10.106.101.39) 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.1118.30; Wed, 19 Jul 2023 17:30:25 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , , , , , , Subject: Re: [PATCH net-next] net: Use _K_SS_MAXSIZE instead of absolute value Date: Wed, 19 Jul 2023 10:30:17 -0700 Message-ID: <20230719173017.33951-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.106.101.39] X-ClientProxiedBy: EX19D036UWB001.ant.amazon.com (10.13.139.133) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR 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 From: Breno Leitao Date: Wed, 19 Jul 2023 10:18:49 -0700 > On Wed, Jul 19, 2023 at 10:04:45AM -0700, Kuniyuki Iwashima wrote: > > From: Breno Leitao > > Date: Wed, 19 Jul 2023 01:44:12 -0700 > > > Looking at sk_getsockopt function, it is unclear why 128 is a magical > > > number. > > > > > > Use the proper macro, so it becomes clear to understand what the value > > > mean, and get a reference where it is coming from (user-exported API). > > > > > > Signed-off-by: Breno Leitao > > > --- > > > net/core/sock.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/net/core/sock.c b/net/core/sock.c > > > index 9370fd50aa2c..58b6f00197d6 100644 > > > --- a/net/core/sock.c > > > +++ b/net/core/sock.c > > > @@ -1815,7 +1815,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname, > > > > > > case SO_PEERNAME: > > > { > > > - char address[128]; > > > + char address[_K_SS_MAXSIZE]; > > > > I guess you saw a bug caught by the fortified memcpy(), but this > > doesn't fix it properly. > > Not really, in fact. I was reading this code, and I found this > discussion a while ago, where I got the idea: > > https://lore.kernel.org/lkml/20140930.005925.995989898229686123.davem@davemloft.net/ I got it, but I prefer using struct sockaddr_storage as done in other places. $ grep -rn sockaddr_storage net/ Also, there would be some situations where we must cast each family-specific address back to sockaddr_storage for fortified library. Then, it makes more sense to use sockaddr_storage rather than _K_SS_MAXSIZE.