June 9, 2004
A Touching Story
Oleg posted a new All Code Sucks entry, titled A Touching Story. Entertaining as usual… go ahead and submit your own!
PNS day 31: no pain, no gain
Workout this morning was a bitch. I had to drag myself out of bed, drag myself to the gym, and drag myself on and off each and every one of the machines I used. Swimming the 1km yesterday, coupled with the drinks I had at night in the Hessel’s pub left in less than spectacular shape this morning.
why user programs can’t access the kernel’s mapping, cont
Yesterday I wrote about “the story of a page
fault”, ending with “What I am not absolutely convinced about is
why the fault happens in the first place. The options are that it gets
a fault because the kernel is mapped, but the protection on the ptes
is such that only code running in ring 0 (i.e. the kernel) can access
them, or that the kernel is not mapped while we are running in user
space, and is only mapped in when we context switch to kernel
space. The former makes a lot more sense, but I haven’t yet hunted
down the code that does it.”
Well, I found it 🙂
in 2.6.7-rc3, arch/i386/mm/pgtable.c, pgd_ctor():
void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) { unsigned long flags; if (PTRS_PER_PMD == 1) spin_lock_irqsave(&pgd_lock, flags); /* muli: copy into the user's pgd the portion of the swapper_pg_dir that maps the kernel */ memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD, swapper_pg_dir + USER_PTRS_PER_PGD, (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); if (PTRS_PER_PMD > 1) return; pgd_list_add(pgd); spin_unlock_irqrestore(&pgd_lock, flags); /* muli: set the rest to 0 */ memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); }
The way I found it is to go through mingo’s 4:4 split patch,
which obviously needs to change this bit, since the kernel is no
longer mapped in each process’s address space.
the postfix bug that isn’t
I just spent a couple of hours tweaking the postfix installation on my desktop
machine, alhambra. I got everything working to my satisfaction, and
then noticed that bounce messages contain the line “For further
assistance, please send mail to “. The bit
looks incorrect, since I would expect it to be a real email
address. I looked in HOWTOs, read the configuration files, searched
the web, and couldn’t find any way to tell postfix which address to
use. Eventually, I downloaded the source and verified that indeed
there is no way to set this particular string. In
src/bounce/bounce_notify_util.c, we have the line
post_mail_fprintf(bounce, "For further assistance, please send mail to ", MAIL_ADDR_POSTMASTER);
where MAIL_ADDR_POSTMASTER is defined in src/global/mail_addr.h as
#define MAIL_ADDR_POSTMASTER "postmaster" #define MAIL_ADDR_MAIL_DAEMON "MAILER-DAEMON" #define MAIL_ADDR_EMPTY "" extern const char *mail_addr_double_bounce(void); extern const char *mail_addr_postmaster(void);
Hmm, thinks I, perhaps MAIL_ADDR_POSTMASTER is a default and
mail_addr_postmaster() does the fully qualified domain name bit? let’s
see. src/global/mail_addr.c:
const char *mail_addr_postmaster(void) { static char *addr; if (addr == 0) addr = concatenate(MAIL_ADDR_POSTMASTER, "@", var_myhostname, (char *) 0); return (addr); }
Couldn’t be much clearer than that. Looks like someone used
MAIL_ADDR_POSTMASTER rather than mail_addr_postmaster(). Not the sort
of silly bug I’d expect in postfix, but stranger things have
happened. Cool, a bug I can report and fix.
Well, let’s see where to report bugs in postfix. Nothing in the
source, no -devel mailing list. Maybe I should report it against the
debian package? Hmm, maybe one of the FAQs will have more information
on it? let’s try this one?. While
browsing through it, what do I see? When Postfix
sends a bounce message, it tells the sender, “For further assistance,
please send mail to…, which states:
4. When Postfix sends a bounce message, it tells the sender, "For further assistance, please send mail to 'postmaster'" But I want it to include my domain name in the address, e.g. . How can I do that? The idea behind this is that people who receive this notification should contact their own local postmasters, since they may very well be the ones who have to deal with the problem. If you really want to change it, you have to modify the source code.
To which I have only one thing to say: D’oh!