From nobody@FreeBSD.org  Tue Feb 25 21:32:17 2014
Return-Path: <nobody@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 2A0AAEAB
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 25 Feb 2014 21:32:17 +0000 (UTC)
Received: from newred.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 01E171C89
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 25 Feb 2014 21:32:16 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by newred.freebsd.org (8.14.7/8.14.7) with ESMTP id s1PLWGJo047882
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 25 Feb 2014 21:32:16 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.7/8.14.7/Submit) id s1PLWGJv047866;
	Tue, 25 Feb 2014 21:32:16 GMT
	(envelope-from nobody)
Message-Id: <201402252132.s1PLWGJv047866@cgiserv.freebsd.org>
Date: Tue, 25 Feb 2014 21:32:16 GMT
From: Michael Pounov <misho@elwix.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Crash cross compilation for MIPS
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         187074
>Category:       kern
>Synopsis:       Crash cross compilation for MIPS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 25 21:40:00 UTC 2014
>Closed-Date:    Wed Mar 05 00:40:56 UTC 2014
>Last-Modified:  Wed Mar  5 00:50:00 UTC 2014
>Originator:     Michael Pounov
>Release:        FreeBSD 11 current
>Organization:
ELWIX
>Environment:
FreeBSD elwix.aitnet.org 11.0-CURRENT FreeBSD 11.0-CURRENT #4: Tue Feb 25 21:16:09 EET 2014     root@elwix.aitnet.org:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Cross compilation of kernel for MIPS architecture failed with this lines::

/home/fbsd_work.src/src/sys/netpfil/pf/pf_ioctl.c: In function 'pfioctl':
/home/fbsd_work.src/src/sys/netpfil/pf/pf_ioctl.c:1357: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/fbsd_work.src/src/sys/netpfil/pf/pf_ioctl.c:1359: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/fbsd_work.src/src/sys/netpfil/pf/pf_ioctl.c:1361: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

>How-To-Repeat:
Try to cross compilation of kernel for MIPS
>Fix:
Index: sys/netpfil/pf/pf_ioctl.c
===================================================================
--- sys/netpfil/pf/pf_ioctl.c	(revision 262482)
+++ sys/netpfil/pf/pf_ioctl.c	(working copy)
@@ -1353,12 +1353,12 @@
 		 * XXXGL: this is what happens when internal kernel
 		 * structures are used as ioctl API structures.
 		 */
