[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200818151707.GD1236603@ZenIV.linux.org.uk>
Date: Tue, 18 Aug 2020 16:17:07 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Jann Horn <jannh@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Christoph Hellwig <hch@....de>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
"Eric W . Biederman" <ebiederm@...ssion.com>
Subject: Re: [PATCH v3 2/5] coredump: Let dump_emit() bail out on short writes
On Tue, Aug 18, 2020 at 03:40:28PM +0200, Oleg Nesterov wrote:
> On 08/18, Jann Horn wrote:
> >
> > + if (dump_interrupted())
> > + return 0;
> > + n = __kernel_write(file, addr, nr, &pos);
> > + if (n != nr)
> > + return 0;
> > + file->f_pos = pos;
>
> Just curious, can't we simply do
>
> __kernel_write(file, addr, nr, &file->f_pos);
>
> and avoid "loff_t pos" ?
Bloody bad pattern; it would be (probably) safe in this case,
but in general ->f_pos is shared data. Exposing it to fuckloads of
->write() instances is a bad idea - we had bugs like that.
General rule: never pass an address of ->f_pos to anything,
and limit access to it as much as possible.
Powered by blists - more mailing lists