GNU bug report logs - #40509
Use of fsetxattr() in cp tickles an EXT leak (possibly unnecessarily so)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Gregg Leventhal <gleventhal@HIDDEN>; dated Wed, 8 Apr 2020 15:11:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at 40509 <at> debbugs.gnu.org:


Received: (at 40509) by debbugs.gnu.org; 15 Apr 2020 23:31:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 15 19:31:02 2020
Received: from localhost ([127.0.0.1]:37309 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jOrUk-0002tB-FN
	for submit <at> debbugs.gnu.org; Wed, 15 Apr 2020 19:31:02 -0400
Received: from mxout1.mail.janestreet.com ([38.105.200.78]:48135)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gleventhal@HIDDEN>) id 1jOrMg-0001f1-2p
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 19:22:42 -0400
X-JS-Received: from [30.32.81.38] (helo=igm-qpr-mailcore1)
 by mxout1.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2)
 (envelope-from <gleventhal@HIDDEN>) id 1jOrMa-0005aP-1U
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 19:22:36 -0400
X-JS-Flow: external
X-JS-Received: by igm-qpr-mailcore1 with ocaml/mailcore/main_production
 (c4a4bbc04b22) (envelope-from <gleventhal@HIDDEN>)
 id Bel5c8-nbarYA-Ax; 2020-04-15 19:22:36.030473-04:00
X-JS-Scanner-attachment: No attachments
X-JS-Scanner-esets: Not scanned (internal mail)
Received: from mail-io1-f70.google.com ([209.85.166.70])
 by mxgoog2.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2)
 id 1jOrMZ-0003jZ-VM
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 19:22:36 -0400
Received: by mail-io1-f70.google.com with SMTP id n26so22041373iop.1
 for <40509 <at> debbugs.gnu.org>; Wed, 15 Apr 2020 16:22:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=janestreet.com; s=google;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=pksA2encbBIRPd6Mopo+FgrNQriqWkXlfx9H+uPRIWA=;
 b=z/6zq3G5Rfwrw5cah7A7beo97uc3Ns1rDXEA/40mIGSarXPTuUP19wg/rBycIaHYrh
 xI2zMPEIhHgh8o18GfqNpM9jItG4Frscy03zt6/1PSIYgfoD81nHlzw/5B6R5o+lP1tV
 XofIT5GdQ9jFg/N/gRz9FoWrz+BbMDGLH5q7w=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=pksA2encbBIRPd6Mopo+FgrNQriqWkXlfx9H+uPRIWA=;
 b=OEBrSSHxjGXBrxoJS//3AQHhRd2cihpLKiIgJIylAYDJyO1eLFhP5ZR5r692VXPw2f
 Rkn049w8RBVDknr+TUN/SRfvzUMgyyMnZd+Y/u7yGHoz8miURJ7eFW6HyphubuGManQY
 7Dpu4gzrxTcE5MdqhcdFy9s5pK+B2FuLSFdPUWhIkBZOemfHo5CaIzA8Wrz6MDkleDLc
 5lU5+Kw/E9jcTgdSsUax2QjCtIp1yzvndhYlMTapuHjGGwahB28qKx9oGL3ZfPYHI9mp
 JRmncsaVQ52VkLMUoXQzKRjZ5u3OOHrct7dfE5qI40+PANLcvWTI3lrAnTg6TPj1jr3I
 ULqw==
X-Gm-Message-State: AGi0PuZqJmv7AuHi8DKU6xQm3cBTG/Y1VNljHprFVfnTRNQiG6AszKI6
 N0B9KnH3jfuQ9BQOGCN72ekowx+xg99Bn3pGR7s253FrSVlz23D9JV9FTuDSxcCBRQyx2oT+jq0
 9Y75GWhePDGf2jLRFPjx0BlZrdkoJ6Q==
X-Received: by 2002:a92:3b1b:: with SMTP id i27mr8340379ila.230.1586992955534; 
 Wed, 15 Apr 2020 16:22:35 -0700 (PDT)
X-Google-Smtp-Source: APiQypKxD8J4rwFTbvbkNJbq6V+jtBoK8/FZNt2hmA/0xeJkNCAOIuBODvCUfiNKwLAQlGZIFW07BJLEWLjVhvoZrsc=
X-Received: by 2002:a92:3b1b:: with SMTP id i27mr8340369ila.230.1586992955381; 
 Wed, 15 Apr 2020 16:22:35 -0700 (PDT)
MIME-Version: 1.0
References: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
 <e4f77f21-9af4-fb63-296d-89153af6eb8c@HIDDEN>
 <CAFN_u7Ex6NYhp84h+tTxLgLcH2HMj8onWohDOji_hwpmhCOgHg@HIDDEN>
 <b50aa2d7-66d5-d55e-0e74-a9da920d05cf@HIDDEN>
In-Reply-To: <b50aa2d7-66d5-d55e-0e74-a9da920d05cf@HIDDEN>
From: Gregg Leventhal <gleventhal@HIDDEN>
Date: Wed, 15 Apr 2020 19:22:24 -0400
Message-ID: <CAFN_u7EmJ8eM=Ym_0pJuUZdQKEt9fZ9CVR2N=XeztmdLxu9B=A@HIDDEN>
Subject: Re: bug#40509: Use of fsetxattr() in cp tickles an EXT leak (possibly
 unnecessarily so)
To: Paul Eggert <eggert@HIDDEN>
Content-Type: multipart/alternative; boundary="0000000000005df4f405a35c971d"
X-JS-Exim-Data-Received: 2020-04-15 19:22:36-0400
X-JS-Processed-by: mailcore
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 40509
X-Mailman-Approved-At: Wed, 15 Apr 2020 19:31:01 -0400
Cc: 40509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--0000000000005df4f405a35c971d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Sure that=E2=80=99s fine (regarding copyright), just let me know what to fi=
ll out
please.

