Re: [PATCH v3 2/5] coredump: Let dump_emit() bail out on short writes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 18, 2020 at 3:40 PM Oleg Nesterov <oleg@xxxxxxxxxx> 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" ?

Hm... e.g. ksys_write() has the same pattern of copying the value into
a local variable and back, but I guess maybe there it's done so that
->f_pos can't change when vfs_write() returns a negative value, or
something like that? Or maybe to make the update look more atomic?
None of that is a concern for the core-dumping code, so I guess we
could change it... but then again, maybe we shouldn't diverge from how
it's done in fs/read_write.c (e.g. in ksys_write()) too much.
Coredumping is already a bit too special, no need to make it worse...

It looks like Al Viro introduced this as part of commit 2507a4fbd48a
("make dump_emit() use vfs_write() instead of banging at ->f_op->write
directly"). Before that commit, &file->f_pos was actually passed as a
parameter, just like you're proposing. I don't really want to try
reverting parts of Al's commits without understanding what exactly is
going on...



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux