HBASE-11052 Sending random data crashes thrift service

This commit is contained in:
Ted Yu 2014-06-17 16:03:16 +00:00
parent e476947d3f
commit 1324a3cb18
3 changed files with 26 additions and 4 deletions

View File

@ -952,6 +952,25 @@ possible configurations would overwhelm and obscure the important.
can be adjusted as needed.
</description>
</property>
<property>
<name>hbase.regionserver.thrift.framed</name>
<value>false</value>
<description>Use Thrift TFramedTransport on the server side.
This is the recommended transport for thrift servers and requires a similar setting
on the client side. Changing this to false will select the default transport,
vulnerable to DoS when malformed requests are issued due to THRIFT-601.
</description>
</property>
<property>
<name>hbase.regionserver.thrift.framed.max_frame_size_in_mb</name>
<value>2</value>
<description>Default frame size when using framed transport</description>
</property>
<property>
<name>hbase.regionserver.thrift.compact</name>
<value>false</value>
<description>Use Thrift TCompactProtocol binary serialization protocol.</description>
</property>
<property>
<name>hbase.offheapcache.percentage</name>
<value>0</value>

View File

@ -118,6 +118,7 @@ public class ThriftServerRunner implements Runnable {
static final String BIND_CONF_KEY = "hbase.regionserver.thrift.ipaddress";
static final String COMPACT_CONF_KEY = "hbase.regionserver.thrift.compact";
static final String FRAMED_CONF_KEY = "hbase.regionserver.thrift.framed";
static final String MAX_FRAME_SIZE_CONF_KEY = "hbase.regionserver.thrift.framed.max_frame_size_in_mb";
static final String PORT_CONF_KEY = "hbase.regionserver.thrift.port";
static final String COALESCE_INC_KEY = "hbase.regionserver.thrift.coalesceIncrement";
@ -283,7 +284,8 @@ public class ThriftServerRunner implements Runnable {
// Construct correct TransportFactory
TTransportFactory transportFactory;
if (conf.getBoolean(FRAMED_CONF_KEY, false) || implType.isAlwaysFramed) {
transportFactory = new TFramedTransport.Factory();
transportFactory = new TFramedTransport.Factory(
conf.getInt(MAX_FRAME_SIZE_CONF_KEY, 2) * 1024 * 1024);
LOG.debug("Using framed transport");
} else {
transportFactory = new TTransportFactory();

View File

@ -125,10 +125,10 @@ public class ThriftServer {
}
}
private static TTransportFactory getTTransportFactory(boolean framed) {
private static TTransportFactory getTTransportFactory(boolean framed, int frameSize) {
if (framed) {
log.debug("Using framed transport");
return new TFramedTransport.Factory();
return new TFramedTransport.Factory(frameSize);
} else {
return new TTransportFactory();
}
@ -274,7 +274,8 @@ public class ThriftServer {
boolean framed = cmd.hasOption("framed") ||
conf.getBoolean("hbase.regionserver.thrift.framed", false) || nonblocking || hsha;
TTransportFactory transportFactory = getTTransportFactory(framed);
TTransportFactory transportFactory = getTTransportFactory(framed,
conf.getInt("hbase.regionserver.thrift.framed.max_frame_size_in_mb", 2) * 1024 * 1024);
InetSocketAddress inetSocketAddress = bindToPort(cmd.getOptionValue("bind"), listenPort);
conf.setBoolean("hbase.regionserver.thrift.framed", framed);