Index: wp-admin/css/common.css
===================================================================
--- wp-admin/css/common.css	(revision 32470)
+++ wp-admin/css/common.css	(working copy)
@@ -1880,6 +1880,25 @@
 	font-weight: 600;
 }
 
+.options-general-php img.favicon {
+	vertical-align:middle;
+
+	-moz-box-shadow:    1px 1px 3px 0px #aaa;
+	-webkit-box-shadow: 1px 1px 3px 0px #aaa;
+	box-shadow:         1px 1px 3px 0px #aaa;
+}
+
+#remove-favicon-button {
+	margin-left:5px;
+}
+
+/* Favicon upload error messages */
+#favicon-invalid-filetype-error {
+	display:none;
+	color:red;
+	font-style: italic;
+}
+
 /*------------------------------------------------------------------------------
   21.0 - Admin Footer
 ------------------------------------------------------------------------------*/
Index: wp-admin/options-general.php
===================================================================
--- wp-admin/options-general.php	(revision 32470)
+++ wp-admin/options-general.php	(working copy)
@@ -105,6 +105,8 @@
 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
 );
 
+wp_enqueue_script('wp-favicon');
+
 include( ABSPATH . 'wp-admin/admin-header.php' );
 ?>
 
@@ -111,6 +113,30 @@
 <div class="wrap">
 <h2><?php echo esc_html( $title ); ?></h2>
 
+<form action="<?php echo admin_url('favicon-upload.php')?>" method="post" enctype="multipart/form-data" id="faviconupload">
+    <?php settings_fields('favicon_upload') ?>
+	<table class="form-table">
+		<tr valign="top">
+			<th scope="row"><label for="sitefavicon"><?php _e('Favicon') ?></label></th>
+			<td>
+				<?php
+					// display the icon and the remove link if appropriate
+					if ( has_custom_favicon() ){
+						if ( $thumbnail = get_favicon_img() ) echo $thumbnail;
+						echo "\t" . '<input type="submit" name="REMOVE_FAVICON" value="Remove Favicon" id="remove-favicon-button" />';
+						echo ' <span class="description no-js">' . __( 'The image at right is used as your site\'s favicon. To change it, first remove this one.' ) . '</span>';
+					} else {
+				?>
+					<input class="button" name="avatarfile" type="file" id="faviconfile" size="35" />
+					<p class="submit no-js hide-if-js"><input type="submit" name="Submit" value="Upload Image &raquo;" id="faviconsubmit" /></p>
+					<span class="description no-js"><?php _e('Click to upload your own custom icon ("favicon") for your blog. You\'ll be able to crop and scale it once it\'s uploaded.') ?></span>
+					<span id="favicon-invalid-filetype-error"><?php _e( 'Please only upload files in the following formats: .ico, .png, .bmp, .jpg' ) ?></span>
+				<?php } ?>
+			</td>
+		</tr>
+	</table>
+</form>
+
 <form method="post" action="options.php" novalidate="novalidate">
 <?php settings_fields('general'); ?>
 
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 32470)
+++ wp-includes/functions.php	(working copy)
@@ -2181,7 +2181,7 @@
 	'png' => 'image/png',
 	'bmp' => 'image/bmp',
 	'tiff|tif' => 'image/tiff',
