[apparmor] [patch] fix "dictionary changed size during iteration" in cleanprof.py delete_net_duplicates()

Seth Arnold seth.arnold at canonical.com
Thu Sep 4 00:16:20 UTC 2014


On Thu, Sep 04, 2014 at 01:45:52AM +0200, Christian Boltz wrote:
> Hello,
> 
> this patch fixes "dictionary changed size during iteration" in 
> cleanprof.py delete_net_duplicates().
> 
> Full backtrace:
> 
> # python3 aa-mergeprof   /etc/apparmor.d/bin.ping /etc/apparmor.d/bin.ping
> Traceback (most recent call last):
>   File "aa-mergeprof", line 695, in <module>
>     main()
>   File "aa-mergeprof", line 53, in main
>     mergeprofiles.clear_common()
>   File "aa-mergeprof", line 126, in clear_common
>     deleted += user_base.compare_profiles()
>   File "/home/cb/apparmor/HEAD-CLEAN/utils/apparmor/cleanprofile.py", line 43, in compare_profiles
>     deleted += self.remove_duplicate_rules(profile)
>   File "/home/cb/apparmor/HEAD-CLEAN/utils/apparmor/cleanprofile.py", line 77, in remove_duplicate_rules
>     deleted += delete_net_duplicates(self.profile.aa[program][hat]['allow']['netdomain'], self.other.aa[program][hat]['allow']['netdomain'], self.same_file)
>   File "/home/cb/apparmor/HEAD-CLEAN/utils/apparmor/cleanprofile.py", line 147, in delete_net_duplicates
>     for sock_type in netrules_other['rule'][fam].keys():
> RuntimeError: dictionary changed size during iteration
> 

Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks

> 
> 
> === modified file 'utils/apparmor/cleanprofile.py'
> --- utils/apparmor/cleanprofile.py      2014-02-12 23:54:00 +0000
> +++ utils/apparmor/cleanprofile.py      2014-09-03 23:41:11 +0000
> @@ -144,7 +144,7 @@
>                          netrules_other['rule'].pop(fam)
>                          deleted += 1
>              else:
> -                for sock_type in netrules_other['rule'][fam].keys():
> +                for sock_type in list(netrules_other['rule'][fam].keys()):
>                      if netrules['rule'].get(fam, False):
>                          if netrules['rule'][fam].get(sock_type, False):
>                              if not same_profile:
> 
> 
> Regards,
> 
> Christian Boltz
> -- 
> The goal is simple: no more gnome related bugs in the 12.2 release :)  
> (ok, we ARE optimists).   [Dominique Leuenberger in opensuse-factory]
> 
> 
> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140903/2118f06d/attachment.pgp>


More information about the AppArmor mailing list