lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 13 Dec 2022 20:08:22 +0100
From:   "Fabio M. De Francesco" <fmdefrancesco@...il.com>
To:     Al Viro <viro@...iv.linux.org.uk>,
        Al Viro <viro@...iv.linux.org.uk>
Cc:     Evgeniy Dushistov <dushistov@...l.ru>,
        Ira Weiny <ira.weiny@...el.com>, linux-kernel@...r.kernel.org,
        Jeff Moyer <jmoyer@...hat.com>,
        Evgeniy Dushistov <dushistov@...l.ru>,
        Ira Weiny <ira.weiny@...el.com>, linux-kernel@...r.kernel.org,
        Jeff Moyer <jmoyer@...hat.com>
Subject: Re: [PATCH v2 2/3] fs/ufs: Change the signature of ufs_get_page()

On martedì 13 dicembre 2022 08:10:58 CET Al Viro wrote:
> On Tue, Dec 13, 2022 at 12:19:05AM +0100, Fabio M. De Francesco wrote:
> > +static void *ufs_get_page(struct inode *dir, unsigned long n, struct page
> > **page)> 
> >  {
> >  
> >  	struct address_space *mapping = dir->i_mapping;
> > 
> > -	struct page *page = read_mapping_page(mapping, n, NULL);
> > -	if (!IS_ERR(page)) {
> > -		kmap(page);
> > -		if (unlikely(!PageChecked(page))) {
> > -			if (!ufs_check_page(page))
> > +	*page = read_mapping_page(mapping, n, NULL);
> > +	if (!IS_ERR(*page)) {
> > +		kmap(*page);
> > +		if (unlikely(!PageChecked(*page))) {
> > +			if (!ufs_check_page(*page))
> > 
> >  				goto fail;
> >  		
> >  		}
> >  	
> >  	}
> > 
> > -	return page;
> > +	return page_address(*page);
> 
> Er...   You really don't want to do that when you've got ERR_PTR()
> from read_mapping_page().
> 

Sure :-)

Obviously, I'll fix it ASAP.

But I can't yet understand why that pointer was returned unconditionally in 
the code which I'm changing with this patch (i.e., regardless of any potential  
errors from read_mapping_page()) :-/ 

>
> >  fail:
> > -	ufs_put_page(page);
> > +	ufs_put_page(*page);
> > 
> >  	return ERR_PTR(-EIO);
> >  
> >  }
> 
> IDGI...
> 
> static void *ufs_get_page(struct inode *dir, unsigned long n, struct page 
**p)
> {
> 	struct address_space *mapping = dir->i_mapping;
> 	struct page *page = read_mapping_page(mapping, n, NULL);
> 
> 	if (!IS_ERR(page)) {
> 		kmap(page);
> 		if (unlikely(!PageChecked(page))) {
> 			if (!ufs_check_page(page))
> 				goto fail;
> 		}
> 		*p = page;
> 		return page_address(page);
> 	}
> 	return ERR_CAST(page);
> 
> fail:
> 	ufs_put_page(page);
> 	return ERR_PTR(-EIO);
> }
> 
> all there is to it...  The only things you need to change are
> 1) type of function
> 2) make sure to store the page into that pointer to pointer to page on 
success
> 3) return page_address(page) instead of page on success
> 4) use ERR_CAST() to convert ERR_PTR() that is struct page * into equal
> ERR_PTR() that is void * (the last one is optional, just makes the intent
> more clear).

I've never seen anything like this: you are spoon feeding me :-)

Please don't misunderstand: I'm OK with it and, above all, I'm surely  
appreciating how much patience and time you are devolving to help me.

I'll send v3 ASAP (for sure within the next 24 hours).

Furthermore, if there are no other issues, I'd start ASAP with the 
decomposition of the patch to fs/sysv into a series of three units and rework 
the whole design in accordance to the suggestions you have been kindly 
providing.

I'm sorry for responding and reacting so slowly. Aside from being slow because 
of a fundamental lack of knowledge and experience, I can do Kernel development 
(including studying new subjects and code, doing patches, doing reviews, and 
the likes) about 7 hours a week. This is all the time I can set aside until I 
quit one of my jobs at the end of January.

Again thanks,

Fabio

P.S.: While at this patch I'd like to gently ping you about another conversion 
that I sent (and resent) months ago:

[RESEND PATCH] fs/aio: Replace kmap{,_atomic}() with kmap_local_page() at:
https://lore.kernel.org/lkml/20221016150656.5803-1-fmdefrancesco@gmail.com/

This patch to fs/aio.c has already received two "Reviewed-by" tags: the first 
from Ira Weiny and the second from Jeff Moyer (you won't see the second there, 
because I forgot to forward it when I sent again :-( ).

The tag from Jeff is in the following message (from another [RESEND PATCH] 
thread):
https://lore.kernel.org/lkml/x49h6zzvn1a.fsf@segfault.boston.devel.redhat.com/

In that same thread, I explained better I meant in the last sentence of the 
commit message, because Jeff commented that it is ambiguous (I'm adding him in 
the Cc list of recipients).

The original patch, submitted on Thu, 7 Jul 2022 01:33:28 +0200 is at:
https://lore.kernel.org/lkml/20220706233328.18582-1-fmdefrancesco@gmail.com/

I'd appreciate very much if you can spend some time on that patch too :)



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