-	'ico' => 'image/x-icon',
+	'ico' => 'image/vnd.microsoft.icon',
 	// Video formats.
 	'asf|asx' => 'video/x-ms-asf',
 	'wmv' => 'video/x-ms-wmv',
Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 32470)
+++ wp-includes/general-template.php	(working copy)
@@ -2221,6 +2221,137 @@
 }
 
 /**
+ * Convenience function that echoes the HTML for the site's favicon icon.
+ * By default, automatically included in the header via the 'wp_head' action, which can be removed by themes if a custom favicon is desired.
+ *
+ * @uses generate_site_favicon_html() to do the actual heavy lifting
+ */
+function site_favicon(){
+	echo generate_site_favicon_html();
+}
+add_action( 'wp_head', 'site_favicon' );
+add_action( 'admin_head', 'site_favicon' );
+
+/**
+ * Return the HTML for the site's favicon icon, if such has been defined.
+ *
+ * @uses get_site_favicon_uri();
+ *
+ * Includes the conditional tag wrapper for an IE (.ico) version.
+ */
+function generate_site_favicon_html() {
+	$favicon_uri = get_site_favicon_uri();
+	$ie_favicon_uri = get_site_favicon_uri( 'ico' );
+
+	$content = "";
+	if (! empty( $favicon_uri ) ){
+		$content .= "\n\n<!--favicon (via 'wp_head' action) -->\n";
+
+		if (! empty( $ie_favicon_uri )) $content .= <<<IE_FAVICON_1
+<!--[if IE]>
+	<link rel="shortcut icon" href="{$ie_favicon_uri}" />
+<![endif]-->
+<!--[if !IE]>-->\n
+IE_FAVICON_1;
+
+		$content .= "\t<link href=\"{$favicon_uri}\" rel=\"icon\" type=\"image/png\" />\n";
+
+		if (! empty( $ie_favicon_uri )) $content .= "<!--<![endif]-->";
+		$content .= "\n<!-- /favicon -->\n\n";
+    }
+	return $content;
+}
+
+/**
+ * Get the attachment post object associated with the current site favicon, based on the 'sitefavicon' option
+ *
+ * @param string $format Default 'png'. Format of the file we're looking for
+ * @return object If found, returns the post object; if not, a WP_Error object
+ */
+function get_site_favicon_attachment( $format = 'png' ){
+	$favicon_basename = get_option ( 'sitefavicon' );
+
+	if ( ! empty( $favicon_basename ) ) {
+		$favicon_fullname = $favicon_basename . '-' . $format;
+
+		$posts = get_posts( array( 'name' => $favicon_fullname, 'post_type' => 'attachment' ) );
+		if ( count( $posts ) > 0 ){
+			return $posts[0];
+		} else {
+			return new WP_Error( 'attachment_missing', __( "No attachment for '$favicon_fullname' was found." ) );
+		}
+	} else {
+		return new WP_Error( 'not_defined', __( "No favicon file provided." ) );
+	}
+}
+
+/**
+ * Returns the URI for the site's favicon based on the option set in  Admin > Settings > General.
+ *
+ * @param string $format png|ico default 'png'. Use 'ico' for serving up an IE-compatible ICO file
+ * @return string fully qualified URI
+ */
+function get_site_favicon_uri( $format = 'png' ){
+	/** @TODO provide error checking for validity of $format and $size */
+	$favicon_attachment = get_site_favicon_attachment( $format );
+
+	/** @TODO provide the ability to define a 'default' favicon that would be distributed with fresh WP installations */
+	if ( ! is_wp_error( $favicon_attachment ) ) {
+		return wp_get_attachment_url( $favicon_attachment->ID );
+	}
+
+	// We get here because of an error condition
+	/** @TODO default to the theme's favicon **/
+	// ATM do nothing (so URI is blank, rather than a WP_Error)
+}
+
+/**
+ * Gets the path to the favicon file, or returns a WP_Error
+ * @param string $format Default 'png'
+ * @return mixed File string or WP_Error object
+ */
+function get_site_favicon_file( $format = 'png' ){
+	$favicon_attachment = get_site_favicon_attachment( $format );
+
+	/** @TODO provide the ability to define a 'default' favicon that would be distributed with fresh WP installations */
+	if ( ! is_wp_error( $favicon_attachment ) ) {
+		$file = get_attached_file( $favicon_attachment->ID );
+		if ( file_exists( $file ) ) return $file;
+		else return new WP_Error( 'file_missing', __( 'Favicon image file missing.' ) );
+	} else {
+		return $favicon_attachment; // returns the WP_Error object
+	}
+}
+
+/**
+ * Returns true or false depending on whether a custom favicon has been defined in Admin
+ * @return boolean
+ */
+function has_custom_favicon(){
+	return ( get_option ( 'sitefavicon' ) && ! is_wp_error( get_site_favicon_file() ) );
+}
+
+/**
+ * Returns an HTML <img> tag populated with the site favicon, in the format specified (usually PNG)
+ * @param string $format Default 'png'. Valid values are 'png', 'bmp' (note 'ico' is NOT valid)
+ * @return mixed Returns HTML <img> tag or WP_Error if invalid format given. Returns nothing if the file is missing.
+ */
+function get_favicon_img( $format = 'png' ){
+	if (in_array( strtolower( $format ), array( 'png', 'bmp' ) ) ){
+		// Does the file actually exist?
+		$file = get_site_favicon_file( $format );
+		if (! is_wp_error( $file ) && file_exists( $file ) ){
+			$src = get_site_favicon_uri( $format );
+			if (!is_wp_error( $src ) ){
+				return '<img src="' . $src . '" class="favicon" alt="' . _x( 'Site favicon thumbnail', 'Thumbnail image accessibility text' ) .'" />';
+			}
+		}
+	} else {
+		return new WP_Error( 'invalid_file_format', __( 'Invalid file format. Valid formats are "png", "bmp".' ) );
+	}
+}
+
+/**
  * Display the links to the general feeds.
  *
  * @since 2.8.0
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 32470)
+++ wp-includes/script-loader.php	(working copy)
@@ -107,6 +107,8 @@
 
 	$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 );
 
+	$scripts->add( 'wp-favicon', "/wp-admin/js/wp-favicon$suffix.js", array('jquery'), false, 1 );
+
 	$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
 	did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
 		'noPerm' => __('You do not have permission to do that.'),