On Wed, Apr 15, 2020 at 6:55 PM Paul Eggert <eggert@HIDDEN> wrote:

> On 4/15/20 7:11 AM, Gregg Leventhal wrote:
>
> > +    xattr_size =3D flistxattr(src_fd, list, size);
> > +    if ( xattr_size || errno =3D=3D ERANGE )
>
> Surely this should be 'if (flistxattr (src_fd, NULL, 0) < 0 && errno =3D=
=3D
> ERANGE)'.
>
> > If you agree with this direction, I can continue, addressing other
> affected
> > code paths (i.e --preserve=3Dmode).
>
> This sounds like a good thing to do. Before you spend a lot of time on it=
,
> though, would you be willing to assign copyright to your work product to
> the FSF
> so that we could install the patch? If so, I can send you email on how to
> fill
> out the paperwork; if not, we'd better arrange for someone else to write
> the fix.
>

--0000000000005df4f405a35c971d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div><div dir=3D"auto">Sure that=E2=80=99s fine (regarding copyright), just=
 let me know what to fill out please.</div></div><div><br><div class=3D"gma=
il_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr 15, 2020 at 6:5=
5 PM Paul Eggert &lt;<a href=3D"mailto:eggert@HIDDEN">eggert@HIDDEN=
du</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 4/15/20 7:11 A=
M, Gregg Leventhal wrote:<br>
<br>
&gt; +=C2=A0 =C2=A0 xattr_size =3D flistxattr(src_fd, list, size);<br>
&gt; +=C2=A0 =C2=A0 if ( xattr_size || errno =3D=3D ERANGE )<br>
<br>
Surely this should be &#39;if (flistxattr (src_fd, NULL, 0) &lt; 0 &amp;&am=
p; errno =3D=3D ERANGE)&#39;.<br>
<br>
&gt; If you agree with this direction, I can continue, addressing other aff=
ected<br>
&gt; code paths (i.e --preserve=3Dmode).<br>
<br>
This sounds like a good thing to do. Before you spend a lot of time on it, =
<br>
though, would you be willing to assign copyright to your work product to th=
e FSF <br>
so that we could install the patch? If so, I can send you email on how to f=
ill <br>
out the paperwork; if not, we&#39;d better arrange for someone else to writ=
e the fix.<br>
</blockquote></div></div>

--0000000000005df4f405a35c971d--




Information forwarded to bug-coreutils@HIDDEN:
bug#40509; Package coreutils. Full text available.

Message received at 40509 <at> debbugs.gnu.org:


Received: (at 40509) by debbugs.gnu.org; 15 Apr 2020 22:56:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 15 18:56:06 2020
Received: from localhost ([127.0.0.1]:37279 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jOqww-00012l-3a
	for submit <at> debbugs.gnu.org; Wed, 15 Apr 2020 18:56:06 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:50934)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1jOqwr-00012C-L3
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 18:56:04 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id C06C4160085;
 Wed, 15 Apr 2020 15:55:53 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id q831CkEoKzY4; Wed, 15 Apr 2020 15:55:53 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 19DF51600AF;
 Wed, 15 Apr 2020 15:55:53 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id pQksSjukq_Vy; Wed, 15 Apr 2020 15:55:53 -0700 (PDT)
Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com
 [23.242.74.103])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EA62E160085;
 Wed, 15 Apr 2020 15:55:52 -0700 (PDT)
Subject: Re: bug#40509: Use of fsetxattr() in cp tickles an EXT leak (possibly
 unnecessarily so)
To: Gregg Leventhal <gleventhal@HIDDEN>
References: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
 <e4f77f21-9af4-fb63-296d-89153af6eb8c@HIDDEN>
 <CAFN_u7Ex6NYhp84h+tTxLgLcH2HMj8onWohDOji_hwpmhCOgHg@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <b50aa2d7-66d5-d55e-0e74-a9da920d05cf@HIDDEN>
Date: Wed, 15 Apr 2020 15:55:52 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.7.0
MIME-Version: 1.0
In-Reply-To: <CAFN_u7Ex6NYhp84h+tTxLgLcH2HMj8onWohDOji_hwpmhCOgHg@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 40509
Cc: 40509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 4/15/20 7:11 AM, Gregg Leventhal wrote:

> +    xattr_size = flistxattr(src_fd, list, size);
> +    if ( xattr_size || errno == ERANGE )

Surely this should be 'if (flistxattr (src_fd, NULL, 0) < 0 && errno == ERANGE)'.

> If you agree with this direction, I can continue, addressing other affected
> code paths (i.e --preserve=mode).

This sounds like a good thing to do. Before you spend a lot of time on it, 
though, would you be willing to assign copyright to your work product to the FSF 
so that we could install the patch? If so, I can send you email on how to fill 
out the paperwork; if not, we'd better arrange for someone else to write the fix.




Information forwarded to bug-coreutils@HIDDEN:
bug#40509; Package coreutils. Full text available.

Message received at 40509 <at> debbugs.gnu.org:


Received: (at 40509) by debbugs.gnu.org; 15 Apr 2020 14:56:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 15 10:56:29 2020
Received: from localhost ([127.0.0.1]:36914 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jOjSm-00010U-G0
	for submit <at> debbugs.gnu.org; Wed, 15 Apr 2020 10:56:29 -0400
Received: from mxout1.mail.janestreet.com ([38.105.200.78]:55304)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gleventhal@HIDDEN>) id 1jOimK-0008GL-51
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 10:12:37 -0400
X-JS-Received: from [30.32.81.38] (helo=igm-qpr-mailcore1)
 by mxout1.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2)
 (envelope-from <gleventhal@HIDDEN>) id 1jOimE-0008BM-II
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 10:12:30 -0400
X-JS-Flow: external
X-JS-Received: by igm-qpr-mailcore1 with ocaml/mailcore/main_production
 (c4a4bbc04b22) (envelope-from <gleventhal@HIDDEN>)
 id BelxZO-YsXbgA-Qt; 2020-04-15 10:12:30.559680-04:00
