db-d2/primevul-codebert-embeddings huggingface dataset:
Commit message: None
CVE: CVE-2016-2499
CWE: CWE-200
Vulnerability description: AudioSource.cpp in libstagefright in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-06-01 does not initialize certain data, which allows attackers to obtain sensitive information via a crafted application, aka internal bug 27855172.

Project: Android

status_t AudioSource::initCheck() const {
 return mInitCheck;
}

Project: Android

void AudioSource::queueInputBuffer_l(MediaBuffer *buffer, int64_t timeUs) {
 const size_t bufferSize = buffer->range_length();
 const size_t frameSize = mRecord->frameSize();
 const int64_t timestampUs =
                mPrevSampleTimeUs +
 ((1000000LL * (bufferSize / frameSize)) +
 (mSampleRate >> 1)) / mSampleRate;

 if (mNumFramesReceived == 0) {
        buffer->meta_data()->setInt64(kKeyAnchorTime, mStartTimeUs);
 }

    buffer->meta_data()->setInt64(kKeyTime, mPrevSampleTimeUs);
    buffer->meta_data()->setInt64(kKeyDriftTime, timeUs - mInitialReadTimeUs);
    mPrevSampleTimeUs = timestampUs;
    mNumFramesReceived += bufferSize / frameSize;
    mBuffersReceived.push_back(buffer);
    mFrameAvailableCondition.signal();
}

Project: Android

void AudioSource::rampVolume(
 int32_t startFrame, int32_t rampDurationFrames,
 uint8_t *data, size_t bytes) {

 const int32_t kShift = 14;
 int32_t fixedMultiplier = (startFrame << kShift) / rampDurationFrames;
 const int32_t nChannels = mRecord->channelCount();
 int32_t stopFrame = startFrame + bytes / sizeof(int16_t);
 int16_t *frame = (int16_t *) data;
 if (stopFrame > rampDurationFrames) {
        stopFrame = rampDurationFrames;
 }

 while (startFrame < stopFrame) {
 if (nChannels == 1) { // mono
            frame[0] = (frame[0] * fixedMultiplier) >> kShift;
 ++frame;
 ++startFrame;
 } else { // stereo
            frame[0] = (frame[0] * fixedMultiplier) >> kShift;
            frame[1] = (frame[1] * fixedMultiplier) >> kShift;
            frame += 2;
            startFrame += 2;
 }

 if ((startFrame & 3) == 0) {
            fixedMultiplier = (startFrame << kShift) / rampDurationFrames;
 }
 }
}
Commit message: None
CVE: CVE-2016-2450
CWE: CWE-264
Vulnerability description: codecs/on2/enc/SoftVPXEncoder.cpp in libstagefright in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-05-01 does not validate OMX buffer sizes, which allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 27569635.

Project: Android

OMX_ERRORTYPE SoftVPXEncoder::internalSetBitrateParams(
 const OMX_VIDEO_PARAM_BITRATETYPE* bitrate) {
 if (bitrate->nPortIndex != kOutputPortIndex) {
 return OMX_ErrorUnsupportedIndex;
 }

    mBitrate = bitrate->nTargetBitrate;

 if (bitrate->eControlRate == OMX_Video_ControlRateVariable) {
        mBitrateControlMode = VPX_VBR;
 } else if (bitrate->eControlRate == OMX_Video_ControlRateConstant) {
        mBitrateControlMode = VPX_CBR;
 } else {
 return OMX_ErrorUnsupportedSetting;
 }

 return OMX_ErrorNone;
}
Commit message: None
CVE: CVE-2016-2440
CWE: CWE-264
Vulnerability description: libs/binder/IPCThreadState.cpp in Binder in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-05-01 mishandles object references, which allows attackers to gain privileges via a crafted application, aka internal bug 27252896.

Project: Android

void IPCThreadState::blockUntilThreadAvailable()
{
    pthread_mutex_lock(&mProcess->mThreadCountLock);
 while (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads) {
        ALOGW("Waiting for thread to be free. mExecutingThreadsCount=%lu mMaxThreads=%lu\n",
 static_cast<unsigned long>(mProcess->mExecutingThreadsCount),
 static_cast<unsigned long>(mProcess->mMaxThreads));
        pthread_cond_wait(&mProcess->mThreadCountDecrement, &mProcess->mThreadCountLock);
 }
    pthread_mutex_unlock(&mProcess->mThreadCountLock);
}

