From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id 9CC4238582A3 for ; Tue, 7 Mar 2023 09:46:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CC4238582A3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-536c02c9dfbso234226927b3.11 for ; Tue, 07 Mar 2023 01:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678182372; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NY1xdcuhIfS3EOanAZ531UA5edFcuETvnwATD6obi0o=; b=WVNECECorHozDoD8MqBCUtv8h+SHhwRVRuvJcHQFcFnWD5w+vrgAzpuxXyvcHdM/BT mh2vDGiXgXg1ukajHgOFt4rfZtTznTQHheEpOHTUL2wSVc808OwNc9BtvaOMvf4h0em5 9ygpj+qWgi9lUd9u6VzYc+yNfkYVyxsuKQsQH+O25HuNyGm1xFBvii0LZFeBh6HOVi6E 4yTFhsn4NJ+4BFT1P6/FZ6A8KwktUf+26H4Jqlb745jpjIm6+ORXH6W27ObAhQOLaGgY xA1DsSDzsvIfY7ya8jhzOceIaL2Vs6reXF1htyMFpvbSSqTQx6MythhD4QZqvIEJSTkw Ap9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678182372; 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=NY1xdcuhIfS3EOanAZ531UA5edFcuETvnwATD6obi0o=; b=OtjQ+YxfvBhyJOhmoR0W1pNjNSVRLzQFUoXTN6M4X06oLbD70ViDkVOgmnlhWL/y4a aSyuI+lSZwFg2rvOEAe5EDK/eHoaMNjXBHYQyyhzQX3/Y8Z547FJ9XdQ+eTw+Kv5apqA eIpkSoGFZDLBX2Jlq3DbNJu3bo9KCu9jBljYojinAX+V0uonxZ2zJJ7wsTtOmXaOYOpi Ft+jmZfW0vwTHsZY+jEwebXRYxpQ/XPUZZ7JDHWL2nRGKjR0Gt9xGl31yNz+MStKSoOC fkqyjSIYuiD5Pcr6c/Y84aP2LCIvJ1wIBGDmXOMAnF6EBKIkZR3pfQVb2ECEqbwJeACM GENA== X-Gm-Message-State: AO0yUKUsXqbB+qR6PymlwEKCLpalRNk2LSk7wH4k1Tv7CVgbuH9zmGd0 fcLH7kSKSoEM6nZ4nJ0YxuSIbqBS+LBJ/ICcoYkk0L+yWn98NQ== X-Google-Smtp-Source: AK7set+ybkMsu9SiHyIHVwQh0hrOF+YUwE5MD7ms5daX6uXbvvqdppyGQ0Gno1eHoKt7qHllGyj1Vqls/L0BwCMhpbo= X-Received: by 2002:a81:4317:0:b0:53c:70c7:405b with SMTP id q23-20020a814317000000b0053c70c7405bmr8875894ywa.4.1678182371997; Tue, 07 Mar 2023 01:46:11 -0800 (PST) MIME-Version: 1.0 References: <20230307083229.629411-1-abushwangs@gmail.com> <2ff8bc971b5244496b02ebc99ef623532a1a787b.camel@xry111.site> In-Reply-To: <2ff8bc971b5244496b02ebc99ef623532a1a787b.camel@xry111.site> From: abush wang Date: Tue, 7 Mar 2023 17:46:00 +0800 Message-ID: Subject: Re: [PATCH] rt: fix shm_open not set ENAMETOOLONG when name exceeds {_POSIX_PATH_MAX} To: Xi Ruoyao Cc: libc-alpha@sourceware.org, carlos@redhat.com Content-Type: multipart/alternative; boundary="00000000000026bd1505f64c48cd" X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --00000000000026bd1505f64c48cd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have re-send this patch according to your suggest. Thinks abushwang Xi Ruoyao =E4=BA=8E2023=E5=B9=B43=E6=9C=887=E6=97=A5= =E5=91=A8=E4=BA=8C 16:54=E5=86=99=E9=81=93=EF=BC=9A > On Tue, 2023-03-07 at 16:32 +0800, abushwang via Libc-alpha wrote: > > according to man-pages-posix-2017, shm_open() function may fail if the > length > > of the name argument exceeds {_POSIX_PATH_MAX} and set ENAMETOOLONG > > It's "may" fail, not "shall" fail. POSIX 2017 says "may" means: > > may > > Describes a feature or behavior that is optional for an implementation > that conforms to POSIX.1-2017. An application should not rely on the > existence of the feature or behavior. An application that relies on such > a feature or behavior cannot be assured to be portable across conforming > implementations. > > We should not break existing programs just for a "may" clause. > > /* snip */ > > > int > > __shm_get_name (struct shmdir_name *result, const char *name, bool > > sem_prefix) > > @@ -50,13 +51,15 @@ __shm_get_name (struct shmdir_name *result, const > > char *name, bool sem_prefix) > > while (name[0] =3D=3D '/') > > ++name; > > namelen =3D strlen (name); > > + if (namelen > NAME_MAX) > > + return ENAMETOOLONG; > > > > if (sem_prefix) > > alloc_buffer_copy_bytes (&buffer, "sem.", strlen ("sem.")); > > alloc_buffer_copy_bytes (&buffer, name, namelen + 1); > > if (namelen =3D=3D 0 || memchr (name, '/', namelen) !=3D NULL > > || alloc_buffer_has_failed (&buffer)) > > If you really want ENAMETOOLONG I guess you can check if namelen > > NAME_MAX here (as a very long namelen would have caused an allocation > failure). > > By the way if namelen <=3D NAME_MAX but alloc_buffer_has_failed (due to a > high memory usage) should we say ENOSPC instead of EINVAL? POSIX 2017 > says: > > [ENOSPC] > There is insufficient space for the creation of the new shared memory > object. > > > - return -1; > > + return EINVAL; > > return 0; > > } > > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University > --00000000000026bd1505f64c48cd--