X-JS-Scanner-attachment: No attachments
X-JS-Scanner-esets: Not scanned (internal mail)
Received: from mail-il1-f197.google.com ([209.85.166.197])
 by mxgoog2.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2)
 id 1jOimE-0004kN-FN
 for 40509 <at> debbugs.gnu.org; Wed, 15 Apr 2020 10:12:30 -0400
Received: by mail-il1-f197.google.com with SMTP id s7so4504246ilo.17
 for <40509 <at> debbugs.gnu.org>; Wed, 15 Apr 2020 07:12:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=janestreet.com; s=google;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=Yh/d6pbe286X4aLaUqVOzd2PHY3DsHt5CEk7rL/4cOA=;
 b=2KLc3tqL1LiaKj32+FkQl38IXQPzXcpNEufxmZ9DEpZAuoTwgqgwyrEcOqvSPZblsC
 Ql3rdER6Wc3N/Qu50ri4hER/oVAcjpI3of9uMauS62JhmR0QHRyYrCJZId4gGgBG5BOS
 AsuCCU4k9a7ynv3G8wEDzoNSLv/21OyWVQxsU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=Yh/d6pbe286X4aLaUqVOzd2PHY3DsHt5CEk7rL/4cOA=;
 b=VTUJS46n0CVvrOBeWrXEgh23lJvKgEEMhNxacjxna3w2CCLQVWjM5uFE6DrYuTXBtv
 jBR/TbjoyI5SojJLLchZnZ5kfaMMuI+MNvguOIatpNDRVPY+tyFt/ciCwjevyINKIIYk
 gRvM1vdSh9tjzLnUJYSr3GHKk2u3gtvaXHPhs1Ry1qi3FHgcxVASJxo8rxKqKlSftr6v
 CelLOFYL+WoHOYqKRtBc4JdgdpZqGlKHxqogD4ApDkzN5qWSNvwfWDOEWnTqKWTKsfGC
 VfdooGLQ8Y2TSJMAUtqG9BiW/2u7/iodR8wXpDHHPo9u91gllKkxUEje2163CKbmMkGJ
 w7+Q==
X-Gm-Message-State: AGi0PuYEJ4jMxoD2594uv8XHkK/odS/gGL63wOYLsJW/PlvERpVuR+9q
 iwIOV3zFTGI7vvJ57cNGfXwopuNOiHbMg1KbhiM9N4SISticj2t9moQ5AkM+foIF7/RS5nQPgsx
 D0/7LBG3iclODFrg5tUBnZaqF3zKNTw==
X-Received: by 2002:a02:1049:: with SMTP id 70mr1371259jay.94.1586959949551;
 Wed, 15 Apr 2020 07:12:29 -0700 (PDT)
X-Google-Smtp-Source: APiQypJh70uheR8KWnlUBkRA0/kZdgd/OKG+SCDDtPJUxAAQ1zckSRCjUAECtr6yccvlCLEIdIokkp+/hYA1fFScaQg=
X-Received: by 2002:a02:1049:: with SMTP id 70mr1371216jay.94.1586959949100;
 Wed, 15 Apr 2020 07:12:29 -0700 (PDT)
MIME-Version: 1.0
References: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
 <e4f77f21-9af4-fb63-296d-89153af6eb8c@HIDDEN>
In-Reply-To: <e4f77f21-9af4-fb63-296d-89153af6eb8c@HIDDEN>
From: Gregg Leventhal <gleventhal@HIDDEN>
Date: Wed, 15 Apr 2020 10:11:53 -0400
Message-ID: <CAFN_u7Ex6NYhp84h+tTxLgLcH2HMj8onWohDOji_hwpmhCOgHg@HIDDEN>
Subject: Re: bug#40509: Use of fsetxattr() in cp tickles an EXT leak (possibly
 unnecessarily so)
To: Paul Eggert <eggert@HIDDEN>
Content-Type: multipart/alternative; boundary="0000000000000a148005a354e878"
X-JS-Exim-Data-Received: 2020-04-15 10:12:30-0400
X-JS-Processed-by: mailcore
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 40509
X-Mailman-Approved-At: Wed, 15 Apr 2020 10:56:26 -0400
Cc: 40509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--0000000000000a148005a354e878
Content-Type: text/plain; charset="UTF-8"

Paul,
Your understanding is correct.  The problem in cp is that it uses
acl_get_fd or acl_get_file which will always return an ACL on EXT4,
therefore contriving an ACL to set on the target when it doesn't exist on
the source.
This causes an extraneous fsetxattr, and hits several arguably
unnecessary functions from libattr and libacl (since if there are no
xattrs, it doesn't make sense to check for ACLs when they're built on top
of xattrs)

Since ACLs cannot exist without xattrs on EXT4, I propose we simply check
for the existence of xattrs early on and bailout early if they're not found.

A simple patch that attempts to do this, and seems to work for the cp -a
case is below.  It basically checks for the size of the list of xattrs, and
if it's > 0 or ERANGE is returned (signifying that the buffer isn't large
enough to hold the entire list), then we know that we have xattrs,
otherwise bail out.

--- src/copy.c 2020-04-09 09:30:08.279516111 -0400
+++ src/copy.c 2020-04-09 15:21:47.939897542 -0400
@@ -16,11 +16,13 @@

 /* Extracted from cp.c and librarified by Jim Meyering.  */

+
 #include <config.h>
 #include <stdio.h>
 #include <assert.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
+#include <attr/xattr.h>
 #include <selinux/selinux.h>

 #if HAVE_HURD_H
