2022-09-30 03:21:58

by kernel test robot

[permalink] [raw]
Subject: [mic:next 4/9] fs/open.c:191: undefined reference to `security_file_truncate'

tree: git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git next
head: 054fdc359167ae7c17a5fb47c0edbf5cb4b737b0
commit: 0052f28b7cba97cefa48623ef087d1c1cc06078f [4/9] security: create file_truncate hook from path_truncate hook
config: x86_64-rhel-8.3-func
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git/commit/?id=0052f28b7cba97cefa48623ef087d1c1cc06078f
git remote add mic git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git
git fetch --no-tags mic next
git checkout 0052f28b7cba97cefa48623ef087d1c1cc06078f
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

ld: fs/open.o: in function `do_sys_ftruncate':
>> fs/open.c:191: undefined reference to `security_file_truncate'
ld: fs/namei.o: in function `handle_truncate':
>> fs/namei.c:3214: undefined reference to `security_file_truncate'


vim +191 fs/open.c

155
156 long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
157 {
158 struct inode *inode;
159 struct dentry *dentry;
160 struct fd f;
161 int error;
162
163 error = -EINVAL;
164 if (length < 0)
165 goto out;
166 error = -EBADF;
167 f = fdget(fd);
168 if (!f.file)
169 goto out;
170
171 /* explicitly opened as large or we are on 64-bit box */
172 if (f.file->f_flags & O_LARGEFILE)
173 small = 0;
174
175 dentry = f.file->f_path.dentry;
176 inode = dentry->d_inode;
177 error = -EINVAL;
178 if (!S_ISREG(inode->i_mode) || !(f.file->f_mode & FMODE_WRITE))
179 goto out_putf;
180
181 error = -EINVAL;
182 /* Cannot ftruncate over 2^31 bytes without large file support */
183 if (small && length > MAX_NON_LFS)
184 goto out_putf;
185
186 error = -EPERM;
187 /* Check IS_APPEND on real upper inode */
188 if (IS_APPEND(file_inode(f.file)))
189 goto out_putf;
190 sb_start_write(inode->i_sb);
> 191 error = security_file_truncate(f.file);
192 if (!error)
193 error = do_truncate(file_mnt_user_ns(f.file), dentry, length,
194 ATTR_MTIME | ATTR_CTIME, f.file);
195 sb_end_write(inode->i_sb);
196 out_putf:
197 fdput(f);
198 out:
199 return error;
200 }
201

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (2.63 kB)
config (169.95 kB)
Download all attachments

2022-09-30 09:32:17

by Mickaël Salaün

[permalink] [raw]
Subject: Re: [mic:next 4/9] fs/open.c:191: undefined reference to `security_file_truncate'

This build error arises when CONFIG_SECURITY_PATH is disabled. Indeed,
security_file_truncate() is only defined in security/security.c for such
option.

I have pushed the (rebased) fix in my next branch. FYI, you can keep the
current Acked-by.

Original patch:
https://lore.kernel.org/all/[email protected]/


On 30/09/2022 04:57, kernel test robot wrote:
> tree: git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git next
> head: 054fdc359167ae7c17a5fb47c0edbf5cb4b737b0
> commit: 0052f28b7cba97cefa48623ef087d1c1cc06078f [4/9] security: create file_truncate hook from path_truncate hook
> config: x86_64-rhel-8.3-func
> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
> reproduce (this is a W=1 build):
> # https://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git/commit/?id=0052f28b7cba97cefa48623ef087d1c1cc06078f
> git remote add mic git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git
> git fetch --no-tags mic next
> git checkout 0052f28b7cba97cefa48623ef087d1c1cc06078f
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> ld: fs/open.o: in function `do_sys_ftruncate':
>>> fs/open.c:191: undefined reference to `security_file_truncate'
> ld: fs/namei.o: in function `handle_truncate':
>>> fs/namei.c:3214: undefined reference to `security_file_truncate'
>
>
> vim +191 fs/open.c
>
> 155
> 156 long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
> 157 {
> 158 struct inode *inode;
> 159 struct dentry *dentry;
> 160 struct fd f;
> 161 int error;
> 162
> 163 error = -EINVAL;
> 164 if (length < 0)
> 165 goto out;
> 166 error = -EBADF;
> 167 f = fdget(fd);
> 168 if (!f.file)
> 169 goto out;
> 170
> 171 /* explicitly opened as large or we are on 64-bit box */
> 172 if (f.file->f_flags & O_LARGEFILE)
> 173 small = 0;
> 174
> 175 dentry = f.file->f_path.dentry;
> 176 inode = dentry->d_inode;
> 177 error = -EINVAL;
> 178 if (!S_ISREG(inode->i_mode) || !(f.file->f_mode & FMODE_WRITE))
> 179 goto out_putf;
> 180
> 181 error = -EINVAL;
> 182 /* Cannot ftruncate over 2^31 bytes without large file support */
> 183 if (small && length > MAX_NON_LFS)
> 184 goto out_putf;
> 185
> 186 error = -EPERM;
> 187 /* Check IS_APPEND on real upper inode */
> 188 if (IS_APPEND(file_inode(f.file)))
> 189 goto out_putf;
> 190 sb_start_write(inode->i_sb);
> > 191 error = security_file_truncate(f.file);
> 192 if (!error)
> 193 error = do_truncate(file_mnt_user_ns(f.file), dentry, length,
> 194 ATTR_MTIME | ATTR_CTIME, f.file);
> 195 sb_end_write(inode->i_sb);
> 196 out_putf:
> 197 fdput(f);
> 198 out:
> 199 return error;
> 200 }
> 201
>