Project: Android

status_t IPCThreadState::clearLastError()
{
 const status_t err = mLastError;
    mLastError = NO_ERROR;
 return err;
}

Project: Android

void IPCThreadState::expungeHandle(int32_t handle, IBinder* binder)
{
#if LOG_REFCOUNTS
    printf("IPCThreadState::expungeHandle(%ld)\n", handle);
#endif
    self()->mProcess->expungeHandle(handle, binder);
}

Project: Android

uid_t IPCThreadState::getCallingUid() const
{
 return mCallingUid;
}

Project: Android

static const void* printCommand(TextOutput& out, const void* _cmd)
{
 static const size_t N = sizeof(kCommandStrings)/sizeof(kCommandStrings[0]);
 const int32_t* cmd = (const int32_t*)_cmd;
 uint32_t code = (uint32_t)*cmd++;
 size_t cmdIndex = code & 0xff;

 if (cmdIndex >= N) {
        out << "Unknown command: " << code << endl;
 return cmd;
 }
    out << kCommandStrings[cmdIndex];

 switch (code) {
 case BC_TRANSACTION:
 case BC_REPLY: {
            out << ": " << indent;
            cmd = (const int32_t *)printBinderTransactionData(out, cmd);
            out << dedent;
 } break;
 
 case BC_ACQUIRE_RESULT: {
 const int32_t res = *cmd++;
            out << ": " << res << (res ? " (SUCCESS)" : " (FAILURE)");
 } break;
 
 case BC_FREE_BUFFER: {
 const int32_t buf = *cmd++;
            out << ": buffer=" << (void*)(long)buf;
 } break;
 
 case BC_INCREFS:
 case BC_ACQUIRE:
 case BC_RELEASE:
 case BC_DECREFS: {
 const int32_t d = *cmd++;
            out << ": desc=" << d;
 } break;
 
 case BC_INCREFS_DONE:
 case BC_ACQUIRE_DONE: {
 const int32_t b = *cmd++;
 const int32_t c = *cmd++;
            out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")";
 } break;
 
 case BC_ATTEMPT_ACQUIRE: {
 const int32_t p = *cmd++;
 const int32_t d = *cmd++;
            out << ": desc=" << d << ", pri=" << p;
 } break;
 
 case BC_REQUEST_DEATH_NOTIFICATION:
 case BC_CLEAR_DEATH_NOTIFICATION: {
 const int32_t h = *cmd++;
 const int32_t c = *cmd++;
            out << ": handle=" << h << " (death cookie " << (void*)(long)c << ")";
 } break;

 case BC_DEAD_BINDER_DONE: {
 const int32_t c = *cmd++;
            out << ": death cookie " << (void*)(long)c;
 } break;

 default:
 break;
 }
 
    out << endl;
 return cmd;
}
Commit message: None
CVE: CVE-2016-2420
CWE: CWE-264
Vulnerability description: rootdir/init.rc in Android 4.x before 4.4.4 does not ensure that the /data/tombstones directory exists for the Debuggerd component, which allows attackers to gain privileges via a crafted application, aka internal bug 26403620.

Project: Android

static void dump_header_info(log_t* log) {
 char fingerprint[PROPERTY_VALUE_MAX];
 char revision[PROPERTY_VALUE_MAX];

  property_get("ro.build.fingerprint", fingerprint, "unknown");
  property_get("ro.revision", revision, "unknown");

  _LOG(log, logtype::HEADER, "Build fingerprint: '%s'\n", fingerprint);
  _LOG(log, logtype::HEADER, "Revision: '%s'\n", revision);
  _LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING);
}

Project: Android

