Message ID | 20230523223944.691076-1-Kenny.Ho@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2465107vqo; Tue, 23 May 2023 15:54:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WqQ/PiGV/vxATPOBER5C2snqAGzG1ziCW9aB0ARlciCdJcmxIeMZ4+nSE6mw9VMkVEO4B X-Received: by 2002:a05:6a00:2342:b0:64b:7c1d:518e with SMTP id j2-20020a056a00234200b0064b7c1d518emr617632pfj.31.1684882464961; Tue, 23 May 2023 15:54:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684882464; cv=pass; d=google.com; s=arc-20160816; b=jI0uPmRq8POkmMUGPrFf6ZeqxAD8Bgp1dteGIOmIiwERz6micEdpkl6oIOTi/UaUJ5 z/SkWr/WSBw7azZ+Vd4DKAYu7dSWIzwcadTInTuPEUv/JcRCBEib6CM9RvWBDlqI5jca S/jdp5XltItPcDS8cBFnRAGbwRwEzThgJcFh8YiHQ/QSytE2vcvPPhfPtLCHydJZfrE3 b71ZxFpFvgcNJMYM4kTa3R4YmaLCXpIEgQuOLjpR/Uxfm7GkV4Kpb3JCOnydJZH6fR+q H2cPaXsf4Fym1IqXxmIIagh3lvrR4wOBj5TQt/wnkFrtALl2b1tTj5ug1l07w3NLE4x9 G5Yg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yVR95slMPVeVhHM6nc6jlrfG95xlCOFBE/tpIAri17w=; b=gjwU46l+X/TtnvQmyzFoTKCm8riM3cqpjViAbSK2ecgVTEaAncRGtWwE4AWL1WOGEp P8FdLqPZpU2yuRrETAb8tQ0WDaS6eviEOOfZbsv2EA6TgsfueBWBFJtCdhy9pzMmA/8O TsW9Cv6qjJ5vskjUxHdiUwK8NKVgaT69zfFilj5TJaam8CmWl9LtRxDrKooP4ec47t0G VI6JsfL0CdpkM6+1jTzGjCk1ojCRh/9KD2rYjtfF9N4dBaS4j9NpIAcv2kPpLkQnN0Gq I5Ca9GOy3c/qkYBaA2yqs3PlxA4eAGbLFirNfr/WuwjoHp8uMTsozBwl30r/UaDvJmnf fU8w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="x/0o+ov6"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z24-20020aa79598000000b0063b1fbbb8c5si4485941pfj.131.2023.05.23.15.54.12; Tue, 23 May 2023 15:54:24 -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=@amd.com header.s=selector1 header.b="x/0o+ov6"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238650AbjEWWk3 (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 18:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbjEWWk2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 18:40:28 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D81CBF; Tue, 23 May 2023 15:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Txw8wEsjghms3flUMUZwcj2sYwtsTj35nI9453XvMXOOGjiqSVl8T0y2EnPfL1ng17Dy8WL8l19AptyobNLREDo7LL0Bk8NBds7CLzveGGji6vfD7JNo0QXKHcdYcdkVZjuWoJQUn8w3tWJccQsLM3dqbOWoq+ngvEiIsnbWawrRa74u5tpR1MLCzl9+pkSu470hyI8bkDCHgqGeJD+5Wc1Fp1v93owbo0EFNjOX73A2u3C+UUShCIoXsutTLZaNgl9zrpCpnHoAFtqIcnVzB0v0DdJcOIU9LHqWCpqUxhYlbsaNQWsJnyRGZEd9yNkyKvrqJ0l997TkQiLy184sZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yVR95slMPVeVhHM6nc6jlrfG95xlCOFBE/tpIAri17w=; b=QskypTJvJflQI9i0ys7n9TsgxPuvFtpTScZYGwnrTG/w4zqcH/bMRKmTsBrNrdndKVcVrTCXUxiPHs155KJX0anrk0gOG1H+Zi5GpyyeYPrGV6ed/ZO5jGukOURFtOyyrYe+cRKfSjc2TusIcQqt/0pVv/yZgQOtKp6pUDsV+fo29ChU91olcLC+mWDAY6He1cnj5PnMu+TaJLaPa1cGABNhJw28esPD8AAHmh1n7qUKgO7Uyz7xIaYVdmHxIkn5NPyLtdvKI8o7Uzxfsu4E5VCFha2LMIDYBLC12S0AsA2/SscVFKTsIhyiZl8xZ/H2k/sG6FA6H2a1ErIJqeKJSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yVR95slMPVeVhHM6nc6jlrfG95xlCOFBE/tpIAri17w=; b=x/0o+ov6cP6tBRAc/aR7eiztMzMAr+BWS6Y+SkgiQNWf+WFQtvrGNtyUO3qmvmQlDa1atcDFx5kWFD0tvPqVVizc58ld0El8a9qffTnIlIfAPeWsTzy+mz/aeA6g9LXEGFJEyffWeihqyeIoTBVQo8/eDkwu/2yEGc57zVuTMiw= Received: from BN9PR03CA0457.namprd03.prod.outlook.com (2603:10b6:408:139::12) by CO6PR12MB5428.namprd12.prod.outlook.com (2603:10b6:5:35c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 22:40:23 +0000 Received: from BN8NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::f0) by BN9PR03CA0457.outlook.office365.com (2603:10b6:408:139::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 22:40:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT088.mail.protection.outlook.com (10.13.177.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Tue, 23 May 2023 22:40:23 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 23 May 2023 17:40:22 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 23 May 2023 15:40:22 -0700 Received: from yuho-dev.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 23 May 2023 17:40:22 -0500 From: Kenny Ho <Kenny.Ho@amd.com> To: David Howells <dhowells@redhat.com>, Marc Dionne <marc.dionne@auristor.com>, "David S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, <linux-afs@lists.infradead.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <y2kenny@gmail.com> CC: Kenny Ho <Kenny.Ho@amd.com> Subject: [PATCH] Remove hardcoded static string length Date: Tue, 23 May 2023 18:39:44 -0400 Message-ID: <20230523223944.691076-1-Kenny.Ho@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT088:EE_|CO6PR12MB5428:EE_ X-MS-Office365-Filtering-Correlation-Id: e953bc36-e3e4-40ba-5fcd-08db5bdeb212 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DW8nbXNv+FVrgCN6+YauDGcIzzMydhLsQsbheevHhYannlLaY/bEkLqvjoTOM0qqCr42reIzYN67GaDY1nk620B0d0xamI+Jm6xDCRNtFamKUes9Ba0mC9oAPYZrJbmKvvBsxleI8FVy0i6r7GzjqS7ucqPYiYQ933NLayuXOsFjJ99Z0gEjWeXY4QCrSUrlJDUDrNA3aWlGacd0EtnJOgdGOec8paDKBlBkCTsd8yqt+YcBIgEWWEDUbkHKNggx4myimKlZDr2KXUTduatB708YOX1jS8Gk6InOQuTXy0TKfhxkw8imbsXvvFz6SvDzOAOU7mZRE2fhvNRTrw9XZxQMcLRJTlayVPuFLJGMbCG8BayKCbfOdeGGEKSE2E/sXvvHRfhBuJfcN4H3XT53M18xBIB9v+4U9a3L885kSp3OhRZZr2Scz47pBl22AXiadFuL+q4DW/lW4iBInIq9qp2UY/q8kr1aF0xOg61z0LJSEG31xQplkHZtWuifF8CCdj5fW9N5FrklLjogyeBZYB3MeyGJRd5+796VwWMPW42luEKQAga+DTivEn+Iu11MD9+R5IIghkJkoATBvkPM0MA+qIpT/SPfGS76JqLxMulstFbQU4nmmx1vPrI9veBX7bziBJaeqstCsYdpaFyRQctoaYPgHr3Wvj/u4aLIDQTzTljMxPbvR+O/3c0k8WKTi5uA8W8d6j+uaNvfZzZL4ohzy8ojKhI4EG0JqFoFEed7f38TudMkVI0ZB2X3FZjOxtuEypB/W8RqEgn04w0EqWwiStCMocEp106KMdGdyO0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(36840700001)(40470700004)(46966006)(41300700001)(70206006)(70586007)(2906002)(40480700001)(4744005)(186003)(1076003)(478600001)(4326008)(6666004)(7696005)(26005)(316002)(5660300002)(110136005)(7416002)(8936002)(8676002)(36860700001)(40460700003)(81166007)(921005)(356005)(36756003)(47076005)(2616005)(426003)(336012)(83380400001)(82310400005)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 22:40:23.1004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e953bc36-e3e4-40ba-5fcd-08db5bdeb212 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5428 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766727315509238297?= X-GMAIL-MSGID: =?utf-8?q?1766727315509238297?= |
Series |
Remove hardcoded static string length
|
|
Commit Message
Ho, Kenny
May 23, 2023, 10:39 p.m. UTC
UTS_RELEASE length can exceed the hardcoded length. This is causing
compile error when WERROR is turned on.
Signed-off-by: Kenny Ho <Kenny.Ho@amd.com>
---
net/rxrpc/local_event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, May 23, 2023 at 06:39:44PM -0400, Kenny Ho wrote: > UTS_RELEASE length can exceed the hardcoded length. This is causing > compile error when WERROR is turned on. > > Signed-off-by: Kenny Ho <Kenny.Ho@amd.com> > --- > net/rxrpc/local_event.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c > index 19e929c7c38b..61d53ee10784 100644 > --- a/net/rxrpc/local_event.c > +++ b/net/rxrpc/local_event.c > @@ -16,7 +16,7 @@ > #include <generated/utsrelease.h> > #include "ar-internal.h" > > -static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC"; > +static const char rxrpc_version_string[] = "linux-" UTS_RELEASE " AF_RXRPC"; This is not an area of the network stack i know about, so please excuse what might be a dumb question. How is the protocol defined here? Is there an RFC or some other sort of standard? A message is being built and sent over a socket. The size of that message was fixed, at 65 + sizeof(whdr). Now the message is variable length. Does the protocol specification actually allow this? Andrew
> I don't think there is an RFC describing RX, but the closest thing to > a spec (https://web.mit.edu/kolya/afs/rx/rx-spec) states: > > "If a server receives a packet with a type value of 13, and the > client-initiated flag set, it should respond with a 65-byte payload > containing a string that identifies the version of AFS software it is > running." > > So while it may not actually cause any issues (the few things that > look at the data just truncate past 65), it's probably best to keep > the response at a fixed 65 bytes. Thanks for the link and the quote. So the compiler warning/error needs to be fixed a different want. Andrew --- pw-bot: cr
On Wed, May 24, 2023 at 12:02 PM Andrew Lunn <andrew@lunn.ch> wrote:
> So the compiler warning/error needs to be fixed a different want.
Understood. Would caping the length at iov_len with a ternary be sufficient?
Regards,
Kenny
On Wed, May 24, 2023 at 01:02:36PM -0400, Kenny Ho wrote: > On Wed, May 24, 2023 at 12:02 PM Andrew Lunn <andrew@lunn.ch> wrote: > > So the compiler warning/error needs to be fixed a different want. > > Understood. Would caping the length at iov_len with a ternary be sufficient? The quoted text said 'string'. It is not clear if that means c-string, with a trailing \0. If you just cap iov_len you could end up with a string which is not terminated. The other end of the socket should not blow up, because that would be an obvious DOS or buffer overwrite attack vector. So you need to decide, do you want to expose such issues and see if anything does actually blow up, or do you want to do a bit more work and correctly terminate the string when capped? Andrew
On Wed, May 24, 2023 at 1:43 PM Andrew Lunn <andrew@lunn.ch> wrote: > > The other end of the socket should not blow up, because that would be > an obvious DOS or buffer overwrite attack vector. So you need to > decide, do you want to expose such issues and see if anything does > actually blow up, or do you want to do a bit more work and correctly > terminate the string when capped? Right... I guess it's not clear to me that existing implementations null-terminate correctly when UTS_RELEASE causes the string to exceed the 65 byte size of rxrpc_version_string. We can of course do better, but I hesitate to do strncpy because I am not familiar with this code base enough to tell if this function is part of some hot path where strncpy matters. Regards, Kenny
From: Kenny Ho > Sent: 24 May 2023 19:01 > > On Wed, May 24, 2023 at 1:43 PM Andrew Lunn <andrew@lunn.ch> wrote: > > > > The other end of the socket should not blow up, because that would be > > an obvious DOS or buffer overwrite attack vector. So you need to > > decide, do you want to expose such issues and see if anything does > > actually blow up, or do you want to do a bit more work and correctly > > terminate the string when capped? > > Right... I guess it's not clear to me that existing implementations > null-terminate correctly when UTS_RELEASE causes the string to exceed > the 65 byte size of rxrpc_version_string. We can of course do better, > but I hesitate to do strncpy because I am not familiar with this code > base enough to tell if this function is part of some hot path where > strncpy matters. The whole thing looks like it is expecting a max of 64 characters and a terminating '\0'. Since UTE_RELEASE goes in between two fixed strings truncating the whole thing to 64/65 chars/bytes doesn't seem ideal. I does rather beg the question as what is in UTS_RELEASE when it exceeds (IIRC) about 48 characters? If UTS_RELEASE is getting that long, it might easily exceed the 64 characters returned by uname(). I suspect that you need to truncate UTS_RELEASE to limit the string to 64 characters - so something like: static char id[65]; if (!id[0]) snprintf(id, sizeof id, "xxx-%.48s-yyy", UTS_RELEASE); Using an on-stack buffer almost certainly wouldn't matter. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Thu, May 25, 2023 at 5:14 AM David Laight <David.Laight@aculab.com> wrote: > > I does rather beg the question as what is in UTS_RELEASE when > it exceeds (IIRC) about 48 characters? Thanks for the question as it made me dig deeper. UTS_RELEASE is actually capped at 64: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Makefile?#n1317 """ uts_len := 64 define filechk_utsrelease.h if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ exit 1; \ ... """ So UTS_RELEASE on its own would fit perfectly by coincidence (and it is also why UTS_RELEASE with the pre and postfix exceeds the limit.) That makes me wonder if the content / format of the version matter and looks like it sort of does by looking at when the string was introduced: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/net/rxrpc/local_object.c?id=44ba06987c0b10faa998b9324850e8a6564c714d "The standard formulation seems to be: <project> <version> built <yyyy>-<mm>-<dd>" That commit also confirms the size and null termination requirement. I will create a separate patch with your suggestion. Regards, Kenny
From: Kenny Ho > Sent: 25 May 2023 15:28 > To: David Laight <David.Laight@ACULAB.COM> > Cc: Andrew Lunn <andrew@lunn.ch>; Marc Dionne <marc.dionne@auristor.com>; Kenny Ho <Kenny.Ho@amd.com>; > David Howells <dhowells@redhat.com>; David S. Miller <davem@davemloft.net>; Eric Dumazet > <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; linux- > afs@lists.infradead.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH] Remove hardcoded static string length > > On Thu, May 25, 2023 at 5:14 AM David Laight <David.Laight@aculab.com> wrote: > > > > I does rather beg the question as what is in UTS_RELEASE when > > it exceeds (IIRC) about 48 characters? > > Thanks for the question as it made me dig deeper. UTS_RELEASE is > actually capped at 64: ... But isn't UTS_RELEASE usually much shorter? I think it is what 'uname -r' prints, the longest I've seen recently is "3.10.0-1127.19.1.el7.x86_64" - well under the limit. ... > > "The standard formulation seems to be: <project> <version> built > <yyyy>-<mm>-<dd>" Which I don't recall the string actually matching? Also the people who like reproducible builds don't like __DATE__. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Thu, May 25, 2023 at 11:04 AM David Laight <David.Laight@aculab.com> wrote: > But isn't UTS_RELEASE usually much shorter? > I think it is what 'uname -r' prints, the longest I've seen recently > is "3.10.0-1127.19.1.el7.x86_64" - well under the limit. Usually yes, but I believe LOCALVERSION can be appended to KERNELRELEASE / UTS_RELEASE which can makes it much longer. > > "The standard formulation seems to be: <project> <version> built > > <yyyy>-<mm>-<dd>" > > Which I don't recall the string actually matching? > Also the people who like reproducible builds don't like __DATE__. That's correct, it was not matching even when it was introduced. I am simply taking that as people caring about the content and not simply making rxrpc_version_string == UTS_RELEASE. The current format is: "linux-" UTS_RELEASE " AF_RXRPC" Kenny
From: Jeffrey E Altman > Sent: 27 May 2023 16:09 > > On 5/25/2023 11:37 AM, Kenny Ho wrote: > > On Thu, May 25, 2023 at 11:04 AM David Laight<David.Laight@aculab.com> wrote: > >>> "The standard formulation seems to be: <project> <version> built > >>> <yyyy>-<mm>-<dd>" > >> Which I don't recall the string actually matching? > >> Also the people who like reproducible builds don't like __DATE__. > > That's correct, it was not matching even when it was introduced. I am > > simply taking that as people caring about the content and not simply > > making rxrpc_version_string == UTS_RELEASE. The current format is: > > > > "linux-" UTS_RELEASE " AF_RXRPC" > > > > Kenny > > The RX_PACKET_TYPE_VERSION query is issued by the "rxdebug <host> <port> > -version" command which prints the received string to stdout. It has > also been used some implementations to record the version of the peer. > Although it is required that a response to the RX_PACKET_TYPE_VERSION > query be issued, there is no requirement that the returned string > contain anything beyond a single NUL octet. Does that mean that the zero-padding/truncation to 65 bytes is bogus? Additionally is the response supposed to the '\0' terminated? The existing code doesn't guarantee that at all. > Although it is convenient to be able to remotely identify the version of > an Rx implementation, there are good reasons why this information should > not be exposed to an anonymous requester: > > 1. Linux AF_RXRPC is part of the kernel. As such, returning > UTS_RELEASE identifies to potential attackers the explicit kernel > version, architecture and perhaps distro. As this query can be > issued anonymously, this provides an information disclosure that can > be used to target known vulnerabilities in the kernel. I guess it could even be used as a probe to find more/interesting systems to attack once inside the firewall. > 2. The RX_PACKET_TYPE_VERSION reply is larger than the query by the > number of octets in the version data. As the query is received via > udp with no reachability test, it means that the > RX_PACKET_TYPE_VERSION query/response can be used to perform an 3.3x > amplification attack: 28 octets in and potentially 93 octets out. > > With my security hat on I would suggest that either AF_RXRPC return a > single NUL octet or the c-string "AF_RXRPC" and nothing more. Is there any point including "AF_RXRPC"? It is almost certainly implied by the message format. Or the exact text from the standard - which might be: "version string - to be supplied by O.E.M." (I've seen hardware versions with strings like the above that exactly match the datasheet....) Limiting the version to (eg) 6.2 would give a hint to the capabilities/bugs without giving away all the relative addresses in something like a RHEL kernel. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/net/rxrpc/local_event.c b/net/rxrpc/local_event.c index 19e929c7c38b..61d53ee10784 100644 --- a/net/rxrpc/local_event.c +++ b/net/rxrpc/local_event.c @@ -16,7 +16,7 @@ #include <generated/utsrelease.h> #include "ar-internal.h" -static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC"; +static const char rxrpc_version_string[] = "linux-" UTS_RELEASE " AF_RXRPC"; /* * Reply to a version request