<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>xorl %eax, %eax</title>
	<atom:link href="http://xorl.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xorl.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 19:45:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xorl.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>xorl %eax, %eax</title>
		<link>http://xorl.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xorl.wordpress.com/osd.xml" title="xorl %eax, %eax" />
	<atom:link rel='hub' href='http://xorl.wordpress.com/?pushpress=hub'/>
		<item>
		<title>CVE-2013-1798: Linux kernel KVM IOAPIC_REG_SELECT Invalid Memory Access</title>
		<link>http://xorl.wordpress.com/2013/05/23/cve-2013-1798-linux-kernel-kvm-ioapic_reg_select-invalid-memory-access/</link>
		<comments>http://xorl.wordpress.com/2013/05/23/cve-2013-1798-linux-kernel-kvm-ioapic_reg_select-invalid-memory-access/#comments</comments>
		<pubDate>Thu, 23 May 2013 19:44:32 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3410</guid>
		<description><![CDATA[This was very nice vulnerability reported by Andrew Honig of Google. The bug is triggered when a user specifies an invalid IOAPIC_REG_SELECT value which is reachable via read KVM I/O device operation as you can see below. Additionally, if a user makes a read by invoking IOAPIC_REG_WINDOW it will result in calling ioapic_read_indirect(). Here is [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3410&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This was very nice vulnerability reported by Andrew Honig of Google. The bug is triggered when a user specifies an invalid IOAPIC_REG_SELECT value which is reachable via read KVM I/O device operation as you can see below.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
static int ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len,
			    void *val)
{
	struct kvm_ioapic *ioapic = to_ioapic(this);
	u32 result;
   ...
	switch (addr) {
	case IOAPIC_REG_SELECT:
		result = ioapic-&gt;ioregsel;
		break;

	case IOAPIC_REG_WINDOW:
		result = ioapic_read_indirect(ioapic, addr, len);
		break;
   ...
	return 0;
}
   ...
static const struct kvm_io_device_ops ioapic_mmio_ops = {
	.read     = ioapic_mmio_read,
	.write    = ioapic_mmio_write,
};
</pre>
<p>
Additionally, if a user makes a read by invoking IOAPIC_REG_WINDOW it will result in calling ioapic_read_indirect(). Here is what this function does.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
					  unsigned long addr,
					  unsigned long length)
{
	unsigned long result = 0;

	switch (ioapic-&gt;ioregsel) {
  ...
	default:
		{
			u32 redir_index = (ioapic-&gt;ioregsel - 0x10) &gt;&gt; 1;
			u64 redir_content;

			ASSERT(redir_index &lt; IOAPIC_NUM_PINS);

			redir_content = ioapic-&gt;redirtbl[redir_index].bits;
			result = (ioapic-&gt;ioregsel &amp; 0x1) ?
			    (redir_content &gt;&gt; 32) &amp; 0xffffffff :
			    redir_content &amp; 0xffffffff;
			break;
		}
	}

	return result;
}
</pre>
<p>
It calculates and initializes the value of &#8216;redir_index&#8217; from the user controlled &#8216;ioapic-&gt;ioregsel&#8217; variable and then uses it as an index to &#8216;ioapic-&gt;redirtbl[]&#8216; array. If this value is larger than IOAPIC_NUM_PINS it will result in invalid memory access. Here is how IOAPIC_NUM_PINS is defined in virt/kvm/ioapic.h header file.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
#define IOAPIC_NUM_PINS  KVM_IOAPIC_NUM_PINS
</pre>
<p>
And this is because it is architecture specific. For IA64 is defined in include/uapi/asm/kvm.h as 48 and for x86 in arch/x86/include/uapi/asm/kvm.h as 24. As you might have noticed there is an ASSERT() call to make this check but of course, this will only take effect in the debug builds.<br />
The fix was to replace that ASSERT() call with a range check like this.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
 			u32 redir_index = (ioapic-&gt;ioregsel - 0x10) &gt;&gt; 1;
 			u64 redir_content;
-			ASSERT(redir_index &lt; IOAPIC_NUM_PINS);
+			if (redir_index &lt; IOAPIC_NUM_PINS)
+				redir_content =
+					ioapic-&gt;redirtbl[redir_index].bits;
+			else
+				redir_content = ~0ULL;
-			redir_content = ioapic-&gt;redirtbl[redir_index].bits;
 			result = (ioapic-&gt;ioregsel &amp; 0x1) ?
 			    (redir_content &gt;&gt; 32) &amp; 0xffffffff :
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3410/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3410/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3410&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/23/cve-2013-1798-linux-kernel-kvm-ioapic_reg_select-invalid-memory-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>CVE-2013-2074: KDE kdelibs Password Exposure</title>
		<link>http://xorl.wordpress.com/2013/05/22/cve-2013-2074-kde-kdelibs-password-exposure/</link>
		<comments>http://xorl.wordpress.com/2013/05/22/cve-2013-2074-kde-kdelibs-password-exposure/#comments</comments>
		<pubDate>Wed, 22 May 2013 20:47:43 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3407</guid>
		<description><![CDATA[This was a low impact vulnerability reported by m.wege. The issue occurs on &#8220;internal server error&#8221; and triggers the below code located at kioslave/http/http.cpp. Clearly, error() could be called passing the error number along with a string which in all of the above cases is the result of m_request.url.url(). The url() routine is part of [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3407&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This was a low impact vulnerability <a href="https://bugs.kde.org/show_bug.cgi?id=319428">reported</a> by m.wege. The issue occurs on &#8220;internal server error&#8221; and triggers the below code located at kioslave/http/http.cpp.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
/**
 * This function will read in the return header from the server.  It will
 * not read in the body of the return message.  It will also not transmit
 * the header to our client as the client doesn't need to know the gory
 * details of HTTP headers.
 */
bool HTTPProtocol::readResponseHeader()
{
   ...
    if (m_request.responseCode &gt;= 500 &amp;&amp; m_request.responseCode &lt;= 599) {
        // Server side errors

        if (m_request.method == HTTP_HEAD) {
   ...
            if (!sendErrorPageNotification()) {
                error(ERR_INTERNAL_SERVER, m_request.url.url());
                return false;
   ...
    } else if (!isAuthenticationRequired(m_request.responseCode) &amp;&amp; m_request.responseCode &gt;= 400 &amp;&amp; m_request.responseCode &lt;= 499) {
        // Any other client errors
        // Tell that we will only get an error page here.
        if (!sendErrorPageNotification()) {
            if (m_request.responseCode == 403)
                error(ERR_ACCESS_DENIED, m_request.url.url());
            else
                error(ERR_DOES_NOT_EXIST, m_request.url.url());
            return false;
        }
   ...
}
</pre>
<p>
Clearly, error() could be called passing the error number along with a string which in all of the above cases is the result of m_request.url.url().<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
void HTTPProtocol::error( int _err, const QString &amp;_text )
{
  // Close the connection only on connection errors. Otherwise, honor the
  // keep alive flag.
  if (_err == ERR_CONNECTION_BROKEN || _err == ERR_COULD_NOT_CONNECT)
      httpClose(false);
  else
      httpClose(m_request.isKeepAlive);

  if (!m_request.id.isEmpty())
  {
    forwardHttpResponseHeader();
    sendMetaData();
  }

  // It's over, we don't need it anymore
  clearPostDataBuffer();

  SlaveBase::error( _err, _text );
  m_iError = _err;
}
</pre>
<p>
The url() routine is part of kdecore/io/kurl.cpp file and it is being to used to dump the URL.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
QString KUrl::url( AdjustPathOption trailing ) const
{
  if (QString::compare(scheme(), QLatin1String(&quot;mailto&quot;), Qt::CaseInsensitive) == 0) {
      // mailto urls should be prettified, see the url183433 testcase.
      return prettyUrl(trailing);
  }
  if ( trailing == AddTrailingSlash &amp;&amp; !path().endsWith( QLatin1Char('/') ) ) {
      // -1 and 0 are provided by QUrl, but not +1, so that one is a bit tricky.
      // To avoid reimplementing toEncoded() all over again, I just use another QUrl
      // Let's hope this is fast, or not called often...
      QUrl newUrl( *this );
      newUrl.setPath( path() + QLatin1Char('/') );
      return QString::fromLatin1(newUrl.toEncoded());
  }
  else if ( trailing == RemoveTrailingSlash) {
      const QString cleanedPath = trailingSlash(trailing, path());
      if (cleanedPath == QLatin1String(&quot;/&quot;)) {
          if (path() != QLatin1String(&quot;/&quot;)) {
              QUrl fixedUrl = *this;
              fixedUrl.setPath(cleanedPath);
              return QLatin1String(fixedUrl.toEncoded(None));
          }
          return QLatin1String(toEncoded(None));
      }
  }
  return QString::fromLatin1(toEncoded(trailing == RemoveTrailingSlash ? StripTrailingSlash : None));
}
</pre>
<p>
Of course, this means that the same also applies when the URL includes username and password information such as <a href="http://username:password@example.com" rel="nofollow">http://username:password@example.com</a>. To fix this the calls to url() were replaced by prettyUrl() with the following patch.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
diff --git a/kioslave/http/http.cpp b/kioslave/http/http.cpp
index 2d139a9..129fc7b 100644
--- a/kioslave/http/http.cpp
+++ b/kioslave/http/http.cpp
@@ -3056,7 +3056,7 @@ try_again:
             ; // Ignore error
         } else {
             if (!sendErrorPageNotification()) {
-                error(ERR_INTERNAL_SERVER, m_request.url.url());
+                error(ERR_INTERNAL_SERVER, m_request.url.prettyUrl());
                 return false;
             }
         }
@@ -3072,9 +3072,9 @@ try_again:
         // Tell that we will only get an error page here.
         if (!sendErrorPageNotification()) {
             if (m_request.responseCode == 403)
-                error(ERR_ACCESS_DENIED, m_request.url.url());
+                error(ERR_ACCESS_DENIED, m_request.url.prettyUrl());
             else
-                error(ERR_DOES_NOT_EXIST, m_request.url.url());
+                error(ERR_DOES_NOT_EXIST, m_request.url.prettyUrl());
             return false;
         }
     } else if (m_request.responseCode &gt;= 301 &amp;&amp; m_request.responseCode&lt;= 303) {
</pre>
<p>
This routine among other things removes the password from the URL.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
QString KUrl::prettyUrl( AdjustPathOption trailing ) const
{
  // reconstruct the URL in a &quot;pretty&quot; form
  // a &quot;pretty&quot; URL is NOT suitable for data transfer. It's only for showing data to the user.
  // however, it must be parseable back to its original state, since
  // notably Konqueror displays it in the Location address.

  // A pretty URL is the same as a normal URL, except that:
  // - the password is removed
  // - the hostname is shown in Unicode (as opposed to ACE/Punycode)
  // - the pathname and fragment parts are shown in Unicode (as opposed to %-encoding)
  QString result = scheme();
    ...
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3407&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/22/cve-2013-2074-kde-kdelibs-password-exposure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>CVE-2013-1796: Linux kernel KVM MSR_KVM_SYSTEM_TIME Buffer Overflow</title>
		<link>http://xorl.wordpress.com/2013/05/22/cve-2013-1796-linux-kernel-kvm-msr_kvm_system_time-buffer-overflow/</link>
		<comments>http://xorl.wordpress.com/2013/05/22/cve-2013-1796-linux-kernel-kvm-msr_kvm_system_time-buffer-overflow/#comments</comments>
		<pubDate>Wed, 22 May 2013 19:15:47 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3404</guid>
		<description><![CDATA[This is a really nice vulnerability killed by Andy Honig. It is particularly interesting because it allows host kernel memory corruption through guest GPA (Guest Physical Address) manipulation. If we have a look in arch/x86/kvm/x86.c we can see the following code. So by utilizing the &#8216;MSR_KVM_SYSTEM_TIME&#8217; kvmclock MSR a user can set &#8216;vcpu-&#62;arch.time_page&#8217; through gfn_to_page() [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3404&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is a really nice vulnerability killed by Andy Honig. It is particularly interesting because it allows host kernel memory corruption through guest GPA (Guest Physical Address) manipulation. If we have a look in arch/x86/kvm/x86.c we can see the following code.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
{
	bool pr = false;
	u32 msr = msr_info-&gt;index;
	u64 data = msr_info-&gt;data;

	switch (msr) {   
   ...
	case MSR_KVM_SYSTEM_TIME: {
		kvmclock_reset(vcpu);

		vcpu-&gt;arch.time = data;
		kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);

		/* we verify if the enable bit is set... */
		if (!(data &amp; 1))
			break;

		/* ...but clean it before doing the actual write */
		vcpu-&gt;arch.time_offset = data &amp; ~(PAGE_MASK | 1);

		vcpu-&gt;arch.time_page =
				gfn_to_page(vcpu-&gt;kvm, data &gt;&gt; PAGE_SHIFT);

		if (is_error_page(vcpu-&gt;arch.time_page))
			vcpu-&gt;arch.time_page = NULL;

		break;
	}
   ...
	return 0;
}
EXPORT_SYMBOL_GPL(kvm_set_msr_common);
</pre>
<p>
So by utilizing the &#8216;MSR_KVM_SYSTEM_TIME&#8217; kvmclock MSR a user can set &#8216;vcpu-&gt;arch.time_page&#8217; through gfn_to_page() call that uses the user derived &#8216;data&#8217; information. As Andy Honig mentioned in his <a href="https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?id=c300aa64ddf57d9c5d9c898a64b36877345dd4a9">commit</a>, the arbitrary write occurs when kmap atomic attempts to obtain a pointer to the time structure page and performing a memcpy() to it starting at the user controlled offset. The fix was to add a check that verifies that the provided value does not exceed the structure&#8217;s boundaries.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
 		/* ...but clean it before doing the actual write */
 		vcpu-&gt;arch.time_offset = data &amp; ~(PAGE_MASK | 1);
+		/* Check that the address is 32-byte aligned. */
+		if (vcpu-&gt;arch.time_offset &amp;
+				(sizeof(struct pvclock_vcpu_time_info) - 1))
+			break;
+
 		vcpu-&gt;arch.time_page =
 				gfn_to_page(vcpu-&gt;kvm, data &gt;&gt; PAGE_SHIFT);
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3404/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3404&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/22/cve-2013-1796-linux-kernel-kvm-msr_kvm_system_time-buffer-overflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>CVE-2013-1848: Linux kernel EXT3 ext3_msg() Format String</title>
		<link>http://xorl.wordpress.com/2013/05/21/cve-2013-1848-linux-kernel-ext3-ext3_msg-format-string/</link>
		<comments>http://xorl.wordpress.com/2013/05/21/cve-2013-1848-linux-kernel-ext3-ext3_msg-format-string/#comments</comments>
		<pubDate>Tue, 21 May 2013 18:15:18 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3401</guid>
		<description><![CDATA[Recently Lars-Peter Clausen committed a change on Linux kernel that fixes a format string vulnerability in the EXT3 filesystem code. The susceptible code resides in fs/ext3/super.c but to better understand it we need to have a look on how ext3_msg() is defined first. So, it should be called passing the following three mandatory arguments: - [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3401&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently Lars-Peter Clausen committed a change on Linux kernel that fixes a format string vulnerability in the EXT3 filesystem code. The susceptible code resides in fs/ext3/super.c but to better understand it we need to have a look on how ext3_msg() is defined first.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
void ext3_msg(struct super_block *sb, const char *prefix,
                const char *fmt, ...)
{
        struct va_format vaf;
        va_list args;
 
        va_start(args, fmt);
 
        vaf.fmt = fmt;
        vaf.va = &amp;args;
 
        printk(&quot;%sEXT3-fs (%s): %pV\n&quot;, prefix, sb-&gt;s_id, &amp;vaf);
 
        va_end(args);
}
</pre>
<p>
So, it should be called passing the following three mandatory arguments:<br />
- Pointer to the super-block structure<br />
- Prefix string<br />
- Format string<br />
And of course, any variables to be printed. As Lars-Peter Clausen noticed, there were two cases where there was no prefix defined. This makes the format string argument to be passed as prefix and any variables to be processed as the format string. Here are these two cases:<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * Open the external journal device
 */
static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb)
{
  ...
fail:
        ext3_msg(sb, &quot;error: failed to open journal device %s: %ld&quot;,
                __bdevname(dev, b), PTR_ERR(bdev));

        return NULL;
}
</pre>
<p>
And&#8230;<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)
{
        ext3_fsblk_t    sb_block;
  ...
        if (*options &amp;&amp; *options != ',') {
                ext3_msg(sb, &quot;error: invalid sb specification: %s&quot;,
                       (char *) *data);
  ...
        return sb_block;
}
</pre>
<p>
The fix was to add the missing prefix argument to the function call like this.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
@@ -353,7 +353,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb)
 	return bdev;
 fail:
-	ext3_msg(sb, &quot;error: failed to open journal device %s: %ld&quot;,
+	ext3_msg(sb, KERN_ERR, &quot;error: failed to open journal device %s: %ld&quot;,
 		__bdevname(dev, b), PTR_ERR(bdev));
 	return NULL;
@@ -887,7 +887,7 @@ static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb)
 	/*todo: use simple_strtoll with &gt;32bit ext3 */
 	sb_block = simple_strtoul(options, &amp;options, 0);
 	if (*options &amp;&amp; *options != ',') {
-		ext3_msg(sb, &quot;error: invalid sb specification: %s&quot;,
+		ext3_msg(sb, KERN_ERR, &quot;error: invalid sb specification: %s&quot;,
 		       (char *) *data);
 		return 1;
 	}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3401/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3401&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/21/cve-2013-1848-linux-kernel-ext3-ext3_msg-format-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>C Quiz No. 2</title>
		<link>http://xorl.wordpress.com/2013/05/18/c-quiz-no-2/</link>
		<comments>http://xorl.wordpress.com/2013/05/18/c-quiz-no-2/#comments</comments>
		<pubDate>Sat, 18 May 2013 13:44:01 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[C programming]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3397</guid>
		<description><![CDATA[Continuing from the first one back in 2009, here is another that a friend of mine send me yesterday. The concept is that you are free to put whatever you want in do_your_stuff() in order to make it print &#8220;win&#8221; from function do_my_stuff(). Instantly I came up with a quite simple solution that exploits the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3397&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Continuing from <a href="http://xorl.wordpress.com/2009/01/27/c-quiz-no-1/">the first one</a> back in 2009, here is another that a friend of mine send me yesterday.<br />
<br />
The concept is that you are free to put whatever you want in do_your_stuff() in order to make it print &#8220;win&#8221; from function do_my_stuff().<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

void 
do_your_stuff(void)
{
	// do whatever you want
}

void 
do_my_stuff(void)
{
	char c[100];
	unsigned int i, r_index;

	srand(time(NULL));
	for(i = 0; i&lt;1000; i++)
		r_index = rand() % (sizeof(c) - 1);

	printf(&quot;c[%u] = %02x\n&quot;, r_index, c[r_index]);

	if (c[r_index] == 0x20)
		printf(&quot;win!\n&quot;);
	else
		printf(&quot;fail\n&quot;);
	
	return;
}

int 
main(void)
{
	do_your_stuff();
	do_my_stuff();
	return 0;
}

</pre>
<p>
Instantly I came up with a quite simple solution that exploits the concept of uninitialized stack that it&#8217;s being used.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
void 
do_your_stuff(void)
{
	char buf[2048]; int i;
	for(i=0; i&lt;sizeof(buf); i++) buf[i] = 0x20;
}
</pre>
<p>
Which it works&#8230;<br />
</p>
<pre class="brush: bash; title: ; notranslate">
$ ./cquiz2
c[98] = 00
fail
$ ./cquiz2
c[81] = 7f
fail
$ gcc -Wall -Werror --std=c99 cquiz2.c -o cquiz_sol
$ ./cquiz_sol
c[43] = 20
win!
$ ./cquiz_sol
c[54] = 20
win!
$
</pre>
<p>
I found it fun so if you have any other solutions feel free to comment on this post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3397/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3397/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3397&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/18/c-quiz-no-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>CVE-2013-1774: Linux kernel Edgeport USB Serial Converter NULL Pointer Dereference</title>
		<link>http://xorl.wordpress.com/2013/05/18/cve-2013-1774-linux-kernel-edgeport-usb-serial-converter-null-pointer-dereference/</link>
		<comments>http://xorl.wordpress.com/2013/05/18/cve-2013-1774-linux-kernel-edgeport-usb-serial-converter-null-pointer-dereference/#comments</comments>
		<pubDate>Sat, 18 May 2013 13:14:40 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3395</guid>
		<description><![CDATA[This is a vulnerability fixed by Wolfgang Frisch and the buggy code resides in drivers/usb/serial/io_ti.c as you can see below. If the equivalent /dev/ttyUSB device file is in use while the device is disconnected then any call to chase_port() (used to chase the port, close and flush it) will lead to NULL pointer dereference since [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3395&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is a vulnerability fixed by Wolfgang Frisch and the buggy code resides in drivers/usb/serial/io_ti.c as you can see below.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
static void chase_port(struct edgeport_port *port, unsigned long timeout,
								int flush)
{
	int baud_rate;
	struct tty_struct *tty = tty_port_tty_get(&amp;port-&gt;port-&gt;port);
	struct usb_serial *serial = port-&gt;port-&gt;serial;
	wait_queue_t wait;
	unsigned long flags;
   ...
	remove_wait_queue(&amp;tty-&gt;write_wait, &amp;wait);
   ...
	tty_kref_put(tty);
   ...
}
</pre>
<p>
If the equivalent /dev/ttyUSB device file is in use while the device is disconnected then any call to chase_port() (used to chase the port, close and flush it) will lead to NULL pointer dereference since there is no longer a &#8216;tty&#8217; associated with it. The fix was to add a simple check for this case.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
	unsigned long flags;
+	if (!tty)
+		return;
+
	if (!timeout)
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3395/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3395&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/18/cve-2013-1774-linux-kernel-edgeport-usb-serial-converter-null-pointer-dereference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>CVE-2013-1819: Linux kernel XFS _xfs_buf_find() NULL Pointer Dereference</title>
		<link>http://xorl.wordpress.com/2013/05/18/cve-2013-1819-linux-kernel-xfs-_xfs_buf_find-null-pointer-dereference-2/</link>
		<comments>http://xorl.wordpress.com/2013/05/18/cve-2013-1819-linux-kernel-xfs-_xfs_buf_find-null-pointer-dereference-2/#comments</comments>
		<pubDate>Sat, 18 May 2013 13:12:07 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3392</guid>
		<description><![CDATA[On 21 January 2013 Dave Chinner of Red Hat committed a change that fixes a NULL pointer dereference vulnerability in XFS filesystem. The below routine is located in fs/xfs/xfs_buf.c file. First of all, the xfs_addr_to_agno() C macro is the following as defined in fs/xfs/xfs_mount.h header file. As Dave Chinner pointed out, if we try to [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3392&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>On 21 January 2013 Dave Chinner of Red Hat committed a change that fixes a NULL pointer dereference vulnerability in XFS filesystem. The below routine is located in fs/xfs/xfs_buf.c file.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 *	Finding and Reading Buffers
 */

/*
 *	Look up, and creates if absent, a lockable buffer for
 *	a given range of an inode.  The buffer is returned
 *	locked.	No I/O is implied by this call.
 */
xfs_buf_t *
_xfs_buf_find(
	struct xfs_buftarg	*btp,
	struct xfs_buf_map	*map,
	int			nmaps,
	xfs_buf_flags_t		flags,
	xfs_buf_t		*new_bp)
{
	size_t			numbytes;
	struct xfs_perag	*pag;
   ...
	/* get tree root */
	pag = xfs_perag_get(btp-&gt;bt_mount,
				xfs_daddr_to_agno(btp-&gt;bt_mount, blkno));

	/* walk tree */
   ...
	return bp;
}
</pre>
<p>
First of all, the xfs_addr_to_agno() C macro is the following as defined in fs/xfs/xfs_mount.h header file.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
#define xfs_daddr_to_agno(mp,d) \
        ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)-&gt;m_sb.sb_agblocks))
</pre>
<p>
As Dave Chinner pointed out, if we try to walk a filesystem and the extent map has corrupted block number (out of range address) the call to xfs_perag_get() above will trigger a NULL pointer dereference.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * Reference counting access wrappers to the perag structures.
 * Because we never free per-ag structures, the only thing we
 * have to protect against changes is the tree structure itself.
 */
struct xfs_perag *
xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno)
{
        struct xfs_perag        *pag;
        int                     ref = 0;
 
        rcu_read_lock();
        pag = radix_tree_lookup(&amp;mp-&gt;m_perag_tree, agno);
        if (pag) {
               ASSERT(atomic_read(&amp;pag-&gt;pag_ref) &gt;= 0);
               ref = atomic_inc_return(&amp;pag-&gt;pag_ref);
        }
        rcu_read_unlock();
        trace_xfs_perag_get(mp, agno, ref, _RET_IP_);
        return pag;
}
</pre>
<p>
The radix_tree_lookup() call will use the invalid block number &#8216;agblocks&#8217; (size of an allocation group) as an index key to the &#8216;mp-&gt;m_perag_tree&#8217; radix tree.<br />
<br />
The fix to this bug was to add a new variable to the susceptible routine:<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
 	xfs_buf_t		*bp;
 	xfs_daddr_t		blkno = map[0].bm_bn;
+	xfs_daddr_t		eofs;
 	int			numblks = 0;
</pre>
<p>
And write a check for the block number not being larger than the end of the filesystem.<br />
</p>
<pre class="brush: cpp; title: ; notranslate">
 	ASSERT(!(BBTOB(blkno) &amp; (xfs_off_t)btp-&gt;bt_smask));
 
+	/*
+	 * Corrupted block numbers can get through to here, unfortunately, so we
+	 * have to check that the buffer falls within the filesystem bounds.
+	 */
+	eofs = XFS_FSB_TO_BB(btp-&gt;bt_mount, btp-&gt;bt_mount-&gt;m_sb.sb_dblocks);
+	if (blkno &gt;= eofs) {
+		/*
+		 * XXX (dgc): we should really be returning EFSCORRUPTED here,
+		 * but none of the higher level infrastructure supports
+		 * returning a specific error on buffer lookup failures.
+		 */
+		xfs_alert(btp-&gt;bt_mount,
+			  &quot;%s: Block out of range: block 0x%llx, EOFS 0x%llx &quot;,
+			  __func__, blkno, eofs);
+		return NULL;
+	}
+
 	/* get tree root */
</pre>
<p></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3392/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3392&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/18/cve-2013-1819-linux-kernel-xfs-_xfs_buf_find-null-pointer-dereference-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>Book: Absolute OpenBSD (2nd Edition)</title>
		<link>http://xorl.wordpress.com/2013/05/18/book-absolute-openbsd-2nd-edition/</link>
		<comments>http://xorl.wordpress.com/2013/05/18/book-absolute-openbsd-2nd-edition/#comments</comments>
		<pubDate>Sat, 18 May 2013 11:19:14 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[books]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3385</guid>
		<description><![CDATA[This is an excellent book for OpenBSD I recently had the opportunity to read. Let&#8217;s move on to my per chapter overview of the book. Title: Absolute OpenBSD: UNIX for the Practical Paranoid Author: Michael W. Lucas Chapter 1: Getting Additional Help A brief overview of the OpenBSD project&#8217;s support model along with the available [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3385&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is an excellent book for OpenBSD I recently had the opportunity to read. Let&#8217;s move on to my per chapter overview of the book.<br />
<br />
<a href="http://xorl.files.wordpress.com/2013/05/b_aobsd.png"><img src="http://xorl.files.wordpress.com/2013/05/b_aobsd.png?w=227&#038;h=300" alt="b_aobsd" width="227" height="300" class="aligncenter size-medium wp-image-3386" /></a><br />
<br />
<strong>Title:</strong> Absolute OpenBSD: UNIX for the Practical Paranoid<br />
<strong>Author:</strong> Michael W. Lucas<br />
<br />
<strong>Chapter 1: Getting Additional Help</strong><br />
A brief overview of the OpenBSD project&#8217;s support model along with the available resources (documentation, assistance, etc.).<br />
<br />
<strong>Chapter 2: Installation Preparations</strong><br />
A very well written chapter for everything you might need before installing OpenBSD starting from hardware specifications, and moving on how to obtain OpenBSD, understanding partitioning, disklabels, etc.<br />
<br />
<strong>Chapter 3: Installation Walk-Through</strong><br />
Once again the author starts from the very first steps such as configuring BIOS and goes through all the steps of the installer, disk configuration as well as some more advanced disklabel information.<br />
<br />
<strong>Chapter 4: Post-Install Setup</strong><br />
In this chapter you can find information on all the basic configuration that usually takes place exactly after the installation process. This ranges from software configuration, timezone settings, networking to more advanced concepts like keyboard mappings, graphic console, etc.<br />
<br />
<strong>Chapter 5: The Boot Process</strong><br />
Here after a description of the boot loader the author provides us with information on how to work in single-user mode, how to choose different kernel for booting, using serial console and of course, multi-user booting along with everything that comes with it.<br />
<br />
<strong>Chapter 6: User Management</strong><br />
As the chapter&#8217;s title implies, this is a complete guide for user management on OpenBSD. Apart from all the common administration tasks (adding, editing, removing users) there is also a detailed section for login classes.<br />
<br />
<strong>Chapter 7: Root, and How to Avoid It</strong><br />
This chapter could easily be renamed to &#8220;The complete guide to SUDO&#8221; since it includes all the required information to configure privileged accounts using SUDO.<br />
<br />
<strong>Chapter 8: Disks and Filesystems</strong><br />
One of the most useful chapters to anyone moving from Linux to OpenBSD. It&#8217;s another detailed part of the book referencing everything that someone needs to know to have a very good understanding of disks and filesystems in the OpenBSD world. This includes partitioning, labeling, FFS (Fast Filesystem), etc. as well as information for managing disks and filesystems on OpenBSD.<br />
<br />
<strong>Chapter 9: More Filesystems</strong><br />
The previous chapter was mostly focusing on the lower level of disks and filesystems while this one moves to a more in-depth approach on the filesystems. Herein you can find a lot of useful information for MFS (Memory Filesystem), foreign filesystems, NFS, etc.<br />
<br />
<strong>Chapter 10: Securing Your System</strong><br />
This is a 10 pages chapter but with enough information to keep you researching for some time. It&#8217;s an introduction to all the security mechanisms offered by OpenBSD and suggestions on how to keep your system secure after its initial configuration.<br />
<br />
<strong>Chapter 11: Overview of TCP/IP</strong><br />
Another introduction chapter this time for networking. It&#8217;s a very nice and well written part discussing all the basics of TCP/IP from theory to practice always having in mind the OpenBSD&#8217;s implementation of it.<br />
<br />
<strong>Chapter 12: Connecting to the Network</strong><br />
All the essential steps to get your OpenBSD network connected having working Ethernet and DNS name resolution. Furthermore in this chapter there are sections for slightly more advanced topics like trunking, VLANs and over IPv6 tunneling.<br />
<br />
<strong>Chapter 13: Software Management</strong><br />
Apart from the expected, detailed information on packages and port systems, here the reader can find information on customizing ports and sub-packages.<br />
<br />
<strong>Chapter 14: Everything /etc</strong><br />
Literally this is the best title to describe what you can find in this chapter. It&#8217;s a brief overview of every single configuration file under /etc directory.<br />
<br />
<strong>Chapter 15: System Maintenance</strong><br />
Here are some common administrative tasks separated by daily, weekly, monthly and custom maintenance tasks. Additionally, you can find information on system logging configuration and management, NTP, device drivers and hardware sensors configuration.<br />
<br />
<strong>Chapter 16: Network Servers</strong><br />
A description of configuring and managing the most common network servers in OpenBSD. This includes LPD, DHCP, TFTP, SSH and SNMP.<br />
<br />
<strong>Chapter 17: Desktop OpenBSD</strong><br />
Basically, this is everything you need to know to make your OpenBSD a working desktop environment. From the basic information on setting up X to working with CWM window manager and TMUX.<br />
<br />
<strong>Chapter 18: Kernel Configuration</strong><br />
The first part of this chapter&#8217;s aim is to provide an introduction to understanding OpenBSD&#8217;s kernel from a system administrator&#8217;s point of view. The next sections deal with more advanced subjects such as kernel tuning via sysctl and custom kernel configuration with config or boot-time kernel configuration.<br />
<br />
<strong>Chapter 19: Building Custom Kernels</strong><br />
Chapter starts by identifying the cautions of using custom kernels and after that it moves to the complete guide from configuring your own kernel, testing, building, installing and using it.<br />
<br />
<strong>Chapter 20: Upgrading</strong><br />
Another in-depth chapter this time for the upgrading process in OpenBSD. The first sections provide information on OpenBSD versioning and upgrade process while the following ones discuss in detail all the required steps to upgrade your system with all the available methods.<br />
<br />
<strong>Chapter 21: Packet Filtering</strong><br />
One of the main advantages of OpenBSD is the Packet Filtering (PF) system. This is an excellent introduction to it that includes all the basic information along with many different rules for various network protocols, configuration options and examples for sanitizing network traffic.<br />
<br />
<strong>Chapter 22: Advanced PF</strong><br />
Continuing from the previous one, this is a more advanced view of PF. The reader can find more information on setting up packet filtering with subjects like tables, NAT, anchors, bandwidth management, logging, etc.<br />
<br />
<strong>Chapter 23: Customizing OpenBSD</strong><br />
This last chapter is mostly comprised by ideas and small how-to sections for performing not-so-common tasks with OpenBSD. For example, here you can find information on virtualization, diskless setup, custom upgrades, etc.</p>
<p>This is definitely the absolute OpenBSD book since anyone, even with no experience with this operating system, can easily learn everything he/she needs to work with it. The chapters have a gradual level increase from completely basic to advanced so more advanced users can skip some of the initial ones and move on to the subject they want. Overall it&#8217;s an excellent, well written book providing great amount of information. However, the there is not a lot of knowledge for the most advanced users so in my opinion it is mostly focused on people that are starting or have recently started working with OpenBSD.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3385/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3385&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2013/05/18/book-absolute-openbsd-2nd-edition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>

		<media:content url="http://xorl.files.wordpress.com/2013/05/b_aobsd.png?w=227" medium="image">
			<media:title type="html">b_aobsd</media:title>
		</media:content>
	</item>
		<item>
		<title>Admin Mistake: F5 Load Balancer SNAT IP Address Apache Logging</title>
		<link>http://xorl.wordpress.com/2012/09/28/admin-mistake-f5-load-balancer-snat-ip-address-apache-logging/</link>
		<comments>http://xorl.wordpress.com/2012/09/28/admin-mistake-f5-load-balancer-snat-ip-address-apache-logging/#comments</comments>
		<pubDate>Fri, 28 Sep 2012 07:00:40 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[mistakes]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3383</guid>
		<description><![CDATA[Background Assume that you have a common three-tier architecture on a web farm with layers being web, application and database servers. The load balancing is performed by an F5 BIG-IP LTM 1600 load balancer and the logging takes place on the web farm that uses Apache web servers. Problem When you attempt to review the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3383&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Background</strong><br />
Assume that you have a common three-tier architecture on a web farm with layers being web, application and database servers. The load balancing is performed by an F5 BIG-IP LTM 1600 load balancer and the logging takes place on the web farm that uses Apache web servers.<br />
<br />
<strong>Problem</strong><br />
When you attempt to review the access logs of the Apache web servers the only IP address for all the requests is that of the F5 load balancer. Assuming that the load balancer address is 10.10.10.10, the log entries would always look like that:</p>
<pre class="brush: bash; title: ; notranslate">
10.10.10.10 - - [28/Sep/2012:15:06:18 +0000] &quot;GET / HTTP/1.0&quot; 200 228 &quot;-&quot; &quot;Wget/1.12 (linux-gnu)&quot;
10.10.10.10 - - [28/Sep/2012:15:06:31 +0000] &quot;GET / HTTP/1.0&quot; 200 228 &quot;-&quot; &quot;Wget/1.12 (linux-gnu)&quot;
</pre>
<p>
<strong>Mistake</strong><br />
By default this F5 load balancer will perform SNAT (Source Network Address Translation) and this is why the requestor IP address is always the load balancer&#8217;s one.<br />
<br />
<strong>Resolution</strong><br />
The solution is to utilize HTTP header field <a href="http://en.wikipedia.org/wiki/X-Forwarded-For">XFF</a>. On the load balancer side you will first have to follow the below steps in the BIG-IP configuration utility:<br />
- Go to &#8220;Local Traffic&#8221;<br />
- Select &#8220;Profiles&#8221;<br />
- On the &#8220;Services&#8221; menu choose &#8220;HTTP&#8221;<br />
- Create a new profile by clicking on &#8220;Create&#8221;<br />
- Activate &#8220;Insert X-Forwarded For&#8221; check box and select &#8220;Enabled&#8221; from the menu<br />
- Finally click on &#8220;Update&#8221;<br />
At last, you can use this new HTTP profile to the virtual servers you want to have the XFF HTTP header field.<br />
Moving to the web server side you will have to create a new custom log format on the virtual hosts you want to have proper source IP address logging. So, here is an example custom log format that will include the XFF field.</p>
<pre class="brush: bash; title: ; notranslate">
LogFormat &quot;%v %{X-Forwarded-For}i %l %u %t \&quot;%r\&quot; %&gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-Agent}i\&quot;&quot; CUST_F5_XFF_LOG
CustomLog /somewhere/access_log CUST_F5_XFF_LOG
</pre>
<p>And assuming that the real IP address is 2.2.2.2 while the load balancer&#8217;s is 10.10.10.10, the log entries will be:</p>
<pre class="brush: bash; title: ; notranslate">
10.10.10.10 2.2.2.2 - - [28/Sep/2012:16:48:25 +0000] &quot;GET / HTTP/1.0&quot; 200 228 &quot;-&quot; &quot;Wget/1.12 (linux-gnu)&quot;
10.10.10.10 2.2.2.2 - - [28/Sep/2012:16:41:28 +0000] &quot;GET / HTTP/1.0&quot; 200 228 &quot;-&quot; &quot;Wget/1.12 (linux-gnu)&quot;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3383/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3383&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2012/09/28/admin-mistake-f5-load-balancer-snat-ip-address-apache-logging/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>
	</item>
		<item>
		<title>History: Ancient Athens &#8211; Hadrian&#8217;s Arch (Greece)</title>
		<link>http://xorl.wordpress.com/2012/09/27/history-ancient-athens-hadrians-arch-greece/</link>
		<comments>http://xorl.wordpress.com/2012/09/27/history-ancient-athens-hadrians-arch-greece/#comments</comments>
		<pubDate>Thu, 27 Sep 2012 14:51:21 +0000</pubDate>
		<dc:creator>xorl</dc:creator>
				<category><![CDATA[history]]></category>

		<guid isPermaLink="false">http://xorl.wordpress.com/?p=3365</guid>
		<description><![CDATA[This post is part of a new category named &#8220;history&#8221; where I will be publishing quick overviews of historical locations (mainly in Greece) along with photographs and brief descriptions. This first post will be about Hadrian&#8217;s Arch which is currently located at the center of Athens but it used to separate the new with the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3365&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This post is part of a new category named &#8220;<a href="http://xorl.wordpress.com/category/history/">history</a>&#8221; where I will be publishing quick overviews of historical locations (mainly in Greece) along with photographs and brief descriptions.</p>
<p>This first post will be about <a href="http://en.wikipedia.org/wiki/Arch_of_Hadrian">Hadrian&#8217;s Arch</a> which is currently located at the center of Athens but it used to separate the new with the old city in ancient Greece. Below is a map of Ancient Athens I found <a href="http://www.ancient-athens.com/acropolis/map">here</a> which is very convenient for this post.<br />
<br />
<a href="http://xorl.files.wordpress.com/2012/09/hadrianarch_01.jpg"><img src="http://xorl.files.wordpress.com/2012/09/hadrianarch_01.jpg?w=295&#038;h=300" alt="" title="hadrianarch_01" width="295" height="300" class="aligncenter size-medium wp-image-3366" /></a><br />
<br />
And here is a photograph I took a couple of months ago.<br />
<br />
<a href="http://xorl.files.wordpress.com/2012/09/hadrianarch_02.jpg"><img src="http://xorl.files.wordpress.com/2012/09/hadrianarch_02.jpg?w=224&#038;h=300" alt="" title="hadrianarch_02" width="224" height="300" class="aligncenter size-medium wp-image-3367" /></a><br />
<br />
In the above photograph, through the Hadrian&#8217;s Arch you can clearly see the Acropolis of Athens which we will discuss in another blog post.<br />
<br />
<strong>History</strong><br />
Hadrian&#8217;s Arch was a triumphal arch made of Pentelikon marble in honor of Emperor Hadrian for his numerous benefactions in Ancient Athens. The arch was constructed in 131-132 A.D. and it has height of 18m and width of 13m. The monument was built using <a href="http://en.wikipedia.org/wiki/Corinthian_order">corinthian order</a> (the upper part). The inscription of the West side says:<br />
<strong>&#8220;ΑΙΔ&#8217;ΕΙΣΙΝ ΑΘΗΝΑΙ, ΘΗΣΕΩΣ Η ΠΡΙΝ ΠΟΛΙΣ&#8221;</strong> (This is Athens, the old city of Theseus)<br />
While the East side has the below inscription:<br />
<strong>&#8220;ΑΙΔ&#8217; ΕIΣΙΝ ΑΔΡΙΑΝΟΥ, ΚΟΥΧI ΘΗΣΕΩΣ ΠΟΛΙΣ&#8221;</strong> (This is the city of Hadrian, and not of Theseus)<br />
At this point something notable is that the arch can be easily separated in the lower and upper part where the lower has the <a href="http://en.wikipedia.org/wiki/Triumphal_arch#Roman_triumphal_arches">Ancient Roman Arch</a> design while the upper one has the previously mentioned Ancient Greek architecture (Corinthian Order). This was to honor both the Roman Hadrian as well as the mythical Greek founder of Athens, Theseus.<br />
<br />
I can write huge blog posts for such subjects but the whole idea is to provide small overviews. You can continue the research on your own. :)<br />
Below are a few additional photos.<br />
<br />
<a href="http://xorl.files.wordpress.com/2012/09/hadrianarch_03.jpg"><img src="http://xorl.files.wordpress.com/2012/09/hadrianarch_03.jpg?w=300&#038;h=224" alt="" title="hadrianarch_03" width="300" height="224" class="aligncenter size-medium wp-image-3373" /></a><br />
<br />
<a href="http://xorl.files.wordpress.com/2012/09/hadrianarch_04.jpg"><img src="http://xorl.files.wordpress.com/2012/09/hadrianarch_04.jpg?w=224&#038;h=300" alt="" title="hadrianarch_04" width="224" height="300" class="aligncenter size-medium wp-image-3374" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xorl.wordpress.com/3365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xorl.wordpress.com/3365/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xorl.wordpress.com&#038;blog=6013855&#038;post=3365&#038;subd=xorl&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xorl.wordpress.com/2012/09/27/history-ancient-athens-hadrians-arch-greece/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fddd541cb1c2cd8b2d9b0f4da2c5e8c?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=X" medium="image">
			<media:title type="html">xorl</media:title>
		</media:content>

		<media:content url="http://xorl.files.wordpress.com/2012/09/hadrianarch_01.jpg?w=295" medium="image">
			<media:title type="html">hadrianarch_01</media:title>
		</media:content>

		<media:content url="http://xorl.files.wordpress.com/2012/09/hadrianarch_02.jpg?w=224" medium="image">
			<media:title type="html">hadrianarch_02</media:title>
		</media:content>

		<media:content url="http://xorl.files.wordpress.com/2012/09/hadrianarch_03.jpg?w=300" medium="image">
			<media:title type="html">hadrianarch_03</media:title>
		</media:content>

		<media:content url="http://xorl.files.wordpress.com/2012/09/hadrianarch_04.jpg?w=224" medium="image">
			<media:title type="html">hadrianarch_04</media:title>
		</media:content>
	</item>
	</channel>
</rss>