2022-09-30 14:02:43

by Günther Noack

[permalink] [raw]
Subject: Re: [mic:next 4/9] fs/open.c:191: undefined reference to `security_file_truncate'

On Fri, Sep 30, 2022 at 11:02:00AM +0200, Micka?l Sala?n wrote:
> This build error arises when CONFIG_SECURITY_PATH is disabled. Indeed,
> security_file_truncate() is only defined in security/security.c for such
> option.
>
> I have pushed the (rebased) fix in my next branch. FYI, you can keep the
> current Acked-by.

Thank you, I'll merge that fix into v7 of the truncate patch set. I'll
try to send v7 to the list soon, so that you can have a look at the
newest version of the patch set.

>
> Original patch:
> https://lore.kernel.org/all/[email protected]/
>
>
> On 30/09/2022 04:57, kernel test robot wrote:
> > tree: git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git next
> > head: 054fdc359167ae7c17a5fb47c0edbf5cb4b737b0
> > commit: 0052f28b7cba97cefa48623ef087d1c1cc06078f [4/9] security: create file_truncate hook from path_truncate hook
> > config: x86_64-rhel-8.3-func
> > compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
> > reproduce (this is a W=1 build):
> > # https://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git/commit/?id=0052f28b7cba97cefa48623ef087d1c1cc06078f
> > git remote add mic git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux.git
> > git fetch --no-tags mic next
> > git checkout 0052f28b7cba97cefa48623ef087d1c1cc06078f
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag where applicable
> > | Reported-by: kernel test robot <[email protected]>
> >
> > All errors (new ones prefixed by >>):
> >
> > ld: fs/open.o: in function `do_sys_ftruncate':
> > > > fs/open.c:191: undefined reference to `security_file_truncate'
> > ld: fs/namei.o: in function `handle_truncate':
> > > > fs/namei.c:3214: undefined reference to `security_file_truncate'
> >
> >
> > vim +191 fs/open.c
> >
> > 155
> > 156 long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
> > 157 {
> > 158 struct inode *inode;
> > 159 struct dentry *dentry;
> > 160 struct fd f;
> > 161 int error;
> > 162
> > 163 error = -EINVAL;
> > 164 if (length < 0)
> > 165 goto out;
> > 166 error = -EBADF;
> > 167 f = fdget(fd);
> > 168 if (!f.file)
> > 169 goto out;
> > 170
> > 171 /* explicitly opened as large or we are on 64-bit box */
> > 172 if (f.file->f_flags & O_LARGEFILE)
> > 173 small = 0;
> > 174
> > 175 dentry = f.file->f_path.dentry;
> > 176 inode = dentry->d_inode;
> > 177 error = -EINVAL;
> > 178 if (!S_ISREG(inode->i_mode) || !(f.file->f_mode & FMODE_WRITE))
> > 179 goto out_putf;
> > 180
> > 181 error = -EINVAL;
> > 182 /* Cannot ftruncate over 2^31 bytes without large file support */
> > 183 if (small && length > MAX_NON_LFS)
> > 184 goto out_putf;
> > 185
> > 186 error = -EPERM;
> > 187 /* Check IS_APPEND on real upper inode */
> > 188 if (IS_APPEND(file_inode(f.file)))
> > 189 goto out_putf;
> > 190 sb_start_write(inode->i_sb);
> > > 191 error = security_file_truncate(f.file);
> > 192 if (!error)
> > 193 error = do_truncate(file_mnt_user_ns(f.file), dentry, length,
> > 194 ATTR_MTIME | ATTR_CTIME, f.file);
> > 195 sb_end_write(inode->i_sb);
> > 196 out_putf:
> > 197 fdput(f);
> > 198 out:
> > 199 return error;
> > 200 }
> > 201
> >

--