-		pr->rule.states_cur =
-		    (counter_u64_t )counter_u64_fetch(rule->states_cur);
-		pr->rule.states_tot =
-		    (counter_u64_t )counter_u64_fetch(rule->states_tot);
-		pr->rule.src_nodes =
-		    (counter_u64_t )counter_u64_fetch(rule->src_nodes);
+		pr->rule.states_cur = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->states_cur);
+		pr->rule.states_tot = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->states_tot);
+		pr->rule.src_nodes = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->src_nodes);
 		if (pf_anchor_copyout(ruleset, rule, pr)) {
 			PF_RULES_WUNLOCK();
 			error = EBUSY;


Patch attached with submission follows:

Index: sys/netpfil/pf/pf_ioctl.c
===================================================================
--- sys/netpfil/pf/pf_ioctl.c	(revision 262482)
+++ sys/netpfil/pf/pf_ioctl.c	(working copy)
@@ -1353,12 +1353,12 @@
 		 * XXXGL: this is what happens when internal kernel
 		 * structures are used as ioctl API structures.
 		 */
-		pr->rule.states_cur =
-		    (counter_u64_t )counter_u64_fetch(rule->states_cur);
-		pr->rule.states_tot =
-		    (counter_u64_t )counter_u64_fetch(rule->states_tot);
-		pr->rule.src_nodes =
-		    (counter_u64_t )counter_u64_fetch(rule->src_nodes);
+		pr->rule.states_cur = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->states_cur);
+		pr->rule.states_tot = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->states_tot);
+		pr->rule.src_nodes = (counter_u64_t) (uintptr_t) 
+			counter_u64_fetch(rule->src_nodes);
 		if (pf_anchor_copyout(ruleset, rule, pr)) {
 			PF_RULES_WUNLOCK();
 			error = EBUSY;


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Wed Mar 5 00:40:37 UTC 2014 
State-Changed-Why:  
Fixed. 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Wed Mar 5 00:40:37 UTC 2014 
Responsible-Changed-Why:  
Fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=187074 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/187074: commit references a PR
Date: Wed,  5 Mar 2014 00:40:11 +0000 (UTC)

 Author: glebius
 Date: Wed Mar  5 00:40:03 2014
 New Revision: 262760
 URL: http://svnweb.freebsd.org/changeset/base/262760
 
 Log:
   Instead of playing games with casts simply add 3 more members to the
   structure pf_rule, that are used when the structure is passed via
   ioctl().
   
   PR:		187074
 
 Modified:
   head/sbin/pfctl/pfctl.c
   head/sys/net/pfvar.h
   head/sys/netpfil/pf/pf_ioctl.c
 
 Modified: head/sbin/pfctl/pfctl.c
 ==============================================================================
 --- head/sbin/pfctl/pfctl.c	Wed Mar  5 00:26:25 2014	(r262759)
 +++ head/sbin/pfctl/pfctl.c	Wed Mar  5 00:40:03 2014	(r262760)
 @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
  #include <err.h>
  #include <errno.h>
  #include <fcntl.h>
 -#include <inttypes.h>
  #include <limits.h>
  #include <netdb.h>
  #include <stdio.h>
 @@ -792,18 +791,17 @@ pfctl_print_rule_counters(struct pf_rule
  	}
  	if (opts & PF_OPT_VERBOSE) {
  		printf("  [ Evaluations: %-8llu  Packets: %-8llu  "
 -			    "Bytes: %-10llu  States: %-6"PRIuPTR"]\n",
 +			    "Bytes: %-10llu  States: %-6lu]\n",
  			    (unsigned long long)rule->evaluations,
  			    (unsigned long long)(rule->packets[0] +
  			    rule->packets[1]),
  			    (unsigned long long)(rule->bytes[0] +
 -			    rule->bytes[1]),
 -			    (uintptr_t)rule->states_cur);
 +			    rule->bytes[1]), rule->u_states_cur);
  		if (!(opts & PF_OPT_DEBUG))
  			printf("  [ Inserted: uid %u pid %u "
 -			    "State Creations: %-6"PRIuPTR"]\n",
 +			    "State Creations: %-6lu]\n",
  			    (unsigned)rule->cuid, (unsigned)rule->cpid,
 -			    (uintptr_t)rule->states_tot);
 +			    rule->u_states_tot);
  	}
  }
  
 @@ -905,7 +903,7 @@ pfctl_show_rules(int dev, char *path, in
  		case PFCTL_SHOW_LABELS:
  			if (pr.rule.label[0]) {
  				printf("%s %llu %llu %llu %llu"
 -				    " %llu %llu %llu %"PRIuPTR"\n",
 +				    " %llu %llu %llu %llu\n",
  				    pr.rule.label,
  				    (unsigned long long)pr.rule.evaluations,
  				    (unsigned long long)(pr.rule.packets[0] +
 @@ -916,7 +914,7 @@ pfctl_show_rules(int dev, char *path, in
  				    (unsigned long long)pr.rule.bytes[0],
  				    (unsigned long long)pr.rule.packets[1],
  				    (unsigned long long)pr.rule.bytes[1],
 -				    (uintptr_t)pr.rule.states_tot);
 +				    (unsigned long long)pr.rule.u_states_tot);
  			}
  			break;
  		case PFCTL_SHOW_RULES:
 
 Modified: head/sys/net/pfvar.h
 ==============================================================================
 --- head/sys/net/pfvar.h	Wed Mar  5 00:26:25 2014	(r262759)
 +++ head/sys/net/pfvar.h	Wed Mar  5 00:40:03 2014	(r262760)
 @@ -580,6 +580,10 @@ struct pf_rule {
  		struct pf_addr		addr;
  		u_int16_t		port;
  	}			divert;
 +
 +	uint64_t		 u_states_cur;
 +	uint64_t		 u_states_tot;
 +	uint64_t		 u_src_nodes;
  };
  
  /* rule flags */
 
 Modified: head/sys/netpfil/pf/pf_ioctl.c
 ==============================================================================
 --- head/sys/netpfil/pf/pf_ioctl.c	Wed Mar  5 00:26:25 2014	(r262759)
 +++ head/sys/netpfil/pf/pf_ioctl.c	Wed Mar  5 00:40:03 2014	(r262760)
 @@ -1349,16 +1349,9 @@ DIOCADDRULE_error:
  			break;
  		}
  		bcopy(rule, &pr->rule, sizeof(struct pf_rule));
 -		/*
 -		 * XXXGL: this is what happens when internal kernel
 -		 * structures are used as ioctl API structures.
 -		 */
 -		pr->rule.states_cur =
 -		    (counter_u64_t )counter_u64_fetch(rule->states_cur);
 -		pr->rule.states_tot =
 -		    (counter_u64_t )counter_u64_fetch(rule->states_tot);
 -		pr->rule.src_nodes =
 -		    (counter_u64_t )counter_u64_fetch(rule->src_nodes);
 +		pr->rule.u_states_cur = counter_u64_fetch(rule->states_cur);
 +		pr->rule.u_states_tot = counter_u64_fetch(rule->states_tot);
 +		pr->rule.u_src_nodes = counter_u64_fetch(rule->src_nodes);
  		if (pf_anchor_copyout(ruleset, rule, pr)) {
  			PF_RULES_WUNLOCK();
  			error = EBUSY;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
