From owner-freebsd-net@FreeBSD.ORG Thu Jan 9 14:29:43 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8BAAD27C; Thu, 9 Jan 2014 14:29:43 +0000 (UTC) Received: from mail-pa0-x229.google.com (mail-pa0-x229.google.com [IPv6:2607:f8b0:400e:c03::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 537F219AA; Thu, 9 Jan 2014 14:29:43 +0000 (UTC) Received: by mail-pa0-f41.google.com with SMTP id fb1so1806364pad.0 for ; Thu, 09 Jan 2014 06:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=uiMWN5jR8dsST8Fyoc7iCFIDOG3Y13psOfpasyyJ9RE=; b=ihRUrAZ4vld8PwPj5IFhTZ81qrI7K3Ty5mfqYjfedA8gO+nkyNeG7XatS+/kiAnECz dy6mYLLJSCMikV++iHhnHGpxYi0QI/AHsmvUyBR9FTj2t9iTdEUghtnLiQLOvyobnuaY 6yOblnINkeaJftDwTuaaVgBojGQoeun32oxyREp2pPlvPZNF6Fe6SKFtNMjEUPUEK1mq maB51SS10MEJfWVVO95UhBI7Y3dPddE/5usHtNcUk10lu5/5hAXCGNwgPGhCYMCnM3np 9e/ueJHwwAIISU+7MLutInZmACjqvMorBJh7qt8jGbv6170kjAQ3vH08hqoPzAHZAJh+ zFFw== MIME-Version: 1.0 X-Received: by 10.69.12.99 with SMTP id ep3mr4128600pbd.86.1389277782965; Thu, 09 Jan 2014 06:29:42 -0800 (PST) Sender: ermal.luci@gmail.com Received: by 10.70.46.42 with HTTP; Thu, 9 Jan 2014 06:29:42 -0800 (PST) In-Reply-To: <20140109104223.GS71033@FreeBSD.org> References: <20140109104223.GS71033@FreeBSD.org> Date: Thu, 9 Jan 2014 15:29:42 +0100 X-Google-Sender-Auth: rwc266wx-fMYed7KwqO91Nco2B4 Message-ID: Subject: Re: 10.0-RC1, armv6: "pfctl -s state" crashes on BeagleBone Black due to unaligned access From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 Cc: freebsd-net , freebsd-arm@freebsd.org, Guy Yur X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2014 14:29:43 -0000 On Thu, Jan 9, 2014 at 11:42 AM, Gleb Smirnoff wrote: > Guy, > > On Sat, Jan 04, 2014 at 03:06:02PM +0200, Guy Yur wrote: > G> I am running 10.0-RC1 arm.armv6 on the BeagleBone Black. > G> The "pfctl -s state" command is crashing when trying to print the > G> second entry. > G> > G> struct pfsync_state has a size that is not divisiable by 4 or 8 leading > to the > G> second entry in the returned state array not being aligned and pfctl > G> core dumps on Bus error when trying to access a uint32_t field. > G> > G> (gdb) bt > G> #0 print_host (addr=0x2085a11a, port=7660, af=2 '\002', opts=1024) at > G> /usr/src/sbin/pfctl/pf_print_state.c:178 > G> #1 0x00021c4c in print_state (s=0x2085a0f2, opts=1024) at > G> /usr/src/sbin/pfctl/pf_print_state.c:236 > G> #2 0x0000c664 in pfctl_show_states (dev=, > G> iface=0x0, opts=1024) at /usr/src/sbin/pfctl/pfctl.c:1095 > G> > G> sizeof(struct pfsync_state_key) is 36 > G> sizeof(struct pfsync_state_peer) is 32 > G> sizeof(struct pf_addr) is 16 > G> sizeof(struct pfsync_state) is 242 > G> > G> Removing the __spare[2] field will allow the struct to be aligned on 8 > bytes > G> for the u_int64_t id field and also cover the uint32_t fields alignment > G> but this will break KBI. > G> > G> I am currently using an inefficient workaround in pfctl_show_states > G> that memcpy each entry to a struct pfsync_state on the stack > G> ensuring each call to print_state receives an aligned struct. > G> > G> 10.0-RC1 World and kernel were compiled in a VirtualBox VM running > G> 9.2-RELEASE-p2 i386. > G> clang and ARM_EABI used as the default make options. > > For pf we are ready to break KBI. It uses same structs for internal kernel > representation and for ioctl() API and this is actually a bug. Until it is > properly fixed, we are doomed to break KBI always. > > Unfortunately, pfsync_state is not only a KBI but also a wire protocol for > pfsync(4). We can't break this, since that would make different FreeBSD > versions not exchanging states properly. > > Well, <= 8.x already is incompatible with >= 9.x, thanks yet another > OpenBSD > import. But we don't want to introduce another one. > > I will try to fix this making new structure for the ioctl. That will mean > moving slowly towards divorcing internal structures and ioctl ones. > > I'd appreciate if you file a PR on that, so that problem won't leave > forgotten > in the mailing list. You can even code the bugfix :) > > Thanks! > > Well pfsync has a version in its header so its quite possible to support many of them. > -- > Totus tuus, Glebius. > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > -- Ermal