RFC: Using fixed-length strings for version[] and osrelease[]

From: Colin Percival (cperciva_at_freebsd.org)
Date: 05/20/05

  • Next message: John-Mark Gurney: "Re: RFC: Using fixed-length strings for version[] and osrelease[]"
    Date: Thu, 19 May 2005 16:52:33 -0700
    To: freebsd-arch@freebsd.org
    
    

    In vers.c (created by src/sys/conf/newvers.sh), the strings version[] and
    osrelease[] are not declared with a fixed length. As a result, as the kernel
    moves from x.y-RELEASE to x.y-RELEASE-p1, and later to x.y-RELEASE-p10, the
    length of these strings will change; this causes cascading differences in
    addresses throughout the kernel binary.

    This is not a major problem for most people, but it causes difficulty for
    FreeBSD Update. Such cascading differences in addresses cause FreeBSD Update
    to recognize the kernel as having changed, at which point it decided that the
    new kernel needs to be distributed to everybody -- or rather, it would do this
    but for the fact that my FreeBSD Update build code replaces the traditional
    "x.y-RELEASE-p15" name with "x.y-SECURITY".

    As this is the last remaining place where the files built and distributed by
    FreeBSD Update differ from the standard src tree, I'd like to remove the need
    for this local patch. At BSDCan last week, Jacques Vidrine pointed out that
    this could be done simply by declaring these two strings as having fixed
    length -- i.e., by zero-padding them.

    Would anyone object to the following patch being applied?

    --- newvers.sh 15 Jan 2005 13:25:41 -0000 1.68
    +++ newvers.sh 19 May 2005 23:48:21 -0000
    @@ -87,9 +87,9 @@ cat << EOF > vers.c
     $COPYRIGHT
     char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
     char sccs[4] = { '@', '(', '#', ')' };
    -char version[] = "${VERSION} #${v}: ${t}\\n ${u}@${h}:${d}\\n";
    +char version[512] = "${VERSION} #${v}: ${t}\\n ${u}@${h}:${d}\\n";
     char ostype[] = "${TYPE}";
    -char osrelease[] = "${RELEASE}";
    +char osrelease[64] = "${RELEASE}";
     int osreldate = ${RELDATE};
     char kern_ident[] = "${i}";
     EOF

    The lengths 512 and 64 are chosen as being considerably more than double the
    likely lengths of these strings; on my system, these two strings are 12 bytes
    and 134 bytes long respectively.

    Colin Percival
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: John-Mark Gurney: "Re: RFC: Using fixed-length strings for version[] and osrelease[]"

    Relevant Pages

    • Re: [NFS] rpc.mountd crashes when extensively using netgroups
      ... the kernel export cache would increase. ... hosts are in which netgroups? ... We need to map IPADDRESS to THING, and THING + PATH to EXPORTPOINT. ... Another option is to use whatever strings are included in /etc/exports ...
      (Linux-Kernel)
    • Re: "Re: [PATCH 0/2] Colored kernel output (run2)" + "`Subject: usage"
      ... If kernel printing were going to be done over, I would suggest that instead of the current fixed format strings, the format argument would be an index, an ordinal into an array of *char pointers, and the string so described would be used as the format. ... These strings and pointers could be put in two modules, one part of init to be released after boot like other init code, one resident. ...
      (Linux-Kernel)
    • sysctl text definitions.
      ... export those handy description strings from the kernel SYSCTL macros ... const char *parent; ... Then after building the kernel one should be able to do: ... Sysctl or some other util could then read these db files to give ...
      (freebsd-hackers)
    • Re: [PATCH] PCMCIA identification strings for cards manufactured by Elan
      ... The strings came from our company product database. ... Elan Digital Systems Limited ... 16-bit PCMCIA card manufacturer to distribute or make available ... very easily enabled new hardware without rebuilding the kernel, ...
      (Linux-Kernel)
    • Re: Unbloating the kernel, was: :mem=16MB laptop testing
      ... Are kernel versions 2.2 or even 2.0 really not sufficient for such ... | games/X/mozilla/kde/gnome on old hardware perhaps you shouldn't run the ... | strings as error codes and return ERROR#42345 or something instead of the ... set of definitions optimized for various configurations. ...
      (Linux-Kernel)