From patchwork Tue Feb 23 20:23:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Cashman X-Patchwork-Id: 8395861 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F20C29F372 for ; Tue, 23 Feb 2016 20:36:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 596F8202E9 for ; Tue, 23 Feb 2016 20:36:33 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [63.239.67.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89BE9202DD for ; Tue, 23 Feb 2016 20:36:32 +0000 (UTC) X-TM-IMSS-Message-ID: <0f1ca5140000893b@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id 0f1ca5140000893b ; Tue, 23 Feb 2016 15:37:58 -0500 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u1NKYFxd022768; Tue, 23 Feb 2016 15:34:18 -0500 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u1NKOVsG035120 for ; Tue, 23 Feb 2016 15:24:31 -0500 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u1NKOUw1020565 for ; Tue, 23 Feb 2016 15:24:31 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DqAQCmv8xWeTLcVdFeGQEBAg8BAQEBhEm4WIQHhg0CghkBAQEBAQESAQEJCwwIIYRxAQEBAxIuAQE3AQ8gMTQBBQEcGSKHfKBvgTE+MYpNhScBBIonAQEBAQYCARcGCoQGgXgKiTuDbo4jiGmWcYVeRIxHL4EPglgNGYFpGy6INQEBAQ X-IPAS-Result: A1DqAQCmv8xWeTLcVdFeGQEBAg8BAQEBhEm4WIQHhg0CghkBAQEBAQESAQEJCwwIIYRxAQEBAxIuAQE3AQ8gMTQBBQEcGSKHfKBvgTE+MYpNhScBBIonAQEBAQYCARcGCoQGgXgKiTuDbo4jiGmWcYVeRIxHL4EPglgNGYFpGy6INQEBAQ X-IronPort-AV: E=Sophos;i="5.22,491,1449550800"; d="scan'208";a="5226855" Received: from emvm-gh1-uea08.nsa.gov ([10.208.42.193]) by goalie.tycho.ncsc.mil with ESMTP; 23 Feb 2016 15:24:30 -0500 X-TM-IMSS-Message-ID: <32e5d331000906ed@nsa.gov> Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1; TLSv1/SSLv3 AES128-SHA (128/128)) id 32e5d331000906ed ; Tue, 23 Feb 2016 15:23:58 -0500 Received: by mail-pa0-f50.google.com with SMTP id fy10so115710539pac.1 for ; Tue, 23 Feb 2016 12:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20120917; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ltp7AbeTYRjAHsxV9W4jBgFxVunPl9CuhR9HR+bChK8=; b=iRFK1XJrw43k7oiObUhlqSuYg7BYvPJ17WqPRJf5LB7LUxbW1ugwGMMwcq32xRXQQ+ tJ8sgR/fOYvRzNczAYMWtgqejMe724fWBQ5aWVCEVoAypIEYJ5X3k/Dg3vcw7GMH7WRS BSYeTm6vpLau4WPcIWKrgKZkNRnIuBylOXyju8f2N5ssIe6kepfC99FSFdjvLBX8MOWt 2uP9E1gLPe69Qugg9mDAOJ7SWy6tUWcRVxAI48HF9b+3No/55Cb/adH6JLWDbPTXblqt MFYS/BVcTi1opkrLjNaLtTkn+ZMCSmWDI44SaJq7FGr55zHXZs3gCIeZh/0IwydteiUc Rp1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ltp7AbeTYRjAHsxV9W4jBgFxVunPl9CuhR9HR+bChK8=; b=Rp0Mn0/YkHTyhO6p8tYRpOJVYVHEK6DtFebaYYrymv2KEJ/gB8gFmscPKgBrw0XqLz CyRAvfhA3rkb4ydDOfUt7q/E1BI4X2nYsKysmj7CmOzql8/lyqyCpZlgtaYNMvpwzYoQ YIalNPNXUZOk8sPhJkftqEyKT9Gx5Hfpwfuf8zSyuAImCtPHsUEtcw22IvGjaUWqPNQZ r3HApvi88KNuAPXvncw8FG6bK6SZIXqVhmo/cb/5KecIy9t6gAagjf+5UQ+toiEkquxz DAeZqrPUOPyAkdh5zz/rxHRqfczA5ibHdGBSekB0X3Tcgk7XlEJLX43r0JXIWaib4oOY SEqA== X-Gm-Message-State: AG10YORbNSQz+jD262L69zq3ga33qK5zdE3+ooPwn7zGYTiR1jKVjdiyJ9EQqYNJNembyw== X-Received: by 10.66.235.9 with SMTP id ui9mr49118757pac.135.1456259067644; Tue, 23 Feb 2016 12:24:27 -0800 (PST) Received: from dcashman.mtv.corp.google.com ([172.22.115.19]) by smtp.gmail.com with ESMTPSA id fc8sm46328943pab.21.2016.02.23.12.24.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Feb 2016 12:24:26 -0800 (PST) From: Daniel Cashman To: selinux@tycho.nsa.gov Subject: [PATCH 1/2] libselinux: procattr: return error on invalid pid_t input. Date: Tue, 23 Feb 2016 12:23:59 -0800 Message-Id: <1456259040-13721-2-git-send-email-dcashman@android.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1456259040-13721-1-git-send-email-dcashman@android.com> References: <1456259040-13721-1-git-send-email-dcashman@android.com> X-TM-AS-MML: disable X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: sds@tycho.nsa.gov MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: dcashman Signed-off-by: Daniel Cashman --- libselinux/src/procattr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c index 527a0a5..c20f003 100644 --- a/libselinux/src/procattr.c +++ b/libselinux/src/procattr.c @@ -70,9 +70,9 @@ static int openattr(pid_t pid, const char *attr, int flags) char *path; pid_t tid; - if (pid > 0) + if (pid > 0) { rc = asprintf(&path, "/proc/%d/attr/%s", pid, attr); - else { + } else if (pid == 0) { rc = asprintf(&path, "/proc/thread-self/attr/%s", attr); if (rc < 0) return -1; @@ -82,6 +82,9 @@ static int openattr(pid_t pid, const char *attr, int flags) free(path); tid = gettid(); rc = asprintf(&path, "/proc/self/task/%d/attr/%s", tid, attr); + } else { + errno = EINVAL; + return -1; } if (rc < 0) return -1;