Re: what's papered over by set_fs(USER_DS) in amd64 signal delivery?

Al Viro
2010-09-25T02:48:16Z

On Fri, Sep 24, 2010 at 10:25:15PM -0400, Brian Gerst wrote:
> > + ?? ?? ?? ?? ?? ?? ?? __asm__("mov %w0,%%fs ; mov %w0,%%gs":"=r" (seg) :"0" (seg));
> > + ?? ?? ?? ?? ?? ?? ?? set_fs(seg);
> > + ?? ?? ?? ?? ?? ?? ?? regs->xds = seg;
> > + ?? ?? ?? ?? ?? ?? ?? regs->xes = seg;
> > + ?? ?? ?? ?? ?? ?? ?? regs->xss = seg;
> > + ?? ?? ?? ?? ?? ?? ?? regs->xcs = USER_CS;
> > in 2.1.2. ??And that's when we had
> > ?? ?? ?? ??* fs and gs evicted from pt_regs
> > ?? ?? ?? ??* fs and gs not saved restored on kernel entry/exit
> > ?? ?? ?? ??* just introduced set_fs() to start with (that went in 2.1.0)
> >
> > A bit before my time, so I'm not sure what's been going on there...
>
> I believe it can be safely removed. Looking through the history, the
> corresponding set_fs() calls were removed from 32-bit by commit
> b93b6ca3. This is just an artifact from ancient i386 code where
> set_fs (which is grossly misnamed now) really did set the %fs
> register.

Not quite. If you look at the tree where it has shown up (2.1.2), you'll see
that
a) by that time it _wasn't_ an assignment to %fs
b) the same patch that has introduced that call there does direct
assignment to %fs right next to that set_fs(). See that __asm__ above?

Again, I agree that it almost certainly can be dropped. I really wonder
about the history, though. It predates git and bk by far (late 1996).
Linus, do you have any recollection regarding that stuff?