From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933325AbcHJWMq (ORCPT ); Wed, 10 Aug 2016 18:12:46 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35167 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752651AbcHJWMo (ORCPT ); Wed, 10 Aug 2016 18:12:44 -0400 From: Salah Triki To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, luisbg@osg.samsung.com Cc: linux-kernel@vger.kernel.org, salah.triki@gmail.com Subject: [PATCH 1/4] befs: check allocation_group number before use Date: Wed, 10 Aug 2016 23:12:30 +0100 Message-Id: <8f7f9b76ead677bdc834867e549ea6c4d1c04ccd.1470867071.git.salah.triki@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check that the allocation group number is not greater or equal to the number of allocations group in the file system and return BEF_ERR in the case of error. Signed-off-by: Salah Triki --- fs/befs/befs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/befs/befs.h b/fs/befs/befs.h index 55f3ea2..6daf4c4 100644 --- a/fs/befs/befs.h +++ b/fs/befs/befs.h @@ -121,6 +121,11 @@ BEFS_I(const struct inode *inode) static inline befs_blocknr_t iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr) { + if (iaddr->allocation_group >= BEFS_SB(sb)->num_ags) { + befs_error(sb, "BEFS: Invalid allocation group %u, max is %u", + iaddr->allocation_group, BEFS_SB(sb)->num_ags); + return BEFS_ERR; + } return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) + iaddr->start); } -- 1.9.1