From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbcCKKc5 (ORCPT ); Fri, 11 Mar 2016 05:32:57 -0500 Received: from mx2.suse.de ([195.135.220.15]:35917 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751238AbcCKKcr (ORCPT ); Fri, 11 Mar 2016 05:32:47 -0500 Subject: Re: [PATCH 04/18] mm, aout: handle vm_brk failures To: Michal Hocko , LKML References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-5-git-send-email-mhocko@kernel.org> Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=c3=b6nig?= , Daniel Vetter , Dave Hansen , David Airlie , Davidlohr Bueso , David Rientjes , "H . Peter Anvin" , Hugh Dickins , Ingo Molnar , Johannes Weiner , "Kirill A . Shutemov" , Konstantin Khlebnikov , linux-arch@vger.kernel.org, Mel Gorman , Oleg Nesterov , Peter Zijlstra , Petr Cermak , Thomas Gleixner , Michal Hocko , Ingo Molnar , Alexander Viro From: Vlastimil Babka Message-ID: <56E29ECA.5050809@suse.cz> Date: Fri, 11 Mar 2016 11:32:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1456752417-9626-5-git-send-email-mhocko@kernel.org> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > vm_brk is allowed to fail but load_aout_binary simply ignores the error > and happily continues. I haven't noticed any problem from that in real > life but later patches will make the failure more likely because > vm_brk will become killable (resp. mmap_sem for write waiting will become > killable) so we should be more careful now. > > The error handling should be quite straightforward because there are > calls to vm_mmap which check the error properly already. The only > notable exception is set_brk which is called after beyond_if label. > But nothing indicates that we cannot move it above set_binfmt as the two > do not depend on each other and fail before we do set_binfmt and alter > reference counting. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Alexander Viro > Signed-off-by: Michal Hocko Acked--by: Vlastimil Babka [...] > @@ -378,7 +381,9 @@ static int load_aout_library(struct file *file) > "N_TXTOFF is not page aligned. Please convert library: %pD\n", > file); > } > - vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + retval = vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + if (IS_ERR_VALUE(retval)) > + goto out; > You could have removed the extra whitespace on the line above, which my vim so prominently highlights :) > read_code(file, start_addr, N_TXTOFF(ex), > ex.a_text + ex.a_data); > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlastimil Babka Subject: Re: [PATCH 04/18] mm, aout: handle vm_brk failures Date: Fri, 11 Mar 2016 11:32:42 +0100 Message-ID: <56E29ECA.5050809@suse.cz> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-5-git-send-email-mhocko@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de ([195.135.220.15]:35917 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751238AbcCKKcr (ORCPT ); Fri, 11 Mar 2016 05:32:47 -0500 In-Reply-To: <1456752417-9626-5-git-send-email-mhocko@kernel.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Michal Hocko , LKML Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=c3=b6nig?= , Daniel Vetter , Dave Hansen , David Airlie , Davidlohr Bueso , David Rientjes , "H . Peter Anvin" , Hugh Dickins , Ingo Molnar , Johannes Weiner , "Kirill A . Shutemov" , Konstantin Khlebnikov , linux-arch@vger.kernel.org, Mel Gorman , Oleg Nesterov , Peter Zijlstra Pe On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > vm_brk is allowed to fail but load_aout_binary simply ignores the error > and happily continues. I haven't noticed any problem from that in real > life but later patches will make the failure more likely because > vm_brk will become killable (resp. mmap_sem for write waiting will become > killable) so we should be more careful now. > > The error handling should be quite straightforward because there are > calls to vm_mmap which check the error properly already. The only > notable exception is set_brk which is called after beyond_if label. > But nothing indicates that we cannot move it above set_binfmt as the two > do not depend on each other and fail before we do set_binfmt and alter > reference counting. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Alexander Viro > Signed-off-by: Michal Hocko Acked--by: Vlastimil Babka [...] > @@ -378,7 +381,9 @@ static int load_aout_library(struct file *file) > "N_TXTOFF is not page aligned. Please convert library: %pD\n", > file); > } > - vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + retval = vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + if (IS_ERR_VALUE(retval)) > + goto out; > You could have removed the extra whitespace on the line above, which my vim so prominently highlights :) > read_code(file, start_addr, N_TXTOFF(ex), > ex.a_text + ex.a_data); > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by kanga.kvack.org (Postfix) with ESMTP id 6CB096B0005 for ; Fri, 11 Mar 2016 05:32:47 -0500 (EST) Received: by mail-wm0-f46.google.com with SMTP id p65so12148545wmp.1 for ; Fri, 11 Mar 2016 02:32:47 -0800 (PST) Subject: Re: [PATCH 04/18] mm, aout: handle vm_brk failures References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-5-git-send-email-mhocko@kernel.org> From: Vlastimil Babka Message-ID: <56E29ECA.5050809@suse.cz> Date: Fri, 11 Mar 2016 11:32:42 +0100 MIME-Version: 1.0 In-Reply-To: <1456752417-9626-5-git-send-email-mhocko@kernel.org> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , LKML Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=c3=b6nig?= , Daniel Vetter , Dave Hansen , David Airlie , Davidlohr Bueso , David Rientjes , "H . Peter Anvin" , Hugh Dickins , Ingo Molnar , Johannes Weiner , "Kirill A . Shutemov" , Konstantin Khlebnikov , linux-arch@vger.kernel.org, Mel Gorman , Oleg Nesterov , Peter Zijlstra , Petr Cermak , Thomas Gleixner , Michal Hocko , Ingo Molnar , Alexander Viro On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > vm_brk is allowed to fail but load_aout_binary simply ignores the error > and happily continues. I haven't noticed any problem from that in real > life but later patches will make the failure more likely because > vm_brk will become killable (resp. mmap_sem for write waiting will become > killable) so we should be more careful now. > > The error handling should be quite straightforward because there are > calls to vm_mmap which check the error properly already. The only > notable exception is set_brk which is called after beyond_if label. > But nothing indicates that we cannot move it above set_binfmt as the two > do not depend on each other and fail before we do set_binfmt and alter > reference counting. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Alexander Viro > Signed-off-by: Michal Hocko Acked--by: Vlastimil Babka [...] > @@ -378,7 +381,9 @@ static int load_aout_library(struct file *file) > "N_TXTOFF is not page aligned. Please convert library: %pD\n", > file); > } > - vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + retval = vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); > + if (IS_ERR_VALUE(retval)) > + goto out; > You could have removed the extra whitespace on the line above, which my vim so prominently highlights :) > read_code(file, start_addr, N_TXTOFF(ex), > ex.a_text + ex.a_data); > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org