static void dump_stack_segment(
 Backtrace* backtrace, log_t* log, uintptr_t* sp, size_t words, int label) {
 for (size_t i = 0; i < words; i++) {
 word_t stack_content;
 if (!backtrace->ReadWord(*sp, &stack_content)) {
 break;
 }

 const backtrace_map_t* map = backtrace->FindMap(stack_content);
 const char* map_name;
 if (!map) {
      map_name = "";
 } else {
      map_name = map->name.c_str();
 }
 uintptr_t offset = 0;
    std::string func_name(backtrace->GetFunctionName(stack_content, &offset));
 if (!func_name.empty()) {
 if (!i && label >= 0) {
 if (offset) {
          _LOG(log, logtype::STACK, "    #%02d  %" PRIPTR "  %" PRIPTR "  %s (%s+%" PRIuPTR ")\n",
               label, *sp, stack_content, map_name, func_name.c_str(), offset);
 } else {
          _LOG(log, logtype::STACK, "    #%02d  %" PRIPTR "  %" PRIPTR "  %s (%s)\n",
               label, *sp, stack_content, map_name, func_name.c_str());
 }
 } else {
 if (offset) {
          _LOG(log, logtype::STACK, "         %" PRIPTR "  %" PRIPTR "  %s (%s+%" PRIuPTR ")\n",
 *sp, stack_content, map_name, func_name.c_str(), offset);
 } else {
          _LOG(log, logtype::STACK, "         %" PRIPTR "  %" PRIPTR "  %s (%s)\n",
 *sp, stack_content, map_name, func_name.c_str());
 }
 }
 } else {
 if (!i && label >= 0) {
        _LOG(log, logtype::STACK, "    #%02d  %" PRIPTR "  %" PRIPTR "  %s\n",
             label, *sp, stack_content, map_name);
 } else {
        _LOG(log, logtype::STACK, "         %" PRIPTR "  %" PRIPTR "  %s\n",
 *sp, stack_content, map_name);
 }
 }

 *sp += sizeof(word_t);
 }
}

Project: Android

static bool signal_has_si_addr(int sig) {
 switch (sig) {
 case SIGBUS:
 case SIGFPE:
 case SIGILL:
 case SIGSEGV:
 case SIGTRAP:
 return true;
 default:
 return false;
 }
}
Commit message: None
CVE: CVE-2016-2419
CWE: CWE-264
Vulnerability description: media/libmedia/IDrm.cpp in mediaserver in Android 6.x before 2016-04-01 does not initialize a certain key-request data structure, which allows attackers to obtain sensitive information from process memory, and consequently bypass an unspecified protection mechanism, via unspecified vectors, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 26323455.

Project: Android

 virtual status_t createPlugin(const uint8_t uuid[16]) {
 Parcel data, reply;
        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());
        data.write(uuid, 16);

 status_t status = remote()->transact(CREATE_PLUGIN, data, &reply);
 if (status != OK) {
 return status;
 }

 return reply.readInt32();
 }

Project: Android

 virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId,
 String8 const &algorithm) {
 Parcel data, reply;
        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());

        writeVector(data, sessionId);
        data.writeString8(algorithm);
 status_t status = remote()->transact(SET_CIPHER_ALGORITHM, data, &reply);
 if (status != OK) {
 return status;
 }
 return reply.readInt32();
 }

Project: Android

 virtual status_t verify(Vector<uint8_t> const &sessionId,
 Vector<uint8_t> const &keyId,
 Vector<uint8_t> const &message,
 Vector<uint8_t> const &signature,
 bool &match) {
 Parcel data, reply;
        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());

        writeVector(data, sessionId);
        writeVector(data, keyId);
        writeVector(data, message);
        writeVector(data, signature);

 status_t status = remote()->transact(VERIFY, data, &reply);
 if (status != OK) {
 return status;
 }
        match = (bool)reply.readInt32();
 return reply.readInt32();
 }
Commit message: None
CVE: CVE-2016-2417
CWE: CWE-264
Vulnerability description: media/libmedia/IOMX.cpp in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-04-01 does not initialize a parameter data structure, which allows attackers to obtain sensitive information from process memory, and consequently bypass an unspecified protection mechanism, via unspecified vectors, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 26914474.

Project: Android

 virtual status_t createInputSurface(
            node_id node, OMX_U32 port_index,
            sp<IGraphicBufferProducer> *bufferProducer) {
 Parcel data, reply;
 status_t err;
        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
        data.writeInt32((int32_t)node);
        data.writeInt32(port_index);
        err = remote()->transact(CREATE_INPUT_SURFACE, data, &reply);
 if (err != OK) {
            ALOGW("binder transaction failed: %d", err);
 return err;
 }

        err = reply.readInt32();
 if (err != OK) {
 return err;
 }

 *bufferProducer = IGraphicBufferProducer::asInterface(
                reply.readStrongBinder());

 return err;
 }

