File tree Expand file tree Collapse file tree 9 files changed +51
-1
lines changed
hadoop-hdfs-project/hadoop-hdfs
main/java/org/apache/hadoop/hdfs
test/java/org/apache/hadoop/hdfs Expand file tree Collapse file tree 9 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,9 @@ Release 2.3.0 - UNRELEASED
798798 HDFS-5590. Block ID and generation stamp may be reused when persistBlocks is
799799 set to false. (jing9)
800800
801+ HDFS-5353. Short circuit reads fail when dfs.encrypt.data.transfer is
802+ enabled. (Colin Patrick McCabe via jing9)
803+
801804Release 2.2.0 - 2013-10-13
802805
803806 INCOMPATIBLE CHANGES
Original file line number Diff line number Diff line change @@ -125,4 +125,9 @@ public String toString() {
125125 public DomainSocket getDomainSocket () {
126126 return null ;
127127 }
128+
129+ @ Override
130+ public boolean hasSecureChannel () {
131+ return false ;
132+ }
128133}
Original file line number Diff line number Diff line change @@ -114,4 +114,19 @@ public String toString() {
114114 public DomainSocket getDomainSocket () {
115115 return socket ;
116116 }
117+
118+ @ Override
119+ public boolean hasSecureChannel () {
120+ //
121+ // Communication over domain sockets is assumed to be secure, since it
122+ // doesn't pass over any network. We also carefully control the privileges
123+ // that can be used on the domain socket inode and its parent directories.
124+ // See #{java.org.apache.hadoop.net.unix.DomainSocket#validateSocketPathSecurity0}
125+ // for details.
126+ //
127+ // So unless you are running as root or the hdfs superuser, you cannot
128+ // launch a man-in-the-middle attach on UNIX domain socket traffic.
129+ //
130+ return true ;
131+ }
117132}
Original file line number Diff line number Diff line change @@ -139,4 +139,9 @@ public String toString() {
139139 public DomainSocket getDomainSocket () {
140140 return enclosedPeer .getDomainSocket ();
141141 }
142+
143+ @ Override
144+ public boolean hasSecureChannel () {
145+ return true ;
146+ }
142147}
Original file line number Diff line number Diff line change @@ -128,4 +128,9 @@ public String toString() {
128128 public DomainSocket getDomainSocket () {
129129 return null ;
130130 }
131+
132+ @ Override
133+ public boolean hasSecureChannel () {
134+ return false ;
135+ }
131136}
Original file line number Diff line number Diff line change @@ -112,4 +112,12 @@ public interface Peer extends Closeable {
112112 * peer, or null if there is none.
113113 */
114114 public DomainSocket getDomainSocket ();
115+
116+ /**
117+ * Return true if the channel is secure.
118+ *
119+ * @return True if our channel to this peer is not
120+ * susceptible to man-in-the-middle attacks.
121+ */
122+ public boolean hasSecureChannel ();
115123}
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ public void run() {
162162 try {
163163 peer .setWriteTimeout (datanode .getDnConf ().socketWriteTimeout );
164164 InputStream input = socketIn ;
165- if (dnConf .encryptDataTransfer ) {
165+ if ((! peer . hasSecureChannel ()) && dnConf .encryptDataTransfer ) {
166166 IOStreamPair encryptedStreams = null ;
167167 try {
168168 encryptedStreams = DataTransferEncryptor .getEncryptedStreams (socketOut ,
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ static public void setupCluster() throws Exception {
4242 new File (sockDir .getDir (),
4343 "TestParallelShortCircuitReadUnCached._PORT.sock" ).getAbsolutePath ());
4444 conf .setBoolean (DFSConfigKeys .DFS_CLIENT_READ_SHORTCIRCUIT_KEY , true );
45+ // Enabling data transfer encryption should have no effect when using
46+ // short-circuit local reads. This is a regression test for HDFS-5353.
47+ conf .setBoolean (DFSConfigKeys .DFS_ENCRYPT_DATA_TRANSFER_KEY , true );
48+ conf .setBoolean (DFSConfigKeys .DFS_BLOCK_ACCESS_TOKEN_ENABLE_KEY , true );
4549 conf .setBoolean (DFSConfigKeys .
4650 DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY , false );
4751 conf .setBoolean (DFSConfigKeys .
Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ public boolean equals(Object o) {
140140 public int hashCode () {
141141 return dnId .hashCode () ^ (hasDomain ? 1 : 0 );
142142 }
143+
144+ @ Override
145+ public boolean hasSecureChannel () {
146+ return false ;
147+ }
143148 }
144149
145150 @ Test
You can’t perform that action at this time.
0 commit comments