@@ -536,6 +538,9 @@
   bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
   bool some_errors = (!all_errors && !x->reduce_diagnostics);
   bool selinux_done = (x->preserve_security_context ||
x->set_security_context);
+  ssize_t xattr_size;
+  size_t size = 0;
+  char *list;
   struct error_context ctx =
   {
     .error = all_errors ? copy_attr_allerror : copy_attr_error,
@@ -543,13 +548,28 @@
     .quote_free = copy_attr_free
   };
   if (0 <= src_fd && 0 <= dst_fd)
-    ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
-                        selinux_done ? check_selinux_attr : NULL,
-                        (all_errors || some_errors ? &ctx : NULL));
-  else
-    ret = attr_copy_file (src_path, dst_path,
+  {
+
+    xattr_size = flistxattr(src_fd, list, size);
+    if ( xattr_size || errno == ERANGE )
+    {
+      ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
                           selinux_done ? check_selinux_attr : NULL,
                           (all_errors || some_errors ? &ctx : NULL));
+    }
+    else
+      ret = (int)xattr_size;
+  }
+  else
+  {
+    xattr_size = listxattr(src_path, list, size);
+    if ( xattr_size || errno == ERANGE )
+      ret = attr_copy_file (src_path, dst_path,
+                            selinux_done ? check_selinux_attr : NULL,
+                            (all_errors || some_errors ? &ctx : NULL));
+    else
+      ret = (int)xattr_size;
+  }

   return ret == 0;
 }

If you agree with this direction, I can continue, addressing other affected
code paths (i.e --preserve=mode).  Either way, I am interested to hear your
thoughts.
It also might make sense to wrap this in a file system check and only do
this for EXT4, since I don't know if xattrs and acls are mutually inclusive
on all supported file systems.


*EXAMPLE of behavior difference between rsync -A and cp -a*
# Create non-empty source files
$ echo source file | tee cp_src rsync_src