Project: Android

 virtual status_t useBuffer(
            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
            buffer_id *buffer) {
 Parcel data, reply;
        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
        data.writeInt32((int32_t)node);
        data.writeInt32(port_index);
        data.writeStrongBinder(params->asBinder());
        remote()->transact(USE_BUFFER, data, &reply);

 status_t err = reply.readInt32();
 if (err != OK) {
 *buffer = 0;

 return err;
 }

 *buffer = (buffer_id)reply.readInt32();

 return err;
 }
Commit message: None
CVE: CVE-2016-2416
CWE: CWE-264
Vulnerability description: libs/gui/BufferQueueConsumer.cpp in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-04-01 does not check for the android.permission.DUMP permission, which allows attackers to obtain sensitive information, and consequently bypass an unspecified protection mechanism, via a dump request, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 27046057.

Project: Android

status_t BufferQueueConsumer::detachBuffer(int slot) {
    ATRACE_CALL();
    ATRACE_BUFFER_INDEX(slot);
    BQ_LOGV("detachBuffer(C): slot %d", slot);
 Mutex::Autolock lock(mCore->mMutex);

 if (mCore->mIsAbandoned) {
        BQ_LOGE("detachBuffer(C): BufferQueue has been abandoned");
 return NO_INIT;
 }

 if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
        BQ_LOGE("detachBuffer(C): slot index %d out of range [0, %d)",
                slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
 return BAD_VALUE;
 } else if (mSlots[slot].mBufferState != BufferSlot::ACQUIRED) {
        BQ_LOGE("detachBuffer(C): slot %d is not owned by the consumer "
 "(state = %d)", slot, mSlots[slot].mBufferState);
 return BAD_VALUE;
 }

    mCore->freeBufferLocked(slot);
    mCore->mDequeueCondition.broadcast();

 return NO_ERROR;
}

Project: Android

status_t BufferQueueConsumer::disconnect() {
    ATRACE_CALL();

    BQ_LOGV("disconnect(C)");

 Mutex::Autolock lock(mCore->mMutex);

 if (mCore->mConsumerListener == NULL) {
        BQ_LOGE("disconnect(C): no consumer is connected");
 return BAD_VALUE;
 }

    mCore->mIsAbandoned = true;
    mCore->mConsumerListener = NULL;
    mCore->mQueue.clear();
    mCore->freeAllBuffersLocked();
    mCore->mDequeueCondition.broadcast();
 return NO_ERROR;
}
Commit message: None
CVE: CVE-2016-0846
CWE: CWE-264
Vulnerability description: libs/binder/IMemory.cpp in the IMemory Native Interface in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-04-01 does not properly consider the heap size, which allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 26877992.

Project: Android

void HeapCache::binderDied(const wp<IBinder>& binder)
{
    free_heap(binder);
}

Project: Android

void* IMemory::fastPointer(const sp<IBinder>& binder, ssize_t offset) const
{
    sp<IMemoryHeap> realHeap = BpMemoryHeap::get_heap(binder);
 void* const base = realHeap->base();
 if (base == MAP_FAILED)
 return 0;
 return static_cast<char*>(base) + offset;
}
Commit message: None
CVE: CVE-2016-0839
CWE: CWE-119
Vulnerability description: post_proc/volume_listener.c in mediaserver in Android 6.x before 2016-04-01 mishandles deleted effect context, which allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, aka internal bug 25753245.

Project: Android

