Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #45: virus attack, luser responsible


comp / comp.lang.python / Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment

SubjectAuthor
o Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment2QdxY4RzWzUUiLuE

1
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
From: 2QdxY4RzWzUUiLuE@potatochowder.com
Newsgroups: comp.lang.python
Date: Thu, 24 Oct 2024 20:25 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4RzWzUUiLuE@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment
Date: Thu, 24 Oct 2024 16:25:56 -0400
Lines: 39
Message-ID: <mailman.42.1729802816.4695.python-list@python.org>
References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
<0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
<CAJQBtg=ButLwvoA2USBEV8-q=taRhuC+t6D1HkJMbG9VzTvxnQ@mail.gmail.com>
<69934a74-6d04-40a0-a75f-b8024bd0af43@mrabarnett.plus.com>
<CAJQBtgm6Re8tj5hKAZ7Zz6+NC-0iqcBH-MKo8gaOMm8A4prZfA@mail.gmail.com>
<db1bf48a-01a8-4f7e-8d13-33da26af7613@mrabarnett.plus.com>
<ZxqtVHjJOR8XZyHR@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de bGFiZ3ZJT9CNxQTX1J4WQgtoTYF1Lx/KBEvXj3pLoCrQ==
Cancel-Lock: sha1:MxiwolSR4Itfb6kr84377gwgR2Y= sha256:FAEfglqV10y5c8Q5eYBRNSm6uRqz8CTxF+WS67Br+rE=
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=potatochowder.com header.i=@potatochowder.com
header.b=PNka5MnT; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'thread': 0.05; 'cpu':
0.07; 'subject:when': 0.07; 'alternatives': 0.09; 'comparison':
0.09; 'fact,': 0.09; 'received:78': 0.09; 'reference:': 0.09;
'resolved': 0.09; '651': 0.16; '677': 0.16; '679': 0.16; '689':
0.16; '760': 0.16; 'appended': 0.16; 'assert': 0.16;
'comparison,': 0.16; 'designing,': 0.16; 'failed.': 0.16;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'lambda': 0.16; 'odds': 0.16; 'received:136.243': 0.16;
'received:172.58': 0.16; 'received:www458.your-server.de': 0.16;
'received:your-server.de': 0.16; 'subject:() ': 0.16;
'subject:Fedora': 0.16; 'subject:fails': 0.16; 'subject:used':
0.16; 'wrote:': 0.16; "can't": 0.17; 'to:addr:python-list': 0.20;
'skip:_ 10': 0.22; 'lines': 0.23; 'received:de': 0.23; 'anyone':
0.25; 'object': 0.26; 'else': 0.27; 'modify': 0.31; 'module':
0.31; "doesn't": 0.32; 'question': 0.32; 'end.': 0.32;
'maintaining': 0.32; 'modified': 0.32; 'python-list': 0.32;
'received:136': 0.32; 'but': 0.32; 'header:In-Reply-To:1': 0.34;
'yes,': 0.35; 'following': 0.35; 'those': 0.36; 'put': 0.38;
'added': 0.39; 'something': 0.40; 'reference': 0.60; 'remember':
0.61; 'between': 0.63; 'less': 0.64; 'probability': 0.64; 'that,':
0.68; 'right': 0.68; 'matter': 0.68; 'living': 0.71; 'skip:* 10':
0.73; 'left': 0.83; 'beat': 0.84; 'replacing': 0.91; 'time?': 0.91
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=potatochowder.com; s=default2305; h=In-Reply-To:Content-Type:MIME-Version:
References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:
Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=7ga6UaFtPJAINz7qQiWOx7eAtsJpWzsXCozGGoeAadM=; b=PNka5MnTjteMFI2vaEdslbFwga
sZbvLblhod6jYsMVqj0g+jiKmvLV1wVIZKOdy1yjzcwlVcZjLwcwmoeiguroqpLG/n6fwdsVyB2WD
zw5+fwPMTCiRNv0dPDvg+gmHeEqH1ahgy60yWQC8WQy5ngOGrFXhx+ZTO2kNuMT0a4NSrOeQr5kZR
4WDFL2WGOqF3gw7gsHWoui1RKYah70eFKbblvoBvsDA4AFVXf3Rsx6KJ+ojEMzj3otPcqgpNAEPmb
6+hRsZlBO/Gx6u/LOgo0CWdr64WVd6qLILwNC9pcncTtOE5LCKNN6iS2emVyk4BoJh2g6zWLMgVbl
o4OJdZoQ==;
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <db1bf48a-01a8-4f7e-8d13-33da26af7613@mrabarnett.plus.com>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.10/27437/Thu Oct 24 10:33:37 2024)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZxqtVHjJOR8XZyHR@anomaly>
X-Mailman-Original-References: <4a13731716200669342338ae409e73ca@posteo.de>
<CAJQBtg=kCr0VMGXvkBcj4U6CwatC2_G2dstO5pS56_koAXJurA@mail.gmail.com>
<0c080a7d-92de-4518-ac44-78d97fc9e3bb@mrabarnett.plus.com>
<CAJQBtg=ButLwvoA2USBEV8-q=taRhuC+t6D1HkJMbG9VzTvxnQ@mail.gmail.com>
<69934a74-6d04-40a0-a75f-b8024bd0af43@mrabarnett.plus.com>
<CAJQBtgm6Re8tj5hKAZ7Zz6+NC-0iqcBH-MKo8gaOMm8A4prZfA@mail.gmail.com>
<db1bf48a-01a8-4f7e-8d13-33da26af7613@mrabarnett.plus.com>
View all headers

On 2024-10-24 at 20:54:53 +0100,
MRAB via Python-list <python-list@python.org> wrote:

> On 2024-10-24 20:21, Left Right wrote:
> > > > > The stack is created on line 760 with os.lstat and entries are appended
> > > > > on lines 677 (os.rmdir), 679 (os.close) and 689 (os.lstat).
> > > > >
> > > > > 'func' is popped off the stack on line 651 and check in the following lines.
> > > > >
> > > > > I can't see anywhere else where something else is put onto the stack or
> > > > > an entry is replaced.
> >
> > But the _rmtree_safe_fd() compares func to a *dynamically* resolved
> > reference: os.lstat. If the reference to os changed (or os object was
> > modified to have new reference at lstat) between the time os.lstat was
> > added to the stack and the time of comparison, then comparison
> > would've failed. To illustrate my idea:
> >
> > os.lstat = lambda x: x # thread 1
> > stack.append((os.lstat, ...)) # thread 1
> > os.lstat = lambda x: x # thread 2
> > func, *_ = stack.pop() # thread 1
> > assert func is os.lstat # thread 1 (failure!)
> >
> > The only question is: is it possible to modify os.lstat like that, and
> > if so, how?
> >
> > Other alternatives include a malfunctioning "is" operator,
> > malfunctioning module cache... all those are a lot less likely.
> What is the probability of replacing os.lstat, os.close or os.rmdir from
> another thread at just the right time?

That is never the right question in a multi-threaded system. The answer
is always that is doesn't matter, the odds will beat you in the end. Or
sometimes right in the middle of a CPU instruction; does anyone remember
the MC680XX series?

Yes, as a matter of fact, I did used to make my living designing,
building, delivering, and maintaining such systems.

1

rocksolid light 0.9.8
clearnet tor