# cp attempts to setxattr even though no extended attributes exist
$ strace -f cp -a cp_src cp_dest |& egrep -i 'acl|attr'
open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
flistxattr(3, NULL, 0)                  = 0
flistxattr(3, 0x7fffee2db2c0, 0)        = 0
fgetxattr(3, "system.posix_acl_access", 0x7fffee2db1c0, 132) = -1 ENODATA
(No data available)
fsetxattr(4, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\4\0\6\0\377\377\377\377
\0\4\0\377\377\377\377", 28, 0) = 0

# Rsync doesn't attempt an extraneous fsetxattr
$ strace -f rsync -A rsync_src rsync_dest |& egrep -i 'acl|attr'
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
 getxattr("rsync_src", "system.posix_acl_access", 0x7ffe9e150290, 132) = -1
ENODATA (No data available)
 getxattr(".rsync_dest.HgYAGV", "system.posix_acl_access", 0x7ffe9e14f100,
132) = -1 ENODATA (No data available)


# Add ACLS (and by extension, xattrs) to the source files
$ setfacl -m user:gleventhal:rwx cp_src
$ setfacl -m user:gleventhal:rwx rsync_src

# cp behaves the same
$ strace -f cp -a cp_src cp_dest2 |& egrep -i 'acl|attr'
open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
flistxattr(3, NULL, 0)                  = 24
flistxattr(3, "system.posix_acl_access\0", 24) = 24
open("/etc/xattr.conf", O_RDONLY)       = -1 ENOENT (No such file or
directory)
fgetxattr(3, "system.posix_acl_access", NULL, 0) = 44
fgetxattr(3, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 44) = 44
fsetxattr(4, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 44, 0) = 0
fgetxattr(3, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 132) = 44
fsetxattr(4, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 44, 0) = 0

# rsync now does the set, because xattrs actually exist
$ strace -f rsync -A rsync_src rsync_dest2 |& egrep -i 'acl|attr'
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
 getxattr("rsync_src", "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 132) = 44
 getxattr(".rsync_dest2.DjNiRs", "system.posix_acl_access", 0x7ffeac4780d0,
132) = -1 ENODATA (No data available)
 setxattr(".rsync_dest2.DjNiRs", "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377
\0\4\0\377\377\377\377", 44, 0) = 0

On Wed, Apr 8, 2020 at 1:32 PM Paul Eggert <eggert@HIDDEN> wrote:

> On 4/8/20 7:15 AM, Gregg Leventhal wrote:
>
> > rsync doesn't make set/get xattr calls and purports to preserve ACLs with
> > -A.
>
> I'm not quite following your bug report, but it appears that you're saying
> that
> cp could somehow discover that it needn't use fgetxattr and fsetxattr on
> files
> that lack extended attributes, and for those files cp could stick with
> ordinary
> POSIX syscalls (e.g., umask, chmod) to give files proper permissions, and
> in
> that case 'cp' would presumably (a) operate more efficiently and (b) not
> trigger
> a bug in the EXT filesystem.
>
> This sounds like a worthy suggestion, though of course it would be better
> to
> have a concrete proposal in the form of a coreutils patch, along with a
> few
> performance measurements. For starters, how does rsync do it?
>
> Also, of course EXT should be fixed regardless of what coreutils does here.
>

--0000000000000a148005a354e878
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Paul,</div><div>Your understanding is correct.=C2=A0 =
The problem in cp is that it uses acl_get_fd or acl_get_file which will alw=
ays return an ACL on EXT4, therefore contriving an ACL to=C2=A0set on the t=
arget when it doesn&#39;t exist on the source.=C2=A0=C2=A0</div><div>This c=
auses an extraneous fsetxattr, and hits several arguably unnecessary=C2=A0f=
unctions from libattr and libacl (since if there are no xattrs, it doesn&#3=
9;t make sense to check for ACLs when they&#39;re built on top of xattrs)</=
div><div><br></div><div>Since ACLs cannot exist without xattrs on EXT4, I p=
ropose we simply check for the existence of xattrs early on and bailout ear=
ly if they&#39;re not found.<br><br>A simple patch that attempts to do this=
, and seems to work for the cp -a case is below.=C2=A0 It basically checks =
for the size of the list of xattrs, and if it&#39;s &gt; 0 or ERANGE is ret=
urned (signifying that the buffer isn&#39;t large enough to hold the entire=
 list), then we know that we have xattrs, otherwise bail out.=C2=A0=C2=A0<b=
r><br>--- src/copy.c	2020-04-09 09:30:08.279516111 -0400<br>+++ src/copy.c	=
2020-04-09 15:21:47.939897542 -0400<br>@@ -16,11 +16,13 @@<br>=C2=A0<br>=C2=
=A0/* Extracted from cp.c and librarified by Jim Meyering. =C2=A0*/<br>=C2=
=A0<br>+<br>=C2=A0#include &lt;config.h&gt;<br>=C2=A0#include &lt;stdio.h&g=
t;<br>=C2=A0#include &lt;assert.h&gt;<br>=C2=A0#include &lt;sys/ioctl.h&gt;=
<br>=C2=A0#include &lt;sys/types.h&gt;<br>+#include &lt;attr/xattr.h&gt;<br=
>=C2=A0#include &lt;selinux/selinux.h&gt;<br>=C2=A0<br>=C2=A0#if HAVE_HURD_=
H<br>@@ -536,6 +538,9 @@<br>=C2=A0 =C2=A0bool all_errors =3D (!x-&gt;data_c=
opy_required || x-&gt;require_preserve_xattr);<br>=C2=A0 =C2=A0bool some_er=
rors =3D (!all_errors &amp;&amp; !x-&gt;reduce_diagnostics);<br>=C2=A0 =C2=
=A0bool selinux_done =3D (x-&gt;preserve_security_context || x-&gt;set_secu=
rity_context);<br>+ =C2=A0ssize_t xattr_size;<br>+ =C2=A0size_t size =3D 0;=
<br>+ =C2=A0char *list;<br>=C2=A0 =C2=A0struct error_context ctx =3D<br>=C2=
=A0 =C2=A0{<br>=C2=A0 =C2=A0 =C2=A0.error =3D all_errors ? copy_attr_allerr=
or : copy_attr_error,<br>@@ -543,13 +548,28 @@<br>=C2=A0 =C2=A0 =C2=A0.quot=
e_free =3D copy_attr_free<br>=C2=A0 =C2=A0};<br>=C2=A0 =C2=A0if (0 &lt;=3D =
src_fd &amp;&amp; 0 &lt;=3D dst_fd)<br>- =C2=A0 =C2=A0ret =3D attr_copy_fd =
(src_path, src_fd, dst_path, dst_fd,<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0selinux_done ? check_se=
linux_attr : NULL,<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(all_errors || some_errors ? &amp;ctx : N=
ULL));<br>- =C2=A0else<br>- =C2=A0 =C2=A0ret =3D attr_copy_file (src_path, =
dst_path,<br>+ =C2=A0{<br>+<br>+ =C2=A0 =C2=A0xattr_size =3D flistxattr(src=
_fd, list, size);<br>+ =C2=A0 =C2=A0if ( xattr_size || errno =3D=3D ERANGE =
)<br>+ =C2=A0 =C2=A0{<br>+ =C2=A0 =C2=A0 =C2=A0ret =3D attr_copy_fd (src_pa=
th, src_fd, dst_path, dst_fd,<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0selinux_done ? check=
_selinux_attr : NULL,<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(all_errors || some_errors =
? &amp;ctx : NULL));<br>+ =C2=A0 =C2=A0}<br>+ =C2=A0 =C2=A0else<br>+ =C2=A0=
 =C2=A0 =C2=A0ret =3D (int)xattr_size;<br>+ =C2=A0}<br>+ =C2=A0else<br>+ =
=C2=A0{<br>+ =C2=A0 =C2=A0xattr_size =3D listxattr(src_path, list, size);<b=
r>+ =C2=A0 =C2=A0if ( xattr_size || errno =3D=3D ERANGE )<br>+ =C2=A0 =C2=
=A0 =C2=A0ret =3D attr_copy_file (src_path, dst_path,<br>+ =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0selinux_done ? check_selinux_attr : NULL,<br>+ =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0(all_errors || some_errors ? &amp;ctx : NULL));<br>+ =C2=A0 =C2=A0els=
e<br>+ =C2=A0 =C2=A0 =C2=A0ret =3D (int)xattr_size;<br>+ =C2=A0}<br>=C2=A0<=
br>=C2=A0 =C2=A0return ret =3D=3D 0;<br>=C2=A0}<br><br>If you agree with th=
is direction, I can continue, addressing other affected code paths (i.e --p=
reserve=3Dmode).=C2=A0 Either way, I am interested to hear your thoughts.=
=C2=A0=C2=A0</div><div>It also might make sense to wrap this in a file syst=
em check and only do this for EXT4, since I don&#39;t know if xattrs and ac=
ls are mutually inclusive on all supported file systems.</div><div><br></di=
v><div><br></div><div><b>EXAMPLE of behavior difference between rsync -A an=
d cp -a</b></div># Create non-empty source files<br>$ echo source file | te=
e cp_src rsync_src<br><br># cp attempts to setxattr even though no extended=
 attributes exist<br>$ strace -f cp -a cp_src cp_dest |&amp; egrep -i &#39;=
acl|attr&#39;<br>open(&quot;/lib64/libacl.so.1&quot;, O_RDONLY|O_CLOEXEC) =
=3D 3<br>open(&quot;/lib64/libattr.so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br=
>flistxattr(3, NULL, 0) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0=3D 0<br>flistxattr(3, 0x7fffee2db2c0, 0) =C2=A0 =C2=A0 =C2=A0=
 =C2=A0=3D 0<br>fgetxattr(3, &quot;system.posix_acl_access&quot;, 0x7fffee2=
db1c0, 132) =3D -1 ENODATA (No data available)<br>fsetxattr(4, &quot;system=
.posix_acl_access&quot;, &quot;\2\0\0\0\1\0\6\0\377\377\377\377\4\0\6\0\377=
\377\377\377 \0\4\0\377\377\377\377&quot;, 28, 0) =3D 0<br><br># Rsync does=
n&#39;t attempt an extraneous fsetxattr<br>$ strace -f rsync -A rsync_src r=
sync_dest |&amp; egrep -i &#39;acl|attr&#39; <br>open(&quot;/lib64/libattr.=
so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br>open(&quot;/lib64/libacl.so.1&quot=
;, O_RDONLY|O_CLOEXEC) =3D 3<br>=C2=A0getxattr(&quot;rsync_src&quot;, &quot=
;system.posix_acl_access&quot;, 0x7ffe9e150290, 132) =3D -1 ENODATA (No dat=
a available) <br>=C2=A0getxattr(&quot;.rsync_dest.HgYAGV&quot;, &quot;syste=
m.posix_acl_access&quot;, 0x7ffe9e14f100, 132) =3D -1 ENODATA (No data avai=
lable) <br>=C2=A0 <br>=C2=A0 <br># Add ACLS (and by extension, xattrs) to t=
he source files<br>$ setfacl -m user:gleventhal:rwx cp_src <br>$ setfacl -m=
 user:gleventhal:rwx rsync_src <br>=C2=A0 <br># cp behaves the same<br>$ st=
race -f cp -a cp_src cp_dest2 |&amp; egrep -i &#39;acl|attr&#39; <br>open(&=
quot;/lib64/libacl.so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br>open(&quot;/lib=
64/libattr.so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br>flistxattr(3, NULL, 0) =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 24<br>fli=
stxattr(3, &quot;system.posix_acl_access\0&quot;, 24) =3D 24<br>open(&quot;=
/etc/xattr.conf&quot;, O_RDONLY) =C2=A0 =C2=A0 =C2=A0 =3D -1 ENOENT (No suc=
h file or directory)<br>fgetxattr(3, &quot;system.posix_acl_access&quot;, N=
ULL, 0) =3D 44<br>fgetxattr(3, &quot;system.posix_acl_access&quot;, &quot;\=
2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20=
\0\7\0\377\377\377\377 \0\4\0\377\377\377\377&quot;, 44) =3D 44<br>fsetxatt=
r(4, &quot;system.posix_acl_access&quot;, &quot;\2\0\0\0\1\0\6\0\377\377\37=
7\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377 \0\=
4\0\377\377\377\377&quot;, 44, 0) =3D 0<br>fgetxattr(3, &quot;system.posix_=
acl_access&quot;, &quot;\2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4=
\0\6\0\377\377\377\377\20\0\7\0\377\377\377\377 \0\4\0\377\377\377\377&quot=
;, 132) =3D 44<br>fsetxattr(4, &quot;system.posix_acl_access&quot;, &quot;\=
2\0\0\0\1\0\6\0\377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20=
\0\7\0\377\377\377\377 \0\4\0\377\377\377\377&quot;, 44, 0) =3D 0<br><br># =
rsync now does the set, because xattrs actually exist<br>$ strace -f rsync =
-A rsync_src rsync_dest2 |&amp; egrep -i &#39;acl|attr&#39; <br>open(&quot;=
/lib64/libattr.so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br>open(&quot;/lib64/l=
ibacl.so.1&quot;, O_RDONLY|O_CLOEXEC) =3D 3<br>=C2=A0getxattr(&quot;rsync_s=
rc&quot;, &quot;system.posix_acl_access&quot;, &quot;\2\0\0\0\1\0\6\0\377\3=
77\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\377\37=
7 \0\4\0\377\377\377\377&quot;, 132) =3D 44<br>=C2=A0getxattr(&quot;.rsync_=
dest2.DjNiRs&quot;, &quot;system.posix_acl_access&quot;, 0x7ffeac4780d0, 13=
2) =3D -1 ENODATA (No data available) <br>=C2=A0setxattr(&quot;.rsync_dest2=
.DjNiRs&quot;, &quot;system.posix_acl_access&quot;, &quot;\2\0\0\0\1\0\6\0\=
377\377\377\377\2\0\7\0\3300\0\0\4\0\6\0\377\377\377\377\20\0\7\0\377\377\3=
77\377 \0\4\0\377\377\377\377&quot;, 44, 0) =3D 0=C2=A0<br></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Apr 8, 2=
020 at 1:32 PM Paul Eggert &lt;<a href=3D"mailto:eggert@HIDDEN">eggert=
@cs.ucla.edu</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddin=
g-left:1ex">On 4/8/20 7:15 AM, Gregg Leventhal wrote:<br>
<br>
&gt; rsync doesn&#39;t make set/get xattr calls and purports to preserve AC=
Ls with<br>
&gt; -A.<br>
<br>
I&#39;m not quite following your bug report, but it appears that you&#39;re=
 saying that <br>
cp could somehow discover that it needn&#39;t use fgetxattr and fsetxattr o=
n files <br>
that lack extended attributes, and for those files cp could stick with ordi=
nary <br>
POSIX syscalls (e.g., umask, chmod) to give files proper permissions, and i=
n <br>
that case &#39;cp&#39; would presumably (a) operate more efficiently and (b=
) not trigger <br>
a bug in the EXT filesystem.<br>
<br>
This sounds like a worthy suggestion, though of course it would be better t=
o <br>
have a concrete proposal in the form of a coreutils patch, along with a few=
 <br>
performance measurements. For starters, how does rsync do it?<br>
<br>
Also, of course EXT should be fixed regardless of what coreutils does here.=
<br>
</blockquote></div>

--0000000000000a148005a354e878--




Information forwarded to bug-coreutils@HIDDEN:
bug#40509; Package coreutils. Full text available.

Message received at 40509 <at> debbugs.gnu.org:


Received: (at 40509) by debbugs.gnu.org; 8 Apr 2020 17:32:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 08 13:32:41 2020
Received: from localhost ([127.0.0.1]:52889 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jMEZ6-0004AK-PG
	for submit <at> debbugs.gnu.org; Wed, 08 Apr 2020 13:32:40 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49762)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1jMEZ3-0004A6-Ux
 for 40509 <at> debbugs.gnu.org; Wed, 08 Apr 2020 13:32:38 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id E380A1600CF;
 Wed,  8 Apr 2020 10:32:31 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 5XGzug51mSiO; Wed,  8 Apr 2020 10:32:31 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 354AA1600D9;
 Wed,  8 Apr 2020 10:32:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id jDWq8Wexm4IR; Wed,  8 Apr 2020 10:32:31 -0700 (PDT)
Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com
 [23.242.74.103])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 0A1C81600CF;
 Wed,  8 Apr 2020 10:32:31 -0700 (PDT)
Subject: Re: bug#40509: Use of fsetxattr() in cp tickles an EXT leak (possibly
 unnecessarily so)
To: Gregg Leventhal <gleventhal@HIDDEN>
References: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <e4f77f21-9af4-fb63-296d-89153af6eb8c@HIDDEN>
Date: Wed, 8 Apr 2020 10:32:30 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.4.1
MIME-Version: 1.0
In-Reply-To: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 40509
Cc: 40509 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 4/8/20 7:15 AM, Gregg Leventhal wrote:

> rsync doesn't make set/get xattr calls and purports to preserve ACLs with
> -A.

I'm not quite following your bug report, but it appears that you're saying that 
cp could somehow discover that it needn't use fgetxattr and fsetxattr on files 
that lack extended attributes, and for those files cp could stick with ordinary 
POSIX syscalls (e.g., umask, chmod) to give files proper permissions, and in 
that case 'cp' would presumably (a) operate more efficiently and (b) not trigger 
a bug in the EXT filesystem.

This sounds like a worthy suggestion, though of course it would be better to 
have a concrete proposal in the form of a coreutils patch, along with a few 
performance measurements. For starters, how does rsync do it?

Also, of course EXT should be fixed regardless of what coreutils does here.




Information forwarded to bug-coreutils@HIDDEN:
bug#40509; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Apr 2020 15:10:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 08 11:10:22 2020
Received: from localhost ([127.0.0.1]:52806 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jMCLN-0000Qi-IB
	for submit <at> debbugs.gnu.org; Wed, 08 Apr 2020 11:10:22 -0400
Received: from lists.gnu.org ([209.51.188.17]:38807)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gleventhal@HIDDEN>) id 1jMBVM-0003PO-Oe
 for submit <at> debbugs.gnu.org; Wed, 08 Apr 2020 10:16:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:49121)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <gleventhal@HIDDEN>) id 1jMBVL-0007mq-7R
 for bug-coreutils@HIDDEN; Wed, 08 Apr 2020 10:16:36 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_50,HTML_MESSAGE,
 RCVD_IN_DNSWL_MED,URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gleventhal@HIDDEN>) id 1jMBVI-0006mE-W8
 for bug-coreutils@HIDDEN; Wed, 08 Apr 2020 10:16:34 -0400