static int vol_prc_lib_get_descriptor(const effect_uuid_t *uuid,
 effect_descriptor_t *descriptor)
{
 int i = 0;
    ALOGV("%s Called ", __func__);
 if (lib_init() != 0) {
 return init_status;
 }

 if (descriptor == NULL || uuid == NULL) {
        ALOGE("%s: %s is NULL", __func__, (descriptor == NULL) ? "descriptor" : "uuid");
 return -EINVAL;
 }

 for (i = 0; descriptors[i] != NULL; i++) {
 if (memcmp(uuid, &descriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
 *descriptor = *descriptors[i];
 return 0;
 }
 }

    ALOGE("%s: couldnt found uuid passed, oops", __func__);
 return -EINVAL;
}
Commit message: None
CVE: CVE-2016-0829
CWE: CWE-254
Vulnerability description: The BnGraphicBufferProducer::onTransact function in libs/gui/IGraphicBufferConsumer.cpp in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.x before 2016-03-01 does not initialize a certain output data structure, which allows attackers to obtain sensitive information, and consequently bypass an unspecified protection mechanism, by triggering a QUEUE_BUFFER action, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 26338109.

Project: Android

size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
 return sizeof(timestamp)
 + sizeof(isAutoTimestamp)
 + sizeof(crop)
 + sizeof(scalingMode)
 + sizeof(transform)
 + sizeof(async)
 + fence->getFlattenedSize();
}
Commit message: None
CVE: CVE-2016-0828
CWE: CWE-254
Vulnerability description: The BnGraphicBufferConsumer::onTransact function in libs/gui/IGraphicBufferConsumer.cpp in mediaserver in Android 5.x before 5.1.1 LMY49H and 6.x before 2016-03-01 does not initialize a certain slot variable, which allows attackers to obtain sensitive information, and consequently bypass an unspecified protection mechanism, by triggering an ATTACH_BUFFER action, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 26338113.

Project: Android

IGraphicBufferConsumer::BufferItem::BufferItem() :
    mTransform(0),
    mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
    mTimestamp(0),
    mIsAutoTimestamp(false),
    mFrameNumber(0),
    mBuf(INVALID_BUFFER_SLOT),
    mIsDroppable(false),
    mAcquireCalled(false),
    mTransformToDisplayInverse(false) {
    mCrop.makeInvalid();
}
Commit message: None
CVE: CVE-2016-0811
CWE: CWE-200
Vulnerability description: Integer overflow in the BnCrypto::onTransact function in media/libmedia/ICrypto.cpp in libmediaplayerservice in Android 6.x before 2016-02-01 allows attackers to obtain sensitive information, and consequently bypass an unspecified protection mechanism, by triggering an improper size calculation, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 25800375.

Project: Android

 BpCrypto(const sp<IBinder> &impl)
 : BpInterface<ICrypto>(impl) {
 }
Commit message: None
CVE: CVE-2016-0809
CWE: CWE-264
Vulnerability description: Use-after-free vulnerability in the wifi_cleanup function in bcmdhd/wifi_hal/wifi_hal.cpp in Wi-Fi in Android 6.x before 2016-02-01 allows attackers to gain privileges by leveraging access to the local physical environment during execution of a crafted application, aka internal bug 25753768.

Project: Android

 virtual int create() {
 int ret;

 if(feature_type == FEATURE_SET) {
            ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_GET_FEATURE_SET);
 } else if (feature_type == FEATURE_SET_MATRIX) {
            ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_GET_FEATURE_SET_MATRIX);
 } else {
            ALOGE("Unknown feature type %d", feature_type);
 return -1;
 }

 if (ret < 0) {
            ALOGE("Can't create message to send to driver - %d", ret);
 }

 return ret;
 }

Project: Android

 virtual int handleResponse(WifiEvent& reply) {

        ALOGV("In GetFeatureSetCommand::handleResponse");

 if (reply.get_cmd() != NL80211_CMD_VENDOR) {
            ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
 return NL_SKIP;
 }

 int id = reply.get_vendor_id();
 int subcmd = reply.get_vendor_subcmd();

        nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
 int len = reply.get_vendor_data_len();

        ALOGV("Id = %0x, subcmd = %d, len = %d", id, subcmd, len);
 if (vendor_data == NULL || len == 0) {
            ALOGE("no vendor data in GetFeatureSetCommand response; ignoring it");
 return NL_SKIP;
 }
 if(feature_type == FEATURE_SET) {
 void *data = reply.get_vendor_data();
 if(!fset) {
                ALOGE("Buffers pointers not set");
 return NL_SKIP;
 }
            memcpy(fset, data, min(len, (int) sizeof(*fset)));
 } else {
 int num_features_set = 0;
 int i = 0;

 if(!feature_matrix || !fm_size) {
                ALOGE("Buffers pointers not set");
 return NL_SKIP;
 }

 for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
 if (it.get_type() == ANDR_WIFI_ATTRIBUTE_NUM_FEATURE_SET) {
                    num_features_set = it.get_u32();
                    ALOGV("Got feature list with %d concurrent sets", num_features_set);
 if(set_size_max && (num_features_set > set_size_max))
                        num_features_set = set_size_max;
 *fm_size = num_features_set;
 } else if ((it.get_type() == ANDR_WIFI_ATTRIBUTE_FEATURE_SET) &&
                             i < num_features_set) {
                    feature_matrix[i] = it.get_u32();
                    i++;
 } else {
                    ALOGW("Ignoring invalid attribute type = %d, size = %d",
                            it.get_type(), it.get_len());
 }
 }

 }
 return NL_OK;
 }
