linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, steved@redhat.com
Subject: [PATCH v2] closing fd associated with /proc/fs/nfsd/export_features
Date: Tue, 12 Jul 2011 21:38:17 +0900 (JST)	[thread overview]
Message-ID: <20110712.213817.1045173784079879730.yamato@redhat.com> (raw)
In-Reply-To: <20110712104652.GA2162@fieldses.org>

Sorry, my patch has a serious bug.
The value returned from read() is stored to fd.
So fd should not be passed to close().

I rearranged the code as below.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>

diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index c250383..744c01b 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -784,9 +784,10 @@ struct export_features *get_export_features(void)
 	fd = open(path, O_RDONLY);
 	if (fd == -1)
 		goto good;
-	fd = read(fd, buf, 50);
-	if (fd == -1)
+	c = read(fd, buf, 50);
+	if (c == -1)
 		goto err;
+	close(fd);
 	c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
 	if (c != 2)
 		goto err;


> On Tue, Jul 12, 2011 at 11:47:00AM +0900, Masatake YAMATO wrote:
>> A fd associated with /proc/fs/nfsd/export_features opened in get_export_features is 
>> not closed.
>> 
>> 
>> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> Acked-by: J. Bruce Fields <bfields@redhat.com>
>> 
>> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
>> index c250383..819a18a 100644
>> --- a/support/nfs/exports.c
>> +++ b/support/nfs/exports.c
>> @@ -787,6 +787,7 @@ struct export_features *get_export_features(void)
>>  	fd = read(fd, buf, 50);
>>  	if (fd == -1)
>>  		goto err;
>> +	close(fd);
>>  	c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
>>  	if (c != 2)
>>  		goto err;
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-07-12 12:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12  2:47 [PATCH] closing fd associated with /proc/fs/nfsd/export_features Masatake YAMATO
2011-07-12 10:46 ` J. Bruce Fields
2011-07-12 12:38   ` Masatake YAMATO [this message]
2011-07-12 13:01     ` [PATCH v3] " Masatake YAMATO
2011-07-12 14:03       ` Steve Dickson
2011-07-12 14:20       ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110712.213817.1045173784079879730.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).