Received: from mxout1.mail.janestreet.com ([38.105.200.78]:53584)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <gleventhal@HIDDEN>)
 id 1jMBVI-0006lB-KS
 for bug-coreutils@HIDDEN; Wed, 08 Apr 2020 10:16:32 -0400
X-JS-Received: from [30.32.81.38] (helo=igm-qpr-mailcore1)
 by mxout1.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2)
 (envelope-from <gleventhal@HIDDEN>) id 1jMBVG-0005NJ-MS
 for bug-coreutils@HIDDEN; Wed, 08 Apr 2020 10:16:30 -0400
X-JS-Flow: external
X-JS-Received: by igm-qpr-mailcore1 with ocaml/mailcore/main_production
 (c4a4bbc04b22) (envelope-from <gleventhal@HIDDEN>)
 id Bejdy--KehemA-T3; 2020-04-08 10:16:30.672436-04:00
X-JS-Scanner-attachment: No attachments
X-JS-Scanner-esets: Not scanned (internal mail)
Received: from mail-il1-f199.google.com ([209.85.166.199])
 by mxgoog2.mail.janestreet.com with esmtps
 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2)
 id 1jMBVG-0003A5-Iv
 for bug-coreutils@HIDDEN; Wed, 08 Apr 2020 10:16:30 -0400