Commit message: None
CVE: CVE-2015-6640
CWE: CWE-264
Vulnerability description: The prctl_set_vma_anon_name function in kernel/sys.c in Android before 5.1.1 LMY49F and 6.0 before 2016-01-01 does not ensure that only one vma is accessed in a certain update action, which allows attackers to gain privileges or cause a denial of service (vma list corruption) via a crafted application, aka internal bug 20017123.

Project: Android
File: sys.c

SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
 struct rlimit __user *, rlim)
{
 struct rlimit x;
 if (resource >= RLIM_NLIMITS)
 return -EINVAL;

	task_lock(current->group_leader);
	x = current->signal->rlim[resource];
	task_unlock(current->group_leader);
 if (x.rlim_cur > 0x7FFFFFFF)
		x.rlim_cur = 0x7FFFFFFF;
 if (x.rlim_max > 0x7FFFFFFF)
		x.rlim_max = 0x7FFFFFFF;
 return copy_to_user(rlim, &x, sizeof(x))?-EFAULT:0;
}

Project: Android

SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
{
 const struct cred *old;
 struct cred *new;
 int retval;

 new = prepare_creds();
 if (!new)
 return -ENOMEM;

	old = current_cred();

	retval = -EPERM;
 if (!nsown_capable(CAP_SETUID)) {
 if (ruid != (uid_t) -1 && ruid != old->uid &&
		    ruid != old->euid  && ruid != old->suid)
 goto error;
 if (euid != (uid_t) -1 && euid != old->uid &&
		    euid != old->euid  && euid != old->suid)
 goto error;
 if (suid != (uid_t) -1 && suid != old->uid &&
		    suid != old->euid  && suid != old->suid)
 goto error;
 }

 if (ruid != (uid_t) -1) {
 new->uid = ruid;
 if (ruid != old->uid) {
			retval = set_user(new);
 if (retval < 0)
 goto error;
 }
 }
 if (euid != (uid_t) -1)
 new->euid = euid;
 if (suid != (uid_t) -1)
 new->suid = suid;
 new->fsuid = new->euid;

	retval = security_task_fix_setuid(new, old, LSM_SETID_RES);
 if (retval < 0)
 goto error;

 return commit_creds(new);

error:
	abort_creds(new);
 return retval;
}

Project: Android

SYSCALL_DEFINE3(getresuid, uid_t __user *, ruid, uid_t __user *, euid, uid_t __user *, suid)
{
 const struct cred *cred = current_cred();
 int retval;

 if (!(retval   = put_user(cred->uid,  ruid)) &&
 !(retval   = put_user(cred->euid, euid)))
		retval = put_user(cred->suid, suid);

 return retval;
}

Project: Android
File: sys.c

void do_sys_times(struct tms *tms)
{
 cputime_t tgutime, tgstime, cutime, cstime;

	spin_lock_irq(&current->sighand->siglock);
	thread_group_times(current, &tgutime, &tgstime);
	cutime = current->signal->cutime;
	cstime = current->signal->cstime;
	spin_unlock_irq(&current->sighand->siglock);
	tms->tms_utime = cputime_to_clock_t(tgutime);
	tms->tms_stime = cputime_to_clock_t(tgstime);
	tms->tms_cutime = cputime_to_clock_t(cutime);
	tms->tms_cstime = cputime_to_clock_t(cstime);
}

Project: Android

void kernel_power_off(void)
{
	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
 if (pm_power_off_prepare)
		pm_power_off_prepare();
	migrate_to_reboot_cpu();
	syscore_shutdown();
	printk(KERN_EMERG "Power down.\n");
	kmsg_dump(KMSG_DUMP_POWEROFF);
	machine_power_off();
}