Port-vax archive

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

Re: Mopd which works with ELF and a.out in Linux and can netboot ULTRIX





On 2020-10-27 1:20 p.m., David Brownlee wrote:
On Tue, 27 Oct 2020 at 13:46, Boris Gjenero <boris.gjenero%gmail.com@localhost> wrote:

I did not use the old Linux port from https://github.com/qu1j0t3/mopd,
and instead used https://github.com/NetBSD/src/tree/trunk/usr.sbin/mopd,
which is an official conversion of
http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/mopd/ to git. It uses
the same source as when building mopd on NetBSD, except it uses
different files for interfacing with network devices
(common/loop-linux2.c and common/pf-linux2.c) and disables ELF and a.out
support by defining NOELF and NOAOUT. I made the NOELF and NOAOUT
defines unnecessary by building with 3 NetBSD header files.

Thanks for clarifying - and thanks again for both the work and for
feeding back the changes :)

I've committed the pfInit and 1k/4k changes.
One quick question on the mid 0 change - should the N_BADMAG (ex) &&
N_BADMAG (ex_swap)) check be conditionalised on mid 0?

Thanks again

David



On 2020-10-27 1:20 p.m., David Brownlee wrote:
> On Tue, 27 Oct 2020 at 13:46, Boris Gjenero <boris.gjenero%gmail.com@localhost> wrote:
>>
>> I did not use the old Linux port from https://github.com/qu1j0t3/mopd,
>> and instead used https://github.com/NetBSD/src/tree/trunk/usr.sbin/mopd,
>> which is an official conversion of
>> http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/mopd/ to git. It uses
>> the same source as when building mopd on NetBSD, except it uses
>> different files for interfacing with network devices
>> (common/loop-linux2.c and common/pf-linux2.c) and disables ELF and a.out
>> support by defining NOELF and NOAOUT. I made the NOELF and NOAOUT
>> defines unnecessary by building with 3 NetBSD header files.
>
> Thanks for clarifying - and thanks again for both the work and for
> feeding back the changes :)
>
> I've committed the pfInit and 1k/4k changes.
> One quick question on the mid 0 change - should the N_BADMAG (ex) &&
> N_BADMAG (ex_swap)) check be conditionalised on mid 0?
>
> Thanks again
>
> David

You're welcome.

I don't think the N_BADMAG (ex) check should be conditional, because it seems all a.out files should have magic numbers there, which are the same across different operating systems. Anyways, if some foreign a.out files used different magic numbers, mopd couldn't tell if the file is OMAGIC or NMAGIC, which could cause problems. So it seems best to reject such files.

BTW. I think CheckAOutFile() endian handling is wrong. Compare it:
https://github.com/dreamlayers/netbsd-mopd/blob/c4ebe27a95731e85af7442ac53b52e8f263dc856/common/file.c#L635
to GetAOutFileInfo():
https://github.com/dreamlayers/netbsd-mopd/blob/c4ebe27a95731e85af7442ac53b52e8f263dc856/common/file.c#L673

CheckAOutFile() lacks the mopFileSwapX((u_char *)&ex_swap, 0, 4) found in GetAOutFileInfo(), so ex_swap isn't actually swapped.

Also, the first read() wants to get data from offset 0 in the file. But it doesn't seek to offset 0 and the file has been read before. In GetFileInfo() it runs after CheckElfFile(), which reads stuff and doesn't seek to the start of the file afterwards. So ex gets read from wrong position in the file.

These things interact to make things work on little endian, where ex_swap gets accepted instead of ex. There is a seek to the start of the file before ex_swap is read, and ex_swap doesn't get swapped. But it should fail on big endian. I've been meaning to fix this but don't have a big endian build environment set up yet.

Home | Main Index | Thread Index | Old Index