Received: by mail-il1-f199.google.com with SMTP id a79so6820607ill.19
 for <bug-coreutils@HIDDEN>; Wed, 08 Apr 2020 07:16:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=janestreet.com; s=google;
 h=mime-version:from:date:message-id:subject:to;
 bh=hV9uXTlZ3nk7fROwo4+2RlcCTNhxHqLytpag9aa1E8M=;
 b=FZGoHjnT2tX/zsKskG4r/XHaXpuZrEXnSUqvKiIFmlh85FgOMAntdhRUcez8HFhkJ+
 FNzsGQ0ixfFsLGBkSbPgFyzsRRp/CIaK4EyQG4R0lJafarJ0fp3g7BWJeT4gDW8ZdKQe
 0jaVc6GZpzQkS9nGx9HLa1vMr/Jf8qsQJquAM=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=hV9uXTlZ3nk7fROwo4+2RlcCTNhxHqLytpag9aa1E8M=;
 b=dIqdN/POTCa0UuSGymiem7QpSOSGb2vse0D9hwmwENroVAbJgqulWADnUnRtvOdjCs
 +PKKqVAazK1aq83lJPBmt0CtLW6OtAXptTwHQd5JmwdMLu9scttKod31KpGASLyVXigh
 aCFXAMirr5IitR0xt8IaCzMRbrbldd43+iQuedWfuMs3YQA0bP6UcHXC5u0noWCAST9v
 AIyZUupD+bRbv6QmA0f3f3NMZgWWgtdesDF15v0cJsDyAXxLlEIfx3BGbO2kHFRHjNKG
 /ac2+WqgNNkuef60SmHGdbJADyd+lewogNK+GGf72w9yiUzZWxYfrov0QC00eAyMaGPh
 aPDA==
