From patchwork Sun Apr 13 07:26:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter TB Brett X-Patchwork-Id: 338732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8AA140080 for ; Sun, 13 Apr 2014 17:27:08 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=VbII/jPDc4rrtss9VdR1tDlu1Yfe22lxSHJ7fTotkJU+GCeZYz7pL bWaiF07wS5cNRXkYJJynJKIJ7YtQTnkEc6w3jvFVciFdqxFJe3o7r/uqoA2igGK2 YPL6ZnxX9AamyHGxC6cfazrIMMVpYOf1tHr4H07f0Ifaq7mLVs8oDk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=z9bUQbpV2LvdJTBz3I/30vCqGFE=; b=Yc1eDdusn6mPoDUbGYqd8LvLg46G 0DJSTCMSh2uOI374VEQZQQY7D/z0U1U9dS/oUiNCLgtkxCFbF6lrtXB2nrBXTKF2 H/1gjDBKQR8Fgd3W2Ja/AgR7U4cMU3pdZU3xPl4GMq5TrJkW8YKH0WFZ3Bw9/vKt hB476IpzUhdW04s= Received: (qmail 17629 invoked by alias); 13 Apr 2014 07:27:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17612 invoked by uid 89); 13 Apr 2014 07:26:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL, BAYES_00, KAM_COUK, NO_DNS_FOR_FROM, RCVD_IN_PBL, RCVD_IN_SEMBLACK, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC autolearn=no version=3.3.2 X-HELO: harrington.peter-b.co.uk From: Peter TB Brett To: libc-alpha@sourceware.org Cc: Peter TB Brett Subject: [PATCH] Use statfs64() in shm_open() and posix_getpt(). Date: Sun, 13 Apr 2014 08:26:18 +0100 Message-Id: <1397373978-17449-1-git-send-email-peter@peter-b.co.uk> Philip Guenther noted in [BZ 15514] that statfs() may EOVERFLOW when running 32-bit programs on 64-bit systems, and that shm_open() and posix_getpt() may be affected. This patch modifies shm_open() and posix_getpt() to use statfs64() instead of __statfs(). Reported-by: Philip Guenther --- ChangeLog | 9 +++++++++ sysdeps/unix/sysv/linux/getpt.c | 6 +++--- sysdeps/unix/sysv/linux/shm_open.c | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a42e08e..4e52aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-04-13 Peter Brett + + [BZ 15514] + * sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs): Check for + shmfs using statfs64(). + * sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Check for + /dev/pts and devfs using statfs64(). + Reported by Philip Guenther + 2014-04-12 Allan McRae [BZ #16838] diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c index cea2fa6..c8f9275 100644 --- a/sysdeps/unix/sysv/linux/getpt.c +++ b/sysdeps/unix/sysv/linux/getpt.c @@ -46,15 +46,15 @@ __posix_openpt (oflag) fd = __open (_PATH_DEVPTMX, oflag); if (fd != -1) { - struct statfs fsbuf; + struct statfs64 fsbuf; static int devpts_mounted; /* Check that the /dev/pts filesystem is mounted or if /dev is a devfs filesystem (this implies /dev/pts). */ if (devpts_mounted - || (__statfs (_PATH_DEVPTS, &fsbuf) == 0 + || (statfs64 (_PATH_DEVPTS, &fsbuf) == 0 && fsbuf.f_type == DEVPTS_SUPER_MAGIC) - || (__statfs (_PATH_DEV, &fsbuf) == 0 + || (statfs64 (_PATH_DEV, &fsbuf) == 0 && fsbuf.f_type == DEVFS_SUPER_MAGIC)) { /* Everything is ok. */ diff --git a/sysdeps/unix/sysv/linux/shm_open.c b/sysdeps/unix/sysv/linux/shm_open.c index cec6fdb..a41b6b5 100644 --- a/sysdeps/unix/sysv/linux/shm_open.c +++ b/sysdeps/unix/sysv/linux/shm_open.c @@ -55,14 +55,14 @@ static void where_is_shmfs (void) { char buf[512]; - struct statfs f; + struct statfs64 f; struct mntent resmem; struct mntent *mp; FILE *fp; /* The canonical place is /dev/shm. This is at least what the documentation tells everybody to do. */ - if (__statfs (defaultdir, &f) == 0 && (f.f_type == SHMFS_SUPER_MAGIC + if (statfs64 (defaultdir, &f) == 0 && (f.f_type == SHMFS_SUPER_MAGIC || f.f_type == RAMFS_MAGIC)) { /* It is in the normal place. */ @@ -97,7 +97,7 @@ where_is_shmfs (void) /* First make sure this really is the correct entry. At least some versions of the kernel give wrong information because of the implicit mount of the shmfs for SysV IPC. */ - if (__statfs (mp->mnt_dir, &f) != 0 || (f.f_type != SHMFS_SUPER_MAGIC + if (statfs64 (mp->mnt_dir, &f) != 0 || (f.f_type != SHMFS_SUPER_MAGIC && f.f_type != RAMFS_MAGIC)) continue;