Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754452AbYAHKoz (ORCPT ); Tue, 8 Jan 2008 05:44:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751171AbYAHKoj (ORCPT ); Tue, 8 Jan 2008 05:44:39 -0500 Received: from ms0.nttdata.co.jp ([163.135.193.231]:42773 "EHLO ms0.nttdata.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbYAHKoh (ORCPT ); Tue, 8 Jan 2008 05:44:37 -0500 Message-Id: <20080108095002.094118080@nttdata.co.jp> References: <20080108094903.484613061@nttdata.co.jp> User-Agent: quilt/0.46-1 Date: Tue, 08 Jan 2008 18:49:15 +0900 From: Kentaro Takeda To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Kentaro Takeda , Tetsuo Handa Subject: [TOMOYO #6 12/21] argv0 check functions. X-OriginalArrivalTime: 08 Jan 2008 09:50:02.0459 (UTC) FILETIME=[D6DD8AB0:01C851DB] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="boundary-1" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8630 Lines: 119 --boundary-1 Content-Disposition: inline; filename="tomoyo-exec.patch" Content-Type: application/octect-stream Content-Transfer-Encoding: base64 SWYgdGhlIGV4ZWN1dGVkIHByb2dyYW0gbmFtZSBhbmQgYXJndlswXSBpcyBkaWZmZXJlbnQsDQpU T01PWU8gTGludXggY2hlY2tzIHBlcm1pc3Npb24uDQoNCkVhY2ggcGVybWlzc2lvbiBjYW4gYmUg YXV0b21hdGljYWxseSBhY2N1bXVsYXRlZCBpbnRvDQp0aGUgcG9saWN5IG9mIGVhY2ggZG9tYWlu IHVzaW5nICdsZWFybmluZyBtb2RlJy4NCg0KU2lnbmVkLW9mZi1ieTogS2VudGFybyBUYWtlZGEg PHRha2VkYWtuQG50dGRhdGEuY28uanA+DQpTaWduZWQtb2ZmLWJ5OiBUZXRzdW8gSGFuZGEgPHBl bmd1aW4ta2VybmVsQEktbG92ZS5TQUtVUkEubmUuanA+DQotLS0NCiBzZWN1cml0eS90b21veW8v ZXhlYy5jIHwgIDIxNSArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrDQogMSBmaWxlIGNoYW5nZWQsIDIxNSBpbnNlcnRpb25zKCspDQoNCi0tLSAvZGV2L251 bGwNCisrKyBsaW51eC0yLjYtbW0vc2VjdXJpdHkvdG9tb3lvL2V4ZWMuYw0KQEAgLTAsMCArMSwy MTUgQEANCisvKg0KKyAqIHNlY3VyaXR5L3RvbW95by9leGVjLmMNCisgKg0KKyAqIEFyZ3YwIGFj Y2VzcyBjb250cm9sIGZ1bmN0aW9ucyBmb3IgVE9NT1lPIExpbnV4Lg0KKyAqLw0KKw0KKyNpbmNs dWRlICJ0b21veW8uaCINCisjaW5jbHVkZSAicmVhbHBhdGguaCINCisNCisvKioqKioqKioqKioq KioqKioqKioqKioqKiAgQVVESVQgRlVOQ1RJT05TICAqKioqKioqKioqKioqKioqKioqKioqKioq Lw0KKw0KK3N0YXRpYyBpbnQgdG15X2F1ZGl0X2FyZ3YwX2xvZyhjb25zdCBzdHJ1Y3QgcGF0aF9p bmZvICpmaWxlbmFtZSwNCisJCQkgICAgICAgY29uc3QgY2hhciAqYXJndjAsDQorCQkJICAgICAg IGNvbnN0IGJvb2wgaXNfZ3JhbnRlZCwNCisJCQkgICAgICAgY29uc3QgdTggcHJvZmlsZSwNCisJ CQkgICAgICAgY29uc3QgdW5zaWduZWQgaW50IG1vZGUpDQorew0KKwljaGFyICpidWY7DQorCWlu dCBsZW47DQorDQorCWlmIChpc19ncmFudGVkKSB7DQorCQlpZiAoIXRteV9hdWRpdF9ncmFudCgp KQ0KKwkJCXJldHVybiAwOw0KKwl9IGVsc2Ugew0KKwkJaWYgKCF0bXlfYXVkaXRfcmVqZWN0KCkp DQorCQkJcmV0d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ICAgICAgZG9tYWluLT5kb21haW5uYW1lLT5u YW1lLA0KKwkJCQkJICAgICAgIGZpbGVuYW1lLT5uYW1lLCBhcmd2MCk7DQorDQorCQllbHNlIGlm IChtb2RlID09IDEgJiYgdG15X3F1b3RhKCkpDQorCQkJdG15X2FkZF9hcmd2MF9lbnRyeShmaWxl bmFtZS0+bmFtZSwgYXJndjAsIGRvbWFpbiwNCisJCQkJCSAgICBOVUxMLCAwKTsNCisNCisJCWlm ICghaXNfZW5mb3JjZSkNCisJCQllcnJvciA9IDA7DQorCX0NCisNCisJcmV0dXJuIGVycm9yOw0K K30NCisNCisvKioNCisgKiB0bXlfYWRkX2FyZ3YwX3BvbGljeSAtIGFkZCBvciBkZWxldGUgYXJn dlswXSBwb2xpY3kuDQorICogQGRhdGE6ICAgICAgYSBsaW5lIHRvIHBhcnNlLg0KKyAqIEBkb21h aW46ICAgIHBvaW50ZXIgdG8gInN0cnVjdCBkb21haW5faW5mbyIuDQorICogQGNvbmQ6ICAgICAg cG9pbnRlciB0byAic3RydWN0IGNvbmRpdGlvbl9saXN0Ii4gTWF5IGJlIE5VTEwuDQorICogQGlz X2RlbGV0ZTogaXMgdGhpcyBkZWxldGUgcmVxdWVzdD8NCisgKg0KKyAqIFJldHVybnMgemVybyBv biBzdWNjZXNzLg0KKyAqIFJldHVybnMgbm9uemVybyBvbiBmYWlsdXJlLg0KKyAqLw0KK2ludCB0 bXlfYWRkX2FyZ3YwX3BvbGljeShjaGFyICpkYXRhLA0KKwkJCSBzdHJ1Y3QgZG9tYWluX2luZm8g KmRvbWFpbiwNCisJCQkgY29uc3Qgc3RydWN0IGNvbmRpdGlvbl9saXN0ICpjb25kLA0KKwkJCSBj b25zdCBib29sIGlzX2RlbGV0ZSkNCit7DQorCWNoYXIgKmFyZ3YwID0gc3RyY2hyKGRhdGEsICcg Jyk7DQorDQorCWlmICghYXJndjApDQorCQlyZXR1cm4gLUVJTlZBTDsNCisNCisJKmFyZ3YwKysg PSAnXDAnOw0KKw0KKwlyZXR1cm4gdG15X2FkZF9hcmd2MF9lbnRyeShkYXRhLCBhcmd2MCwgZG9t YWluLCBjb25kLA0KKwkJCQkgICBpc19kZWxldGUpOw0KK30NCg0KLS0gDQo= --boundary-1-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/