X-Gm-Message-State: AGi0Pua6FP+Njirja6Wj77+ZUH1CRY7UoSSq9qSd7+/5M6FYC3BlJwCM
 Bu2EtbtHaJrMU35TzpHZyBjEoDx6nVw4keChyBgh38XvNQ7gMBr3XjRbtFMhPOLnv+k45CG99Ec
 g98r+OgzDD+DP3VFdWXDr3sC6IU48rw==
X-Received: by 2002:a6b:fc0c:: with SMTP id r12mr7024015ioh.147.1586355388316; 
 Wed, 08 Apr 2020 07:16:28 -0700 (PDT)
X-Google-Smtp-Source: APiQypIlIdlRN9DlpyN1sglwUJ2tUTE6oxvd6JDAdnaRR9722TCZX4pT0GGkrX8fUXRLdlPvIggFaBcLbi3HezI/L8o=
X-Received: by 2002:a6b:fc0c:: with SMTP id r12mr7023934ioh.147.1586355387288; 
 Wed, 08 Apr 2020 07:16:27 -0700 (PDT)
MIME-Version: 1.0
From: Gregg Leventhal <gleventhal@HIDDEN>
Date: Wed, 8 Apr 2020 10:15:51 -0400
Message-ID: <CAFN_u7EnL0ujuHBO2DvZYMXRjaSjNTqi8DoQ1W1SCYX+pOfAtg@HIDDEN>
Subject: Use of fsetxattr() in cp tickles an EXT leak (possibly unnecessarily
 so)
To: bug-coreutils@HIDDEN
Content-Type: multipart/alternative; boundary="00000000000058e5ad05a2c82534"
X-JS-Exim-Data-Received: 2020-04-08 10:16:30-0400
X-JS-Processed-by: mailcore
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 38.105.200.78
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 08 Apr 2020 11:10:20 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

--00000000000058e5ad05a2c82534
Content-Type: text/plain; charset="UTF-8"

This bug <https://patchwork.criu.org/patch/7413/> in EXT4 leaks posix_acl
allocations causing unreclaimable slab allocations to grow unbounded in the
kmalloc-64 cache.

It turns out that most of the problems we are having due to that leak is
due to programs making heavy use of "cp -a" or any of the cp --preserve
arguments that call fsetxattr.




*$ echo example1 > file$ strace -e fgetxattr,fsetxattr -f cp -a file
file2fgetxattr(3, "system.posix_acl_access", 0x7ffef5a38ce0, 132) = -1
ENODATA (No data available)fsetxattr(4, "system.posix_acl_access",
"\2\0\0\0\1\0\6\0\377\377\377\377\4\0\6\0\377\377\377\377
\0\4\0\377\377\377\377", 28, 0) = 0*

Mainly, I am concerned about this behavior because there are no ACLs, we
don't use them, so what is it setting?
















* $ getfacl file2# file: file2# owner: gleventhal# group:
techuser::rw-group::rw-other::r--$ touch new$ getfacl new# file: new#
owner: gleventhal# group: techuser::rw-group::rw-other::r--*

This is an ext4 file system with kernel 3.10.0-1062.18.1.el7 - CentOS Linux
release 7.7.1908 (Core)

rsync doesn't make set/get xattr calls and purports to preserve ACLs with
-A.

Thanks for listening, please let me know if I can provide more
information.  I hope all of you are doing well during this trying time in
our civilization.

--00000000000058e5ad05a2c82534
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><a href=3D"https://patchwork.criu.org/patch/7413/">This bu=
g</a>=C2=A0in EXT4 leaks posix_acl allocations causing unreclaimable slab a=
llocations to grow unbounded in the kmalloc-64 cache.=C2=A0=C2=A0<div><br><=
/div><div>It turns out that most of the problems we are having due to that =
leak is due to programs making heavy use of &quot;cp -a&quot; or any of the=
 cp --preserve arguments that call fsetxattr.<br><br><i>$ echo example1 &gt=
; file<br>$ strace -e fgetxattr,fsetxattr -f cp -a file file2<br>fgetxattr(=
3, &quot;system.posix_acl_access&quot;, 0x7ffef5a38ce0, 132) =3D -1 ENODATA=
 (No data available)<br>fsetxattr(4, &quot;system.posix_acl_access&quot;, &=
quot;\2\0\0\0\1\0\6\0\377\377\377\377\4\0\6\0\377\377\377\377 \0\4\0\377\37=
7\377\377&quot;, 28, 0) =3D 0</i><br><br>Mainly, I am concerned about this =
behavior because there are no ACLs, we don&#39;t use them,=C2=A0so what is =
it setting?=C2=A0=C2=A0<br><br><i>=C2=A0$ getfacl file2<br># file: file2<br=
># owner: gleventhal<br># group: tech<br>user::rw-<br>group::rw-<br>other::=
r--<br><br>$ touch new<br>$ getfacl new<br># file: new<br># owner: gleventh=
al<br># group: tech<br>user::rw-<br>group::rw-<br>other::r--</i><br><div><b=
r></div><div>This is an ext4 file system with kernel 3.10.0-1062.18.1.el7 -=
 CentOS Linux release 7.7.1908 (Core)</div><div><br></div><div>rsync doesn&=
#39;t make set/get xattr calls and purports to preserve ACLs with -A.<br><b=
r>Thanks for listening, please let me know if I can provide more informatio=
n.=C2=A0 I hope all of you are doing well during this trying time in our ci=
vilization.=C2=A0=C2=A0</div></div></div>

--00000000000058e5ad05a2c82534--




Acknowledgement sent to Gregg Leventhal <gleventhal@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#40509; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 15 Apr 2020 23:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.