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: 525 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 1F265360072 for ; Sun, 13 Apr 2014 00:27:05 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14307373) id C2AD9496594C; Sun, 13 Apr 2014 00:27:04 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx22.g.dreamhost.com 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 homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 9A242496133E for ; Sun, 13 Apr 2014 00:27:04 -0700 (PDT) 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=uhteuBGNYF97Imxp1nuERRjr7U/VoZATeGdqz9vZQqpPOUGXeCceX UGm/P3IaBhPS/vx9Uj4JBhDhipXoYTGwmZ6Ld2JlUkS+BDN2zBriz1IdFltLWzPN mcYnNQMA6kAc8iY68bUfWcdW3RwonSHL6JzYVuUvuYiWMxe5AmC0Yk= 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=Af6c7wvWpEVSo/GeHpubaKge7FPh IF5zgslKFS41yXGyIfYNS3r0HYH2leXyvdwT/kbM9su6n4r/Sej3xwSoqSM3587U ZmA03LJDzzw6QIQYqItz7KB/DzJRaSf8KrW6ifL1b0JOWlX0D4v6SrJzenbD/k/9 QK8ESkuP3d17x3M= 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> X-DH-Original-To: glibc@patchwork.siddhesh.in 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;